/* Shared helpers + header/nav for every ProjectOS wallet page. */ const $ = (id) => document.getElementById(id); const fmt = (minor, cur = "usd") => new Intl.NumberFormat(undefined, { style: "currency", currency: cur.toUpperCase() }).format(minor / 100); const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c])); async function api(path, opts = {}) { const o = { credentials: "same-origin", ...opts }; if (o.body && typeof o.body !== "string") { o.body = JSON.stringify(o.body); o.headers = { "content-type": "application/json", ...(o.headers || {}) }; } let r; try { r = await fetch(path, o); } catch { return { ok: false, status: 0, body: { error: "Network error: could not reach the server." } }; } let body = {}; try { body = await r.json(); } catch {} return { ok: r.ok, status: r.status, body }; } function msg(el, cls, text) { el.className = "msg " + cls; el.textContent = text; } const NAV = [["/", "Wallet"], ["/devices", "Devices"], ["/settings", "Settings"]]; function renderHeader() { const here = location.pathname.replace(/\/$/, "") || "/"; const links = NAV.map(([h, t]) => `${t}`).join(""); $("top").innerHTML = `◆ProjectOS