"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 WriteResult_exports = {};
__export(WriteResult_exports, {
  WriteResult: () => WriteResult
});
module.exports = __toCommonJS(WriteResult_exports);
var import_ExpandedPath = require("#common/ExpandedPath.js");
var import_ExpandedStatus = require("#common/ExpandedStatus.js");
var import_PathError = require("#common/PathError.js");
var import_general = require("@matter/general");
var import_types = require("@matter/types");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var WriteResult;
((WriteResult2) => {
  function assertSuccess(result) {
    const errors = result.filter((attr) => attr.status !== import_types.Status.Success).map((attr) => {
      const path = (0, import_ExpandedPath.ExpandedPath)({ ...attr, kind: "attribute" });
      const status = new import_ExpandedStatus.ExpandedStatus(attr);
      return new import_PathError.PathError({ path, status });
    });
    if (!errors.length) {
      return;
    }
    if (errors.length === 1) {
      throw errors[0];
    }
    throw new import_general.MatterAggregateError(errors, "Multiple writes failed");
  }
  WriteResult2.assertSuccess = assertSuccess;
})(WriteResult || (WriteResult = {}));
//# sourceMappingURL=WriteResult.js.map
