var e=Object.defineProperty,t=(t,i,n)=>((t,i,n)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n)(t,"symbol"!=typeof i?i+"":i,n);const i=new Map;let n=!1,a=!1;performance.now();const r=document.createElement("div");r.style.position="fixed",r.style.bottom="0",r.style.left="0",r.style.font="12px monospace",r.style.color="#0f0",r.style.background="rgba(0,0,0,0.75)",r.style.padding="0.25rem 0.5rem",r.style.zIndex="9999",r.style.pointerEvents="none",r.style.display="none";const s=`
`;r.innerHTML+=s,r.style.lineHeight="1.4",document.body.appendChild(r);const o=new class{constructor({fps:e=!0}={}){this.fpsEnabled=e,this.fps=0,this.frameCount=0,this.lastTime=performance.now(),this.visible=!1,this.taskTimings=new Map,this.logs=[],this.container=document.createElement("div"),this.container.style.position="fixed",this.container.style.bottom="0",this.container.style.left="0",this.container.style.font="12px Consolas, monospace",this.container.style.color="#0f0",this.container.style.background="rgba(0,0,0,0.75)",this.container.style.padding="0.5rem",this.container.style.zIndex="9999",this.container.style.pointerEvents="none",this.container.style.lineHeight="1.4",this.container.style.whiteSpace="pre",this.container.style.display="none",document.body.appendChild(this.container),window.addEventListener("keydown",e=>{"§"===e.key&&(this.visible=!this.visible,this.container.style.display=this.visible?"block":"none")})}log(e){const t=(new Date).toLocaleTimeString();this.logs.push(`[${t}] ${e}`),this.logs.length>5&&this.logs.shift()}update(e=new Map){this.frameCount++;const t=performance.now();if(t-this.lastTime>=1e3){this.fps=this.frameCount,this.frameCount=0,this.lastTime=t;const i=[];for(const[e,t]of this.taskTimings.entries())i.push(`${e}: ${t.toFixed(2)}ms`);const n=Math.min(2*this.fps,100),a=this.logs.slice().reverse().join("\n");this.container.innerHTML=`\nFPS: ${this.fps} | Tasks: ${e.size}\n${i.join("\n")}\n\n${a?"\nLogs:\n"+a:""}\n `}}trackTask(e,t){const i=performance.now();t();const n=performance.now()-i;this.taskTimings.set(e,n)}};function l(e,t,r={}){i.set(e,t),r.autoStart&&!n&&function(){if(n)return;function e(){for(const[e,n]of i)try{a?o.trackTask(e,n):n()}catch(t){d.warn("[Frameloop] Fehler in Task:",t)}a&&o.update(i),requestAnimationFrame(e)}n=!0,requestAnimationFrame(e)}()}function c(e){i.delete(e)}window.addEventListener("keydown",e=>{"§"===e.key&&(a=!a,r.style.display=a?"block":"none")});class d{static debug(...e){this._write("log","[DEBUG]",e,"debug")}static log(...e){this._write("log","[LOG]",e,"info")}static info(...e){this._write("info","[INFO]",e,"info")}static warn(...e){this._write("warn","[WARN]",e,"warn")}static error(...e){this._write("error","[ERROR]",e,"error")}static _write(e,t,i,n="info"){if(!this.enabled)return;const a=this.levels[this.level]||this.levels.info;if((this.levels[n]||this.levels.info){if(e instanceof Error)return`${e.name}: ${e.message}\n${e.stack||""}`;if("object"==typeof e&&null!==e)try{return JSON.stringify(e)}catch(t){return"[Circular Object]"}return e}).join(" ")}`;if("function"==typeof console[e]&&console[e](r),o&&"function"==typeof o.log)try{o.log(r)}catch(s){}}static setLevel(e){this.levels.hasOwnProperty(e)?(this.level=e,this.info(`[Logger] Log level set to: ${e}`)):this.warn(`[Logger] Invalid log level: ${e}. Valid levels:`,Object.keys(this.levels))}static setEnabled(e){this.enabled=!!e,e&&console.log("[Logger] Logging enabled")}}t(d,"enabled",!1),t(d,"level","error"),t(d,"levels",{debug:0,info:1,warn:2,error:3,none:99});class h{constructor(e={}){this.config=e,this.activeObservers=new Map,this.observerInstances=new Map,d.info("[ObserverManager] Initialized with support:",{intersection:"IntersectionObserver"in window,resize:"ResizeObserver"in window,mutation:"MutationObserver"in window,performance:"PerformanceObserver"in window})}intersection(e,t,i={}){if(!("IntersectionObserver"in window))return d.warn("[ObserverManager] IntersectionObserver not supported"),this.createFallbackObserver("intersection",e,t);const n={root:null,rootMargin:"50px",threshold:[0,.1,.5,1],...i},a=this.generateId("intersection"),r=new IntersectionObserver((e,i)=>{const n=e.map(e=>({element:e.target,isIntersecting:e.isIntersecting,intersectionRatio:e.intersectionRatio,boundingClientRect:e.boundingClientRect,rootBounds:e.rootBounds,intersectionRect:e.intersectionRect,time:e.time,visibility:this.calculateVisibility(e),direction:this.getScrollDirection(e),position:this.getElementPosition(e)}));t(n,i)},n),s=Array.isArray(e)?e:[e];return s.forEach(e=>{e instanceof Element&&r.observe(e)}),this.observerInstances.set(a,r),this.activeObservers.set(a,{type:"intersection",elements:s,callback:t,options:n}),d.info(`[ObserverManager] IntersectionObserver created: ${a}`),{id:a,observer:r,unobserve:e=>r.unobserve(e),disconnect:()=>this.disconnect(a),updateThreshold:e=>this.updateIntersectionThreshold(a,e)}}resize(e,t,i={}){if(!("ResizeObserver"in window))return d.warn("[ObserverManager] ResizeObserver not supported"),this.createFallbackObserver("resize",e,t);const n=this.generateId("resize"),a=new ResizeObserver(e=>{const i=e.map(e=>({element:e.target,contentRect:e.contentRect,borderBoxSize:e.borderBoxSize,contentBoxSize:e.contentBoxSize,devicePixelContentBoxSize:e.devicePixelContentBoxSize,dimensions:{width:e.contentRect.width,height:e.contentRect.height,aspectRatio:e.contentRect.width/e.contentRect.height},deltaSize:this.calculateDeltaSize(e),breakpoint:this.detectBreakpoint(e.contentRect.width)}));t(i)}),r=Array.isArray(e)?e:[e];return r.forEach(e=>{e instanceof Element&&a.observe(e)}),this.observerInstances.set(n,a),this.activeObservers.set(n,{type:"resize",elements:r,callback:t,options:i}),d.info(`[ObserverManager] ResizeObserver created: ${n}`),{id:n,observer:a,unobserve:e=>a.unobserve(e),disconnect:()=>this.disconnect(n)}}mutation(e,t,i={}){if(!("MutationObserver"in window))return d.warn("[ObserverManager] MutationObserver not supported"),null;const n={childList:!0,attributes:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0,...i},a=this.generateId("mutation"),r=new MutationObserver(e=>{const i=e.map(e=>({type:e.type,target:e.target,addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),attributeName:e.attributeName,attributeNamespace:e.attributeNamespace,oldValue:e.oldValue,summary:this.summarizeMutation(e),impact:this.assessMutationImpact(e)}));t(i)});return r.observe(e,n),this.observerInstances.set(a,r),this.activeObservers.set(a,{type:"mutation",target:e,callback:t,options:n}),d.info(`[ObserverManager] MutationObserver created: ${a}`),{id:a,observer:r,disconnect:()=>this.disconnect(a),takeRecords:()=>r.takeRecords()}}performance(e,t={}){if(!("PerformanceObserver"in window))return d.warn("[ObserverManager] PerformanceObserver not supported"),null;const i={entryTypes:["measure","navigation","paint","largest-contentful-paint"],buffered:!0,...t},n=this.generateId("performance"),a=new PerformanceObserver(t=>{const i=t.getEntries().map(e=>({name:e.name,entryType:e.entryType,startTime:e.startTime,duration:e.duration,details:this.enhancePerformanceEntry(e),timestamp:Date.now()}));e(i)});return a.observe(i),this.observerInstances.set(n,a),this.activeObservers.set(n,{type:"performance",callback:e,options:i}),d.info(`[ObserverManager] PerformanceObserver created: ${n}`),{id:n,observer:a,disconnect:()=>this.disconnect(n),takeRecords:()=>a.takeRecords()}}lazyLoad(e="img[data-src], iframe[data-src]",t={}){const i=document.querySelectorAll(e);return this.intersection(i,e=>{e.forEach(e=>{if(e.isIntersecting){const t=e.element;t.dataset.src&&(t.src=t.dataset.src,delete t.dataset.src),t.dataset.srcset&&(t.srcset=t.dataset.srcset,delete t.dataset.srcset),t.classList.add("loaded"),e.observer.unobserve(t),d.info("[ObserverManager] Lazy loaded:",t.src)}})},{rootMargin:"100px",...t})}scrollTrigger(e,t,i={}){return this.intersection(e,e=>{e.forEach(e=>{const i={element:e.element,progress:e.intersectionRatio,isVisible:e.isIntersecting,direction:e.direction,position:e.position};t(i)})},{threshold:this.createThresholdArray(i.steps||10),...i})}viewport(e,t={}){const i=document.createElement("div");return i.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n visibility: hidden;\n ",document.body.appendChild(i),this.resize([i],t=>{const i=t[0];e({width:i.dimensions.width,height:i.dimensions.height,aspectRatio:i.dimensions.aspectRatio,orientation:i.dimensions.width>i.dimensions.height?"landscape":"portrait",breakpoint:i.breakpoint})},t)}generateId(e){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}disconnect(e){const t=this.observerInstances.get(e);t&&(t.disconnect(),this.observerInstances.delete(e),this.activeObservers.delete(e),d.info(`[ObserverManager] Observer disconnected: ${e}`))}disconnectAll(){this.observerInstances.forEach((e,t)=>{e.disconnect()}),this.observerInstances.clear(),this.activeObservers.clear(),d.info("[ObserverManager] All observers disconnected")}calculateVisibility(e){if(!e.isIntersecting)return 0;const t=e.intersectionRect.width*e.intersectionRect.height,i=e.boundingClientRect.width*e.boundingClientRect.height;return i>0?Math.round(t/i*100):0}getScrollDirection(e){return e.intersectionRatio>.5?"down":"up"}getElementPosition(e){const t=e.boundingClientRect,i=window.innerHeight;return t.top<0&&t.bottom>0?"entering-top":t.topi?"entering-bottom":t.top>=0&&t.bottom<=i?"visible":"hidden"}calculateDeltaSize(e){return{width:0,height:0}}detectBreakpoint(e){return e<576?"xs":e<768?"sm":e<992?"md":e<1200?"lg":"xl"}summarizeMutation(e){return`${e.type} on ${e.target.tagName}`}assessMutationImpact(e){return"childList"===e.type?e.addedNodes.length+e.removedNodes.length>5?"high":"low":"medium"}enhancePerformanceEntry(e){const t={raw:e};switch(e.entryType){case"navigation":t.loadTime=e.loadEventEnd-e.navigationStart,t.domContentLoaded=e.domContentLoadedEventEnd-e.navigationStart;break;case"paint":t.paintType=e.name;break;case"largest-contentful-paint":t.element=e.element,t.url=e.url}return t}createThresholdArray(e){const t=[];for(let i=0;i<=e;i++)t.push(i/e);return t}createFallbackObserver(e,t,i){d.warn(`[ObserverManager] Creating fallback for ${e}Observer`);const n=this.generateId(`fallback_${e}`);let a;if("intersection"===e)a=setInterval(()=>{const e=(Array.isArray(t)?t:[t]).map(e=>({element:e,isIntersecting:this.isElementInViewport(e),intersectionRatio:this.calculateIntersectionRatio(e)}));i(e)},100);return{id:n,disconnect:()=>{a&&clearInterval(a)}}}isElementInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}calculateIntersectionRatio(e){const t=e.getBoundingClientRect(),i=window.innerHeight,n=window.innerWidth,a=Math.min(t.bottom,i)-Math.max(t.top,0),r=Math.min(t.right,n)-Math.max(t.left,0);if(a<=0||r<=0)return 0;const s=a*r,o=t.height*t.width;return o>0?s/o:0}getActiveObservers(){return Array.from(this.activeObservers.entries()).map(([e,t])=>({id:e,...t}))}}class u{constructor(e={}){var t;this.config=e,this.activeStreams=new Map,this.activeConnections=new Map,this.audioContext=null,this.support={mediaDevices:void 0!==navigator.mediaDevices,webRTC:"RTCPeerConnection"in window,webAudio:"AudioContext"in window||"webkitAudioContext"in window,mediaRecorder:"MediaRecorder"in window,screenShare:void 0!==(null==(t=navigator.mediaDevices)?void 0:t.getDisplayMedia)},d.info("[MediaManager] Initialized with support:",this.support)}async getUserCamera(e={}){if(!this.support.mediaDevices)throw new Error("MediaDevices API not supported");const t={video:{width:{ideal:1280},height:{ideal:720},facingMode:"user"},audio:!1,...e};try{const e=await navigator.mediaDevices.getUserMedia(t),i=this.generateId("camera");return this.activeStreams.set(i,{stream:e,type:"camera",constraints:t,tracks:e.getTracks()}),d.info(`[MediaManager] Camera stream acquired: ${i}`),{id:i,stream:e,video:e.getVideoTracks()[0],audio:e.getAudioTracks()[0],stop:()=>this.stopStream(i),switchCamera:()=>this.switchCamera(i),takePhoto:t=>this.takePhoto(e,t),applyFilter:e=>this.applyVideoFilter(i,e)}}catch(i){throw d.warn("[MediaManager] Camera access failed:",i.message),i}}async getUserMicrophone(e={}){if(!this.support.mediaDevices)throw new Error("MediaDevices API not supported");const t={audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e.audio},video:!1,...e};try{const e=await navigator.mediaDevices.getUserMedia(t),i=this.generateId("microphone");return this.activeStreams.set(i,{stream:e,type:"microphone",constraints:t,tracks:e.getTracks()}),d.info(`[MediaManager] Microphone stream acquired: ${i}`),{id:i,stream:e,audio:e.getAudioTracks()[0],stop:()=>this.stopStream(i),getVolume:()=>this.getAudioLevel(e),startRecording:t=>this.startRecording(e,t)}}catch(i){throw d.warn("[MediaManager] Microphone access failed:",i.message),i}}async getScreenShare(e={}){if(!this.support.screenShare)throw new Error("Screen sharing not supported");const t={video:{cursor:"always"},audio:!1,...e};try{const e=await navigator.mediaDevices.getDisplayMedia(t),i=this.generateId("screen");return this.activeStreams.set(i,{stream:e,type:"screen",constraints:t,tracks:e.getTracks()}),e.getTracks().forEach(e=>{e.addEventListener("ended",()=>{this.stopStream(i)})}),d.info(`[MediaManager] Screen share acquired: ${i}`),{id:i,stream:e,video:e.getVideoTracks()[0],audio:e.getAudioTracks()[0],stop:()=>this.stopStream(i)}}catch(i){throw d.warn("[MediaManager] Screen share failed:",i.message),i}}async startRecording(e,t={}){if(!this.support.mediaRecorder)throw new Error("MediaRecorder API not supported");const i={mimeType:"video/webm;codecs=vp9",videoBitsPerSecond:2e6,audioBitsPerSecond:128e3,...t},n=this.getSupportedMimeType(["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"])||i.mimeType,a=new MediaRecorder(e,{...i,mimeType:n}),r=this.generateId("recording"),s=[];return a.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},a.onstop=()=>{const e=new Blob(s,{type:n});this.onRecordingComplete(r,e)},a.start(),d.info(`[MediaManager] Recording started: ${r}`),{id:r,recorder:a,stop:()=>(a.stop(),new Promise(e=>{a.onstop=()=>{const t=new Blob(s,{type:n});e({blob:t,url:URL.createObjectURL(t),size:t.size,type:t.type,download:(e=`recording-${Date.now()}.webm`)=>{this.downloadBlob(t,e)}})}})),pause:()=>a.pause(),resume:()=>a.resume(),get state(){return a.state}}}takePhoto(e,t){const i=document.createElement("video");return i.srcObject=e,i.autoplay=!0,i.muted=!0,new Promise(e=>{i.onloadedmetadata=()=>{t||(t=document.createElement("canvas")),t.width=i.videoWidth,t.height=i.videoHeight;t.getContext("2d").drawImage(i,0,0),t.toBlob(i=>{e({canvas:t,blob:i,url:URL.createObjectURL(i),dataURL:t.toDataURL("image/jpeg",.9),download:(e=`photo-${Date.now()}.jpg`)=>{this.downloadBlob(i,e)}})},"image/jpeg",.9),i.remove()}})}getAudioContext(){if(!this.audioContext){if(!this.support.webAudio)return d.warn("[MediaManager] Web Audio API not supported"),null;this.audioContext=new(window.AudioContext||window.webkitAudioContext),d.info("[MediaManager] Audio context created")}return this.audioContext}createAudioAnalyzer(e,t={}){const i=this.getAudioContext();if(!i)return null;const n=i.createMediaStreamSource(e),a=i.createAnalyser();a.fftSize=t.fftSize||256,a.smoothingTimeConstant=t.smoothing||.8,n.connect(a);const r=a.frequencyBinCount,s=new Uint8Array(r);return{analyzer:a,bufferLength:r,dataArray:s,getFrequencyData:()=>(a.getByteFrequencyData(s),Array.from(s)),getTimeDomainData:()=>(a.getByteTimeDomainData(s),Array.from(s)),getAverageVolume:()=>(a.getByteFrequencyData(s),s.reduce((e,t)=>e+t,0)/r)}}async createPeerConnection(e={}){if(!this.support.webRTC)throw new Error("WebRTC not supported");const t={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}],...e},i=new RTCPeerConnection(t),n=this.generateId("rtc");this.activeConnections.set(n,i);const a={id:n,connection:i,onTrack:e=>i.addEventListener("track",e),onIceCandidate:e=>i.addEventListener("icecandidate",e),onConnectionStateChange:e=>i.addEventListener("connectionstatechange",e),addStream:e=>{e.getTracks().forEach(t=>{i.addTrack(t,e)})},createOffer:()=>i.createOffer(),createAnswer:()=>i.createAnswer(),setLocalDescription:e=>i.setLocalDescription(e),setRemoteDescription:e=>i.setRemoteDescription(e),addIceCandidate:e=>i.addIceCandidate(e),close:()=>{i.close(),this.activeConnections.delete(n)},get connectionState(){return i.connectionState},get iceConnectionState(){return i.iceConnectionState}};return d.info(`[MediaManager] Peer connection created: ${n}`),a}async getDevices(){if(!this.support.mediaDevices)return{cameras:[],microphones:[],speakers:[]};try{const e=await navigator.mediaDevices.enumerateDevices();return{cameras:e.filter(e=>"videoinput"===e.kind),microphones:e.filter(e=>"audioinput"===e.kind),speakers:e.filter(e=>"audiooutput"===e.kind),all:e}}catch(e){return d.warn("[MediaManager] Device enumeration failed:",e),{cameras:[],microphones:[],speakers:[]}}}async checkPermissions(){const e={};try{if(navigator.permissions){const t=await navigator.permissions.query({name:"camera"}),i=await navigator.permissions.query({name:"microphone"});e.camera=t.state,e.microphone=i.state}}catch(t){d.warn("[MediaManager] Permission check failed:",t)}return e}stopStream(e){const t=this.activeStreams.get(e);t&&(t.tracks.forEach(e=>e.stop()),this.activeStreams.delete(e),d.info(`[MediaManager] Stream stopped: ${e}`))}stopAllStreams(){this.activeStreams.forEach((e,t)=>{e.tracks.forEach(e=>e.stop())}),this.activeStreams.clear(),d.info("[MediaManager] All streams stopped")}async switchCamera(e){const t=this.activeStreams.get(e);if(!t||"camera"!==t.type)return null;const i="user"===t.constraints.video.facingMode?"environment":"user";return this.stopStream(e),this.getUserCamera({video:{...t.constraints.video,facingMode:i}})}getAudioLevel(e){const t=this.getAudioContext();if(!t)return 0;const i=t.createMediaStreamSource(e),n=t.createAnalyser();i.connect(n);const a=new Uint8Array(n.frequencyBinCount);return n.getByteFrequencyData(a),a.reduce((e,t)=>e+t,0)/a.length}getSupportedMimeType(e){return e.find(e=>MediaRecorder.isTypeSupported(e))}downloadBlob(e,t){const i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(i)}generateId(e="media"){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}onRecordingComplete(e,t){d.info(`[MediaManager] Recording completed: ${e}, size: ${t.size} bytes`)}applyVideoFilter(e,t){const i=this.activeStreams.get(e);if(!i||"camera"!==i.type)return;const n={none:"none",blur:"blur(2px)",brightness:"brightness(1.2)",contrast:"contrast(1.3)",grayscale:"grayscale(1)",sepia:"sepia(1)",invert:"invert(1)",vintage:"sepia(0.8) contrast(1.4) brightness(1.1)",cool:"hue-rotate(180deg) saturate(1.5)",warm:"hue-rotate(25deg) saturate(1.2)"};return{filter:n[t]||t,apply:e=>{e.style.filter=n[t]||t}}}getStatus(){var e;return{activeStreams:this.activeStreams.size,activeConnections:this.activeConnections.size,audioContextState:(null==(e=this.audioContext)?void 0:e.state)||"none",support:this.support,streams:Array.from(this.activeStreams.entries()).map(([e,t])=>({id:e,type:t.type,tracks:t.tracks.length,active:t.tracks.some(e=>"live"===e.readyState)}))}}}class m{constructor(e={}){t(this,"db",{set:async(e,t,i=null)=>new Promise((n,a)=>{if(!this.db)return void a(new Error("IndexedDB not available"));const r=this.db.transaction(["keyValue"],"readwrite").objectStore("keyValue"),s={key:e,value:t,timestamp:Date.now(),expiration:i?Date.now()+i:null},o=r.put(s);o.onsuccess=()=>{d.info(`[StorageManager] DB set: ${e}`),n(s)},o.onerror=()=>{d.error(`[StorageManager] DB set failed: ${e}`),a(o.error)}}),get:async e=>new Promise((t,i)=>{if(!this.db)return void i(new Error("IndexedDB not available"));const n=this.db.transaction(["keyValue"],"readonly").objectStore("keyValue").get(e);n.onsuccess=()=>{const i=n.result;if(i)return i.expiration&&Date.now()>i.expiration?(this.db.delete(e),void t(null)):void t(i.value);t(null)},n.onerror=()=>{d.error(`[StorageManager] DB get failed: ${e}`),i(n.error)}}),delete:async e=>new Promise((t,i)=>{if(!this.db)return void i(new Error("IndexedDB not available"));const n=this.db.transaction(["keyValue"],"readwrite").objectStore("keyValue").delete(e);n.onsuccess=()=>{d.info(`[StorageManager] DB deleted: ${e}`),t(!0)},n.onerror=()=>{i(n.error)}}),keys:async()=>new Promise((e,t)=>{if(!this.db)return void t(new Error("IndexedDB not available"));const i=this.db.transaction(["keyValue"],"readonly").objectStore("keyValue").getAllKeys();i.onsuccess=()=>{e(i.result)},i.onerror=()=>{t(i.error)}}),clear:async()=>new Promise((e,t)=>{if(!this.db)return void t(new Error("IndexedDB not available"));const i=this.db.transaction(["keyValue"],"readwrite").objectStore("keyValue").clear();i.onsuccess=()=>{d.info("[StorageManager] DB cleared"),e(!0)},i.onerror=()=>{t(i.error)}}),storeFile:async(e,t,i={})=>new Promise((n,a)=>{if(!this.db)return void a(new Error("IndexedDB not available"));const r=this.db.transaction(["files"],"readwrite").objectStore("files"),s={name:e,file:t,type:t.type,size:t.size,timestamp:Date.now(),metadata:i},o=r.add(s);o.onsuccess=()=>{d.info(`[StorageManager] File stored: ${e}`),n({id:o.result,...s})},o.onerror=()=>{a(o.error)}}),getFile:async e=>new Promise((t,i)=>{if(!this.db)return void i(new Error("IndexedDB not available"));const n=this.db.transaction(["files"],"readonly").objectStore("files").get(e);n.onsuccess=()=>{t(n.result)},n.onerror=()=>{i(n.error)}})}),t(this,"cache",{add:async(e,t=null)=>{if(!this.cache)throw new Error("Cache API not available");try{t?await this.cache.put(e,t):await this.cache.add(e),d.info(`[StorageManager] Cache add: ${e}`)}catch(i){throw d.error("[StorageManager] Cache add failed:",i),i}},get:async e=>{if(!this.cache)throw new Error("Cache API not available");try{const t=await this.cache.match(e);return t?d.info(`[StorageManager] Cache hit: ${e}`):d.info(`[StorageManager] Cache miss: ${e}`),t}catch(t){throw d.error("[StorageManager] Cache get failed:",t),t}},delete:async e=>{if(!this.cache)throw new Error("Cache API not available");try{const t=await this.cache.delete(e);return t&&d.info(`[StorageManager] Cache deleted: ${e}`),t}catch(t){throw d.error("[StorageManager] Cache delete failed:",t),t}},keys:async()=>{if(!this.cache)throw new Error("Cache API not available");try{return await this.cache.keys()}catch(e){throw d.error("[StorageManager] Cache keys failed:",e),e}},clear:async()=>{if(!this.cache)throw new Error("Cache API not available");try{const e=await this.cache.keys();await Promise.all(e.map(e=>this.cache.delete(e))),d.info("[StorageManager] Cache cleared")}catch(e){throw d.error("[StorageManager] Cache clear failed:",e),e}}}),t(this,"channel",{create:(e,t=null)=>{if(!this.support.broadcastChannel)return d.warn("[StorageManager] BroadcastChannel not supported"),null;if(this.channels.has(e))return this.channels.get(e);const i=new BroadcastChannel(e);t&&i.addEventListener("message",t);const n={name:e,channel:i,send:t=>{i.postMessage({data:t,timestamp:Date.now(),sender:"current-tab"}),d.info(`[StorageManager] Broadcast sent to ${e}`)},onMessage:e=>{i.addEventListener("message",t=>{e(t.data)})},close:()=>{i.close(),this.channels.delete(e),d.info(`[StorageManager] Channel closed: ${e}`)}};return this.channels.set(e,n),d.info(`[StorageManager] Channel created: ${e}`),n},get:e=>this.channels.get(e)||null,close:e=>{const t=this.channels.get(e);t&&t.close()},closeAll:()=>{this.channels.forEach(e=>e.close()),this.channels.clear(),d.info("[StorageManager] All channels closed")}}),t(this,"locks",{acquire:async(e,t,i={})=>{if(!this.support.webLocks)return d.warn("[StorageManager] Web Locks not supported, executing without lock"),await t();try{return await navigator.locks.request(e,i,async i=>{d.info(`[StorageManager] Lock acquired: ${e}`);const n=await t(i);return d.info(`[StorageManager] Lock released: ${e}`),n})}catch(n){throw d.error(`[StorageManager] Lock failed: ${e}`,n),n}},query:async()=>{if(!this.support.webLocks)return{held:[],pending:[]};try{return await navigator.locks.query()}catch(e){throw d.error("[StorageManager] Lock query failed:",e),e}}}),t(this,"local",{set:(e,t,i=null)=>{if(!this.support.localStorage)return!1;try{const n={value:t,timestamp:Date.now(),expiration:i?Date.now()+i:null};return localStorage.setItem(e,JSON.stringify(n)),!0}catch(n){return d.error("[StorageManager] localStorage set failed:",n),!1}},get:e=>{if(!this.support.localStorage)return null;try{const t=localStorage.getItem(e);if(!t)return null;const i=JSON.parse(t);return i.expiration&&Date.now()>i.expiration?(localStorage.removeItem(e),null):i.value}catch(t){return d.error("[StorageManager] localStorage get failed:",t),null}},delete:e=>!!this.support.localStorage&&(localStorage.removeItem(e),!0),clear:()=>!!this.support.localStorage&&(localStorage.clear(),!0),keys:()=>this.support.localStorage?Object.keys(localStorage):[]}),t(this,"session",{set:(e,t)=>{if(!this.support.sessionStorage)return!1;try{return sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(i){return d.error("[StorageManager] sessionStorage set failed:",i),!1}},get:e=>{if(!this.support.sessionStorage)return null;try{const t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return d.error("[StorageManager] sessionStorage get failed:",t),null}},delete:e=>!!this.support.sessionStorage&&(sessionStorage.removeItem(e),!0),clear:()=>!!this.support.sessionStorage&&(sessionStorage.clear(),!0)}),t(this,"smartCache",{set:async(e,t,i={})=>{const{storage:n="indexedDB",expiration:a=null,fallback:r=!0}=i;try{if("indexedDB"===n&&this.db)return await this.db.set(e,t,a);if(r)return this.local.set(e,t,a)}catch(s){if(r)return this.local.set(e,t,a);throw s}},get:async(e,t={})=>{const{storage:i="indexedDB",fallback:n=!0}=t;try{if("indexedDB"===i&&this.db)return await this.db.get(e);if(n)return this.local.get(e)}catch(a){if(n)return this.local.get(e);throw a}},delete:async(e,t={})=>{const{storage:i="indexedDB",fallback:n=!0}=t;try{"indexedDB"===i&&this.db&&await this.db.delete(e),n&&this.local.delete(e)}catch(a){throw n&&this.local.delete(e),a}}}),this.config=e,this.dbName=e.dbName||"AppDatabase",this.dbVersion=e.dbVersion||1,this.db=null,this.cache=null,this.channels=new Map,this.support={indexedDB:"indexedDB"in window,cacheAPI:"caches"in window,webLocks:"locks"in navigator,broadcastChannel:"BroadcastChannel"in window,localStorage:"localStorage"in window,sessionStorage:"sessionStorage"in window},d.info("[StorageManager] Initialized with support:",this.support),this.initializeDB(),this.initializeCache()}async initializeDB(){if(this.support.indexedDB)try{const e=indexedDB.open(this.dbName,this.dbVersion);e.onerror=()=>{d.error("[StorageManager] IndexedDB failed to open")},e.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains("keyValue")){t.createObjectStore("keyValue",{keyPath:"key"}).createIndex("timestamp","timestamp",{unique:!1})}if(t.objectStoreNames.contains("cache")||t.createObjectStore("cache",{keyPath:"key"}),!t.objectStoreNames.contains("files")){const e=t.createObjectStore("files",{keyPath:"id",autoIncrement:!0});e.createIndex("name","name",{unique:!1}),e.createIndex("type","type",{unique:!1})}d.info("[StorageManager] IndexedDB schema updated")},e.onsuccess=e=>{this.db=e.target.result,d.info("[StorageManager] IndexedDB connected")}}catch(e){d.error("[StorageManager] IndexedDB initialization failed:",e)}else d.warn("[StorageManager] IndexedDB not supported")}async initializeCache(){if(this.support.cacheAPI)try{this.cache=await caches.open(this.config.cacheName||"app-cache-v1"),d.info("[StorageManager] Cache API initialized")}catch(e){d.error("[StorageManager] Cache API initialization failed:",e)}else d.warn("[StorageManager] Cache API not supported")}async getStorageUsage(){const e={quota:0,usage:0,available:0,percentage:0};if("storage"in navigator&&"estimate"in navigator.storage)try{const t=await navigator.storage.estimate();e.quota=t.quota||0,e.usage=t.usage||0,e.available=e.quota-e.usage,e.percentage=e.quota>0?Math.round(e.usage/e.quota*100):0}catch(t){d.error("[StorageManager] Storage estimate failed:",t)}return e}async cleanup(){d.info("[StorageManager] Starting cleanup...");try{if(this.db){const e=this.db.transaction(["keyValue"],"readwrite").objectStore("keyValue"),t=e.index("timestamp").openCursor();let i=0;t.onsuccess=e=>{const t=e.target.result;if(t){const e=t.value;e.expiration&&Date.now()>e.expiration&&(t.delete(),i++),t.continue()}else d.info(`[StorageManager] Cleanup completed: ${i} expired entries removed`)}}if(this.support.localStorage){const e=Object.keys(localStorage);let t=0;e.forEach(e=>{try{const i=localStorage.getItem(e),n=JSON.parse(i);n.expiration&&Date.now()>n.expiration&&(localStorage.removeItem(e),t++)}catch(i){}}),t>0&&d.info(`[StorageManager] LocalStorage cleanup: ${t} expired entries removed`)}}catch(e){d.error("[StorageManager] Cleanup failed:",e)}}async getStatus(){const e=await this.getStorageUsage();return{support:this.support,usage:e,activeChannels:this.channels.size,dbConnected:!!this.db,cacheConnected:!!this.cache,channelNames:Array.from(this.channels.keys())}}}class g{constructor(e={}){t(this,"geolocation",{getCurrent:(e={})=>new Promise((t,i)=>{if(!this.support.geolocation)return void i(new Error("Geolocation not supported"));const n={enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4,...e};navigator.geolocation.getCurrentPosition(e=>{const i=this.enhanceLocationData(e);d.info("[DeviceManager] Location acquired:",{lat:i.latitude,lng:i.longitude,accuracy:i.accuracy}),t(i)},e=>{d.error("[DeviceManager] Geolocation failed:",e.message),i(e)},n)}),watch:(e,t={})=>{if(!this.support.geolocation)throw new Error("Geolocation not supported");const i={enableHighAccuracy:!0,timeout:3e4,maximumAge:1e4,...t},n=navigator.geolocation.watchPosition(t=>{const i=this.enhanceLocationData(t);e(i)},t=>{d.error("[DeviceManager] Location watch failed:",t.message),e({error:t})},i);return this.activeWatchers.set(`geo_${n}`,{type:"geolocation",id:n,stop:()=>{navigator.geolocation.clearWatch(n),this.activeWatchers.delete(`geo_${n}`)}}),d.info("[DeviceManager] Location watch started:",n),{id:n,stop:()=>{navigator.geolocation.clearWatch(n),this.activeWatchers.delete(`geo_${n}`),d.info("[DeviceManager] Location watch stopped:",n)}}},distance:(e,t)=>{const i=this.toRadians(t.latitude-e.latitude),n=this.toRadians(t.longitude-e.longitude),a=Math.sin(i/2)*Math.sin(i/2)+Math.cos(this.toRadians(e.latitude))*Math.cos(this.toRadians(t.latitude))*Math.sin(n/2)*Math.sin(n/2),r=6371*(2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)));return{kilometers:r,miles:.621371*r,meters:1e3*r}}}),t(this,"motion",{start:(e,t={})=>{if(!this.support.deviceMotion)throw new Error("Device Motion not supported");const i=t=>{const i={acceleration:t.acceleration,accelerationIncludingGravity:t.accelerationIncludingGravity,rotationRate:t.rotationRate,interval:t.interval,timestamp:t.timeStamp,totalAcceleration:this.calculateTotalAcceleration(t.acceleration),shake:this.detectShake(t.accelerationIncludingGravity),orientation:this.getDeviceOrientation(t)};e(i)};"function"==typeof DeviceMotionEvent.requestPermission?DeviceMotionEvent.requestPermission().then(e=>{"granted"===e&&window.addEventListener("devicemotion",i)}):window.addEventListener("devicemotion",i);const n=this.generateId("motion");return this.activeWatchers.set(n,{type:"motion",handler:i,stop:()=>{window.removeEventListener("devicemotion",i),this.activeWatchers.delete(n)}}),d.info("[DeviceManager] Motion detection started"),{id:n,stop:()=>{window.removeEventListener("devicemotion",i),this.activeWatchers.delete(n),d.info("[DeviceManager] Motion detection stopped")}}},startOrientation:(e,t={})=>{if(!this.support.deviceOrientation)throw new Error("Device Orientation not supported");const i=t=>{const i={alpha:t.alpha,beta:t.beta,gamma:t.gamma,absolute:t.absolute,timestamp:t.timeStamp,compass:this.calculateCompass(t.alpha),tilt:this.calculateTilt(t.beta,t.gamma),rotation:this.getRotationState(t)};e(i)};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&window.addEventListener("deviceorientation",i)}):window.addEventListener("deviceorientation",i);const n=this.generateId("orientation");return this.activeWatchers.set(n,{type:"orientation",handler:i,stop:()=>{window.removeEventListener("deviceorientation",i),this.activeWatchers.delete(n)}}),d.info("[DeviceManager] Orientation detection started"),{id:n,stop:()=>{window.removeEventListener("deviceorientation",i),this.activeWatchers.delete(n),d.info("[DeviceManager] Orientation detection stopped")}}}}),t(this,"vibration",{vibrate:e=>{if(!this.support.vibration)return d.warn("[DeviceManager] Vibration not supported"),!1;try{return navigator.vibrate(e),d.info("[DeviceManager] Vibration triggered:",e),!0}catch(t){return d.error("[DeviceManager] Vibration failed:",t),!1}},patterns:{short:200,long:600,double:[200,100,200],triple:[200,100,200,100,200],sos:[100,30,100,30,100,200,200,30,200,30,200,200,100,30,100,30,100],heartbeat:[100,30,100,130,40,30,40,30,100],notification:[200,100,200],success:[100],error:[300,100,300],warning:[200,100,200,100,200]},stop:()=>{this.support.vibration&&(navigator.vibrate(0),d.info("[DeviceManager] Vibration stopped"))},success:()=>this.vibration.vibrate(this.vibration.patterns.success),error:()=>this.vibration.vibrate(this.vibration.patterns.error),warning:()=>this.vibration.vibrate(this.vibration.patterns.warning),notification:()=>this.vibration.vibrate(this.vibration.patterns.notification)}),t(this,"battery",{get:async()=>{if(!this.support.battery)return d.warn("[DeviceManager] Battery API not supported"),null;try{const e=await navigator.getBattery(),t={level:Math.round(100*e.level),charging:e.charging,chargingTime:e.chargingTime,dischargingTime:e.dischargingTime,status:this.getBatteryStatus(e),timeRemaining:this.formatBatteryTime(e)};return d.info("[DeviceManager] Battery status:",t),t}catch(e){return d.error("[DeviceManager] Battery status failed:",e),null}},watch:async e=>{if(!this.support.battery)throw new Error("Battery API not supported");try{const t=await navigator.getBattery(),i=[];["chargingchange","levelchange","chargingtimechange","dischargingtimechange"].forEach(n=>{const a=()=>{const i={level:Math.round(100*t.level),charging:t.charging,chargingTime:t.chargingTime,dischargingTime:t.dischargingTime,status:this.getBatteryStatus(t),timeRemaining:this.formatBatteryTime(t),event:n};e(i)};t.addEventListener(n,a),i.push({event:n,handler:a})});const n=this.generateId("battery");return this.activeWatchers.set(n,{type:"battery",battery:t,handlers:i,stop:()=>{i.forEach(({event:e,handler:i})=>{t.removeEventListener(e,i)}),this.activeWatchers.delete(n)}}),d.info("[DeviceManager] Battery watch started"),{id:n,stop:()=>{i.forEach(({event:e,handler:i})=>{t.removeEventListener(e,i)}),this.activeWatchers.delete(n),d.info("[DeviceManager] Battery watch stopped")}}}catch(t){throw d.error("[DeviceManager] Battery watch failed:",t),t}}}),t(this,"network",{get:()=>{if(!this.support.networkInfo)return d.warn("[DeviceManager] Network Information not supported"),null;const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;return{effectiveType:e.effectiveType,downlink:e.downlink,rtt:e.rtt,saveData:e.saveData,speed:this.getConnectionSpeed(e),quality:this.getConnectionQuality(e),recommendation:this.getNetworkRecommendation(e)}},watch:e=>{if(!this.support.networkInfo)throw new Error("Network Information not supported");const t=navigator.connection||navigator.mozConnection||navigator.webkitConnection,i=()=>{const i={effectiveType:t.effectiveType,downlink:t.downlink,rtt:t.rtt,saveData:t.saveData,speed:this.getConnectionSpeed(t),quality:this.getConnectionQuality(t),recommendation:this.getNetworkRecommendation(t)};e(i)};t.addEventListener("change",i);const n=this.generateId("network");return this.activeWatchers.set(n,{type:"network",connection:t,handler:i,stop:()=>{t.removeEventListener("change",i),this.activeWatchers.delete(n)}}),d.info("[DeviceManager] Network watch started"),{id:n,stop:()=>{t.removeEventListener("change",i),this.activeWatchers.delete(n),d.info("[DeviceManager] Network watch stopped")}}}}),t(this,"wakeLock",{request:async(e="screen")=>{if(!this.support.wakeLock)return d.warn("[DeviceManager] Wake Lock not supported"),null;try{const t=await navigator.wakeLock.request(e);return d.info(`[DeviceManager] Wake lock acquired: ${e}`),{type:t.type,release:()=>{t.release(),d.info(`[DeviceManager] Wake lock released: ${e}`)}}}catch(t){throw d.error("[DeviceManager] Wake lock failed:",t),t}}}),this.config=e,this.activeWatchers=new Map,this.sensorData=new Map,this.support={geolocation:"geolocation"in navigator,deviceMotion:"DeviceMotionEvent"in window,deviceOrientation:"DeviceOrientationEvent"in window,vibration:"vibrate"in navigator,battery:"getBattery"in navigator,networkInfo:"connection"in navigator||"mozConnection"in navigator||"webkitConnection"in navigator,wakeLock:"wakeLock"in navigator,bluetooth:"bluetooth"in navigator,usb:"usb"in navigator,serial:"serial"in navigator},d.info("[DeviceManager] Initialized with support:",this.support),this.initializeSensors()}initializeSensors(){(this.support.deviceMotion||this.support.deviceOrientation)&&(this.sensorData.set("motionBaseline",{x:0,y:0,z:0}),this.sensorData.set("shakeThreshold",this.config.shakeThreshold||15))}enhanceLocationData(e){return{latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy,altitude:e.coords.altitude,altitudeAccuracy:e.coords.altitudeAccuracy,heading:e.coords.heading,speed:e.coords.speed,timestamp:e.timestamp,coordinates:`${e.coords.latitude},${e.coords.longitude}`,accuracyLevel:this.getAccuracyLevel(e.coords.accuracy),mapUrl:`https://maps.google.com/?q=${e.coords.latitude},${e.coords.longitude}`}}getAccuracyLevel(e){return e<=5?"excellent":e<=10?"good":e<=50?"fair":"poor"}calculateTotalAcceleration(e){if(!e)return 0;const t=e.x||0,i=e.y||0,n=e.z||0;return Math.sqrt(t*t+i*i+n*n)}detectShake(e){if(!e)return!1;const t=this.sensorData.get("shakeThreshold"),i=Math.abs(e.x||0),n=Math.abs(e.y||0),a=Math.abs(e.z||0);return i>t||n>t||a>t}getDeviceOrientation(e){const t=e.accelerationIncludingGravity;if(!t)return"unknown";const i=t.x||0,n=t.y||0,a=t.z||0;return Math.abs(i)>Math.abs(n)&&Math.abs(i)>Math.abs(a)?i>0?"landscape-right":"landscape-left":Math.abs(n)>Math.abs(a)?n>0?"portrait-upside-down":"portrait":a>0?"face-down":"face-up"}calculateCompass(e){if(null===e)return null;const t=Math.round(e/45)%8;return{degrees:Math.round(e),direction:["N","NE","E","SE","S","SW","W","NW"][t],cardinal:this.getCardinalDirection(e)}}getCardinalDirection(e){return e>=337.5||e<22.5?"North":e>=22.5&&e<67.5?"Northeast":e>=67.5&&e<112.5?"East":e>=112.5&&e<157.5?"Southeast":e>=157.5&&e<202.5?"South":e>=202.5&&e<247.5?"Southwest":e>=247.5&&e<292.5?"West":e>=292.5&&e<337.5?"Northwest":"Unknown"}calculateTilt(e,t){return{x:Math.round(e||0),y:Math.round(t||0),magnitude:Math.round(Math.sqrt((e||0)**2+(t||0)**2))}}getRotationState(e){const{alpha:t,beta:i,gamma:n}=e,a=Math.abs(i)>10||Math.abs(n)>10;return{isRotating:a,intensity:a?Math.max(Math.abs(i),Math.abs(n)):0}}getBatteryStatus(e){const t=100*e.level;return e.charging?"charging":t<=10?"critical":t<=20?"low":t<=50?"medium":"high"}formatBatteryTime(e){const t=e.charging?e.chargingTime:e.dischargingTime;if(t===1/0||isNaN(t))return"Unknown";return`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}getConnectionSpeed(e){const t=e.downlink;return t>=10?"fast":t>=1.5?"good":t>=.5?"slow":"very-slow"}getConnectionQuality(e){switch(e.effectiveType){case"4g":return"excellent";case"3g":return"good";case"2g":return"poor";case"slow-2g":return"very-poor";default:return"unknown"}}getNetworkRecommendation(e){switch(this.getConnectionQuality(e)){case"excellent":return"Full quality content recommended";case"good":return"Moderate quality content recommended";case"poor":return"Light content only, avoid large files";case"very-poor":return"Text-only content recommended";default:return"Monitor connection quality"}}toRadians(e){return e*(Math.PI/180)}generateId(e="device"){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}stopAllWatchers(){this.activeWatchers.forEach(e=>{e.stop()}),this.activeWatchers.clear(),d.info("[DeviceManager] All watchers stopped")}getCapabilities(){return{support:this.support,activeWatchers:this.activeWatchers.size,watcherTypes:Array.from(this.activeWatchers.values()).map(e=>e.type)}}}class p{constructor(e={}){t(this,"effects",{fadeIn:(e=300)=>[{opacity:0},{opacity:1}],slideInLeft:(e="100px",t=300)=>[{transform:`translateX(-${e})`,opacity:0},{transform:"translateX(0)",opacity:1}],slideInRight:(e="100px",t=300)=>[{transform:`translateX(${e})`,opacity:0},{transform:"translateX(0)",opacity:1}],slideInUp:(e="100px",t=300)=>[{transform:`translateY(${e})`,opacity:0},{transform:"translateY(0)",opacity:1}],slideInDown:(e="100px",t=300)=>[{transform:`translateY(-${e})`,opacity:0},{transform:"translateY(0)",opacity:1}],scaleIn:(e=.8,t=300)=>[{transform:`scale(${e})`,opacity:0},{transform:"scale(1)",opacity:1}],rotateIn:(e="-180deg",t=600)=>[{transform:`rotate(${e})`,opacity:0},{transform:"rotate(0deg)",opacity:1}],fadeOut:(e=300)=>[{opacity:1},{opacity:0}],slideOutLeft:(e="100px",t=300)=>[{transform:"translateX(0)",opacity:1},{transform:`translateX(-${e})`,opacity:0}],slideOutRight:(e="100px",t=300)=>[{transform:"translateX(0)",opacity:1},{transform:`translateX(${e})`,opacity:0}],scaleOut:(e=.8,t=300)=>[{transform:"scale(1)",opacity:1},{transform:`scale(${e})`,opacity:0}],bounce:(e="20px",t=600)=>[{transform:"translateY(0)"},{transform:`translateY(-${e})`,offset:.25},{transform:"translateY(0)",offset:.5},{transform:`translateY(-${e})`,offset:.75},{transform:"translateY(0)"}],pulse:(e=1.1,t=600)=>[{transform:"scale(1)"},{transform:`scale(${e})`,offset:.5},{transform:"scale(1)"}],shake:(e="10px",t=600)=>[{transform:"translateX(0)"},{transform:`translateX(-${e})`,offset:.1},{transform:`translateX(${e})`,offset:.2},{transform:`translateX(-${e})`,offset:.3},{transform:`translateX(${e})`,offset:.4},{transform:`translateX(-${e})`,offset:.5},{transform:`translateX(${e})`,offset:.6},{transform:`translateX(-${e})`,offset:.7},{transform:`translateX(${e})`,offset:.8},{transform:`translateX(-${e})`,offset:.9},{transform:"translateX(0)"}],rubberBand:(e=1e3)=>[{transform:"scale(1)"},{transform:"scale(1.25, 0.75)",offset:.3},{transform:"scale(0.75, 1.25)",offset:.4},{transform:"scale(1.15, 0.85)",offset:.5},{transform:"scale(0.95, 1.05)",offset:.65},{transform:"scale(1.05, 0.95)",offset:.75},{transform:"scale(1)"}],spin:(e=1e3)=>[{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],heartbeat:(e=1.3,t=1e3)=>[{transform:"scale(1)"},{transform:`scale(${e})`,offset:.14},{transform:"scale(1)",offset:.28},{transform:`scale(${e})`,offset:.42},{transform:"scale(1)",offset:.7}]}),t(this,"easings",{linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",easeInQuad:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",easeOutQuad:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",easeInOutQuad:"cubic-bezier(0.455, 0.03, 0.515, 0.955)",easeInCubic:"cubic-bezier(0.32, 0, 0.67, 0)",easeOutCubic:"cubic-bezier(0.33, 1, 0.68, 1)",easeInOutCubic:"cubic-bezier(0.65, 0, 0.35, 1)",easeInQuart:"cubic-bezier(0.5, 0, 0.75, 0)",easeOutQuart:"cubic-bezier(0.25, 1, 0.5, 1)",easeInOutQuart:"cubic-bezier(0.76, 0, 0.24, 1)",easeOutBack:"cubic-bezier(0.34, 1.56, 0.64, 1)",easeInBack:"cubic-bezier(0.36, 0, 0.66, -0.56)",easeInOutBack:"cubic-bezier(0.68, -0.6, 0.32, 1.6)"}),this.config=e,this.activeAnimations=new Map,this.animationGroups=new Map,this.defaultEasing=e.easing||"ease-out",this.defaultDuration=e.duration||300,this.supported="animate"in Element.prototype,this.supported?d.info("[AnimationManager] Initialized with Web Animations API support"):d.warn("[AnimationManager] Web Animations API not supported, using fallbacks")}animate(e,t,i={}){if(!e||!t)return d.warn("[AnimationManager] Missing element or keyframes"),null;const n={duration:this.defaultDuration,easing:this.defaultEasing,fill:"forwards",...i},a=this.generateId();if(this.supported){const i=e.animate(t,n),r=this.enhanceAnimation(i,a,{element:e,keyframes:t,options:n});return this.activeAnimations.set(a,r),i.addEventListener("finish",()=>{this.activeAnimations.delete(a)}),d.info(`[AnimationManager] Animation started: ${a}`),r}return this.fallbackAnimate(e,t,n,a)}keyframes(e){if(Array.isArray(e))return e;if("object"==typeof e){const t=[];return Object.keys(e).sort((e,t)=>parseFloat(e.replace("%",""))-parseFloat(t.replace("%",""))).forEach(i=>{const n=parseFloat(i.replace("%",""))/100;t.push({...e[i],offset:n})}),t}return e}fadeIn(e,t={}){return this.animate(e,this.effects.fadeIn(),{duration:300,easing:this.easings.easeOut,...t})}fadeOut(e,t={}){return this.animate(e,this.effects.fadeOut(),{duration:300,easing:this.easings.easeIn,...t})}slideIn(e,t="up",i={}){return this.animate(e,this.effects[{up:"slideInUp",down:"slideInDown",left:"slideInLeft",right:"slideInRight"}[t]](),{duration:400,easing:this.easings.easeOutBack,...i})}bounce(e,t={}){return this.animate(e,this.effects.bounce(),{duration:600,easing:this.easings.easeInOut,...t})}pulse(e,t={}){return this.animate(e,this.effects.pulse(),{duration:600,easing:this.easings.easeInOut,iterations:1/0,...t})}group(e,t={}){const i=this.generateId("group"),n=[];e.forEach(({element:e,keyframes:i,animationOptions:a={}})=>{const r=this.animate(e,i,{...a,...t});r&&r.finished&&n.push(r.finished)});const a={id:i,finished:Promise.all(n),play:()=>{e.forEach(e=>{e.animation&&e.animation.play()})},pause:()=>{e.forEach(e=>{e.animation&&e.animation.pause()})},reverse:()=>{e.forEach(e=>{e.animation&&e.animation.reverse()})},cancel:()=>{e.forEach(e=>{e.animation&&e.animation.cancel()})}};return this.animationGroups.set(i,a),a}stagger(e,t,i={}){const n=i.staggerDelay||100,a=[];return e.forEach((e,r)=>{const s=r*n,o=this.animate(e,t,{...i,delay:s});a.push({element:e,animation:o})}),this.group(a.map(({element:e,animation:i})=>({element:e,keyframes:t,animation:i})))}timeline(e){const t=this.generateId("timeline");let i=0;const n=[];return e.forEach(e=>{var t;const a=void 0!==e.at?e.at:i,r=this.animate(e.element,e.keyframes,{...e.options,delay:a});n.push(r),void 0===e.at&&(i+=(null==(t=e.options)?void 0:t.duration)||this.defaultDuration)}),{id:t,animations:n,finished:Promise.all(n.map(e=>e.finished)),play:()=>n.forEach(e=>e.play()),pause:()=>n.forEach(e=>e.pause()),reverse:()=>n.forEach(e=>e.reverse()),cancel:()=>n.forEach(e=>e.cancel())}}onScroll(e,t,i={}){const n=i.trigger||e,a=i.start||0,r=i.end||1,s=new IntersectionObserver(n=>{n.forEach(n=>{if(n.isIntersecting){Math.min(Math.max((n.intersectionRatio-a)/(r-a),0),1)>=0&&this.animate(e,t,{...i,duration:i.duration||this.defaultDuration})}})},{threshold:this.createThresholdArray(20)});return s.observe(n),{observer:s,disconnect:()=>s.disconnect()}}enhanceAnimation(e,t,i){return{id:t,animation:e,metadata:i,play:()=>e.play(),pause:()=>e.pause(),reverse:()=>e.reverse(),cancel:()=>e.cancel(),finish:()=>e.finish(),get currentTime(){return e.currentTime},set currentTime(t){e.currentTime=t},get playbackRate(){return e.playbackRate},set playbackRate(t){e.playbackRate=t},get playState(){return e.playState},get finished(){return e.finished},seek(t){e.currentTime=e.effect.getTiming().duration*t},setProgress(e){this.seek(Math.max(0,Math.min(1,e)))},onFinish(t){e.addEventListener("finish",t)},onCancel(t){e.addEventListener("cancel",t)}}}fallbackAnimate(e,t,i,n){d.info("[AnimationManager] Using CSS fallback animation");const a=t[t.length-1];return e.style.transition=`all ${i.duration}ms ${i.easing}`,Object.assign(e.style,a),{id:n,finished:new Promise(e=>setTimeout(e,i.duration)),play:()=>{},pause:()=>{},cancel:()=>{e.style.transition=""}}}generateId(e="anim"){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}createThresholdArray(e){const t=[];for(let i=0;i<=e;i++)t.push(i/e);return t}getActiveAnimations(){return Array.from(this.activeAnimations.entries()).map(([e,t])=>({id:e,playState:t.playState,currentTime:t.currentTime,metadata:t.metadata}))}cancelAll(){this.activeAnimations.forEach(e=>{e.cancel()}),this.activeAnimations.clear(),d.info("[AnimationManager] All animations cancelled")}pauseAll(){this.activeAnimations.forEach(e=>{e.pause()}),d.info("[AnimationManager] All animations paused")}resumeAll(){this.activeAnimations.forEach(e=>{"paused"===e.playState&&e.play()}),d.info("[AnimationManager] All animations resumed")}}class f{constructor(e={}){t(this,"web",{create:(e,t={})=>{if(!this.support.webWorkers)throw new Error("Web Workers not supported");let i;const n=this.generateId("worker");try{if("string"==typeof e)i=new Worker(e,t);else if("function"==typeof e){const n=this.createWorkerBlob(e);i=new Worker(URL.createObjectURL(n),t)}else{if(!(e instanceof Blob))throw new Error("Invalid script type");i=new Worker(URL.createObjectURL(e),t)}const a={id:n,worker:i,send:(e,t=null)=>{t?i.postMessage(e,t):i.postMessage(e),d.info(`[WorkerManager] Message sent to worker: ${n}`)},onMessage:e=>{i.addEventListener("message",t=>{e(t.data,t)})},onError:e=>{i.addEventListener("error",e),i.addEventListener("messageerror",e)},terminate:()=>{i.terminate(),this.activeWorkers.delete(n),d.info(`[WorkerManager] Worker terminated: ${n}`)},execute:(e,t=null)=>new Promise((n,a)=>{const r=this.generateId("msg"),s=e=>{e.data.id===r&&(i.removeEventListener("message",s),e.data.error?a(new Error(e.data.error)):n(e.data.result))};i.addEventListener("message",s),i.postMessage({id:r,type:"execute",function:e.toString(),data:t}),setTimeout(()=>{i.removeEventListener("message",s),a(new Error("Worker execution timeout"))},3e4)})};return this.activeWorkers.set(n,a),d.info(`[WorkerManager] Web Worker created: ${n}`),a}catch(a){throw d.error("[WorkerManager] Worker creation failed:",a),a}},createPool:(e,t=navigator.hardwareConcurrency||4,i={})=>{const n=[];for(let s=0;sSupports ${this.config.allowedTypes.map(e=>e.split("/")[1].toUpperCase()).join(", ")}\n up to ${Math.round(this.config.maxSize/1048576)}MB
\nNo variants available
'}showLoading(){const e=this.modal.querySelector(".image-modal__loading"),t=this.modal.querySelector(".image-modal__image");e.style.display="flex",t.style.display="none"}hideLoading(){const e=this.modal.querySelector(".image-modal__loading"),t=this.modal.querySelector(".image-modal__image");e.style.display="none",t.style.display="block"}showImageError(){this.modal.querySelector(".image-modal__image-container").innerHTML='\nThe image could not be loaded. It may have been deleted or moved.
\n \n