const KEY = "context.sidebar";
/** The rail or the full sidebar, as the clinician last chose; wide screens start full. */
export function readCollapsed(): boolean {
try {
const saved = localStorage.getItem(KEY);
if (saved === "rail" || saved === "full") return saved === "rail";
} catch {
// Storage can be blocked (private windows); fall back to the screen width.
}
try {
return !window.matchMedia("(min-width: 1280px)").matches;
} catch {
return false;
}
}
export function saveCollapsed(collapsed: boolean) {
try {
localStorage.setItem(KEY, collapsed ? "rail" : "full");
} catch {
// Not saved: the choice lasts until the page reloads.
}
}