// ============================================================
// UI STATE — sub-pill / sub-tab persistence across browser restart
// ============================================================
// Tab-level selection (ped_last_tab) is handled in app.js. This file
// persists the finer-grained choices that would otherwise reset to
// defaults when the user closes the browser, signs out / back in, or
// reloads the page — because _componentCache is in-memory and cleared
// on reload.
//
// All keys live under the "ped_ui/" namespace in localStorage so they
// are easy to enumerate and clear. Reads and writes are wrapped in
// try/catch — localStorage can throw in some contexts (Safari private
// mode, storage quotas), and a persistence failure must never break
// the UI.
// ============================================================

var PREFIX = 'ped_ui/';

function get(key) {
  try { return localStorage.getItem(PREFIX + key); } catch (e) { return null; }
}
function set(key, value) {
  try { localStorage.setItem(PREFIX + key, value); } catch (e) {}
}
function del(key) {
  try { localStorage.removeItem(PREFIX + key); } catch (e) {}
}

window.UIState = {
  get: get,
  set: set,
  del: del,
};
