"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var DecodedDataReport_exports = {};
__export(DecodedDataReport_exports, {
  DecodedDataReport: () => DecodedDataReport
});
module.exports = __toCommonJS(DecodedDataReport_exports);
var import_AttributeDataDecoder = require("./AttributeDataDecoder.js");
var import_EventDataDecoder = require("./EventDataDecoder.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function DecodedDataReport(report, leftoverAttributeReports) {
  if (report.isNormalized) {
    if (leftoverAttributeReports !== void 0 && leftoverAttributeReports.length > 0) {
      throw new Error("Cannot provide leftoverAttributeReports for already normalized DecodedDataReport");
    }
    return report;
  }
  if (leftoverAttributeReports !== void 0 && leftoverAttributeReports.length > 0) {
    if (report.attributeReports === void 0) {
      report.attributeReports = [...leftoverAttributeReports];
    } else {
      report.attributeReports = [...leftoverAttributeReports, ...report.attributeReports];
    }
    leftoverAttributeReports.length = 0;
  }
  const { attributeData: attributeReports, attributeStatus } = report.attributeReports === void 0 ? { attributeData: [] } : (0, import_AttributeDataDecoder.normalizeAndDecodeReadAttributeReport)(
    report.attributeReports,
    report.moreChunkedMessages ? leftoverAttributeReports : void 0
  );
  const { eventData: eventReports, eventStatus } = report.eventReports === void 0 ? { eventData: [] } : (0, import_EventDataDecoder.normalizeAndDecodeReadEventReport)(report.eventReports);
  return {
    ...report,
    isNormalized: true,
    attributeReports,
    attributeStatus,
    eventReports,
    eventStatus
  };
}
//# sourceMappingURL=DecodedDataReport.js.map
