// src/store/index.ts
function createDatabaseProvider(options = {}) {
  const message = options.notReadyMessage ?? "Database not initialized \u2014 call setDatabase() first.";
  let current = null;
  const db = new Proxy({}, {
    get(_target, prop) {
      if (!current) throw new Error(message);
      const value = current[prop];
      return typeof value === "function" ? value.bind(current) : value;
    },
    has(_target, prop) {
      return current !== null && prop in current;
    }
  });
  return {
    db,
    setDatabase(database) {
      current = database;
    },
    isReady() {
      return current !== null;
    },
    reset() {
      current = null;
    }
  };
}
function createInMemoryKV(initial) {
  const store = new Map(
    initial ? Object.entries(initial).map(([k, v]) => [k, { value: v, metadata: null }]) : []
  );
  return {
    async get(key) {
      return store.get(key)?.value ?? null;
    },
    async getWithMetadata(key) {
      const entry = store.get(key);
      return { value: entry?.value ?? null, metadata: entry?.metadata ?? null };
    },
    async put(key, value, options) {
      store.set(key, { value, metadata: options?.metadata ?? null });
    },
    async delete(key) {
      store.delete(key);
    },
    async list(options) {
      const prefix = options?.prefix ?? "";
      const keys = [...store.keys()].filter((k) => k.startsWith(prefix)).sort().map((name) => ({ name }));
      return { keys, list_complete: true };
    }
  };
}
export {
  createDatabaseProvider,
  createInMemoryKV
};
//# sourceMappingURL=index.js.map