document.addEventListener("DOMContentLoaded",()=>{const T=document.querySelectorAll("[data-reveal]"),w=new IntersectionObserver(n=>{n.forEach(i=>{i.isIntersecting&&(i.target.classList.add("revealed"),w.unobserve(i.target))})},{rootMargin:"0px 0px -150px 0px",threshold:.1});T.forEach(n=>w.observe(n));const v=document.querySelector("nav");window.addEventListener("scroll",()=>{window.scrollY>50?(v.style.padding="0.75rem 0",v.style.background="rgba(15, 23, 42, 0.9)"):(v.style.padding="1rem 0",v.style.background="rgba(30, 41, 59, 0.7)")}),document.querySelectorAll('a[href^="#"]').forEach(n=>{n.addEventListener("click",function(i){i.preventDefault();const t=document.querySelector(this.getAttribute("href"));t&&t.scrollIntoView({behavior:"smooth",block:"start"})})});const k=()=>{const n=window.location.pathname.includes("join");let t=new URLSearchParams(window.location.search).get("dev");if(!t){const o=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash;t=new URLSearchParams(o).get("dev")}if(t||((window.location.hash.includes("devsuccess")||window.location.search.includes("devsuccess"))&&(t="success"),(window.location.hash.includes("devfailure")||window.location.search.includes("devfailure"))&&(t="failure")),n&&t){setTimeout(()=>{const o=document.getElementById("display-room-id"),e=document.getElementById("join-actions");o&&(o.textContent="DEV-ROOM"),e&&(e.innerHTML=`
Simulating connection (DEV)...Verbindung wird simuliert (DEV)...

Simulating status event in 1.5 seconds.Status-Event wird in 1,5 Sekunden simuliert.

`,setTimeout(()=>{window.dispatchEvent(new CustomEvent("KOALASYNC_STATUS",{detail:{success:t==="success",message:t==="failure"?"Simulated Connection Timeout!":""}}))},1500))},600);return}setTimeout(()=>{const o=document.documentElement.dataset.koalasyncInstalled==="true";if(window.location.hash.startsWith("#join:")){const e=window.location.hash.split(":");if(e.length>=3){const l=e[1],u=e[2],c=e[3]||"0",s=e[4]?decodeURIComponent(e[4]):"";if(n){const a=document.getElementById("display-room-id"),r=document.getElementById("join-actions");a&&(a.textContent=l),r&&(o?(r.innerHTML=`
Joining room automatically...Raum wird automatisch betreten...

Your extension is taking care of it.Deine Erweiterung k\xFCmmert sich darum.

`,setTimeout(()=>{window.dispatchEvent(new CustomEvent("KOALASYNC_JOIN_REQUEST",{detail:{roomId:l,password:u,useCustomServer:c==="1",serverUrl:s}}))},500)):navigator.userAgent.includes("Firefox")?r.innerHTML=`
Firefox GET IT ON MOZILLA ADD-ONSIM FIREFOX ADD-ON STORE HERUNTERLADEN Download via GitHub\xDCber GitHub herunterladen

The extension is required to join and sync videos. Die Erweiterung ist erforderlich, um beizutreten und Videos zu synchronisieren.

`:r.innerHTML=`
Chrome GET IT ON CHROME WEBSTOREIM CHROME WEB STORE HERUNTERLADEN Download via GitHub\xDCber GitHub herunterladen

The extension is required to join and sync videos. Die Erweiterung ist erforderlich, um beizutreten und Videos zu synchronisieren.

`)}else if(!document.getElementById("koala-banner")){const a=document.createElement("div");a.className="invite-banner",a.id="koala-banner";const r=document.createElement("div");r.className="container",r.style.cssText="display:flex; justify-content:space-between; align-items:center;";const d=document.createElement("span");d.appendChild(document.createTextNode("\u{1F3AB} Invitation for "));const m=document.createElement("b");m.textContent=l,d.appendChild(m),d.appendChild(document.createTextNode(" detected!"));const h=document.createElement("a");h.href="join"+window.location.hash,h.className="btn-banner",h.textContent="OPEN JOIN PAGE",r.appendChild(d),r.appendChild(h),a.appendChild(r),document.body.prepend(a)}document.addEventListener("click",a=>{a.target&&a.target.id==="webJoinBtn"&&(a.target.textContent="JOINING...",a.target.disabled=!0,window.dispatchEvent(new CustomEvent("KOALASYNC_JOIN_REQUEST",{detail:{roomId:l,password:u,useCustomServer:c==="1",serverUrl:s}})))})}}},600)};window.addEventListener("KOALASYNC_STATUS",n=>{const{success:i,message:t}=n.detail;if(window.location.pathname.includes("join")){const e=document.getElementById("join-status-icon"),l=document.getElementById("join-title"),u=document.getElementById("join-actions"),c=document.getElementById("join-desc"),s=document.getElementById("status-ring");if(i){s&&(s.classList.remove("active-pulse"),s.style.display="none"),e&&(e.innerHTML='Success',e.style.transform="scale(1)");const a=document.documentElement.classList.contains("lang-de");l.textContent=a?"Erfolgreich!":"Success!",c.innerHTML=a?'Verbunden!
W\xE4hle jetzt einen Video-Tab in der Erweiterung aus.':'Connected!
Now select a video tab in the extension.';let r=3;const d=()=>{r<=0?(window.close(),c.textContent=a?"Beitritt erfolgreich! Du kannst diesen Tab jetzt manuell schlie\xDFen.":"Joined successfully! You can close this tab manually."):(r--,setTimeout(d,1e3))};setTimeout(d,1e3);const m=a?"TAB JETZT SCHLIESSEN":"CLOSE TAB NOW";u.innerHTML=`
`}else{s&&(s.classList.remove("active-pulse"),s.style.display="none"),e&&(e.innerHTML=`Error`,e.style.transform="scale(1)");const a=document.documentElement.classList.contains("lang-de");l.textContent=a?"Fehler":"Error",c.textContent=a?`Beitritt fehlgeschlagen: ${t}`:`Join failed: ${t}`;const r=a?"ERNEUT VERSUCHEN":"TRY AGAIN";u.innerHTML=`
`}}else{const e=document.getElementById("koala-banner");if(e)if(i)e.style.background="var(--success)",e.innerHTML='
\u2705 Joined! This tab will close in 2s...
',setTimeout(()=>window.close(),2e3);else{e.style.background="var(--error)",e.innerHTML="";const l=document.createElement("div");l.className="container",l.textContent="\u274C Error: "+t,e.appendChild(l)}}});const C=async()=>{try{const n=document.documentElement.lang==="de"?"../version.json":"version.json",i=await fetch(n);if(!i.ok)return;const t=await i.json(),{version:o,date:e}=t;if(!o||!e)return;const l=new Date(e),c=new Date-l,s=Math.floor(c/(1e3*60*60*24)),a=Math.floor(c/(1e3*60*60)),r=Math.floor(c/(1e3*60));let d="",m="";s>0?(d=`${s} ${s===1?"day":"days"} ago`,m=`vor ${s} ${s===1?"Tag":"Tagen"}`):a>0?(d=`${a} ${a===1?"hour":"hours"} ago`,m=`vor ${a} ${a===1?"Stunde":"Stunden"}`):r>0?(d=`${r} ${r===1?"minute":"minutes"} ago`,m=`vor ${r} ${r===1?"Minute":"Minuten"}`):(d="just now",m="gerade eben");const h=document.querySelector(".version-text-en"),x=document.querySelector(".version-text-de");h&&(h.textContent=`v${o} OUT NOW \u2022 ${d}`),x&&(x.textContent=`v${o} JETZT VERF\xDCGBAR \u2022 ${m}`);const E=document.getElementById("schema-software");if(E)try{const y=JSON.parse(E.textContent);y.softwareVersion=o,E.textContent=JSON.stringify(y,null,2)}catch(y){console.warn("Failed to dynamically update schema version:",y)}}catch(n){console.warn("Failed to fetch dynamic version info:",n)}},b=document.querySelectorAll(".mock-tab"),A=document.querySelectorAll(".mock-screen");b.forEach(n=>{n.addEventListener("click",()=>{b.forEach(o=>o.classList.remove("active")),A.forEach(o=>o.classList.remove("active")),n.classList.add("active");const i=n.getAttribute("data-target"),t=document.getElementById(i);t&&t.classList.add("active")})});const L=document.querySelectorAll(".terminal-tab-btn"),I=document.querySelectorAll(".terminal-pane");L.forEach(n=>{n.addEventListener("click",()=>{L.forEach(o=>o.classList.remove("active")),I.forEach(o=>o.classList.remove("active")),n.classList.add("active");const i=n.getAttribute("data-tab"),t=document.getElementById(i);t&&t.classList.add("active")})});const g=document.querySelector(".terminal-copy-btn");g&&g.addEventListener("click",()=>{const n=document.querySelector(".terminal-pane.active");if(!n)return;const i=n.querySelector("code");if(!i)return;const t=i.innerText||i.textContent;navigator.clipboard.writeText(t).then(()=>{const o=document.documentElement.classList.contains("lang-de"),e=g.innerHTML;g.innerHTML=o?"\u2705 Kopiert!":"\u2705 Copied!",g.disabled=!0,setTimeout(()=>{g.innerHTML=e,g.disabled=!1},2e3)}).catch(o=>{console.error("Failed to copy text: ",o)})});const f=document.querySelector(".hamburger"),p=document.querySelector("#primary-nav");if(f&&p){f.setAttribute("aria-expanded","false");const n=()=>{p.classList.add("open"),f.setAttribute("aria-expanded","true"),document.addEventListener("keydown",o)},i=()=>{p.classList.remove("open"),f.setAttribute("aria-expanded","false"),document.removeEventListener("keydown",o)},t=()=>p.classList.contains("open")?i():n(),o=e=>{e.key==="Escape"&&i()};f.addEventListener("click",t),p.querySelectorAll("a").forEach(e=>e.addEventListener("click",i))}const S=()=>{const n=localStorage.getItem("koala_lang")||(navigator.language.startsWith("de")?"de":"en");window.location.pathname.split("/").some(e=>["de","fr","es","pt-BR","ru"].includes(e))||document.querySelectorAll('a[href="./"], a[href="de/"], a[href="fr/"], a[href="es/"], a[href="pt-BR/"], a[href="ru/"]').forEach(l=>{l.href=n==="en"?"./":`${n}/`})},B=n=>{const t=n.currentTarget.value,o=window.location.pathname;if(localStorage.setItem("koala_lang",t),!(o.includes("impressum")||o.includes("datenschutz")||o.includes("join"))){const c=o.split("/").some(a=>["de","fr","es","pt-BR","ru"].includes(a));let s;t==="en"?c?s="../":s="./":c?s="../"+t+"/":s=t+"/",window.location.href=s}else{const u=document.documentElement;u.classList.remove("lang-en","lang-de","lang-fr","lang-es","lang-pt-br","lang-ru");const c=t==="de"?"de":"en";if(u.classList.add("lang-"+c),u.lang=c,document.querySelectorAll(".lang-dropdown").forEach(a=>{a.value=t}),o.includes("join")){const a={en:"Join Room | KoalaSync",de:"Raum beitreten | KoalaSync"};document.title=a[c]||a.en}S()}};document.querySelectorAll(".lang-dropdown").forEach(n=>{n.addEventListener("change",B)});const j=()=>{const n=localStorage.getItem("koala_lang"),i=navigator.language.startsWith("de")?"de":"en",t=n||i;document.querySelectorAll(".lang-dropdown").forEach(o=>{o.value=t})};document.querySelectorAll(".email-reveal").forEach(n=>{n.addEventListener("click",function(){const i=this.getAttribute("data-user"),t=this.getAttribute("data-domain");i&&t&&(this.innerHTML=`${i}@${t}`)})}),(()=>{const n=navigator.userAgent.includes("Firefox"),i=navigator.userAgent.includes("Chrome")||navigator.userAgent.includes("Chromium"),t=document.querySelectorAll(".btn-primary"),o=document.querySelectorAll(".btn-firefox");n&&t.length>0&&o.length>0?(t.forEach(e=>{e.classList.remove("btn-primary"),e.classList.add("btn-secondary")}),o.forEach(e=>{e.style.order="-1",e.style.transform="scale(1.05)",e.addEventListener("mouseleave",()=>{e.style.transform="scale(1)"}),e.addEventListener("mouseenter",()=>{e.style.transform="scale(1.05) translateY(-2px)"})})):i&&t.length>0&&o.length>0&&o.forEach(e=>{e.classList.remove("btn-firefox"),e.classList.add("btn-secondary"),e.style.color="var(--text)",e.style.background="var(--card)",e.style.border="1px solid var(--glass-border)",e.style.boxShadow="none"}),setTimeout(()=>{const e=document.documentElement.dataset.koalasyncInstalled==="true",l=document.getElementById("nav-extension-status");e&&l&&(l.style.display="inline-flex");const u=document.querySelectorAll(".illus-store-btn.chrome"),c=document.querySelectorAll(".illus-store-btn.firefox");if(n&&c.length>0?(c.forEach(s=>{s.style.order="-1",e||(s.classList.add("install-breathe"),s.style.cursor="pointer",s.onclick=()=>window.open("https://addons.mozilla.org/de/firefox/addon/koalasync/","_blank"))}),u.forEach(s=>{s.style.opacity="0.5",s.style.transform="scale(0.95)"})):i&&u.length>0&&(u.forEach(s=>{s.style.order="-1",e||(s.classList.add("install-breathe"),s.style.cursor="pointer",s.onclick=()=>window.open("https://chromewebstore.google.com/detail/koalasync/obbnmkmlaaddodakcbdljknjpagklifc","_blank"))}),c.forEach(s=>{s.style.opacity="0.5",s.style.transform="scale(0.95)"})),!e){const s=document.querySelectorAll(n?".btn-firefox":i?".btn-primary":null);s&&s.length>0&&s.forEach(a=>{const d=a.classList.contains("btn-firefox")?"rgba(249, 115, 22, ":"rgba(99, 102, 241, ";a.animate([{transform:"scale(1)",boxShadow:`0 0 15px ${d}0.2)`},{transform:"scale(1.05)",boxShadow:`0 0 25px ${d}0.5)`},{transform:"scale(1)",boxShadow:`0 0 15px ${d}0.2)`}],{duration:2500,iterations:1/0,easing:"ease-in-out"})})}},600)})(),k(),C(),S(),j()});