/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ExpandedPath } from "#common/ExpandedPath.js";
import { ExpandedStatus } from "#common/ExpandedStatus.js";
import { PathError } from "#common/PathError.js";
import { MatterAggregateError } from "@matter/general";
import {
  Status
} from "@matter/types";
var WriteResult;
((WriteResult2) => {
  function assertSuccess(result) {
    const errors = result.filter((attr) => attr.status !== Status.Success).map((attr) => {
      const path = ExpandedPath({ ...attr, kind: "attribute" });
      const status = new ExpandedStatus(attr);
      return new PathError({ path, status });
    });
    if (!errors.length) {
      return;
    }
    if (errors.length === 1) {
      throw errors[0];
    }
    throw new MatterAggregateError(errors, "Multiple writes failed");
  }
  WriteResult2.assertSuccess = assertSuccess;
})(WriteResult || (WriteResult = {}));
export {
  WriteResult
};
//# sourceMappingURL=WriteResult.js.map
