/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { RootSupervisor } from "#behavior/supervision/RootSupervisor.js";
import { NotImplementedError } from "#general";
import { any } from "#model";
import { Envelope } from "./Envelope.js";
class ApiResource {
  /**
   * The item's owner, if any.
   */
  parent;
  /**
   * Indicates whether this is an RPC endpoint.
   */
  isInvocable = false;
  /**
   * Indicates whether this is an event endpoint.
   */
  isSubscribable = false;
  constructor(parent) {
    this.parent = parent;
  }
  /**
   * Retrieve the body of the item.
   */
  read() {
    if (this.value === void 0) {
      return;
    }
    return new Envelope({
      supervisor: this.supervisor ?? RootSupervisor.for(any),
      js: this.value
    });
  }
  /**
   * Create or replace item.
   */
  write(_request) {
    throw new NotImplementedError();
  }
  /**
   * Update item using matter.js patch semantics.
   */
  patch(_request) {
    throw new NotImplementedError();
  }
  /**
   * Add a child item of this item.
   */
  add(_request) {
    throw new NotImplementedError();
  }
  /**
   * Remove this item.
   */
  delete() {
    throw new NotImplementedError();
  }
  /**
   * The {@link Schema} for this resource subtree.
   */
  get schema() {
    return this.supervisor?.schema;
  }
  /**
   * Obtain the appropriate {@link ValueSupervisor} for a {@link Schema} in this subtree.
   */
  supervisorFor(schema) {
    return this.rootSupervisor?.get(schema) ?? RootSupervisor.for(schema);
  }
  /**
   * The {@link RootSupervisor} for this resource subtree.
   */
  get rootSupervisor() {
    return this.parent?.rootSupervisor;
  }
  /**
   * Execute a procedure.
   */
  async invoke(_request) {
    throw new NotImplementedError();
  }
  /**
   * Subscribe to events.
   */
  // eslint-disable-next-line require-yield
  async *subscribe(_abort, _request) {
    throw new NotImplementedError();
  }
  /**
   * Retrieve a child with the specified ID.
   */
  async childFor(_id) {
    return void 0;
  }
}
export {
  ApiResource
};
//# sourceMappingURL=ApiResource.js.map
