strataplayer 1.2.21 → 1.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- "use strict";var ps=Object.defineProperty;var bs=(i,t,s)=>t in i?ps(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var P=(i,t,s)=>bs(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),gs=require("react-dom/client"),e=require("react/jsx-runtime"),vs=require("react-dom");class ws{constructor(){P(this,"events");this.events=new Map}on(t,s){var o;return this.events.has(t)||this.events.set(t,[]),(o=this.events.get(t))==null||o.push(s),()=>this.off(t,s)}off(t,s){const o=this.events.get(t);o&&this.events.set(t,o.filter(a=>a!==s))}emit(t,s){const o=this.events.get(t);o&&o.forEach(a=>a(s))}destroy(){this.events.clear()}}class js{constructor(t){P(this,"state");P(this,"listeners");this.state=t,this.listeners=new Set}get(){return this.state}setState(t){const s=this.state,o=typeof t=="function"?t(s):t;this.state={...s,...o},this.listeners.forEach(a=>a(this.state,s))}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.listeners.clear()}}class ys{constructor(t){P(this,"context",null);P(this,"source",null);P(this,"gainNode",null);P(this,"video");P(this,"isInitialized",!1);this.video=t}init(){if(!(this.isInitialized||!(window.AudioContext||window.webkitAudioContext))){this.context=new AudioContext,this.gainNode=this.context.createGain();try{this.source=this.context.createMediaElementSource(this.video),this.source.connect(this.gainNode),this.gainNode.connect(this.context.destination),this.isInitialized=!0}catch(s){console.warn("StrataPlayer: Failed to initialize AudioEngine",s)}}}setGain(t){this.isInitialized||this.init(),this.gainNode&&this.context&&(this.gainNode.gain.value=t,this.context.state==="suspended"&&this.context.resume())}destroy(){this.context&&this.context.close(),this.isInitialized=!1}}const Xe=i=>{if(isNaN(i))return"00:00";const t=Math.floor(i/3600),s=Math.floor(i%3600/60),o=Math.floor(i%60);return t>0?`${t}:${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${s}:${o.toString().padStart(2,"0")}`},ks=async(i,t=3,s=2e4)=>{for(let o=0;o<t;o++){const a=new AbortController,d=setTimeout(()=>a.abort(),s);try{const u=await fetch(i,{signal:a.signal});if(clearTimeout(d),!u.ok)throw new Error(`HTTP ${u.status}`);return await u.text()}catch(u){if(clearTimeout(d),o===t-1)throw u;await new Promise(x=>setTimeout(x,1e3))}}throw new Error("Failed")},Ss=async(i,t,s=2e4)=>{try{const a=(await ks(i,3,s)).split(`
2
- `),d=[];let u=null,x=null;const v=i.substring(0,i.lastIndexOf("/")+1),p=h=>{const g=h.split(":");let f=0;return g.length===3?(f+=parseFloat(g[0])*3600,f+=parseFloat(g[1])*60,f+=parseFloat(g[2])):(f+=parseFloat(g[0])*60,f+=parseFloat(g[1])),f};for(let h of a)if(h=h.trim(),h.includes("-->")){const g=h.split("-->");u=p(g[0].trim()),x=p(g[1].trim())}else if(u!==null&&x!==null&&h.length>0){let[g,f]=h.split("#");!g.match(/^https?:\/\//)&&!g.startsWith("data:")&&(g=v+g);let k=0,F=0,H=0,D=0;if(f&&f.startsWith("xywh=")){const G=f.replace("xywh=","").split(",");G.length===4&&(k=parseInt(G[0]),F=parseInt(G[1]),H=parseInt(G[2]),D=parseInt(G[3]))}H>0&&D>0&&d.push({start:u,end:x,url:g,x:k,y:F,w:H,h:D}),u=null,x=null}return d}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},Cs=()=>{if(!(typeof document>"u")){if(!document.getElementById("strata-fonts")){const i=document.createElement("link");i.rel="preconnect",i.href="https://fonts.googleapis.com",document.head.appendChild(i);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);const s=document.createElement("link");s.id="strata-fonts",s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Press+Start+2P&family=Cinzel:wght@400;600;700&display=swap",document.head.appendChild(s)}if(!document.querySelector('script[src*="cast_sender.js"]')&&!window.cast){const i=document.createElement("script");i.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(i)}}},et={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},Wt="strata-settings",Q={isPlaying:!1,isBuffering:!1,isLive:!1,currentTime:0,duration:0,buffered:[],volume:1,isMuted:!1,audioGain:1,playbackRate:1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,error:null,isFullscreen:!1,isWebFullscreen:!1,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:et,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,sourceStatuses:{},isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",videoFit:"contain",brightness:1,isAutoSized:!1,isLooping:!1,controlsVisible:!0},Ut=(i={})=>{let t={};if(!i.disablePersistence&&typeof window<"u")try{const a=localStorage.getItem(Wt);a&&(t=JSON.parse(a))}catch{}const s={...et,...t.subtitleSettings||{},...i.subtitleSettings||{}},o=i.videoFit??(i.autoSize?"cover":void 0)??t.videoFit??Q.videoFit;return{...Q,...t,volume:i.volume??t.volume??Q.volume,isMuted:i.muted??t.isMuted??Q.isMuted,playbackRate:i.playbackRate??t.playbackRate??Q.playbackRate,audioGain:i.audioGain??t.audioGain??Q.audioGain,theme:i.theme??t.theme??Q.theme,themeColor:i.themeColor??t.themeColor??Q.themeColor,iconSize:i.iconSize??t.iconSize??Q.iconSize,subtitleSettings:s,isAutoSized:i.autoSize??Q.isAutoSized,videoFit:o,brightness:i.brightness??t.brightness??Q.brightness,isLive:i.isLive??t.isLive??Q.isLive,isLooping:i.loop??t.isLooping??Q.isLooping,sourceStatuses:{}}};class Gt{constructor(t={},s){P(this,"video");P(this,"container",null);P(this,"events");P(this,"store");P(this,"plugins",new Map);P(this,"audioEngine");P(this,"config");P(this,"resizeObserver",null);P(this,"retryCount",0);P(this,"maxRetries",5);P(this,"retryTimer",null);P(this,"currentSource",null);P(this,"currentSrc","");P(this,"trackConfigs",[]);P(this,"activeDownloads",new Map);P(this,"castInitialized",!1);P(this,"boundCueChange");P(this,"boundFullscreenChange");Cs(),this.config=t,this.config.autoOrientation=this.config.autoOrientation??!0,this.config.fetchTimeout=this.config.fetchTimeout??3e4,this.config.centerControls=this.config.centerControls??!0,this.config.gestureSeek=this.config.gestureSeek??!1,this.video=s||document.createElement("video"),this.video.crossOrigin="anonymous",this.video.preload="auto",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new ws;const o=Ut(t);this.store=new js(o),this.audioEngine=new ys(this.video),this.boundCueChange=this.handleCueChange.bind(this),this.boundFullscreenChange=()=>{const a=!!document.fullscreenElement;if(this.store.setState({isFullscreen:a}),this.emit("resize"),this.emit(a?"fullscreen":"fullscreen_exit"),a&&this.config.autoOrientation&&screen.orientation&&"lock"in screen.orientation){const u=this.video.videoWidth>this.video.videoHeight?"landscape":"portrait";try{screen.orientation.lock(u).catch(()=>{})}catch{}}else!a&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=o.volume,this.video.muted=o.isMuted,this.video.playbackRate=o.playbackRate,this.video.loop=o.isLooping,this.video.style.filter=`brightness(${o.brightness})`,o.audioGain>1&&this.audioEngine.setGain(o.audioGain),this.video.style.objectFit=o.videoFit,this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(a=>{const d={volume:a.volume,isMuted:a.isMuted,playbackRate:a.playbackRate,subtitleSettings:a.subtitleSettings,iconSize:a.iconSize,themeColor:a.themeColor,theme:a.theme,isLive:a.isLive,isLooping:a.isLooping,brightness:a.brightness,videoFit:a.videoFit};localStorage.setItem(Wt,JSON.stringify(d))})}get playing(){return!this.video.paused&&!this.video.ended&&this.video.readyState>2}get currentTime(){return this.video.currentTime}set currentTime(t){this.seek(t)}get duration(){return this.video.duration||0}get paused(){return this.video.paused}get volume(){return this.video.volume}set volume(t){this.setVolume(t)}get muted(){return this.video.muted}set muted(t){this.video.muted=t,this.store.setState({isMuted:t})}get playbackRate(){return this.video.playbackRate}set playbackRate(t){this.video.playbackRate=t}get loop(){return this.video.loop}set loop(t){this.video.loop=t,this.store.setState({isLooping:t})}forward(t=10){this.skip(t)}backward(t=10){this.skip(-t)}on(t,s){return this.events.on(t,s)}off(t,s){return this.events.off(t,s)}emit(t,s){return this.events.emit(t,s)}initVideoListeners(){const t=o=>this.store.setState(o);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(o=>{this.video.addEventListener(o,a=>{switch(this.emit(`video:${o}`,a),o==="play"&&this.emit("play"),o==="pause"&&this.emit("pause"),o==="ended"&&this.emit("ended"),o==="error"&&this.emit("error",this.video.error),o==="seeked"&&this.emit("seek"),o){case"play":t({isPlaying:!0}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="playing"),this.updateMediaSessionPosition();break;case"pause":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"ended":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"waiting":t({isBuffering:!0}),this.emit("loading",!0);break;case"playing":t({isBuffering:!1}),this.emit("loading",!1);break;case"canplay":t({isBuffering:!1}),this.emit("loading",!1),this.updateSourceStatus("success");break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null}),this.updateSourceStatus("success");break;case"loadedmetadata":this.updateMediaSessionMetadata(),this.updateMediaSessionPosition();break;case"timeupdate":this.video.seeking||t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"seeked":t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"durationchange":t({duration:this.video.duration}),this.updateMediaSessionPosition();break;case"volumechange":t({volume:this.video.volume,isMuted:this.video.muted});break;case"ratechange":t({playbackRate:this.video.playbackRate}),this.updateMediaSessionPosition();break;case"error":this.handleError();break;case"progress":this.updateBuffer();break;case"enterpictureinpicture":t({isPip:!0});break;case"leavepictureinpicture":t({isPip:!1});break}})}),this.video.addEventListener("enterpictureinpicture",()=>{t({isPip:!0}),this.emit("pip",!0)}),this.video.addEventListener("leavepictureinpicture",()=>{t({isPip:!1}),this.emit("pip",!1)}),document.addEventListener("fullscreenchange",this.boundFullscreenChange)}updateSourceStatus(t){const s=this.store.get().currentSourceIndex;s!==-1&&this.store.setState(o=>({sourceStatuses:{...o.sourceStatuses,[s]:t}}))}initMediaSession(){if(!("mediaSession"in navigator))return;const t=navigator.mediaSession;t.setActionHandler("play",()=>this.play()),t.setActionHandler("pause",()=>this.pause()),t.setActionHandler("seekbackward",s=>this.skip(s.seekOffset?-s.seekOffset:-10)),t.setActionHandler("seekforward",s=>this.skip(s.seekOffset||10)),t.setActionHandler("seekto",s=>{s.seekTime!==void 0&&this.seek(s.seekTime)}),t.setActionHandler("stop",()=>{this.pause(),this.seek(0)}),t.setActionHandler("previoustrack",()=>{const s=this.store.get().currentSourceIndex;s>0&&this.switchSource(s-1)}),t.setActionHandler("nexttrack",()=>{const s=this.store.get().currentSourceIndex,o=this.store.get().sources.length;s<o-1&&this.switchSource(s+1)})}updateMediaSessionMetadata(){var o,a;if(!("mediaSession"in navigator))return;const t=((o=this.currentSource)==null?void 0:o.name)||((a=this.currentSource)==null?void 0:a.url.split("/").pop())||"Video",s=[];this.config.poster&&s.push({src:this.config.poster,sizes:"512x512",type:"image/jpeg"}),s.push({src:"logo.png",sizes:"512x512",type:"image/png"}),navigator.mediaSession.metadata=new MediaMetadata({title:t,artist:"StrataPlayer",artwork:s})}updateMediaSessionPosition(){if(!("mediaSession"in navigator))return;const t=this.video.duration,s=this.video.currentTime,o=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(s))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:o,position:Math.max(0,Math.min(s,t))})}catch(a){console.warn("MediaSession Position Error:",a)}}triggerError(t,s=!1){s?this.handleError(t):this.notify({type:"warning",message:`Warning: ${t}`,duration:5e3})}handleError(t){const s=this.video.error,o=t||(s==null?void 0:s.message)||(s?`Code ${s.code}`:"Unknown Error");if(this.removeNotification("retry"),this.emit("video:error",s),this.retryCount<this.maxRetries){this.retryCount++;const a=Math.pow(2,this.retryCount-1)*1500;this.notify({id:"retry",type:"loading",message:`Error: ${o}.
3
- Retrying (${this.retryCount}/${this.maxRetries})`}),console.warn(`[StrataPlayer] Error: ${o}. Retrying in ${a}ms...`),this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{if(this.currentSource){this.load(this.currentSource,this.trackConfigs,!0);const d=this.store.get().currentTime;if(d>0){const u=()=>{this.video.currentTime=d,this.video.removeEventListener("canplay",u)};this.video.addEventListener("canplay",u)}}},a)}else{this.removeNotification("retry");const a=`Failed to play after ${this.maxRetries} attempts: ${o}`;this.store.setState({error:a}),this.emit("error",a),this.updateSourceStatus("error")}}updateBuffer(){const t=[];for(let s=0;s<this.video.buffered.length;s++)t.push({start:this.video.buffered.start(s),end:this.video.buffered.end(s)});this.store.setState({buffered:t})}updateSubtitleTrackState(t,s){this.store.setState(o=>{const a=[...o.subtitleTracks];return a[t]&&(a[t]={...a[t],...s}),{subtitleTracks:a}})}async fetchWithRetry(t,s=3,o,a){const d=o??this.config.fetchTimeout??3e4;for(let u=0;u<s;u++){const x=a?null:new AbortController,v=a||(x==null?void 0:x.signal),p=setTimeout(()=>x==null?void 0:x.abort(),d);try{const h=await fetch(t,{signal:v});if(clearTimeout(p),!h.ok)throw new Error(`HTTP ${h.status}`);return h}catch(h){if(clearTimeout(p),a!=null&&a.aborted)throw new Error("Aborted");if(u===s-1)throw h;if(h.name==="AbortError"){if(a!=null&&a.aborted)throw h;console.warn(`Fetch timeout (${d}ms) for ${t}`)}await new Promise(g=>setTimeout(g,1e3*Math.pow(2,u)))}}throw new Error("Fetch failed")}convertToVTT(t){let s=t.trim();if(!s.startsWith("WEBVTT")){let o=s.replace(/(\d+:\d{2}:\d{2}),(\d{3})/g,"$1.$2");return o=o.replace(/(\d{2}:\d{2}),(\d{3})/g,"$1.$2"),`WEBVTT
1
+ "use strict";var ps=Object.defineProperty;var bs=(i,t,s)=>t in i?ps(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var I=(i,t,s)=>bs(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),gs=require("react-dom/client"),e=require("react/jsx-runtime"),vs=require("react-dom");class ws{constructor(){I(this,"events");this.events=new Map}on(t,s){var o;return this.events.has(t)||this.events.set(t,[]),(o=this.events.get(t))==null||o.push(s),()=>this.off(t,s)}off(t,s){const o=this.events.get(t);o&&this.events.set(t,o.filter(a=>a!==s))}emit(t,s){const o=this.events.get(t);o&&o.forEach(a=>a(s))}destroy(){this.events.clear()}}class js{constructor(t){I(this,"state");I(this,"listeners");this.state=t,this.listeners=new Set}get(){return this.state}setState(t){const s=this.state,o=typeof t=="function"?t(s):t;this.state={...s,...o},this.listeners.forEach(a=>a(this.state,s))}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}destroy(){this.listeners.clear()}}class ys{constructor(t){I(this,"context",null);I(this,"source",null);I(this,"gainNode",null);I(this,"video");I(this,"isInitialized",!1);this.video=t}init(){if(!(this.isInitialized||!(window.AudioContext||window.webkitAudioContext))){this.context=new AudioContext,this.gainNode=this.context.createGain();try{this.source=this.context.createMediaElementSource(this.video),this.source.connect(this.gainNode),this.gainNode.connect(this.context.destination),this.isInitialized=!0}catch(s){console.warn("StrataPlayer: Failed to initialize AudioEngine",s)}}}setGain(t){this.isInitialized||this.init(),this.gainNode&&this.context&&(this.gainNode.gain.value=t,this.context.state==="suspended"&&this.context.resume())}destroy(){this.context&&this.context.close(),this.isInitialized=!1}}const Xe=i=>{if(isNaN(i))return"00:00";const t=Math.floor(i/3600),s=Math.floor(i%3600/60),o=Math.floor(i%60);return t>0?`${t}:${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${s}:${o.toString().padStart(2,"0")}`},ks=async(i,t=3,s=2e4)=>{for(let o=0;o<t;o++){const a=new AbortController,d=setTimeout(()=>a.abort(),s);try{const u=await fetch(i,{signal:a.signal});if(clearTimeout(d),!u.ok)throw new Error(`HTTP ${u.status}`);return await u.text()}catch(u){if(clearTimeout(d),o===t-1)throw u;await new Promise(x=>setTimeout(x,1e3))}}throw new Error("Failed")},Ss=async(i,t,s=2e4)=>{try{const a=(await ks(i,3,s)).split(`
2
+ `),d=[];let u=null,x=null;const g=i.substring(0,i.lastIndexOf("/")+1),p=h=>{const v=h.split(":");let f=0;return v.length===3?(f+=parseFloat(v[0])*3600,f+=parseFloat(v[1])*60,f+=parseFloat(v[2])):(f+=parseFloat(v[0])*60,f+=parseFloat(v[1])),f};for(let h of a)if(h=h.trim(),h.includes("-->")){const v=h.split("-->");u=p(v[0].trim()),x=p(v[1].trim())}else if(u!==null&&x!==null&&h.length>0){let[v,f]=h.split("#");!v.match(/^https?:\/\//)&&!v.startsWith("data:")&&(v=g+v);let k=0,E=0,H=0,D=0;if(f&&f.startsWith("xywh=")){const q=f.replace("xywh=","").split(",");q.length===4&&(k=parseInt(q[0]),E=parseInt(q[1]),H=parseInt(q[2]),D=parseInt(q[3]))}H>0&&D>0&&d.push({start:u,end:x,url:v,x:k,y:E,w:H,h:D}),u=null,x=null}return d}catch{return t({type:"warning",message:"Failed to load thumbnails",duration:4e3}),[]}},Cs=()=>{if(!(typeof document>"u")){if(!document.getElementById("strata-fonts")){const i=document.createElement("link");i.rel="preconnect",i.href="https://fonts.googleapis.com",document.head.appendChild(i);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);const s=document.createElement("link");s.id="strata-fonts",s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Press+Start+2P&family=Cinzel:wght@400;600;700&display=swap",document.head.appendChild(s)}if(!document.querySelector('script[src*="cast_sender.js"]')&&!window.cast){const i=document.createElement("script");i.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(i)}}},et={useNative:!1,fixCapitalization:!1,backgroundOpacity:50,backgroundBlur:!1,backgroundBlurAmount:4,textSize:100,textStyle:"shadow",isBold:!1,textColor:"#ffffff",verticalOffset:40},Wt="strata-settings",Q={isPlaying:!1,isBuffering:!1,isLive:!1,currentTime:0,duration:0,buffered:[],volume:1,isMuted:!1,audioGain:1,playbackRate:1,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,error:null,isFullscreen:!1,isWebFullscreen:!1,isPip:!1,subtitleTracks:[],currentSubtitle:-1,subtitleOffset:0,subtitleSettings:et,activeCues:[],viewMode:"normal",notifications:[],iconSize:"medium",themeColor:"#6366f1",theme:"default",sources:[],currentSourceIndex:-1,sourceStatuses:{},isLocked:!1,flipState:{horizontal:!1,vertical:!1},aspectRatio:"default",videoFit:"contain",brightness:1,isAutoSized:!1,isLooping:!1,controlsVisible:!0},Ut=(i={})=>{let t={};if(!i.disablePersistence&&typeof window<"u")try{const a=localStorage.getItem(Wt);a&&(t=JSON.parse(a))}catch{}const s={...et,...t.subtitleSettings||{},...i.subtitleSettings||{}},o=i.videoFit??(i.autoSize?"cover":void 0)??t.videoFit??Q.videoFit;return{...Q,...t,volume:i.volume??t.volume??Q.volume,isMuted:i.muted??t.isMuted??Q.isMuted,playbackRate:i.playbackRate??t.playbackRate??Q.playbackRate,audioGain:i.audioGain??t.audioGain??Q.audioGain,theme:i.theme??t.theme??Q.theme,themeColor:i.themeColor??t.themeColor??Q.themeColor,iconSize:i.iconSize??t.iconSize??Q.iconSize,subtitleSettings:s,isAutoSized:i.autoSize??Q.isAutoSized,videoFit:o,brightness:i.brightness??t.brightness??Q.brightness,isLive:i.isLive??t.isLive??Q.isLive,isLooping:i.loop??t.isLooping??Q.isLooping,sourceStatuses:{}}};class qt{constructor(t={},s){I(this,"video");I(this,"container",null);I(this,"events");I(this,"store");I(this,"plugins",new Map);I(this,"audioEngine");I(this,"config");I(this,"resizeObserver",null);I(this,"retryCount",0);I(this,"maxRetries",5);I(this,"retryTimer",null);I(this,"currentSource",null);I(this,"currentSrc","");I(this,"trackConfigs",[]);I(this,"activeDownloads",new Map);I(this,"castInitialized",!1);I(this,"boundCueChange");I(this,"boundFullscreenChange");Cs(),this.config=t,this.config.autoOrientation=this.config.autoOrientation??!0,this.config.fetchTimeout=this.config.fetchTimeout??3e4,this.config.centerControls=this.config.centerControls??!0,this.config.gestureSeek=this.config.gestureSeek??!1,this.video=s||document.createElement("video"),this.video.crossOrigin="anonymous",this.video.preload="auto",t.playsInline!==!1&&(this.video.playsInline=!0),this.events=new ws;const o=Ut(t);this.store=new js(o),this.audioEngine=new ys(this.video),this.boundCueChange=this.handleCueChange.bind(this),this.boundFullscreenChange=()=>{const a=document,d=!!(a.fullscreenElement||a.webkitFullscreenElement||a.mozFullScreenElement||a.msFullscreenElement);if(this.store.setState({isFullscreen:d}),this.emit("resize"),this.emit(d?"fullscreen":"fullscreen_exit"),d&&this.config.autoOrientation&&screen.orientation&&"lock"in screen.orientation){const x=this.video.videoWidth>this.video.videoHeight?"landscape":"portrait";try{screen.orientation.lock(x).catch(()=>{})}catch{}}else!d&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()},this.video.volume=o.volume,this.video.muted=o.isMuted,this.video.playbackRate=o.playbackRate,this.video.loop=o.isLooping,this.video.style.filter=`brightness(${o.brightness})`,o.audioGain>1&&this.audioEngine.setGain(o.audioGain),this.video.style.objectFit=o.videoFit,this.initVideoListeners(),this.initMediaSession(),this.initCast(),t.disablePersistence||this.store.subscribe(a=>{const d={volume:a.volume,isMuted:a.isMuted,playbackRate:a.playbackRate,subtitleSettings:a.subtitleSettings,iconSize:a.iconSize,themeColor:a.themeColor,theme:a.theme,isLive:a.isLive,isLooping:a.isLooping,brightness:a.brightness,videoFit:a.videoFit};localStorage.setItem(Wt,JSON.stringify(d))})}get playing(){return!this.video.paused&&!this.video.ended&&this.video.readyState>2}get currentTime(){return this.video.currentTime}set currentTime(t){this.seek(t)}get duration(){return this.video.duration||0}get paused(){return this.video.paused}get volume(){return this.video.volume}set volume(t){this.setVolume(t)}get muted(){return this.video.muted}set muted(t){this.video.muted=t,this.store.setState({isMuted:t})}get playbackRate(){return this.video.playbackRate}set playbackRate(t){this.video.playbackRate=t}get loop(){return this.video.loop}set loop(t){this.video.loop=t,this.store.setState({isLooping:t})}forward(t=10){this.skip(t)}backward(t=10){this.skip(-t)}on(t,s){return this.events.on(t,s)}off(t,s){return this.events.off(t,s)}emit(t,s){return this.events.emit(t,s)}initVideoListeners(){const t=a=>this.store.setState(a);["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"].forEach(a=>{this.video.addEventListener(a,d=>{switch(this.emit(`video:${a}`,d),a==="play"&&this.emit("play"),a==="pause"&&this.emit("pause"),a==="ended"&&this.emit("ended"),a==="error"&&this.emit("error",this.video.error),a==="seeked"&&this.emit("seek"),a){case"play":t({isPlaying:!0}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="playing"),this.updateMediaSessionPosition();break;case"pause":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"ended":t({isPlaying:!1}),"mediaSession"in navigator&&(navigator.mediaSession.playbackState="paused");break;case"waiting":t({isBuffering:!0}),this.emit("loading",!0);break;case"playing":t({isBuffering:!1}),this.emit("loading",!1);break;case"canplay":t({isBuffering:!1}),this.emit("loading",!1),this.updateSourceStatus("success");break;case"loadeddata":t({isBuffering:!1}),this.retryCount=0,this.removeNotification("retry"),this.store.get().error&&t({error:null}),this.updateSourceStatus("success");break;case"loadedmetadata":this.updateMediaSessionMetadata(),this.updateMediaSessionPosition();break;case"timeupdate":this.video.seeking||t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"seeked":t({currentTime:this.video.currentTime}),this.updateMediaSessionPosition();break;case"durationchange":t({duration:this.video.duration}),this.updateMediaSessionPosition();break;case"volumechange":t({volume:this.video.volume,isMuted:this.video.muted});break;case"ratechange":t({playbackRate:this.video.playbackRate}),this.updateMediaSessionPosition();break;case"error":this.handleError();break;case"progress":this.updateBuffer();break;case"enterpictureinpicture":t({isPip:!0});break;case"leavepictureinpicture":t({isPip:!1});break}})}),this.video.addEventListener("enterpictureinpicture",()=>{t({isPip:!0}),this.emit("pip",!0)}),this.video.addEventListener("leavepictureinpicture",()=>{t({isPip:!1}),this.emit("pip",!1)}),["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"].forEach(a=>document.addEventListener(a,this.boundFullscreenChange))}updateSourceStatus(t){const s=this.store.get().currentSourceIndex;s!==-1&&this.store.setState(o=>({sourceStatuses:{...o.sourceStatuses,[s]:t}}))}initMediaSession(){if(!("mediaSession"in navigator))return;const t=navigator.mediaSession;t.setActionHandler("play",()=>this.play()),t.setActionHandler("pause",()=>this.pause()),t.setActionHandler("seekbackward",s=>this.skip(s.seekOffset?-s.seekOffset:-10)),t.setActionHandler("seekforward",s=>this.skip(s.seekOffset||10)),t.setActionHandler("seekto",s=>{s.seekTime!==void 0&&this.seek(s.seekTime)}),t.setActionHandler("stop",()=>{this.pause(),this.seek(0)}),t.setActionHandler("previoustrack",()=>{const s=this.store.get().currentSourceIndex;s>0&&this.switchSource(s-1)}),t.setActionHandler("nexttrack",()=>{const s=this.store.get().currentSourceIndex,o=this.store.get().sources.length;s<o-1&&this.switchSource(s+1)})}updateMediaSessionMetadata(){var o,a;if(!("mediaSession"in navigator))return;const t=((o=this.currentSource)==null?void 0:o.name)||((a=this.currentSource)==null?void 0:a.url.split("/").pop())||"Video",s=[];this.config.poster&&s.push({src:this.config.poster,sizes:"512x512",type:"image/jpeg"}),s.push({src:"logo.png",sizes:"512x512",type:"image/png"}),navigator.mediaSession.metadata=new MediaMetadata({title:t,artist:"StrataPlayer",artwork:s})}updateMediaSessionPosition(){if(!("mediaSession"in navigator))return;const t=this.video.duration,s=this.video.currentTime,o=this.video.playbackRate;if(!isNaN(t)&&isFinite(t)&&!isNaN(s))try{navigator.mediaSession.setPositionState({duration:Math.max(0,t),playbackRate:o,position:Math.max(0,Math.min(s,t))})}catch(a){console.warn("MediaSession Position Error:",a)}}triggerError(t,s=!1){s?this.handleError(t):this.notify({type:"warning",message:`Warning: ${t}`,duration:5e3})}handleError(t){const s=this.video.error,o=t||(s==null?void 0:s.message)||(s?`Code ${s.code}`:"Unknown Error");if(this.removeNotification("retry"),this.emit("video:error",s),this.retryCount<this.maxRetries){this.retryCount++;const a=Math.pow(2,this.retryCount-1)*1500;this.notify({id:"retry",type:"loading",message:`Error: ${o}.
3
+ Retrying (${this.retryCount}/${this.maxRetries})`}),console.warn(`[StrataPlayer] Error: ${o}. Retrying in ${a}ms...`),this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{if(this.currentSource){this.load(this.currentSource,this.trackConfigs,!0);const d=this.store.get().currentTime;if(d>0){const u=()=>{this.video.currentTime=d,this.video.removeEventListener("canplay",u)};this.video.addEventListener("canplay",u)}}},a)}else{this.removeNotification("retry");const a=`Failed to play after ${this.maxRetries} attempts: ${o}`;this.store.setState({error:a}),this.emit("error",a),this.updateSourceStatus("error")}}updateBuffer(){const t=[];for(let s=0;s<this.video.buffered.length;s++)t.push({start:this.video.buffered.start(s),end:this.video.buffered.end(s)});this.store.setState({buffered:t})}updateSubtitleTrackState(t,s){this.store.setState(o=>{const a=[...o.subtitleTracks];return a[t]&&(a[t]={...a[t],...s}),{subtitleTracks:a}})}async fetchWithRetry(t,s=3,o,a){const d=o??this.config.fetchTimeout??3e4;for(let u=0;u<s;u++){const x=a?null:new AbortController,g=a||(x==null?void 0:x.signal),p=setTimeout(()=>x==null?void 0:x.abort(),d);try{const h=await fetch(t,{signal:g});if(clearTimeout(p),!h.ok)throw new Error(`HTTP ${h.status}`);return h}catch(h){if(clearTimeout(p),a!=null&&a.aborted)throw new Error("Aborted");if(u===s-1)throw h;if(h.name==="AbortError"){if(a!=null&&a.aborted)throw h;console.warn(`Fetch timeout (${d}ms) for ${t}`)}await new Promise(v=>setTimeout(v,1e3*Math.pow(2,u)))}}throw new Error("Fetch failed")}convertToVTT(t){let s=t.trim();if(!s.startsWith("WEBVTT")){let o=s.replace(/(\d+:\d{2}:\d{2}),(\d{3})/g,"$1.$2");return o=o.replace(/(\d{2}:\d{2}),(\d{3})/g,"$1.$2"),`WEBVTT
4
4
 
5
- `+o}return s}formatDuration(t){if(!isFinite(t)||t<=0)return"";const s=Math.floor(t/1e3),o=Math.floor(s/(3600*24)),a=Math.floor(s%(3600*24)/3600),d=Math.floor(s%3600/60),u=s%60,x=[];return o>0&&x.push(`${o}d`),a>0&&x.push(`${a}h`),d>0&&x.push(`${d}m`),x.push(`${u}s`),x.join(" ")}attach(t){this.resizeObserver&&this.resizeObserver.disconnect(),this.container=t,this.container.appendChild(this.video),this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=this.store.get().videoFit,this.video.style.backgroundColor="black",this.updateAspectRatio(),this.resizeObserver=new ResizeObserver(s=>{for(const o of s)this.emit("resize",{width:o.contentRect.width,height:o.contentRect.height}),this.updateAspectRatio()}),this.resizeObserver.observe(this.container),this.emit("ready")}use(t){this.plugins.has(t.name)||(t.init(this),this.plugins.set(t.name,t))}setSources(t,s=[]){this.store.setState({sources:t}),this.trackConfigs=s,t.length>0&&this.load(t[0],s)}switchSource(t){const s=this.store.get().sources;if(t>=0&&t<s.length){const o=this.video.currentTime,a=!this.video.paused;this.load(s[t],this.trackConfigs);const d=()=>{this.video.currentTime=o,a&&this.video.play(),this.video.removeEventListener("canplay",d)};this.video.addEventListener("canplay",d)}}load(t,s=[],o=!1){this.retryTimer&&clearTimeout(this.retryTimer);const a=typeof t=="string"?{url:t,type:"auto"}:t;o||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=a.url,this.currentSource=a,this.trackConfigs=s;const u=this.store.get().sources.findIndex(g=>g.url===a.url),x=s.map((g,f)=>({...g,index:f,status:"idle",isDefault:!!g.default}));this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,subtitleTracks:x,currentSubtitle:-1,currentSourceIndex:u}),this.updateMediaSessionMetadata();let v=a.type||"auto";v==="auto"&&(a.url.includes(".m3u8")?v="hls":a.url.includes(".mpd")?v="dash":a.url.includes(".flv")||a.url.includes(".ts")?v="mpegts":a.url.startsWith("magnet:")||a.url.includes(".torrent")?v="webtorrent":v="mp4"),this.events.emit("load",{url:a.url,type:v});const p=this.video.getElementsByTagName("track");for(;p.length>0;)p[0].remove();const h=x.findIndex(g=>g.default);h!==-1&&this.setSubtitle(h),(v==="mp4"||v==="webm"||v==="ogg")&&(this.video.src=a.url)}loadSubtitle(t,s="Subtitle"){const o=this.store.get().subtitleTracks.length,a={src:t,label:s,srcLang:"user",default:!0,kind:"subtitles",index:o,status:"idle",isDefault:!0};this.store.setState(d=>({subtitleTracks:[...d.subtitleTracks,a]})),this.setSubtitle(o)}addTextTrack(t,s){const o=new FileReader;o.onload=a=>{var v;if(!((v=a.target)!=null&&v.result))return;let d=a.target.result;d=this.convertToVTT(d);const u=new Blob([d],{type:"text/vtt"}),x=URL.createObjectURL(u);this.loadSubtitle(x,s),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3})},o.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},o.readAsText(t)}addTextTrackInternal(t,s,o="",a=!1){const d=document.createElement("track");d.kind="subtitles",d.label=s,d.src=t,d.srclang=o,a&&(d.default=!0),this.video.appendChild(d)}play(){return this.video.play()}pause(){return this.video.pause()}togglePlay(){this.video.paused?this.play():this.pause()}seek(t){if(isNaN(t))return;const s=Math.max(0,Math.min(t,this.video.duration));this.store.setState({currentTime:s}),this.video.currentTime=s}skip(t){this.seek(this.video.currentTime+t)}setVolume(t){const s=Math.max(0,Math.min(t,1));this.video.volume=s,s>0&&this.video.muted&&(this.video.muted=!1),s===0&&(this.video.muted=!0)}toggleMute(){this.video.muted=!this.video.muted}setAudioGain(t){this.store.setState({audioGain:t}),this.audioEngine.setGain(t)}setQuality(t){this.store.setState({currentQuality:t}),this.events.emit("quality-request",t)}setAudioTrack(t){this.store.setState({currentAudioTrack:t}),this.events.emit("audio-track-request",t)}setControlsVisible(t){this.store.get().controlsVisible!==t&&(this.store.setState({controlsVisible:t}),this.emit("control",t))}async toggleFullscreen(){if(this.container){if(document.fullscreenElement){await document.exitFullscreen().catch(()=>{});return}if(this.store.get().isWebFullscreen){this.toggleWebFullscreen();return}try{await this.container.requestFullscreen()}catch(t){console.warn("Native fullscreen failed, falling back to Web Fullscreen",t),this.toggleWebFullscreen()}}}toggleWebFullscreen(){const t=this.store.get().isWebFullscreen;document.fullscreenElement&&document.exitFullscreen().catch(()=>{});const s=!t;this.store.setState({isWebFullscreen:s}),typeof document<"u"&&(document.body.style.overflow=s?"hidden":""),this.emit("webfullscreen",s)}togglePip(){document.pictureInPictureElement?document.exitPictureInPicture():this.video!==document.pictureInPictureElement&&this.video.requestPictureInPicture&&this.video.requestPictureInPicture()}screenshot(){const t=document.createElement("canvas");t.width=this.video.videoWidth,t.height=this.video.videoHeight;const s=t.getContext("2d");if(s){s.drawImage(this.video,0,0,t.width,t.height);try{const o=t.toDataURL("image/png"),a=document.createElement("a");a.download=`screenshot-${new Date().toISOString()}.png`,a.href=o,a.click(),this.notify({type:"success",message:"Screenshot saved",duration:2e3})}catch{this.notify({type:"error",message:"Failed to take screenshot",duration:3e3})}}}toggleLock(){this.store.setState(t=>({isLocked:!t.isLocked}))}toggleLoop(){this.video.loop=!this.video.loop,this.store.setState({isLooping:this.video.loop}),this.notify({type:"info",message:`Loop: ${this.video.loop?"On":"Off"}`,duration:1500})}setFlip(t){const s=this.store.get().flipState,o={...s,[t]:!s[t]};this.store.setState({flipState:o});const a=o.horizontal?-1:1,d=o.vertical?-1:1;this.video.style.transform=`scale(${a}, ${d})`}setAspectRatio(t){this.store.setState({aspectRatio:t}),this.updateAspectRatio(),t!=="default"&&this.notify({type:"info",message:`Aspect Ratio: ${t}`,duration:2e3})}setVideoFit(t){this.store.setState({videoFit:t}),this.video.style.objectFit=t,this.updateAspectRatio()}setBrightness(t){const s=Math.max(0,Math.min(t,2));this.store.setState({brightness:s}),this.video.style.filter=`brightness(${s})`}updateAspectRatio(){if(!this.container)return;const{aspectRatio:t,videoFit:s}=this.store.get();if(t==="default"){this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=s;return}const[o,a]=t.split(":").map(Number);if(!o||!a)return;const d=o/a,u=this.container.getBoundingClientRect();if(u.width===0||u.height===0)return;const x=u.width/u.height;let v,p;x>d?(p=u.height,v=p*d):(v=u.width,p=v/d),this.video.style.width=`${v}px`,this.video.style.height=`${p}px`,this.video.style.objectFit="fill"}initCast(){const t=window,s=()=>{if(!this.castInitialized)try{t.cast&&t.cast.framework&&t.chrome&&t.chrome.cast&&(t.cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:t.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:t.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),this.castInitialized=!0)}catch(o){console.warn("Cast Init Error or already initialized",o)}};t.cast&&t.cast.framework?s():t.__onGCastApiAvailable=o=>{o&&s()}}requestCast(){const t=window;if(t.cast&&t.cast.framework)try{this.castInitialized||this.initCast(),t.cast.framework.CastContext.getInstance().requestSession().then(()=>{this.loadMediaToCast()}).catch(s=>{s!=="cancel"&&this.notify({type:"error",message:"Cast failed: "+s,duration:3e3})})}catch{this.notify({type:"warning",message:"Cast not available yet",duration:3e3})}else this.notify({type:"warning",message:"Cast API not loaded",duration:3e3})}loadMediaToCast(){const t=window;try{const s=t.cast.framework.CastContext.getInstance().getCurrentSession();if(!s)return;const o=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),a=new t.chrome.cast.media.LoadRequest(o);s.loadMedia(a).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(d=>console.error("Cast load error",d))}catch(s){console.error("Failed to load media into Cast session",s)}}handleCueChange(){if(this.store.get().currentSubtitle===-1){this.store.setState({activeCues:[]});return}const o=Array.from(this.video.textTracks).filter(a=>a.kind==="subtitles"||a.kind==="captions").find(a=>a.mode==="showing"||a.mode==="hidden");if(o&&o.activeCues){const a=Array.from(o.activeCues).map(d=>d.text);this.store.setState({activeCues:a})}else this.store.setState({activeCues:[]})}async setSubtitle(t){const o=this.store.get().subtitleTracks[t];if(Array.from(this.video.textTracks).forEach(u=>{u.removeEventListener("cuechange",this.boundCueChange),u.mode="disabled"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t===-1||!o)return;if(o.status==="idle"||o.status==="error"){this.updateSubtitleTrackState(t,{status:"loading"});try{let x=await(await this.fetchWithRetry(o.src)).text();x=this.convertToVTT(x);const v=new Blob([x],{type:"text/vtt"}),p=URL.createObjectURL(v);this.addTextTrackInternal(p,o.label,o.srcLang,!1),this.updateSubtitleTrackState(t,{status:"success"})}catch(u){this.updateSubtitleTrackState(t,{status:"error"}),console.error("Failed to load subtitle",u);return}}const a=Array.from(this.video.textTracks);let d=a.find(u=>u.label===o.label&&u.language===o.srcLang);if(d||(d=a.find(u=>u.label===o.label)),d){const u=this.store.get().subtitleSettings;d.mode=u.useNative?"showing":"hidden",d.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}updateSubtitleSettings(t){const o={...this.store.get().subtitleSettings,...t};if(this.store.setState({subtitleSettings:o}),t.useNative!==void 0){const a=this.store.get().currentSubtitle;if(a!==-1){const u=this.store.get().subtitleTracks[a],x=Array.from(this.video.textTracks).find(v=>v.label===u.label&&v.language===u.srcLang);x&&(x.mode=t.useNative?"showing":"hidden")}}}resetSubtitleSettings(){this.store.setState({subtitleSettings:et}),this.updateSubtitleSettings({useNative:!1})}setSubtitleOffset(t){const s=this.store.get().subtitleOffset,o=t-s;Math.abs(o)<.001||(Array.from(this.video.textTracks).forEach(a=>{(a.mode==="showing"||a.mode==="hidden")&&a.cues&&Array.from(a.cues).forEach(d=>{d.startTime+=o,d.endTime+=o})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}cancelDownload(t){var s;t&&this.activeDownloads.has(t)?((s=this.activeDownloads.get(t))==null||s.abort(),this.activeDownloads.delete(t),this.notify({type:"info",message:"Download cancelled",duration:2e3}),this.removeNotification(t)):t||this.activeDownloads.size>0&&(this.activeDownloads.forEach(o=>o.abort()),this.activeDownloads.clear(),this.notify({type:"info",message:"All downloads cancelled",duration:2e3}))}async download(t={}){var u,x,v;const s=((u=this.currentSource)==null?void 0:u.url)||this.video.src;if(!s)return;if(s.includes(".m3u8")||((x=this.currentSource)==null?void 0:x.type)==="hls"){this.downloadHls(s,t.format||"ts");return}if(s.startsWith("blob:")){this.notify({type:"warning",message:"Stream download not supported in browser.",duration:4e3});return}const o=Math.random().toString(36).substr(2,9),a=new AbortController;this.activeDownloads.set(o,a);const d=a.signal;this.notify({id:o,type:"loading",message:"Preparing download",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}});try{const p=await this.fetchWithRetry(s,3,void 0,d);if(!p.body)throw new Error("No body");const h=p.body.getReader(),g=p.headers.get("Content-Length"),f=g?parseInt(g,10):0;let k=0;const F=[],H=Date.now(),D=[];let G=0;for(;;){const{done:ue,value:y}=await h.read();if(ue)break;if(F.push(y),k+=y.length,f){const O=Date.now();if(O-G>800||k===f){G=O;const V=Math.round(k/f*100);for(D.push({time:O,loaded:k});D.length>0&&O-D[0].time>5e3;)D.shift();let N="",n=0;if(D.length>1){const q=D[0],U=D[D.length-1],ee=U.time-q.time,ie=U.loaded-q.loaded;ee>0&&(n=ie/ee)}else{const q=O-H;q>0&&(n=k/q)}if(n>0){const U=(f-k)/n;N=`
6
- ${this.formatDuration(U)} remaining`}this.notify({id:o,type:"loading",message:`${N}`,progress:V,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}})}}}const b=new Blob(F),_=window.URL.createObjectURL(b),W=document.createElement("a");W.style.display="none",W.href=_,W.download=((v=s.split("/").pop())==null?void 0:v.split("?")[0])||"video.mp4",document.body.appendChild(W),W.click(),window.URL.revokeObjectURL(_),document.body.removeChild(W),this.notify({id:o,type:"success",message:"Saved!",duration:3e3})}catch{d.aborted?this.removeNotification(o):(this.notify({id:o,type:"error",message:"Download failed.",duration:4e3}),window.open(s,"_blank"))}finally{this.activeDownloads.delete(o)}}async downloadHls(t,s){var u;const o=Math.random().toString(36).substr(2,9),a=new AbortController;this.activeDownloads.set(o,a);const d=a.signal;this.notify({id:o,type:"loading",message:"Analyzing HLS stream",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}});try{let x=await this.fetchWithRetry(t,3,void 0,d),v=await x.text(),p=t.substring(0,t.lastIndexOf("/")+1);if(v.includes("#EXT-X-STREAM-INF")){this.notify({id:o,type:"loading",message:"Selecting best quality",progress:0});const y=v.split(`
7
- `);let O=0,V="";for(let N=0;N<y.length;N++)if(y[N].includes("#EXT-X-STREAM-INF")){const n=y[N].match(/BANDWIDTH=(\d+)/);if(n){const q=parseInt(n[1]);let U=(u=y[N+1])==null?void 0:u.trim();U&&!U.startsWith("#")&&q>O&&(O=q,V=U)}}V&&(V.startsWith("http")||(V=p+V),x=await this.fetchWithRetry(V,3,void 0,d),v=await x.text(),p=V.substring(0,V.lastIndexOf("/")+1))}if(v.includes("#EXT-X-KEY"))throw new Error("Encrypted HLS streams are not supported for download.");const h=v.split(`
8
- `),g=[];for(let y of h)y=y.trim(),y&&!y.startsWith("#")&&(y.startsWith("http")?g.push(y):g.push(p+y));if(g.length===0)throw new Error("No segments found.");let f=s==="mp4"?"mp4":"ts",k=s==="mp4"?"video/mp4":"video/mp2t",F=null,H=null,D=[];if("showSaveFilePicker"in window)try{F=await window.showSaveFilePicker({suggestedName:`video.${f}`,types:[{description:s==="mp4"?"MPEG-4 Video":"MPEG Transport Stream",accept:{[k]:[`.${f}`]}}]}),H=await F.createWritable()}catch(y){if(y.name==="AbortError"){this.removeNotification(o),this.notify({type:"info",message:"Download cancelled",duration:2e3}),this.activeDownloads.delete(o);return}console.warn("File System API cancelled or failed, falling back to memory",y)}let b=!1;const _=Date.now(),W=[];let ue=0;for(let y=0;y<g.length&&!d.aborted;y++){const O=Date.now();if(O-ue>800||y===0||y===g.length-1){ue=O;const q=Math.round((y+1)/g.length*100);for(W.push({time:O,count:y+1});W.length>0&&O-W[0].time>5e3;)W.shift();let U="";if(W.length>1){const ee=W[0],ie=W[W.length-1],he=ie.time-ee.time,me=ie.count-ee.count;if(he>0&&me>0){const je=he/me,$e=(g.length-(y+1))*je;U=`
9
- ${this.formatDuration($e)} remaining`}}else if(y>0){const ie=(O-_)/y,me=(g.length-y)*ie;U=`
10
- ${this.formatDuration(me)} remaining`}this.notify({id:o,type:"loading",message:`Downloading segment ${y+1}/${g.length}${U}`,progress:q,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}})}const N=await(await this.fetchWithRetry(g[y],3,void 0,d)).arrayBuffer();y===0&&new Uint8Array(N.slice(0,4))[0]===71&&(b=!0,s==="mp4"&&(this.notify({type:"info",message:"Stream is MPEG-TS. Downloading as .ts to prevent corruption.",duration:5e3}),f="ts",k="video/mp2t"));const n=new Blob([N]);H?await H.write(n):D.push(n)}if(d.aborted)throw H&&await H.abort(),new Error("Aborted");if(H)await H.close(),this.notify({id:o,type:"success",message:"Download complete!",duration:3e3});else{this.notify({id:o,type:"loading",message:"Stitching video",progress:100});const y=new Blob(D,{type:k}),O=window.URL.createObjectURL(y),V=document.createElement("a");V.style.display="none",V.href=O;const N=s==="mp4"&&b?"ts":f;V.download=`video.${N}`,document.body.appendChild(V),V.click(),window.URL.revokeObjectURL(O),document.body.removeChild(V),this.notify({id:o,type:"success",message:"Saved!",duration:3e3})}}catch(x){d.aborted?this.removeNotification(o):this.notify({id:o,type:"error",message:`Download failed: ${x.message}`,duration:4e3})}finally{this.activeDownloads.delete(o)}}notify(t){const s=t.id||Math.random().toString(36).substr(2,9),o={...t,id:s};return this.store.setState(a=>a.notifications.find(u=>u.id===s)?{notifications:a.notifications.map(u=>u.id===s?o:u)}:{notifications:[...a.notifications,o]}),t.duration&&setTimeout(()=>this.removeNotification(s),t.duration),s}removeNotification(t){const s=this.store.get().notifications;this.store.setState({notifications:s.filter(o=>o.id!==t)})}setAppearance(t){this.store.setState(s=>({...s,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.activeDownloads.forEach(s=>s.abort()),this.activeDownloads.clear(),this.store.get().isWebFullscreen&&typeof document<"u"&&(document.body.style.overflow=""),document.removeEventListener("fullscreenchange",this.boundFullscreenChange),this.video.pause(),this.video.src="";const t=this.video.getElementsByTagName("track");for(;t.length>0;)t[0].remove();this.emit("destroy"),this.events.destroy(),this.store.destroy(),this.plugins.forEach(s=>s.destroy&&s.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const Qe=(i,t=200)=>{const[s,o]=m.useState(i),[a,d]=m.useState(!1);return m.useEffect(()=>{if(i)o(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{d(!0)})});else{d(!1);const u=setTimeout(()=>{o(!1)},t);return()=>clearTimeout(u)}},[i,t]),{isMounted:s,isVisible:a}},j=({className:i,children:t,fill:s="none",strokeWidth:o=2,viewBox:a="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:a,fill:s,stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",className:i,children:t}),Lt=({className:i})=>e.jsx(j,{className:i,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),$t=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"4",height:"16",x:"6",y:"4",rx:"1"}),e.jsx("rect",{width:"4",height:"16",x:"14",y:"4",rx:"1"})]}),Et=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),Ns=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),At=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("line",{x1:"23",x2:"17",y1:"9",y2:"15"}),e.jsx("line",{x1:"17",x2:"23",y1:"9",y2:"15"})]}),Ms=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),e.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),e.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),e.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]}),Ts=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),e.jsx("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),e.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}),e.jsx("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"})]}),zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.47a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Fe=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),Rs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),e.jsx("rect",{x:"12",y:"13",width:"10",height:"7",rx:"2"})]}),Is=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 15h4"}),e.jsx("path",{d:"M15 15h2"}),e.jsx("path",{d:"M7 11h2"}),e.jsx("path",{d:"M13 11h4"})]}),Je=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),Ps=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]}),Fs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),Ie=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Ls=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 16.1A5 5 0 0 1 5.9 20"}),e.jsx("path",{d:"M2 12.05A9 9 0 0 1 9.95 20"}),e.jsx("path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"}),e.jsx("line",{x1:"2",x2:"2.01",y1:"20",y2:"20"})]}),$s=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),Es=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),As=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M5 12h14"})}),Vs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),qt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M4 21v-7"}),e.jsx("path",{d:"M4 10V3"}),e.jsx("path",{d:"M12 21v-9"}),e.jsx("path",{d:"M12 8V3"}),e.jsx("path",{d:"M20 21v-5"}),e.jsx("path",{d:"M20 12V3"}),e.jsx("path",{d:"M1 14h6"}),e.jsx("path",{d:"M9 8h6"}),e.jsx("path",{d:"M17 16h6"})]}),Bs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",x2:"15",y1:"20",y2:"20"}),e.jsx("line",{x1:"12",x2:"12",y1:"4",y2:"20"})]}),_t=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]}),Ds=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Os=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polyline",{points:"8 18 12 22 16 18"}),e.jsx("polyline",{points:"8 6 12 2 16 6"}),e.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"})]}),Hs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),Ws=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]}),Us=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m3 17 4-10 4 10"}),e.jsx("path",{d:"M4 13h6"}),e.jsx("path",{d:"M15 12h4.5a2.5 2.5 0 0 1 0 5H15V7h4a2.5 2.5 0 0 1 0 5h-4"})]}),Gs=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"})}),qs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),_s=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),Xs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}),Qs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),Ys=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"13 19 22 12 13 5 13 19"}),e.jsx("polygon",{points:"2 19 11 12 2 5 2 19"})]}),Xt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Js=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]}),Ks=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),Zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M6 2v14a2 2 0 0 0 2 2h14"}),e.jsx("path",{d:"M18 22V8a2 2 0 0 0-2-2H2"})]}),ei=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}),e.jsx("circle",{cx:"12",cy:"14",r:"4"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"6",y2:"6"})]}),ti=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 14 4-4"}),e.jsx("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"})]}),si=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]}),ii=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),e.jsx("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),e.jsx("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"20",y2:"20"})]}),Ke=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),ni=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 20h.01"}),e.jsx("path",{d:"M7 20v-4"}),e.jsx("path",{d:"M12 20v-8"}),e.jsx("path",{d:"M17 20V8"}),e.jsx("path",{d:"M22 20V4"})]}),oi=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 7v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 12h18"})]}),ai=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),Qt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"m9 15 2 2 4-4"})]}),ri=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M12 12v4"})]}),Vt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("path",{d:"M12 1v2"}),e.jsx("path",{d:"M12 21v2"}),e.jsx("path",{d:"M4.22 4.22l1.42 1.42"}),e.jsx("path",{d:"M18.36 18.36l1.42 1.42"}),e.jsx("path",{d:"M1 12h2"}),e.jsx("path",{d:"M21 12h2"}),e.jsx("path",{d:"M4.22 19.78l1.42-1.42"}),e.jsx("path",{d:"M18.36 5.64l1.42-1.42"})]}),li=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"7",x:"3",y:"3",rx:"1"}),e.jsx("rect",{width:"9",height:"7",x:"3",y:"14",rx:"1"}),e.jsx("rect",{width:"5",height:"7",x:"16",y:"14",rx:"1"})]}),Bt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{className:"w-full h-full",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),Dt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{className:"w-full h-full",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),ci=({notifications:i})=>e.jsx("div",{className:"absolute top-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[280px]",children:i.map(t=>{const s=typeof t.progress=="number";return e.jsx("div",{className:`
5
+ `+o}return s}formatDuration(t){if(!isFinite(t)||t<=0)return"";const s=Math.floor(t/1e3),o=Math.floor(s/(3600*24)),a=Math.floor(s%(3600*24)/3600),d=Math.floor(s%3600/60),u=s%60,x=[];return o>0&&x.push(`${o}d`),a>0&&x.push(`${a}h`),d>0&&x.push(`${d}m`),x.push(`${u}s`),x.join(" ")}attach(t){this.resizeObserver&&this.resizeObserver.disconnect(),this.container=t,this.container.appendChild(this.video),this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=this.store.get().videoFit,this.video.style.backgroundColor="black",this.updateAspectRatio(),this.resizeObserver=new ResizeObserver(s=>{for(const o of s)this.emit("resize",{width:o.contentRect.width,height:o.contentRect.height}),this.updateAspectRatio()}),this.resizeObserver.observe(this.container),this.emit("ready")}use(t){this.plugins.has(t.name)||(t.init(this),this.plugins.set(t.name,t))}setSources(t,s=[]){this.store.setState({sources:t}),this.trackConfigs=s,t.length>0&&this.load(t[0],s)}switchSource(t){const s=this.store.get().sources;if(t>=0&&t<s.length){const o=this.video.currentTime,a=!this.video.paused;this.load(s[t],this.trackConfigs);const d=()=>{this.video.currentTime=o,a&&this.video.play(),this.video.removeEventListener("canplay",d)};this.video.addEventListener("canplay",d)}}load(t,s=[],o=!1){this.retryTimer&&clearTimeout(this.retryTimer);const a=typeof t=="string"?{url:t,type:"auto"}:t;o||(this.retryCount=0,this.store.setState({error:null}),this.removeNotification("retry")),this.currentSrc=a.url,this.currentSource=a,this.trackConfigs=s;const u=this.store.get().sources.findIndex(v=>v.url===a.url),x=s.map((v,f)=>({...v,index:f,status:"idle",isDefault:!!v.default}));this.store.setState({isBuffering:!0,qualityLevels:[],currentQuality:-1,audioTracks:[],currentAudioTrack:-1,subtitleTracks:x,currentSubtitle:-1,currentSourceIndex:u}),this.updateMediaSessionMetadata();let g=a.type||"auto";g==="auto"&&(a.url.includes(".m3u8")?g="hls":a.url.includes(".mpd")?g="dash":a.url.includes(".flv")||a.url.includes(".ts")?g="mpegts":a.url.startsWith("magnet:")||a.url.includes(".torrent")?g="webtorrent":g="mp4"),this.events.emit("load",{url:a.url,type:g});const p=this.video.getElementsByTagName("track");for(;p.length>0;)p[0].remove();const h=x.findIndex(v=>v.default);h!==-1&&this.setSubtitle(h),(g==="mp4"||g==="webm"||g==="ogg")&&(this.video.src=a.url)}loadSubtitle(t,s="Subtitle"){const o=this.store.get().subtitleTracks.length,a={src:t,label:s,srcLang:"user",default:!0,kind:"subtitles",index:o,status:"idle",isDefault:!0};this.store.setState(d=>({subtitleTracks:[...d.subtitleTracks,a]})),this.setSubtitle(o)}addTextTrack(t,s){const o=new FileReader;o.onload=a=>{var g;if(!((g=a.target)!=null&&g.result))return;let d=a.target.result;d=this.convertToVTT(d);const u=new Blob([d],{type:"text/vtt"}),x=URL.createObjectURL(u);this.loadSubtitle(x,s),this.notify({type:"success",message:"Subtitle uploaded",duration:3e3})},o.onerror=()=>{this.notify({type:"error",message:"Failed to read file",duration:3e3})},o.readAsText(t)}addTextTrackInternal(t,s,o="",a=!1){const d=document.createElement("track");d.kind="subtitles",d.label=s,d.src=t,d.srclang=o,a&&(d.default=!0),this.video.appendChild(d)}play(){return this.video.play()}pause(){return this.video.pause()}togglePlay(){this.video.paused?this.play():this.pause()}seek(t){if(isNaN(t))return;const s=Math.max(0,Math.min(t,this.video.duration));this.store.setState({currentTime:s}),this.video.currentTime=s}skip(t){this.seek(this.video.currentTime+t)}setVolume(t){const s=Math.max(0,Math.min(t,1));this.video.volume=s,s>0&&this.video.muted&&(this.video.muted=!1),s===0&&(this.video.muted=!0)}toggleMute(){this.video.muted=!this.video.muted}setAudioGain(t){this.store.setState({audioGain:t}),this.audioEngine.setGain(t)}setQuality(t){this.store.setState({currentQuality:t}),this.events.emit("quality-request",t)}setAudioTrack(t){this.store.setState({currentAudioTrack:t}),this.events.emit("audio-track-request",t)}setControlsVisible(t){this.store.get().controlsVisible!==t&&(this.store.setState({controlsVisible:t}),this.emit("control",t))}async toggleFullscreen(){if(!this.container)return;const t=document,s=this.container;if(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement){t.exitFullscreen?await t.exitFullscreen().catch(()=>{}):t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen();return}if(this.store.get().isWebFullscreen){this.toggleWebFullscreen();return}try{if(s.requestFullscreen)await s.requestFullscreen();else if(s.webkitRequestFullscreen)s.webkitRequestFullscreen();else if(s.mozRequestFullScreen)s.mozRequestFullScreen();else if(s.msRequestFullscreen)s.msRequestFullscreen();else if(this.video&&this.video.webkitEnterFullscreen)this.video.webkitEnterFullscreen();else throw new Error("Native fullscreen API not supported")}catch(a){console.warn("Native fullscreen failed, falling back to Web Fullscreen",a),this.toggleWebFullscreen()}}toggleWebFullscreen(){const t=this.store.get().isWebFullscreen,s=document;(s.fullscreenElement||s.webkitFullscreenElement||s.mozFullScreenElement||s.msFullscreenElement)&&(s.exitFullscreen?s.exitFullscreen().catch(()=>{}):s.webkitExitFullscreen?s.webkitExitFullscreen():s.mozCancelFullScreen?s.mozCancelFullScreen():s.msExitFullscreen&&s.msExitFullscreen());const o=!t;this.store.setState({isWebFullscreen:o}),typeof document<"u"&&(document.body.style.overflow=o?"hidden":""),this.emit("webfullscreen",o)}togglePip(){document.pictureInPictureElement?document.exitPictureInPicture():this.video!==document.pictureInPictureElement&&this.video.requestPictureInPicture&&this.video.requestPictureInPicture()}screenshot(){const t=document.createElement("canvas");t.width=this.video.videoWidth,t.height=this.video.videoHeight;const s=t.getContext("2d");if(s){s.drawImage(this.video,0,0,t.width,t.height);try{const o=t.toDataURL("image/png"),a=document.createElement("a");a.download=`screenshot-${new Date().toISOString()}.png`,a.href=o,a.click(),this.notify({type:"success",message:"Screenshot saved",duration:2e3})}catch{this.notify({type:"error",message:"Failed to take screenshot",duration:3e3})}}}toggleLock(){this.store.setState(t=>({isLocked:!t.isLocked}))}toggleLoop(){this.video.loop=!this.video.loop,this.store.setState({isLooping:this.video.loop}),this.notify({type:"info",message:`Loop: ${this.video.loop?"On":"Off"}`,duration:1500})}setFlip(t){const s=this.store.get().flipState,o={...s,[t]:!s[t]};this.store.setState({flipState:o});const a=o.horizontal?-1:1,d=o.vertical?-1:1;this.video.style.transform=`scale(${a}, ${d})`}setAspectRatio(t){this.store.setState({aspectRatio:t}),this.updateAspectRatio(),t!=="default"&&this.notify({type:"info",message:`Aspect Ratio: ${t}`,duration:2e3})}setVideoFit(t){this.store.setState({videoFit:t}),this.video.style.objectFit=t,this.updateAspectRatio()}setBrightness(t){const s=Math.max(0,Math.min(t,2));this.store.setState({brightness:s}),this.video.style.filter=`brightness(${s})`}updateAspectRatio(){if(!this.container)return;const{aspectRatio:t,videoFit:s}=this.store.get();if(t==="default"){this.video.style.width="100%",this.video.style.height="100%",this.video.style.objectFit=s;return}const[o,a]=t.split(":").map(Number);if(!o||!a)return;const d=o/a,u=this.container.getBoundingClientRect();if(u.width===0||u.height===0)return;const x=u.width/u.height;let g,p;x>d?(p=u.height,g=p*d):(g=u.width,p=g/d),this.video.style.width=`${g}px`,this.video.style.height=`${p}px`,this.video.style.objectFit="fill"}initCast(){const t=window,s=()=>{if(!this.castInitialized)try{t.cast&&t.cast.framework&&t.chrome&&t.chrome.cast&&(t.cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:t.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:t.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),this.castInitialized=!0)}catch(o){console.warn("Cast Init Error or already initialized",o)}};t.cast&&t.cast.framework?s():t.__onGCastApiAvailable=o=>{o&&s()}}requestCast(){const t=window;if(t.cast&&t.cast.framework)try{this.castInitialized||this.initCast(),t.cast.framework.CastContext.getInstance().requestSession().then(()=>{this.loadMediaToCast()}).catch(s=>{s!=="cancel"&&this.notify({type:"error",message:"Cast failed: "+s,duration:3e3})})}catch{this.notify({type:"warning",message:"Cast not available yet",duration:3e3})}else this.notify({type:"warning",message:"Cast API not loaded",duration:3e3})}loadMediaToCast(){const t=window;try{const s=t.cast.framework.CastContext.getInstance().getCurrentSession();if(!s)return;const o=new t.chrome.cast.media.MediaInfo(this.currentSrc,this.currentSrc.includes(".m3u8")?"application/x-mpegurl":"video/mp4"),a=new t.chrome.cast.media.LoadRequest(o);s.loadMedia(a).then(()=>{this.notify({type:"success",message:"Casting...",duration:3e3})}).catch(d=>console.error("Cast load error",d))}catch(s){console.error("Failed to load media into Cast session",s)}}handleCueChange(){if(this.store.get().currentSubtitle===-1){this.store.setState({activeCues:[]});return}const o=Array.from(this.video.textTracks).filter(a=>a.kind==="subtitles"||a.kind==="captions").find(a=>a.mode==="showing"||a.mode==="hidden");if(o&&o.activeCues){const a=Array.from(o.activeCues).map(d=>d.text);this.store.setState({activeCues:a})}else this.store.setState({activeCues:[]})}async setSubtitle(t){const o=this.store.get().subtitleTracks[t];if(Array.from(this.video.textTracks).forEach(u=>{u.removeEventListener("cuechange",this.boundCueChange),u.mode="disabled"}),this.store.setState({currentSubtitle:t,subtitleOffset:0,activeCues:[]}),t===-1||!o)return;if(o.status==="idle"||o.status==="error"){this.updateSubtitleTrackState(t,{status:"loading"});try{let x=await(await this.fetchWithRetry(o.src)).text();x=this.convertToVTT(x);const g=new Blob([x],{type:"text/vtt"}),p=URL.createObjectURL(g);this.addTextTrackInternal(p,o.label,o.srcLang,!1),this.updateSubtitleTrackState(t,{status:"success"})}catch(u){this.updateSubtitleTrackState(t,{status:"error"}),console.error("Failed to load subtitle",u);return}}const a=Array.from(this.video.textTracks);let d=a.find(u=>u.label===o.label&&u.language===o.srcLang);if(d||(d=a.find(u=>u.label===o.label)),d){const u=this.store.get().subtitleSettings;d.mode=u.useNative?"showing":"hidden",d.addEventListener("cuechange",this.boundCueChange),this.handleCueChange()}}updateSubtitleSettings(t){const o={...this.store.get().subtitleSettings,...t};if(this.store.setState({subtitleSettings:o}),t.useNative!==void 0){const a=this.store.get().currentSubtitle;if(a!==-1){const u=this.store.get().subtitleTracks[a],x=Array.from(this.video.textTracks).find(g=>g.label===u.label&&g.language===u.srcLang);x&&(x.mode=t.useNative?"showing":"hidden")}}}resetSubtitleSettings(){this.store.setState({subtitleSettings:et}),this.updateSubtitleSettings({useNative:!1})}setSubtitleOffset(t){const s=this.store.get().subtitleOffset,o=t-s;Math.abs(o)<.001||(Array.from(this.video.textTracks).forEach(a=>{(a.mode==="showing"||a.mode==="hidden")&&a.cues&&Array.from(a.cues).forEach(d=>{d.startTime+=o,d.endTime+=o})}),this.store.setState({subtitleOffset:t}),this.notify({type:"info",message:`Subtitle Offset: ${t>0?"+":""}${t.toFixed(1)}s`,duration:1500}))}cancelDownload(t){var s;t&&this.activeDownloads.has(t)?((s=this.activeDownloads.get(t))==null||s.abort(),this.activeDownloads.delete(t),this.notify({type:"info",message:"Download cancelled",duration:2e3}),this.removeNotification(t)):t||this.activeDownloads.size>0&&(this.activeDownloads.forEach(o=>o.abort()),this.activeDownloads.clear(),this.notify({type:"info",message:"All downloads cancelled",duration:2e3}))}async download(t={}){var u,x,g;const s=((u=this.currentSource)==null?void 0:u.url)||this.video.src;if(!s)return;if(s.includes(".m3u8")||((x=this.currentSource)==null?void 0:x.type)==="hls"){this.downloadHls(s,t.format||"ts");return}if(s.startsWith("blob:")){this.notify({type:"warning",message:"Stream download not supported in browser.",duration:4e3});return}const o=Math.random().toString(36).substr(2,9),a=new AbortController;this.activeDownloads.set(o,a);const d=a.signal;this.notify({id:o,type:"loading",message:"Preparing download",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}});try{const p=await this.fetchWithRetry(s,3,void 0,d);if(!p.body)throw new Error("No body");const h=p.body.getReader(),v=p.headers.get("Content-Length"),f=v?parseInt(v,10):0;let k=0;const E=[],H=Date.now(),D=[];let q=0;for(;;){const{done:ue,value:y}=await h.read();if(ue)break;if(E.push(y),k+=y.length,f){const O=Date.now();if(O-q>800||k===f){q=O;const V=Math.round(k/f*100);for(D.push({time:O,loaded:k});D.length>0&&O-D[0].time>5e3;)D.shift();let N="",n=0;if(D.length>1){const G=D[0],U=D[D.length-1],ee=U.time-G.time,ie=U.loaded-G.loaded;ee>0&&(n=ie/ee)}else{const G=O-H;G>0&&(n=k/G)}if(n>0){const U=(f-k)/n;N=`
6
+ ${this.formatDuration(U)} remaining`}this.notify({id:o,type:"loading",message:`${N}`,progress:V,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}})}}}const b=new Blob(E),_=window.URL.createObjectURL(b),W=document.createElement("a");W.style.display="none",W.href=_,W.download=((g=s.split("/").pop())==null?void 0:g.split("?")[0])||"video.mp4",document.body.appendChild(W),W.click(),window.URL.revokeObjectURL(_),document.body.removeChild(W),this.notify({id:o,type:"success",message:"Saved!",duration:3e3})}catch{d.aborted?this.removeNotification(o):(this.notify({id:o,type:"error",message:"Download failed.",duration:4e3}),window.open(s,"_blank"))}finally{this.activeDownloads.delete(o)}}async downloadHls(t,s){var u;const o=Math.random().toString(36).substr(2,9),a=new AbortController;this.activeDownloads.set(o,a);const d=a.signal;this.notify({id:o,type:"loading",message:"Analyzing HLS stream",progress:0,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}});try{let x=await this.fetchWithRetry(t,3,void 0,d),g=await x.text(),p=t.substring(0,t.lastIndexOf("/")+1);if(g.includes("#EXT-X-STREAM-INF")){this.notify({id:o,type:"loading",message:"Selecting best quality",progress:0});const y=g.split(`
7
+ `);let O=0,V="";for(let N=0;N<y.length;N++)if(y[N].includes("#EXT-X-STREAM-INF")){const n=y[N].match(/BANDWIDTH=(\d+)/);if(n){const G=parseInt(n[1]);let U=(u=y[N+1])==null?void 0:u.trim();U&&!U.startsWith("#")&&G>O&&(O=G,V=U)}}V&&(V.startsWith("http")||(V=p+V),x=await this.fetchWithRetry(V,3,void 0,d),g=await x.text(),p=V.substring(0,V.lastIndexOf("/")+1))}if(g.includes("#EXT-X-KEY"))throw new Error("Encrypted HLS streams are not supported for download.");const h=g.split(`
8
+ `),v=[];for(let y of h)y=y.trim(),y&&!y.startsWith("#")&&(y.startsWith("http")?v.push(y):v.push(p+y));if(v.length===0)throw new Error("No segments found.");let f=s==="mp4"?"mp4":"ts",k=s==="mp4"?"video/mp4":"video/mp2t",E=null,H=null,D=[];if("showSaveFilePicker"in window)try{E=await window.showSaveFilePicker({suggestedName:`video.${f}`,types:[{description:s==="mp4"?"MPEG-4 Video":"MPEG Transport Stream",accept:{[k]:[`.${f}`]}}]}),H=await E.createWritable()}catch(y){if(y.name==="AbortError"){this.removeNotification(o),this.notify({type:"info",message:"Download cancelled",duration:2e3}),this.activeDownloads.delete(o);return}console.warn("File System API cancelled or failed, falling back to memory",y)}let b=!1;const _=Date.now(),W=[];let ue=0;for(let y=0;y<v.length&&!d.aborted;y++){const O=Date.now();if(O-ue>800||y===0||y===v.length-1){ue=O;const G=Math.round((y+1)/v.length*100);for(W.push({time:O,count:y+1});W.length>0&&O-W[0].time>5e3;)W.shift();let U="";if(W.length>1){const ee=W[0],ie=W[W.length-1],he=ie.time-ee.time,me=ie.count-ee.count;if(he>0&&me>0){const je=he/me,Le=(v.length-(y+1))*je;U=`
9
+ ${this.formatDuration(Le)} remaining`}}else if(y>0){const ie=(O-_)/y,me=(v.length-y)*ie;U=`
10
+ ${this.formatDuration(me)} remaining`}this.notify({id:o,type:"loading",message:`Downloading segment ${y+1}/${v.length}${U}`,progress:G,action:{label:"Cancel",onClick:()=>this.cancelDownload(o)}})}const N=await(await this.fetchWithRetry(v[y],3,void 0,d)).arrayBuffer();y===0&&new Uint8Array(N.slice(0,4))[0]===71&&(b=!0,s==="mp4"&&(this.notify({type:"info",message:"Stream is MPEG-TS. Downloading as .ts to prevent corruption.",duration:5e3}),f="ts",k="video/mp2t"));const n=new Blob([N]);H?await H.write(n):D.push(n)}if(d.aborted)throw H&&await H.abort(),new Error("Aborted");if(H)await H.close(),this.notify({id:o,type:"success",message:"Download complete!",duration:3e3});else{this.notify({id:o,type:"loading",message:"Stitching video",progress:100});const y=new Blob(D,{type:k}),O=window.URL.createObjectURL(y),V=document.createElement("a");V.style.display="none",V.href=O;const N=s==="mp4"&&b?"ts":f;V.download=`video.${N}`,document.body.appendChild(V),V.click(),window.URL.revokeObjectURL(O),document.body.removeChild(V),this.notify({id:o,type:"success",message:"Saved!",duration:3e3})}}catch(x){d.aborted?this.removeNotification(o):this.notify({id:o,type:"error",message:`Download failed: ${x.message}`,duration:4e3})}finally{this.activeDownloads.delete(o)}}notify(t){const s=t.id||Math.random().toString(36).substr(2,9),o={...t,id:s};return this.store.setState(a=>a.notifications.find(u=>u.id===s)?{notifications:a.notifications.map(u=>u.id===s?o:u)}:{notifications:[...a.notifications,o]}),t.duration&&setTimeout(()=>this.removeNotification(s),t.duration),s}removeNotification(t){const s=this.store.get().notifications;this.store.setState({notifications:s.filter(o=>o.id!==t)})}setAppearance(t){this.store.setState(s=>({...s,...t}))}destroy(){this.retryTimer&&clearTimeout(this.retryTimer),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.activeDownloads.forEach(o=>o.abort()),this.activeDownloads.clear(),this.store.get().isWebFullscreen&&typeof document<"u"&&(document.body.style.overflow=""),["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"].forEach(o=>document.removeEventListener(o,this.boundFullscreenChange)),this.video.pause(),this.video.src="";const s=this.video.getElementsByTagName("track");for(;s.length>0;)s[0].remove();this.emit("destroy"),this.events.destroy(),this.store.destroy(),this.plugins.forEach(o=>o.destroy&&o.destroy()),this.plugins.clear(),this.video.remove(),this.audioEngine.destroy()}}const Qe=(i,t=200)=>{const[s,o]=m.useState(i),[a,d]=m.useState(!1);return m.useEffect(()=>{if(i)o(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{d(!0)})});else{d(!1);const u=setTimeout(()=>{o(!1)},t);return()=>clearTimeout(u)}},[i,t]),{isMounted:s,isVisible:a}},j=({className:i,children:t,fill:s="none",strokeWidth:o=2,viewBox:a="0 0 24 24"})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:a,fill:s,stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",className:i,children:t}),Pt=({className:i})=>e.jsx(j,{className:i,children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),Lt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"4",height:"16",x:"6",y:"4",rx:"1"}),e.jsx("rect",{width:"4",height:"16",x:"14",y:"4",rx:"1"})]}),$t=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),Ns=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),At=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("line",{x1:"23",x2:"17",y1:"9",y2:"15"}),e.jsx("line",{x1:"17",x2:"23",y1:"9",y2:"15"})]}),Ms=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),e.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),e.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),e.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]}),Ts=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),e.jsx("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),e.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}),e.jsx("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"})]}),zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.47a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Ee=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),Fs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),e.jsx("rect",{x:"12",y:"13",width:"10",height:"7",rx:"2"})]}),Rs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 15h4"}),e.jsx("path",{d:"M15 15h2"}),e.jsx("path",{d:"M7 11h2"}),e.jsx("path",{d:"M13 11h4"})]}),Je=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),Is=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]}),Es=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]}),Re=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Ps=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 16.1A5 5 0 0 1 5.9 20"}),e.jsx("path",{d:"M2 12.05A9 9 0 0 1 9.95 20"}),e.jsx("path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"}),e.jsx("line",{x1:"2",x2:"2.01",y1:"20",y2:"20"})]}),Ls=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),$s=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),As=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M5 12h14"})}),Vs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"M12 5v14"})]}),Gt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M4 21v-7"}),e.jsx("path",{d:"M4 10V3"}),e.jsx("path",{d:"M12 21v-9"}),e.jsx("path",{d:"M12 8V3"}),e.jsx("path",{d:"M20 21v-5"}),e.jsx("path",{d:"M20 12V3"}),e.jsx("path",{d:"M1 14h6"}),e.jsx("path",{d:"M9 8h6"}),e.jsx("path",{d:"M17 16h6"})]}),Bs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",x2:"15",y1:"20",y2:"20"}),e.jsx("line",{x1:"12",x2:"12",y1:"4",y2:"20"})]}),_t=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]}),Ds=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Os=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polyline",{points:"8 18 12 22 16 18"}),e.jsx("polyline",{points:"8 6 12 2 16 6"}),e.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"})]}),Hs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),Ws=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]}),Us=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m3 17 4-10 4 10"}),e.jsx("path",{d:"M4 13h6"}),e.jsx("path",{d:"M15 12h4.5a2.5 2.5 0 0 1 0 5H15V7h4a2.5 2.5 0 0 1 0 5h-4"})]}),qs=({className:i})=>e.jsx(j,{className:i,children:e.jsx("path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"})}),Gs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),_s=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),Xs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}),Qs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),Ys=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("polygon",{points:"13 19 22 12 13 5 13 19"}),e.jsx("polygon",{points:"2 19 11 12 2 5 2 19"})]}),Xt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),Js=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]}),Ks=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),Zs=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M6 2v14a2 2 0 0 0 2 2h14"}),e.jsx("path",{d:"M18 22V8a2 2 0 0 0-2-2H2"})]}),ei=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}),e.jsx("circle",{cx:"12",cy:"14",r:"4"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"6",y2:"6"})]}),ti=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"m12 14 4-4"}),e.jsx("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"})]}),si=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]}),ii=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),e.jsx("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),e.jsx("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"20",y2:"20"})]}),Ke=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),ni=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M2 20h.01"}),e.jsx("path",{d:"M7 20v-4"}),e.jsx("path",{d:"M12 20v-8"}),e.jsx("path",{d:"M17 20V8"}),e.jsx("path",{d:"M22 20V4"})]}),oi=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M21 7v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 12h18"})]}),ai=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),Qt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"m9 15 2 2 4-4"})]}),ri=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M12 12v4"})]}),Vt=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("path",{d:"M12 1v2"}),e.jsx("path",{d:"M12 21v2"}),e.jsx("path",{d:"M4.22 4.22l1.42 1.42"}),e.jsx("path",{d:"M18.36 18.36l1.42 1.42"}),e.jsx("path",{d:"M1 12h2"}),e.jsx("path",{d:"M21 12h2"}),e.jsx("path",{d:"M4.22 19.78l1.42-1.42"}),e.jsx("path",{d:"M18.36 5.64l1.42-1.42"})]}),li=({className:i})=>e.jsxs(j,{className:i,children:[e.jsx("rect",{width:"18",height:"7",x:"3",y:"3",rx:"1"}),e.jsx("rect",{width:"9",height:"7",x:"3",y:"14",rx:"1"}),e.jsx("rect",{width:"5",height:"7",x:"16",y:"14",rx:"1"})]}),Bt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{className:"w-full h-full",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),Dt=({className:i})=>e.jsxs("div",{className:`relative flex items-center justify-center ${i}`,children:[e.jsxs(j,{className:"w-full h-full",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"})]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[32%] font-bold select-none mt-[1px]",children:"10"})]}),ci=({notifications:i})=>e.jsx("div",{className:"absolute top-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none font-sans max-w-[85%] md:max-w-[280px]",children:i.map(t=>{const s=typeof t.progress=="number";return e.jsx("div",{className:`
11
11
  relative overflow-hidden bg-zinc-950/80 backdrop-blur-xl border border-white/10 text-zinc-100 shadow-2xl rounded-lg pointer-events-auto
12
12
  animate-in slide-in-from-left-4 fade-in duration-300
13
13
  ${s?"w-64":"w-auto max-w-full px-3 py-2.5"}
14
- `,style:{borderRadius:"var(--radius)"},children:s?e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-white/10 flex items-center justify-center text-[var(--accent)] shrink-0",children:e.jsx(Je,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[e.jsxs("div",{className:"flex justify-between items-baseline mb-1",children:[e.jsx("span",{className:"text-xs font-bold text-white tracking-tight",children:"Downloading"}),e.jsxs("span",{className:"text-[10px] font-mono text-zinc-400",children:[t.progress,"%"]})]}),e.jsx("p",{className:"text-[10px] text-zinc-400 mb-2 leading-tight whitespace-pre-wrap",children:t.message.replace(/Downloading\.\.\. \d+%/,"").trim()||"Processing..."}),e.jsx("div",{className:"h-0.5 w-full bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)] transition-all duration-300 ease-out",style:{width:`${t.progress}%`}})})]}),t.action&&e.jsx("button",{onClick:o=>{var a;o.stopPropagation(),(a=t.action)==null||a.onClick()},className:"text-zinc-500 hover:text-zinc-200 transition-colors p-1 -mt-1.5 -mr-1.5",title:t.action.label,children:e.jsx(Xt,{className:"w-3.5 h-3.5"})})]})}):e.jsxs("div",{className:"flex items-start gap-2.5",children:[t.type==="loading"&&e.jsx(Ie,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)] shrink-0 mt-0.5"}),t.type==="success"&&e.jsx(Fe,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0 mt-0.5"}),t.type==="error"&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-red-500 shrink-0 mt-0.5"}),t.type==="warning"&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-amber-500 shrink-0 mt-0.5"}),t.type==="info"&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[var(--accent)] mt-1.5 shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium leading-snug break-words text-zinc-200 whitespace-pre-wrap",children:t.message}),t.action&&e.jsx("button",{onClick:o=>{var a;o.stopPropagation(),(a=t.action)==null||a.onClick()},className:"mt-1 self-start text-[10px] font-bold text-[var(--accent)] hover:text-white transition-colors uppercase tracking-wider",children:t.action.label})]})]})},t.id)})}),di=({cues:i,settings:t})=>{if(t.useNative||i.length===0)return null;const s=()=>{switch(t.textStyle){case"outline":return"0px 0px 4px black, 0px 0px 4px black";case"raised":return"0 -1px 1px black, 0 -2px 2px black";case"depressed":return"0 1px 1px white, 0 2px 2px black";case"shadow":return"2px 2px 2px rgba(0,0,0,0.8)";default:return"none"}};return e.jsx("div",{className:"absolute inset-x-0 flex flex-col items-center justify-end text-center z-10 pointer-events-none transition-all duration-200 strata-subtitle-overlay",style:{bottom:`${t.verticalOffset}px`},children:i.map((o,a)=>e.jsx("div",{className:"mb-1 inline-block max-w-[80%]",style:{fontSize:`${t.textSize}%`,color:t.textColor,fontWeight:t.isBold?"bold":"normal",textTransform:t.fixCapitalization?"capitalize":"none",textShadow:s(),lineHeight:1.4,whiteSpace:"pre-line"},children:e.jsx("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`rgba(0, 0, 0, ${t.backgroundOpacity/100})`,backdropFilter:t.backgroundBlur?`blur(${t.backgroundBlurAmount}px)`:"none"},dangerouslySetInnerHTML:{__html:o}})},a))})},Pe=({content:i})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{children:i}):e.jsx(e.Fragment,{children:i}),ne=({label:i,checked:t,onChange:s,icon:o,tooltip:a})=>e.jsxs("div",{className:"flex items-center justify-between py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[o&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Pe,{content:o})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm text-zinc-300 font-medium group-hover:text-white transition-colors flex items-center",children:e.jsx(Pe,{content:i})}),a&&e.jsx("span",{className:"text-[10px] text-zinc-500",children:a})]})]}),e.jsx("button",{onClick:()=>s(!t),className:`w-11 h-6 shrink-0 transition-colors relative focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-zinc-900 ${t?"bg-[var(--accent)]":"bg-zinc-700"}`,style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius-full)",borderWidth:"var(--border-width)",borderColor:"rgba(255,255,255,0.1)"},children:e.jsx("div",{className:`absolute top-1/2 -translate-y-1/2 left-1 w-4 h-4 transition-transform shadow-sm ${t?"translate-x-5":"translate-x-0"}`,style:{borderRadius:"var(--radius-full)",backgroundColor:t?"var(--accent-contrast)":"#ffffff"}})})]}),xe=({label:i,value:t,min:s,max:o,step:a,onChange:d,formatValue:u,icon:x})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[x&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Pe,{content:x})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:i})]}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-zinc-300 bg-white/10 px-1.5 py-0.5 tabular-nums",style:{borderRadius:"var(--radius-sm)"},children:u?u(t):t})]}),e.jsxs("div",{className:"relative h-4 flex items-center px-1",children:[e.jsx("input",{type:"range",min:s,max:o,step:a,value:t,onChange:v=>d(parseFloat(v.target.value)),className:"w-full h-1.5 appearance-none cursor-pointer focus:outline-none focus:ring-2 strata-range-input",style:{borderRadius:"var(--radius-full)",background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${(t-s)/(o-s)*100}%, #3f3f46 ${(t-s)/(o-s)*100}%, #3f3f46 100%)`,"--tw-ring-color":"var(--accent)"}}),e.jsx("style",{children:`
14
+ `,style:{borderRadius:"var(--radius)"},children:s?e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-white/10 flex items-center justify-center text-[var(--accent)] shrink-0",children:e.jsx(Je,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[e.jsxs("div",{className:"flex justify-between items-baseline mb-1",children:[e.jsx("span",{className:"text-xs font-bold text-white tracking-tight",children:"Downloading"}),e.jsxs("span",{className:"text-[10px] font-mono text-zinc-400",children:[t.progress,"%"]})]}),e.jsx("p",{className:"text-[10px] text-zinc-400 mb-2 leading-tight whitespace-pre-wrap",children:t.message.replace(/Downloading\.\.\. \d+%/,"").trim()||"Processing..."}),e.jsx("div",{className:"h-0.5 w-full bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)] transition-all duration-300 ease-out",style:{width:`${t.progress}%`}})})]}),t.action&&e.jsx("button",{onClick:o=>{var a;o.stopPropagation(),(a=t.action)==null||a.onClick()},className:"text-zinc-500 hover:text-zinc-200 transition-colors p-1 -mt-1.5 -mr-1.5",title:t.action.label,children:e.jsx(Xt,{className:"w-3.5 h-3.5"})})]})}):e.jsxs("div",{className:"flex items-start gap-2.5",children:[t.type==="loading"&&e.jsx(Re,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)] shrink-0 mt-0.5"}),t.type==="success"&&e.jsx(Ee,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0 mt-0.5"}),t.type==="error"&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-red-500 shrink-0 mt-0.5"}),t.type==="warning"&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-amber-500 shrink-0 mt-0.5"}),t.type==="info"&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[var(--accent)] mt-1.5 shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium leading-snug break-words text-zinc-200 whitespace-pre-wrap",children:t.message}),t.action&&e.jsx("button",{onClick:o=>{var a;o.stopPropagation(),(a=t.action)==null||a.onClick()},className:"mt-1 self-start text-[10px] font-bold text-[var(--accent)] hover:text-white transition-colors uppercase tracking-wider",children:t.action.label})]})]})},t.id)})}),di=({cues:i,settings:t})=>{if(t.useNative||i.length===0)return null;const s=()=>{switch(t.textStyle){case"outline":return"0px 0px 4px black, 0px 0px 4px black";case"raised":return"0 -1px 1px black, 0 -2px 2px black";case"depressed":return"0 1px 1px white, 0 2px 2px black";case"shadow":return"2px 2px 2px rgba(0,0,0,0.8)";default:return"none"}};return e.jsx("div",{className:"absolute inset-x-0 flex flex-col items-center justify-end text-center z-10 pointer-events-none transition-all duration-200 strata-subtitle-overlay",style:{bottom:`${t.verticalOffset}px`},children:i.map((o,a)=>e.jsx("div",{className:"mb-1 inline-block max-w-[80%]",style:{fontSize:`${t.textSize}%`,color:t.textColor,fontWeight:t.isBold?"bold":"normal",textTransform:t.fixCapitalization?"capitalize":"none",textShadow:s(),lineHeight:1.4,whiteSpace:"pre-line"},children:e.jsx("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`rgba(0, 0, 0, ${t.backgroundOpacity/100})`,backdropFilter:t.backgroundBlur?`blur(${t.backgroundBlurAmount}px)`:"none"},dangerouslySetInnerHTML:{__html:o}})},a))})},Ie=({content:i})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{children:i}):e.jsx(e.Fragment,{children:i}),ne=({label:i,checked:t,onChange:s,icon:o,tooltip:a})=>e.jsxs("div",{className:"flex items-center justify-between py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[o&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Ie,{content:o})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm text-zinc-300 font-medium group-hover:text-white transition-colors flex items-center",children:e.jsx(Ie,{content:i})}),a&&e.jsx("span",{className:"text-[10px] text-zinc-500",children:a})]})]}),e.jsx("button",{onClick:()=>s(!t),className:`w-11 h-6 shrink-0 transition-colors relative focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-zinc-900 ${t?"bg-[var(--accent)]":"bg-zinc-700"}`,style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius-full)",borderWidth:"var(--border-width)",borderColor:"rgba(255,255,255,0.1)"},children:e.jsx("div",{className:`absolute top-1/2 -translate-y-1/2 left-1 w-4 h-4 transition-transform shadow-sm ${t?"translate-x-5":"translate-x-0"}`,style:{borderRadius:"var(--radius-full)",backgroundColor:t?"var(--accent-contrast)":"#ffffff"}})})]}),xe=({label:i,value:t,min:s,max:o,step:a,onChange:d,formatValue:u,icon:x})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[x&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Ie,{content:x})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:i})]}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-zinc-300 bg-white/10 px-1.5 py-0.5 tabular-nums",style:{borderRadius:"var(--radius-sm)"},children:u?u(t):t})]}),e.jsxs("div",{className:"relative h-4 flex items-center px-1",children:[e.jsx("input",{type:"range",min:s,max:o,step:a,value:t,onChange:g=>d(parseFloat(g.target.value)),className:"w-full h-1.5 appearance-none cursor-pointer focus:outline-none focus:ring-2 strata-range-input",style:{borderRadius:"var(--radius-full)",background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${(t-s)/(o-s)*100}%, #3f3f46 ${(t-s)/(o-s)*100}%, #3f3f46 100%)`,"--tw-ring-color":"var(--accent)"}}),e.jsx("style",{children:`
15
15
  .strata-range-input::-webkit-slider-thumb {
16
16
  -webkit-appearance: none;
17
17
  height: 14px;
@@ -27,7 +27,7 @@ ${this.formatDuration(me)} remaining`}this.notify({id:o,type:"loading",message:`
27
27
  transform: scale(1.1);
28
28
  }
29
29
  /* Pixel theme specific overrides are handled by global css */
30
- `})]})]}),ui=({label:i,value:t,options:s,onChange:o,icon:a})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Pe,{content:a})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:i})]}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:t,onChange:d=>o(d.target.value),className:"w-full bg-zinc-800 border-[length:var(--border-width)] border-white/10 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:ring-2 appearance-none hover:bg-zinc-700 transition-colors cursor-pointer",style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius)"},children:s.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-zinc-400",children:e.jsx("svg",{width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M1 1L5 5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),de=({title:i,children:t})=>e.jsxs("div",{className:"py-2",children:[i&&e.jsx("h4",{className:"px-3 text-[10px] font-bold text-[var(--accent)] uppercase tracking-wider mb-1 mt-2",children:i}),e.jsx("div",{className:"space-y-0.5",children:t})]}),tt=({children:i,onClose:t,align:s="right",maxHeight:o,className:a})=>{const d=m.useRef(null),u=m.useRef(null),[x,v]=m.useState("auto"),p=s==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right";m.useLayoutEffect(()=>{if(!u.current)return;const g=()=>{u.current&&v(u.current.offsetHeight)},f=new ResizeObserver(g);return f.observe(u.current),g(),()=>f.disconnect()},[]);const h={height:x==="auto"?"auto":`${x+14}px`,maxHeight:o?`${o}px`:void 0};return e.jsx("div",{ref:d,className:`absolute bottom-full mb-4 ${p} bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl overflow-hidden w-[300px] max-w-[calc(100vw-32px)] text-sm z-50 ring-1 ring-white/5 font-[family-name:var(--font-main)] flex flex-col p-1.5 transition-[height,opacity,transform] duration-300 ease-out ${a}`,style:{...h,borderRadius:"var(--radius-lg)"},onClick:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onTouchStart:g=>g.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:u,children:i})})})},we=({content:i,className:t})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{className:t,dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{className:t,children:i}):e.jsx("span",{className:t,children:i}),I=({label:i,value:t,active:s,onClick:o,hasSubmenu:a,icon:d,rightIcon:u})=>e.jsxs("button",{onClick:o,className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-white/10 transition-colors text-left text-zinc-200 active:bg-white/5 focus:outline-none focus:bg-white/10 group overflow-hidden my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[d&&e.jsx("span",{className:"text-zinc-400 shrink-0 group-hover:text-zinc-300 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(we,{content:d})}),e.jsx("span",{className:`font-medium truncate text-sm flex items-center ${s?"text-[var(--accent)]":""}`,title:typeof i=="string"?i:void 0,children:e.jsx(we,{content:i})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400 shrink-0",children:[t&&e.jsx("span",{className:"text-xs font-medium truncate max-w-[60px]",title:t,children:e.jsx(we,{content:t})}),u,s&&e.jsx(Fe,{className:"w-4 h-4 text-[var(--accent)] shrink-0"}),a&&e.jsx("span",{className:"text-xs group-hover:translate-x-0.5 transition-transform text-zinc-500 shrink-0",children:"›"})]})]}),Y=({label:i,onBack:t,rightAction:s})=>e.jsxs("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:[e.jsxs("button",{className:"flex items-center gap-2 hover:text-white transition-colors focus:outline-none",onClick:t,children:[e.jsx(Fs,{className:"w-3 h-3"}),e.jsx("span",{children:e.jsx(we,{content:i})})]}),s]}),ce=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),Ot=({items:i,onClose:t,title:s,maxHeight:o,className:a})=>{const[d,u]=m.useState([]),x=d.length>0?d[d.length-1]:null,v=x?x.children||[]:i,p=x?x.html:s||"Menu",h=()=>{u(f=>f.slice(0,-1))},g=f=>{f.children&&u(k=>[...k,f])};return e.jsx(tt,{onClose:t,maxHeight:o,className:a,children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-right-4 duration-200",children:[d.length>0?e.jsx(Y,{label:p||"Menu",onBack:h}):s&&e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:s})}),e.jsx("div",{className:"pb-1",children:v.map((f,k)=>f.separator?e.jsx(ce,{},k):f.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(we,{content:f.html||""})},k):f.range?e.jsx("div",{className:"px-1",children:e.jsx(xe,{label:f.html,icon:f.icon,value:f.value??f.min??0,min:f.min??0,max:f.max??100,step:f.step??1,onChange:F=>f.onRange&&f.onRange(F),formatValue:f.formatValue})},k):f.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:f.html,icon:f.icon,checked:f.switch,tooltip:f.tooltip,onChange:F=>f.onSwitch&&f.onSwitch(f,F)})},k):e.jsx(m.Fragment,{children:e.jsx(I,{label:f.html,icon:f.icon,value:f.currentLabel||f.value,active:f.active,hasSubmenu:!!f.children,onClick:()=>{f.children?g(f):f.onClick?(f.onClick(f),!f.switch&&!f.range&&t()):f.click&&(f.click(f),t())}})},k))})]})})},hi=({tracks:i,current:t,onSelect:s,onUpload:o,onClose:a,settings:d,onSettingsChange:u,onReset:x,offset:v,onOffsetChange:p,maxHeight:h,animationClass:g})=>{const[f,k]=m.useState("main"),[F,H]=m.useState(""),D=m.useRef(null),G=m.useMemo(()=>F?i.filter(b=>b.label.toLowerCase().includes(F.toLowerCase())||b.srcLang&&b.srcLang.toLowerCase().includes(F.toLowerCase())):i,[i,F]);return e.jsxs(tt,{onClose:a,align:"right",maxHeight:h,className:g,children:[f==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200 flex flex-col h-full",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md shrink-0",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Subtitles"})}),e.jsxs("div",{className:"px-1.5 pb-2 shrink-0",children:[e.jsx(I,{label:"Upload Subtitle",icon:e.jsx(Ps,{className:"w-4 h-4"}),onClick:()=>{var b;return(b=D.current)==null?void 0:b.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:D,className:"hidden",onChange:b=>{var _;(_=b.target.files)!=null&&_[0]&&o(b.target.files[0])}}),e.jsx(I,{label:"Customize",icon:e.jsx(qt,{className:"w-4 h-4"}),onClick:()=>k("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(I,{label:"Off",active:t===-1,onClick:()=>{s(-1),a()}}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx("input",{type:"text",placeholder:"Search subtitles...",value:F,onChange:b=>H(b.target.value),className:"w-full bg-zinc-800/50 border border-white/10 rounded-md py-1.5 pl-8 pr-3 text-xs text-zinc-200 focus:outline-none focus:border-white/20 transition-colors"}),e.jsx(ai,{className:"w-3.5 h-3.5 text-zinc-500 absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"overflow-y-auto hide-scrollbar flex-1",children:[G.map(b=>{let _=null;return b.status==="loading"?_=e.jsx(Ie,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)]"}):b.status==="error"?_=e.jsx(ri,{className:"w-3.5 h-3.5 text-red-500"}):b.status==="success"&&(_=e.jsx(Qt,{className:"w-3.5 h-3.5 text-emerald-500"})),e.jsx(I,{label:b.label,value:b.srcLang,active:t===b.index,rightIcon:_,onClick:()=>{s(b.index),a()}},b.index)}),G.length===0&&F&&e.jsx("div",{className:"px-4 py-3 text-center text-xs text-zinc-500",children:"No results found"})]})]}),f==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(Y,{label:"Customize",onBack:()=>k("main"),rightAction:e.jsx("button",{onClick:x,className:"p-1.5 text-zinc-400 hover:text-white transition-colors rounded-md hover:bg-white/10",title:"Reset All",children:e.jsx(Hs,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(de,{children:e.jsx(ne,{label:"Native Video Subtitle",checked:d.useNative,onChange:b=>u({useNative:b})})}),!d.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(de,{title:"Sync & Position",children:[e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsx("div",{className:"flex justify-between items-center mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Es,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Sync Offset"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>p(Math.round((v-.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(As,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 bg-zinc-900 border border-white/5 rounded-lg h-8 flex items-center justify-center text-xs font-mono font-medium text-[var(--accent)]",children:[v>0?"+":"",(v==null?void 0:v.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>p(Math.round((v+.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(Vs,{className:"w-4 h-4"})})]})]}),e.jsx(xe,{label:"Vertical Position",icon:e.jsx(Os,{className:"w-4 h-4"}),value:d.verticalOffset,min:0,max:200,step:5,onChange:b=>u({verticalOffset:b}),formatValue:b=>`${b}px`})]}),e.jsxs(de,{title:"Appearance",children:[e.jsx(xe,{label:"Text Size",icon:e.jsx(Bs,{className:"w-4 h-4"}),value:d.textSize,min:50,max:200,step:10,onChange:b=>u({textSize:b}),formatValue:b=>`${b}%`}),e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(_t,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Text Color"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 p-1 bg-zinc-800/50 rounded-lg",children:[["#ffffff","#ffff00","#00ffff","#ff00ff","#ff0000","#00ff00"].map(b=>e.jsx("button",{onClick:()=>u({textColor:b}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${d.textColor===b?"ring-2 scale-110":""}`,style:{backgroundColor:b,"--tw-ring-color":"var(--accent)"}},b)),e.jsx("div",{className:"w-px h-6 bg-white/10 mx-1"}),e.jsx("div",{className:"relative w-6 h-6 rounded-full overflow-hidden ring-1 ring-white/20 cursor-pointer",children:e.jsx("input",{type:"color",value:d.textColor,onChange:b=>u({textColor:b.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(ui,{label:"Text Style",value:d.textStyle,options:[{label:"None",value:"none"},{label:"Outline",value:"outline"},{label:"Raised",value:"raised"},{label:"Depressed",value:"depressed"},{label:"Drop Shadow",value:"shadow"}],onChange:b=>u({textStyle:b})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(ne,{label:"Bold",icon:e.jsx(Ws,{className:"w-4 h-4"}),checked:d.isBold,onChange:b=>u({isBold:b})}),e.jsx(ne,{label:"Fix Caps",icon:e.jsx(Us,{className:"w-4 h-4"}),checked:d.fixCapitalization,onChange:b=>u({fixCapitalization:b})})]})]}),e.jsxs(de,{title:"Background",children:[e.jsx(xe,{label:"Opacity",icon:e.jsx(Ds,{className:"w-4 h-4"}),value:d.backgroundOpacity,min:0,max:100,step:5,onChange:b=>u({backgroundOpacity:b}),formatValue:b=>`${b}%`}),e.jsx(ne,{label:"Blur Background",icon:e.jsx(Gs,{className:"w-4 h-4"}),checked:d.backgroundBlur,onChange:b=>u({backgroundBlur:b})}),d.backgroundBlur&&e.jsx(xe,{label:"Blur Intensity",value:d.backgroundBlurAmount,min:0,max:20,step:1,onChange:b=>u({backgroundBlurAmount:b}),formatValue:b=>`${b}px`})]})]})]})]})]})},Ye=({content:i})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{children:i}):e.jsx(e.Fragment,{children:i}),mi=({x:i,y:t,items:s,onClose:o,containerWidth:a,containerHeight:d})=>{const u=m.useRef(null),[x,v]=m.useState({top:t,left:i,opacity:0});return m.useLayoutEffect(()=>{if(!u.current)return;const p=u.current.getBoundingClientRect(),h=p.width,g=p.height;let f=i,k=t;i+h>a-10&&(f=i-h),f<10&&(f=10),f+h>a&&(f=Math.max(10,a-h-10)),t+g>d-10&&(k=t-g);let F=d-20;k<10&&(k=10),k+g>d-10&&(k=Math.max(10,d-g-10)),v({top:k,left:f,maxHeight:F,opacity:1})},[i,t,s,a,d]),m.useEffect(()=>{const p=h=>{u.current&&!u.current.contains(h.target)&&o()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]),e.jsx("div",{ref:u,className:"absolute z-50 min-w-[200px] bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl p-1.5 font-[family-name:var(--font-main)] overflow-y-auto hide-scrollbar flex flex-col",style:{top:x.top,left:x.left,maxHeight:x.maxHeight,opacity:x.opacity,borderRadius:"var(--radius-lg)"},onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:s.map((p,h)=>p.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},h):p.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(Ye,{content:p.html||""})},h):e.jsxs(m.Fragment,{children:[e.jsxs("button",{onClick:()=>{p.disabled||(p.click?p.click(o):p.onClick&&p.onClick(o))},disabled:p.disabled,className:"w-full text-left px-3 py-2.5 flex items-center justify-between hover:bg-white/10 focus:bg-white/10 focus:outline-none transition-colors text-sm text-zinc-200 disabled:opacity-50 disabled:cursor-not-allowed group my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[p.icon&&e.jsx("span",{className:"text-zinc-400 w-4 h-4 flex items-center justify-center shrink-0 group-hover:text-zinc-300 transition-colors",children:e.jsx(Ye,{content:p.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${p.checked?"text-[var(--accent)]":""}`,children:e.jsx(Ye,{content:p.html||""})})]}),p.checked&&e.jsx(Fe,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),p.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},h))})},fi=({player:i,onClose:t})=>{const[s,o]=m.useState({});return m.useEffect(()=>{const a=()=>{var v;if(!i.video)return;const u=i.video,x=u.getVideoPlaybackQuality?u.getVideoPlaybackQuality():null;o({"Player Size":`${u.offsetWidth} x ${u.offsetHeight}`,"Video Resolution":`${u.videoWidth} x ${u.videoHeight}`,"Current Time":`${u.currentTime.toFixed(3)}s`,Duration:`${u.duration.toFixed(3)}s`,Volume:`${Math.round(u.volume*100)}%`,"Dropped Frames":x?x.droppedVideoFrames:"N/A",Buffer:u.buffered.length>0?`${(u.buffered.end(u.buffered.length-1)-u.currentTime).toFixed(2)}s`:"0s",Engine:((v=i.store.get().sources[i.store.get().currentSourceIndex])==null?void 0:v.type)||"native",URL:u.currentSrc})};a();const d=setInterval(a,1e3);return()=>clearInterval(d)},[i]),e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-[var(--bg-panel)] border border-white/10 rounded-xl w-full max-w-md shadow-2xl relative font-mono text-xs text-zinc-300 flex flex-col",style:{borderRadius:"var(--radius)",maxHeight:"90%"},children:[e.jsxs("div",{className:"p-5 pb-0 flex-shrink-0 relative",children:[e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},className:"absolute top-3 right-3 p-1.5 text-zinc-400 hover:text-white hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx("h3",{className:"text-sm font-bold text-white mb-4 uppercase tracking-wider border-b border-white/10 pb-2",children:"Video Statistics"})]}),e.jsx("div",{className:"overflow-y-auto hide-scrollbar p-5 pt-0 space-y-2.5 flex-1 min-h-0",children:Object.entries(s).map(([a,d])=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-1",children:[e.jsx("span",{className:"text-zinc-500 font-bold shrink-0",children:a}),e.jsx("span",{className:"text-zinc-200 truncate select-all font-medium bg-white/5 px-1.5 py-0.5 rounded break-all text-right",title:String(d),children:String(d)})]},a))})]})})};function xi(i){if(!i)return"#ffffff";i=i.replace("#",""),i.length===3&&(i=i.split("").map(d=>d+d).join(""));const t=parseInt(i.substring(0,2),16),s=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return(t*299+s*587+o*114)/1e3>=128?"#000000":"#ffffff"}const pi=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],bi=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],Ht=({content:i,className:t,style:s})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("div",{className:t,style:s,dangerouslySetInnerHTML:{__html:i}}):e.jsx("div",{className:t,style:s,children:i}):e.jsx("div",{className:t,style:s,children:i}),Ze=i=>{var Pt,Ft;const{src:t,type:s,sources:o,poster:a,autoPlay:d,thumbnails:u,textTracks:x,plugins:v,onGetInstance:p,...h}=i,g=h.screenshot??!1,f=h.pip??!0,k=h.setting??!0,F=h.fullscreen??!0,H=h.fullscreenWeb??!1,D=h.lock??!1,G=h.fastForward??!0,b=h.flip??!0,_=h.aspectRatio??!0,W=h.hotKey??!0,ue=h.backdrop??!0,y=h.gestureSeek??!1,O=h.centerControls??!0,V=h.fetchTimeout??3e4;h.autoOrientation;const N=m.useRef(null),[n,q]=m.useState(null),[U,ee]=m.useState(!1),[ie,he]=m.useState(0),[me,je]=m.useState(0),[Le,$e]=m.useState(!1),st=m.useMemo(()=>Ut(h),[]),r=m.useSyncExternalStore(m.useCallback(c=>n?n.store.subscribe(c):()=>{},[n]),()=>n?n.store.get():st,()=>st),Yt=m.useMemo(()=>xi(r.themeColor),[r.themeColor]),[E,it]=m.useState(!1),[A,nt]=m.useState(!1),[X,$]=m.useState("main"),[L,Ee]=m.useState(null),Ae=m.useRef(null);L&&(Ae.current=L);const[te,ot]=m.useState({x:0,y:0,visible:!1}),[Jt,at]=m.useState(!1),rt=Qe(E,300),lt=Qe(A,300),ye=Qe(!!L,300),M=m.useCallback(()=>{(E||A||L||te.visible)&&(it(!1),nt(!1),Ee(null),ot(c=>({...c,visible:!1})))},[E,A,L,te.visible]);m.useEffect(()=>{const c=w=>{(E||A||L||te.visible)&&M()};return(E||A||L||te.visible)&&(document.addEventListener("click",c),document.addEventListener("touchstart",c)),()=>{document.removeEventListener("click",c),document.removeEventListener("touchstart",c)}},[E,A,L,te.visible,M]);const[Ve,ke]=m.useState(!1),[Se,Be]=m.useState(0),[Kt,ct]=m.useState(!1),[Zt,dt]=m.useState(!1),[Ce,fe]=m.useState(!1),[ut,De]=m.useState(!1),[ht,mt]=m.useState([]),[ft,xt]=m.useState(null),[es,ts]=m.useState(0),[oe,pt]=m.useState(null),[re,Ne]=m.useState(null),[vi,bt]=m.useState(null),[Oe,gt]=m.useState(!1),He=m.useRef(null),vt=m.useRef(1),pe=m.useRef(null),Me=m.useRef(null),wt=m.useRef(0),jt=m.useRef(0),yt=m.useRef(0),J=m.useRef(null),be=m.useRef(!1),ge=m.useRef(null),ae=m.useRef(null),We=m.useRef(null),Ue=m.useRef(null),ve=m.useRef(null);m.useLayoutEffect(()=>{n&&N.current&&n.attach(N.current)},[n,r.isWebFullscreen]),m.useLayoutEffect(()=>{if(!N.current)return;(()=>{N.current&&(he(N.current.clientHeight),je(N.current.clientWidth))})();const w=new ResizeObserver(S=>{for(const C of S)he(C.contentRect.height),je(C.contentRect.width)});return w.observe(N.current),()=>{w.disconnect()}},[r.isWebFullscreen]),m.useEffect(()=>{if($e("ontouchstart"in window||navigator.maxTouchPoints>0),!N.current)return;const c=new Gt({...h,poster:a});return v&&v.length>0&&v.forEach(w=>c.use(w)),c.attach(N.current),q(c),p&&p(c),()=>{c.destroy(),q(null)}},[]),m.useEffect(()=>{if(!n)return;const c={};h.theme!==void 0&&h.theme!==r.theme&&(c.theme=h.theme),h.themeColor!==void 0&&h.themeColor!==r.themeColor&&(c.themeColor=h.themeColor),h.iconSize!==void 0&&h.iconSize!==r.iconSize&&(c.iconSize=h.iconSize),h.brightness!==void 0&&Math.abs(h.brightness-r.brightness)>.05&&n.setBrightness(h.brightness),h.videoFit!==void 0&&h.videoFit!==r.videoFit&&n.setVideoFit(h.videoFit),Object.keys(c).length>0&&n.setAppearance(c),h.volume!==void 0&&Math.abs(h.volume-r.volume)>.01&&n.setVolume(h.volume),h.muted!==void 0&&h.muted!==r.isMuted&&(h.muted?n.video.muted=!0:n.video.muted=!1)},[n,h.theme,h.themeColor,h.iconSize,h.volume,h.muted,h.brightness,h.videoFit]),m.useEffect(()=>{if(!n)return;const c=x||[];o&&o.length>0?(ee(!1),n.setSources(o,c)):t&&(ee(!1),n.setSources([{url:t,type:s||"auto"}],c))},[t,s,o,x,n]),m.useEffect(()=>{n&&d&&n.play().catch(()=>{n.pause(),n.store.setState({isPlaying:!1,isBuffering:!1}),n.notify({type:"warning",message:"Autoplay blocked by browser. Click play to start.",duration:5e3})})},[n,d]),m.useEffect(()=>{r.isPlaying&&!U&&ee(!0)},[r.isPlaying,U]),m.useEffect(()=>{u&&n?Ss(u,n.notify.bind(n),V).then(c=>mt(c)):mt([])},[u,n,V]),m.useEffect(()=>(re&&(ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{Ne(null)},600)),()=>{ve.current&&clearTimeout(ve.current)}),[re]),m.useEffect(()=>{const c=w=>{var C;if(!n||!W||((C=document.activeElement)==null?void 0:C.tagName)==="INPUT")return;switch(w.key.toLowerCase()){case" ":case"k":w.preventDefault(),n.togglePlay();break;case"arrowright":w.preventDefault(),n.skip(5);break;case"arrowleft":w.preventDefault(),n.skip(-5);break;case"arrowup":w.preventDefault(),n.setVolume(n.video.volume+.1);break;case"arrowdown":w.preventDefault(),n.setVolume(n.video.volume-.1);break;case"f":w.preventDefault(),n.toggleFullscreen();break;case"m":w.preventDefault(),n.toggleMute();break;case"escape":n.store.get().isWebFullscreen&&(w.preventDefault(),n.toggleWebFullscreen());break}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,W]);const kt=()=>{n&&(n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current),!(E||A||L)&&(ae.current=setTimeout(()=>{!r.isPlaying||E||A||L||n.setControlsVisible(!1)},2500)))};m.useEffect(()=>{n&&(!E&&!A&&!L&&r.isPlaying?kt():(E||A||L)&&(n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current)))},[E,A,L,r.isPlaying,n]);const St=m.useCallback(()=>{if(!(!G||!n||!r.isPlaying||r.isLocked)){if(E||A||L){M();return}vt.current=n.video.playbackRate,He.current=setTimeout(()=>{n.video.playbackRate=2,gt(!0)},500)}},[G,n,r.isPlaying,r.isLocked,E,A,L]),Ge=m.useCallback(()=>{He.current&&clearTimeout(He.current),Oe&&n&&(n.video.playbackRate=vt.current,gt(!1))},[Oe,n]),ss=c=>{if(St(),E||A||L){M();return}r.isLocked||(pe.current=c.touches[0].clientX,Me.current=c.touches[0].clientY,wt.current=r.currentTime,jt.current=r.volume,yt.current=r.brightness,be.current=!1,J.current=null)},is=c=>{var se,l;if(r.isLocked||!n||pe.current===null||Me.current===null)return;const w=c.touches[0].clientX,S=c.touches[0].clientY,C=w-pe.current,R=S-Me.current;if(!J.current&&(Math.abs(C)>10||Math.abs(R)>10))if(be.current=!0,Ge(),Math.abs(C)>Math.abs(R))y&&(J.current="seek",ke(!0));else{const z=N.current?N.current.clientWidth/2:window.innerWidth/2;pe.current<z?(J.current="brightness",De(!0)):(J.current="volume",fe(!0))}if(J.current==="seek"&&N.current&&r.duration){const z=N.current.getBoundingClientRect(),B=C/z.width,T=Math.max(0,Math.min(r.duration,wt.current+B*r.duration));Be(T)}else if(J.current==="volume"){const B=-(R/(((se=N.current)==null?void 0:se.clientHeight)||300))*1.5;n.setVolume(Math.max(0,Math.min(1,jt.current+B)))}else if(J.current==="brightness"){const B=-(R/(((l=N.current)==null?void 0:l.clientHeight)||300))*1.5;n.setBrightness(Math.max(0,Math.min(2,yt.current+B)))}},ns=c=>{Ge(),J.current==="seek"?(n==null||n.seek(Se),ke(!1)):J.current==="volume"?fe(!1):J.current==="brightness"&&De(!1),be.current=!1,J.current=null,pe.current=null,Me.current=null},qe=c=>{if(!We.current||!r.duration)return 0;const w=We.current.getBoundingClientRect(),S="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(S-w.left)/w.width))*r.duration},Ct=c=>{if(c.stopPropagation(),r.isLocked)return;(E||A||L)&&M(),ke(!0),Be(qe(c));const w=C=>Be(qe(C)),S=C=>{n==null||n.seek(qe(C)),ke(!1),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchend",S)};document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",S),document.addEventListener("touchend",S)},Nt=c=>{if(!Ue.current)return 0;const w=Ue.current.getBoundingClientRect(),S="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(S-w.left)/w.width))},Mt=c=>{if(c.stopPropagation(),!n||r.isLocked)return;ct(!0),n.setVolume(Nt(c));const w=C=>n.setVolume(Nt(C)),S=()=>{ct(!1),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchend",S)};document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",S),document.addEventListener("touchend",S)},os=c=>{if(!r.duration||r.isLive)return;const w=c.currentTarget.getBoundingClientRect(),S=(c.clientX-w.left)/w.width,C=S*r.duration;ts(S*100),xt(C),ht.length>0&&pt(ht.find(R=>C>=R.start&&C<R.end)||null)},Te=c=>{!n||r.isLocked||(n.skip(c==="forward"?10:-10),bt(c),setTimeout(()=>bt(null),300))},as=c=>{if(!n)return;if(be.current){be.current=!1;return}if(E||A||L||te.visible){M();return}if(Ce&&fe(!1),ut&&De(!1),n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{!r.isPlaying||E||A||L||n.setControlsVisible(!1)},2500),r.isLocked)return;const w=c.currentTarget.getBoundingClientRect(),S=c.clientX-w.left,C=w.width,R=Date.now();ge.current?(clearTimeout(ge.current),ge.current=null,S<C*.35?(Te("rewind"),Ne({type:"rewind",id:R})):S>C*.65?(Te("forward"),Ne({type:"forward",id:R})):n.toggleFullscreen()):ge.current=setTimeout(()=>{n.togglePlay(),ge.current=null},250)},rs=c=>{var S;if(c.preventDefault(),c.stopPropagation(),r.isLocked)return;M();const w=(S=N.current)==null?void 0:S.getBoundingClientRect();w&&requestAnimationFrame(()=>{ot({visible:!0,x:c.clientX-w.left,y:c.clientY-w.top})})},ls=c=>{if(c.stopPropagation(),M(),Ce){fe(!1);return}Le?fe(!0):n==null||n.toggleMute()},cs=r.isMuted||r.volume===0?At:r.volume<.5?Ns:Et,ze=Math.max(100,ie-120),ds=()=>{switch(r.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},us=()=>{switch(r.iconSize){case"small":return"p-2 min-w-[32px] min-h-[32px]";case"large":return"p-3 min-w-[44px] min-h-[44px]";default:return"p-2.5 min-w-[36px] min-h-[36px]"}},K=ds(),Z=us(),le=(()=>{switch(r.iconSize){case"small":return{playBtn:"w-14 h-14",playIcon:"w-6 h-6",skipBtn:"w-10 h-10",skipIcon:"w-5 h-5"};case"large":return{playBtn:"w-24 h-24",playIcon:"w-12 h-12",skipBtn:"w-16 h-16",skipIcon:"w-8 h-8"};default:return{playBtn:"w-20 h-20",playIcon:"w-9 h-9",skipBtn:"w-12 h-12",skipIcon:"w-6 h-6"}}})(),hs=!r.isLocked&&(r.controlsVisible||!r.isPlaying||E||A||L||te.visible),Tt=Zt||Kt||Ce,Re=ue?"backdrop-blur-xl bg-black/80":"bg-black/95",zt=m.useMemo(()=>{const c=[{id:"play",position:"left",index:10,isBuiltIn:!0},{id:"volume",position:"left",index:20,isBuiltIn:!0},{id:"time",position:"left",index:30,isBuiltIn:!0},{id:"subtitle",position:"right",index:80,isBuiltIn:!0},{id:"screenshot",position:"right",index:85,isBuiltIn:!0},{id:"pip",position:"right",index:90,isBuiltIn:!0},{id:"download",position:"right",index:95,isBuiltIn:!0},{id:"settings",position:"right",index:100,isBuiltIn:!0},{id:"fullscreenWeb",position:"right",index:110,isBuiltIn:!0},{id:"fullscreen",position:"right",index:120,isBuiltIn:!0}];h.controls&&h.controls.forEach(R=>{const se=c.find(l=>l.id===R.id);se?Object.assign(se,R):c.push(R)});const w=r.sources[r.currentSourceIndex]||{url:t||"",type:s||"auto"},S=w.type==="hls"||w.url.includes(".m3u8"),C=c.find(R=>R.id==="download");return C&&(S?(C.children=[{html:"Download Format",isLabel:!0},{html:"MPEG-TS",value:"Original Stream",icon:e.jsx(Qt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"ts"})},{html:"MP4",value:"Converted",icon:e.jsx(qt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"mp4"})}],C.onClick=void 0):(C.children=void 0,C.onClick=R=>R.download())),c.filter(R=>!(R.id==="screenshot"&&!g||R.id==="pip"&&!f||R.id==="settings"&&!k||R.id==="fullscreen"&&!F||R.id==="fullscreenWeb"&&!H)).sort((R,se)=>R.index-se.index)},[h.controls,g,f,k,F,H,r.currentSourceIndex,r.sources,t,s]),Rt=c=>{var w,S,C,R,se;if(!c.isBuiltIn){const l=c.id||`ctrl-${c.index}`,z=L===l,B=z||ye.isMounted&&Ae.current===l;return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:T=>T.stopPropagation(),onTouchStart:T=>T.stopPropagation(),onClick:T=>{if(T.stopPropagation(),c.children){const _e=z;M(),_e||Ee(l)}else M(),c.click?c.click(n):c.onClick&&c.onClick(n)},className:`strata-control-btn transition-colors focus:outline-none flex items-center justify-center ${Z} ${z?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"} ${c.className||""}`,style:{borderRadius:"var(--radius)",...c.style},title:c.tooltip,children:e.jsx(Ht,{content:c.html||""})}),c.children&&B&&e.jsx(Ot,{items:c.children,onClose:M,maxHeight:ze,className:`strata-backdrop ${Re} ${ye.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},c.index)}switch(c.id){case"play":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.togglePlay()},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:r.isPlaying?e.jsx($t,{className:`${K} fill-current`}):e.jsx(Lt,{className:`${K} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&dt(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&dt(!1)},children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:ls,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(cs,{className:K})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${Tt?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:Ue,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:Mt,onTouchStart:Mt,children:[e.jsx("div",{className:"w-full h-1 bg-white/20 overflow-hidden",style:{borderRadius:"var(--radius-full)"},children:e.jsx("div",{className:"h-full bg-white",style:{width:`${(r.isMuted?0:r.volume)*100}%`,borderRadius:"var(--radius-full)"}})}),e.jsx("div",{className:"absolute h-3 w-3 bg-white shadow-md top-1/2 -translate-y-1/2 pointer-events-none",style:{left:`calc(${(r.isMuted?0:r.volume)*100}% * 0.85 + 4px)`,borderRadius:"var(--radius-full)"}})]})}),Tt&&e.jsx("div",{className:"strata-tooltip absolute bottom-full mb-2 px-1.5 py-0.5 rounded text-[10px] font-bold font-mono shadow-lg pointer-events-none whitespace-nowrap z-50 transform -translate-x-1/2",style:{left:`calc(52px + ${(r.isMuted?0:r.volume)*80}px)`},children:r.isMuted?"0%":`${Math.round(r.volume*100)}%`})]},"volume");case"time":return h.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 rounded-md border border-white/10",style:{backgroundColor:`${r.themeColor}1a`,borderColor:`${r.themeColor}33`},children:[e.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:r.themeColor}}),e.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:r.themeColor},children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[Xe(Ve?Se:r.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",Xe(r.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const z=A;M(),z||nt(!0)},className:`strata-control-btn transition-colors focus:outline-none ${Z} ${A?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Is,{className:K})}),lt.isMounted&&e.jsx(hi,{tracks:r.subtitleTracks,current:r.currentSubtitle,onSelect:l=>n==null?void 0:n.setSubtitle(l),onUpload:l=>n==null?void 0:n.addTextTrack(l,l.name),onClose:M,settings:r.subtitleSettings,onSettingsChange:l=>n==null?void 0:n.updateSubtitleSettings(l),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:r.subtitleOffset,onOffsetChange:l=>n==null?void 0:n.setSubtitleOffset(l),maxHeight:ze,animationClass:`strata-backdrop ${Re} ${lt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.screenshot()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(qs,{className:K})},"ss");case"pip":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.togglePip()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Rs,{className:K})},"pip");case"download":if(c.children){const l=L==="download-menu",z=l||ye.isMounted&&Ae.current==="download-menu";return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:B=>B.stopPropagation(),onTouchStart:B=>B.stopPropagation(),onClick:B=>{B.stopPropagation();const T=l;M(),T||Ee("download-menu")},className:`strata-control-btn transition-colors hidden sm:block focus:outline-none ${Z} ${l?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Je,{className:K})}),z&&e.jsx(Ot,{items:c.children,onClose:M,maxHeight:ze,className:`strata-backdrop ${Re} ${ye.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"dl")}return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.download()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Je,{className:K})},"dl");case"fullscreen":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.toggleFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:r.isFullscreen||r.isWebFullscreen?e.jsx(Ts,{className:K}):e.jsx(Ms,{className:K})},"fs");case"fullscreenWeb":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.toggleWebFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${Z} ${r.isWebFullscreen?"text-[var(--accent)]":""}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(Qs,{className:K})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const z=E;M(),z||(it(!0),$("main"))},className:`strata-control-btn transition-all duration-300 focus:outline-none ${Z} ${E?"rotate-90 text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(zs,{className:K})}),rt.isMounted&&e.jsx(tt,{onClose:M,align:"right",maxHeight:ze,className:`strata-backdrop ${Re} ${rt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`,children:e.jsxs("div",{className:"w-full",children:[X==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Settings"})}),r.sources.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(I,{label:"Source",icon:e.jsx(Ks,{className:"w-4 h-4"}),value:((w=r.sources[r.currentSourceIndex])==null?void 0:w.name)||`Source ${r.currentSourceIndex+1}`,onClick:()=>$("sources"),hasSubmenu:!0}),e.jsx(ce,{})]}),e.jsx(I,{label:"Quality",icon:e.jsx(ni,{className:"w-4 h-4"}),value:r.currentQuality===-1?"Auto":`${(S=r.qualityLevels[r.currentQuality])==null?void 0:S.height}p`,onClick:()=>$("quality"),hasSubmenu:!0}),e.jsx(I,{label:"Speed",icon:e.jsx(ti,{className:"w-4 h-4"}),value:`${r.playbackRate}x`,onClick:()=>$("speed"),hasSubmenu:!0}),e.jsx(I,{label:"Audio",icon:e.jsx(si,{className:"w-4 h-4"}),value:((C=r.audioTracks[r.currentAudioTrack])==null?void 0:C.label)||"Default",onClick:()=>$("audio"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(I,{label:"Video Fit",icon:e.jsx(li,{className:"w-4 h-4"}),value:r.videoFit==="none"?"Default":r.videoFit.charAt(0).toUpperCase()+r.videoFit.slice(1),onClick:()=>$("videofit"),hasSubmenu:!0}),_&&e.jsx(I,{label:"Aspect Ratio",icon:e.jsx(Zs,{className:"w-4 h-4"}),value:r.aspectRatio,onClick:()=>$("ratio"),hasSubmenu:!0}),b&&e.jsx(I,{label:"Flip",icon:e.jsx(oi,{className:"w-4 h-4"}),value:r.flipState.horizontal?"H":r.flipState.vertical?"V":"Normal",onClick:()=>$("flip"),hasSubmenu:!0}),e.jsx(I,{label:"Audio Boost",icon:e.jsx(ei,{className:"w-4 h-4"}),value:r.audioGain>1?`${r.audioGain}x`:"Off",onClick:()=>$("boost"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(I,{label:"Watch Party",icon:e.jsx($s,{className:"w-4 h-4"}),onClick:()=>$("party"),hasSubmenu:!0}),e.jsx(I,{label:"Cast to Device",icon:e.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),M()}}),h.settings&&h.settings.length>0&&e.jsx(ce,{}),(R=h.settings)==null?void 0:R.map((l,z)=>l.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:l.html,icon:l.icon,checked:l.switch,tooltip:l.tooltip,onChange:B=>{l.onSwitch&&l.onSwitch(l,B)}})},`cust-${z}`):e.jsx(I,{label:l.html,icon:l.icon,value:l.currentLabel||l.value,hasSubmenu:!!l.children,onClick:()=>{l.children?$(`custom-${z}`):(l.click?l.click(l):l.onClick&&l.onClick(l),M())}},`cust-${z}`)),e.jsx(ce,{}),e.jsx(I,{label:"Appearance",icon:e.jsx(_t,{className:"w-4 h-4"}),onClick:()=>$("appearance"),hasSubmenu:!0})]}),X.startsWith("custom-")&&(()=>{var B;const l=parseInt(X.split("-")[1]),z=(B=h.settings)==null?void 0:B[l];return!z||!z.children?null:e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(Y,{label:z.html||"Menu",onBack:()=>$("main")}),z.children.map((T,_e)=>e.jsxs(m.Fragment,{children:[T.separator&&e.jsx(ce,{}),T.switch!==void 0&&e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:T.html,checked:T.switch,onChange:xs=>T.onSwitch&&T.onSwitch(T,xs)})}),!T.separator&&T.switch===void 0&&e.jsx(I,{label:T.html,icon:T.icon,value:T.value,active:T.active,onClick:()=>{T.onClick?T.onClick(T):T.click&&T.click(T),M()}})]},_e))]})})(),["speed","quality","audio","boost","party","appearance","sources","flip","ratio","videofit"].includes(X)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[X==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Select Source",onBack:()=>$("main")}),r.sources.map((l,z)=>{const B=r.sourceStatuses[z],T=B==="success"?e.jsx(ii,{className:"w-3.5 h-3.5 text-emerald-500"}):B==="error"?e.jsx(Ke,{className:"w-3.5 h-3.5 text-red-500"}):null;return e.jsx(I,{label:l.name||`Source ${z+1}`,value:l.type,active:r.currentSourceIndex===z,rightIcon:T,onClick:()=>n==null?void 0:n.switchSource(z)},z)})]}),X==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Speed",onBack:()=>$("main")}),[.5,1,1.5,2].map(l=>e.jsx(I,{label:`${l}x`,active:r.playbackRate===l,onClick:()=>n.video.playbackRate=l},l))]}),X==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Quality",onBack:()=>$("main")}),e.jsx(I,{label:"Auto",active:r.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),r.qualityLevels.map(l=>e.jsx(I,{label:`${l.height}p`,value:`${Math.round(l.bitrate/1e3)}k`,active:r.currentQuality===l.index,onClick:()=>n==null?void 0:n.setQuality(l.index)},l.index))]}),X==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Audio Track",onBack:()=>$("main")}),r.audioTracks.length===0&&e.jsx("div",{className:"px-4 py-3 text-zinc-500 text-xs text-center",children:"No tracks available"}),r.audioTracks.map(l=>e.jsx(I,{label:l.label,value:l.language,active:r.currentAudioTrack===l.index,onClick:()=>n==null?void 0:n.setAudioTrack(l.index)},l.index))]}),X==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Audio Boost",onBack:()=>$("main")}),[1,1.5,2,3].map(l=>e.jsx(I,{label:l===1?"Off":`${l}x`,active:r.audioGain===l,onClick:()=>n==null?void 0:n.setAudioGain(l)},l))]}),X==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Video Flip",onBack:()=>$("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(ne,{label:"Horizontal Flip",checked:r.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(ne,{label:"Vertical Flip",checked:r.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),X==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Aspect Ratio",onBack:()=>$("main")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto hide-scrollbar",children:["default","16:9","4:3","21:9","18:9","1:1","9:16"].map(l=>e.jsx(I,{label:l==="default"?"Default":l.replace(":"," : "),active:r.aspectRatio===l,onClick:()=>n==null?void 0:n.setAspectRatio(l)},l))})]}),X==="videofit"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Video Fit",onBack:()=>$("main")}),e.jsx(I,{label:"Contain (Default)",value:"Fit",active:r.videoFit==="contain",onClick:()=>n==null?void 0:n.setVideoFit("contain")}),e.jsx(I,{label:"Cover",value:"Zoom",active:r.videoFit==="cover",onClick:()=>n==null?void 0:n.setVideoFit("cover")}),e.jsx(I,{label:"Fill",value:"Stretch",active:r.videoFit==="fill",onClick:()=>n==null?void 0:n.setVideoFit("fill")}),e.jsx(I,{label:"None",value:"Original",active:r.videoFit==="none",onClick:()=>n==null?void 0:n.setVideoFit("none")})]}),X==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Watch Party",onBack:()=>$("main")}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("p",{className:"text-xs text-zinc-400 leading-relaxed",children:"Create a synchronized room on WatchParty.me to watch together."}),e.jsx("a",{href:`https://www.watchparty.me/create?video=${encodeURIComponent(((se=r.sources[r.currentSourceIndex])==null?void 0:se.url)||t||"")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-full py-2.5 bg-[var(--accent)] hover:opacity-90 text-white font-medium transition-opacity text-xs",style:{borderRadius:"var(--radius)"},children:"Create Room"})]})]}),X==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Appearance",onBack:()=>$("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx("div",{className:"px-1 pt-1",children:e.jsx(xe,{label:"Brightness",icon:e.jsx(Vt,{className:"w-4 h-4"}),value:r.brightness,min:0,max:2,step:.1,onChange:l=>n==null?void 0:n.setBrightness(l),formatValue:l=>`${Math.round(l*100)}%`})}),e.jsx(de,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:bi.map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({theme:l.value,themeColor:l.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${r.theme===l.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:l.label},l.value))})}),e.jsx(de,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({iconSize:l}),className:`py-1.5 text-xs font-medium transition-colors ${r.iconSize===l?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:l.charAt(0).toUpperCase()+l.slice(1)},l))})}),e.jsxs(de,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:pi.map(l=>e.jsx("button",{title:l.label,onClick:()=>n==null?void 0:n.setAppearance({themeColor:l.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${r.themeColor===l.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:l.value,borderRadius:"var(--radius-full)"},children:r.themeColor===l.value&&e.jsx(Fe,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},l.value))}),e.jsx("div",{className:"px-3 pt-4",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white/5 p-2 hover:bg-white/10 transition-colors group",style:{borderRadius:"var(--radius)"},children:[e.jsx("div",{className:"relative w-6 h-6 overflow-hidden ring-1 ring-white/20",style:{borderRadius:"var(--radius-full)"},children:e.jsx("input",{type:"color",value:r.themeColor,onChange:l=>n==null?void 0:n.setAppearance({themeColor:l.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})}),e.jsx("span",{className:"text-xs text-zinc-400 font-medium group-hover:text-zinc-200",children:"Custom Color"}),e.jsx("span",{className:"text-[10px] font-mono text-zinc-500 ml-auto uppercase",children:r.themeColor})]})})]})]})]})]})]})})]},"settings");default:return null}},ms=m.useMemo(()=>{const c=[{html:"Playback",isLabel:!0},{html:"Loop",checked:r.isLooping,onClick:()=>n==null?void 0:n.toggleLoop()},{separator:!0},{html:"Transform",isLabel:!0},{html:"Flip Horizontal",onClick:()=>n==null?void 0:n.setFlip("horizontal")},{html:"Flip Vertical",onClick:()=>n==null?void 0:n.setFlip("vertical")},{separator:!0},{html:"Aspect Ratio",isLabel:!0},{html:"Default",checked:r.aspectRatio==="default",onClick:()=>n==null?void 0:n.setAspectRatio("default")},{html:"16:9",checked:r.aspectRatio==="16:9",onClick:()=>n==null?void 0:n.setAspectRatio("16:9")},{html:"21:9",checked:r.aspectRatio==="21:9",onClick:()=>n==null?void 0:n.setAspectRatio("21:9")},{separator:!0},{html:"Video Fit",isLabel:!0},{html:"Contain",checked:r.videoFit==="contain",onClick:()=>n==null?void 0:n.setVideoFit("contain")},{html:"Cover",checked:r.videoFit==="cover",onClick:()=>n==null?void 0:n.setVideoFit("cover")},{separator:!0},{html:"Video Info",icon:e.jsx(Js,{className:"w-3.5 h-3.5"}),onClick:()=>at(!0)},{separator:!0}];return h.contextmenu&&c.push(...h.contextmenu),c.push({html:e.jsx("span",{className:"text-zinc-500 text-xs font-semibold tracking-wide",children:"StrataPlayer"}),disabled:!0}),c.push({html:"Close",onClick:w=>w(),icon:e.jsx("div",{className:"text-red-400",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})}),c},[h.contextmenu,r.aspectRatio,r.isLooping,r.videoFit,n]),fs=r.isWebFullscreen,It=e.jsxs("div",{id:h.id,ref:N,className:`group bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none text-zinc-100 strata-player-reset flex items-center justify-center ${fs?"fixed inset-0 z-[2147483647] w-screen h-screen rounded-none":"relative w-full h-full rounded-[var(--radius-player)]"} ${h.container||""}`,style:{touchAction:"manipulation","--accent":r.themeColor,"--accent-contrast":Yt},onMouseMove:kt,onMouseLeave:()=>{r.isPlaying&&!E&&!A&&!L&&n&&n.setControlsVisible(!1)},onMouseDown:St,onMouseUp:Ge,onTouchStart:ss,onTouchMove:is,onTouchEnd:ns,onContextMenu:rs,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":r.theme,children:[e.jsx("style",{children:`
30
+ `})]})]}),ui=({label:i,value:t,options:s,onChange:o,icon:a})=>e.jsxs("div",{className:"py-2.5 px-3 hover:bg-white/5 group transition-colors",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a&&e.jsx("span",{className:"text-zinc-500 group-hover:text-zinc-400 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(Ie,{content:a})}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:i})]}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:t,onChange:d=>o(d.target.value),className:"w-full bg-zinc-800 border-[length:var(--border-width)] border-white/10 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:ring-2 appearance-none hover:bg-zinc-700 transition-colors cursor-pointer",style:{"--tw-ring-color":"var(--accent)",borderRadius:"var(--radius)"},children:s.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-zinc-400",children:e.jsx("svg",{width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M1 1L5 5L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),de=({title:i,children:t})=>e.jsxs("div",{className:"py-2",children:[i&&e.jsx("h4",{className:"px-3 text-[10px] font-bold text-[var(--accent)] uppercase tracking-wider mb-1 mt-2",children:i}),e.jsx("div",{className:"space-y-0.5",children:t})]}),tt=({children:i,onClose:t,align:s="right",maxHeight:o,className:a})=>{const d=m.useRef(null),u=m.useRef(null),[x,g]=m.useState("auto"),p=s==="center"?"left-1/2 -translate-x-1/2 origin-bottom":"right-0 origin-bottom-right";m.useLayoutEffect(()=>{if(!u.current)return;const v=()=>{u.current&&g(u.current.offsetHeight)},f=new ResizeObserver(v);return f.observe(u.current),v(),()=>f.disconnect()},[]);const h={height:x==="auto"?"auto":`${x+14}px`,maxHeight:o?`${o}px`:void 0};return e.jsx("div",{ref:d,className:`absolute bottom-full mb-4 ${p} bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl overflow-hidden w-[300px] max-w-[calc(100vw-32px)] text-sm z-50 ring-1 ring-white/5 font-[family-name:var(--font-main)] flex flex-col p-1.5 transition-[height,opacity,transform] duration-300 ease-out ${a}`,style:{...h,borderRadius:"var(--radius-lg)"},onClick:v=>v.stopPropagation(),onMouseDown:v=>v.stopPropagation(),onTouchStart:v=>v.stopPropagation(),children:e.jsx("div",{className:"overflow-y-auto hide-scrollbar flex-1",style:{borderRadius:"var(--radius)"},children:e.jsx("div",{ref:u,children:i})})})},we=({content:i,className:t})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{className:t,dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{className:t,children:i}):e.jsx("span",{className:t,children:i}),R=({label:i,value:t,active:s,onClick:o,hasSubmenu:a,icon:d,rightIcon:u})=>e.jsxs("button",{onClick:o,className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-white/10 transition-colors text-left text-zinc-200 active:bg-white/5 focus:outline-none focus:bg-white/10 group overflow-hidden my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[d&&e.jsx("span",{className:"text-zinc-400 shrink-0 group-hover:text-zinc-300 transition-colors flex items-center justify-center w-4 h-4",children:e.jsx(we,{content:d})}),e.jsx("span",{className:`font-medium truncate text-sm flex items-center ${s?"text-[var(--accent)]":""}`,title:typeof i=="string"?i:void 0,children:e.jsx(we,{content:i})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400 shrink-0",children:[t&&e.jsx("span",{className:"text-xs font-medium truncate max-w-[60px]",title:t,children:e.jsx(we,{content:t})}),u,s&&e.jsx(Ee,{className:"w-4 h-4 text-[var(--accent)] shrink-0"}),a&&e.jsx("span",{className:"text-xs group-hover:translate-x-0.5 transition-transform text-zinc-500 shrink-0",children:"›"})]})]}),Y=({label:i,onBack:t,rightAction:s})=>e.jsxs("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:[e.jsxs("button",{className:"flex items-center gap-2 hover:text-white transition-colors focus:outline-none",onClick:t,children:[e.jsx(Es,{className:"w-3 h-3"}),e.jsx("span",{children:e.jsx(we,{content:i})})]}),s]}),ce=()=>e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),Ot=({items:i,onClose:t,title:s,maxHeight:o,className:a})=>{const[d,u]=m.useState([]),x=d.length>0?d[d.length-1]:null,g=x?x.children||[]:i,p=x?x.html:s||"Menu",h=()=>{u(f=>f.slice(0,-1))},v=f=>{f.children&&u(k=>[...k,f])};return e.jsx(tt,{onClose:t,maxHeight:o,className:a,children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-right-4 duration-200",children:[d.length>0?e.jsx(Y,{label:p||"Menu",onBack:h}):s&&e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:s})}),e.jsx("div",{className:"pb-1",children:g.map((f,k)=>f.separator?e.jsx(ce,{},k):f.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(we,{content:f.html||""})},k):f.range?e.jsx("div",{className:"px-1",children:e.jsx(xe,{label:f.html,icon:f.icon,value:f.value??f.min??0,min:f.min??0,max:f.max??100,step:f.step??1,onChange:E=>f.onRange&&f.onRange(E),formatValue:f.formatValue})},k):f.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:f.html,icon:f.icon,checked:f.switch,tooltip:f.tooltip,onChange:E=>f.onSwitch&&f.onSwitch(f,E)})},k):e.jsx(m.Fragment,{children:e.jsx(R,{label:f.html,icon:f.icon,value:f.currentLabel||f.value,active:f.active,hasSubmenu:!!f.children,onClick:()=>{f.children?v(f):f.onClick?(f.onClick(f),!f.switch&&!f.range&&t()):f.click&&(f.click(f),t())}})},k))})]})})},hi=({tracks:i,current:t,onSelect:s,onUpload:o,onClose:a,settings:d,onSettingsChange:u,onReset:x,offset:g,onOffsetChange:p,maxHeight:h,animationClass:v})=>{const[f,k]=m.useState("main"),[E,H]=m.useState(""),D=m.useRef(null),q=m.useMemo(()=>E?i.filter(b=>b.label.toLowerCase().includes(E.toLowerCase())||b.srcLang&&b.srcLang.toLowerCase().includes(E.toLowerCase())):i,[i,E]);return e.jsxs(tt,{onClose:a,align:"right",maxHeight:h,className:v,children:[f==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200 flex flex-col h-full",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md shrink-0",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Subtitles"})}),e.jsxs("div",{className:"px-1.5 pb-2 shrink-0",children:[e.jsx(R,{label:"Upload Subtitle",icon:e.jsx(Is,{className:"w-4 h-4"}),onClick:()=>{var b;return(b=D.current)==null?void 0:b.click()}}),e.jsx("input",{type:"file",accept:".vtt,.srt",ref:D,className:"hidden",onChange:b=>{var _;(_=b.target.files)!=null&&_[0]&&o(b.target.files[0])}}),e.jsx(R,{label:"Customize",icon:e.jsx(Gt,{className:"w-4 h-4"}),onClick:()=>k("customize"),hasSubmenu:!0}),e.jsx("div",{className:"h-px bg-white/5 mx-2 my-1"}),e.jsx(R,{label:"Off",active:t===-1,onClick:()=>{s(-1),a()}}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx("input",{type:"text",placeholder:"Search subtitles...",value:E,onChange:b=>H(b.target.value),className:"w-full bg-zinc-800/50 border border-white/10 rounded-md py-1.5 pl-8 pr-3 text-xs text-zinc-200 focus:outline-none focus:border-white/20 transition-colors"}),e.jsx(ai,{className:"w-3.5 h-3.5 text-zinc-500 absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"overflow-y-auto hide-scrollbar flex-1",children:[q.map(b=>{let _=null;return b.status==="loading"?_=e.jsx(Re,{className:"w-3.5 h-3.5 animate-spin text-[var(--accent)]"}):b.status==="error"?_=e.jsx(ri,{className:"w-3.5 h-3.5 text-red-500"}):b.status==="success"&&(_=e.jsx(Qt,{className:"w-3.5 h-3.5 text-emerald-500"})),e.jsx(R,{label:b.label,value:b.srcLang,active:t===b.index,rightIcon:_,onClick:()=>{s(b.index),a()}},b.index)}),q.length===0&&E&&e.jsx("div",{className:"px-4 py-3 text-center text-xs text-zinc-500",children:"No results found"})]})]}),f==="customize"&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(Y,{label:"Customize",onBack:()=>k("main"),rightAction:e.jsx("button",{onClick:x,className:"p-1.5 text-zinc-400 hover:text-white transition-colors rounded-md hover:bg-white/10",title:"Reset All",children:e.jsx(Hs,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"pb-1",children:[e.jsx(de,{children:e.jsx(ne,{label:"Native Video Subtitle",checked:d.useNative,onChange:b=>u({useNative:b})})}),!d.useNative&&e.jsxs(e.Fragment,{children:[e.jsxs(de,{title:"Sync & Position",children:[e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsx("div",{className:"flex justify-between items-center mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($s,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Sync Offset"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>p(Math.round((g-.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(As,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 bg-zinc-900 border border-white/5 rounded-lg h-8 flex items-center justify-center text-xs font-mono font-medium text-[var(--accent)]",children:[g>0?"+":"",(g==null?void 0:g.toFixed(1))||"0.0","s"]}),e.jsx("button",{onClick:()=>p(Math.round((g+.1)*10)/10),className:"w-8 h-8 flex items-center justify-center bg-zinc-800 rounded-lg hover:bg-zinc-700 text-zinc-300 transition-colors active:scale-95",children:e.jsx(Vs,{className:"w-4 h-4"})})]})]}),e.jsx(xe,{label:"Vertical Position",icon:e.jsx(Os,{className:"w-4 h-4"}),value:d.verticalOffset,min:0,max:200,step:5,onChange:b=>u({verticalOffset:b}),formatValue:b=>`${b}px`})]}),e.jsxs(de,{title:"Appearance",children:[e.jsx(xe,{label:"Text Size",icon:e.jsx(Bs,{className:"w-4 h-4"}),value:d.textSize,min:50,max:200,step:10,onChange:b=>u({textSize:b}),formatValue:b=>`${b}%`}),e.jsxs("div",{className:"py-2.5 px-3 rounded-lg hover:bg-white/5 group transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(_t,{className:"w-4 h-4 text-zinc-500 group-hover:text-zinc-400 transition-colors"}),e.jsx("span",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider group-hover:text-zinc-300 transition-colors",children:"Text Color"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 p-1 bg-zinc-800/50 rounded-lg",children:[["#ffffff","#ffff00","#00ffff","#ff00ff","#ff0000","#00ff00"].map(b=>e.jsx("button",{onClick:()=>u({textColor:b}),className:`w-6 h-6 rounded-full border border-white/10 transition-transform hover:scale-110 ${d.textColor===b?"ring-2 scale-110":""}`,style:{backgroundColor:b,"--tw-ring-color":"var(--accent)"}},b)),e.jsx("div",{className:"w-px h-6 bg-white/10 mx-1"}),e.jsx("div",{className:"relative w-6 h-6 rounded-full overflow-hidden ring-1 ring-white/20 cursor-pointer",children:e.jsx("input",{type:"color",value:d.textColor,onChange:b=>u({textColor:b.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})})]})]}),e.jsx(ui,{label:"Text Style",value:d.textStyle,options:[{label:"None",value:"none"},{label:"Outline",value:"outline"},{label:"Raised",value:"raised"},{label:"Depressed",value:"depressed"},{label:"Drop Shadow",value:"shadow"}],onChange:b=>u({textStyle:b})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1 px-1",children:[e.jsx(ne,{label:"Bold",icon:e.jsx(Ws,{className:"w-4 h-4"}),checked:d.isBold,onChange:b=>u({isBold:b})}),e.jsx(ne,{label:"Fix Caps",icon:e.jsx(Us,{className:"w-4 h-4"}),checked:d.fixCapitalization,onChange:b=>u({fixCapitalization:b})})]})]}),e.jsxs(de,{title:"Background",children:[e.jsx(xe,{label:"Opacity",icon:e.jsx(Ds,{className:"w-4 h-4"}),value:d.backgroundOpacity,min:0,max:100,step:5,onChange:b=>u({backgroundOpacity:b}),formatValue:b=>`${b}%`}),e.jsx(ne,{label:"Blur Background",icon:e.jsx(qs,{className:"w-4 h-4"}),checked:d.backgroundBlur,onChange:b=>u({backgroundBlur:b})}),d.backgroundBlur&&e.jsx(xe,{label:"Blur Intensity",value:d.backgroundBlurAmount,min:0,max:20,step:1,onChange:b=>u({backgroundBlurAmount:b}),formatValue:b=>`${b}px`})]})]})]})]})]})},Ye=({content:i})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("span",{dangerouslySetInnerHTML:{__html:i}}):e.jsx("span",{children:i}):e.jsx(e.Fragment,{children:i}),mi=({x:i,y:t,items:s,onClose:o,containerWidth:a,containerHeight:d})=>{const u=m.useRef(null),[x,g]=m.useState({top:t,left:i,opacity:0});return m.useLayoutEffect(()=>{if(!u.current)return;const p=u.current.getBoundingClientRect(),h=p.width,v=p.height;let f=i,k=t;i+h>a-10&&(f=i-h),f<10&&(f=10),f+h>a&&(f=Math.max(10,a-h-10)),t+v>d-10&&(k=t-v);let E=d-20;k<10&&(k=10),k+v>d-10&&(k=Math.max(10,d-v-10)),g({top:k,left:f,maxHeight:E,opacity:1})},[i,t,s,a,d]),m.useEffect(()=>{const p=h=>{u.current&&!u.current.contains(h.target)&&o()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]),e.jsx("div",{ref:u,className:"absolute z-50 min-w-[200px] bg-[var(--bg-panel)] backdrop-blur-xl border-[length:var(--border-width)] border-white/10 shadow-2xl p-1.5 font-[family-name:var(--font-main)] overflow-y-auto hide-scrollbar flex flex-col",style:{top:x.top,left:x.left,maxHeight:x.maxHeight,opacity:x.opacity,borderRadius:"var(--radius-lg)"},onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:s.map((p,h)=>p.separator?e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1.5"},h):p.isLabel?e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider select-none",children:e.jsx(Ye,{content:p.html||""})},h):e.jsxs(m.Fragment,{children:[e.jsxs("button",{onClick:()=>{p.disabled||(p.click?p.click(o):p.onClick&&p.onClick(o))},disabled:p.disabled,className:"w-full text-left px-3 py-2.5 flex items-center justify-between hover:bg-white/10 focus:bg-white/10 focus:outline-none transition-colors text-sm text-zinc-200 disabled:opacity-50 disabled:cursor-not-allowed group my-0.5",style:{borderRadius:"var(--radius)"},children:[e.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[p.icon&&e.jsx("span",{className:"text-zinc-400 w-4 h-4 flex items-center justify-center shrink-0 group-hover:text-zinc-300 transition-colors",children:e.jsx(Ye,{content:p.icon})}),e.jsx("span",{className:`flex items-center font-medium truncate ${p.checked?"text-[var(--accent)]":""}`,children:e.jsx(Ye,{content:p.html||""})})]}),p.checked&&e.jsx(Ee,{className:"w-4 h-4 text-[var(--accent)] shrink-0 ml-2"})]}),p.showBorder&&e.jsx("div",{className:"h-0 border-t border-white/10 mx-2 my-1"})]},h))})},fi=({player:i,onClose:t})=>{const[s,o]=m.useState({});return m.useEffect(()=>{const a=()=>{var g;if(!i.video)return;const u=i.video,x=u.getVideoPlaybackQuality?u.getVideoPlaybackQuality():null;o({"Player Size":`${u.offsetWidth} x ${u.offsetHeight}`,"Video Resolution":`${u.videoWidth} x ${u.videoHeight}`,"Current Time":`${u.currentTime.toFixed(3)}s`,Duration:`${u.duration.toFixed(3)}s`,Volume:`${Math.round(u.volume*100)}%`,"Dropped Frames":x?x.droppedVideoFrames:"N/A",Buffer:u.buffered.length>0?`${(u.buffered.end(u.buffered.length-1)-u.currentTime).toFixed(2)}s`:"0s",Engine:((g=i.store.get().sources[i.store.get().currentSourceIndex])==null?void 0:g.type)||"native",URL:u.currentSrc})};a();const d=setInterval(a,1e3);return()=>clearInterval(d)},[i]),e.jsx("div",{className:"absolute inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-[var(--bg-panel)] border border-white/10 rounded-xl w-full max-w-md shadow-2xl relative font-mono text-xs text-zinc-300 flex flex-col",style:{borderRadius:"var(--radius)",maxHeight:"90%"},children:[e.jsxs("div",{className:"p-5 pb-0 flex-shrink-0 relative",children:[e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},className:"absolute top-3 right-3 p-1.5 text-zinc-400 hover:text-white hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx("h3",{className:"text-sm font-bold text-white mb-4 uppercase tracking-wider border-b border-white/10 pb-2",children:"Video Statistics"})]}),e.jsx("div",{className:"overflow-y-auto hide-scrollbar p-5 pt-0 space-y-2.5 flex-1 min-h-0",children:Object.entries(s).map(([a,d])=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-1",children:[e.jsx("span",{className:"text-zinc-500 font-bold shrink-0",children:a}),e.jsx("span",{className:"text-zinc-200 truncate select-all font-medium bg-white/5 px-1.5 py-0.5 rounded break-all text-right",title:String(d),children:String(d)})]},a))})]})})};function xi(i){if(!i)return"#ffffff";i=i.replace("#",""),i.length===3&&(i=i.split("").map(d=>d+d).join(""));const t=parseInt(i.substring(0,2),16),s=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return(t*299+s*587+o*114)/1e3>=128?"#000000":"#ffffff"}const pi=[{label:"Strata",value:"#6366f1"},{label:"Emerald",value:"#10b981"},{label:"Rose",value:"#f43f5e"},{label:"Amber",value:"#f59e0b"},{label:"Sky",value:"#0ea5e9"},{label:"Violet",value:"#8b5cf6"}],bi=[{label:"Default",value:"default",color:"#6366f1"},{label:"Pixel",value:"pixel",color:"#ef4444"},{label:"Game",value:"game",color:"#eab308"},{label:"Hacker",value:"hacker",color:"#22c55e"}],Ht=({content:i,className:t,style:s})=>typeof i=="string"?i.trim().startsWith("<")?e.jsx("div",{className:t,style:s,dangerouslySetInnerHTML:{__html:i}}):e.jsx("div",{className:t,style:s,children:i}):e.jsx("div",{className:t,style:s,children:i}),Ze=i=>{var It,Et;const{src:t,type:s,sources:o,poster:a,autoPlay:d,thumbnails:u,textTracks:x,plugins:g,onGetInstance:p,...h}=i,v=h.screenshot??!1,f=h.pip??!0,k=h.setting??!0,E=h.fullscreen??!0,H=h.fullscreenWeb??!1,D=h.lock??!1,q=h.fastForward??!0,b=h.flip??!0,_=h.aspectRatio??!0,W=h.hotKey??!0,ue=h.backdrop??!0,y=h.gestureSeek??!1,O=h.centerControls??!0,V=h.fetchTimeout??3e4;h.autoOrientation;const N=m.useRef(null),[n,G]=m.useState(null),[U,ee]=m.useState(!1),[ie,he]=m.useState(0),[me,je]=m.useState(0),[Pe,Le]=m.useState(!1),st=m.useMemo(()=>Ut(h),[]),r=m.useSyncExternalStore(m.useCallback(c=>n?n.store.subscribe(c):()=>{},[n]),()=>n?n.store.get():st,()=>st),Yt=m.useMemo(()=>xi(r.themeColor),[r.themeColor]),[$,it]=m.useState(!1),[A,nt]=m.useState(!1),[X,L]=m.useState("main"),[P,$e]=m.useState(null),Ae=m.useRef(null);P&&(Ae.current=P);const[te,ot]=m.useState({x:0,y:0,visible:!1}),[Jt,at]=m.useState(!1),rt=Qe($,300),lt=Qe(A,300),ye=Qe(!!P,300),M=m.useCallback(()=>{($||A||P||te.visible)&&(it(!1),nt(!1),$e(null),ot(c=>({...c,visible:!1})))},[$,A,P,te.visible]);m.useEffect(()=>{const c=w=>{($||A||P||te.visible)&&M()};return($||A||P||te.visible)&&(document.addEventListener("click",c),document.addEventListener("touchstart",c)),()=>{document.removeEventListener("click",c),document.removeEventListener("touchstart",c)}},[$,A,P,te.visible,M]);const[Ve,ke]=m.useState(!1),[Se,Be]=m.useState(0),[Kt,ct]=m.useState(!1),[Zt,dt]=m.useState(!1),[Ce,fe]=m.useState(!1),[ut,De]=m.useState(!1),[ht,mt]=m.useState([]),[ft,xt]=m.useState(null),[es,ts]=m.useState(0),[oe,pt]=m.useState(null),[re,Ne]=m.useState(null),[vi,bt]=m.useState(null),[Oe,gt]=m.useState(!1),He=m.useRef(null),vt=m.useRef(1),pe=m.useRef(null),Me=m.useRef(null),wt=m.useRef(0),jt=m.useRef(0),yt=m.useRef(0),J=m.useRef(null),be=m.useRef(!1),ge=m.useRef(null),ae=m.useRef(null),We=m.useRef(null),Ue=m.useRef(null),ve=m.useRef(null);m.useLayoutEffect(()=>{n&&N.current&&n.attach(N.current)},[n,r.isWebFullscreen]),m.useLayoutEffect(()=>{if(!N.current)return;(()=>{N.current&&(he(N.current.clientHeight),je(N.current.clientWidth))})();const w=new ResizeObserver(S=>{for(const C of S)he(C.contentRect.height),je(C.contentRect.width)});return w.observe(N.current),()=>{w.disconnect()}},[r.isWebFullscreen]),m.useEffect(()=>{if(Le("ontouchstart"in window||navigator.maxTouchPoints>0),!N.current)return;const c=new qt({...h,poster:a});return g&&g.length>0&&g.forEach(w=>c.use(w)),c.attach(N.current),G(c),p&&p(c),()=>{c.destroy(),G(null)}},[]),m.useEffect(()=>{if(!n)return;const c={};h.theme!==void 0&&h.theme!==r.theme&&(c.theme=h.theme),h.themeColor!==void 0&&h.themeColor!==r.themeColor&&(c.themeColor=h.themeColor),h.iconSize!==void 0&&h.iconSize!==r.iconSize&&(c.iconSize=h.iconSize),h.brightness!==void 0&&Math.abs(h.brightness-r.brightness)>.05&&n.setBrightness(h.brightness),h.videoFit!==void 0&&h.videoFit!==r.videoFit&&n.setVideoFit(h.videoFit),Object.keys(c).length>0&&n.setAppearance(c),h.volume!==void 0&&Math.abs(h.volume-r.volume)>.01&&n.setVolume(h.volume),h.muted!==void 0&&h.muted!==r.isMuted&&(h.muted?n.video.muted=!0:n.video.muted=!1)},[n,h.theme,h.themeColor,h.iconSize,h.volume,h.muted,h.brightness,h.videoFit]),m.useEffect(()=>{if(!n)return;const c=x||[];o&&o.length>0?(ee(!1),n.setSources(o,c)):t&&(ee(!1),n.setSources([{url:t,type:s||"auto"}],c))},[t,s,o,x,n]),m.useEffect(()=>{n&&d&&n.play().catch(()=>{n.pause(),n.store.setState({isPlaying:!1,isBuffering:!1}),n.notify({type:"warning",message:"Autoplay blocked by browser. Click play to start.",duration:5e3})})},[n,d]),m.useEffect(()=>{r.isPlaying&&!U&&ee(!0)},[r.isPlaying,U]),m.useEffect(()=>{u&&n?Ss(u,n.notify.bind(n),V).then(c=>mt(c)):mt([])},[u,n,V]),m.useEffect(()=>(re&&(ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{Ne(null)},600)),()=>{ve.current&&clearTimeout(ve.current)}),[re]),m.useEffect(()=>{const c=w=>{var C;if(!n||!W||((C=document.activeElement)==null?void 0:C.tagName)==="INPUT")return;switch(w.key.toLowerCase()){case" ":case"k":w.preventDefault(),n.togglePlay();break;case"arrowright":w.preventDefault(),n.skip(5);break;case"arrowleft":w.preventDefault(),n.skip(-5);break;case"arrowup":w.preventDefault(),n.setVolume(n.video.volume+.1);break;case"arrowdown":w.preventDefault(),n.setVolume(n.video.volume-.1);break;case"f":w.preventDefault(),n.toggleFullscreen();break;case"m":w.preventDefault(),n.toggleMute();break;case"escape":n.store.get().isWebFullscreen&&(w.preventDefault(),n.toggleWebFullscreen());break}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,W]);const kt=()=>{n&&(n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current),!($||A||P)&&(ae.current=setTimeout(()=>{!r.isPlaying||$||A||P||n.setControlsVisible(!1)},2500)))};m.useEffect(()=>{n&&(!$&&!A&&!P&&r.isPlaying?kt():($||A||P)&&(n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current)))},[$,A,P,r.isPlaying,n]);const St=m.useCallback(()=>{if(!(!q||!n||!r.isPlaying||r.isLocked)){if($||A||P){M();return}vt.current=n.video.playbackRate,He.current=setTimeout(()=>{n.video.playbackRate=2,gt(!0)},500)}},[q,n,r.isPlaying,r.isLocked,$,A,P]),qe=m.useCallback(()=>{He.current&&clearTimeout(He.current),Oe&&n&&(n.video.playbackRate=vt.current,gt(!1))},[Oe,n]),ss=c=>{if(St(),$||A||P){M();return}r.isLocked||(pe.current=c.touches[0].clientX,Me.current=c.touches[0].clientY,wt.current=r.currentTime,jt.current=r.volume,yt.current=r.brightness,be.current=!1,J.current=null)},is=c=>{var se,l;if(r.isLocked||!n||pe.current===null||Me.current===null)return;const w=c.touches[0].clientX,S=c.touches[0].clientY,C=w-pe.current,F=S-Me.current;if(!J.current&&(Math.abs(C)>10||Math.abs(F)>10))if(be.current=!0,qe(),Math.abs(C)>Math.abs(F))y&&(J.current="seek",ke(!0));else{const z=N.current?N.current.clientWidth/2:window.innerWidth/2;pe.current<z?(J.current="brightness",De(!0)):(J.current="volume",fe(!0))}if(J.current==="seek"&&N.current&&r.duration){const z=N.current.getBoundingClientRect(),B=C/z.width,T=Math.max(0,Math.min(r.duration,wt.current+B*r.duration));Be(T)}else if(J.current==="volume"){const B=-(F/(((se=N.current)==null?void 0:se.clientHeight)||300))*1.5;n.setVolume(Math.max(0,Math.min(1,jt.current+B)))}else if(J.current==="brightness"){const B=-(F/(((l=N.current)==null?void 0:l.clientHeight)||300))*1.5;n.setBrightness(Math.max(0,Math.min(2,yt.current+B)))}},ns=c=>{qe(),J.current==="seek"?(n==null||n.seek(Se),ke(!1)):J.current==="volume"?fe(!1):J.current==="brightness"&&De(!1),be.current=!1,J.current=null,pe.current=null,Me.current=null},Ge=c=>{if(!We.current||!r.duration)return 0;const w=We.current.getBoundingClientRect(),S="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(S-w.left)/w.width))*r.duration},Ct=c=>{if(c.stopPropagation(),r.isLocked)return;($||A||P)&&M(),ke(!0),Be(Ge(c));const w=C=>Be(Ge(C)),S=C=>{n==null||n.seek(Ge(C)),ke(!1),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchend",S)};document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",S),document.addEventListener("touchend",S)},Nt=c=>{if(!Ue.current)return 0;const w=Ue.current.getBoundingClientRect(),S="touches"in c?c.touches[0].clientX:c.clientX;return Math.max(0,Math.min(1,(S-w.left)/w.width))},Mt=c=>{if(c.stopPropagation(),!n||r.isLocked)return;ct(!0),n.setVolume(Nt(c));const w=C=>n.setVolume(Nt(C)),S=()=>{ct(!1),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchend",S)};document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",S),document.addEventListener("touchend",S)},os=c=>{if(!r.duration||r.isLive)return;const w=c.currentTarget.getBoundingClientRect(),S=(c.clientX-w.left)/w.width,C=S*r.duration;ts(S*100),xt(C),ht.length>0&&pt(ht.find(F=>C>=F.start&&C<F.end)||null)},Te=c=>{!n||r.isLocked||(n.skip(c==="forward"?10:-10),bt(c),setTimeout(()=>bt(null),300))},as=c=>{if(!n)return;if(be.current){be.current=!1;return}if($||A||P||te.visible){M();return}if(Ce&&fe(!1),ut&&De(!1),n.setControlsVisible(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{!r.isPlaying||$||A||P||n.setControlsVisible(!1)},2500),r.isLocked)return;const w=c.currentTarget.getBoundingClientRect(),S=c.clientX-w.left,C=w.width,F=Date.now();ge.current?(clearTimeout(ge.current),ge.current=null,S<C*.35?(Te("rewind"),Ne({type:"rewind",id:F})):S>C*.65?(Te("forward"),Ne({type:"forward",id:F})):n.toggleFullscreen()):ge.current=setTimeout(()=>{n.togglePlay(),ge.current=null},250)},rs=c=>{var S;if(c.preventDefault(),c.stopPropagation(),r.isLocked)return;M();const w=(S=N.current)==null?void 0:S.getBoundingClientRect();w&&requestAnimationFrame(()=>{ot({visible:!0,x:c.clientX-w.left,y:c.clientY-w.top})})},ls=c=>{if(c.stopPropagation(),M(),Ce){fe(!1);return}Pe?fe(!0):n==null||n.toggleMute()},cs=r.isMuted||r.volume===0?At:r.volume<.5?Ns:$t,ze=Math.max(100,ie-120),ds=()=>{switch(r.iconSize){case"small":return"w-4 h-4";case"large":return"w-6 h-6";default:return"w-5 h-5"}},us=()=>{switch(r.iconSize){case"small":return"p-2 min-w-[32px] min-h-[32px]";case"large":return"p-3 min-w-[44px] min-h-[44px]";default:return"p-2.5 min-w-[36px] min-h-[36px]"}},K=ds(),Z=us(),le=(()=>{switch(r.iconSize){case"small":return{playBtn:"w-14 h-14",playIcon:"w-6 h-6",skipBtn:"w-10 h-10",skipIcon:"w-5 h-5"};case"large":return{playBtn:"w-24 h-24",playIcon:"w-12 h-12",skipBtn:"w-16 h-16",skipIcon:"w-8 h-8"};default:return{playBtn:"w-20 h-20",playIcon:"w-9 h-9",skipBtn:"w-12 h-12",skipIcon:"w-6 h-6"}}})(),hs=!r.isLocked&&(r.controlsVisible||!r.isPlaying||$||A||P||te.visible),Tt=Zt||Kt||Ce,Fe=ue?"backdrop-blur-xl bg-black/80":"bg-black/95",zt=m.useMemo(()=>{const c=[{id:"play",position:"left",index:10,isBuiltIn:!0},{id:"volume",position:"left",index:20,isBuiltIn:!0},{id:"time",position:"left",index:30,isBuiltIn:!0},{id:"subtitle",position:"right",index:80,isBuiltIn:!0},{id:"screenshot",position:"right",index:85,isBuiltIn:!0},{id:"pip",position:"right",index:90,isBuiltIn:!0},{id:"download",position:"right",index:95,isBuiltIn:!0},{id:"settings",position:"right",index:100,isBuiltIn:!0},{id:"fullscreenWeb",position:"right",index:110,isBuiltIn:!0},{id:"fullscreen",position:"right",index:120,isBuiltIn:!0}];h.controls&&h.controls.forEach(F=>{const se=c.find(l=>l.id===F.id);se?Object.assign(se,F):c.push(F)});const w=r.sources[r.currentSourceIndex]||{url:t||"",type:s||"auto"},S=w.type==="hls"||w.url.includes(".m3u8"),C=c.find(F=>F.id==="download");return C&&(S?(C.children=[{html:"Download Format",isLabel:!0},{html:"MPEG-TS",value:"Original Stream",icon:e.jsx(Qt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"ts"})},{html:"MP4",value:"Converted",icon:e.jsx(Gt,{className:"w-3.5 h-3.5"}),onClick:()=>n==null?void 0:n.download({format:"mp4"})}],C.onClick=void 0):(C.children=void 0,C.onClick=F=>F.download())),c.filter(F=>!(F.id==="screenshot"&&!v||F.id==="pip"&&!f||F.id==="settings"&&!k||F.id==="fullscreen"&&!E||F.id==="fullscreenWeb"&&!H)).sort((F,se)=>F.index-se.index)},[h.controls,v,f,k,E,H,r.currentSourceIndex,r.sources,t,s]),Ft=c=>{var w,S,C,F,se;if(!c.isBuiltIn){const l=c.id||`ctrl-${c.index}`,z=P===l,B=z||ye.isMounted&&Ae.current===l;return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:T=>T.stopPropagation(),onTouchStart:T=>T.stopPropagation(),onClick:T=>{if(T.stopPropagation(),c.children){const _e=z;M(),_e||$e(l)}else M(),c.click?c.click(n):c.onClick&&c.onClick(n)},className:`strata-control-btn transition-colors focus:outline-none flex items-center justify-center ${Z} ${z?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"} ${c.className||""}`,style:{borderRadius:"var(--radius)",...c.style},title:c.tooltip,children:e.jsx(Ht,{content:c.html||""})}),c.children&&B&&e.jsx(Ot,{items:c.children,onClose:M,maxHeight:ze,className:`strata-backdrop ${Fe} ${ye.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},c.index)}switch(c.id){case"play":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.togglePlay()},className:`strata-control-btn text-zinc-300 hover:text-white transition-colors hover:bg-white/10 focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:r.isPlaying?e.jsx(Lt,{className:`${K} fill-current`}):e.jsx(Pt,{className:`${K} fill-current`})},"play");case"volume":return e.jsxs("div",{className:"flex items-center gap-2 group/vol relative",onMouseEnter:()=>{window.matchMedia("(hover: hover)").matches&&dt(!0)},onMouseLeave:()=>{window.matchMedia("(hover: hover)").matches&&dt(!1)},children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:ls,className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(cs,{className:K})}),e.jsx("div",{className:`relative h-8 flex items-center transition-all duration-300 ease-out overflow-hidden ${Tt?"w-28 opacity-100 ml-1":"w-0 opacity-0"}`,children:e.jsxs("div",{ref:Ue,className:"relative w-full h-full flex items-center cursor-pointer px-2",onMouseDown:Mt,onTouchStart:Mt,children:[e.jsx("div",{className:"w-full h-1 bg-white/20 overflow-hidden",style:{borderRadius:"var(--radius-full)"},children:e.jsx("div",{className:"h-full bg-white",style:{width:`${(r.isMuted?0:r.volume)*100}%`,borderRadius:"var(--radius-full)"}})}),e.jsx("div",{className:"absolute h-3 w-3 bg-white shadow-md top-1/2 -translate-y-1/2 pointer-events-none",style:{left:`calc(${(r.isMuted?0:r.volume)*100}% * 0.85 + 4px)`,borderRadius:"var(--radius-full)"}})]})}),Tt&&e.jsx("div",{className:"strata-tooltip absolute bottom-full mb-2 px-1.5 py-0.5 rounded text-[10px] font-bold font-mono shadow-lg pointer-events-none whitespace-nowrap z-50 transform -translate-x-1/2",style:{left:`calc(52px + ${(r.isMuted?0:r.volume)*80}px)`},children:r.isMuted?"0%":`${Math.round(r.volume*100)}%`})]},"volume");case"time":return h.isLive?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-0.5 rounded-md border border-white/10",style:{backgroundColor:`${r.themeColor}1a`,borderColor:`${r.themeColor}33`},children:[e.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:r.themeColor}}),e.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:r.themeColor},children:"LIVE"})]},"live"):e.jsxs("div",{className:"text-xs font-medium text-zinc-400 font-mono select-none hidden sm:block tabular-nums",children:[Xe(Ve?Se:r.currentTime)," ",e.jsx("span",{className:"text-zinc-600",children:"/"})," ",Xe(r.duration)]},"time");case"subtitle":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const z=A;M(),z||nt(!0)},className:`strata-control-btn transition-colors focus:outline-none ${Z} ${A?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Rs,{className:K})}),lt.isMounted&&e.jsx(hi,{tracks:r.subtitleTracks,current:r.currentSubtitle,onSelect:l=>n==null?void 0:n.setSubtitle(l),onUpload:l=>n==null?void 0:n.addTextTrack(l,l.name),onClose:M,settings:r.subtitleSettings,onSettingsChange:l=>n==null?void 0:n.updateSubtitleSettings(l),onReset:()=>n==null?void 0:n.resetSubtitleSettings(),offset:r.subtitleOffset,onOffsetChange:l=>n==null?void 0:n.setSubtitleOffset(l),maxHeight:ze,animationClass:`strata-backdrop ${Fe} ${lt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"subtitle");case"screenshot":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.screenshot()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},title:"Screenshot",children:e.jsx(Gs,{className:K})},"ss");case"pip":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.togglePip()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Fs,{className:K})},"pip");case"download":if(c.children){const l=P==="download-menu",z=l||ye.isMounted&&Ae.current==="download-menu";return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:B=>B.stopPropagation(),onTouchStart:B=>B.stopPropagation(),onClick:B=>{B.stopPropagation();const T=l;M(),T||$e("download-menu")},className:`strata-control-btn transition-colors hidden sm:block focus:outline-none ${Z} ${l?"text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Je,{className:K})}),z&&e.jsx(Ot,{items:c.children,onClose:M,maxHeight:ze,className:`strata-backdrop ${Fe} ${ye.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`})]},"dl")}return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.download()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 transition-colors hidden sm:block focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:e.jsx(Je,{className:K})},"dl");case"fullscreen":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.toggleFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 rounded-lg transition-transform focus:outline-none ${Z}`,style:{borderRadius:"var(--radius)"},children:r.isFullscreen||r.isWebFullscreen?e.jsx(Ts,{className:K}):e.jsx(Ms,{className:K})},"fs");case"fullscreenWeb":return e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),M(),n==null||n.toggleWebFullscreen()},className:`strata-control-btn text-zinc-300 hover:text-white hover:bg-white/10 hidden sm:block focus:outline-none ${Z} ${r.isWebFullscreen?"text-[var(--accent)]":""}`,style:{borderRadius:"var(--radius)"},title:"Web Fullscreen",children:e.jsx(Qs,{className:K})},"fsw");case"settings":return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation();const z=$;M(),z||(it(!0),L("main"))},className:`strata-control-btn transition-all duration-300 focus:outline-none ${Z} ${$?"rotate-90 text-[var(--accent)] bg-white/10":"text-zinc-300 hover:text-white hover:bg-white/10"}`,style:{borderRadius:"var(--radius)"},children:e.jsx(zs,{className:K})}),rt.isMounted&&e.jsx(tt,{onClose:M,align:"right",maxHeight:ze,className:`strata-backdrop ${Fe} ${rt.isVisible?"opacity-100 translate-y-0 scale-100 animate-in fade-in zoom-in-95 duration-300":"opacity-0 translate-y-2 scale-95 duration-300"}`,children:e.jsxs("div",{className:"w-full",children:[X==="main"&&e.jsxs("div",{className:"animate-in slide-in-from-left-4 fade-in duration-200",children:[e.jsx("div",{className:"px-3 py-2 mb-1 border-b border-white/5 font-bold text-zinc-400 uppercase text-[11px] tracking-wider flex justify-between items-center bg-white/5 sticky top-0 z-10 backdrop-blur-md",style:{borderRadius:"var(--radius)"},children:e.jsx("span",{children:"Settings"})}),r.sources.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(R,{label:"Source",icon:e.jsx(Ks,{className:"w-4 h-4"}),value:((w=r.sources[r.currentSourceIndex])==null?void 0:w.name)||`Source ${r.currentSourceIndex+1}`,onClick:()=>L("sources"),hasSubmenu:!0}),e.jsx(ce,{})]}),e.jsx(R,{label:"Quality",icon:e.jsx(ni,{className:"w-4 h-4"}),value:r.currentQuality===-1?"Auto":`${(S=r.qualityLevels[r.currentQuality])==null?void 0:S.height}p`,onClick:()=>L("quality"),hasSubmenu:!0}),e.jsx(R,{label:"Speed",icon:e.jsx(ti,{className:"w-4 h-4"}),value:`${r.playbackRate}x`,onClick:()=>L("speed"),hasSubmenu:!0}),e.jsx(R,{label:"Audio",icon:e.jsx(si,{className:"w-4 h-4"}),value:((C=r.audioTracks[r.currentAudioTrack])==null?void 0:C.label)||"Default",onClick:()=>L("audio"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(R,{label:"Video Fit",icon:e.jsx(li,{className:"w-4 h-4"}),value:r.videoFit==="none"?"Default":r.videoFit.charAt(0).toUpperCase()+r.videoFit.slice(1),onClick:()=>L("videofit"),hasSubmenu:!0}),_&&e.jsx(R,{label:"Aspect Ratio",icon:e.jsx(Zs,{className:"w-4 h-4"}),value:r.aspectRatio,onClick:()=>L("ratio"),hasSubmenu:!0}),b&&e.jsx(R,{label:"Flip",icon:e.jsx(oi,{className:"w-4 h-4"}),value:r.flipState.horizontal?"H":r.flipState.vertical?"V":"Normal",onClick:()=>L("flip"),hasSubmenu:!0}),e.jsx(R,{label:"Audio Boost",icon:e.jsx(ei,{className:"w-4 h-4"}),value:r.audioGain>1?`${r.audioGain}x`:"Off",onClick:()=>L("boost"),hasSubmenu:!0}),e.jsx(ce,{}),e.jsx(R,{label:"Watch Party",icon:e.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>L("party"),hasSubmenu:!0}),e.jsx(R,{label:"Cast to Device",icon:e.jsx(Ps,{className:"w-4 h-4"}),onClick:()=>{n==null||n.requestCast(),M()}}),h.settings&&h.settings.length>0&&e.jsx(ce,{}),(F=h.settings)==null?void 0:F.map((l,z)=>l.switch!==void 0?e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:l.html,icon:l.icon,checked:l.switch,tooltip:l.tooltip,onChange:B=>{l.onSwitch&&l.onSwitch(l,B)}})},`cust-${z}`):e.jsx(R,{label:l.html,icon:l.icon,value:l.currentLabel||l.value,hasSubmenu:!!l.children,onClick:()=>{l.children?L(`custom-${z}`):(l.click?l.click(l):l.onClick&&l.onClick(l),M())}},`cust-${z}`)),e.jsx(ce,{}),e.jsx(R,{label:"Appearance",icon:e.jsx(_t,{className:"w-4 h-4"}),onClick:()=>L("appearance"),hasSubmenu:!0})]}),X.startsWith("custom-")&&(()=>{var B;const l=parseInt(X.split("-")[1]),z=(B=h.settings)==null?void 0:B[l];return!z||!z.children?null:e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[e.jsx(Y,{label:z.html||"Menu",onBack:()=>L("main")}),z.children.map((T,_e)=>e.jsxs(m.Fragment,{children:[T.separator&&e.jsx(ce,{}),T.switch!==void 0&&e.jsx("div",{className:"px-1",children:e.jsx(ne,{label:T.html,checked:T.switch,onChange:xs=>T.onSwitch&&T.onSwitch(T,xs)})}),!T.separator&&T.switch===void 0&&e.jsx(R,{label:T.html,icon:T.icon,value:T.value,active:T.active,onClick:()=>{T.onClick?T.onClick(T):T.click&&T.click(T),M()}})]},_e))]})})(),["speed","quality","audio","boost","party","appearance","sources","flip","ratio","videofit"].includes(X)&&e.jsxs("div",{className:"animate-in slide-in-from-right-4 fade-in duration-200",children:[X==="sources"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Select Source",onBack:()=>L("main")}),r.sources.map((l,z)=>{const B=r.sourceStatuses[z],T=B==="success"?e.jsx(ii,{className:"w-3.5 h-3.5 text-emerald-500"}):B==="error"?e.jsx(Ke,{className:"w-3.5 h-3.5 text-red-500"}):null;return e.jsx(R,{label:l.name||`Source ${z+1}`,value:l.type,active:r.currentSourceIndex===z,rightIcon:T,onClick:()=>n==null?void 0:n.switchSource(z)},z)})]}),X==="speed"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Speed",onBack:()=>L("main")}),[.5,1,1.5,2].map(l=>e.jsx(R,{label:`${l}x`,active:r.playbackRate===l,onClick:()=>n.video.playbackRate=l},l))]}),X==="quality"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Quality",onBack:()=>L("main")}),e.jsx(R,{label:"Auto",active:r.currentQuality===-1,onClick:()=>n==null?void 0:n.setQuality(-1)}),r.qualityLevels.map(l=>e.jsx(R,{label:`${l.height}p`,value:`${Math.round(l.bitrate/1e3)}k`,active:r.currentQuality===l.index,onClick:()=>n==null?void 0:n.setQuality(l.index)},l.index))]}),X==="audio"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Audio Track",onBack:()=>L("main")}),r.audioTracks.length===0&&e.jsx("div",{className:"px-4 py-3 text-zinc-500 text-xs text-center",children:"No tracks available"}),r.audioTracks.map(l=>e.jsx(R,{label:l.label,value:l.language,active:r.currentAudioTrack===l.index,onClick:()=>n==null?void 0:n.setAudioTrack(l.index)},l.index))]}),X==="boost"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Audio Boost",onBack:()=>L("main")}),[1,1.5,2,3].map(l=>e.jsx(R,{label:l===1?"Off":`${l}x`,active:r.audioGain===l,onClick:()=>n==null?void 0:n.setAudioGain(l)},l))]}),X==="flip"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Video Flip",onBack:()=>L("main")}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(ne,{label:"Horizontal Flip",checked:r.flipState.horizontal,onChange:()=>n==null?void 0:n.setFlip("horizontal")}),e.jsx(ne,{label:"Vertical Flip",checked:r.flipState.vertical,onChange:()=>n==null?void 0:n.setFlip("vertical")})]})]}),X==="ratio"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Aspect Ratio",onBack:()=>L("main")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto hide-scrollbar",children:["default","16:9","4:3","21:9","18:9","1:1","9:16"].map(l=>e.jsx(R,{label:l==="default"?"Default":l.replace(":"," : "),active:r.aspectRatio===l,onClick:()=>n==null?void 0:n.setAspectRatio(l)},l))})]}),X==="videofit"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Video Fit",onBack:()=>L("main")}),e.jsx(R,{label:"Contain (Default)",value:"Fit",active:r.videoFit==="contain",onClick:()=>n==null?void 0:n.setVideoFit("contain")}),e.jsx(R,{label:"Cover",value:"Zoom",active:r.videoFit==="cover",onClick:()=>n==null?void 0:n.setVideoFit("cover")}),e.jsx(R,{label:"Fill",value:"Stretch",active:r.videoFit==="fill",onClick:()=>n==null?void 0:n.setVideoFit("fill")}),e.jsx(R,{label:"None",value:"Original",active:r.videoFit==="none",onClick:()=>n==null?void 0:n.setVideoFit("none")})]}),X==="party"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Watch Party",onBack:()=>L("main")}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("p",{className:"text-xs text-zinc-400 leading-relaxed",children:"Create a synchronized room on WatchParty.me to watch together."}),e.jsx("a",{href:`https://www.watchparty.me/create?video=${encodeURIComponent(((se=r.sources[r.currentSourceIndex])==null?void 0:se.url)||t||"")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-full py-2.5 bg-[var(--accent)] hover:opacity-90 text-white font-medium transition-opacity text-xs",style:{borderRadius:"var(--radius)"},children:"Create Room"})]})]}),X==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:"Appearance",onBack:()=>L("main")}),e.jsxs("div",{className:"pb-1",children:[e.jsx("div",{className:"px-1 pt-1",children:e.jsx(xe,{label:"Brightness",icon:e.jsx(Vt,{className:"w-4 h-4"}),value:r.brightness,min:0,max:2,step:.1,onChange:l=>n==null?void 0:n.setBrightness(l),formatValue:l=>`${Math.round(l*100)}%`})}),e.jsx(de,{title:"Theme",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 px-3",children:bi.map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({theme:l.value,themeColor:l.color}),className:`py-2 text-xs font-bold uppercase tracking-wide transition-colors border-[length:var(--border-width)] border-white/10 ${r.theme===l.value?"bg-[var(--accent)] text-white":"bg-white/5 text-zinc-400 hover:text-white"}`,style:{borderRadius:"var(--radius)"},children:l.label},l.value))})}),e.jsx(de,{title:"Icon Size",children:e.jsx("div",{className:"grid grid-cols-3 gap-1 px-3",children:["small","medium","large"].map(l=>e.jsx("button",{onClick:()=>n==null?void 0:n.setAppearance({iconSize:l}),className:`py-1.5 text-xs font-medium transition-colors ${r.iconSize===l?"bg-white text-black":"bg-white/5 text-zinc-400 hover:text-zinc-200"}`,style:{borderRadius:"var(--radius)"},children:l.charAt(0).toUpperCase()+l.slice(1)},l))})}),e.jsxs(de,{title:"Theme Color",children:[e.jsx("div",{className:"grid grid-cols-6 gap-2 px-3",children:pi.map(l=>e.jsx("button",{title:l.label,onClick:()=>n==null?void 0:n.setAppearance({themeColor:l.value}),className:`w-6 h-6 transition-transform hover:scale-110 ${r.themeColor===l.value?"ring-2 ring-white scale-110":"ring-1 ring-white/10"}`,style:{backgroundColor:l.value,borderRadius:"var(--radius-full)"},children:r.themeColor===l.value&&e.jsx(Ee,{className:"w-3 h-3 text-white mx-auto stroke-[3]"})},l.value))}),e.jsx("div",{className:"px-3 pt-4",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white/5 p-2 hover:bg-white/10 transition-colors group",style:{borderRadius:"var(--radius)"},children:[e.jsx("div",{className:"relative w-6 h-6 overflow-hidden ring-1 ring-white/20",style:{borderRadius:"var(--radius-full)"},children:e.jsx("input",{type:"color",value:r.themeColor,onChange:l=>n==null?void 0:n.setAppearance({themeColor:l.target.value}),className:"absolute inset-[-4px] w-[150%] h-[150%] cursor-pointer p-0 border-0"})}),e.jsx("span",{className:"text-xs text-zinc-400 font-medium group-hover:text-zinc-200",children:"Custom Color"}),e.jsx("span",{className:"text-[10px] font-mono text-zinc-500 ml-auto uppercase",children:r.themeColor})]})})]})]})]})]})]})})]},"settings");default:return null}},ms=m.useMemo(()=>{const c=[{html:"Playback",isLabel:!0},{html:"Loop",checked:r.isLooping,onClick:()=>n==null?void 0:n.toggleLoop()},{separator:!0},{html:"Transform",isLabel:!0},{html:"Flip Horizontal",onClick:()=>n==null?void 0:n.setFlip("horizontal")},{html:"Flip Vertical",onClick:()=>n==null?void 0:n.setFlip("vertical")},{separator:!0},{html:"Aspect Ratio",isLabel:!0},{html:"Default",checked:r.aspectRatio==="default",onClick:()=>n==null?void 0:n.setAspectRatio("default")},{html:"16:9",checked:r.aspectRatio==="16:9",onClick:()=>n==null?void 0:n.setAspectRatio("16:9")},{html:"21:9",checked:r.aspectRatio==="21:9",onClick:()=>n==null?void 0:n.setAspectRatio("21:9")},{separator:!0},{html:"Video Fit",isLabel:!0},{html:"Contain",checked:r.videoFit==="contain",onClick:()=>n==null?void 0:n.setVideoFit("contain")},{html:"Cover",checked:r.videoFit==="cover",onClick:()=>n==null?void 0:n.setVideoFit("cover")},{separator:!0},{html:"Video Info",icon:e.jsx(Js,{className:"w-3.5 h-3.5"}),onClick:()=>at(!0)},{separator:!0}];return h.contextmenu&&c.push(...h.contextmenu),c.push({html:e.jsx("span",{className:"text-zinc-500 text-xs font-semibold tracking-wide",children:"StrataPlayer"}),disabled:!0}),c.push({html:"Close",onClick:w=>w(),icon:e.jsx("div",{className:"text-red-400",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})}),c},[h.contextmenu,r.aspectRatio,r.isLooping,r.videoFit,n]),fs=r.isWebFullscreen,Rt=e.jsxs("div",{id:h.id,ref:N,className:`group bg-black overflow-hidden select-none font-[family-name:var(--font-main)] outline-none text-zinc-100 strata-player-reset flex items-center justify-center ${fs?"fixed inset-0 z-[2147483647] w-screen h-screen rounded-none":"relative w-full h-full rounded-[var(--radius-player)]"} ${h.container||""}`,style:{touchAction:"manipulation","--accent":r.themeColor,"--accent-contrast":Yt},onMouseMove:kt,onMouseLeave:()=>{r.isPlaying&&!$&&!A&&!P&&n&&n.setControlsVisible(!1)},onMouseDown:St,onMouseUp:qe,onTouchStart:ss,onTouchMove:is,onTouchEnd:ns,onContextMenu:rs,tabIndex:0,role:"region","aria-label":"Video Player","data-theme":r.theme,children:[e.jsx("style",{children:`
31
31
  [data-theme="default"] {
32
32
  --radius: 0.75rem;
33
33
  --radius-lg: 0.75rem;
@@ -124,5 +124,5 @@ ${this.formatDuration(me)} remaining`}this.notify({id:o,type:"loading",message:`
124
124
  /* Override Backdrop for specific themes if needed */
125
125
  [data-theme="pixel"] .strata-backdrop { backdrop-filter: none; background: #000; }
126
126
  [data-theme="hacker"] .strata-backdrop { backdrop-filter: none; background: #000; }
127
- `}),r.theme==="hacker"&&e.jsx("div",{className:"strata-scanlines"}),!n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-950 z-50",children:e.jsx(Ie,{className:"w-10 h-10 text-[var(--accent)] animate-spin"})}),n&&e.jsxs(e.Fragment,{children:[(Pt=h.layers)==null?void 0:Pt.map((c,w)=>e.jsx("div",{className:`absolute inset-0 pointer-events-none z-10 ${c.className||""}`,style:c.style,children:e.jsx(Ht,{content:c.html||"",className:"w-full h-full"})},w)),e.jsx(ci,{notifications:r.notifications}),e.jsx(di,{cues:r.activeCues,settings:r.subtitleSettings}),e.jsx("div",{className:"absolute inset-0 z-[1] cursor-pointer",onClick:as,"aria-hidden":"true",role:"button",tabIndex:-1}),a&&!U&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center z-[5] pointer-events-none strata-poster",style:{backgroundImage:`url(${a})`}}),te.visible&&e.jsx(mi,{x:te.x,y:te.y,items:ms,onClose:M,containerWidth:me,containerHeight:ie}),Jt&&n&&e.jsx(fi,{player:n,onClose:()=>at(!1)}),Oe&&e.jsxs("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 bg-black/50 backdrop-blur-md px-4 py-2 rounded-full flex items-center gap-2 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[e.jsx(Ys,{className:"w-4 h-4 text-[var(--accent)] fill-current"}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:"2x Speed"})]}),Ce&&e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-black/60 backdrop-blur-md p-6 rounded-2xl flex flex-col items-center gap-4 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[r.isMuted||r.volume===0?e.jsx(At,{className:"w-10 h-10 text-white/80"}):e.jsx(Et,{className:"w-10 h-10 text-white/80"}),e.jsx("div",{className:"w-32 h-1.5 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)]",style:{width:`${r.isMuted?0:r.volume*100}%`}})}),e.jsxs("span",{className:"text-xl font-bold font-mono",children:[Math.round(r.volume*100),"%"]})]}),ut&&e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-black/60 backdrop-blur-md p-6 rounded-2xl flex flex-col items-center gap-4 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[e.jsx(Vt,{className:"w-10 h-10 text-white/80"}),e.jsx("div",{className:"w-32 h-1.5 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)]",style:{width:`${Math.min(100,r.brightness*100)}%`}})}),e.jsxs("span",{className:"text-xl font-bold font-mono",children:[Math.round(r.brightness*100),"%"]})]}),D&&Le&&r.controlsVisible&&e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),n.toggleLock()},className:`absolute left-4 md:left-6 bottom-24 md:bottom-28 z-50 p-3 rounded-full bg-black/50 backdrop-blur-md border border-white/10 text-white transition-all active:scale-95 ${r.isLocked?"text-[var(--accent)] bg-white/10":"hover:bg-white/10"}`,children:r.isLocked?e.jsx(_s,{className:"w-5 h-5"}):e.jsx(Xs,{className:"w-5 h-5"})}),re&&e.jsx("div",{className:`absolute top-0 bottom-0 flex items-center justify-center w-[35%] z-20 bg-white/5 backdrop-blur-[1px] animate-out fade-out duration-500 fill-mode-forwards pointer-events-none ${re.type==="rewind"?"left-0 rounded-r-[4rem]":"right-0 rounded-l-[4rem]"}`,onAnimationEnd:()=>Ne(null),children:e.jsxs("div",{className:"flex flex-col items-center text-white drop-shadow-lg",children:[re.type==="rewind"?e.jsx(Bt,{className:"w-12 h-12 animate-pulse"}):e.jsx(Dt,{className:"w-12 h-12 animate-pulse"}),e.jsx("span",{className:"font-bold text-sm mt-2 font-mono",children:re.type==="rewind"?"-10s":"+10s"})]})},re.id),r.isBuffering&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx(Ie,{className:"w-12 h-12 text-[var(--accent)] animate-spin drop-shadow-lg"})}),r.error&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 bg-black/90 backdrop-blur-md animate-in fade-in",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-red-500 p-8 max-w-md text-center",children:[e.jsx("span",{className:"text-5xl mb-2",children:"⚠️"}),e.jsx("h3",{className:"text-xl font-bold text-white",children:"Playback Error"}),e.jsx("p",{className:"text-zinc-400 text-sm",children:r.error}),e.jsx("button",{onClick:()=>n.load(n.store.get().sources[n.store.get().currentSourceIndex]||{url:t||"",type:s||"auto"},x),className:"px-6 py-2 bg-[var(--accent)] text-white font-medium rounded-full hover:opacity-90 transition-opacity mt-4 shadow-lg",children:"Try Again"})]})}),O&&!r.isLocked&&(!r.isPlaying&&!r.isBuffering&&!r.error||r.controlsVisible)&&!r.isBuffering?e.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-300 pointer-events-none ${r.controlsVisible||!r.isPlaying?"opacity-100":"opacity-0"}`,children:e.jsxs("div",{className:"flex items-center gap-8 md:gap-16 pointer-events-auto",children:[e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),Te("rewind")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${le.skipBtn}`,children:e.jsx(Bt,{className:le.skipIcon})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),n.togglePlay()},className:`group relative flex items-center justify-center rounded-full bg-white/10 hover:bg-[var(--accent)] border border-white/10 shadow-2xl transition-all duration-300 active:scale-90 active:opacity-80 focus:outline-none backdrop-blur-md ${le.playBtn}`,children:r.isPlaying?e.jsx($t,{className:`${le.playIcon} text-white fill-current`}):e.jsx(Lt,{className:`${le.playIcon} text-white ml-1 fill-current`})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),Te("forward")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${le.skipBtn}`,children:e.jsx(Dt,{className:le.skipIcon})})]})}):null,e.jsxs("div",{className:`absolute inset-x-0 bottom-0 z-30 transition-all duration-300 px-4 md:px-6 py-4 bg-gradient-to-t from-black/90 via-black/50 to-transparent ${hs?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"}`,onClick:c=>{(E||A||L)&&M(),c.target===c.currentTarget&&fe(!1),c.stopPropagation()},children:[!h.isLive&&e.jsxs("div",{ref:We,className:"relative w-full h-3 group/slider mb-3 cursor-pointer touch-none flex items-center",onMouseMove:os,onMouseLeave:()=>{xt(null),pt(null)},onMouseDown:Ct,onTouchStart:Ct,children:[(Ft=h.highlight)==null?void 0:Ft.map((c,w)=>e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-1.5 h-1.5 bg-yellow-400 rounded-full z-10 pointer-events-none",style:{left:`${c.time/r.duration*100}%`},title:c.text},w)),ft!==null&&e.jsxs("div",{className:"absolute bottom-full mb-1.5 flex flex-col items-center transform -translate-x-1/2 z-40 pointer-events-none transition-opacity duration-150",style:{left:`clamp(70px, ${es}%, calc(100% - 70px))`},children:[oe&&e.jsx("div",{className:"bg-black/90 border border-white/10 shadow-2xl overflow-hidden backdrop-blur-sm",style:{width:`${oe.w*.5}px`,height:`${oe.h*.5}px`,borderRadius:"var(--radius)"},children:e.jsx("div",{style:{backgroundImage:`url("${oe.url}")`,width:`${oe.w}px`,height:`${oe.h}px`,backgroundPosition:`-${oe.x}px -${oe.y}px`,backgroundRepeat:"no-repeat",transform:"scale(0.5)",transformOrigin:"top left"}})}),e.jsx("div",{className:"strata-tooltip px-2 py-0.5 text-[11px] font-bold font-mono shadow-lg tabular-nums mt-1",children:Xe(ft)})]}),e.jsxs("div",{className:"w-full h-1 bg-white/20 overflow-hidden relative backdrop-blur-sm border-[length:var(--border-width)] border-white/10",style:{borderRadius:"var(--radius-full)"},children:[r.duration>0&&r.buffered.map((c,w)=>e.jsx("div",{className:"absolute top-0 bottom-0 bg-white/20",style:{left:`${c.start/r.duration*100}%`,width:`${(c.end-c.start)/r.duration*100}%`}},w)),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-[var(--accent)]",style:{width:`${(Ve?Se:r.currentTime)/r.duration*100}%`}})]}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-3.5 h-3.5 bg-white shadow-md scale-0 group-hover/slider:scale-100 transition-transform duration-100 z-10",style:{left:`${(Ve?Se:r.currentTime)/r.duration*100}%`,borderRadius:"var(--radius-full)"}})]}),e.jsxs("div",{className:"flex items-center justify-between pointer-events-auto",children:[e.jsx("div",{className:"flex items-center gap-3",children:zt.filter(c=>c.position==="left"||c.position==="center").map(Rt)}),e.jsx("div",{className:"flex items-center gap-1",children:zt.filter(c=>c.position==="right").map(Rt)})]})]})]})]});return r.isWebFullscreen&&typeof document<"u"?vs.createPortal(It,document.body):It},gi=(i,t)=>{const s=gs.createRoot(i);return s.render(m.createElement(Ze,t)),{unmount:()=>{s.unmount()},update:o=>{s.render(m.createElement(Ze,{...t,...o}))}}};exports.StrataCore=Gt;exports.StrataPlayer=Ze;exports.mountStrataPlayer=gi;
127
+ `}),r.theme==="hacker"&&e.jsx("div",{className:"strata-scanlines"}),!n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-950 z-50",children:e.jsx(Re,{className:"w-10 h-10 text-[var(--accent)] animate-spin"})}),n&&e.jsxs(e.Fragment,{children:[(It=h.layers)==null?void 0:It.map((c,w)=>e.jsx("div",{className:`absolute inset-0 pointer-events-none z-10 ${c.className||""}`,style:c.style,children:e.jsx(Ht,{content:c.html||"",className:"w-full h-full"})},w)),e.jsx(ci,{notifications:r.notifications}),e.jsx(di,{cues:r.activeCues,settings:r.subtitleSettings}),e.jsx("div",{className:"absolute inset-0 z-[1] cursor-pointer",onClick:as,"aria-hidden":"true",role:"button",tabIndex:-1}),a&&!U&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center z-[5] pointer-events-none strata-poster",style:{backgroundImage:`url(${a})`}}),te.visible&&e.jsx(mi,{x:te.x,y:te.y,items:ms,onClose:M,containerWidth:me,containerHeight:ie}),Jt&&n&&e.jsx(fi,{player:n,onClose:()=>at(!1)}),Oe&&e.jsxs("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 bg-black/50 backdrop-blur-md px-4 py-2 rounded-full flex items-center gap-2 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[e.jsx(Ys,{className:"w-4 h-4 text-[var(--accent)] fill-current"}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:"2x Speed"})]}),Ce&&e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-black/60 backdrop-blur-md p-6 rounded-2xl flex flex-col items-center gap-4 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[r.isMuted||r.volume===0?e.jsx(At,{className:"w-10 h-10 text-white/80"}):e.jsx($t,{className:"w-10 h-10 text-white/80"}),e.jsx("div",{className:"w-32 h-1.5 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)]",style:{width:`${r.isMuted?0:r.volume*100}%`}})}),e.jsxs("span",{className:"text-xl font-bold font-mono",children:[Math.round(r.volume*100),"%"]})]}),ut&&e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-black/60 backdrop-blur-md p-6 rounded-2xl flex flex-col items-center gap-4 z-40 animate-in fade-in zoom-in duration-200 pointer-events-none",children:[e.jsx(Vt,{className:"w-10 h-10 text-white/80"}),e.jsx("div",{className:"w-32 h-1.5 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--accent)]",style:{width:`${Math.min(100,r.brightness*100)}%`}})}),e.jsxs("span",{className:"text-xl font-bold font-mono",children:[Math.round(r.brightness*100),"%"]})]}),D&&Pe&&r.controlsVisible&&e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),n.toggleLock()},className:`absolute left-4 md:left-6 bottom-24 md:bottom-28 z-50 p-3 rounded-full bg-black/50 backdrop-blur-md border border-white/10 text-white transition-all active:scale-95 ${r.isLocked?"text-[var(--accent)] bg-white/10":"hover:bg-white/10"}`,children:r.isLocked?e.jsx(_s,{className:"w-5 h-5"}):e.jsx(Xs,{className:"w-5 h-5"})}),re&&e.jsx("div",{className:`absolute top-0 bottom-0 flex items-center justify-center w-[35%] z-20 bg-white/5 backdrop-blur-[1px] animate-out fade-out duration-500 fill-mode-forwards pointer-events-none ${re.type==="rewind"?"left-0 rounded-r-[4rem]":"right-0 rounded-l-[4rem]"}`,onAnimationEnd:()=>Ne(null),children:e.jsxs("div",{className:"flex flex-col items-center text-white drop-shadow-lg",children:[re.type==="rewind"?e.jsx(Bt,{className:"w-12 h-12 animate-pulse"}):e.jsx(Dt,{className:"w-12 h-12 animate-pulse"}),e.jsx("span",{className:"font-bold text-sm mt-2 font-mono",children:re.type==="rewind"?"-10s":"+10s"})]})},re.id),r.isBuffering&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx(Re,{className:"w-12 h-12 text-[var(--accent)] animate-spin drop-shadow-lg"})}),r.error&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 bg-black/90 backdrop-blur-md animate-in fade-in",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-red-500 p-8 max-w-md text-center",children:[e.jsx("span",{className:"text-5xl mb-2",children:"⚠️"}),e.jsx("h3",{className:"text-xl font-bold text-white",children:"Playback Error"}),e.jsx("p",{className:"text-zinc-400 text-sm",children:r.error}),e.jsx("button",{onClick:()=>n.load(n.store.get().sources[n.store.get().currentSourceIndex]||{url:t||"",type:s||"auto"},x),className:"px-6 py-2 bg-[var(--accent)] text-white font-medium rounded-full hover:opacity-90 transition-opacity mt-4 shadow-lg",children:"Try Again"})]})}),O&&!r.isLocked&&(!r.isPlaying&&!r.isBuffering&&!r.error||r.controlsVisible)&&!r.isBuffering?e.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-300 pointer-events-none ${r.controlsVisible||!r.isPlaying?"opacity-100":"opacity-0"}`,children:e.jsxs("div",{className:"flex items-center gap-8 md:gap-16 pointer-events-auto",children:[e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),Te("rewind")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${le.skipBtn}`,children:e.jsx(Bt,{className:le.skipIcon})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),n.togglePlay()},className:`group relative flex items-center justify-center rounded-full bg-white/10 hover:bg-[var(--accent)] border border-white/10 shadow-2xl transition-all duration-300 active:scale-90 active:opacity-80 focus:outline-none backdrop-blur-md ${le.playBtn}`,children:r.isPlaying?e.jsx(Lt,{className:`${le.playIcon} text-white fill-current`}):e.jsx(Pt,{className:`${le.playIcon} text-white ml-1 fill-current`})}),e.jsx("button",{onMouseDown:c=>c.stopPropagation(),onTouchStart:c=>c.stopPropagation(),onClick:c=>{c.stopPropagation(),M(),Te("forward")},className:`group flex items-center justify-center rounded-full bg-black/40 hover:bg-black/60 border border-white/10 transition-all duration-300 active:scale-125 active:opacity-80 text-white/90 focus:outline-none backdrop-blur-sm ${le.skipBtn}`,children:e.jsx(Dt,{className:le.skipIcon})})]})}):null,e.jsxs("div",{className:`absolute inset-x-0 bottom-0 z-30 transition-all duration-300 px-4 md:px-6 py-4 bg-gradient-to-t from-black/90 via-black/50 to-transparent ${hs?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"}`,onClick:c=>{($||A||P)&&M(),c.target===c.currentTarget&&fe(!1),c.stopPropagation()},children:[!h.isLive&&e.jsxs("div",{ref:We,className:"relative w-full h-3 group/slider mb-3 cursor-pointer touch-none flex items-center",onMouseMove:os,onMouseLeave:()=>{xt(null),pt(null)},onMouseDown:Ct,onTouchStart:Ct,children:[(Et=h.highlight)==null?void 0:Et.map((c,w)=>e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-1.5 h-1.5 bg-yellow-400 rounded-full z-10 pointer-events-none",style:{left:`${c.time/r.duration*100}%`},title:c.text},w)),ft!==null&&e.jsxs("div",{className:"absolute bottom-full mb-1.5 flex flex-col items-center transform -translate-x-1/2 z-40 pointer-events-none transition-opacity duration-150",style:{left:`clamp(70px, ${es}%, calc(100% - 70px))`},children:[oe&&e.jsx("div",{className:"bg-black/90 border border-white/10 shadow-2xl overflow-hidden backdrop-blur-sm",style:{width:`${oe.w*.5}px`,height:`${oe.h*.5}px`,borderRadius:"var(--radius)"},children:e.jsx("div",{style:{backgroundImage:`url("${oe.url}")`,width:`${oe.w}px`,height:`${oe.h}px`,backgroundPosition:`-${oe.x}px -${oe.y}px`,backgroundRepeat:"no-repeat",transform:"scale(0.5)",transformOrigin:"top left"}})}),e.jsx("div",{className:"strata-tooltip px-2 py-0.5 text-[11px] font-bold font-mono shadow-lg tabular-nums mt-1",children:Xe(ft)})]}),e.jsxs("div",{className:"w-full h-1 bg-white/20 overflow-hidden relative backdrop-blur-sm border-[length:var(--border-width)] border-white/10",style:{borderRadius:"var(--radius-full)"},children:[r.duration>0&&r.buffered.map((c,w)=>e.jsx("div",{className:"absolute top-0 bottom-0 bg-white/20",style:{left:`${c.start/r.duration*100}%`,width:`${(c.end-c.start)/r.duration*100}%`}},w)),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-[var(--accent)]",style:{width:`${(Ve?Se:r.currentTime)/r.duration*100}%`}})]}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-3.5 h-3.5 bg-white shadow-md scale-0 group-hover/slider:scale-100 transition-transform duration-100 z-10",style:{left:`${(Ve?Se:r.currentTime)/r.duration*100}%`,borderRadius:"var(--radius-full)"}})]}),e.jsxs("div",{className:"flex items-center justify-between pointer-events-auto",children:[e.jsx("div",{className:"flex items-center gap-3",children:zt.filter(c=>c.position==="left"||c.position==="center").map(Ft)}),e.jsx("div",{className:"flex items-center gap-1",children:zt.filter(c=>c.position==="right").map(Ft)})]})]})]})]});return r.isWebFullscreen&&typeof document<"u"?vs.createPortal(Rt,document.body):Rt},gi=(i,t)=>{const s=gs.createRoot(i);return s.render(m.createElement(Ze,t)),{unmount:()=>{s.unmount()},update:o=>{s.render(m.createElement(Ze,{...t,...o}))}}};exports.StrataCore=qt;exports.StrataPlayer=Ze;exports.mountStrataPlayer=gi;
128
128
  //# sourceMappingURL=strataplayer.cjs.js.map