/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import {
  normalizeAndDecodeReadAttributeReport
} from "./AttributeDataDecoder.js";
import {
  normalizeAndDecodeReadEventReport
} from "./EventDataDecoder.js";
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: [] } : normalizeAndDecodeReadAttributeReport(
    report.attributeReports,
    report.moreChunkedMessages ? leftoverAttributeReports : void 0
  );
  const { eventData: eventReports, eventStatus } = report.eventReports === void 0 ? { eventData: [] } : normalizeAndDecodeReadEventReport(report.eventReports);
  return {
    ...report,
    isNormalized: true,
    attributeReports,
    attributeStatus,
    eventReports,
    eventStatus
  };
}
export {
  DecodedDataReport
};
//# sourceMappingURL=DecodedDataReport.js.map
