import { useEffect, useState } from 'react'; /* Simple mode: the test run page as one guided column (the current step only, the rest folded away), for people new to the app. Each person switches it in the account menu; the choice stays in this browser. */ const KEY = 'pw.simple'; const EVT = 'pw-simple'; export const simpleModeOn = () => { try { return window.localStorage.getItem(KEY) === 'on'; } catch { return false; } }; export function setSimpleMode(on: boolean) { try { window.localStorage.setItem(KEY, on ? 'on' : 'off'); } catch { /* storage blocked: the choice lasts this page */ } window.dispatchEvent(new Event(EVT)); } export function useSimpleMode() { const [on, setOn] = useState(simpleModeOn); useEffect(() => { const f = () => setOn(simpleModeOn()); window.addEventListener(EVT, f); return () => window.removeEventListener(EVT, f); }, []); return on; }