// data.jsx — fallback shapes + small utilities used across screens.
// Live data is provided by store.jsx via useStore(); this module only exists
// so legacy references to MS_DATA / byId don't blow up before the store
// hydrates and so a few mock-only collections (TASKS, INBOX) still render —
// those are not yet wired to the backend.

const MS_DATA_EMPTY = {
  PROVIDERS: [],
  PATIENTS: [],
  APPOINTMENTS: [],
  todayISO: new Date().toISOString().slice(0, 10),
};

// Mock-only collections that don't have backend equivalents yet.
const MOCK_TASKS = [
  { id: "t1", kind: "labs", text: "Sign off on outstanding lab results", urgent: true },
  { id: "t2", kind: "rx",   text: "Refill request — Albuterol", urgent: false },
  { id: "t3", kind: "msg",  text: "Patient message awaiting reply", urgent: false },
  { id: "t4", kind: "doc",  text: "Sign encounter notes from yesterday", urgent: false },
];

const MOCK_INBOX = [
  { id: "m1", from: "Patient",  preview: "Quick question about my prescription…", time: "12 min", unread: true,  kind: "patient" },
  { id: "m2", from: "Lab",      preview: "Lab results are ready",                  time: "1 h",   unread: true,  kind: "lab" },
  { id: "m3", from: "Pharmacy", preview: "Refill authorization needed",            time: "3 h",   unread: false, kind: "rx" },
];

window.MS_DATA = Object.assign({}, MS_DATA_EMPTY, { TASKS: MOCK_TASKS, INBOX: MOCK_INBOX });
window.byId = (arr, id) => (arr || []).find(x => x && x.id === id) || null;
