/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Agent } from "#endpoint/Agent.js"; import { Endpoint } from "#endpoint/Endpoint.js"; import { MutableSet } from "@matter/general"; import { Behavior } from "../../Behavior.js"; /** * Provides access to child endpoints. */ export class PartsBehavior extends Behavior implements MutableSet { static override readonly id = "parts"; add(child: Endpoint.Definition | Agent) { this.endpoint.parts.add(child); } /** * @deprecated Always throws; remove the endpoint with {@link Endpoint.close} or {@link Endpoint.delete}. */ delete(child: Endpoint | Agent): never { return this.endpoint.parts.delete(child); } /** * @deprecated Always throws; remove each endpoint with {@link Endpoint.close} or {@link Endpoint.delete}. */ clear(): never { return this.endpoint.parts.clear(); } has(child: Endpoint | Agent) { return this.endpoint.parts.has(child); } indexOf(child: Endpoint | Agent) { return this.endpoint.parts.indexOf(child); } *[Symbol.iterator]() { for (const part of this.endpoint.parts) { yield part.agentFor(this.context); } } }