import { createAtom, toObserver } from "./atom.js";
class Store {
  constructor(valueOrFn) {
    this.atom = createAtom(
      valueOrFn
    );
  }
  setState(updater) {
    this.atom.set(updater);
  }
  get state() {
    return this.atom.get();
  }
  get() {
    return this.state;
  }
  subscribe(observerOrFn) {
    return this.atom.subscribe(toObserver(observerOrFn));
  }
}
class ReadonlyStore {
  constructor(valueOrFn) {
    this.atom = createAtom(
      valueOrFn
    );
  }
  get state() {
    return this.atom.get();
  }
  get() {
    return this.state;
  }
  subscribe(observerOrFn) {
    return this.atom.subscribe(toObserver(observerOrFn));
  }
}
function createStore(valueOrFn) {
  if (typeof valueOrFn === "function") {
    return new ReadonlyStore(valueOrFn);
  }
  return new Store(valueOrFn);
}
export {
  ReadonlyStore,
  Store,
  createStore
};//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/e0b7a2bcf575cfba10528c4e7c10bd3ce2d7769a/node_modules/@tanstack/store/dist/esm/store.js.map
