"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 EndpointResource_exports = {};
__export(EndpointResource_exports, {
  EndpointResource: () => EndpointResource
});
module.exports = __toCommonJS(EndpointResource_exports);
var import_general = require("#general");
var import_ApiResource = require("../ApiResource.js");
var import_BehaviorResource = require("./BehaviorResource.js");
var import_EndpointContainerResource = require("./EndpointContainerResource.js");
/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class EndpointResource extends import_ApiResource.ApiResource {
  agent;
  supervisor;
  constructor(agent, parent) {
    super(parent);
    this.agent = agent;
  }
  get valueKind() {
    return "endpoint";
  }
  get id() {
    return this.agent.endpoint.id;
  }
  get dataModelPath() {
    return this.agent.endpoint.path;
  }
  get value() {
    return this.agent.endpoint.state;
  }
  async childFor(name) {
    if (name === "parts") {
      return new import_EndpointContainerResource.EndpointContainerResource(
        this,
        "parts",
        () => this.agent.endpoint.parts.map((part) => part.id),
        (name2) => {
          const part = this.agent.endpoint.parts.get(name2);
          if (part) {
            return new EndpointResource(part.agentFor(this.agent.context), this);
          }
        }
      );
    }
    name = (0, import_general.camelize)(name);
    const { supported } = this.agent.endpoint.behaviors;
    if (name in supported) {
      const type = supported[name];
      const behavior = this.agent.get(type);
      if (behavior.type.schema === void 0) {
        return;
      }
      return new import_BehaviorResource.BehaviorResource(behavior, this);
    }
  }
}
//# sourceMappingURL=EndpointResource.js.map
