// Shared observable store: one state object, subscribe for changes, set() to // patch. Views read state and re-render on notify. Nothing here touches the URL // (the router owns navigable state) or the network (the api client owns that) — // this is only the in-memory glue between them. export function createStore(initial = {}) { let state = { ...initial }; const listeners = new Set(); function set(patch) { const next = typeof patch === "function" ? patch(state) : patch; state = { ...state, ...next }; for (const listener of listeners) listener(state); } return { get: () => state, set, subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); }, }; }