/* GoldenPharm site — Tweaks controller. Applies tweak values to CSS custom properties on , syncs across the separate page files via localStorage, and persists through the host. */ const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{ "accent": "#1b5c9b", "buttonShape": "pill", "headlineStyle": "two-tone", "density": "regular" }/*EDITMODE-END*/; const GP_ACCENT_MAP = { '#1b5c9b': { accent: '#1b5c9b', strong: '#123459', light: '#418ac1', soft: '#eef5fb' }, '#418ac1': { accent: '#2a6fb0', strong: '#16456f', light: '#79addb', soft: '#eef5fb' }, '#123459': { accent: '#123459', strong: '#0c2742', light: '#2a6fb0', soft: '#eef3f8' }, }; function applyTweaks(t) { const r = document.documentElement; const a = GP_ACCENT_MAP[t.accent] || GP_ACCENT_MAP['#1b5c9b']; r.style.setProperty('--accent', a.accent); r.style.setProperty('--accent-strong', a.strong); r.style.setProperty('--accent-light', a.light); r.style.setProperty('--accent-soft', a.soft); r.style.setProperty('--btn-radius', t.buttonShape === 'rounded' ? '10px' : '999px'); r.style.setProperty('--rhythm', t.density === 'comfy' ? '120px' : t.density === 'compact' ? '72px' : '96px'); r.setAttribute('data-headline', t.headlineStyle); } function TweaksController() { const [t, setT] = React.useState(() => { try { const s = JSON.parse(localStorage.getItem('gp_tweaks') || 'null'); return { ...TWEAK_DEFAULTS, ...(s || {}) }; } catch (e) { return TWEAK_DEFAULTS; } }); React.useLayoutEffect(() => { applyTweaks(t); }, [t]); const set = (k, v) => { setT((prev) => { const next = { ...prev, [k]: v }; try { localStorage.setItem('gp_tweaks', JSON.stringify(next)); } catch (e) {} window.parent.postMessage({ type: '__edit_mode_set_keys', edits: { [k]: v } }, '*'); return next; }); }; const { TweaksPanel, TweakSection, TweakColor, TweakRadio } = window; return ( set('accent', v)} /> set('buttonShape', v)} /> set('headlineStyle', v)} /> set('density', v)} /> ); } window.TweaksController = TweaksController; window.applyTweaks = applyTweaks;