/* Click-to-load embed facades. HF Space iframes load only after a click (which also records the "demos" consent for the session) — no third-party frames, no cookies, before that. */ (function () { window.addEventListener('DOMContentLoaded', function () { document.querySelectorAll('.embed-facade').forEach(function (f) { f._orig = f.innerHTML; // kept so the facade can collapse back (accordion behaviour) function collapseOthers() { document.querySelectorAll('.embed-facade.loaded').forEach(function (o) { if (o === f) return; o.classList.remove('loaded'); o.removeAttribute('data-loaded'); o.innerHTML = o._orig || ''; }); } function load() { if (f.getAttribute('data-loaded') === '1') return; var src = f.getAttribute('data-src'); if (!src) { // e.g. simulator while not PRO → go buy Pro Access if (f.id === 'facade-sim') location.href = 'pricing.html#pro'; return; } f.setAttribute('data-loaded', '1'); try { var c = window.Consent && window.Consent.get(); if (c) window.Consent.set({ analytics: c.analytics, demos: true }); } catch (e) {} collapseOthers(); var ifr = document.createElement('iframe'); ifr.src = src; ifr.loading = 'lazy'; ifr.title = f.getAttribute('data-title') || 'demo'; ifr.setAttribute('allow', 'autoplay; fullscreen; microphone; clipboard-write'); ifr.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-downloads allow-popups'); f.innerHTML = ''; f.appendChild(ifr); f.classList.add('loaded'); f.scrollIntoView({ behavior: 'smooth', block: 'center' }); } // delegation so restored facades keep working after a collapse f.addEventListener('click', function (e) { if (e.target.closest('button') || e.target === f) load(); }); // if the visitor already accepted demo embeds, load the demo as soon as its section scrolls in if ('IntersectionObserver' in window) { var io = new IntersectionObserver(function (entries) { entries.forEach(function (en) { if (!en.isIntersecting) return; io.unobserve(f); try { var c = window.Consent && window.Consent.get(); if (c && c.demos) load(); } catch (e) {} }); }, { threshold: 0.25 }); io.observe(f); } }); }); })();