// App-wide "hints" toggle: when on, Tooltip components reveal short explanatory
// captions on hover so the UI is somewhat self-documenting for new users. Experienced
// users can turn it off in Settings. Persisted to localStorage (+ server preferences).
import { createStore } from "./store";
import { getAccountRaw, LS, setAccountRaw } from "./storage";

function load(): boolean {
  return getAccountRaw(LS.hints) !== "0"; // default ON (also when the account isn't known yet)
}

const store = createStore<boolean>(load());

export const hintsEnabled = store.get;
export const subscribeHints = store.subscribe;

export function setHintsEnabled(v: boolean): void {
  store.set(v);
  setAccountRaw(LS.hints, v ? "1" : "0");
}
