"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 ControllerStore_exports = {};
__export(ControllerStore_exports, {
  ControllerStore: () => ControllerStore,
  ControllerStoreInterface: () => ControllerStoreInterface
});
module.exports = __toCommonJS(ControllerStore_exports);
var import_general = require("@matter/general");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class ControllerStore {
  #storageManager;
  #sessionStorage;
  #caStorage;
  // Root certificate and Fabric
  #nodesStorage;
  // Holds a list of nodes in the root level and then sublevels with data per client node?
  /**
   * Create a new store.
   *
   * TODO - implement conversion from 0.7 format so people can change API seamlessly
   */
  constructor(nodeId, storageManager) {
    if (nodeId === void 0) {
      throw new import_general.ImplementationError("ServerStore must be created with a nodeId");
    }
    this.#storageManager = storageManager;
  }
  async erase() {
    await this.#sessionStorage?.clearAll();
    await this.#caStorage?.clearAll();
    await this.#nodesStorage?.clearAll();
  }
  async close() {
  }
  get sessionStorage() {
    if (!this.#sessionStorage) {
      this.#sessionStorage = this.storage.createContext("sessions");
    }
    return this.#sessionStorage;
  }
  get caStorage() {
    if (!this.#caStorage) {
      this.#caStorage = this.storage.createContext("credentials");
    }
    return this.#caStorage;
  }
  get nodesStorage() {
    if (this.#nodesStorage === void 0) {
      this.#nodesStorage = this.storage.createContext("nodes");
    }
    return this.#nodesStorage;
  }
  get fabricStorage() {
    return this.caStorage;
  }
  get storage() {
    if (this.#storageManager === void 0) {
      throw new import_general.ImplementationError("Node storage accessed prior to initialization");
    }
    return this.#storageManager;
  }
  async clientNodeStore(nodeId) {
    return this.storage.createContext(`node-${nodeId}`);
  }
}
class ControllerStoreInterface {
}
//# sourceMappingURL=ControllerStore.js.map
