import{J as D,K as g,a as y,b as s,c as h}from"./chunk-mp8cvhyn.js";import{T as u,U as v,W as a}from"./chunk-yffrxdym.js";import{_}from"./chunk-q07bg6gn.js";class m{static async load(t){if(!("fonts"in document))return console.warn("Font Loading API not supported in this browser"),[];if(!t||t.length===0)return[];let e=t.map((i)=>{let n=`${i.style||"normal"} ${i.weight} 1em "${i.family}"`;return document.fonts.load(n)});try{let i=await Promise.all(e);if(u.IS_DEV)console.log(`✅ Loaded ${t.length} font(s)`);return i.flat()}catch(i){throw console.error("Font loading failed:",i),Error(`Font loading failed: ${i}`)}}static async loadWithTimeout(t,e=5000){let i=new Promise((o,n)=>{setTimeout(()=>{n(Error(`Font loading timeout after ${e}ms`))},e)});try{return await Promise.race([this.load(t),i])}catch(o){if(u.IS_DEV)console.warn("⚠️ Font loading timeout - continuing anyway");return[]}}static check(t,e=400){if(!("fonts"in document))return!1;return document.fonts.check(`${e} 1em "${t}"`)}static async ready(){if(!("fonts"in document))return;await document.fonts.ready}static get status(){if(!("fonts"in document))return"unsupported";return document.fonts.status}}var E='img[loading="lazy"][srcset]:not([data-auto-sizes="off"])',T="auto, 100vw";function F(t){let e=t.dataset.autoSizes?.trim();if(!e||e==="off")return T;return e}function p(t){if(!t.matches(E))return;let e=F(t);if(t.sizes===e)return;t.sizes=e}function w(t){if(t instanceof HTMLImageElement){p(t);return}if(!(t instanceof Element)&&!(t instanceof Document))return;t.querySelectorAll(E).forEach(p)}class b{#t=null;#e=!1;init(){y((t)=>{if(this.#e=t,t){this.destroy();return}this.#i()})}#i(){if(this.#e||this.#t)return;w(document),this.#t=new MutationObserver((t)=>{t.forEach((e)=>{if(e.type==="attributes"){let i=e.target;if(i instanceof HTMLImageElement)p(i);return}e.addedNodes.forEach((i)=>{if(i instanceof Element)w(i)})})}),this.#t.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["loading","srcset","data-auto-sizes"]})}destroy(){this.#t?.disconnect(),this.#t=null}}var f=new b;var V=300000;class k{#t=new Map;#e="idle";#i=null;#o=null;#n=null;#r=null;#s=null;#a=null;constructor(){this.#i=performance.now(),this.#l()}async#l(){if(this.#e!=="idle")throw Error("App already initialized");this.#e="initializing";try{this.#d(),this.#c(),this.#u(),this.#m(),this.#t.set("scroll",h),this.#t.set("pages",g),f.init(),this.#t.set("responsiveImages",f),await this.#p(),await D(),this.#e="ready",this.#f(),this.#h()}catch(t){this.#e="failed",this.#g(t)}}async#w(){return}async#d(){if(a.EAGER.length===0)return;try{await m.loadWithTimeout(a.EAGER,a.OPTIONS.timeout)}catch(t){console.warn("⚠️ Font loading failed:",t)}}#c(){try{s.init(),this.#t.set("viewport",s)}catch(t){throw console.error("❌ Viewport initialization failed:",t),t}}#u(){let t=(e)=>e==="desktop"||e==="large";this.#r=(e)=>{let{from:i,to:o}=e.detail;if(i===null)return;if(t(i)===t(o))return;window.location.reload()},window.addEventListener("breakpoint:change",this.#r)}#m(){let t=()=>this.#n!==null&&Date.now()-this.#n>V;this.#s=()=>{if(document.visibilityState==="hidden"){this.#n=Date.now();return}let e=t();if(this.#n=null,e)window.location.reload()},this.#a=(e)=>{if(!e.persisted)return;let i=t();if(this.#n=null,i)window.location.reload()},document.addEventListener("visibilitychange",this.#s),window.addEventListener("pageshow",this.#a)}async#p(){return}#f(){document.documentElement.classList.add(v.READY),this.#o?.add("app-ready",!0),window.dispatchEvent(new CustomEvent("app:ready",{detail:{status:this.#e,modules:Array.from(this.#t.keys()),initTime:this.initTime}}))}#h(){if(!this.#i)return;let t=(performance.now()-this.#i).toFixed(2)}get initTime(){return this.#i?performance.now()-this.#i:0}#g(t){console.error("❌ App initialization failed:",t),document.documentElement.classList.add("app-error"),window.dispatchEvent(new CustomEvent("app:error",{detail:{error:t}}))}#y(t){let e=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:"",o=document.createElement("div");o.style.cssText=` position: fixed; inset: 0; background: rgba(0, 0, 0, 0.95); color: #ff6b6b; display: flex; align-items: center; justify-content: center; z-index: 999999; font-family: 'Monaco', 'Courier New', monospace; font-size: 14px; padding: 2rem; `;let n=document.createElement("div");n.style.cssText="max-width: 800px; width: 100%;";let l=document.createElement("h1");l.style.cssText="color: #ff6b6b; margin: 0 0 1rem 0;",l.textContent="App Initialization Failed";let d=document.createElement("p");if(d.style.cssText="margin: 0 0 1rem 0; color: #fff;",d.textContent=e,n.append(l,d),i){let c=document.createElement("pre");c.style.cssText="background: rgba(255, 255, 255, 0.1); padding: 1rem; border-radius: 4px; overflow: auto; color: #fff;",c.textContent=i,n.appendChild(c)}let r=document.createElement("button");r.type="button",r.textContent="Reload Page",r.style.cssText=` margin-top: 1rem; padding: 0.75rem 1.5rem; background: #ff6b6b; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; `,r.addEventListener("click",()=>window.location.reload()),n.appendChild(r),o.appendChild(n),document.body.appendChild(o)}get(t){let e=this.#t.get(t);return e}get status(){return this.#e}get isReady(){return this.#e==="ready"}get scroll(){return h}get viewport(){return s}get pages(){return g}destroy(){if(this.#t.forEach((t,e)=>{try{if(typeof t.destroy==="function")t.destroy()}catch(i){console.error(`❌ Failed to destroy ${e}:`,i)}}),this.#o?.cleanup(),this.#o=null,this.#s)document.removeEventListener("visibilitychange",this.#s),this.#s=null;if(this.#a)window.removeEventListener("pageshow",this.#a),this.#a=null;if(this.#r)window.removeEventListener("breakpoint:change",this.#r),this.#r=null;this.#n=null,this.#t.clear(),this.#e="idle",this.#i=null}get performance(){let t=this.#o;return{getWebVitals:()=>t?.getWebVitals(),showWebVitals:()=>t?.showWebVitals(),getAnimationMetrics:()=>t?.getAnimationMetrics(),showAnimationMetrics:()=>t?.showAnimationMetrics(),resetAnimationMetrics:()=>t?.resetAnimationMetrics(),enableFrameDropDetection:()=>t?.enableFrameDropDetection(),disableFrameDropDetection:()=>t?.disableFrameDropDetection(),getFrameDropHistory:()=>t?.getFrameDropHistory(),toggleFpsDisplay:()=>t?.toggleFpsDisplay()}}}var B=new k;export{B as App};