/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ImplementationError, MatterError } from "../MatterError.js";
import { MaybePromise } from "../util/Promises.js";
class StorageError extends MatterError {
}
class Storage {
  /**
   * Checks if a key exists in the storage for the given contexts.
   * Important Note: This default implementation just reads the value for the key and checks if it is undefined.
   * Please implement this method in your storage implementation if you want to optimize it.
   */
  has(contexts, key) {
    const value = this.get(contexts, key);
    if (MaybePromise.is(value)) {
      return MaybePromise.then(value, (v) => v !== void 0);
    }
    return value !== void 0;
  }
}
var CloneableStorage;
((CloneableStorage2) => {
  function is(storage) {
    return "clone" in storage && typeof storage.clone === "function";
  }
  CloneableStorage2.is = is;
  function assert(storage) {
    if (!is(storage)) {
      throw new ImplementationError("Storage does not support required snapshotting function");
    }
  }
  CloneableStorage2.assert = assert;
})(CloneableStorage || (CloneableStorage = {}));
export {
  CloneableStorage,
  Storage,
  StorageError
};
//# sourceMappingURL=Storage.js.map
