(() => {
const { VHHome, VHBooking, VHOmgeving, VHGastenmap, VHGastomgeving, VHUnit } = window;
const TEMPLATES = [['alpenlicht', 'Alpenlicht'], ['hutte', 'Hütte'], ['raster', 'Raster'], ['zomerdal', 'Zomerdal'], ['boutique', 'Boutique'], ['spinnaker', 'Spinnaker'], ['longboard', 'Longboard']];
const SCREENS = [['home', 'Home'], ['appartement', 'Appartement'], ['boeken', 'Boeken'], ['omgeving', 'Omgeving'], ['gastenmap', 'Gastenmap'], ['gastomgeving', 'Gastomgeving']];
const LIGHT_SCREENS = ['boeken', 'gastenmap', 'gastomgeving'];
const KEY = window.vhS('storageKey', 'vh-trattenbach-demo');
const BAR = window.vhS('bar', true), FIXED_TPL = window.vhS('tpl', null);
const load = () => { try { return JSON.parse(localStorage.getItem(KEY) || '{}'); } catch (e) { return {}; } };
function Seg({ label, opts, v, set }) {
  return <label style={{ display: 'flex', alignItems: 'center', gap: 6 }}><span style={{ opacity: .7 }}>{label}</span>
    <select value={v} onChange={e => set(e.target.value)} style={{ height: 30, background: '#2a2a2a', color: '#fff', border: '1px solid #444', borderRadius: 6, font: '500 13px system-ui', padding: '0 6px' }}>{opts.map(([k, l]) => <option key={k} value={k}>{l}</option>)}</select></label>;
}
function App() {
  const [s, setS] = React.useState({ tpl: 'alpenlicht', screen: 'home', device: window.innerWidth < 700 ? 'mobile' : 'desktop', season: 'winter', ...load() });
  if (FIXED_TPL) s.tpl = FIXED_TPL;
  if (window.vhS('season', null)) s.season = window.vhS('season', null);
  if (!BAR) s.device = window.innerWidth < 700 ? 'mobile' : 'desktop';
  if (!s.lang) s.lang = window.VH_I18N.pickLang();
  window.VH_I18N.setLang(s.lang);
  const set = k => v => setS(o => ({ ...o, [k]: v }));
  React.useEffect(() => { try { localStorage.setItem(KEY, JSON.stringify(s)); } catch (e) {} }, [s]);
  const house = window.vhHouse();
  const [unit, setUnit] = React.useState(window.vhS('unit', 'Boven groot'));
  let theme = s.tpl;
  if (theme === 'hutte' && LIGHT_SCREENS.includes(s.screen)) theme = 'hutte-licht';
  if (theme === 'zomerdal' && s.season === 'winter') theme = 'zomerdal-winter';
  const m = s.device === 'mobile';
  const [vw, setVw] = React.useState(window.innerWidth);
  React.useEffect(() => { const f = () => setVw(window.innerWidth); window.addEventListener('resize', f); return () => window.removeEventListener('resize', f); }, []);
  const n = !m && vw < 1100;
  const scroller = React.useRef(null);
  const onNav = sc => { set('screen')(sc); if (scroller.current) scroller.current.scrollTop = 0; window.scrollTo(0, 0); };
  const props = { m, n, house, lang: s.lang, setLang: set('lang'), onNav, empty: false, few: false, unit, setUnit };
  const Locked = () => <div style={{ minHeight: '70vh', display: 'grid', placeItems: 'center', padding: 24, background: 'var(--surface-page)' }}><div style={{ maxWidth: 560, display: 'flex', flexDirection: 'column', gap: 16, padding: 32, background: 'var(--surface-card)', border: 'var(--border-card)', borderRadius: 'var(--radius-lg)', boxShadow: 'var(--shadow-card)', color: 'var(--text-1)' }}><h2 style={{ fontSize: 28 }}>Dit is een voorbeeld</h2><p style={{ fontSize: 17, color: 'var(--text-2)' }}>Op deze demo kun je nog niet boeken. De echte site gaat pas open als de vergunning en het registratienummer rond zijn.</p><div><button onClick={() => onNav('home')} style={{ minHeight: 44, padding: '0 20px', borderRadius: 'var(--radius-btn)', border: 0, background: 'var(--accent)', color: 'var(--on-accent)', fontWeight: 600, fontSize: 16, cursor: 'pointer' }}>Terug naar het huis</button></div></div></div>;
  const Screen = { home: VHHome, appartement: VHUnit, boeken: VHBooking, omgeving: VHOmgeving, gastenmap: VHGastenmap, gastomgeving: VHGastomgeving }[s.screen];
  const page = <div data-template={theme} style={{ minHeight: '100%' }}><Screen {...props} /></div>;
  const narrowPhone = vw < 430 || !BAR;
  return <div style={{ minHeight: '100vh', background: m && !narrowPhone ? '#d9d9d6' : 'transparent' }}>
    {BAR && <div style={{ position: 'sticky', top: 0, zIndex: 100, background: '#161616', color: '#fff', font: '500 13px system-ui' }}>
      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 14, alignItems: 'center', padding: '8px 14px' }}>
        <strong style={{ marginRight: 4 }}>Trattenbach 21</strong>
        <Seg label="Template" opts={TEMPLATES} v={s.tpl} set={set('tpl')} />
        <Seg label="Scherm" opts={SCREENS} v={s.screen} set={onNav} />
        {!narrowPhone && <Seg label="Apparaat" opts={[['desktop', 'Desktop'], ['mobile', 'Mobiel 390']]} v={s.device} set={set('device')} />}
        {s.tpl === 'zomerdal' && <Seg label="Seizoen" opts={[['zomer', 'Zomer'], ['winter', 'Winter']]} v={s.season} set={set('season')} />}
      </div>
    </div>}
    {m && !narrowPhone ? <div style={{ display: 'flex', justifyContent: 'center', padding: '24px 0 40px' }}>
      <div ref={scroller} style={{ width: 390, height: 844, overflow: 'auto', borderRadius: 36, boxShadow: '0 0 0 10px #111, 0 30px 60px rgba(0,0,0,.3)', background: '#fff' }}>{page}</div>
    </div> : page}
  </div>;
}
ReactDOM.createRoot(document.getElementById('root')).render(<App />);
})();
