@serifpersia/dango 3.8.0 → 3.8.1
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.
- package/README.md +1 -1
- package/client/dist/assets/{AnimeCard-BURLDiUV.js → AnimeCard-D9nRVw2O.js} +1 -1
- package/client/dist/assets/{AnimeInfo-D2coN_ZJ.js → AnimeInfo-DFaWXccH.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-BfPP9trp.js → AnimeInfoPage-DdAmDngx.js} +2 -2
- package/client/dist/assets/{Asmr-CiuBtMGl.js → Asmr-CR7tgg-i.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-BDFeO6fQ.js → AsmrResetProgressModal-DKg0JAtz.js} +1 -1
- package/client/dist/assets/{Home-GShTLEbZ.js → Home-CA8njtnj.js} +1 -1
- package/client/dist/assets/{Insights-CKk02Whw.js → Insights-DRwVoCbK.js} +1 -1
- package/client/dist/assets/{LibraryListPage-AGyVc7pR.js → LibraryListPage-o39P5Z1e.js} +1 -1
- package/client/dist/assets/{ListeningList-DeAdvRjS.js → ListeningList-BOHUSWrP.js} +1 -1
- package/client/dist/assets/{Manga-CiPWc8Ly.js → Manga-B1wUUjnX.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-3jObt7zd.js → MangaInfoPage-CjhOeVB7.js} +1 -1
- package/client/dist/assets/{MangaReadPage-V5M2BLWG.js → MangaReadPage-CNIBLt4y.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-CXRvdwD9.js → MangaResetProgressModal-BcZuwZGV.js} +1 -1
- package/client/dist/assets/{Mature-B9IEX0IP.js → Mature-riRXX3b6.js} +1 -1
- package/client/dist/assets/{MatureConsentModal-LTZSG_Kx.js → MatureConsentModal-UaIQxjyb.js} +1 -1
- package/client/dist/assets/{MediaCard-l2gAJctz.js → MediaCard-gCn0mrX1.js} +1 -1
- package/client/dist/assets/{OptionListMenu-CHJb3qot.js → OptionListMenu-lx42ItXH.js} +1 -1
- package/client/dist/assets/Player-wMuWckmw.js +56 -0
- package/client/dist/assets/PlayerProvider-HU614Yx3.js +1 -0
- package/client/dist/assets/PlayerProvider-ZeplRma-.css +1 -0
- package/client/dist/assets/{PlayerSettings-B-_QOjfP.js → PlayerSettings-CI1aLmPu.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-BCxERY1G.js → QueueOptionsButton-DhLD1z9e.js} +1 -1
- package/client/dist/assets/{QueueRail-BX4CwNHY.js → QueueRail-Be6pVYWN.js} +1 -1
- package/client/dist/assets/{ReadingList-BLUM-leI.js → ReadingList-qMAlWX2e.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-DLs9yqI-.js → ResetProgressModal-B_bS4cVJ.js} +1 -1
- package/client/dist/assets/{Search-tnIvsV_a.js → Search-BSX7Q3Ra.js} +1 -1
- package/client/dist/assets/{Settings-CibKc1Rt.js → Settings-B-LE4vM3.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-nW7P1jQU.js → SkeletonGrid-BH33GvAW.js} +1 -1
- package/client/dist/assets/{Trackers-Cynvnhc3.js → Trackers-lFax8dy0.js} +1 -1
- package/client/dist/assets/Tv-DXPnMGb7.js +4 -0
- package/client/dist/assets/{TvInfo-DGIpvh-v.js → TvInfo-BI8xiFWp.js} +1 -1
- package/client/dist/assets/{TvPopup-BS4iiQMd.js → TvPopup-By5JenW3.js} +1 -1
- package/client/dist/assets/{TvSearch-p0kCDTee.js → TvSearch-BebgoNua.js} +1 -1
- package/client/dist/assets/{TvWatchlist-CmXQkDQp.js → TvWatchlist-BN8HI1-Y.js} +1 -1
- package/client/dist/assets/{VirtualKeyboard-CroH8QGP.js → VirtualKeyboard-CZt4P_VM.js} +1 -1
- package/client/dist/assets/{WatchAlong-iCJlxiZA.js → WatchAlong-CZpH1Z5f.js} +1 -1
- package/client/dist/assets/WatchAlongPanel-BMq7R_pe.js +1 -0
- package/client/dist/assets/WatchAlongPanel-DWb8lSzW.css +1 -0
- package/client/dist/assets/{Watchlist-D2sHodVo.js → Watchlist-BRscj0qq.js} +1 -1
- package/client/dist/assets/{index-DYanm9eZ.js → index-Nyp_7HqY.js} +2 -2
- package/client/dist/assets/{libraryInvalidation-DlwONLN-.js → libraryInvalidation-rvuk3e2Z.js} +1 -1
- package/client/dist/assets/{playbackCompletion-CxGa4g7a.js → playbackCompletion-CxUTa1RU.js} +1 -1
- package/client/dist/assets/{useAnimeInfoData-DMeGA3wY.js → useAnimeInfoData-Bj-9VSAf.js} +1 -1
- package/client/dist/assets/{useAsmr-B88X71vs.js → useAsmr-gsAVhvqA.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-DEhKwHLC.js → useAsmrPopup-BNd3V-Rs.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-CX_0zLJK.js → useMangaLibrary-BRvcl5UH.js} +1 -1
- package/client/dist/assets/{useMangaPopup-Dkq2Yw-e.js → useMangaPopup-DeuuZC7a.js} +1 -1
- package/client/dist/assets/{useProviders-D9QoFCnY.js → useProviders-BsyTv0Tl.js} +1 -1
- package/client/dist/assets/{useTv-BGXZmuV8.js → useTv-IgkCy7kA.js} +1 -1
- package/client/dist/assets/{useTvLibrary-TnVQ2e21.js → useTvLibrary-BlxUofsj.js} +1 -1
- package/client/dist/assets/{useWatchAlongPlayer-BMf_H2dw.css → useWatchAlongPlayer-1fbftVwT.css} +1 -1
- package/client/dist/assets/useWatchAlongPlayer-Bt9U4MaM.js +10 -0
- package/client/dist/index.html +1 -1
- package/package.json +2 -2
- package/server/dist/server.js +170 -170
- package/server/package.json +1 -1
- package/client/dist/assets/Player-BTimy0Mp.js +0 -56
- package/client/dist/assets/PlayerProvider-BXBzQc8G.js +0 -1
- package/client/dist/assets/PlayerProvider-N2pT5gty.css +0 -1
- package/client/dist/assets/Tv-BePMuQoo.js +0 -4
- package/client/dist/assets/WatchAlongPanel-DbJuLqxU.css +0 -1
- package/client/dist/assets/WatchAlongPanel-R7Nd5MXr.js +0 -1
- package/client/dist/assets/useWatchAlongPlayer-3HXJvQR2.js +0 -10
package/server/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-B-_QOjfP.js","assets/vendor-core-DfaOB3Rn.js","assets/index-DYanm9eZ.js","assets/vendor-query-BBT5_sHx.js","assets/vendor-icons-DrybRNxP.js","assets/index-DP9TtvZX.css","assets/OptionListMenu-CHJb3qot.js","assets/useWatchAlongPlayer-3HXJvQR2.js","assets/PlayerProvider-BXBzQc8G.js","assets/PlayerProvider-N2pT5gty.css","assets/playbackCompletion-CxGa4g7a.js","assets/useWatchAlongPlayer-BMf_H2dw.css","assets/PlayerSettings-BXGe3F5k.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as t,g as ct,h as Q,P as er,z as tr,d as ae,A as R,q as G,y as rr,T as Te,o as nr,a as sr,c as or,_ as ir,S as at}from"./vendor-core-DfaOB3Rn.js";import{p as J,_ as Bt,$ as Je,l as ar,q as ie,t as me,F as Re,a0 as lr,a1 as Ke,L as ut,a2 as cr,e as ur,r as dr,v as mr,w as fr,x as hr,d as pr,u as vr,B as lt,a3 as gr,f as yr}from"./index-DYanm9eZ.js";import{P as br,a as Sr,b as Er,F as kr,s as wr,c as Tr}from"./PlayerProvider-BXBzQc8G.js";import{u as Dt,b as _t,a as Et}from"./vendor-query-BBT5_sHx.js";import{p as wt,s as Cr,C as Mr,P as Rr,a as Nr,b as $e,c as xt,f as $t,d as Pr,e as Ar,g as _r,r as xr,u as Lr,h as Br,i as Dr,j as $r,k as Ir,l as Fr,m as Or,n as Wr,o as we,A as Ur,q as Vr,R as Qr,E as Kr,t as qr,v as E,w as Gr,x as zr,y as jr}from"./useWatchAlongPlayer-3HXJvQR2.js";import{I as ge}from"./vendor-icons-DrybRNxP.js";import{l as Hr,i as dt,s as Yr}from"./playbackCompletion-CxGa4g7a.js";import{M as Xr}from"./MatureConsentModal-LTZSG_Kx.js";import{u as Jr}from"./useIsMobile-Dvx1uJ82.js";import{s as Me,Q as Zr}from"./QueueRail-BX4CwNHY.js";import{u as en,Q as tn}from"./QueueOptionsButton-BCxERY1G.js";import{u as It}from"./useProviders-D9QoFCnY.js";import{A as rn}from"./AnimeMetaDetails-B3-A7O5H.js";import{S as nn}from"./SynopsisText-B3Sa5pRv.js";import{W as sn}from"./WatchAlongPanel-R7Nd5MXr.js";import"./vendor-ui-3qrARCPr.js";const on="_controlsOverlay_cejny_1",an="_hidden_cejny_21",ln="_topControls_cejny_27",cn="_backBtn_cejny_47",un="_videoTitleInfo_cejny_67",dn="_animeTitle_cejny_73",mn="_episodeNumber_cejny_83",fn="_bottomControls_cejny_91",hn="_progressBarContainer_cejny_110",pn="_progressBar_cejny_110",vn="_thumb_cejny_129",gn="_scrubbing_cejny_144",yn="_watchedBar_cejny_148",bn="_bufferedBar_cejny_149",Sn="_timeBubble_cejny_187",En="_skipSegment_cejny_221",kn="_bottomControlsRow_cejny_231",wn="_leftControls_cejny_239",Tn="_rightControls_cejny_240",Cn="_controlBtn_cejny_247",Mn="_theaterBtn_cejny_288",Rn="_nextEpisodeBtn_cejny_292",Nn="_active_cejny_313",Pn="_timeDisplay_cejny_317",An="_skipControls_cejny_325",B={controlsOverlay:on,hidden:an,topControls:ln,backBtn:cn,videoTitleInfo:un,animeTitle:dn,episodeNumber:mn,bottomControls:fn,progressBarContainer:hn,progressBar:pn,thumb:vn,scrubbing:gn,watchedBar:yn,bufferedBar:bn,timeBubble:Sn,skipSegment:En,bottomControlsRow:kn,leftControls:wn,rightControls:Tn,controlBtn:Cn,theaterBtn:Mn,nextEpisodeBtn:Rn,active:Nn,timeDisplay:Pn,skipControls:An},_n=({player:r,handlers:o,visible:l,skipIntervals:d,showNextEpisodeButton:b,onNextEpisode:a,isTheaterMode:s,onTheaterModeToggle:n,settingsBtnRef:i,timeDisplayRef:m})=>{const{state:S,actions:f}=r,{showSettings:T}=S;return t("div",{className:`${B.controlsOverlay} ${l?"":B.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:B.bottomControls,"data-speed-boost-ignore":"true",onClick:k=>k.stopPropagation(),children:[t(br,{classes:{container:B.progressBarContainer,scrubbing:B.scrubbing,timeBubble:B.timeBubble,bar:B.progressBar,buffered:B.bufferedBar,watched:B.watchedBar,thumb:B.thumb},timeLabelRef:m,children:[S.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${B.skipSegment} ${B[r.state.currentSkipInterval.skip_type]} `,style:{left:`${r.state.currentSkipInterval.start_time/S.duration*100}% `,width:`${(r.state.currentSkipInterval.end_time-r.state.currentSkipInterval.start_time)/S.duration*100}% `}}),d.map(k=>{const e=k.start_time/S.duration*100,v=(k.end_time-k.start_time)/S.duration*100;return t("div",{className:`${B.skipSegment} ${B[k.skip_type]} `,style:{left:`${e}% `,width:`${v}% `},title:k.skip_type.toUpperCase()},k.skip_id)})]}),t("div",{className:B.bottomControlsRow,children:[t("div",{className:B.leftControls,children:[t(Sr,{className:B.controlBtn}),t(Er,{buttonClassName:B.controlBtn,onExpandedChange:f.setShowVolumeSlider}),t("span",{className:B.timeDisplay,ref:m,children:[f.formatTime(0)," / ",f.formatTime(S.duration)]}),S.currentSkipInterval&&!S.isAutoSkipEnabled&&!S.playbackLocked&&t("button",{className:B.controlBtn,onClick:()=>{S.currentSkipInterval&&(r.engine.seek(S.currentSkipInterval.end_time),f.setCurrentSkipInterval(null))},children:["Skip ",S.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:B.rightControls,children:[t("div",{className:B.skipControls,children:b&&t("button",{className:B.nextEpisodeBtn,onClick:a,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${B.controlBtn} ${o.isSubtitleActive?B.active:""}`,onClick:o.handleCCToggle,title:o.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(ge,{name:"closed-captioning",size:22})}),t("button",{ref:i,className:`${B.controlBtn} ${T?B.active:""} `,onClick:()=>f.setShowSettings(!T),"aria-label":"Settings",children:t(ge,{name:"cog"})}),t("button",{className:`${B.controlBtn} ${B.theaterBtn} ${s?B.active:""} `,onClick:k=>{k.stopPropagation(),n()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(ge,{name:"tv"})}),t(kr,{className:B.controlBtn})]})]})]})})};function xn(r){const{state:o,refs:l,actions:d}=r,b=n=>{if(!l.videoRef.current)return;d.setActiveSubtitleTrack(n);try{if(n===null||n==="off")J.setItem("playerSubtitlesEnabled","false");else{J.setItem("playerSubtitlesEnabled","true");const m=o.availableSubtitles.find(S=>S.label===n||S.lang===n);m?J.setItem("playerLastSubtitle",Cr(m)):J.setItem("playerLastSubtitle",n)}}catch{}let i=!1;Array.from(l.videoRef.current.textTracks).forEach(m=>{const f=n!==null&&n!=="off"&&(m.language===n||m.label===n)&&!i;m.mode=f?"showing":"hidden",f&&(i=!0)})},a=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off";return{handleSubtitleSelection:b,isSubtitleActive:a,handleCCToggle:()=>{if(!l.videoRef.current)return;if(a){b("off");return}if(o.availableSubtitles.length===0)return;let n=null;try{n=J.getItem("playerLastSubtitle")}catch{}const i=wt(o.availableSubtitles,{lastKey:n,enabled:!0});if(i<0)return;const m=o.availableSubtitles[i];b(m.label||m.lang)}}}const Ln=tr(()=>Bt(()=>import("./PlayerSettings-B-_QOjfP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),Bn=({player:r,isAutoplayEnabled:o,onAutoplayChange:l,showNextEpisodeButton:d,onNextEpisode:b,videoSources:a,selectedSource:s,selectedLink:n,onSourceChange:i,loadingVideo:m,skipIntervals:S,animeTitle:f,episodeNumber:T,isTheaterMode:k,onTheaterModeToggle:e,anime4kEnabled:v,onAnime4kToggle:N,anime4kSupported:A,anime4kProfile:L,onAnime4kProfileChange:g,anime4kInitializing:u,anime4kError:P,videoDelayEnabled:_,onVideoDelayToggle:U,videoDelayMs:K,onVideoDelayChange:y,onCalibrateAvSync:p,fallbackChoice:V,onFallbackChoiceChange:j,ambientSettings:I,onAmbientChange:D,children:H,overlays:Y,isInteractingExtra:fe=!1,className:F,hideChrome:q=!1})=>{const{state:x,actions:h}=r,{showSettings:C}=x,{setShowSettings:w}=h,M=xn(r),O=ct.useRef(null),X=ct.useRef(null),Pe=ct.useRef(null);Q(()=>{const $=ue=>{O.current&&!O.current.contains(ue.target)&&X.current&&!X.current.contains(ue.target)&&C&&w(!1)};return C&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[C,w]);const Ne=x.showControls||C||x.isScrubbing,se=t(Nr,{visible:Ne,title:f,episode:T?`Episode ${T}`:void 0,onBack:()=>window.history.back(),classes:{overlay:B.controlsOverlay,hidden:B.hidden,top:B.topControls,backBtn:B.backBtn,titleInfo:B.videoTitleInfo,title:B.animeTitle,episode:B.episodeNumber}}),Z=!m&&!x.isBuffering&&x.duration>0?t(Mr,{}):null,Ae=t(_n,{player:r,handlers:M,visible:Ne,skipIntervals:S,showNextEpisodeButton:d,onNextEpisode:b,isTheaterMode:k,onTheaterModeToggle:e,settingsBtnRef:X,timeDisplayRef:Pe}),Le=t(er,{fallback:null,children:t(Ln,{ref:O,isOpen:C,onClose:()=>w(!1),videoSources:a,currentSource:s,currentLink:n,onSourceChange:i,subtitles:x.availableSubtitles,activeSubtitleTrack:x.activeSubtitleTrack,onSubtitleChange:M.handleSubtitleSelection,subtitleSettings:{fontSize:x.subtitleFontSize,position:x.subtitlePosition,bgOpacity:x.subtitleBgOpacity,bgColor:x.subtitleBgColor,textColor:x.subtitleTextColor,edge:x.subtitleEdge,bold:x.subtitleBold},onSubtitleSettingsChange:h.setSubtitleStyle,useNativeControls:!x.playbackLocked&&x.useNativeControls,onNativeControlsToggle:h.setUseNativeControls,anime4kEnabled:v,onAnime4kToggle:N,anime4kSupported:A,anime4kProfile:L,onAnime4kProfileChange:g,anime4kInitializing:u,anime4kError:P,videoDelayEnabled:_,onVideoDelayToggle:U,videoDelayMs:K,onVideoDelayChange:y,onCalibrateAvSync:p,isAutoSkipEnabled:x.isAutoSkipEnabled,onAutoSkipChange:$=>{h.setIsAutoSkipEnabled($);try{J.setItem("autoSkipEnabled",$.toString())}catch{}},isAutoplayEnabled:o,onAutoplayChange:l,fallbackChoice:V,onFallbackChoiceChange:j,isTheaterMode:k,ambientSettings:I,onAmbientChange:D})}),ne=C?t("div",{"data-speed-boost-ignore":"true",onClick:$=>$.stopPropagation(),children:Le}):null;return t(Rr,{engine:r.engine,topBar:se,centerControls:Z,bottomBar:!m&&x.duration>0?Ae:null,settingsPanel:ne,overlays:Y,isInteracting:fe||x.showSettings||x.showVolumeSlider,nativeControls:!x.playbackLocked&&x.useNativeControls,className:F,chromeDisabled:q,children:H})},Dn=({count:r=3})=>t("section",{className:Me.section,children:[t("div",{className:Me.header,children:t("button",{className:Me.headerToggle,disabled:!0,children:[t("span",{className:Me.title,children:t(Je,{width:"60px",height:"1.2rem",variant:"text"})}),t(ge,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:Me.list,children:Array.from({length:r}).map((o,l)=>t("div",{className:Me.item,style:{pointerEvents:"none"},children:[t("div",{className:Me.dragHandle,style:{opacity:.2},children:t(Je,{width:"16px",height:"16px",variant:"rectangular"})}),t("div",{className:Me.thumbnail,style:{overflow:"hidden",background:"transparent"},children:t(Je,{width:"100%",height:"100%",variant:"rectangular"})}),t("div",{className:Me.meta,children:[t(Je,{width:"80%",height:"1.2rem",variant:"text",className:Me.metaGap}),t(Je,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},l))})]}),$n={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},In={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Fn=["direct","cookie","embed"],On=({selectedProvider:r,onProviderChange:o,isAdult:l,options:d})=>{const a=(d&&d.length>0?d:[]).filter(s=>s.mature===(l===!0));return t("div",{className:$e.providerSelectContainer,children:[t("h4",{children:"Provider"}),t("select",{className:$e.providerSelect,value:r,onChange:s=>o(s.currentTarget.value),children:Fn.map(s=>{const n=a.filter(i=>(i.tier??"direct")===s);return n.length===0?null:t("optgroup",{label:In[s],children:n.map(i=>t("option",{value:i.id,children:i.sub?`${i.label} (${$n[i.sub]})`:i.label},i.id))},s)})})]})},Wn=({videoSources:r,selectedSource:o,selectedLink:l,onSourceChange:d,onLinkChange:b})=>{const a=Array.isArray(r)?r:[];if(a.length===0)return null;const s=o?.type==="iframe"&&(o.links?.length??0)>1;return t("div",{className:$e.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:$e.sourceButtons,children:a.map((n,i)=>t("button",{className:`${$e.sourceButton} ${o?.sourceName===n.sourceName?$e.active:""} `,onClick:()=>d(n),children:n.sourceName},`${n.sourceName}-${i}`))}),s&&t("select",{className:$e.sourceSelect,"aria-label":"Fallback embed quality",value:l?.link??o.links[0]?.link??"",onChange:n=>{const i=o.links.find(m=>m.link===n.currentTarget.value);i&&b(i)},children:o.links.map(n=>t("option",{value:n.link,children:n.resolutionStr},n.link))})]})},Un=ct.memo(Wn,(r,o)=>r.selectedSource?.sourceName===o.selectedSource?.sourceName&&r.selectedLink?.link===o.selectedLink?.link&&r.videoSources===o.videoSources),Vn={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},Qn={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Kn=5,qn=15e3,Gn=`
|
|
3
|
-
@group(0) @binding(0) var extTex: texture_external;
|
|
4
|
-
@group(0) @binding(1) var extSamp: sampler;
|
|
5
|
-
struct VSOut {
|
|
6
|
-
@builtin(position) pos: vec4f,
|
|
7
|
-
@location(0) uv: vec2f,
|
|
8
|
-
};
|
|
9
|
-
@vertex
|
|
10
|
-
fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
|
|
11
|
-
var positions = array<vec2f, 6>(
|
|
12
|
-
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
13
|
-
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
14
|
-
);
|
|
15
|
-
var uvs = array<vec2f, 6>(
|
|
16
|
-
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
17
|
-
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
18
|
-
);
|
|
19
|
-
var out: VSOut;
|
|
20
|
-
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
21
|
-
out.uv = uvs[idx];
|
|
22
|
-
return out;
|
|
23
|
-
}
|
|
24
|
-
@fragment
|
|
25
|
-
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
26
|
-
return textureSampleBaseClampToEdge(extTex, extSamp, uv);
|
|
27
|
-
}
|
|
28
|
-
`;function zn({videoRef:r,canvasRef:o,profile:l="balanced",delayMs:d=0}){const[b,a]=ae(!1),[s,n]=ae(()=>{try{return J.getItem("anime4kEnabled")==="true"}catch{return!1}}),[i,m]=ae(!1),[S,f]=ae(null),[T,k]=ae(0),e=R(0),v=R(null),N=R(null),A=R(null),L=R(null),g=R(null),u=R(null),P=R(null),_=R(null),U=R(null),K=R(!1),y=R(-1),p=R(0),V=R(d);V.current=d;const j=R([]),I=R(!1),D=R(!1),H=R(!1),Y=R(null),fe=R(-1),F=R(-1),q=R(!1),x=R(0);Q(()=>{async function w(){if(typeof navigator>"u"||!navigator.gpu){a(!1);return}try{const M=await navigator.gpu.requestAdapter();a(!!M)}catch{a(!1)}}w()},[]),Q(()=>{if(!s||!b)return;let w=!1;const M=++e.current,O=Z=>{if(Z)try{Z.close()}catch{}},X=()=>{for(const Z of j.current)O(Z.bitmap);j.current=[]},Pe=Z=>Math.max(8,Math.min(40,Math.ceil(Z/16.7)+4));function Ne(){U.current!==null&&(cancelAnimationFrame(U.current),U.current=null)}async function se(){let Z=r.current;const Ae=o.current;if(!Z||!Ae||e.current!==M)return;const Le=performance.now()+qn;for(;(!Z||Z.videoWidth===0)&&performance.now()<Le;){if(await new Promise(de=>requestAnimationFrame(de)),w||e.current!==M)return;Z=r.current}if(!Z||Z.videoWidth===0){!w&&e.current===M&&(f("Timed out waiting for video metadata"),m(!1),n(!1));return}const ne=Z.videoWidth,$=Z.videoHeight,ue=Math.max(ne,$),et=window.innerWidth,qe=window.innerHeight,Ge=Math.max(et,qe),ze=ue<Ge?Ge/ue:1,Ie=Vn[l],mt=ue<=480?Ie.sd:ue<=720?Ie.hd:ue<=1080?Ie.fhd:1,Ce=Math.min(mt,ze);Ae.width=Math.round(ne*Ce),Ae.height=Math.round($*Ce),m(!0),f(null),p.current=0,y.current=-1,fe.current=-1,F.current=-1,q.current=!1,x.current=0,X(),K.current=!1;try{let de=function(){w||e.current!==M||(Ne(),U.current=requestAnimationFrame(()=>{gt()}))};const{ModeA:tt,ModeB:ft,ModeC:ht,ModeAA:ye}=await Bt(async()=>{const{ModeA:z,ModeB:te,ModeC:be,ModeAA:le}=await import("./index-BOKlZEHq.js").then(ce=>ce.i);return{ModeA:z,ModeB:te,ModeC:be,ModeAA:le}},[]);if(w||e.current!==M)return;if(!navigator.gpu)throw new Error("WebGPU not available");const je=await navigator.gpu.requestAdapter();if(w||e.current!==M)return;if(!je)throw new Error("No GPU adapter found");const W=await je.requestDevice();if(!W)throw new Error("Failed to get GPU device");if(w||e.current!==M){W.destroy();return}v.current=W;const he=Ae.getContext("webgpu");if(!he)throw new Error("Failed to get WebGPU context");N.current=he;const He=navigator.gpu.getPreferredCanvasFormat();he.configure({device:W,format:He,alphaMode:"premultiplied"});const pe=W.createTexture({size:[ne,$],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),pt=Qn[l],Fe=Math.round(ne*Ce),Be=Math.round($*Ce),Oe=(()=>{switch(pt){case"ModeB":return new ft({device:W,inputTexture:pe,nativeDimensions:{width:ne,height:$},targetDimensions:{width:Fe,height:Be}});case"ModeC":return new ht({device:W,inputTexture:pe,nativeDimensions:{width:ne,height:$},targetDimensions:{width:Fe,height:Be}});case"ModeAA":return new ye({device:W,inputTexture:pe,nativeDimensions:{width:ne,height:$},targetDimensions:{width:Fe,height:Be}});default:return new tt({device:W,inputTexture:pe,nativeDimensions:{width:ne,height:$},targetDimensions:{width:Fe,height:Be}})}})(),rt=Oe.getOutputTexture(),We=W.createSampler({magFilter:"linear",minFilter:"linear"}),nt=W.createShaderModule({code:`
|
|
29
|
-
@group(0) @binding(0) var tex: texture_2d<f32>;
|
|
30
|
-
@group(0) @binding(1) var samp: sampler;
|
|
31
|
-
struct VertexOutput {
|
|
32
|
-
@builtin(position) pos: vec4f,
|
|
33
|
-
@location(0) uv: vec2f,
|
|
34
|
-
}
|
|
35
|
-
@vertex
|
|
36
|
-
fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
|
|
37
|
-
var positions = array<vec2f, 6>(
|
|
38
|
-
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
39
|
-
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
40
|
-
);
|
|
41
|
-
var uvs = array<vec2f, 6>(
|
|
42
|
-
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
43
|
-
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
44
|
-
);
|
|
45
|
-
var out: VertexOutput;
|
|
46
|
-
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
47
|
-
out.uv = uvs[idx];
|
|
48
|
-
return out;
|
|
49
|
-
}
|
|
50
|
-
@fragment
|
|
51
|
-
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
52
|
-
return textureSample(tex, samp, uv);
|
|
53
|
-
}
|
|
54
|
-
`}),Ye=W.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),st=W.createRenderPipeline({layout:W.createPipelineLayout({bindGroupLayouts:[Ye]}),vertex:{module:nt,entryPoint:"vs"},fragment:{module:nt,entryPoint:"fs",targets:[{format:He}]},primitive:{topology:"triangle-list"}}),Ue=W.createBindGroup({layout:Ye,entries:[{binding:0,resource:rt.createView()},{binding:1,resource:We}]});try{const z=W.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),te=W.createShaderModule({code:Gn}),be=W.createRenderPipeline({layout:W.createPipelineLayout({bindGroupLayouts:[z]}),vertex:{module:te,entryPoint:"vs"},fragment:{module:te,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});Y.current={pipeline:be,layout:z,inputView:pe.createView()}}catch{Y.current=null}A.current=Oe,L.current=pe,g.current=rt,u.current=st,P.current=We,_.current=Ye,D.current=!1,H.current=!1;async function vt(){const z=Y.current;if(!z||D.current)return!1;const te=r.current;if(!te)return!1;const be=!H.current;be&&W.pushErrorScope("validation");try{const le=W.importExternalTexture({source:te}),ce=W.createBindGroup({layout:z.layout,entries:[{binding:0,resource:le},{binding:1,resource:We}]}),re=W.createCommandEncoder(),Se=re.beginRenderPass({colorAttachments:[{view:z.inputView,loadOp:"load",storeOp:"store"}]});Se.setPipeline(z.pipeline),Se.setBindGroup(0,ce),Se.draw(6),Se.end(),W.queue.submit([re.finish()])}catch{return D.current=!0,Y.current=null,!1}if(be){const le=await W.popErrorScope().catch(()=>null);if(le)return console.warn("[anime4k] blit probe failed:",le.message),D.current=!0,Y.current=null,!1;H.current=!0}return!0}m(!1);async function gt(){if(w||e.current!==M||!he)return;const z=r.current;if(!z||z.videoWidth===0){de();return}if(z!==Z||z.videoWidth!==ne||z.videoHeight!==$){k(ce=>ce+1);return}if(z.paused||z.ended||document.hidden||z.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){de();return}const te=z.getVideoPlaybackQuality().totalVideoFrames;if(te===F.current){de();return}if(K.current){de();return}const be=z.currentTime;(z.seeking||fe.current>=0&&Math.abs(be-fe.current)>.5)&&(X(),q.current=!1,x.current=0,F.current=-1),fe.current=be;const le=Math.max(0,V.current||0);le>x.current&&(q.current=!1),K.current=!0;try{const ce=performance.now();let re=null,Se=!1;if(le<=0){j.current.length>0&&X(),q.current=!1,x.current=0;let Ee=!1;if(!I.current)try{W.queue.copyExternalImageToTexture({source:z},{texture:pe},[ne,$]),F.current=te,Ee=!0}catch(oe){if(oe instanceof TypeError)I.current=!0;else throw oe}if(!Ee&&!D.current&&Y.current&&await vt()&&(F.current=te,Ee=!0),!Ee){const oe=await createImageBitmap(z);F.current=te,W.queue.copyExternalImageToTexture({source:oe},{texture:pe},[ne,$]),O(oe)}}else{const Ee=await createImageBitmap(z);F.current=te;const oe=j.current;oe.push({bitmap:Ee,capture:ce});const yt=Pe(le);for(;oe.length>yt;)O(oe.shift()?.bitmap);let Xe=-1;for(let ve=oe.length-1;ve>=0;ve--)if(ce-oe[ve].capture>=le){Xe=ve;break}if(Xe!==-1){for(let ot=0;ot<Xe;ot++)O(oe.shift()?.bitmap);const ve=oe.shift();ve?(re=ve.bitmap,q.current=!0,x.current=le):(re=Ee,Se=!0)}else if(!q.current)re=Ee,Se=!0;else{const ve=oe.shift();re=ve?ve.bitmap:Ee,ve||(Se=!0)}if(!re){K.current=!1,de();return}W.queue.copyExternalImageToTexture({source:re},{texture:pe},[ne,$]),Se||O(re)}const Ve=W.createCommandEncoder();await Oe.pass(Ve);const Qe=Ve.beginRenderPass({colorAttachments:[{view:he.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});Qe.setPipeline(st),Qe.setBindGroup(0,Ue),Qe.draw(6),Qe.end(),W.queue.submit([Ve.finish()]),y.current=te,p.current=0,W.queue.onSubmittedWorkDone().then(()=>{e.current===M&&(K.current=!1)})}catch(ce){if(K.current=!1,p.current+=1,p.current>=Kn&&!w&&e.current===M){console.error(ce),f(ce instanceof Error?ce.message:"Render error"),n(!1);return}}de()}de()}catch(de){!w&&e.current===M&&(N.current?.unconfigure(),v.current?.destroy(),v.current=null,N.current=null,f(de instanceof Error?de.message:"Failed to initialize upscaler"),m(!1),n(!1))}}return se(),()=>{w=!0,e.current+=1,Ne(),X(),N.current?.unconfigure(),L.current&&(L.current.destroy(),L.current=null),g.current&&(g.current.destroy(),g.current=null),v.current&&(v.current.destroy(),v.current=null),A.current=null,u.current=null,P.current=null,_.current=null,Y.current=null,N.current=null,K.current=!1}},[s,b,r,o,l,T]);const h=G(w=>{n(w);try{J.setItem("anime4kEnabled",String(w))}catch{}},[]),C=G(()=>{n(w=>{const M=!w;try{J.setItem("anime4kEnabled",String(M))}catch{}return M})},[]);return{isWebGPUSupported:b,isEnabled:s,isInitializing:i,error:S,toggle:C,setEnabled:h}}function jn({videoRef:r,episodeKey:o,isEnabled:l,isSupported:d,mediaReady:b,isIframeSource:a,setEnabled:s}){const n=R(null),i=R(!1),m=R(!1),S=R(s);S.current=s,Q(()=>{const f=n.current;n.current=o,!(f===null||f===o)&&(!l||!d||(i.current=!0,m.current=!1,S.current(!1)))},[o,l,d]),Q(()=>{if(!i.current)return;if(l){m.current&&(i.current=!1);return}if(m.current=!0,!b)return;if(a){i.current=!1,S.current(!0);return}const f=r.current;if(!f)return;let T,k=!1;const e=()=>{k||(k=!0,i.current=!1,S.current(!0))};if(f.readyState>=2)return T=window.setTimeout(e,500),()=>window.clearTimeout(T);const v=()=>{window.setTimeout(e,500)};return f.addEventListener("canplay",v,{once:!0}),f.addEventListener("playing",v,{once:!0}),T=window.setTimeout(e,5e3),()=>{window.clearTimeout(T),f.removeEventListener("canplay",v),f.removeEventListener("playing",v)}},[l,b,a,r])}const Hn=()=>J.getItem("preferredMode")==="dub"?"dub":"sub",Yn=/^[a-z0-9-]+$/i,Ft=r=>r?"preferredProviderMature":"preferredProvider",Ot=r=>{const o=J.getItem(Ft(r));return o&&Yn.test(o)?o:null},Wt=(r,o)=>{J.setItem(Ft(o),r)},Xn=()=>Ot(!1)??"megaplay",Jn=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Hn(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:Hr(),showResumeModal:!0,resumeProgressPending:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Xn(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Zn(r,o){switch(o.type){case"SET_STATE":return{...r,...o.payload};case"SET_MODE":return{...r,currentMode:o.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...r,selectedProvider:o.payload};default:return r}}async function Lt(r,o,l,d,b=!1){if(!r||!o)throw new Error("Missing params");try{const[a,s,n,i]=await Promise.all([me.data.video.query({showId:r,episodeNumber:o,mode:l.currentMode,provider:l.selectedProvider}).catch(g=>{const u=g.data?.cause;return g.message==="AUTH_REQUIRED"&&u?.provider==="mkissa"&&d({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),me.progress.getEpisode.query({showId:r,episodeNumber:o}).catch(()=>null),me.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),me.data.skipTimes.query({showId:r,episodeNumber:o}).catch(()=>[])]),m=n?.value,S=a?.filter(g=>{const u=g.sourceName.toLowerCase();return l.currentMode==="dub"?u.includes("eng")||u.includes("dub"):u.includes("jpn")||u.includes("sub")||!u.includes("eng")&&!u.includes("dub")})??[],f=S.length>0?S:a??[];let T=f.length>0?f[0]:null;if(m){const g=f.find(u=>u.sourceName===m);g&&(T=g)}const k=T&&T.links.length>0?T.links.sort((g,u)=>(parseInt(u.resolutionStr)||0)-(parseInt(g.resolutionStr)||0))[0]:null,e=s?.currentTime||0,v=s?.duration||0,N=e,L=(Array.isArray(i)?i:i?.results||[]).map(g=>({skip_id:g.skip_id||"",skip_type:g.skip_type||"",start_time:g.interval?.start_time??g.start_time??0,end_time:g.interval?.end_time??g.end_time??0})).filter(g=>g.end_time>0);return(!a||a.length===0)&&(b||Re.error(`No video sources found for ${l.selectedProvider}`)),{videoSources:a,selectedSource:T,selectedLink:k,resumeTime:N,resumeDuration:v,showResumeModal:N>5&&!dt(N,v)&&T?.type!=="iframe",skipIntervals:L,fetchedEpisodeNumber:o}}catch(a){const s=a;if(s.message==="AUTH_REQUIRED")return d({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:s.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:o};throw a}}const es=(r,o,l,d)=>{const[b,a]=rr(Zn,l,h=>({...Jn(),showMeta:h?.name?{name:h.name,thumbnail:h.thumbnail,nativeName:h.nativeName,englishName:h.englishName,names:{romaji:h.name||h.englishName,english:h.englishName||h.name,native:h.nativeName}}:{}})),s=d?.watchSelection,n=Te(()=>s?{...b,selectedProvider:s.provider,currentMode:s.mode}:b,[b,s]),i=Dt(),m=ar(),S=R(null),f=R(null),{options:T}=It(),k=Te(()=>T.filter(h=>(h.kind??"anime")==="anime"),[T]),e=o||n.initialEpisode,v=`${r}:${e}`,N=R(v);Q(()=>{N.current!==v&&(N.current=v,a({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[v,a]),Q(()=>{!s&&r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&n.selectedProvider!=="animepahe"&&S.current!==r&&(S.current=r,a({type:"SET_PROVIDER",payload:"animepahe"}))},[r,n.selectedProvider,s]);const{data:A,isLoading:L,error:g}=en(r),{data:u}=_t({queryKey:[ie.playerData,r,n.currentMode,n.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const h=async()=>{try{const X=await me.data.episodes.query({showId:r,mode:n.currentMode,provider:n.selectedProvider}).catch(()=>null);if(X?.episodes?.length)return X}catch{}return null},[C,w,M]=await Promise.all([h(),me.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),me.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),O=C?.episodes?C.episodes.sort((X,Pe)=>parseFloat(X)-parseFloat(Pe)):[];return{description:C?.description||"",episodes:O,inWatchlist:w.inWatchlist,watchlistStatus:w.status??null,watchedEpisodes:M}},enabled:!!r});Q(()=>{!o&&u?.episodes&&u.episodes.length>0&&!o&&a({type:"SET_STATE",payload:{initialEpisode:u.episodes[0]}})},[u,o]),Q(()=>{if(s||A?.isAdult===void 0||f.current===r)return;const h=A.isAdult===!0,C=k.filter(M=>M.mature===h);if(C.length===0||k.find(M=>M.id===n.selectedProvider)?.mature===h)return;const w=Ot(h);f.current=r??null,a({type:"SET_PROVIDER",payload:C.find(M=>M.id===w)?.id??C[0].id})},[A?.isAdult,n.selectedProvider,r,k,s]),Q(()=>{if(s||!r||!/^dango-mt-\d+$/.test(r)||f.current===`temp:${r}`)return;const h=A?.provider;h&&(f.current=`temp:${r}`,h!==n.selectedProvider&&a({type:"SET_PROVIDER",payload:h}))},[r,A,n.selectedProvider,s]);const{data:P,isLoading:_,isFetching:U,error:K}=_t({queryKey:[ie.videoSources,r,e,n.selectedProvider,n.currentMode],queryFn:()=>Lt(r,e,n,a),enabled:!!r&&!!e&&!(n.showMeta?.isAdult===!0&&!d?.hasMatureConsent)}),{mutateAsync:y}=Et({mutationFn:async({wasIn:h,showMeta:C})=>{if(!r)throw new Error("Missing showId");if(h)await me.watchlist.remove.mutate({id:r});else{const w=C.name||C.names?.romaji;if(!w)throw new Error("Missing show name");await me.watchlist.add.mutate({id:r,name:w,thumbnail:C.thumbnail,nativeName:C.names?.native,englishName:C.names?.english,type:C.type,isAdult:C.isAdult})}return!h},onSuccess:h=>{Re.success(h?"Added to watchlist":"Removed from watchlist"),i.invalidateQueries({queryKey:[ie.playerData,r]}),i.invalidateQueries({queryKey:[ie.showData,r]}),i.invalidateQueries({queryKey:[ie.watchlist]})},onError:h=>Re.error(h instanceof Error?h.message:"Failed to update watchlist")}),p=G(async()=>{!r||!A||await y({wasIn:!!u?.inWatchlist,showMeta:A})},[r,A,u?.inWatchlist,y]),V=G(async h=>{try{await me.settings.set.mutate({key:"preferredSource",value:h})}catch(C){console.error(C)}},[]),{mutateAsync:j,isPending:I}=Et({mutationFn:async({status:h})=>{if(!r)throw new Error("Missing showId");if(u?.inWatchlist)return await me.watchlist.setStatus.mutate({id:r,status:h}),h;const C=A,w=C?.name||C?.names?.romaji;if(!C||!w)throw new Error("Missing show name");return await me.watchlist.add.mutate({id:r,name:w,thumbnail:C.thumbnail,nativeName:C.names?.native,englishName:C.names?.english,type:C.type,isAdult:C.isAdult,status:h}),h},onSuccess:h=>{a({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:h}}),Re.success(`Moved to ${h}`),i.invalidateQueries({queryKey:[ie.showData,r]}),i.invalidateQueries({queryKey:[ie.watchlist]}),i.invalidateQueries({queryKey:[ie.continueWatching]})},onError:()=>Re.error("Failed to update watchlist status")}),D=G(async()=>{await j({status:"Completed"})},[j]),{mutateAsync:H,isPending:Y}=Et({mutationFn:async({episodeNumber:h,duration:C,showMeta:w,episodes:M})=>{await me.progress.updateProgress.mutate({showId:r??"",episodeNumber:h,currentTime:C,duration:C,showName:w.name,showThumbnail:w.thumbnail,nativeName:w.names?.native,englishName:w.names?.english,genres:w.genres?.map(O=>O.name),popularityScore:lr(w.score)??void 0,type:w.type,status:w.status,episodeCount:M.length,isAdult:w.isAdult})},onSuccess:(h,C)=>{Re.success(`Episode ${C.episodeNumber} marked as watched`),i.invalidateQueries({queryKey:[ie.playerData,r]}),i.invalidateQueries({queryKey:[ie.showMeta,r]}),i.invalidateQueries({queryKey:[ie.videoSources,r,C.episodeNumber]}),i.invalidateQueries({queryKey:[ie.continueWatching]}),i.invalidateQueries({queryKey:[ie.thisWeekSchedule]}),i.invalidateQueries(m.continueWatching.pathFilter())},onError:()=>Re.error("Failed to mark episode as watched")}),fe=G(async(h,C)=>{!r||!A||await H({episodeNumber:h,duration:C,showMeta:A,episodes:u?.episodes||[]})},[r,A,u?.episodes,H]),F=G(async()=>{a({type:"SET_STATE",payload:{showCombinedDetails:!n.showCombinedDetails}})},[n.showCombinedDetails]),q=Te(()=>{const h=g||K,C=h?h.message:null,w=C==="AUTH_REQUIRED"?null:C,M=P&&P.fetchedEpisodeNumber===e?P:null,O=!!P&&!M,X=s?M?.videoSources?.find(se=>se.sourceName===s.source&&se.type!=="iframe"&&se.links.some(Z=>Z.hls))??null:null,Ne=(n.selectedSource?.sourceName===X?.sourceName?X?.links.find(se=>se.hls&&se.link===n.selectedLink?.link):null)??X?.links.filter(se=>se.hls).slice().sort((se,Z)=>(parseInt(Z.resolutionStr)||0)-(parseInt(se.resolutionStr)||0))[0]??null;return{...n,currentEpisode:e,showMeta:{...n.showMeta||{},...A||{}},episodes:u?.episodes||[],watchedEpisodes:u?.watchedEpisodes||[],inWatchlist:!!u?.inWatchlist,watchlistStatus:u?.watchlistStatus??n.watchlistStatus??null,videoSources:M?.videoSources||[],selectedSource:s?X:n.selectedSource||M?.selectedSource||null,selectedLink:s?Ne:n.selectedLink||M?.selectedLink||null,resumeTime:s?0:M?.resumeTime||0,resumeDuration:M?.resumeDuration||0,resumeProgressPending:U,showResumeModal:!s&&n.showResumeModal&&(M?.showResumeModal??!1),skipIntervals:M?.skipIntervals||[],loadingShowData:L,loadingVideo:_||O,error:w,fetchedEpisodeNumber:M?.fetchedEpisodeNumber}},[n,A,u,P,L,_,U,g,K,e,s]),x=G((h,C)=>{const w=C||r;if(!w||!h||w===r&&h===e)return;const O=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(w)&&n.selectedProvider!=="animepahe"?"animepahe":n.selectedProvider,X=["video-sources",w,h,O,n.currentMode];i.getQueryState(X)?.status!=="success"&&i.prefetchQuery({queryKey:X,queryFn:()=>Lt(w,h,{selectedProvider:O,currentMode:n.currentMode},a,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,e,i,n,a]);return{state:q,dispatch:a,toggleWatchlist:p,moveToCompleted:D,setPreferredSource:V,handleToggleDetails:F,markEpisodeWatched:fe,prefetchEpisodeSources:x,isMarkingWatched:Y,isUpdatingWatchlistStatus:I}};function ts({onNext:r,onToggleTheater:o,flashControls:l}){Q(()=>{const d=b=>{b.defaultPrevented||b.ctrlKey||b.metaKey||b.altKey||b.repeat||b.target.closest('input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(b.key.toLowerCase())&&l(),b.key.toLowerCase()==="n"&&r(),b.key.toLowerCase()==="t"&&o())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[l,r,o])}const Ze=(r,o,l)=>r.showId===o||!!l&&r.showId===l;function rs({testClipActive:r,selectedSourceType:o,onEnded:l,queue:d,removeFromQueue:b,showId:a,showMetaId:s,currentEpisode:n,isAutoplayEnabled:i,nextEpisode:m,previousEpisode:S,navigate:f,invalidateContinueWatching:T,dispatch:k}){const[e,v]=ae(!1),[N,A]=ae(null),[L,g]=ae(null),u=R(b);u.current=b;const P=R(!1);Q(()=>{P.current=!1,v(!1)},[a,n]);const _=G(()=>{if(r||P.current)return;P.current=!0,l();const I=d.find(D=>Ze(D,a,s)&&D.episodeNumber===n);if(d.length>0){const D=d.findIndex(Y=>Ze(Y,a,s)&&Y.episodeNumber===n),H=D>=0?d[D+1]||null:d[0];g({nextItem:H,playedItem:I||null}),A(2);return}if(I&&u.current({showId:I.showId,episodeNumber:I.episodeNumber}),i&&m){T(),f(`/watch/${a}/${m}`);return}m||v(!0)},[l,f,d,a,s,n,m,i,T,r]),U=G(()=>{if(d.length===0)return;l();const I=d.find(Y=>Ze(Y,a,s)&&Y.episodeNumber===n),D=d.findIndex(Y=>Ze(Y,a,s)&&Y.episodeNumber===n),H=D>=0?d[D+1]||null:d[0];I&&b({showId:I.showId,episodeNumber:I.episodeNumber}),H?f(`/watch/${H.showId}/${H.episodeNumber}`):m||v(!0)},[l,f,d,b,a,s,n,m]),K=G(()=>{m&&(T(),f(`/watch/${a}/${m}`)),v(!1),k({type:"SET_STATE",payload:{showResumeModal:!1}})},[m,f,a,k,T]),y=G(()=>{d.length>0?U():m?K():Re.error("No next episode available")},[d.length,U,K,m]),p=G(()=>v(!1),[]),V=G(()=>{g(null),A(null)},[]),j=G(()=>{S&&f(`/watch/${a}/${S}`)},[S,f,a]);return Q(()=>{const I=D=>{D.origin===window.location.origin&&o==="iframe"&&D.data?.type==="ANI_WEB_MEDIA_ENDED"&&_()};return window.addEventListener("message",I),()=>window.removeEventListener("message",I)},[_,o]),Q(()=>{if(!L||N===null)return;if(N<=0){const{nextItem:D,playedItem:H}=L;g(null),A(null),H&&u.current({showId:H.showId,episodeNumber:H.episodeNumber}),D?f(`/watch/${D.showId}/${D.episodeNumber}`):m||v(!0);return}const I=window.setTimeout(()=>{A(D=>D===null?null:D-1)},1e3);return()=>window.clearTimeout(I)},[L,N,f,m]),{showCompleteModal:e,queueCountdown:N,pendingQueueTransition:L,handleQueueTransition:U,handleNextEpisode:K,handleNShortcut:y,handlePreviousEpisode:j,handlePlaybackFinished:_,closeCompleteModal:p,cancelQueueTransition:V}}function ns({videoRef:r,queue:o,showId:l,showMetaId:d,currentEpisode:b,selectedSource:a,hasNextEpisode:s,nextEpisode:n,prefetchEpisodeSources:i,matchesQueueItem:m}){const[S,f]=ae(!1),T=R(i);T.current=i;const k=R("");Q(()=>{f(!1)},[b]);const e=G(()=>{const v=r.current;if(!v||a?.type==="iframe")return;const N=v.duration,A=v.currentTime;if(!N||Number.isNaN(N)){f(!1);return}if(N-A<=60){const L=o.findIndex(P=>m(P,l,d)&&P.episodeNumber===b),g=o.length>0?L>=0?o[L+1]||null:o[0]:null,u=g?`${g.showId}:${g.episodeNumber}`:s?`${l}:${n}`:"";u&&k.current!==u&&(k.current=u,g?T.current(g.episodeNumber,g.showId):T.current(n??""))}f(s&&dt(A,N))},[r,a,o,l,d,b,s,n,m]);return{showNextEpisodePrompt:S,handleThresholds:e}}const kt="fallbackChoice";function ss(){try{const r=J.getItem(kt);return r==="iframe"||r==="retry"?r:null}catch{return null}}function os(r){try{r===null?J.removeItem(kt):J.setItem(kt,r)}catch{}}function is({showId:r,episodeNumber:o,currentMode:l,selectedProvider:d,selectedSourceType:b,videoSources:a,isAdult:s,providerOrder:n,matureProviders:i,setPreferredSource:m,dispatch:S,showControls:f}){const T=R(!1),k=R([]),e=R(!1),[v,N]=ae(null),[A,L]=ae(!1),[g,u]=ae(!1),[P,_]=ae(()=>ss()??"ask"),U=G(F=>{_(F),os(F==="ask"?null:F)},[]),K=R(P);Q(()=>{K.current=P},[P]);const y=R(a);y.current=a;const p=G(()=>{T.current=!1,k.current=[],e.current=!1,N(null),L(!1)},[]);Q(()=>{p()},[p,r,o]);const V=G(F=>{if(T.current)return;T.current=!0;const q=F.links[0];m(F.sourceName),S({type:"SET_STATE",payload:{selectedSource:F,selectedLink:q}}),N(null)},[S,m]),j=G(()=>{const q=y.current.find(x=>x.type==="iframe");return q?.links?.length?q:null},[]),I=G(async()=>{const F=n.filter(q=>{if(k.current.includes(q))return!1;const x=i.has(q);return s===void 0?!0:x===s});L(!0);try{for(const q of F){k.current.push(q);let x=null;try{x=await me.data.video.query({showId:r,episodeNumber:o,mode:l,provider:q})}catch{continue}const h=(x??[]).filter(M=>{const O=M.sourceName.toLowerCase();return l==="dub"?O.includes("eng")||O.includes("dub"):O.includes("jpn")||O.includes("sub")||!O.includes("eng")&&!O.includes("dub")});if((h.length>0?h:x??[]).find(M=>M.type!=="iframe"&&M.links?.length)){k.current=[d],e.current=!1,S({type:"SET_STATE",payload:{selectedProvider:q,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Wt(q,s===!0),N(null),Re.success(`Switched to ${q} (direct stream)`);return}}N({retryFailed:!0}),Re.error("No working direct stream found on other providers")}finally{L(!1)}},[r,o,l,s,d,S,n,i]),D=G(()=>{if(T.current||e.current||b!=="player")return;const F=j();if(!F)return;k.current.includes(d)||k.current.push(d);const q=K.current;if(q==="iframe"){V(F);return}if(q==="retry"){I();return}f(!0),N({retryFailed:!1})},[b,d,j,V,I,f]),H=G(()=>{e.current=!0,N(null),u(!1)},[]),Y=G(()=>{g&&U("iframe");const F=j();F?V(F):N(null)},[g,U,j,V]),fe=G(()=>{g&&U("retry"),I()},[g,U,I]);return{fallbackPrompt:v,isRetryingProvider:A,rememberFallbackChoice:g,setRememberFallbackChoice:u,fallbackChoice:P,updateFallbackChoice:U,dismissFallbackPrompt:H,chooseIframeFallback:Y,chooseProviderRetry:fe,handleVideoSourceError:D,resetFallback:p}}function as({engine:r,videoRef:o,selectedSource:l,selectedLink:d,loadingVideo:b,testClipActive:a,resumeTime:s,resumeDuration:n=0,showResumeModal:i,calibReturnRef:m,setAvailableSubtitles:S,setActiveSubtitleTrack:f,onFatalError:T}){const k=R(null),e=R(s),v=R(n),N=R(i),A=R(T);return A.current=T,Q(()=>{e.current=s,v.current=n,N.current=i},[s,n,i]),Q(()=>{const L=o.current;if(!L)return;for(;L.firstChild;)L.removeChild(L.firstChild);if(a)return r.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!0});if(b||!l||!d||l.type==="iframe"){r.unload();return}m.current!=null?(k.current=m.current,m.current=null):k.current===null&&e.current>5&&!N.current&&!dt(e.current,v.current)?k.current=e.current:k.current===null&&N.current&&(k.current=0);let g=d.link;if(g.startsWith("/api/proxy")||(g=`/api/proxy?url=${encodeURIComponent(g)}`,d.headers?.Referer&&(g+=`&referer=${encodeURIComponent(d.headers.Referer)}`)),l.subtitles){const _=J.getItem("playerSubtitlesEnabled")!=="false";let U=null;try{U=J.getItem("playerLastSubtitle")}catch{}const K=wt(l.subtitles,{lastKey:U,enabled:_}),y=K>=0?l.subtitles[K]:null;l.subtitles.forEach(p=>{const V=document.createElement("track");V.kind="subtitles",V.label=p.label,V.srclang=p.lang;const j=p.src??p.url;if(j){let I=`/api/subtitle-proxy?url=${encodeURIComponent(j)}`;const D=d.headers?.Referer;D&&(I+=`&referer=${encodeURIComponent(D)}`),V.src=I}y&&p.label===y.label&&p.lang===y.lang&&(V.default=!0),L.appendChild(V)}),_||f("off"),S(l.subtitles)}const u=k.current??0;k.current=null;const P=document.body.classList.contains("low-end");return r.loadSource({url:g,hls:d.hls},{initialTime:u,autoPlay:!(N.current&&e.current>5)&&!dt(e.current,v.current),hlsConfig:{maxBufferLength:P?15:30,maxMaxBufferLength:P?30:60,maxBufferSize:(P?25:60)*1e3*1e3,startLevel:-1},onHls:(_,U)=>{if(!l.subtitles?.length)return;const K=()=>{_.subtitleTrack!==-1&&(_.subtitleTrack=-1)};_.on(U.Events.SUBTITLE_TRACK_SWITCH,K),K()},onError:()=>A.current()})},[r,l,d,o,m,b,a,f,S]),{seekToTimeRef:k}}function ls({videoRef:r,availableSubtitles:o,activeSubtitleTrack:l,setAvailableSubtitles:d,setActiveSubtitleTrack:b}){Q(()=>{const a=r.current;if(!a)return;const s=()=>{const n=Array.from(a.textTracks).map(i=>({label:i.label,lang:i.language,src:void 0,mode:i.mode}));d(n)};return a.textTracks.addEventListener("addtrack",s),a.textTracks.addEventListener("removetrack",s),s(),()=>{a.textTracks.removeEventListener("addtrack",s),a.textTracks.removeEventListener("removetrack",s)}},[r,d]),Q(()=>{if(l===null&&o.length>0&&J.getItem("playerSubtitlesEnabled")!=="false"){let a=null;try{a=J.getItem("playerLastSubtitle")}catch{}const s=wt(o,{lastKey:a,enabled:!0});if(s<0){b("off");return}const n=o[s];b(n.lang||n.label)}},[l,o,b]),Q(()=>{const a=r.current;if(!a||o.length===0)return;const s=l;if(!(J.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(a.textTracks).forEach(m=>{m.mode="hidden"});return}let i=!1;if(Array.from(a.textTracks).forEach(m=>{const f=(m.language===s||m.label===s)&&!i;m.mode=f?"showing":"hidden",f&&(i=!0)}),!i&&a.textTracks.length>0){const m=Array.from(a.textTracks).find(S=>S.language==="en"||S.label==="English")||a.textTracks[0];m&&(m.mode="showing")}},[l,o,r])}function cs({videoRef:r,videoBoxH:o,style:l,sourceKey:d,activeSubtitleTrack:b,availableSubtitles:a}){Q(()=>{const s="dynamic-subtitle-styles";let n=document.getElementById(s);n||(n=document.createElement("style"),n.id=s,document.head.appendChild(n)),n.textContent=xt(l);const i=r.current;if(!i)return;const m=$t(l.fontSize,o||i.clientHeight||720);n.textContent=xt({...l,fontSize:m});const S=()=>{const u=Number(l.position),P=isNaN(u)?0:Math.max(0,Math.min(100,u));return Math.max(0,Math.min(100,100-P))},f=(u,P)=>{try{const _=u;_.snapToLines=!1,_.line=P}catch{}},T=()=>{const u=m*16,P=i.videoHeight||i.clientHeight||720,_=i.videoWidth||i.clientWidth||1280;return{step:u*1.3/P*100,chars:Math.max(20,Math.floor(_/(u*.55)))}},k=u=>{const P=S(),_=Array.from(u.activeCues??[]);if(_.length<=1){_.forEach(p=>f(p,P));return}const{step:U,chars:K}=T();let y=P;for(let p=_.length-1;p>=0;p--){const j=String(_[p].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
-
`).reduce((D,H)=>D+Math.max(1,Math.ceil(H.length/K)),0),I=y-j*U;f(_[p],Math.max(0,I)),y=I-U*.4}},e=u=>{if(!u.cues)return;const P=S();Array.from(u.cues).forEach(_=>f(_,P)),u.mode==="showing"&&k(u)},v=()=>{Array.from(i.textTracks).forEach(e)};v();const N=u=>{const P=u.target;P.mode==="showing"&&k(P)};Array.from(i.textTracks).forEach(u=>{u.addEventListener("cuechange",N)});const A=()=>{Array.from(i.textTracks).forEach(u=>{u.removeEventListener("cuechange",N),u.addEventListener("cuechange",N)}),v()};i.textTracks.addEventListener("addtrack",A),i.textTracks.addEventListener("removetrack",A);const L=Array.from(i.querySelectorAll("track")),g=()=>{v()};return L.forEach(u=>{u.addEventListener("load",g)}),()=>{Array.from(i.textTracks).forEach(u=>{u.removeEventListener("cuechange",N)}),i.textTracks.removeEventListener("addtrack",A),i.textTracks.removeEventListener("removetrack",A),L.forEach(u=>{u.removeEventListener("load",g)})}},[l,o,r,d,b,a])}function us({videoRef:r,overlayRef:o,style:l,activeSubtitleTrack:d,delayMs:b,enabled:a}){Q(()=>{if(!a)return;const s=r.current,n=o.current;if(!s||!n)return;const i=J.getItem("playerSubtitlesEnabled")!=="false",m=()=>{if(n.innerHTML="",!i||d==="off"||d===null)return;const T=Array.from(s.textTracks).find(g=>g.language===d||g.label===d);if(!T||T.mode!=="showing")return;const k=b/1e3;let e;if(k>0&&T.cues){const g=s.currentTime-k;e=Array.from(T.cues).filter(u=>u.startTime<=g&&g<=u.endTime)}else e=Array.from(T.activeCues??[]);if(e.length===0)return;const v={...l,fontSize:$t(l.fontSize,s.clientHeight||0)},N=Pr(v),A=Ar(s,v.position),L=Array.from(e);L.forEach((g,u)=>{const P=String(g.text??"");if(!_r(P).trim())return;const _=document.createElement("div"),U=(L.length-1-u)*1.7;_.style.cssText=`${N}
|
|
56
|
-
bottom: calc(${A}px + ${U}em);`,_.innerHTML=xr(P),n.appendChild(_)})},S=()=>m(),f=()=>m();return Array.from(s.textTracks).forEach(T=>{T.addEventListener("cuechange",S)}),s.addEventListener("timeupdate",f),m(),()=>{Array.from(s.textTracks).forEach(T=>{T.removeEventListener("cuechange",S)}),s.removeEventListener("timeupdate",f),n.innerHTML=""}},[d,b,a,o,l,r])}const ds=({isOpen:r,onClose:o,onSuccess:l})=>{const d=()=>{l?.(),o()};return t(ut,{isOpen:r,onClose:o,title:"MKissa Browser Verification",children:t("div",{className:Ke.container,children:[t("p",{children:"Open MKissa in this browser, play an anime episode, and complete any Cloudflare verification it shows. Once playback works there, return to Dango and click Refresh."}),t("div",{className:Ke.actions,children:t("a",{className:Ke.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),t("div",{className:Ke.actions,children:[t("button",{className:Ke.secondaryButton,onClick:o,children:"Cancel"}),t("button",{className:Ke.button,onClick:d,children:"Refresh Dango"})]})]})})},Ps=()=>{const{id:r,episodeNumber:o}=nr(),l=sr(),d=Dt(),b=or(),a=cr(),s=!!a.session,n=s&&!a.session?.host,{hasConsent:i,grant:m}=ur(),{options:S}=It(),f=Te(()=>S.filter(c=>(c.kind??"anime")==="anime"),[S]),T=Te(()=>f.map(c=>c.id),[f]),k=Te(()=>new Set(f.filter(c=>c.mature).map(c=>c.id)),[f]),{state:e,dispatch:v,toggleWatchlist:N,moveToCompleted:A,setPreferredSource:L,handleToggleDetails:g,markEpisodeWatched:u,prefetchEpisodeSources:P,isMarkingWatched:_,isUpdatingWatchlistStatus:U}=es(r,o,b.state||null,{hasMatureConsent:i,watchSelection:n?a.room?.selection:null});Q(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const c=o?`/watch/${e.showMeta.id}/${o}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;l(c,{replace:!0})}},[r,e.showMeta?.id,o,l]);const K=Te(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),y=Lr({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:K}),{refs:p,actions:V}=y,j=Te(()=>!r||r.startsWith("dango-mt-")||!e.currentEpisode||e.selectedSource?.type==="iframe"||!e.selectedLink?.hls||!e.selectedSource?null:{showId:r,episode:e.currentEpisode,provider:e.selectedProvider,mode:e.currentMode,source:e.selectedSource.sourceName,title:e.showMeta.name||r},[r,e.currentEpisode,e.selectedProvider,e.currentMode,e.selectedSource,e.selectedLink,e.showMeta.name]),I=Br(y.engine,j,e.loadingVideo||e.loadingShowData),D=Jr(),H=R(null),Y=R(null),fe=R(null),[F,q]=ae(()=>{try{const c=J.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(c)?c:"balanced"}catch{return"balanced"}}),{videoDelayMs:x,videoDelayEnabled:h,setDelayEnabled:C,handleVideoDelayChange:w,isCalibrating:M,testClipActive:O,stopCalibration:X,openAvSyncCalibrator:Pe,cancelAvSyncCalibrator:Ne,applyAvSyncCalibrator:se,toggleTestClip:Z,calibReturnRef:Ae,effectiveVideoDelayMs:Le}=Dr(p.videoRef,()=>V.setShowSettings(!1)),ne=R(null),$=zn({videoRef:p.videoRef,canvasRef:Y,profile:F,delayMs:Le}),ue=$.isEnabled&&$.isWebGPUSupported;jn({videoRef:p.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:$.isEnabled,isSupported:$.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:$.setEnabled}),$r({videoRef:p.videoRef,canvasRef:ne,delayMs:Le,enabled:h&&!ue});const et=h&&!ue,qe=ue||et,[Ge,ze]=ae(!1),Ie=R(o);Q(()=>{Ie.current!==o&&(Ie.current=o,X())},[o,X]);const mt=G(()=>{d.invalidateQueries({queryKey:[ie.continueWatching]})},[d]),{data:Ce=[],isLoading:de}=dr(),tt=mr(),ft=fr(),ht=hr(),{isTheaterMode:ye,toggleTheaterMode:je,handleLayoutClick:W}=Ir();ir(()=>{if(y.state.isFullscreen||ye)return;const c=p.playerContainerRef.current,ee=H.current;if(!c||!ee)return;const De=()=>{const St=c.getBoundingClientRect().height;ee.style.height=`${St}px`};De();const xe=new ResizeObserver(De);return xe.observe(c),()=>xe.disconnect()},[y.state.isFullscreen,ye,p.playerContainerRef]);const he=Te(()=>e.episodes.findIndex(c=>c===e.currentEpisode),[e.episodes,e.currentEpisode]),He=he>0?e.episodes[he-1]:null,pe=he>=0&&he<e.episodes.length-1?e.episodes[he+1]:null,pt=he>-1&&he<e.episodes.length-1,{showCompleteModal:Fe,queueCountdown:Be,pendingQueueTransition:Oe,handleQueueTransition:rt,handleNextEpisode:We,handleNShortcut:nt,handlePreviousEpisode:Ye,handlePlaybackFinished:st,closeCompleteModal:Ue,cancelQueueTransition:vt}=rs({testClipActive:O,selectedSourceType:e.selectedSource?.type,onEnded:V.onEnded,queue:Ce,removeFromQueue:tt.mutate,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,isAutoplayEnabled:!n&&e.isAutoplayEnabled,nextEpisode:pe,previousEpisode:He,navigate:l,invalidateContinueWatching:mt,dispatch:v}),{showNextEpisodePrompt:gt,handleThresholds:z}=ns({videoRef:p.videoRef,queue:Ce,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:pt,nextEpisode:pe,prefetchEpisodeSources:P,matchesQueueItem:Ze}),{checkEnd:te,logDuration:be}=Fr({videoRef:p.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}`,onEnd:n?V.onEnded:st}),le=!s&&e.showResumeModal&&!e.resumeProgressPending,ce=Fe,re=le||ce;Or(y,!!e.selectedLink&&!ye&&!re);const{fallbackPrompt:Se,isRetryingProvider:Ve,rememberFallbackChoice:Qe,setRememberFallbackChoice:Ee,fallbackChoice:oe,updateFallbackChoice:yt,dismissFallbackPrompt:Xe,chooseIframeFallback:ve,chooseProviderRetry:ot,handleVideoSourceError:Tt,resetFallback:Ct}=is({showId:r,episodeNumber:e.currentEpisode??void 0,currentMode:e.currentMode,selectedProvider:e.selectedProvider,selectedSourceType:e.selectedSource?.type,videoSources:e.videoSources,isAdult:e.showMeta?.isAdult,providerOrder:T,matureProviders:k,setPreferredSource:L,showControls:V.setShowControls,dispatch:v}),{seekToTimeRef:Mt}=as({engine:y.engine,videoRef:p.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:!s&&O,resumeTime:s?0:e.resumeTime,resumeDuration:e.resumeDuration,showResumeModal:!s&&e.showResumeModal,calibReturnRef:Ae,setAvailableSubtitles:V.setAvailableSubtitles,setActiveSubtitleTrack:V.setActiveSubtitleTrack,onFatalError:s?()=>{}:Tt});Q(()=>{re&&y.state.isFullscreen&&y.actions.toggleFullscreen()},[re,y.state.isFullscreen,y.actions]),Q(()=>{re&&p.videoRef.current&&p.videoRef.current.pause()},[re,p.videoRef]);const{titlePreference:it}=pr(),{lowEndMode:Rt}=vr(),{settings:bt,update:Ut}=Wr(),Vt=ye&&bt.enabled&&!Rt&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,_e=Te(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:c,names:ee}=e.showMeta;return it==="name"?c||"Loading...":it==="nativeName"?ee?.native||c||"Loading...":it==="englishName"?ee?.english||c||"Loading...":c||"Loading..."},[e.showMeta,it,e.loadingShowData]);Q(()=>{_e&&_e!=="Loading..."&&e.currentEpisode&&(document.title=`► ${_e} Episode ${e.currentEpisode} - dango`)},[_e,e.currentEpisode]),ts({onNext:n?()=>{}:nt,onToggleTheater:je,flashControls:y.actions.flashControls});const{setAvailableSubtitles:Qt,setActiveSubtitleTrack:Kt}=V,Nt=Te(()=>({fontSize:y.state.subtitleFontSize,position:y.state.subtitlePosition,bgOpacity:y.state.subtitleBgOpacity,bgColor:y.state.subtitleBgColor,textColor:y.state.subtitleTextColor,edge:y.state.subtitleEdge,bold:y.state.subtitleBold}),[y.state.subtitleFontSize,y.state.subtitlePosition,y.state.subtitleBgOpacity,y.state.subtitleBgColor,y.state.subtitleTextColor,y.state.subtitleEdge,y.state.subtitleBold]);ls({videoRef:p.videoRef,availableSubtitles:y.state.availableSubtitles,activeSubtitleTrack:y.state.activeSubtitleTrack,setAvailableSubtitles:Qt,setActiveSubtitleTrack:Kt});const[qt,Gt]=ae(0);Q(()=>{const c=p.videoRef.current;if(!c)return;const ee=()=>Gt(c.clientHeight||0);ee();const De=new ResizeObserver(ee);return De.observe(c),()=>De.disconnect()},[p.videoRef,e.selectedSource,e.selectedLink]),cs({videoRef:p.videoRef,videoBoxH:qt,style:Nt,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:y.state.activeSubtitleTrack,availableSubtitles:y.state.availableSubtitles}),us({videoRef:p.videoRef,overlayRef:fe,style:Nt,activeSubtitleTrack:y.state.activeSubtitleTrack,delayMs:Le,enabled:qe}),Q(()=>{try{J.setItem("anime4kProfile",F)}catch{}},[F]);const zt=()=>{p.videoRef.current&&(p.videoRef.current.currentTime=e.resumeTime,p.videoRef.current.play()),v({type:"SET_STATE",payload:{showResumeModal:!1}})},jt=()=>{p.videoRef.current&&(p.videoRef.current.currentTime=0,p.videoRef.current.play()),v({type:"SET_STATE",payload:{showResumeModal:!1}})},Ht=G(()=>{v({type:"SET_STATE",payload:{showResumeModal:!1}})},[v]),Yt=G(async()=>{try{await A(),Ue(),v({type:"SET_STATE",payload:{showResumeModal:!1}}),l("/")}catch{}},[A,Ue,v,l]),Pt=(c,ee)=>t("div",{className:c,children:[t("button",{className:`${E.episodeNavBtn} ${E.secondary}`,onClick:Ye,disabled:n||!He,type:"button",children:[t(ge,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${E.episodeNavBtn} ${E.primary}`,onClick:We,disabled:n||!pe,type:"button",children:["Next EP",t(ge,{name:"chevron-right",size:12})]}),ee==="mobile"&&D&&t("button",{className:`${E.episodeNavBtn} ${E.episodePickerBtn}`,onClick:()=>ze(!0),type:"button",children:[t(ge,{name:"list-ul",size:12}),"Episodes"]})]}),Xt=c=>{v({type:"SET_STATE",payload:{isAutoplayEnabled:c}}),Yr(c)},At=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Jt=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Zt=G(async()=>{if(!r||!e.currentEpisode||!e.showMeta.name||_)return;const c=p.videoRef.current?.duration,ee=Math.max(c||0,e.resumeDuration||0,Number(e.showMeta.episodeDuration||0)*60,1);await u(e.currentEpisode,ee)},[r,e.currentEpisode,e.showMeta,e.resumeDuration,u,_,p.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return t("p",{className:"error-message",children:["Error: ",e.error]});const ke=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!i?t("div",{className:we.playerPageLayout,children:t(Xr,{isOpen:!0,onClose:()=>l("/home"),onGrant:m})}):t("div",{className:`${we.playerPageLayout} ${ye?we.theaterMode:""}`,onClick:W,children:[ye&&t(Ur,{videoRef:p.videoRef,active:Vt,settings:bt}),t(Vr,{isOpen:ce,onClose:Ue,title:"Show Completed!",heading:_e,message:"Congratulations! You finished all available episodes.",children:[t(lt,{variant:"secondary",onClick:Ue,children:"Close"}),t(lt,{onClick:Yt,disabled:U,children:U?"Saving...":"Move to Completed"})]}),t(Qr,{isOpen:le,onClose:Ht,title:"Resume Playback?",message:t(at,{children:["You were watching at ",t("strong",{children:y.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:zt,onRestart:jt}),t(ut,{isOpen:!!Se,onClose:Xe,title:"Direct stream failed",width:"sm",children:[t(ut.Body,{children:[t("p",{children:[t("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),Se?.retryFailed&&t("p",{children:"No working direct stream was found on the other providers either."}),t("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",t("strong",{children:"ads and pop-ups"}),"."]}),t("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[t("input",{type:"checkbox",checked:Qe,onChange:c=>Ee(c.currentTarget.checked)}),"Remember my choice"]})]}),t(ut.Actions,{children:[t(lt,{variant:"secondary",onClick:ve,children:"Continue with iframe"}),t(lt,{onClick:ot,disabled:Ve,children:Ve?"Searching…":"Try another provider"})]})]}),t(gr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>v({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{d.invalidateQueries({queryKey:[ie.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(ds,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>v({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{d.invalidateQueries({queryKey:[ie.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ye&&t("aside",{ref:H,className:we.episodeSidebar,children:e.loadingShowData?t(Kr,{variant:"sidebar"}):t(qr,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:c=>{n||l(`/watch/${r}/${c}`)}})}),t("div",{className:we.playerMain,children:[t("div",{className:`${E.videoContainer} ${y.state.isFullscreen?"":we.videoPlayerWrapper} ${y.state.isFullscreen?E.fullscreenActive:""}`,style:{...re?{visibility:"hidden"}:{}},onContextMenu:c=>c.preventDefault(),children:t(Bn,{player:y,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Xt,fallbackChoice:oe,onFallbackChoiceChange:yt,ambientSettings:bt,onAmbientChange:Ut,showNextEpisodeButton:!n&&!re&>&&Ce.length===0,onNextEpisode:We,videoSources:n?[]:s?e.videoSources.filter(c=>c.type!=="iframe"&&c.links.some(ee=>ee.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(c,ee)=>{n&&c.sourceName!==a.room?.selection.source||s&&(c.type==="iframe"||!ee.hls)||(p.videoRef.current&&!isNaN(p.videoRef.current.currentTime)&&(Mt.current=p.videoRef.current.currentTime),L(c.sourceName),v({type:"SET_STATE",payload:{selectedSource:c,selectedLink:ee,showResumeModal:e.showResumeModal&&c.type!=="iframe"}}))},loadingVideo:ke,skipIntervals:e.skipIntervals,animeTitle:_e,episodeNumber:e.currentEpisode??void 0,isTheaterMode:ye,onTheaterModeToggle:je,anime4kEnabled:$.isEnabled,onAnime4kToggle:$.toggle,anime4kSupported:$.isWebGPUSupported,anime4kProfile:F,onAnime4kProfileChange:q,anime4kInitializing:$.isInitializing,anime4kError:$.error,videoDelayEnabled:h,onVideoDelayToggle:C,videoDelayMs:x,onVideoDelayChange:w,onCalibrateAvSync:s?()=>{}:Pe,isInteractingExtra:Ge||M,className:wr.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:t(at,{children:[y.state.isSpeedBoostActive&&t("div",{className:E.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(ge,{name:"forward",size:12})]}),Be!==null&&Oe?.nextItem&&t("div",{className:E.queueCountdown,children:["Queue next in ",Be,"s"]})]}),children:[ke&&t("div",{className:E.loadingOverlay,children:t("div",{className:E.loadingDots,children:[t("div",{className:E.dot}),t("div",{className:E.dot}),t("div",{className:E.dot})]})}),y.state.isBuffering&&!ke&&e.selectedSource?.type!=="iframe"&&t("div",{className:E.bufferingOverlay,children:t("div",{className:E.bufferingSpinner})}),e.selectedSource?.type==="iframe"&&!s?!ke&&t("iframe",{src:e.selectedLink?.link,className:E.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):t(at,{children:[!ke&&e.videoSources.length===0&&t("div",{className:E.errorOverlay,children:[t("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),t("p",{className:E.errorSubtext,children:"Please try selecting a different provider below."}),t("button",{className:E.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!ke&&e.videoSources.length>0&&t(Tr,{controls:!y.state.playbackLocked&&y.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:V.onPlay,onPause:V.onPause,onEnded:()=>{O||te(!0)},onDurationChange:()=>{be()},onSeeked:()=>{O||(z(),te())},onLoadedMetadata:()=>{z(),be(),O||te()},onTimeUpdate:()=>{O||(V.onTimeUpdate(),z(),te(),Oe&&p.videoRef.current&&p.videoRef.current.currentTime<p.videoRef.current.duration-1&&vt())},onError:s?void 0:Tt,onContextMenu:c=>c.preventDefault(),className:qe?E.videoElementHidden:""}),$.isWebGPUSupported&&!ke&&e.videoSources.length>0&&t("canvas",{ref:Y,className:`${E.upscalerCanvas} ${ue?E.upscalerActive:""}`}),!ue&&!ke&&e.videoSources.length>0&&t("canvas",{ref:ne,className:`${E.upscalerCanvas} ${et?E.upscalerActive:""}`}),$.isEnabled&&$.isWebGPUSupported&&$.isInitializing&&t("div",{className:E.upscalerStatusBadge,children:"Preparing upscaler…"}),qe&&t("div",{ref:fe,className:E.subtitleOverlay}),t(Gr,{isOpen:M,ms:x,onChange:w,onApply:se,onClose:Ne,testClipActive:O,onTestClip:Z})]})]})}),t(sn,{playback:j&&!ke?{selection:j,position:p.videoRef.current?.currentTime||0,playing:!1,rate:y.engine.getState().playbackRate}:null,onCreate:()=>{X(),y.engine.pause()},needsPlayback:I.needsPlayback,onEnablePlayback:I.enablePlayback}),s&&!ke&&!j&&t("p",{role:"alert",children:"This room requires the host's direct HLS source. It is unavailable here. Retry the episode or leave the room to use another source."}),!ye&&t(zr,{}),!ye&&t(at,{children:[de&&Ce.length===0?t(Dn,{count:3}):t(Zr,{title:"Queue",items:Ce,currentShowId:r,currentEpisode:e.currentEpisode??void 0,onNextQueue:n?()=>{}:rt,onRemove:c=>tt.mutate({showId:c.showId,episodeNumber:c.episodeNumber}),onClear:()=>ft.mutate(),showClearAll:!0,onReorder:c=>ht.mutate(c.map(ee=>({id:ee.id,showId:ee.showId,episodeNumber:ee.episodeNumber})))}),t("div",{className:E.streamPanel,children:[!n&&t(On,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:f,onProviderChange:c=>{Ct(),v({type:"SET_STATE",payload:{selectedProvider:c,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Wt(c,e.showMeta?.isAdult===!0)}}),Pt(`${E.episodeActions} ${E.desktopEpisodeActions}`,"desktop"),ke?t("div",{className:E.sourceLoader,children:t("div",{className:E.spinner})}):n?t("p",{children:["Provider: ",e.selectedProvider," · Source: ",a.room?.selection.source," ·"," ",e.currentMode]}):t(Un,{videoSources:s?e.videoSources.filter(c=>c.type!=="iframe"&&c.links.some(ee=>ee.hls)):e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:c=>{if(s&&(c.type==="iframe"||!c.links.some(xe=>xe.hls)))return;p.videoRef.current&&!isNaN(p.videoRef.current.currentTime)&&(Mt.current=p.videoRef.current.currentTime);const De=(s?c.links.filter(xe=>xe.hls):c.links||[]).sort((xe,St)=>(parseInt(St.resolutionStr)||0)-(parseInt(xe.resolutionStr)||0))[0]||null;L(c.sourceName),v({type:"SET_STATE",payload:{selectedSource:c,selectedLink:De,showResumeModal:e.showResumeModal&&c.type!=="iframe"}})},onLinkChange:c=>{e.selectedSource&&(L(e.selectedSource.sourceName),v({type:"SET_STATE",payload:{selectedLink:c}}))}})]}),t("div",{className:we.playerInfoContainer,children:[t("div",{className:we.playerInfoHeader,children:[t("div",{className:we.playerAnimeCard,children:t("img",{src:yr(e.showMeta.thumbnail||""),alt:_e,loading:"lazy",decoding:"async",onError:c=>{c.target.src="/placeholder.svg"}})}),t("div",{className:we.videoTitleSection,children:[t("div",{className:E.titleContainer,children:[t("h1",{children:_e}),t("div",{className:E.scheduleInfo,children:[e.showMeta.status&&t("span",{className:E.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&t("span",{className:E.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),t("div",{className:E.controls,children:[t("button",{className:`${E.watchlistBtn} ${e.inWatchlist?E.inList:""}`,onClick:N,children:[e.inWatchlist?t(ge,{name:"check",size:14}):t(ge,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),t(tn,{showId:r,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${E.watchlistBtn} ${E.queueBtn}`,activeClassName:E.queueActive}),Jt&&t("button",{className:`${E.watchlistBtn} ${E.markWatchedBtn} ${At?E.markWatchedDone:""}`,onClick:Zt,disabled:_||!e.currentEpisode,children:[t(ge,{name:"check",size:14}),_?"Saving...":At?"Watched":"Mark Watched"]}),t("button",{className:`${E.watchlistBtn} ${E.modeToggleBtn} ${e.currentMode==="dub"?E.modeToggleActive:""}`,disabled:n,onClick:()=>{const c=e.currentMode==="dub"?"sub":"dub";Ct(),v({type:"SET_MODE",payload:c}),J.setItem("preferredMode",c)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),Rt&&t("button",{disabled:n,className:`${E.watchlistBtn} ${E.modeToggleBtn} ${y.state.useNativeControls?E.modeToggleActive:""}`,onClick:()=>{const c=!y.state.useNativeControls;y.actions.setUseNativeControls(c),J.setItem("playerUseNativeControls",c.toString())},type:"button",children:y.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),Pt(`${E.episodeActions} ${E.mobileEpisodeActions}`,"mobile"),t("div",{className:we.infoColumns,children:[t("div",{className:`${E.descriptionSection} ${E.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(nn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),t("button",{className:E.detailsToggleBtn,onClick:g,children:[e.showCombinedDetails?t(ge,{name:"chevron-up"}):t(ge,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(rn,{showMeta:e.showMeta,styles:E})]})]})]})]}),t(jr,{isOpen:Ge,onClose:()=>ze(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:c=>{ze(!1),l(`/watch/${r}/${c}`)}})]})};export{Ps as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{X as Ee,x as we,u as d,A as C,q as de,h as X,d as ue,T as oe,_ as Te,C as me}from"./vendor-core-DfaOB3Rn.js";import{I as te}from"./vendor-icons-DrybRNxP.js";import{_ as Pe,p as pe,g as be}from"./index-DYanm9eZ.js";const ye=Ee(null);function q(){const n=we(ye);if(!n)throw new Error("Player controls must be inside a PlayerProvider.");return n}function ve(n,i){const t=q(),r=C(i);r.current=i;const l=n?.url,m=n?.hls,s=de(g=>{t.mediaRef.current=g,t.connect()},[t]);return X(()=>{if(l)return t.loadSource({url:l,hls:m},r.current)},[t,l,m]),s}function Ge({source:n,sourceOptions:i,...t}){const r=ve(n,i);return d("video",{playsInline:!0,...t,ref:r})}function ze({source:n,sourceOptions:i,...t}){const r=ve(n,i);return d("audio",{...t,ref:r})}const Se="_shell_u5gii_1",Le="_stage_u5gii_38",Fe="_shellFill_u5gii_87",Re="_shellFullscreen_u5gii_95",Me="_uiLayer_u5gii_110",xe="_engineStatus_u5gii_121",Ce="_volumeWrap_u5gii_134",_e="_volumeSlider_u5gii_140",se={shell:Se,stage:Le,shellFill:Fe,shellFullscreen:Re,uiLayer:Me,engineStatus:xe,volumeWrap:Ce,volumeSlider:_e},Be=({classes:n,videoRef:i,duration:t,formatTime:r,isScrubbing:l,buffered:m="auto",onSeek:s,onScrubStart:g,onScrubMove:v,onScrubEnd:R,timeLabelRef:E,children:w})=>{const p=C(null),S=C(null),P=C(null),k=C(null),h=C(null),u=C(!1),f=C(l);f.current=l;const b=C({onScrubMove:v,onScrubEnd:R});b.current={onScrubMove:v,onScrubEnd:R};const[A,I]=ue({time:0,position:null});X(()=>{const c=i.current;if(!c)return;const y=_=>{const U=_/t*100||0;p.current?.setAttribute("aria-valuenow",String(Math.round(_))),p.current?.setAttribute("aria-valuetext",`${r(_)} of ${r(t)}`),S.current&&(S.current.style.width=`${U}%`),P.current&&(P.current.style.left=`${U}%`),E?.current&&(E.current.innerText=`${r(_)} / ${r(t)}`)},M=()=>{l||y(c.currentTime)},$=()=>{if(m==="auto"&&c.buffered.length>0){const U=c.buffered.end(c.buffered.length-1)/t*100||0;k.current&&(k.current.style.width=`${U}%`)}};return y(c.currentTime),$(),c.addEventListener("timeupdate",M),c.addEventListener("progress",$),()=>{c.removeEventListener("timeupdate",M),c.removeEventListener("progress",$)}},[i,t,l,m,r,E]);const D=c=>{if(!p.current)return 0;const y=p.current.getBoundingClientRect();return y.width<=0?0:Math.min(1,Math.max(0,(c-y.left)/y.width))},Q=c=>{const y=c*t;p.current?.setAttribute("aria-valuenow",String(Math.round(y))),p.current?.setAttribute("aria-valuetext",`${r(y)} of ${r(t)}`);const M=y/t*100||0;S.current&&(S.current.style.width=`${M}%`),P.current&&(P.current.style.left=`${M}%`),E?.current&&(E.current.innerText=`${r(y)} / ${r(t)}`);const $=p.current?.getBoundingClientRect();I({time:y,position:$?c*$.width:null})};X(()=>{if(!l){h.current=null;return}const c=M=>{if(h.current!==null&&M.pointerId!==h.current||!t)return;const $=D(M.clientX);b.current.onScrubMove($);const _=$*t;p.current?.setAttribute("aria-valuenow",String(Math.round(_))),p.current?.setAttribute("aria-valuetext",`${r(_)} of ${r(t)}`);const U=_/t*100||0;S.current&&(S.current.style.width=`${U}%`),P.current&&(P.current.style.left=`${U}%`),E?.current&&(E.current.innerText=`${r(_)} / ${r(t)}`);const e=p.current?.getBoundingClientRect();I({time:_,position:e?$*e.width:null})},y=M=>{h.current!==null&&M.pointerId!==h.current||(h.current=null,u.current=!0,M.pointerType!=="mouse"&&I({time:0,position:null}),b.current.onScrubEnd())};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",y),document.addEventListener("pointercancel",y),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",y),document.removeEventListener("pointercancel",y)}},[l,t,r,E]);const ne=c=>{if(c.pointerType==="mouse"&&c.button!==0||!i.current||!t)return;c.preventDefault(),h.current=c.pointerId;try{p.current?.setPointerCapture(c.pointerId)}catch{}f.current||(f.current=!0,g());const y=D(c.clientX);v(y),Q(y)},G=c=>{if(!t||f.current||c.pointerType!=="mouse")return;const y=D(c.clientX);I({time:y*t,position:c.clientX-(p.current?.getBoundingClientRect().left??0)})},Z=c=>{if(!(h.current!==null&&c.pointerId!==h.current)&&f.current){h.current=null,u.current=!0,c.pointerType!=="mouse"&&I({time:0,position:null});try{p.current?.hasPointerCapture(c.pointerId)&&p.current.releasePointerCapture(c.pointerId)}catch{}R()}};return d("div",{className:`${n.container} ${l&&n.scrubbing?n.scrubbing:""}`,ref:p,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.round(t||0),"aria-valuenow":Math.round(i.current?.currentTime||0),"aria-disabled":!t,tabIndex:0,onClick:c=>{if(u.current){u.current=!1;return}!i.current||isNaN(t)||t===0||s(D(c.clientX))},onPointerDown:ne,onPointerMove:G,onPointerUp:Z,onPointerCancel:Z,onMouseMove:c=>{if(l||!t)return;const y=D(c.clientX);I({time:y*t,position:c.clientX-(p.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{l||I({time:0,position:null})},onKeyDown:c=>{if(!(!i.current||!t)&&((c.key==="Home"||c.key==="End")&&(c.preventDefault(),s(c.key==="Home"?0:1)),c.key==="ArrowRight"||c.key==="ArrowLeft")){c.preventDefault();const y=(c.key==="ArrowRight"?5:-5)/t,M=i.current.currentTime/t||0;s(Math.min(1,Math.max(0,M+y)))}},children:[A.position!==null&&d("div",{className:n.timeBubble,style:{left:A.position},children:r(A.time)}),d("div",{className:n.bar,children:[d("div",{className:n.buffered,ref:k,style:m==="full"?{width:"100%"}:void 0}),d("div",{className:n.watched,ref:S}),d("div",{className:n.thumb,ref:P,onMouseDown:c=>{c.preventDefault(),i.current&&(f.current||g())}}),w]})]})};function re(){try{if(typeof window>"u")return!1;const n=window.matchMedia?.("(pointer: coarse)").matches??!1,t=(navigator.maxTouchPoints??0)>0||"ontouchstart"in window;return n||t}catch{return!1}}function Ae(){const[n,i]=ue(re);return X(()=>{i(re());let t=null;const r=()=>i(re());try{t=window.matchMedia("(pointer: coarse)"),t.addEventListener?t.addEventListener("change",r):t.addListener(r)}catch{}return window.addEventListener("touchstart",r,{passive:!0,once:!0}),()=>{try{t&&(t.removeEventListener?t.removeEventListener("change",r):t.removeListener(r))}catch{}window.removeEventListener("touchstart",r)}},[]),n}const $e=450,De=({muted:n,volume:i,volumeIcon:t,buttonClassName:r,sliderClassName:l,onToggleMute:m,onVolumeChange:s,onExpandedChange:g})=>{const v=Ae(),[R,E]=ue(!1),w=C(null),p=C(!1),S=C(null),P=de(b=>{E(b),g?.(b)},[g]);X(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),X(()=>{if(!R)return;const b=A=>{S.current&&!S.current.contains(A.target)&&P(!1)};return document.addEventListener("pointerdown",b),()=>document.removeEventListener("pointerdown",b)},[R,P]);const k=n?0:i,h=()=>{p.current=!1,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{p.current=!0,P(!0)},$e)},u=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},f=b=>{if(b.stopPropagation(),p.current){p.current=!1;return}if(v){R?m():P(!0);return}m()};return d("div",{ref:S,className:se.volumeWrap,"data-expanded":R?"true":"false",onContextMenu:b=>b.preventDefault(),children:[d("button",{type:"button",className:r,onClick:f,onPointerDown:h,onPointerUp:u,onPointerLeave:u,onContextMenu:b=>b.preventDefault(),"aria-label":n?"Unmute":"Mute","aria-expanded":R,children:t}),d("input",{type:"range",min:"0",max:"1",step:"0.05",value:k,onChange:b=>s(parseFloat(b.currentTarget.value)),onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),onContextMenu:b=>b.preventDefault(),className:`${se.volumeSlider} ${l??""}`,style:{"--volume-percent":`${k*100}%`},"aria-label":"Volume"})]})};let ee=null,ie=null;async function Ie(){return ee||(ie||(ie=Pe(()=>import("./hls-BOLXTnjL.js"),[]).then(n=>(ee=n.default,ee)).catch(()=>null)),ie)}function Ne(n){return n.canPlayType("application/vnd.apple.mpegurl")!==""||n.canPlayType("application/x-mpegURL")!==""}function ae(){return document}function le(n){const i=ae();if(document.fullscreenElement)return document.fullscreenElement;if(i.webkitFullscreenElement)return i.webkitFullscreenElement;const t=n;return t?.webkitDisplayingFullscreen?t:null}function ge(n){return le(n)!==null}async function Ve(n,i){if(le(i))return;const t=n;try{if(typeof n.requestFullscreen=="function"){await n.requestFullscreen();return}if(typeof t.webkitRequestFullscreen=="function"){await t.webkitRequestFullscreen();return}if(typeof t.webkitRequestFullScreen=="function"){await t.webkitRequestFullScreen();return}}catch{}const r=i;if(r&&typeof r.webkitEnterFullscreen=="function"){if(r.webkitSupportsFullscreen===!1)return;try{await r.webkitEnterFullscreen()}catch{}}}async function qe(n){const i=ae();try{if(document.fullscreenElement&&typeof document.exitFullscreen=="function"){await document.exitFullscreen();return}if(i.webkitFullscreenElement&&typeof i.webkitExitFullscreen=="function"){await i.webkitExitFullscreen();return}}catch{}const t=n;if(t?.webkitDisplayingFullscreen&&typeof t.webkitExitFullscreen=="function"){try{t.webkitExitFullscreen()}catch{}return}try{typeof i.webkitCancelFullScreen=="function"?i.webkitCancelFullScreen():!document.fullscreenElement&&typeof document.exitFullscreen=="function"&&(document.fullscreenElement??i.webkitFullscreenElement)&&await document.exitFullscreen()}catch{}}async function Ue(n,i){!n&&!i||(ge(i)?await qe(i):n&&await Ve(n,i))}function He(n,i){const t=()=>{try{i(ge(n()))}catch{}},r=ae(),l=t;r.addEventListener("fullscreenchange",t),r.addEventListener("webkitfullscreenchange",l),r.addEventListener("webkitbeginfullscreen",l,!0),r.addEventListener("webkitendfullscreen",l,!0);const m=n();return m?.addEventListener("webkitbeginfullscreen",l),m?.addEventListener("webkitendfullscreen",l),()=>{r.removeEventListener("fullscreenchange",t),r.removeEventListener("webkitfullscreenchange",l),r.removeEventListener("webkitbeginfullscreen",l,!0),r.removeEventListener("webkitendfullscreen",l,!0),m?.removeEventListener("webkitbeginfullscreen",l),m?.removeEventListener("webkitendfullscreen",l)}}let K=null;function fe(n){try{return n?pe.getItem(n):null}catch{return null}}function Y(n,i){try{n&&pe.setItem(n,String(i))}catch{}}function Ke(n={}){const i=Number.parseFloat(fe(n.volumeKey)??"");let t={isPlaying:!1,isBuffering:!1,isMuted:fe(n.mutedKey)==="true",volume:Number.isFinite(i)?Math.max(0,Math.min(1,i)):1,duration:0,playbackRate:1,isScrubbing:!1,isFullscreen:!1,showControls:!0,isSpeedBoostActive:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1,error:null,playBlocked:!1,playbackLocked:!1},r={currentTime:0,bufferedEnd:0};const l=new Set,m=new Set,s={current:null},g={current:null};let v=null,R=()=>{},E=()=>{},w=0,p=!1,S=1,P=!1,k=null,h=!1;function u(e){Object.entries(e).every(([a,o])=>Object.is(t[a],o))||(t={...t,...e},l.forEach(a=>a()))}function f(e){r.currentTime===e.currentTime&&r.bufferedEnd===e.bufferedEnd||(r=e,m.forEach(a=>a()))}function b(e){if(!e)return;let a=0;for(let o=0;o<e.buffered.length;o++)if(e.buffered.start(o)<=e.currentTime&&e.buffered.end(o)>=e.currentTime){a=e.buffered.end(o);break}f({currentTime:Number.isFinite(e.currentTime)?e.currentTime:0,bufferedEnd:a})}function A(){b(s.current)}function I(){const e=s.current;if(v===e||(v&&(K===v&&(K=e),b(v),E(),v.pause(),v.removeAttribute("src"),v.load()),R(),v=e,!e))return;P=!1,K||(K=e),e.volume=t.volume,e.muted=t.isMuted,e.playbackRate=t.playbackRate;const a=()=>{const T=Array.from(e.textTracks);if(!T.length)return;const H=T.findIndex(W=>W.mode==="showing");u({subtitleTracks:T.map((W,z)=>({id:z,label:W.label||W.language||`Track ${z+1}`,language:W.language})),...H>=0?{activeSubtitleTrack:H}:{}})},o={play:()=>{K=e,u({isPlaying:!0,playBlocked:!1,error:null})},playing:()=>u({isPlaying:!0,isBuffering:!1,playBlocked:!1}),pause:()=>u({isPlaying:!1,isBuffering:!1}),ended:()=>{u({isPlaying:!1,isBuffering:!1}),A()},waiting:()=>{!e.paused&&(e.readyState<3||e.seeking)&&u({isBuffering:!0})},canplay:()=>u({isBuffering:!1}),seeking:()=>{e.paused||u({isBuffering:!0}),A()},seeked:()=>{u({isBuffering:!1}),A()},timeupdate:()=>{A(),!e.paused&&!e.seeking&&u({isBuffering:!1})},progress:A,loadedmetadata:()=>{e.playbackRate=t.playbackRate,u({duration:Number.isFinite(e.duration)?e.duration:0}),a()},durationchange:()=>u({duration:Number.isFinite(e.duration)?e.duration:0}),ratechange:()=>{t.isSpeedBoostActive||(S=e.playbackRate),e.defaultPlaybackRate!==e.playbackRate&&(e.defaultPlaybackRate=e.playbackRate),u({playbackRate:e.playbackRate})},volumechange:()=>{u({volume:e.volume,isMuted:e.muted}),Y(n.volumeKey,e.volume),Y(n.mutedKey,e.muted)},error:()=>u({error:e.error?.message||"Unable to play this source.",isPlaying:!1,isBuffering:!1})};Object.entries(o).forEach(([T,H])=>e.addEventListener(T,H)),e.textTracks.addEventListener("addtrack",a),e.textTracks.addEventListener("removetrack",a),e.textTracks.addEventListener("change",a);const L=()=>e.tagName==="VIDEO"?e:null,j=()=>{const T=le(L());u({isFullscreen:T!==null&&(T===e||T===g.current)})},B=typeof document>"u"?()=>{}:He(L,j);typeof document<"u"&&j(),R=()=>{Object.entries(o).forEach(([T,H])=>e.removeEventListener(T,H)),B(),e.textTracks.removeEventListener("addtrack",a),e.textTracks.removeEventListener("removetrack",a),e.textTracks.removeEventListener("change",a)}}async function D(){if(t.playbackLocked&&!h)return!1;const e=s.current;if(!e)return!1;K=e;const a=w;try{return await e.play(),a===w}catch(o){if(a===w){const L=o instanceof Error&&o.name==="NotAllowedError",j=o instanceof Error&&o.name==="AbortError";u({isPlaying:!1,isBuffering:!1,playBlocked:L,...!L&&!j?{error:o instanceof Error?o.message:"Playback failed."}:{}})}return!1}}function Q(){t.playbackLocked&&!h||s.current?.pause()}function ne(){s.current?.paused?D():Q()}function G(e){if(t.playbackLocked&&!h)return;const a=s.current;if(!a||!Number.isFinite(e))return;let o=Math.max(0,e);if(Number.isFinite(a.duration))o=Math.min(a.duration,o);else if(a.seekable.length)for(let L=0;L<a.seekable.length;L++){if(o<=a.seekable.end(L)){o=Math.max(a.seekable.start(L),o);break}L===a.seekable.length-1&&(o=a.seekable.end(L))}a.currentTime=o,A()}function Z(e){G((s.current?.currentTime??r.currentTime)+e)}function c(e){if(!Number.isFinite(e))return;const a=Math.max(0,Math.min(1,e));u({volume:a,isMuted:a===0}),s.current&&(s.current.volume=a,s.current.muted=a===0),Y(n.volumeKey,a),Y(n.mutedKey,a===0)}function y(){const e=!t.isMuted;!e&&t.volume===0&&c(.5),u({isMuted:e}),s.current&&(s.current.muted=e),Y(n.mutedKey,e)}function M(e){if(t.playbackLocked&&!h||!Number.isFinite(e)||e<.25||e>4)return;S=e;const a=t.isSpeedBoostActive?2:e;u({playbackRate:a}),s.current&&(s.current.playbackRate=a)}function $(){t.playbackLocked||t.isScrubbing||(p=!!s.current&&!s.current.paused,u({isScrubbing:!0}),Q())}function _(){t.isScrubbing&&(u({isScrubbing:!1}),p&&D(),p=!1)}function U(e,a={}){E(),I();const o=s.current,L=++w;if(!o)return()=>{};let j=!1,B=null;const T=()=>!j&&w===L&&s.current===o;o.pause(),o.removeAttribute("src"),o.load(),u({duration:0,isPlaying:!1,isBuffering:!0,isScrubbing:!1,error:null,playBlocked:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1}),f({currentTime:0,bufferedEnd:0});const H=()=>{T()&&a.initialTime&&a.initialTime>0&&G(a.initialTime)};o.addEventListener("loadedmetadata",H,{once:!0});const W=()=>{T()&&(a.onReady?.(),a.autoPlay&&T()&&D())},z=F=>{if(!T())return;const N=F instanceof Error?F:new Error(String(F));u({error:N.message,isPlaying:!1,isBuffering:!1}),a.onError?.(N)},J=()=>{j||(j=!0,o.removeEventListener("loadedmetadata",H),o.removeEventListener("error",ce),B?.destroy(),k===B&&(k=null),B=null,w===L&&w++)},ce=()=>{z(new Error(o.error?.message||"Unable to play this source.")),J()};return o.addEventListener("error",ce),E=J,(async()=>{if(e.hls){const F=await Ie();if(!T())return;if(F?.isSupported()){B=new F({enableWorker:!0,startPosition:a.initialTime??-1,...a.hlsConfig}),k=B;const N=B,he=()=>{T()&&u({audioTracks:N.audioTracks.map((x,V)=>({id:V,label:x.name||x.lang||`Track ${V+1}`,language:x.lang})),...o.querySelector("track")?{}:{subtitleTracks:N.subtitleTracks.map((x,V)=>({id:V,label:x.name||x.lang||`Track ${V+1}`,language:x.lang}))},qualities:N.levels.map((x,V)=>({id:V,label:x.height?`${x.height}p`:`${Math.round(x.bitrate/1e3)}k`})),activeAudioTrack:N.audioTrack,...o.querySelector("track")?{}:{activeSubtitleTrack:N.subtitleTrack},activeQuality:N.currentLevel})};for(const x of[F.Events.MANIFEST_PARSED,F.Events.AUDIO_TRACKS_UPDATED,F.Events.AUDIO_TRACK_SWITCHED,F.Events.SUBTITLE_TRACKS_UPDATED,F.Events.SUBTITLE_TRACK_SWITCH,F.Events.LEVEL_SWITCHED])N.on(x,he);if(B.on(F.Events.ERROR,(x,V)=>{V.fatal&&T()&&(z(new Error(`Stream failed (${V.details}). Try another source or reload.`)),J())}),B.once(F.Events.MANIFEST_PARSED,W),a.onHls?.(B,F),!T())return;B.loadSource(e.url),B.attachMedia(o);return}if(!Ne(o))throw new Error("HLS playback is unavailable in this browser.")}T()&&(o.src=e.url,o.load(),W())})().catch(F=>{z(F),J()}),J}return{mediaRef:s,containerRef:g,connect:I,getState:()=>t,getTimeline:()=>r,getHls:()=>k,isActive:()=>K===s.current,subscribe:e=>(l.add(e),()=>{l.delete(e)}),subscribeTimeline:e=>(m.add(e),()=>{m.delete(e)}),play:D,pause:Q,togglePlay:ne,seek:G,seekRelative:Z,setVolume:c,toggleMute:y,setPlaybackRate:M,setPlaybackLocked:e=>u({playbackLocked:e}),applyRemotePlayback:(e,a,o)=>{h=!0;try{e!==void 0&&G(e),Math.abs(t.playbackRate-o)>.001&&M(o),a&&s.current?.paused?D():!a&&!s.current?.paused&&Q()}finally{h=!1}},setAudioTrack:e=>{k&&t.audioTracks.some(a=>a.id===e)&&(k.audioTrack=e,u({activeAudioTrack:e}))},setSubtitleTrack:e=>{if(e!==-1&&!t.subtitleTracks.some(o=>o.id===e))return;const a=s.current;a?.querySelector("track")?Array.from(a.textTracks).forEach((o,L)=>{o.mode=L===e?"showing":"disabled"}):k&&(k.subtitleTrack=e),u({activeSubtitleTrack:e})},setQuality:e=>{k&&(e===-1||t.qualities.some(a=>a.id===e))&&(k.currentLevel=e,u({activeQuality:e}))},setSpeedBoost:e=>{if(t.playbackLocked)return;const a=e?2:S;u({isSpeedBoostActive:e,playbackRate:a}),s.current&&(s.current.playbackRate=a)},setShowControls:e=>u({showControls:e}),startScrubbing:$,endScrubbing:_,loadSource:U,unload:()=>{const e=s.current;b(e),E(),e&&(e.pause(),e.removeAttribute("src"),e.load()),u({isPlaying:!1,isBuffering:!1,duration:0,error:null}),f({currentTime:0,bufferedEnd:0})},toggleFullscreen:()=>{const e=s.current;Ue(g.current,e?.tagName==="VIDEO"?e:null).catch(a=>u({error:a instanceof Error?a.message:"Fullscreen failed."}))},reset:()=>{u({duration:0,isBuffering:!1,error:null}),f({currentTime:0,bufferedEnd:0})},destroy:()=>{if(P)return;P=!0;const e=v??s.current;b(e),R(),v=null,E(),e?.pause(),e?.removeAttribute("src"),e?.load(),K===e&&(K=null)}}}function O(n){return me(n.subscribe,n.getState)}function ke(n){return me(n.subscribeTimeline,n.getTimeline)}function Je(n={}){const i=C(n),t=oe(()=>Ke(i.current),[]);return Te(()=>{t.connect()}),X(()=>()=>t.destroy(),[t]),oe(()=>({engine:t,mediaRef:t.mediaRef}),[t])}function Oe({children:n,...i}){const t=q(),{isPlaying:r,playbackLocked:l}=O(t);return d("button",{type:"button","aria-label":r?"Pause":"Play",...i,disabled:l||i.disabled,onClick:t.togglePlay,children:n??d(te,{name:r?"pause":"play"})})}function Ye({seconds:n,children:i,...t}){const r=q(),{playbackLocked:l}=O(r);return d("button",{type:"button","aria-label":`Seek ${n<0?"back":"forward"} ${Math.abs(n)} seconds`,...t,disabled:l||t.disabled,onClick:()=>r.seekRelative(n),children:i??d(te,{name:n<0?"replay-10":"forward-10"})})}function Ze(n){const i=q(),{isFullscreen:t}=O(i);return d("button",{type:"button","aria-label":t?"Exit Fullscreen":"Fullscreen",...n,onClick:i.toggleFullscreen,children:d(te,{name:t?"compress":"expand"})})}function et({buttonClassName:n,onExpandedChange:i}){const t=q(),{isMuted:r,volume:l}=O(t);return d(De,{muted:r,volume:l,volumeIcon:d(te,{name:r||l===0?"volume-mute":l<.5?"volume-down":"volume-up"}),buttonClassName:n,onToggleMute:t.toggleMute,onVolumeChange:t.setVolume,onExpandedChange:i})}function tt({className:n}){const i=q(),{volume:t,isMuted:r}=O(i);return d("input",{type:"range",min:0,max:1,step:.01,value:r?0:t,onChange:l=>i.setVolume(Number(l.currentTarget.value)),className:n,style:{"--volume-percent":`${(r?0:t)*100}%`},"aria-label":"Volume"})}function nt({classes:n,timeLabelRef:i,children:t}){const r=q(),{duration:l,isScrubbing:m,playbackLocked:s}=O(r);return d("div",{inert:s||void 0,style:{display:"contents"},children:d(Be,{classes:n,videoRef:r.mediaRef,duration:l,formatTime:be,isScrubbing:m,onSeek:g=>r.seek(g*l),onScrubStart:r.startScrubbing,onScrubMove:g=>r.seek(g*l),onScrubEnd:r.endScrubbing,timeLabelRef:i,children:t})})}function rt({className:n}){const i=q(),{currentTime:t,bufferedEnd:r}=ke(i),{duration:l,playbackLocked:m}=O(i),s=l?Math.min(100,t/l*100):0,g=l?Math.min(100,Math.max(s,r/l*100)):0;return d("input",{type:"range",disabled:m,min:0,max:l,step:.1,value:Math.min(t,l),onChange:v=>i.seek(Number(v.currentTarget.value)),onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),i.startScrubbing()},onPointerUp:i.endScrubbing,onPointerCancel:i.endScrubbing,onLostPointerCapture:i.endScrubbing,className:n,style:{"--played-percent":`${s}%`,"--buffered-percent":`${g}%`},"aria-label":"Seek"})}function it({className:n,durationOnly:i=!1}){const t=q(),{currentTime:r}=ke(t),{duration:l}=O(t);return d("span",{className:n,children:be(i?l:r)})}function ut(){const n=q(),{error:i,playBlocked:t,isBuffering:r,playbackLocked:l}=O(n);return i?d("div",{role:"alert",children:i}):t&&l?d("span",{children:"Enable playback from the watch-along panel."}):t?d(Oe,{children:"Tap to play"}):r?d("div",{role:"status","aria-label":"Buffering",children:"Loading…"}):null}const je='input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable]:not([contenteditable="false"]), [data-player-ui="true"], [data-speed-boost-ignore="true"]';function at(n,i,t=!0){const r=C(i);r.current=i,X(()=>{if(!t)return;let l=!1,m=!1,s=!1,g,v,R=!1;const E=()=>{const u=m||s;u!==R&&(R=u,n.setSpeedBoost(u))},w=u=>u instanceof Element&&!!u.closest(je),p=u=>{if(!n.isActive()||!n.mediaRef.current||u.defaultPrevented||u.ctrlKey||u.metaKey||u.altKey||w(u.target))return;if(u.code==="Space"){if(u.preventDefault(),l)return;l=!0,g=setTimeout(()=>{g=void 0,m=!0,E()},180),r.current();return}const f=u.key.toLowerCase();["k","j","l","arrowleft","arrowright","arrowup","arrowdown","m","f"].includes(f)&&(u.preventDefault(),!(u.repeat&&["k","m","f"].includes(f))&&(f==="k"&&n.togglePlay(),(f==="j"||f==="arrowleft")&&n.seekRelative(-10),(f==="l"||f==="arrowright")&&n.seekRelative(10),f==="arrowup"&&n.setVolume(n.getState().volume+.1),f==="arrowdown"&&n.setVolume(n.getState().volume-.1),f==="m"&&n.toggleMute(),f==="f"&&n.toggleFullscreen(),r.current()))},S=u=>{u.code!=="Space"||!l||(u.preventDefault(),l=!1,clearTimeout(g),g=void 0,m?(m=!1,E()):n.togglePlay(),r.current())},P=u=>{const f=u.target;u.button!==0||!(f instanceof Element)||w(f)||!n.containerRef.current?.contains(f)||(clearTimeout(v),v=setTimeout(()=>{v=void 0,s=!0,E()},180))},k=()=>{clearTimeout(v),v=void 0,s=!1,E()},h=()=>{clearTimeout(g),g=void 0,l=!1,m=!1,k()};return document.addEventListener("keydown",p),document.addEventListener("keyup",S),document.addEventListener("pointerdown",P),document.addEventListener("pointerup",k),document.addEventListener("pointercancel",k),window.addEventListener("blur",h),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",S),document.removeEventListener("pointerdown",P),document.removeEventListener("pointerup",k),document.removeEventListener("pointercancel",k),window.removeEventListener("blur",h),h()}},[n,t])}function lt({engine:n,children:i}){return d(ye.Provider,{value:n,children:i})}export{Ze as F,nt as P,Ye as S,tt as V,Oe as a,et as b,Ge as c,lt as d,q as e,O as f,ke as g,at as h,it as i,rt as j,ut as k,ze as l,Ae as m,ge as n,se as s,Je as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._shell_u5gii_1{position:relative;width:100%;aspect-ratio:16 / 9;background:#000;overflow:clip;isolation:isolate;border-radius:0;container-type:inline-size;touch-action:manipulation;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}@media(max-width:480px)and (orientation:portrait){._shell_u5gii_1{aspect-ratio:1 / 1}}@media(min-width:481px)and (max-width:768px)and (orientation:portrait){._shell_u5gii_1{aspect-ratio:4 / 3}}._shell_u5gii_1:fullscreen,._shell_u5gii_1:-webkit-full-screen{width:100vw;height:100vh;height:100dvh;aspect-ratio:auto;border-radius:0}._shell_u5gii_1:fullscreen,._shell_u5gii_1:fullscreen ._stage_u5gii_38,._shell_u5gii_1:fullscreen ._stage_u5gii_38>video,._shell_u5gii_1:fullscreen ._stage_u5gii_38>canvas,._shell_u5gii_1:fullscreen ._stage_u5gii_38>iframe,._shell_u5gii_1:-webkit-full-screen,._shell_u5gii_1:-webkit-full-screen ._stage_u5gii_38,._shell_u5gii_1:-webkit-full-screen ._stage_u5gii_38>video,._shell_u5gii_1:-webkit-full-screen ._stage_u5gii_38>canvas,._shell_u5gii_1:-webkit-full-screen ._stage_u5gii_38>iframe{border-radius:0!important}@media(max-width:900px)and (orientation:landscape){._shell_u5gii_1{aspect-ratio:auto;height:100vh;height:100dvh;border-radius:0}}._stage_u5gii_38{position:absolute;inset:0;z-index:1;touch-action:manipulation;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}._stage_u5gii_38>video,._stage_u5gii_38>canvas,._stage_u5gii_38>iframe{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain;display:block;background:#000;border:none;border-radius:inherit;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}._shellFill_u5gii_87{position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto}._shellFullscreen_u5gii_95,._shellFullscreen_u5gii_95 ._stage_u5gii_38,._shellFullscreen_u5gii_95 ._stage_u5gii_38>video,._shellFullscreen_u5gii_95 ._stage_u5gii_38>canvas,._shellFullscreen_u5gii_95 ._stage_u5gii_38>iframe{border-radius:0!important}._shellFullscreen_u5gii_95{width:100vw;height:100vh;height:100dvh;aspect-ratio:auto}._uiLayer_u5gii_110{position:absolute;inset:0;z-index:50;pointer-events:none}._uiLayer_u5gii_110>*{pointer-events:auto}._engineStatus_u5gii_121{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);z-index:60;max-width:90%;padding:var(--space-3);background:var(--bg-scrim-strong);color:var(--text-primary);text-align:center}._volumeWrap_u5gii_134{display:flex;align-items:center;position:relative}._volumeSlider_u5gii_140{width:0;opacity:0;transform:scaleX(0);transform-origin:left center;transition:width .25s ease,opacity .25s ease,transform .25s ease;cursor:pointer;margin-left:8px;-webkit-appearance:none;appearance:none;background:transparent;height:24px;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}._volumeWrap_u5gii_134[data-expanded=true] ._volumeSlider_u5gii_140{width:84px;opacity:1;transform:scaleX(1)}@media(hover:hover)and (pointer:fine){._volumeWrap_u5gii_134:hover ._volumeSlider_u5gii_140,._volumeSlider_u5gii_140:focus-visible{width:84px;opacity:1;transform:scaleX(1)}}._volumeSlider_u5gii_140::-webkit-slider-runnable-track{width:100%;height:4px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--volume-percent, 0%),rgba(255,255,255,.2) var(--volume-percent, 0%),rgba(255,255,255,.2) 100%);border-radius:4px}._volumeSlider_u5gii_140::-moz-range-track{width:100%;height:4px;background:#fff3;border-radius:4px}._volumeSlider_u5gii_140::-moz-range-progress{height:4px;background:var(--accent);border-radius:4px}._volumeSlider_u5gii_140::-webkit-slider-thumb{-webkit-appearance:none;height:12px;width:12px;border-radius:50%;background:#fff;margin-top:-4px;box-shadow:0 0 5px #00000080}@media(pointer:coarse){._volumeWrap_u5gii_134[data-expanded=true] ._volumeSlider_u5gii_140{width:96px;height:32px}}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{u as t,d as _,A as V,h as g,S as Ge,g as Jr,q as N,o as es,p as ts,a as ns,T as ye}from"./vendor-core-DfaOB3Rn.js";import{g as On,p as O,t as mt,a6 as rs,a2 as ss,O as Rn,e as os,a9 as as,F as cr,B as sn}from"./index-DYanm9eZ.js";import{P as is,a as ls,b as cs,F as us,c as ds}from"./PlayerProvider-BXBzQc8G.js";import{u as ms}from"./vendor-query-BBT5_sHx.js";import{I as be}from"./vendor-icons-DrybRNxP.js";import{p as Vn,M as bs,z as br,f as Fn,c as hs,C as fs,P as ps,a as vs,b as on,u as gs,i as ys,j as Ss,n as _s,h as Ts,k as Cs,m as ks,l as Es,s as zn,d as Ns,e as Is,g as As,r as xs,o as Le,A as Ls,t as ws,E as Bs,w as Ps,x as Ms,v as le,y as Rs,R as zs,q as $s}from"./useWatchAlongPlayer-3HXJvQR2.js";import{S as Ds,O as $n,a as Os,A as Vs,b as Fs}from"./OptionListMenu-CHJb3qot.js";import{M as qs}from"./MatureConsentModal-LTZSG_Kx.js";import{u as Us}from"./useProviders-D9QoFCnY.js";import{e as Hs,f as Ws,g as Ks,d as Ys,c as js,h as Gs,i as Qs}from"./useTvLibrary-TnVQ2e21.js";import{l as Xs,s as Zs,i as an,h as ur}from"./playbackCompletion-CxGa4g7a.js";import{u as Js}from"./useIsMobile-Dvx1uJ82.js";import{S as eo}from"./SynopsisText-B3Sa5pRv.js";import{W as to}from"./WatchAlongPanel-R7Nd5MXr.js";import"./libraryInvalidation-DlwONLN-.js";const no="_fullscreenFlat_10bzs_1",ro="_timeDisplay_10bzs_12",so="_bottomControls_10bzs_16",oo="_leftControls_10bzs_20",ao="_rightControls_10bzs_21",io="_controlBtn_10bzs_25",lo="_controlsOverlay_10bzs_32",co="_hidden_10bzs_52",uo="_topControls_10bzs_58",mo="_backBtn_10bzs_78",bo="_videoTitleInfo_10bzs_98",ho="_animeTitle_10bzs_104",fo="_episodeLabel_10bzs_112",po="_speedBoostBadge_10bzs_119",vo="_progressBarContainer_10bzs_165",go="_progressBar_10bzs_165",yo="_thumb_10bzs_184",So="_bufferedBar_10bzs_202",_o="_watchedBar_10bzs_212",To="_scrubbing_10bzs_237",Co="_timeBubble_10bzs_241",ko="_bottomControlsRow_10bzs_255",Eo="_nextEpisodeBtn_10bzs_278",No="_active_10bzs_340",Io="_settingsPanel_10bzs_352",Ao="_settingsHeader_10bzs_371",xo="_settingsBackBtn_10bzs_379",Lo="_settingsTitle_10bzs_397",wo="_settingsContent_10bzs_408",Bo="_currentValue_10bzs_417",Po="_menuItem_10bzs_423",Mo="_menuNote_10bzs_456",Ro="_loadingOverlay_10bzs_465",zo="_loadingDots_10bzs_476",$o="_dot_10bzs_481",Do="_bufferingOverlay_10bzs_510",Oo="_bufferingSpinner_10bzs_519",o={fullscreenFlat:no,timeDisplay:ro,bottomControls:so,leftControls:oo,rightControls:ao,controlBtn:io,controlsOverlay:lo,hidden:co,topControls:uo,backBtn:mo,videoTitleInfo:bo,animeTitle:ho,episodeLabel:fo,speedBoostBadge:po,progressBarContainer:vo,progressBar:go,thumb:yo,bufferedBar:So,watchedBar:_o,scrubbing:To,timeBubble:Co,bottomControlsRow:ko,nextEpisodeBtn:Eo,active:No,settingsPanel:Io,settingsHeader:Ao,settingsBackBtn:xo,settingsTitle:Lo,settingsContent:wo,currentValue:Bo,menuItem:Po,menuNote:Mo,loadingOverlay:Ro,loadingDots:zo,dot:$o,bufferingOverlay:Do,bufferingSpinner:Oo},Vo=({player:s,visible:h,settingsOpen:z,onOpenSettings:L,onCloseSettings:M,hasSubtitles:I,isSubtitleActive:T,subtitles:c,onSubtitleChange:i,showNextEpisodeButton:C,onNextEpisode:r,isTheaterMode:w,onTheaterModeToggle:he,timeLabelRef:ee})=>{const{state:u,actions:Ce}=s,we=()=>{if(T){i(-1);return}let fe=null;try{fe=O.getItem("tvLastSubtitle")}catch{}i(Vn(c,{lastKey:fe,enabled:!0}))};return t("div",{className:`${o.controlsOverlay} ${h?"":o.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:o.bottomControls,onClick:fe=>fe.stopPropagation(),children:[t(is,{classes:{container:o.progressBarContainer,scrubbing:o.scrubbing,timeBubble:o.timeBubble,bar:o.progressBar,buffered:o.bufferedBar,watched:o.watchedBar,thumb:o.thumb},timeLabelRef:ee}),t("div",{className:o.bottomControlsRow,children:[t("div",{className:o.leftControls,children:[t(ls,{className:o.controlBtn}),t(cs,{buttonClassName:o.controlBtn,onExpandedChange:Ce.setShowVolumeSlider}),t("span",{className:o.timeDisplay,ref:ee,children:[On(0)," / ",On(u.duration)]})]}),t("div",{className:o.rightControls,children:[C&&t("button",{className:o.nextEpisodeBtn,onClick:r,title:"Play next episode",children:"Next EP"}),I&&t("button",{className:`${o.controlBtn} ${T?o.active:""}`,onClick:we,"aria-label":T?"Turn subtitles off":"Turn subtitles on",children:t(be,{name:"closed-captioning"})}),t("button",{className:`${o.controlBtn} ${z?o.active:""}`,onClick:()=>z?M():L(),"aria-label":"Settings",children:t(be,{name:"cog"})}),t("button",{className:`${o.controlBtn} ${w?o.active:""}`,onClick:fe=>{fe.stopPropagation(),he()},title:w?"Exit Theater Mode":"Theater Mode","aria-label":w?"Exit Theater Mode":"Theater Mode",children:t(be,{name:"tv"})}),t(us,{className:o.controlBtn})]})]})]})})},ln=-6e4,Dn=6e4,dr=500,Fo=({classes:s,delayMs:h,onDelayChange:z})=>{const[L,M]=_(null),I=L??h,T=V(z);T.current=z;const c=V(h);c.current=h;const i=V(null);i.current=L,g(()=>{M(null)},[h]),g(()=>()=>{const w=i.current;w!==null&&w!==c.current&&T.current(w)},[]);const C=w=>{c.current=w,i.current=null,T.current(w),M(null)},r=w=>{const he=i.current??c.current,ee=Math.max(ln,Math.min(Dn,he+w));C(ee)};return t(Ge,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:s.item,onClick:()=>r(-dr),"aria-label":"Show subtitles 0.5 seconds earlier",style:{flex:1,justifyContent:"center"},children:t("span",{children:"-0.5s"})}),t("button",{type:"button",className:s.item,onClick:()=>r(dr),"aria-label":"Show subtitles 0.5 seconds later",style:{flex:1,justifyContent:"center"},children:t("span",{children:"+0.5s"})}),t("button",{type:"button",className:s.item,onClick:()=>C(0),disabled:I===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(bs,{label:"Subtitle timing",display:br(I),min:ln,max:Dn,step:100,value:I,percent:(I-ln)/(Dn-ln)*100,onChange:w=>{const he=Math.round(w);i.current=he,M(he)},onCommit:()=>{const w=i.current;w!==null&&C(w)}}),t("div",{className:s.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},qo=({view:s,onSelectView:h,onClose:z,player:L,onSubtitleStyleChange:M,streams:I,resolutionIdx:T,onResolutionChange:c,hasSubtitles:i,subtitles:C,selectedSubtitle:r,isSubtitleActive:w,onSubtitleChange:he,audioTracks:ee,selectedAudioTrack:u,onAudioTrackChange:Ce,videoDelayEnabled:we,onVideoDelayToggle:fe,videoDelayMs:pe,onVideoDelayChange:k,onCalibrate:bt,subtitleDelayMs:Qe,onSubtitleDelayChange:A,ambientSettings:$,onAmbientChange:ce})=>{const{state:X}=L,Xe=()=>t(Ge,{children:[I.length>1&&t("button",{className:o.menuItem,onClick:()=>h("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:o.currentValue,children:I[T]?.quality||"Auto"})]}),i&&t("button",{className:o.menuItem,onClick:()=>h("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:o.currentValue,children:w?C[r]?.label||C[r]?.language:"Off"})]}),i&&t("button",{className:o.menuItem,onClick:()=>h("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:o.currentValue,children:[X.subtitleFontSize.toFixed(1),"x · ",X.subtitlePosition]})]}),i&&t("button",{className:o.menuItem,onClick:()=>h("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:o.currentValue,children:br(Qe)})]}),ee.length>0&&t("button",{className:o.menuItem,onClick:()=>h("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:o.currentValue,children:ee[u]?.label||ee[u]?.language})]}),t("button",{className:o.menuItem,onClick:()=>h("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:o.currentValue,children:we?`${pe}ms`:"Off"})]}),$&&ce&&t("button",{className:o.menuItem,onClick:()=>h("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:o.currentValue,children:$.enabled?"On":"Off"})]})]}),rt=()=>t($n,{classes:{item:o.menuItem,active:o.active},options:I.map((v,K)=>({key:String(K),label:v.quality,selected:K===T})),onSelect:v=>c(Number(v))}),ie=()=>t($n,{classes:{item:o.menuItem,active:o.active},options:[{key:"off",label:"Off",selected:!w},...C.map((v,K)=>({key:String(K),label:v.label||v.language,selected:K===r}))],onSelect:v=>he(v==="off"?-1:Number(v))}),ht=()=>t(Os,{classes:{item:o.menuItem,active:o.active},values:{fontSize:X.subtitleFontSize,position:X.subtitlePosition,bgOpacity:X.subtitleBgOpacity,bgColor:X.subtitleBgColor,textColor:X.subtitleTextColor,edge:X.subtitleEdge,bold:X.subtitleBold},onChange:M}),Ze=()=>t(Fo,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},delayMs:Qe,onDelayChange:v=>A?.(v)}),W=()=>t($n,{classes:{item:o.menuItem,active:o.active},options:ee.map((v,K)=>({key:String(K),label:v.label||v.language,selected:K===u})),onSelect:v=>Ce(Number(v))}),De=()=>t(Vs,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},enabled:we,delayMs:pe,onToggle:v=>fe?.(v),onDelayChange:v=>k?.(v),onCalibrate:bt}),Oe=()=>$&&ce?t(Fs,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},values:$,onChange:ce}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:v=>v.stopPropagation(),children:t(Ds,{classes:{panel:o.settingsPanel,header:o.settingsHeader,backBtn:o.settingsBackBtn,title:o.settingsTitle,content:o.settingsContent},title:s==="main"?"Settings":s==="subtitle-style"?"Subtitle Style":s==="subtitle-timing"?"Subtitle Timing":s==="audio"?"Audio Track":s==="resolution"?"Resolution":s==="av-sync"?"A/V Sync":s==="ambient"?"Ambient Light":s.charAt(0).toUpperCase()+s.slice(1),onBack:()=>s==="main"?z():h("main"),children:[s==="main"&&Xe(),s==="resolution"&&rt(),s==="subtitles"&&ie(),s==="subtitle-style"&&ht(),s==="subtitle-timing"&&Ze(),s==="audio"&&W(),s==="av-sync"&&De(),s==="ambient"&&Oe()]})})},Uo=({player:s,title:h,episodeLabel:z,audioTracks:L,selectedAudioTrack:M,onAudioTrackChange:I,subtitles:T,selectedSubtitle:c,onSubtitleChange:i,streams:C,resolutionIdx:r,onResolutionChange:w,onBack:he,children:ee,videoDelayEnabled:u=!1,onVideoDelayToggle:Ce,videoDelayMs:we=0,onVideoDelayChange:fe,onCalibrateAvSync:pe,subtitleDelayMs:k=0,onSubtitleDelayChange:bt,showNextEpisodeButton:Qe=!1,onNextEpisode:A,isLoading:$=!1,isTheaterMode:ce,onTheaterModeToggle:X,ambientSettings:Xe,onAmbientChange:rt})=>{const{state:ie,refs:ht,actions:Ze}=s,W=ht.videoRef,{subtitleFontSize:De,subtitlePosition:Oe,subtitleBgOpacity:v,subtitleBgColor:K,subtitleTextColor:Be,subtitleEdge:se,subtitleBold:ft}=ie,[Ve,Se]=_(null),pt=V(null),[_e,vt]=_(0);g(()=>{const Ee=W.current;if(!Ee)return;const y=()=>vt(Ee.clientHeight||0);y();const qe=new ResizeObserver(y);return qe.observe(Ee),()=>qe.disconnect()},[W]);const ue=Ze.setSubtitleStyle;g(()=>{const Ee="tv-player-subtitle-style";let y=document.getElementById(Ee);y||(y=document.createElement("style"),y.id=Ee,document.head.appendChild(y));const qe={fontSize:De,position:Oe,bgOpacity:v,bgColor:K,textColor:Be,edge:se,bold:ft},te=W.current,Ne=Fn(De,_e||te?.clientHeight||720);if(y.textContent=hs({...qe,fontSize:Ne}),te){const St=()=>{const B=Number(Oe);return isNaN(B)?0:Math.max(0,Math.min(100,B))},_t=(B,Z)=>{try{const ne=B;ne.snapToLines=!1,ne.line=Z}catch{}},Tt=()=>{const B=Ne*16,Z=te.videoHeight||te.clientHeight||720,ne=te.videoWidth||te.clientWidth||1280;return{step:B*1.3/Z*100,chars:Math.max(20,Math.floor(ne/(B*.55)))}},Ct=B=>{const Z=Math.max(0,Math.min(100,100-St())),ne=Array.from(B.activeCues??[]);if(ne.length<=1){ne.forEach(j=>_t(j,Z));return}const{step:b,chars:d}=Tt();let de=Z;for(let j=ne.length-1;j>=0;j--){const $t=String(ne[j].text??"").replace(/<[^>]*>/g,"").split(`
|
|
2
|
-
`).reduce((Nt,dn)=>Nt+Math.max(1,Math.ceil(dn.length/d)),0),Et=de-$t*b;_t(ne[j],Math.max(0,Et)),de=Et-b*.4}},et=()=>{const B=Math.max(0,Math.min(100,100-St()));Array.from(te.textTracks).forEach(Z=>{Z.cues&&(Array.from(Z.cues).forEach(ne=>_t(ne,B)),Z.mode==="showing"&&Ct(Z))})};et();const oe=B=>{const Z=B.target;Z.mode==="showing"&&Ct(Z)},zt=()=>{Array.from(te.textTracks).forEach(B=>{B.removeEventListener("cuechange",oe),B.addEventListener("cuechange",oe)}),et()};Array.from(te.textTracks).forEach(B=>{B.addEventListener("cuechange",oe)}),te.textTracks.addEventListener("addtrack",zt);const Me=Array.from(te.querySelectorAll("track")),kt=()=>et();return Me.forEach(B=>B.addEventListener("load",kt)),()=>{Array.from(te.textTracks).forEach(B=>{B.removeEventListener("cuechange",oe)}),te.textTracks.removeEventListener("addtrack",zt),Me.forEach(B=>B.removeEventListener("load",kt))}}},[De,Oe,v,K,Be,se,ft,c,T,W,_e]);const Pe=T.length>0,ke=c>=0,st=()=>{Se("main"),Ze.setShowControls(!0)},Fe=()=>{Se(null)},Rt=ie.showControls||!!Ve,gt=t(vs,{visible:Rt,title:h,episode:z,onBack:he,classes:{overlay:o.controlsOverlay,hidden:o.hidden,top:o.topControls,backBtn:o.backBtn,titleInfo:o.videoTitleInfo,title:o.animeTitle,episode:o.episodeLabel}}),Je=!$&&!ie.isBuffering&&ie.duration>0?t(fs,{}):null,cn=t(Vo,{player:s,visible:Rt,settingsOpen:!!Ve,onOpenSettings:st,onCloseSettings:Fe,hasSubtitles:Pe,isSubtitleActive:ke,subtitles:T,onSubtitleChange:i,showNextEpisodeButton:Qe,onNextEpisode:A,isTheaterMode:ce,onTheaterModeToggle:X,timeLabelRef:pt}),yt=Ve?t(qo,{view:Ve,onSelectView:Se,onClose:Fe,player:s,onSubtitleStyleChange:ue,streams:C,resolutionIdx:r,onResolutionChange:w,hasSubtitles:Pe,subtitles:T,selectedSubtitle:c,isSubtitleActive:ke,onSubtitleChange:i,audioTracks:L,selectedAudioTrack:M,onAudioTrackChange:I,videoDelayEnabled:u,onVideoDelayToggle:Ce,videoDelayMs:we,onVideoDelayChange:fe,onCalibrate:()=>{Se(null),pe?.()},subtitleDelayMs:k,onSubtitleDelayChange:bt,ambientSettings:Xe,onAmbientChange:rt}):null,Y=t(Ge,{children:[$&&t("div",{className:o.loadingOverlay,"aria-hidden":"true",children:t("div",{className:o.loadingDots,children:[t("div",{className:o.dot}),t("div",{className:o.dot}),t("div",{className:o.dot})]})}),ie.isBuffering&&!$&&t("div",{className:o.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:o.bufferingSpinner})}),ie.isSpeedBoostActive&&t("div",{className:o.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(be,{name:"forward",size:12})]})]});return t(ps,{engine:s.engine,topBar:gt,centerControls:Je,bottomBar:!$&&ie.duration>0?cn:null,settingsPanel:yt,overlays:Y,isInteracting:!!Ve||ie.showVolumeSlider,nativeControls:ie.useNativeControls,onStageClick:Fe,className:ie.isFullscreen?o.fullscreenFlat:"",children:ee})},Ho=({servers:s,selectedServer:h,onServerSelect:z})=>s.length===0?null:t("div",{className:on.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:on.sourceButtons,children:s.map(L=>t("button",{className:`${on.sourceButton} ${h===L?on.active:""}`,onClick:()=>z(L),children:L},L))})]}),Wo=Jr.memo(Ho);function Ko({details:s,isMovie:h,season:z,episode:L,videoRef:M,active:I}){const T=V("");T.current||(T.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const c=N(()=>{if(!s)return;const i=M.current,C=h?"":`S${String(z).padStart(2,"0")}E${String(L).padStart(2,"0")}`;mt.discord.tvPresence.mutate({title:s.title,episodeLabel:C,isPlaying:i?!i.paused&&!i.ended:!0,thumbnail:s.poster,currentTime:i?i.currentTime:0,duration:i&&i.duration||0,isAdult:s.adult===!0,sessionId:T.current}).catch(()=>{}),mt.discord.heartbeat.mutate({sessionId:T.current}).catch(()=>{})},[s,h,z,L,M]);return g(()=>{if(!s)return;c();const i=window.setInterval(()=>{const C=M.current;(!C||!C.paused)&&c()},15e3);return()=>window.clearInterval(i)},[c,s,M]),g(()=>{if(!s||!I)return;const i=M.current;if(!i)return;const C=()=>c();return i.addEventListener("play",C),i.addEventListener("pause",C),i.addEventListener("seeked",C),()=>{i.removeEventListener("play",C),i.removeEventListener("pause",C),i.removeEventListener("seeked",C)}},[s,I,c,M]),g(()=>{const i=T.current,C=()=>rs(i),r=()=>C();return window.addEventListener("pagehide",r),window.addEventListener("beforeunload",r),()=>{window.removeEventListener("pagehide",r),window.removeEventListener("beforeunload",r),C()}},[]),{sendPresence:c}}function Yo(s,h,z){const L=()=>{const I=Array.isArray(s.audioTracks)?s.audioTracks.length:0,T=z.getWant(),c=I>0?Math.min(Math.max(0,T),I-1):T;s.audioTrack=c,c!==T&&z.onResolve(c)},M=(I,T)=>{const c=z.getWant(),i=Array.isArray(s.audioTracks)?s.audioTracks.length:0;if(T.id!==c&&c>=0&&c<i){s.audioTrack!==c&&(s.audioTrack=c);return}z.onResolve(T.id)};return s.on(h.MANIFEST_PARSED,L),s.on(h.AUDIO_TRACK_SWITCHED,M),()=>{s.off(h.MANIFEST_PARSED,L),s.off(h.AUDIO_TRACK_SWITCHED,M)}}const jo=/\b(SmartTV|SMART-TV|Tizen|Web0S|webOS|NetCast|HbbTV|AppleTV|CrKey|BRAVIA|AFT[A-Za-z]|Fire\s?TV|GoogleTV|Roku|VIDAA|DTV|PlayStation|Xbox|Opera TV|POV_TV)\b/i;function Go(){try{if(jo.test(navigator.userAgent||""))return!0;const s=navigator.deviceMemory;if(typeof s=="number"&&s>0&&s<2)return!0}catch{}return!1}const Qo="_statusMsg_zqb8u_1",Xo="_error_zqb8u_7",Zo="_spinner_zqb8u_11",Jo="_spin_zqb8u_11",ea="_sourceLoader_zqb8u_16",ta="_ringSpinner_zqb8u_22",na="_meta_zqb8u_40",ra="_year_zqb8u_48",sa="_rating_zqb8u_53",oa="_typeBadge_zqb8u_62",aa="_tv_zqb8u_70",ia="_movie_zqb8u_75",la="_controlLabel_zqb8u_80",ca="_select_zqb8u_90",ua="_playerSection_zqb8u_102",da="_video_zqb8u_106",ma="_videoHidden_zqb8u_128",ba="_delayCanvas_zqb8u_133",ha="_delayCanvasActive_zqb8u_146",fa="_subtitleOverlay_zqb8u_150",pa="_videoIframe_zqb8u_169",va="_retryButton_zqb8u_177",ga="_sidebarSeason_zqb8u_192",ya="_mobileSeasonRow_zqb8u_208",Sa="_providerSelectWrap_zqb8u_222",_a="_genreRow_zqb8u_230",Ta="_genreChip_zqb8u_237",Ca="_metaRow_zqb8u_247",ka="_detailGrid_zqb8u_256",Ea="_detailItem_zqb8u_264",Na="_imdbLink_zqb8u_286",p={statusMsg:Qo,error:Xo,spinner:Zo,spin:Jo,sourceLoader:ea,ringSpinner:ta,meta:na,year:ra,rating:sa,typeBadge:oa,tv:aa,movie:ia,controlLabel:la,select:ca,playerSection:ua,video:da,videoHidden:ma,delayCanvas:ba,delayCanvasActive:ha,subtitleOverlay:fa,videoIframe:pa,retryButton:va,sidebarSeason:ga,mobileSeasonRow:ya,providerSelectWrap:Sa,genreRow:_a,genreChip:Ta,metaRow:Ca,detailGrid:ka,detailItem:Ea,imdbLink:Na},Ia=[],Aa=[];function mr({error:s,onRetry:h}){return t("div",{className:`${p.statusMsg} ${p.error}`,style:{flexDirection:"column",alignItems:"stretch",gap:8},children:t("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t("span",{style:{flex:1},children:s}),t("button",{className:p.retryButton,onClick:h,children:"Retry"})]})})}const Ha=()=>{const{id:s}=es(),[h]=ts(),z=V(h);z.current=h;const L=ns(),M=ms(),I=h.get("type"),T=ss(),c=!!T.session,i=c&&!T.session?.host,C=i&&["tv","movie"].includes(T.room?.selection.kind||"")?T.room?.selection:null,[r,w]=_(null),[he,ee]=_(()=>parseInt(h.get("s")||"1",10)||1),u=C?.season??he,[Ce,we]=_([]),[fe,pe]=_(()=>parseInt(h.get("e")||"1",10)||1),k=C?Number(C.episode):fe,[bt,Qe]=_(()=>{try{return O.getItem("tvProvider")||""}catch{return""}}),A=C?.provider??bt,[$,ce]=_([]),[X,Xe]=_(""),{options:rt,isFallback:ie,isLoading:ht}=Us(),Ze=ye(()=>rt.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.id,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[rt]),W=ie||Ze.length===0?Ia:Ze,De=W.filter(e=>e.tier==="direct"),Oe=W.filter(e=>e.tier==="embed"),[v,K]=_(!1),[Be,se]=_(""),[ft,Ve]=_([]),[Se,pt]=_(0),[_e,vt]=_([]),[ue,Pe]=_(-1),[ke,st]=_(0),[Fe,Rt]=_(""),[gt,Je]=_(""),[cn,yt]=_(()=>{try{return O.getItem("tvServer")||""}catch{return""}}),Y=C?.source??cn,Ee=ye(()=>W.find(e=>e.id===A),[W,A]),y=Ee?.tier==="embed",[qe,te]=_([]),[Ne,St]=_(""),[_t,Tt]=_(""),[Ct,et]=_(!1),oe=ye(()=>qe.length>0?qe:Ee?.servers??[],[qe,Ee]),zt=ye(()=>Ne&&!c?["Embed",...oe]:oe,[oe,Ne,c]),Me=Ct&&!!Ne,kt=Me?_t||Ne:"";g(()=>{if(!Ne){Tt("");return}let e=!1;return Rn(`/api/resolve?url=${encodeURIComponent(Ne)}`).then(n=>{!e&&n.finalUrl&&Tt(n.finalUrl)}).catch(()=>{}),()=>{e=!0}},[Ne]);const B=V([]);g(()=>{B.current=$},[$]);const Z=V(Se);g(()=>{Z.current=Se},[Se]);const ne=V(ue);g(()=>{ne.current=ue},[ue]);const b=gs({skipIntervals:Aa}),d=b.refs.videoRef,de=V(null),j=V([]),un=V(null),$t=V(null),{videoDelayMs:Et,videoDelayEnabled:Nt,setDelayEnabled:dn,handleVideoDelayChange:qn,isCalibrating:hr,testClipActive:Ie,stopCalibration:mn,openAvSyncCalibrator:fr,cancelAvSyncCalibrator:pr,applyAvSyncCalibrator:vr,toggleTestClip:gr,calibReturnRef:Dt,effectiveVideoDelayMs:bn}=ys(d),[ot,yr]=_(()=>{try{const e=Number(O.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),hn=V(ot);hn.current=ot;const Sr=N(e=>{const n=Math.max(-6e4,Math.min(6e4,Math.round(e)));if(hn.current!==n){hn.current=n,yr(n);try{O.setItem("tvSubtitleDelayMs",String(n))}catch{}}},[]);Ss({videoRef:d,canvasRef:un,delayMs:bn,enabled:Nt});const fn=Nt,ve=fn||ot!==0,{settings:pn,update:_r}=_s(),vn=V(ve);vn.current=ve;const gn=N(()=>{if(!vn.current)return;const e=d.current;e&&Array.from(e.textTracks).forEach(n=>{n.mode!=="hidden"&&(n.mode="hidden")})},[d]),{hasConsent:It,grant:Tr}=os(),f=I==="movie";Ko({details:r,isMovie:f,season:u,episode:k,videoRef:d,active:!y&&!v&&!Be&&$.length>0});const Ot=s?as(I||"tv",s):"",re=Ot,Re=`${re}:${u}:${k}:${A}:${Y}`,Vt=ye(()=>!s||!r||y||Me||v||X!==Re||$[ke]?.type!=="hls"?null:{kind:f?"movie":"tv",...f?{}:{season:u},showId:s,episode:String(f?1:k),provider:A,source:Y,mode:"sub",title:r.title},[s,r,y,Me,v,X,Re,$,ke,f,u,k,A,Y]),Un=Ts(b.engine,Vt,v||!r),Hn=Hs(),Ft=Ws(),qt=Ks(),{toggle:Wn,bookmarkedIds:Cr,pending:kr}=Ys(),{data:Kn}=js(r?Ot:void 0),At=Kn?!!Kn.inLibrary:Ot?Cr.has(Ot):!1,Er=N(()=>{!r||!s||Wn({tmdbId:Number(s),mediaType:I||"tv",title:r.title,poster:r.poster,year:r.year,adult:r.adult})},[r,s,I,Wn]),{data:at,isFetched:Yn,isFetching:yn}=Gs(re||void 0,u,k),Ut=ye(()=>Ce.map(e=>e.episode_number).sort((e,n)=>e-n),[Ce]),xt=Ut.indexOf(k),Sn=xt>0?Ut[xt-1]:null,F=xt>=0&&xt<Ut.length-1?Ut[xt+1]:null,Ht=ye(()=>(r?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,n)=>e-n),[r]),Ue=ye(()=>{if(f||F!=null)return null;const e=Ht.indexOf(u);return e>=0&&e<Ht.length-1?Ht[e+1]:(r?.number_of_seasons??0)>u?u+1:null},[f,F,Ht,u,r?.number_of_seasons]),jn=at?.currentTime??0,Wt=V(null),[He,Kt]=_(!1),[it,Gn]=_(0),[Lt,Qn]=_(!1),[lt,ct]=_(!1),[Nr,_n]=_(!1),[Ir,Ar]=_(""),[Yt,xr]=_(!1),[Lr,Tn]=_(!1),{isTheaterMode:ze,toggleTheaterMode:Cn,handleLayoutClick:wr}=Cs();g(()=>{const e=n=>{n.defaultPrevented||n.ctrlKey||n.metaKey||n.altKey||n.repeat||n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="t"&&Cn()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Cn]),ks(b,($.length>0||gt!=="")&&!ze&&!He&&!lt);const Br=Js(),[ut,Pr]=_(Xs),Mr=N(e=>{Pr(e),Zs(e)},[]),We=V(!1),$e=V(null),kn=V(0),J=V(null),jt=V(""),Rr=ur(jn),wt=!c&&!We.current&&(He||lt||Rr),Gt=V(wt);Gt.current=wt;const Qt=V(!1);g(()=>{Qt.current=Lt},[Lt]);const Ke=N((e,n)=>{if(!re||!n||n<30)return;const a=an(e,n);Math.abs(e-kn.current)<10&&!a||(kn.current=e,Hn.mutate({mediaId:re,season:u,episode:k,currentTime:Math.floor(e),duration:Math.floor(n),completed:a,title:r?.title??null,poster:r?.poster??null,backdrop:r?.backdrop??null,year:r?.year??null,overview:r?.overview??null,tmdbId:r?.id??null,mediaType:I||"tv",adult:r?.adult?1:0}))},[re,u,k,Hn,r,I]),Ae=N((e,n)=>{mn();const a=new URLSearchParams(h);a.set("type",h.get("type")||"tv"),a.set("s",String(e)),a.set("e",String(n)),L(`${window.location.pathname}?${a.toString()}`)},[h,L,mn]),Bt=N(()=>{const e=d.current;if(!e||f||F==null){_n(!1);return}const n=e.duration||0,a=e.currentTime||0;_n(n>0&&a/n>=.8)},[f,F,d]),Xt=N((e,n)=>["tv-sources",A,f?"movie":"tv",s,e,n,Y],[A,f,s,Y]),Zt=N(async(e,n)=>{if(!r||!s||!A)return{valid:!1,sources:[]};const a=f?"movie":"tv",l=await mt.tv.sources.query({provider:A,type:a,tmdbId:String(s),season:e,episode:n,title:r.title||"",year:r.year||"",totalSeasons:String(r.number_of_seasons||1),imdbId:r.imdb_id||"",...Y?{server:Y}:{}});return{valid:"valid"in l?l.valid:!1,error:"error"in l?l.error:void 0,sources:l.sources,referer:"referer"in l?l.referer:void 0,audioTracks:l.audioTracks,subtitles:"subtitles"in l?l.subtitles:void 0,servers:"servers"in l?l.servers:void 0,server:"server"in l?l.server:void 0,embedUrl:"embedUrl"in l?l.embedUrl:void 0}},[r,s,A,f,Y]),Xn=N(()=>{if(f||!r||!s||!A||y||F==null)return;const e=Xt(u,F);M.getQueryState(e)?.status!=="success"&&M.prefetchQuery({queryKey:e,queryFn:()=>Zt(u,F),staleTime:300*1e3,gcTime:1800*1e3})},[f,r,s,A,y,F,u,M,Xt,Zt]),zr=N(()=>{if(Ie)return;Bt();const e=d.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&Xn(),!$e.current&&($e.current=setTimeout(()=>{$e.current=null,Ke(e.currentTime,e.duration||0)},5e3)))},[Ke,d,Ie,Bt,Xn]),$r=N(()=>{const e=d.current;if(!(!e||!r)&&($e.current&&clearTimeout($e.current),$e.current=null,Ke(e.currentTime,e.duration||0),!i)){if(F!=null){ut&&(pe(F),Ae(u,F));return}Ar(f?r.title:`${r.title} - Season ${u}`),ct(!0),We.current=!0}},[f,r,u,F,ut,Ke,Ae,d,i]),{checkEnd:Jt,logDuration:Zn}=Es({videoRef:d,sourceType:y?"iframe":void 0,resetKey:`${re}:${u}:${k}`,onEnd:$r}),Dr=N(()=>{b.actions.onPlay()},[b.actions]),Or=N(()=>{b.actions.onPause();const e=d.current;e&&!e.ended&&Ke(e.currentTime,e.duration||0)},[b.actions,Ke,d]),Vr=N(()=>{const e=d.current;if(e){try{const n=parseFloat(O.getItem("playerVolume")||"");isNaN(n)||(e.volume=Math.max(0,Math.min(1,n))),e.muted=O.getItem("playerMuted")==="true"}catch{}if(J.current!=null&&J.current>0){try{e.currentTime=J.current}catch{}J.current=null}Bt()}},[d,Bt]),En=N(()=>{const e=d.current;if(e&&J.current!=null&&J.current>0){try{e.currentTime=J.current}catch{}J.current=null}},[d]),Fr=N(()=>{it>0&&(J.current=it);const e=d.current;if(e&&it>0){try{e.currentTime=it,J.current=null}catch{}e.play().catch(()=>{})}Kt(!1),We.current=!0},[it,d]),Jn=N(()=>{J.current=null;const e=d.current;e&&(e.currentTime=0,e.play().catch(()=>{})),Kt(!1),We.current=!0},[d]),qr=N(()=>{F!=null&&(We.current=!0,pe(F),Ae(u,F))},[F,u,Ae]),Ur=N(()=>{Ue!=null&&(ct(!1),We.current=!0,ee(Ue),pe(1),Ae(Ue,1))},[Ue,Ae]),Hr=N(async()=>{if(re)try{At?await Ft.mutateAsync({id:re,status:"Completed"}):r&&s&&(await qt.mutateAsync({tmdbId:Number(s),mediaType:I||"tv",title:r.title,poster:r.poster,backdrop:r.backdrop,year:r.year,overview:r.overview,adult:r.adult,status:"Completed",silent:!0}),cr.success("Moved to Completed")),ct(!1),L("/")}catch{}},[re,At,Ft,qt,r,s,I,L]);g(()=>{We.current=!1,Wt.current=null,Kt(!1),_n(!1),Gn(0),Qn(!1),Qt.current=!1,J.current=null,kn.current=0},[re,u,k]),g(()=>{jt.current=Re},[Re]),g(()=>{Yn&&(Qn(!0),Qt.current=!0)},[Yn,re,u,k]),g(()=>{if(c||yn||!at||We.current)return;const e=`${re}:${u}:${k}`;if(Wt.current===e)return;Wt.current=e;const n=at,a=n.currentTime??0;ur(a)&&n.completed!==1&&!an(a,n.duration??0)&&(Gn(a),Kt(!0))},[at,yn,re,u,k,c]),g(()=>{!c&&He&&d.current&&d.current.pause()},[He,d,c]),g(()=>{const e=d.current;return()=>{$e.current&&clearTimeout($e.current),$e.current=null,!e?.ended&&b.engine.getState().duration>0&&Ke(b.engine.getTimeline().currentTime,b.engine.getState().duration)}},[b.engine,Ke,d]);const Nn=N(e=>{let n=null,a=!0;try{n=O.getItem("tvLastSubtitle"),a=O.getItem("tvSubtitlesEnabled")!=="false"}catch{}return Vn(e,{lastKey:n,enabled:a})},[]),In=N(e=>{if(!(e<0))try{O.setItem("tvSubtitlesEnabled","true"),O.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),er=N(e=>{if(e.length===0)return 0;let n=null;try{n=O.getItem("tvLastAudio")}catch{}if(n){const a=e.findIndex(U=>zn(U)===n);if(a>=0)return a;const l=n.indexOf("|||"),m=l>=0?n.slice(0,l):n,x=l>=0?n.slice(l+3):n,q=e.findIndex(U=>U.language===m||U.label===x);if(q>=0)return q}return Vn(e,{lastKey:null,enabled:!0})},[]),{data:tr}=Qs(re||void 0),nr=ye(()=>(tr?.progress??[]).filter(n=>n.season===u&&(n.completed===1||an(n.currentTime,n.duration))).map(n=>String(n.episode)),[tr,u]),rr=ye(()=>Ce.map(e=>({id:String(e.episode_number),label:`Episode ${e.episode_number}`,sublabel:e.name||void 0,thumbnail:e.still_path?`https://image.tmdb.org/t/p/w185${e.still_path}`:void 0})),[Ce]),sr=ye(()=>(r?.genres??[]).map(e=>e.name).slice(0,5),[r]),An=ye(()=>[r?.year,r?.status,r?.number_of_seasons?`${r.number_of_seasons} Season${r.number_of_seasons>1?"s":""}`:null,r?.number_of_episodes?`${r.number_of_episodes} Episodes`:null].filter(Boolean),[r]);g(()=>{if(!i&&W.length!==0&&!W.some(e=>e.id===A)){const e=W.find(n=>n.tier==="direct")?.id??W[0].id;Qe(e);try{O.setItem("tvProvider",e)}catch{}}},[W,A,i]),g(()=>{te([]),St(""),Tt(""),et(!1)},[A]),g(()=>{if(!i&&oe.length!==0&&!oe.includes(Y)){yt(oe[0]);try{O.setItem("tvServer",oe[0])}catch{}}},[oe,Y,i]),g(()=>{if(!s){w(null),ce([]),Xe(""),se(""),Je("");return}const e=Number(s),n=I||"tv";w(null),ce([]),Xe(""),se(""),Je("");const a=parseInt(z.current.get("s")||"",10),l=parseInt(z.current.get("e")||"",10);ee(isNaN(a)?1:a),pe(isNaN(l)?1:l),st(0),mt.tv.details.query({type:n,id:String(e)}).then(m=>{const x={id:m.id,title:m.title||"",overview:m.overview||"",vote_average:m.vote_average,year:m.year,poster:m.poster,backdrop:m.backdrop,imdb_id:m.imdb_id||void 0,adult:m.adult,seasons:m.seasons,number_of_seasons:m.number_of_seasons};w(x),x.seasons&&x.seasons.length>0&&isNaN(a)&&ee(x.seasons[0].season_number)}).catch(()=>{})},[s,I]),g(()=>{if(!r||!s)return;if(!(r.seasons!==void 0||r.number_of_seasons!==void 0)){we([]);return}const n=parseInt(h.get("e")||"",10);mt.tv.episodes.query({id:String(s),season:String(u)}).then(a=>{const l=(a.episodes||[]).map(m=>({episode_number:m.episode_number,name:m.name||"",vote_average:m.vote_average,overview:m.overview||"",still_path:m.still_path||""}));we(l),l.length!==0&&pe(m=>!isNaN(n)&&l.some(x=>x.episode_number===n)?n:l.some(x=>x.episode_number===m)?m:l[0].episode_number)}).catch(()=>{})},[r,s,u,h]),g(()=>{if(!y||!r||!s)return;Rn(`/api/tv/embed/${A}/${f?"movie":"tv"}/${s}?season=${u}&episode=${k}`).then(n=>{if(n.url)return Je(n.url),Rn(`/api/resolve?url=${encodeURIComponent(n.url)}`).then(a=>{a.finalUrl&&Je(a.finalUrl)})}).catch(()=>{})},[A,r,s,u,k,f,y]);const en=N(async()=>{if(!r||!s||!A||y||r.adult&&!It)return;const e=Re;K(!0),se(""),B.current.length===0&&(ce([]),st(0),Ve([]),vt([]));try{const n=await M.fetchQuery({queryKey:Xt(u,k),queryFn:()=>Zt(u,k),staleTime:3e5,gcTime:18e5});if(jt.current!==e)return;if(K(!1),!n.valid||!n.sources?.length){se(n.error?`${n.error}`:oe.length>0?`No streams from ${Y}. Try another server.`:"No streams available.");return}if(c&&Y&&n.server&&n.server!==Y){ce([]),se("The host's selected server is unavailable. Automatic source switching is disabled in watch-along rooms.");return}!i&&!Y&&n.server&&yt(n.server);const a=c?n.sources.filter(U=>U.type==="hls"):n.sources;if(c&&a.length===0){ce([]),se("The room requires a direct HLS source. No compatible stream is available here.");return}ce(a),Xe(e),n.servers?.length&&te(n.servers),n.embedUrl&&St(n.embedUrl),st(0),n.referer&&Rt(n.referer);const l=n.audioTracks||[];Ve(l),pt(l.length>0?er(l):0);const m=n.subtitles||[];if(vt(m),m.length>0){const U=Nn(m);Pe(U),In(U)}else Pe(-1);const x=f?"movie":"tv",q=s;mt.tv.subtitles.query({type:x,tmdbId:String(q),season:String(u),episode:String(k)}).then(U=>{if(jt.current!==e)return;const ge=Array.isArray(U.subtitles)?U.subtitles:[];ge.length!==0&&vt(S=>{const G=[...S,...ge.filter(Q=>!S.some(D=>D.url===Q.url))];if(S.length===0){const Q=Nn(G);Pe(Q),In(Q)}return G})}).catch(()=>{}),se("")}catch(n){if(jt.current!==e)return;K(!1),se(n instanceof Error?n.message:"Failed to load streams.")}},[r,s,A,u,k,f,y,It,oe,Y,Nn,In,er,M,Xt,Zt,Re,c,i]),xn=N(()=>{const e=d.current;e&&!isNaN(e.currentTime)&&(J.current=e.currentTime)},[d]),Wr=N(e=>{if(!(i||c&&e==="Embed")){if(e==="Embed"){et(!0);return}xn(),et(!1),yt(e);try{O.setItem("tvServer",e)}catch{}se("")}},[xn,i,c]),Kr=N(e=>{Qe(e);try{O.setItem("tvProvider",e)}catch{}},[]);g(()=>{A&&r&&!y&&en()},[A,r,en,y]),g(()=>{if(!d.current)return;if(de.current=null,y||Me||c&&$[ke]?.type!=="hls"){b.engine.unload();return}if(Ie&&!c)return b.engine.loadSource({url:"/av-sync-test.mp4"},{autoPlay:!Gt.current});if(Dt.current!=null&&(J.current=Dt.current,Dt.current=null),X===Re&&J.current==null&&!Gt.current)try{const S=d.current;S&&!S.ended&&S.currentTime>1&&(J.current=S.currentTime)}catch{}const n=J.current??0,a=!v&&X===Re?Me?"":$[ke]?.url||"":"";if(!a){try{d.current?.pause(),d.current?.removeAttribute("src"),d.current?.load()}catch{}return}const l=d.current;l.pause(),l.removeAttribute("src"),l.load(),b.actions.resetMediaState();const m=`/api/tv/stream-proxy?url=${encodeURIComponent(a)}&referer=${encodeURIComponent(Fe)}&provider=${encodeURIComponent(A)}`,x=Go()||document.body.classList.contains("low-end"),q=x?60:180,U=b.engine.loadSource({url:m,hls:$[ke]?.type==="hls"},{hlsConfig:{enableWorker:!0,lowLatencyMode:!1,startPosition:n>0?n:-1,maxBufferLength:q,maxMaxBufferLength:q+(x?30:60),backBufferLength:x?30:60,maxBufferSize:(x?120:360)*1e3*1e3,fragLoadPolicy:{default:{maxTimeToFirstByteMs:15e3,maxLoadTimeMs:45e3,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:3,retryDelayMs:800,maxRetryDelayMs:6e3}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:25e3,timeoutRetry:{maxNumRetry:1,retryDelayMs:500,maxRetryDelayMs:2e3},errorRetry:{maxNumRetry:2,retryDelayMs:800,maxRetryDelayMs:4e3}}}},onHls:(S,G)=>{de.current=S;const Q=()=>{let R=!1,P=0;try{R=O.getItem("tvSubtitlesEnabled")==="true";const E=parseInt(O.getItem("tvSelectedSubtitle")||"0",10);!isNaN(E)&&E>=0&&(P=E)}catch{}return{enabled:R,index:P}},D=()=>{if(typeof S.subtitleTrack!="number")return;if(j.current.length>0){S.subtitleTrack=-1;return}const R=Array.isArray(S.subtitleTracks)?S.subtitleTracks:[];if(R.length===0){S.subtitleTrack=-1;return}const P=Q();if(P.enabled){const E=P.index<R.length?P.index:0;S.subtitleTrack=E,Pe(E),gn()}else S.subtitleTrack=-1};Yo(S,G.Events,{getWant:()=>Z.current,onResolve:R=>pt(R)}),S.on(G.Events.MANIFEST_PARSED,D),S.on(G.Events.SUBTITLE_TRACKS_UPDATED,()=>{D()}),S.on(G.Events.SUBTITLE_TRACK_SWITCH,(R,P)=>{if(j.current.length>0){if(P.id!==-1)try{S.subtitleTrack=-1}catch{}return}const E=Array.isArray(S.subtitleTracks)?S.subtitleTracks:[];if(E.length!==0){if(P.id===-1){const Te=Q();if(Te.enabled){const ae=Te.index<E.length?Te.index:0;S.subtitleTrack=ae;return}}Pe(P.id),gn()}})},onReady:()=>{(n>0||!Gt.current&&Qt.current)&&b.engine.play()},onError:S=>{se(S.message),K(!1),de.current=null}}),ge=()=>{const Q=l.error?.code===4?"Video source not supported or not found":"Failed to load video stream";se(`${Q}. The source may be invalid or expired. Try switching source or reloading.`),K(!1)};return l.addEventListener("error",ge),()=>{U(),de.current=null,l.removeEventListener("error",ge)}},[$,X,v,ke,A,Fe,y,Me,d,Dt,Ie,re,u,k,En,gn,b.actions,b.engine,Re,c]),g(()=>{if(i||!Lt||He||lt||wt||y||Ie)return;const e=d.current;!e||!e.paused||e.ended||e.readyState<1||(En(),b.engine.play())},[Lt,He,lt,wt,y,Ie,En,d,i,b.engine]),g(()=>{const e=de.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=Se)},[Se]),g(()=>{const e=de.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||j.current.length>0||(ue>=0?e.subtitleTrack=ue:e.subtitleTrack=-1)},[ue]),g(()=>{const e=d.current;if(!(!e||y)&&(e.querySelectorAll("track").forEach(n=>n.remove()),j.current=[],_e.length!==0&&(_e.forEach(n=>{const a=document.createElement("track");a.kind="subtitles",a.label=n.label||n.language||"Unknown",a.srclang=n.language||n.label||"en";const l=`/api/subtitle-proxy?url=${encodeURIComponent(n.url)}&referer=${encodeURIComponent(Fe)}`;a.src=l,a.addEventListener("load",()=>{const m=j.current.indexOf(a),x=a.track;if(x&&m>=0){const q=m===ne.current;x.mode=q&&!vn.current?"showing":"hidden"}}),e.appendChild(a),j.current.push(a)}),_e.length>0)))try{const n=de.current;n&&typeof n.subtitleTrack=="number"&&n.subtitleTrack!==-1&&(n.subtitleTrack=-1)}catch{}},[_e,Fe,y,A,d]),g(()=>{const e=d.current;if(!e||y)return;const n=de.current;j.current.length>0&&n&&typeof n.subtitleTrack=="number"&&Array.isArray(n.subtitleTracks)&&n.subtitleTracks.length>0&&(n.subtitleTrack=-1);const a=()=>{const x=Fn(b.state.subtitleFontSize,e.clientHeight||720),q=Math.max(0,Math.min(100,100-b.state.subtitlePosition)),U=()=>{const D=x*16,R=e.videoHeight||e.clientHeight||720,P=e.videoWidth||e.clientWidth||1280;return{step:D*1.3/R*100,chars:Math.max(20,Math.floor(P/(D*.55)))}},ge=(D,R)=>{const P=D;P.snapToLines=!1,P.line=R},S=D=>{if(!D.cues)return;Array.from(D.cues).forEach(ae=>ge(ae,q));const R=Array.from(D.activeCues??[]);if(R.length<=1){R.forEach(ae=>ge(ae,q));return}const{step:P,chars:E}=U();let Te=q;for(let ae=R.length-1;ae>=0;ae--){const Ye=String(R[ae].text??"").replace(/<[^>]*>/g,"").split(`
|
|
3
|
-
`).reduce((nn,Pt)=>nn+Math.max(1,Math.ceil(Pt.length/E)),0);Te=Math.max(0,Te-Ye*P),ge(R[ae],Te),Te-=P*.4}},G=j.current;if(G.length>0){G.forEach((D,R)=>{const P=D.track;if(!P)return;const E=R===ue;P.mode=E&&!ve?"showing":"hidden",E&&!ve&&S(P)});return}const Q=Array.from(e.textTracks);Q.length!==0&&Q.forEach((D,R)=>{const P=R===ue;D.mode=P&&!ve?"showing":"hidden",P&&!ve&&S(D)})};a();const l=()=>a();e.textTracks.addEventListener("addtrack",l),e.addEventListener("loadedmetadata",a,{once:!0});const m=window.setTimeout(a,600);return()=>{e.textTracks.removeEventListener("addtrack",l),e.removeEventListener("loadedmetadata",a),window.clearTimeout(m)}},[ue,_e,y,A,d,ve,b.state.subtitleFontSize,b.state.subtitlePosition]),g(()=>{if(!ve)return;const e=d.current,n=$t.current;if(!e||!n)return;const a=ot/1e3,l=bn/1e3,m=new Set;let x=[],q=-1,U=-1,ge=-1,S=-1,G=0,Q=0,D=!1;const R=()=>{const H=ne.current;if(H<0)return null;const je=j.current;return je.length>0?je[H]?.track??null:Array.from(e.textTracks)[H]??null},P=(H,je)=>{const me=H.cues;if(!me||me.length===0)return Array.from(H.activeCues??[]);let tt=0,nt=me.length;for(;tt<nt;){const xe=tt+nt>>>1;me[xe].endTime+a<je?tt=xe+1:nt=xe}const Mt=[];for(let xe=tt;xe<me.length;xe++){const rn=me[xe];if(rn.startTime+a>je)break;rn.endTime+a>=je&&Mt.push(rn)}return Mt},E=()=>{const H=R(),je=e.currentTime-l,me=H?P(H,je):[],tt=e.clientWidth,nt=e.clientHeight,Mt=e.videoWidth,xe=e.videoHeight;if(me.length===x.length&&me.every((Bn,Pn)=>Bn===x[Pn])&&tt===q&&nt===U&&Mt===ge&&xe===S||(x=me,q=tt,U=nt,ge=Mt,S=xe,n.textContent="",me.length===0))return;const ir={fontSize:Fn(b.state.subtitleFontSize,nt),position:b.state.subtitlePosition,bgOpacity:b.state.subtitleBgOpacity,bgColor:b.state.subtitleBgColor,textColor:b.state.subtitleTextColor,edge:b.state.subtitleEdge,bold:b.state.subtitleBold},Qr=Ns(ir),Xr=Is(e,ir.position);me.forEach((Bn,Pn)=>{const lr=String(Bn.text??"");if(!As(lr).trim())return;const Mn=document.createElement("div"),Zr=(me.length-1-Pn)*1.7;Mn.style.cssText=`${Qr}
|
|
4
|
-
bottom: calc(${Xr}px + ${Zr}em);`,Mn.innerHTML=xs(lr),n.appendChild(Mn)})},Te=()=>{Array.from(e.textTracks).forEach(H=>{m.has(H)||(m.add(H),H.addEventListener("cuechange",E))})},ae=()=>{Te(),E()},wn=()=>{if(D||Q)return;const H=()=>{Q=0,!(D||e.paused||e.ended)&&(E(),wn())};Q=window.requestAnimationFrame(H)},Ye=e,nn=()=>{G=0,E(),!D&&Ye.requestVideoFrameCallback&&(G=Ye.requestVideoFrameCallback(nn))},Pt=()=>{E(),Ye.requestVideoFrameCallback?G||(G=Ye.requestVideoFrameCallback(nn)):wn()};Te(),e.textTracks.addEventListener("addtrack",ae),e.textTracks.addEventListener("removetrack",ae),e.addEventListener("timeupdate",E),e.addEventListener("seeked",E),e.addEventListener("loadedmetadata",E),e.addEventListener("play",Pt);const or=Array.from(e.querySelectorAll("track"));or.forEach(H=>H.addEventListener("load",E));const ar=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>E());return ar?.observe(e),E(),Pt(),()=>{D=!0,m.forEach(H=>H.removeEventListener("cuechange",E)),e.textTracks.removeEventListener("addtrack",ae),e.textTracks.removeEventListener("removetrack",ae),e.removeEventListener("timeupdate",E),e.removeEventListener("seeked",E),e.removeEventListener("loadedmetadata",E),e.removeEventListener("play",Pt),or.forEach(H=>H.removeEventListener("load",E)),ar?.disconnect(),Q&&window.cancelAnimationFrame(Q),G&&Ye.cancelVideoFrameCallback&&Ye.cancelVideoFrameCallback(G),n.textContent=""}},[ve,ot,ue,_e,bn,d,b.state.subtitleFontSize,b.state.subtitlePosition,b.state.subtitleBgOpacity,b.state.subtitleBgColor,b.state.subtitleTextColor,b.state.subtitleEdge,b.state.subtitleBold]);const Ln=()=>{w(null),ce([]),Je(""),L(-1)},Yr=N(e=>{i||(ee(e),pe(1),Ae(e,1))},[Ae,i]),tn=!f&&r?.seasons&&r.seasons.length>1?t("label",{className:p.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{disabled:i,value:u,onChange:e=>Yr(parseInt(e.currentTarget.value,10)||1),className:p.select,children:r.seasons.map(e=>t("option",{value:e.season_number,children:["Season ",e.season_number," (",e.episode_count," ep)"]},e.season_number))})]}):null,dt=N(e=>{if(i)return;const n=parseInt(e,10);if(!isNaN(n)){try{d.current?.pause()}catch{}pe(n),Ae(u,n)}Tn(!1)},[u,Ae,d,i]);g(()=>{if(f)return;const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="n"&&(F!=null?dt(String(F)):cr.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[f,F,dt]);const jr=e=>{pt(e);try{const a=ft[e];a&&O.setItem("tvLastAudio",zn(a))}catch{}const n=de.current;n&&n.audioTrack!==void 0&&(n.audioTrack=e)},Gr=e=>{Pe(e);try{if(e===-1)O.setItem("tvSubtitlesEnabled","false");else{O.setItem("tvSubtitlesEnabled","true"),O.setItem("tvSelectedSubtitle",String(e));const m=_e[e];m&&O.setItem("tvLastSubtitle",zn(m))}}catch{}const n=d.current,a=de.current;if(a&&typeof a.subtitleTrack=="number"&&Array.isArray(a.subtitleTracks)&&a.subtitleTracks.length>0&&(a.subtitleTrack=j.current.length>0||e<0?-1:e),!n)return;const l=j.current;if(l.length>0){l.forEach((m,x)=>{const q=m.track;if(!q)return;const U=x===e;q.mode=U&&!ve?"showing":"hidden"});return}Array.from(n.textTracks).forEach((m,x)=>{const q=x===e;m.mode=q&&!ve?"showing":"hidden"})};return g(()=>{if(!r){document.title="TV & Movies - dango";return}document.title=f?`${r.title} - dango`:`${r.title} - Season ${u} Episode ${k} - dango`},[r,f,u,k]),g(()=>{if(!r||f)return;const e=new URLSearchParams(h),n=e.get("s"),a=e.get("e"),l=String(u),m=String(k);n===l&&a===m||(e.set("type",h.get("type")||"tv"),e.set("s",l),e.set("e",m),L(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[r,f,u,k,h,L]),t("div",{className:`${Le.playerPageLayout} ${ze?Le.theaterMode:""} ${f?Le.noSidebar:""}`,onClick:wr,children:[ze&&t(Ls,{videoRef:d,active:pn.enabled&&!y&&$.length>0&&!Be&&!(r?.adult&&!It),settings:pn}),!ze&&!f&&t("aside",{className:Le.episodeSidebar,children:r?t(ws,{episodes:rr,currentEpisode:String(k),watchedEpisodes:nr,onEpisodeClick:dt,header:tn}):t(Bs,{variant:"sidebar"})}),t("div",{className:Le.playerMain,children:[r&&t("div",{className:p.playerSection,onContextMenu:e=>e.preventDefault(),style:r.adult&&!It?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:y&>&&!c?t("iframe",{src:gt,className:p.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!y&&kt&&!c?t("iframe",{src:kt,className:p.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!y&&($.length>0||v)?t(Ge,{children:[Be&&t(mr,{error:Be,onRetry:en}),t(Uo,{player:b,title:r.title,episodeLabel:f?void 0:`S${u} E${k}`,audioTracks:ft,selectedAudioTrack:Se,onAudioTrackChange:jr,subtitles:_e,selectedSubtitle:ue,onSubtitleChange:Gr,streams:$,resolutionIdx:ke,onResolutionChange:e=>{xn(),st(e)},onBack:Ln,videoDelayEnabled:Nt,onVideoDelayToggle:dn,videoDelayMs:Et,onVideoDelayChange:qn,onCalibrateAvSync:c?void 0:fr,subtitleDelayMs:ot,onSubtitleDelayChange:Sr,showNextEpisodeButton:!i&&Nr&&!He&&!lt,onNextEpisode:qr,isLoading:v,isTheaterMode:ze,onTheaterModeToggle:Cn,ambientSettings:pn,onAmbientChange:_r,children:[t(ds,{autoPlay:!c&&Lt&&!wt,playsInline:!0,disablePictureInPicture:!0,className:`${p.video} ${fn?p.videoHidden:""}`,onTimeUpdate:()=>{Ie||(zr(),Jt())},onEnded:()=>{Ie||Jt(!0)},onPlay:Dr,onPause:Or,onSeeked:()=>{Ie||(Bt(),Jt())},onLoadedMetadata:()=>{Vr(),Zn(),Jt()},onDurationChange:()=>{Zn()},onContextMenu:e=>e.preventDefault(),onError:()=>{se("Video failed to load. Try another server or reload."),K(!1)}}),t("canvas",{ref:un,className:`${p.delayCanvas} ${fn?p.delayCanvasActive:""}`}),ve&&t("div",{ref:$t,className:p.subtitleOverlay}),t(Ps,{isOpen:hr,ms:Et,onChange:qn,onApply:vr,onClose:pr,testClipActive:Ie,onTestClip:gr})]})]}):Be&&!y?t(mr,{error:Be,onRetry:en}):null}),t(to,{playback:Vt?{selection:Vt,position:d.current?.currentTime||0,playing:!1,rate:b.engine.getState().playbackRate}:null,onCreate:()=>{mn(),b.engine.pause()},needsPlayback:Un.needsPlayback,onEnablePlayback:Un.enablePlayback}),c&&!v&&r&&!Vt&&t("p",{role:"alert",children:"The host's direct HLS source is unavailable here. Retry or leave the room to use another source."}),!ze&&r&&t(Ms,{}),!ze&&tn&&t("div",{className:p.mobileSeasonRow,children:tn}),!ze&&r&&t("div",{className:le.streamPanel,children:[t("div",{className:p.providerSelectWrap,children:t("label",{className:p.controlLabel,children:["Provider",t("select",{value:A,onChange:e=>Kr(e.currentTarget.value),className:p.select,disabled:i||W.length===0,children:ht?t("option",{value:"",children:"Loading..."}):W.length===0?t("option",{value:"",children:"No providers available"}):t(Ge,{children:[De.length>0&&t("optgroup",{label:"Direct HLS",children:De.map(e=>t("option",{value:e.id,children:e.label},e.id))}),Oe.length>0&&t("optgroup",{label:"Embeds",children:Oe.map(e=>t("option",{value:e.id,children:e.label},e.id))})]})})]})}),!i&&!y&&(v?t("div",{className:p.sourceLoader,children:t("div",{className:p.ringSpinner})}):t(Wo,{servers:zt,selectedServer:Ct?"Embed":Y,onServerSelect:Wr}))]}),!ze&&r&&t("div",{className:Le.playerInfoContainer,children:[t("div",{className:Le.playerInfoHeader,children:[t("div",{className:Le.playerAnimeCard,children:r.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"})}),t("div",{className:Le.videoTitleSection,children:[t("div",{className:le.titleContainer,children:[t("h1",{children:r.title}),t("div",{className:p.meta,children:[t("span",{className:p.year,children:r.year}),r.vote_average!=null&&r.vote_average>0&&t("span",{className:p.rating,children:[t(be,{name:"star",size:12}),Number(r.vote_average).toFixed(1)]}),t("span",{className:`${p.typeBadge} ${p[f?"movie":"tv"]}`,children:f?"Movie":"TV Show"})]}),sr.length>0&&t("div",{className:p.genreRow,children:sr.map(e=>t("span",{className:p.genreChip,children:e},e))}),An.length>0&&t("div",{className:p.metaRow,children:An.map((e,n)=>t("span",{children:[e,n<An.length-1?" · ":""]},`${e}-${n}`))})]}),t("div",{className:le.controls,children:[t("button",{className:`${le.watchlistBtn} ${At?le.inList:""}`,onClick:Er,disabled:kr,type:"button",children:[At?t(be,{name:"check",size:14}):t(be,{name:"plus",size:14}),At?"In Watchlist":"Add to Watchlist"]}),!f&&t(Ge,{children:[t("button",{className:`${le.watchlistBtn}`,onClick:()=>Sn!=null&&dt(String(Sn)),disabled:i||Sn==null,type:"button",children:[t(be,{name:"chevron-left",size:14}),"Prev EP"]}),t("button",{className:`${le.watchlistBtn}`,onClick:()=>F!=null&&dt(String(F)),disabled:i||F==null,type:"button",children:["Next EP",t(be,{name:"chevron-right",size:14})]}),!f&&t("button",{className:`${le.watchlistBtn} ${le.modeToggleBtn} ${ut?le.modeToggleActive:""}`,onClick:()=>Mr(!ut),type:"button","aria-pressed":ut,children:ut?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),Br&&t("button",{className:`${le.watchlistBtn}`,onClick:()=>Tn(!0),type:"button",children:[t(be,{name:"list-ul",size:14}),"Episodes"]})]})]})]})]}),t("div",{className:Le.infoColumns,children:[t("div",{className:`${le.descriptionSection} ${le.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(eo,{text:r.overview,emptyText:"No description available."}),t("button",{className:le.detailsToggleBtn,onClick:()=>xr(!Yt),type:"button",children:[Yt?t(be,{name:"chevron-up"}):t(be,{name:"chevron-down"}),Yt?"Hide Details":"Show Details"]})]}),Yt&&t("div",{className:p.detailGrid,children:[r.first_air_date&&t("div",{className:p.detailItem,children:[t("strong",{children:f?"Release Date":"First Air Date"}),t("span",{children:r.first_air_date})]}),r.last_air_date&&t("div",{className:p.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:r.last_air_date})]}),r.networks&&r.networks.length>0&&t("div",{className:p.detailItem,children:[t("strong",{children:"Networks"}),t("span",{children:r.networks.map(e=>e.name).join(", ")})]}),r.created_by&&r.created_by.length>0&&t("div",{className:p.detailItem,children:[t("strong",{children:"Created By"}),t("span",{children:r.created_by.map(e=>e.name).join(", ")})]}),r.episode_run_time&&r.episode_run_time.length>0&&t("div",{className:p.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[r.episode_run_time[0]," min"]})]}),r.imdb_id&&t("div",{className:p.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${r.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:p.imdbLink,children:"View on IMDb"})]})]})]})]}),!f&&t(Rs,{isOpen:Lr,onClose:()=>Tn(!1),episodes:rr,currentEpisode:String(k),watchedEpisodes:nr,onEpisodeClick:dt,header:tn}),r?.adult&&!It&&t(qs,{isOpen:!0,onClose:Ln,onGrant:Tr}),t(zs,{isOpen:!c&&He&&!yn&&Wt.current===`${re}:${u}:${k}`&&at?.completed!==1&&!an(jn,at?.duration??0),onClose:Jn,title:"Resume Watching",message:t(Ge,{children:["You were at ",t("strong",{children:On(it)})]}),restartLabel:"Start from Beginning",onResume:Fr,onRestart:Jn}),t($s,{isOpen:lt,onClose:()=>ct(!1),title:f?"Movie Completed!":Ue!=null?"Season Complete!":"Show Completed!",heading:Ir,message:f?"You finished this movie!":Ue!=null?`You finished Season ${u}.`:"Congratulations! You finished all available episodes.",children:[t(sn,{variant:"secondary",onClick:()=>ct(!1),children:"Close"}),Ue!=null?t(sn,{onClick:Ur,children:["Start Season ",Ue]}):t(Ge,{children:[t(sn,{onClick:()=>{ct(!1),Ln()},children:"Back to Details"}),t(sn,{onClick:Hr,disabled:Ft.isPending||qt.isPending,children:Ft.isPending||qt.isPending?"Saving...":"Move to Completed"})]})]}),!r&&t("div",{className:p.statusMsg,children:[t(be,{name:"spinner",className:p.spinner})," Loading..."]})]})]})};export{Ha as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._panel_n8xyd_1{padding:1rem;margin:.75rem 0;border:1px solid var(--border-primary);border-radius:12px;background:var(--bg-elevated);color:var(--text-primary)}._heading_n8xyd_10,._actions_n8xyd_11,._members_n8xyd_12{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap}._name_n8xyd_19{display:block;margin:.75rem 0}._name_n8xyd_19 small{color:var(--text-secondary)}._heading_n8xyd_10{justify-content:space-between}._panel_n8xyd_1 p{font-size:.875rem;line-height:1.5;margin:.75rem 0 0;color:var(--text-secondary)}._panel_n8xyd_1 input{box-sizing:border-box;width:100%;padding:.75rem;margin-top:.75rem;border:1px solid var(--border-primary);border-radius:8px;background:var(--bg-primary);color:var(--text-primary)}._members_n8xyd_12{padding:0;list-style:none;font-size:.875rem}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as l,u as s,L as f}from"./vendor-core-DfaOB3Rn.js";import{a2 as m,B as r}from"./index-DYanm9eZ.js";const _="_panel_n8xyd_1",x="_heading_n8xyd_10",C="_actions_n8xyd_11",b="_members_n8xyd_12",k="_name_n8xyd_19",a={panel:_,heading:x,actions:C,members:b,name:k};function N(){const n=m();return s("label",{className:a.name,children:["Display name",s("input",{value:n.displayName,onChange:t=>n.setDisplayName(t.currentTarget.value),maxLength:32,placeholder:"Your name (optional)",autoComplete:"nickname"}),s("small",{children:"Remembered for this profile on this browser."})]})}function W({playback:n,onCreate:t,needsPlayback:u,onEnablePlayback:g}){const e=m(),[p,c]=l(!1),[h,i]=l(""),[y,v]=l(!1),d=e.session?`${e.workerUrl}/join#${e.session.id}.${e.session.guestToken}`:"";return s("section",{className:a.panel,"aria-label":"Watch along",children:[s("div",{className:a.heading,children:[s("strong",{children:["Watch along",e.session?e.session.host?" · You are hosting":" · Following host":""]}),e.session?s("div",{className:a.actions,children:[s(r,{size:"sm",variant:"secondary",onClick:async()=>{v(!0);try{await navigator.clipboard.writeText(d),i("Invite copied")}catch{i("Copy the invite below")}},children:"Copy invite"}),s(r,{size:"sm",variant:"ghost",onClick:e.leave,children:e.session.host?"End room":"Leave room"})]}):s("div",{className:a.actions,children:[t&&s(r,{size:"sm",loading:p,disabled:!n||!e.workerUrl,onClick:async()=>{if(n){c(!0),i("");try{t(),await e.create({...n,playing:!1})}catch(o){i(o instanceof Error?o.message:"Could not create room")}finally{c(!1)}}},children:"Create room"}),s(f,{to:"/watch-along",children:"Join a room"})]})]}),s(N,{}),!e.session&&s("p",{children:"Direct HLS only. Each viewer needs their own dango. Room controls use the shared watch-along service."}),e.session&&s("p",{children:[e.connected?e.room?.hostOnline?"Connected":"Host disconnected. Room closes after 60 seconds unless they reconnect":"Connecting…"," ","· Provider and source follow the host. Volume and subtitles stay yours."]}),e.room&&s("p",{children:[e.session?.host&&"End the room when you are finished watching. ","Rooms automatically close six hours after creation. This room expires at"," ",s("time",{dateTime:new Date(e.room.expiresAt).toISOString(),children:new Date(e.room.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),", even if playback is still active."]}),e.room&&s("ul",{className:a.members,children:e.room.members.map((o,w)=>s("li",{children:[o.name||(o.host?"Host":`Guest ${w+1}`),o.name&&o.host?" (host)":"",o.id===e.selfId?" (you)":"",": ",o.status]},o.id))}),u&&s(r,{size:"sm",onClick:g,children:"Enable playback"}),y&&e.session&&s("input",{"aria-label":"Room invite",readOnly:!0,value:d,onFocus:o=>o.currentTarget.select()}),(e.error||h)&&s("p",{role:"status",children:e.error||h})]})}export{W,N as a,a as s};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{u as t,A as w,q as E,h as j,d as P,T as te,$ as ct}from"./vendor-core-DfaOB3Rn.js";import{p as M,L as qe,B as G,$ as se,l as lt,aa as Re,q as K,a6 as dt,t as ut,g as pt,a2 as ft,ab as je,ac as mt}from"./index-DYanm9eZ.js";import{I as Y}from"./vendor-icons-DrybRNxP.js";import{S as Fe,a as ht,f as He,m as yt,h as bt,d as gt,s as ee,k as _t,u as vt,n as ie}from"./PlayerProvider-BXBzQc8G.js";import{u as St}from"./vendor-query-BBT5_sHx.js";import{i as ce,a as wt}from"./playbackCompletion-CxGa4g7a.js";const Ct="_controls_pcbjf_1",kt="_titleContainer_pcbjf_9",xt="_scheduleInfo_pcbjf_15",Tt="_status_pcbjf_23",Lt="_nextEpisode_pcbjf_35",Nt="_watchlistBtn_pcbjf_45",Pt="_inList_pcbjf_72",Bt="_queueBtn_pcbjf_83",Et="_queueActive_pcbjf_95",At="_modeToggleBtn_pcbjf_101",It="_modeToggleActive_pcbjf_108",$t="_markWatchedBtn_pcbjf_129",Mt="_markWatchedDone_pcbjf_143",Rt="_streamPanel_pcbjf_154",jt="_desktopEpisodeActions_pcbjf_168",Ft="_sourceLoader_pcbjf_174",Dt="_episodeActions_pcbjf_187",Ot="_mobileEpisodeActions_pcbjf_201",qt="_episodeNavBtn_pcbjf_205",Ht="_primary_pcbjf_235",Wt="_secondary_pcbjf_245",zt="_episodePickerBtn_pcbjf_249",Vt="_queueCountdown_pcbjf_253",Kt="_speedBoostBadge_pcbjf_268",Ut="_videoContainer_pcbjf_299",Qt="_loadingOverlay_pcbjf_312",Gt="_loadingDots_pcbjf_326",Yt="_dot_pcbjf_331",Xt="_bounce_pcbjf_1",Jt="_bufferingOverlay_pcbjf_348",Zt="_bufferingSpinner_pcbjf_357",er="_spin_pcbjf_444",tr="_videoIframe_pcbjf_366",rr="_videoElementHidden_pcbjf_389",nr="_upscalerCanvas_pcbjf_394",sr="_upscalerActive_pcbjf_407",ar="_upscalerStatusBadge_pcbjf_411",or="_subtitleOverlay_pcbjf_426",ir="_spinner_pcbjf_444",cr="_errorOverlay_pcbjf_505",lr="_retryButton_pcbjf_515",dr="_detailsToggleBtn_pcbjf_528",ur="_descriptionSection_pcbjf_551",pr="_synopsisFlat_pcbjf_559",fr="_fullscreenActive_pcbjf_593",mr="_errorSubtext_pcbjf_636",Qn={controls:Ct,titleContainer:kt,scheduleInfo:xt,status:Tt,nextEpisode:Lt,watchlistBtn:Nt,inList:Pt,queueBtn:Bt,queueActive:Et,modeToggleBtn:At,modeToggleActive:It,markWatchedBtn:$t,markWatchedDone:Mt,streamPanel:Rt,desktopEpisodeActions:jt,sourceLoader:Ft,episodeActions:Dt,mobileEpisodeActions:Ot,episodeNavBtn:qt,primary:Ht,secondary:Wt,episodePickerBtn:zt,queueCountdown:Vt,speedBoostBadge:Kt,videoContainer:Ut,loadingOverlay:Qt,loadingDots:Gt,dot:Yt,bounce:Xt,bufferingOverlay:Jt,bufferingSpinner:Zt,spin:er,videoIframe:tr,videoElementHidden:rr,upscalerCanvas:nr,upscalerActive:sr,upscalerStatusBadge:ar,subtitleOverlay:or,spinner:ir,errorOverlay:cr,retryButton:lr,detailsToggleBtn:dr,descriptionSection:ur,synopsisFlat:pr,fullscreenActive:fr,errorSubtext:mr},hr="_playerPageLayout_13s1u_1",yr="_noSidebar_13s1u_15",br="_episodeSidebar_13s1u_19",gr="_playerMain_13s1u_32",_r="_videoPlayerWrapper_13s1u_40",vr="_playerInfoHeader_13s1u_56",Sr="_playerAnimeCard_13s1u_62",wr="_playerInfoContainer_13s1u_74",Cr="_infoColumns_13s1u_86",kr="_videoTitleSection_13s1u_114",xr="_theaterMode_13s1u_288",Gn={playerPageLayout:hr,noSidebar:yr,episodeSidebar:br,playerMain:gr,videoPlayerWrapper:_r,playerInfoHeader:vr,playerAnimeCard:Sr,playerInfoContainer:wr,infoColumns:Cr,videoTitleSection:kr,theaterMode:xr},Tr={fontSize:"subtitleFontSize",position:"subtitlePosition",bgOpacity:"subtitleBgOpacity",bgColor:"subtitleBgColor",textColor:"subtitleTextColor",edge:"subtitleEdge",bold:"subtitleBold"},U={fontSize:1.8,position:0,bgOpacity:.5,bgColor:"#000000",textColor:"#ffffff",edge:"shadow",bold:!1},fe=(e,n,s)=>Math.max(n,Math.min(s,e)),me=e=>typeof e=="string"&&/^#[0-9a-fA-F]{6}$/.test(e),le=(e,n,s,o)=>{try{const r=M.getItem(e);if(r===null)return n;const i=parseFloat(r);return Number.isFinite(i)?fe(i,s,o):n}catch{return n}};function Lr(){let e=U.edge,n=U.bgColor,s=U.textColor,o=U.bold;try{const r=M.getItem("subtitleEdge");(r==="shadow"||r==="outline"||r==="none")&&(e=r);const i=M.getItem("subtitleBgColor");me(i)&&(n=i);const c=M.getItem("subtitleTextColor");me(c)&&(s=c);const p=M.getItem("subtitleBold");p!==null&&(o=p==="true")}catch{}return{fontSize:le("subtitleFontSize",U.fontSize,.5,10),position:le("subtitlePosition",U.position,0,100),bgOpacity:le("subtitleBgOpacity",U.bgOpacity,0,1),bgColor:n,textColor:s,edge:e,bold:o}}function We(e,n){const s=`rgba(0, 0, 0, ${fe(n,0,1)})`;if(!me(e))return s;const o=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${o}, ${r}, ${i}, ${fe(n,0,1)})`}function ze(e,n){return e==="none"?n<=0?"0 1px 3px rgba(0, 0, 0, 0.9)":"none":e==="outline"?["-1px 0 0 black","1px 0 0 black","0 -1px 0 black","0 1px 0 black","-1px -1px 0 black","1px -1px 0 black","-1px 1px 0 black","1px 1px 0 black","0 0 6px rgba(0, 0, 0, 0.9)"].join(", "):"0 0 4px black, 0 1px 2px rgba(0, 0, 0, 0.8)"}function Yn(e){return`
|
|
2
|
-
video::cue {
|
|
3
|
-
font-size: ${e.fontSize}rem !important;
|
|
4
|
-
color: ${e.textColor} !important;
|
|
5
|
-
background-color: ${We(e.bgColor,e.bgOpacity)} !important;
|
|
6
|
-
font-weight: ${e.bold?"bold":"normal"} !important;
|
|
7
|
-
text-shadow: ${ze(e.edge,e.bgOpacity)} !important;
|
|
8
|
-
}
|
|
9
|
-
`}function Xn(e){return[`font-size: ${e.fontSize}rem`,`color: ${e.textColor}`,`background-color: ${We(e.bgColor,e.bgOpacity)}`,`font-weight: ${e.bold?"700":"400"}`,`text-shadow: ${ze(e.edge,e.bgOpacity)}`,"padding: 0.2em 0.5em","border-radius: 0.25em","text-align: center","position: absolute","left: 50%","transform: translateX(-50%)","max-width: 92%","white-space: pre-wrap","overflow-wrap: break-word","line-height: 1.4"].join(`;
|
|
10
|
-
`)+";"}const Nr=new Set(["b","i","u","strong","em"]);function Jn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/<(\/?)([a-zA-Z]+)>/g,(s,o,r)=>Nr.has(r.toLowerCase())?`<${o}${r.toLowerCase()}>`:s)}function Zn(e){return e.replace(/<[^>]*>/g,"")}const es=["#ffffff","#ffff00","#7CFC00","#00e5ff","#ff9ff3","#ffa502"],ts=["#000000","#1e272e","#2f3542","#3d0c02","#0c3d2e","#ffffff"];function rs(e,n){const s=Number.isFinite(e)?e*16:U.fontSize*16;return!Number.isFinite(n)||n<=0?s/16:Math.min(s,Math.max(13,n*.07))/16}function ns(e){const n=Math.abs(e/1e3).toFixed(1);return e>0?`+${n}s`:e<0?`-${n}s`:"0.0s"}function ss(e,n){const s=e.clientWidth||0,o=e.clientHeight||0,r=e.videoWidth>0&&e.videoHeight>0?e.videoWidth/e.videoHeight:0;let i=o;r>0&&s>0&&o>0&&(i=s/o>r?o:s/r);const c=Math.max(0,(o-i)/2),p=Math.max(0,Math.min(100,Number(n)||0))/100*i;return c+p}const as=({isOpen:e,onClose:n,title:s,heading:o,message:r,children:i})=>t(qe,{isOpen:e,onClose:n,title:s,width:"sm",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t(Y,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)",marginBottom:"0.5rem"}}),t("p",{style:{fontSize:"1.1rem",fontWeight:600},children:o}),t("p",{style:{color:"var(--text-secondary)"},children:r}),i&&t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:i})]})}),os=({isOpen:e,onClose:n,title:s,message:o,resumeLabel:r="Resume",restartLabel:i="Start Over",onResume:c,onRestart:p})=>t(qe,{isOpen:e,onClose:n,title:s,width:"sm",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:o}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(G,{variant:"secondary",onClick:p,children:i}),t(G,{onClick:c,children:r})]})]})}),Pr="_centerControls_bxt8c_1",Br="_centerSkipBtn_bxt8c_15",Er="_centerPlayPause_bxt8c_37",ae={centerControls:Pr,centerSkipBtn:Br,centerPlayPause:Er},is=()=>t("div",{className:ae.centerControls,onClick:e=>e.stopPropagation(),children:[t(Fe,{seconds:-10,className:ae.centerSkipBtn}),t(ht,{className:ae.centerPlayPause,"data-speed-boost-ignore":"true"}),t(Fe,{seconds:10,className:ae.centerSkipBtn})]}),cs=({visible:e,title:n,episode:s,onBack:o,classes:r})=>t("div",{className:`${r.overlay} ${e?"":r.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:t("div",{className:r.top,onClick:i=>i.stopPropagation(),children:[t("button",{className:r.backBtn,onClick:i=>{i.stopPropagation(),o()},title:"Back","aria-label":"Back",children:t(Y,{name:"chevron-left"})}),t("div",{className:r.titleInfo,children:[t("span",{className:r.title,children:n}),s&&t("span",{className:r.episode,children:s})]})]})});function Ar(e){return e instanceof Element&&!!e.closest('button, input, select, textarea, a, [role="button"], [role="slider"], [data-player-ui="true"]')}function ls({engine:e,topBar:n,centerControls:s,bottomBar:o,settingsPanel:r,overlays:i,isInteracting:c=!1,nativeControls:p=!1,chromeDisabled:a=!1,className:u,onStageClick:_,children:x}){const g=He(e),A=yt(),l=w(void 0),d=w(void 0),C=w(0),f=w(c);f.current=c;const h=E(()=>{clearTimeout(l.current),l.current=void 0},[]),y=E(()=>{h();const N=e.getState();!N.isPlaying||N.isScrubbing||f.current||p||(l.current=setTimeout(()=>{const b=e.getState();f.current||b.isScrubbing||!b.isPlaying||e.setShowControls(!1)},A?5e3:3e3))},[e,A,p,h]),B=E(()=>{e.setShowControls(!0),y()},[e,y]);bt(e,B,!p&&!a),j(()=>(c||g.isScrubbing||!g.isPlaying?(e.setShowControls(!0),h()):y(),h),[e,c,g.isPlaying,g.isScrubbing,g.showControls,h,y]),j(()=>()=>{clearTimeout(d.current)},[]);const m=N=>{if(Ar(N.target)||p||a)return;_?.();const b=Date.now();if(b-C.current<280){clearTimeout(d.current),d.current=void 0,C.current=0,e.toggleFullscreen();return}C.current=b,clearTimeout(d.current),d.current=setTimeout(()=>{d.current=void 0,e.setShowControls(!e.getState().showControls),y()},280)},T=g.showControls||g.isScrubbing||c||!g.isPlaying;return t(gt,{engine:e,children:t("div",{ref:e.containerRef,"data-player-root":"true",className:`${ee.shell} ${g.isFullscreen?ee.shellFullscreen:""} ${u??""}`,style:{cursor:!T&&g.isFullscreen?"none":"default"},onContextMenu:N=>N.preventDefault(),onPointerMove:N=>{N.pointerType==="mouse"&&B()},onFocusIn:B,onMouseLeave:()=>{window.matchMedia?.("(hover: hover) and (pointer: fine)").matches&&e.getState().isPlaying&&!f.current&&e.setShowControls(!1)},children:[t("div",{className:ee.stage,onClick:m,children:x}),i,(g.error||g.playBlocked)&&t("div",{className:ee.engineStatus,"data-player-ui":"true",children:t(_t,{})}),!a&&!p&&t("div",{className:ee.uiLayer,children:[t("div",{"data-player-ui":"true",children:n}),T&&s&&t("div",{"data-player-ui":"true",children:s}),t("div",{"data-player-ui":"true",children:o}),r&&t("div",{"data-player-ui":"true",children:r})]})]})})}const Ir=e=>(e.language??e.lang??"").toLowerCase(),$r=e=>(e.label??"").toLowerCase(),Mr=e=>`${e.language??e.lang??""}|||${e.label??""}`,Rr=e=>Ir(e).startsWith("en")||$r(e).includes("english");function ds(e,n){if(e.length===0||n?.enabled===!1)return-1;const s=n?.lastKey??null;if(s){const r=e.findIndex(i=>Mr(i)===s);if(r>=0)return r}const o=e.findIndex(Rr);return o>=0?o:0}const jr="_statusArea_1xccu_1",Fr="_toggleBtn_1xccu_20",Dr="_shortcuts_1xccu_46",Or="_shortcutGroup_1xccu_56",qr="_shortcut_1xccu_46",Hr="_key_1xccu_70",Wr="_label_1xccu_91",k={statusArea:jr,toggleBtn:Fr,shortcuts:Dr,shortcutGroup:Or,shortcut:qr,key:Hr,label:Wr},us=({showTheater:e=!0})=>{const[n,s]=P(!1);return t("div",{className:k.statusArea,children:[t("button",{type:"button",className:k.toggleBtn,onClick:()=>s(o=>!o),"aria-expanded":n,"aria-controls":"player-shortcuts",children:[t(Y,{name:"keyboard",size:14}),t("span",{children:"Keyboard Shortcuts"}),n?t(Y,{name:"chevron-up",size:12}):t(Y,{name:"chevron-down",size:12})]}),n&&t("div",{id:"player-shortcuts",className:k.shortcuts,children:[t("div",{className:k.shortcutGroup,children:[t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"↑"}),t("span",{className:k.key,children:"↓"}),t("span",{className:k.label,children:"Volume"})]}),t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"←"}),t("span",{className:k.key,children:"→"}),t("span",{className:k.label,children:"Seek"})]})]}),t("div",{className:k.shortcutGroup,children:[t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"Space"}),t("span",{className:k.label,children:"Play/Pause"})]}),t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"F"}),t("span",{className:k.label,children:"Fullscreen"})]}),t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"M"}),t("span",{className:k.label,children:"Mute"})]}),e&&t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"T"}),t("span",{className:k.label,children:"Theater"})]}),t("div",{className:k.shortcut,children:[t("span",{className:k.key,children:"N"}),t("span",{className:k.label,children:"Next"})]})]})]})]})},zr="_episodeListContainer_9tyin_1",Vr="_drawerContainer_9tyin_9",Kr="_episodeListHeader_9tyin_14",Ur="_drawerHeader_9tyin_20",Qr="_episodeListTitle_9tyin_29",Gr="_rangeSelector_9tyin_41",Yr="_rangeButton_9tyin_47",Xr="_active_9tyin_70",Jr="_episodeList_9tyin_1",Zr="_drawerList_9tyin_89",en="_episodeItem_9tyin_118",tn="_watched_9tyin_145",rn="_episodeThumb_9tyin_167",nn="_episodeText_9tyin_176",sn="_episodeLabel_9tyin_184",an="_episodeSub_9tyin_189",L={episodeListContainer:zr,drawerContainer:Vr,episodeListHeader:Kr,drawerHeader:Ur,episodeListTitle:Qr,rangeSelector:Gr,rangeButton:Yr,active:Xr,episodeList:Jr,drawerList:Zr,episodeItem:en,watched:tn,episodeThumb:rn,episodeText:nn,episodeLabel:sn,episodeSub:an},on=({episodes:e,currentEpisode:n,watchedEpisodes:s=[],onEpisodeClick:o,variant:r="sidebar",title:i="Episodes",header:c})=>{const[p,a]=P(0),u=w(null),_=te(()=>e.map(l=>typeof l=="string"?{id:l,label:`Episode ${l}`}:l),[e]),x=te(()=>new Set(s),[s]);j(()=>{const l=u.current;if(!l)return;let d=l.parentElement;for(;d;){const h=window.getComputedStyle(d);if((h.overflowY==="auto"||h.overflowY==="scroll")&&d.scrollHeight>d.clientHeight)break;d=d.parentElement}if(!d)return;const C=d.getBoundingClientRect(),f=l.getBoundingClientRect();d.scrollTop+=f.top+f.height/2-(C.top+d.clientHeight/2)},[n,p]);const g=te(()=>{if(_.length<=100)return[];const l=[];for(let d=0;d<_.length;d+=100){const C=d+1,f=Math.min(d+100,_.length);l.push(`${C}-${f}`)}return l},[_]),A=te(()=>{if(g.length===0)return _;const l=g[p];if(!l)return _;const[d,C]=l.split("-"),f=parseInt(d,10),h=parseInt(C,10);return _.slice(f-1,h)},[_,g,p]);return t("div",{className:`${L.episodeListContainer} ${r==="drawer"?L.drawerContainer:""}`,children:[t("div",{className:`${L.episodeListHeader} ${r==="drawer"?L.drawerHeader:""}`,children:[c,t("h3",{className:L.episodeListTitle,children:i}),g.length>0&&t("div",{className:L.rangeSelector,children:g.map((l,d)=>t("button",{className:`${L.rangeButton} ${p===d?L.active:""}`,onClick:()=>a(d),children:l},l))})]}),t("div",{className:`${L.episodeList} ${r==="drawer"?L.drawerList:""}`,children:A.map(l=>{const d=l.id===n,C=x.has(l.id)||l.watched===!0;return t("div",{ref:d?u:void 0,className:`${L.episodeItem} ${C?L.watched:""} ${d?L.active:""}`,onClick:()=>o(l.id),children:[l.thumbnail&&t("img",{src:l.thumbnail,alt:"",loading:"lazy",decoding:"async",className:L.episodeThumb}),t("span",{className:L.episodeText,children:[t("span",{className:L.episodeLabel,children:l.label??`Episode ${l.id}`}),l.sublabel&&t("span",{className:L.episodeSub,children:l.sublabel})]})]},l.id)})})]})},ps=({variant:e="sidebar",count:n=12})=>t("div",{className:`${L.episodeListContainer} ${e==="drawer"?L.drawerContainer:""}`,children:[t("div",{className:`${L.episodeListHeader} ${e==="drawer"?L.drawerHeader:""}`,children:[t("h3",{className:L.episodeListTitle,children:"Episodes"}),t("div",{className:L.rangeSelector,children:[t(se,{width:"60px",height:"28px",variant:"rectangular"}),t(se,{width:"60px",height:"28px",variant:"rectangular"}),t(se,{width:"60px",height:"28px",variant:"rectangular"})]})]}),t("div",{className:`${L.episodeList} ${e==="drawer"?L.drawerList:""}`,children:Array.from({length:n}).map((s,o)=>t("div",{className:L.episodeItem,style:{border:"none",background:"transparent"},children:t(se,{width:"120px",height:"1.2rem",variant:"text"})},o))})]}),cn="_shell_cys6s_1",ln="_overlay_cys6s_10",dn="_drawer_cys6s_21",un="_handle_cys6s_56",pn="_header_cys6s_64",fn="_headerCopy_cys6s_73",mn="_kicker_cys6s_79",hn="_title_cys6s_87",yn="_closeBtn_cys6s_94",bn="_body_cys6s_116",z={shell:cn,overlay:ln,drawer:dn,handle:un,header:pn,headerCopy:fn,kicker:mn,title:hn,closeBtn:yn,body:bn};function fs({isOpen:e,onClose:n,episodes:s,currentEpisode:o,watchedEpisodes:r=[],onEpisodeClick:i,title:c,header:p}){return j(()=>{if(!e)return;const a=_=>{_.key==="Escape"&&n()},u=document.body.style.overflow;return document.body.style.overflow="hidden",document.addEventListener("keydown",a),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",a)}},[e,n]),e?ct(t("div",{className:z.shell,role:"dialog","aria-modal":"true","aria-label":"Episode picker",children:[t("button",{className:z.overlay,type:"button",onClick:n,"aria-label":"Close episodes"}),t("aside",{className:z.drawer,children:[t("div",{className:z.handle}),t("div",{className:z.header,children:[t("div",{className:z.headerCopy,children:[t("span",{className:z.kicker,children:"Episode picker"}),t("h3",{className:z.title,children:"Choose an episode"})]}),t("button",{className:z.closeBtn,type:"button",onClick:n,"aria-label":"Close",children:t(Y,{name:"times"})})]}),t("div",{className:z.body,children:t(on,{episodes:s,currentEpisode:o,watchedEpisodes:r,onEpisodeClick:i,variant:"drawer",title:c,header:p})})]})]}),document.body):null}const gn="_sourceSelectionContainer_1am19_1",_n="_providerSelectContainer_1am19_14",vn="_providerSelect_1am19_14",Sn="_sourceSelect_1am19_1",wn="_sourceButtons_1am19_70",Cn="_sourceButton_1am19_70",kn="_active_1am19_95",ms={sourceSelectionContainer:gn,providerSelectContainer:_n,providerSelect:vn,sourceSelect:Sn,sourceButtons:wn,sourceButton:Cn,active:kn},hs=({skipIntervals:e,showId:n,episodeNumber:s,episodeCount:o,sourceType:r,showMeta:i})=>{const c=St(),p=lt(),{engine:a,mediaRef:u}=vt({volumeKey:"playerVolume",mutedKey:"playerMuted"}),{isPlaying:_,isMuted:x,volume:g,duration:A,isScrubbing:l,isBuffering:d,isFullscreen:C,isSpeedBoostActive:f,showControls:h,playbackLocked:y}=He(a),B=a.containerRef,m=w(null),T=w(0),N=w(Math.random().toString(36).substring(2)),b=a.setShowControls,[$,O]=P(M.getItem("autoSkipEnabled")==="true"),[V,I]=P(null),[H]=P(Lr),[Ve,ye]=P(H.fontSize),[Ke,be]=P(H.position),[Ue,ge]=P(H.bgOpacity),[Qe,_e]=P(H.bgColor),[Ge,ve]=P(H.textColor),[Ye,Se]=P(H.edge),[Xe,we]=P(H.bold),Ce=E((v,R)=>{if({fontSize:S=>typeof S!="number"?!1:(ye(S),!0),position:S=>typeof S!="number"?!1:(be(S),!0),bgOpacity:S=>typeof S!="number"?!1:(ge(S),!0),bgColor:S=>typeof S!="string"?!1:(_e(S),!0),textColor:S=>typeof S!="string"?!1:(ve(S),!0),edge:S=>S!=="shadow"&&S!=="outline"&&S!=="none"?!1:(Se(S),!0),bold:S=>typeof S!="boolean"?!1:(we(S),!0)}[v](R))try{M.setItem(Tr[v],String(R))}catch{}},[]),[Je,Ze]=P([]),[et,tt]=P(null),[rt,nt]=P(!1),[st,at]=P(!1),[ot,ke]=P(()=>{try{return M.getItem("playerUseNativeControls")==="true"}catch{return!1}}),X=w(!1),re=w(-1),ne=E(()=>{const v=u.current;return!n||!s||!i?.name?null:{showId:n,episodeNumber:s,episodeCount:o,currentTime:a.getTimeline().currentTime,duration:a.getState().duration,showName:i.name,showThumbnail:i.thumbnail,nativeName:i.names?.native,englishName:i.names?.english,genres:Array.isArray(i.genres)?i.genres.map(R=>typeof R=="string"?R:R?.name).filter(Boolean):void 0,popularityScore:i.score,type:i.type,isPlaying:v?!v.paused:r==="iframe",sessionId:N.current,isAdult:i.isAdult}},[a,u,n,s,o,i,r]),F=E((v=!1,R=!1)=>{if(X.current)return!1;const q=ne();if(!q)return!1;const S=u.current;if(!S&&!v&&r!=="iframe"||r!=="iframe"&&q.duration<=0)return!1;const W=a.getTimeline().currentTime;if(!R){if(W===0)return!1;const Z=S?Math.abs(W-re.current):0;if(!v&&S&&W!==S.duration&&Z<5)return!1}return q.currentTime=W,re.current=W,v?(async()=>{try{await Re("progress.updateProgress",q),c.invalidateQueries({queryKey:[K.playerData,n]}),c.invalidateQueries({queryKey:[K.videoSources,n,s]}),c.invalidateQueries({queryKey:[K.continueWatching]}),c.invalidateQueries({queryKey:[K.thisWeekSchedule]}),c.invalidateQueries(p.continueWatching.pathFilter())}catch(Z){console.error("Failed to update progress:",Z)}})():Re("progress.updateProgress",q).then(()=>{ce(q.currentTime,q.duration)&&c.invalidateQueries({queryKey:[K.playerData,n]})}).catch(Z=>console.error("Failed to update progress:",Z)),!0},[a,ne,r,c,n,s,p.continueWatching,u]);j(()=>{const v=()=>{X.current||F(!0)};window.addEventListener("beforeunload",v),window.addEventListener("pagehide",v);const R=()=>{document.visibilityState==="hidden"&&v()};document.addEventListener("visibilitychange",R);const q=m;return()=>{window.removeEventListener("beforeunload",v),window.removeEventListener("pagehide",v),document.removeEventListener("visibilitychange",R),X.current||F(!0),q.current&&clearTimeout(q.current)}},[F]);const xe=E(()=>a.setShowControls(!0),[a]),Te=a.toggleFullscreen,Le=E(()=>{a.togglePlay(),b(!0)},[a,b]),Ne=E(()=>{a.toggleMute(),b(!0)},[a,b]),Pe=E(v=>{a.seekRelative(v),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>F(!1,!0),1500),b(!0)},[a,F,b]),Be=E(()=>{X.current=!1,F(!1,!0)},[F]),Ee=E(()=>{b(!0),F(!1,!0)},[F,b]);j(()=>{X.current=!1,re.current=-1,T.current=0,N.current=Math.random().toString(36).substring(2),a.reset()},[a,n,s]);const Ae=a.reset;j(()=>{const v=N.current;return()=>{dt(v)}},[a,n,s]),j(()=>{if(r!=="iframe")return;F(!1,!0);const v=setInterval(()=>{F(!1,!0)},6e4);return()=>clearInterval(v)},[r,F]);const Ie=E(()=>{const v=u.current;if(!v)return;const R=v.currentTime||0,q=Date.now(),S=ce(R,v.duration)&&!ce(re.current,v.duration);(S||q-T.current>6e4)&&F(!1,S)&&(T.current=q);const W=e.find(J=>R>=J.start_time&&R<J.end_time)||null;I(J=>J?.skip_id!==W?.skip_id?W:J),$&&W&&!v.paused&&!a.getState().playbackLocked&&(a.seek(W.end_time),I(null))},[u,e,$,F,a]),$e=E(()=>{const v=ne();v&&(v.currentTime=v.duration,ut.progress.updateProgress.mutate(v).then(()=>{c.invalidateQueries({queryKey:[K.playerData,n]}),c.invalidateQueries({queryKey:[K.videoSources,n,s]}),c.invalidateQueries({queryKey:[K.continueWatching]})}).catch(R=>console.error("Failed to send final progress:",R)))},[ne,c,n,s]),Me=E(()=>{X.current=!0,$e()},[$e]),it=te(()=>({togglePlay:Le,seek:Pe,toggleMute:Ne,toggleFullscreen:Te,onPlay:Be,onPause:Ee,formatTime:pt,onTimeUpdate:Ie,onEnded:Me,setShowControls:b,setIsAutoSkipEnabled:O,setCurrentSkipInterval:I,setSubtitleFontSize:ye,setSubtitlePosition:be,setSubtitleBgOpacity:ge,setSubtitleBgColor:_e,setSubtitleTextColor:ve,setSubtitleEdge:Se,setSubtitleBold:we,setSubtitleStyle:Ce,setAvailableSubtitles:Ze,setActiveSubtitleTrack:tt,setShowSettings:nt,setShowVolumeSlider:at,flashControls:xe,sendProgressUpdate:F,setUseNativeControls:ke,resetMediaState:Ae}),[Le,Pe,Ne,Te,Be,Ee,Ie,Me,F,ke,Ae,xe,Ce,b]);return{engine:a,refs:{videoRef:u,playerContainerRef:B},state:{playbackLocked:y,isPlaying:_,isMuted:x,volume:g,isFullscreen:C,duration:A,showControls:h,isScrubbing:l,isAutoSkipEnabled:$,currentSkipInterval:V,subtitleFontSize:Ve,subtitlePosition:Ke,subtitleBgOpacity:Ue,subtitleBgColor:Qe,subtitleTextColor:Ge,subtitleEdge:Ye,subtitleBold:Xe,availableSubtitles:Je,activeSubtitleTrack:et,showSettings:rt,showVolumeSlider:st,isBuffering:d,isSpeedBoostActive:f,useNativeControls:ot},actions:it}};function xn(){try{return typeof navigator<"u"&&/android/i.test(navigator.userAgent)}catch{return!1}}function ys(e,n){const{refs:s,actions:o}=e,r=w(n);r.current=n;const i=w(!1),c=w(!1),p=a=>{try{if(a)return a.matches}catch{}try{return window.innerWidth>window.innerHeight}catch{return!1}};j(()=>{if(!xn())return;let a=null;const u=()=>{const _=s.playerContainerRef.current;if(p(a)){if(!r.current||!_||ie(s.videoRef.current)||c.current)return;i.current=!0,o.toggleFullscreen()}else c.current=!1,i.current&&(i.current=!1,ie(s.videoRef.current)&&o.toggleFullscreen())};try{a=window.matchMedia("(orientation: landscape)"),a.addEventListener?a.addEventListener("change",u):a.addListener(u)}catch{}return u(),()=>{try{a&&(a.removeEventListener?a.removeEventListener("change",u):a.removeListener(u))}catch{}}},[o,s.playerContainerRef,s.videoRef,n]),j(()=>{const a=()=>{if(!ie(s.videoRef.current)){i.current=!1;try{window.matchMedia("(orientation: landscape)").matches&&(c.current=!0)}catch{c.current=!0}}};return document.addEventListener("fullscreenchange",a),document.addEventListener("webkitfullscreenchange",a),()=>{document.removeEventListener("fullscreenchange",a),document.removeEventListener("webkitfullscreenchange",a)}},[s.videoRef])}const Tn=e=>Math.max(8,Math.min(40,Math.ceil(e/16.7)+4));function bs({videoRef:e,canvasRef:n,delayMs:s,enabled:o}){const r=w(s);r.current=s;const i=w([]),c=w(-1),p=w(-1),a=w(!1),u=w(0),_=w(null);j(()=>{const x=f=>{if(f)try{f.close()}catch{}},g=()=>{for(const f of i.current)x(f.bitmap);i.current=[]};if(!o){g(),c.current=-1,p.current=-1,a.current=!1,u.current=0;return}let A=!1;const l=()=>{_.current!==null&&(cancelAnimationFrame(_.current),_.current=null)},d=()=>{A||(l(),_.current=requestAnimationFrame(()=>{C()}))};async function C(){if(A)return;const f=e.current,h=n.current;if(!f||!h||f.videoWidth===0){d();return}if(f.paused||f.ended||document.hidden||f.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){d();return}const y=f.getVideoPlaybackQuality().totalVideoFrames;if(y===c.current){d();return}(f.seeking||p.current>=0&&Math.abs(f.currentTime-p.current)>.5)&&(g(),a.current=!1,u.current=0,c.current=-1),p.current=f.currentTime,(h.width!==f.videoWidth||h.height!==f.videoHeight)&&(h.width=f.videoWidth,h.height=f.videoHeight);const B=Math.max(0,r.current||0);B>u.current&&(a.current=!1);try{const m=await createImageBitmap(f);if(A){x(m);return}c.current=y;const T=performance.now(),N=h.getContext("2d"),b=I=>{N&&N.drawImage(I,0,0,h.width,h.height)};if(B<=0){g(),a.current=!1,u.current=0,b(m),x(m),d();return}const $=i.current;$.push({bitmap:m,capture:T});const O=Tn(B);for(;$.length>O;)x($.shift()?.bitmap);let V=-1;for(let I=$.length-1;I>=0;I--)if(T-$[I].capture>=B){V=I;break}if(V!==-1){for(let H=0;H<V;H++)x($.shift()?.bitmap);const I=$.shift();I?(b(I.bitmap),x(I.bitmap),a.current=!0,u.current=B):b(m)}else if(!a.current)b(m);else{const I=$.shift();I?(b(I.bitmap),x(I.bitmap)):b(m)}}catch{}d()}return d(),()=>{A=!0,l();for(const f of i.current)try{f.bitmap.close()}catch{}i.current=[]}},[o,e,n])}const De=(e,n)=>{try{M.setItem("playerVideoDelayMs",String(e)),M.setItem("playerVideoDelayEnabled",String(n))}catch{}},Oe=e=>{try{M.setItem("playerVideoDelayEnabled",String(e))}catch{}};function gs(e,n){const[s,o]=P(()=>{try{const y=Number(M.getItem("playerVideoDelayMs"));if(Number.isFinite(y)&&y>=0&&y<=500)return Math.round(y)}catch{}return 180}),[r,i]=P(()=>{try{return M.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[c,p]=P(!1),[a,u]=P(!1),_=w(null),x=w(null),g=y=>{const B=Math.max(0,Math.min(500,Math.round(y)));o(B);try{M.setItem("playerVideoDelayMs",String(B))}catch{}},A=y=>{i(y),Oe(y)},l=E(()=>{u(!1),p(!1)},[]);return{videoDelayMs:s,videoDelayEnabled:r,setDelayEnabled:A,handleVideoDelayChange:g,isCalibrating:c,testClipActive:a,stopCalibration:l,openAvSyncCalibrator:()=>{_.current={enabled:r,ms:s},i(!0),Oe(!0),n?.(),p(!0)},cancelAvSyncCalibrator:()=>{const y=_.current;_.current=null,y&&(o(y.ms),i(y.enabled),De(y.ms,y.enabled)),u(!1),p(!1)},applyAvSyncCalibrator:()=>{_.current=null,i(!0),De(s,!0),u(!1),p(!1)},toggleTestClip:()=>{if(a){u(!1);return}const y=e.current;y&&!isNaN(y.currentTime)&&(x.current=y.currentTime),u(!0)},calibReturnRef:x,effectiveVideoDelayMs:r?s:0}}function _s(){const[e,n]=P(()=>{try{return M.getItem("playerTheaterMode")==="true"}catch{return!1}});j(()=>{try{e?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(r){console.error(r)}return()=>{try{document.body.classList.remove("theater-mode")}catch(r){console.error(r)}}},[e]);const s=E(()=>{n(r=>{const i=!r;try{M.setItem("playerTheaterMode",i.toString())}catch{}return i})},[]),o=E(r=>{if(e&&r.target===r.currentTarget){n(!1);try{M.setItem("playerTheaterMode","false")}catch{}}},[e]);return{isTheaterMode:e,toggleTheaterMode:s,handleLayoutClick:o}}const Q={enabled:!0,blur:60,saturation:150,brightness:70,opacity:60};function Ln(){try{const e=M.getItem("playerAmbientLight");if(!e)return Q;const n=JSON.parse(e),s=(o,r,i,c)=>{const p=Number(o);return Number.isFinite(p)?Math.max(i,Math.min(c,p)):r};return{enabled:n.enabled??Q.enabled,blur:s(n.blur,Q.blur,0,120),saturation:s(n.saturation,Q.saturation,0,200),brightness:s(n.brightness,Q.brightness,20,120),opacity:s(n.opacity,Q.opacity,10,100)}}catch{return Q}}function vs(){const[e,n]=P(Ln),s=E(o=>{n(r=>{const i={...r,...o};try{M.setItem("playerAmbientLight",JSON.stringify(i))}catch{}return i})},[]);return{settings:e,update:s}}const Nn="_theaterAmbient_x9t0o_1",Pn={theaterAmbient:Nn},de=160,ue=90,Bn=120,Ss=({videoRef:e,active:n,settings:s,className:o})=>{const r=w(null);return j(()=>{if(!n)return;const i=r.current,c=e.current;if(!i||!c)return;const p=i.getContext("2d",{alpha:!1});if(!p)return;let a=0,u=0,_=!1;const x=()=>{if(!(c.readyState<2||!c.videoWidth))try{const d=c.videoWidth,C=c.videoHeight,f=de/ue,h=d/C;let y=d,B=C,m=0,T=0;h>f?(y=C*f,m=(d-y)/2):(B=d/f,T=(C-B)/2),p.drawImage(c,m,T,y,B,0,0,de,ue)}catch{}},g=d=>{_||c.paused||(a=requestAnimationFrame(g),!(d-u<Bn)&&(u=d,x()))},A=()=>{_||(cancelAnimationFrame(a),u=0,a=requestAnimationFrame(g))},l=()=>cancelAnimationFrame(a);return c.addEventListener("play",A),c.addEventListener("pause",l),c.addEventListener("seeked",x),c.addEventListener("loadeddata",x),a=requestAnimationFrame(g),()=>{_=!0,cancelAnimationFrame(a),c.removeEventListener("play",A),c.removeEventListener("pause",l),c.removeEventListener("seeked",x),c.removeEventListener("loadeddata",x)}},[n,e]),n?t("canvas",{ref:r,width:de,height:ue,"aria-hidden":"true",className:o??Pn.theaterAmbient,style:{filter:`blur(${s.blur}px) saturate(${s.saturation}%) brightness(${s.brightness}%)`,opacity:s.opacity/100}}):null},En="_row_1fq55_1",An="_rowHeader_1fq55_9",In="_rowLabel_1fq55_17",$n="_rowValue_1fq55_28",Mn="_slider_1fq55_36",Rn="_swatches_1fq55_99",jn="_swatch_1fq55_99",Fn="_swatchPicked_1fq55_114",Dn="_colorInput_1fq55_120",On="_segmented_1fq55_131",D={row:En,rowHeader:An,rowLabel:In,rowValue:$n,slider:Mn,swatches:Rn,swatch:jn,swatchPicked:Fn,colorInput:Dn,segmented:On},qn=({label:e,display:n,min:s,max:o,step:r,value:i,percent:c,onChange:p,onCommit:a})=>t("div",{className:D.row,children:[t("div",{className:D.rowHeader,children:[t("span",{className:D.rowLabel,children:e}),t("span",{className:D.rowValue,children:n})]}),t("input",{type:"range",className:D.slider,min:s,max:o,step:r,value:i,"aria-label":e,"data-speed-boost-ignore":"true",onInput:u=>p(Number(u.target.value)),onMouseDown:u=>u.stopPropagation(),onPointerDown:u=>u.stopPropagation(),onTouchStart:u=>u.stopPropagation(),onPointerUp:a,onPointerCancel:a,onTouchEnd:a,onKeyUp:a,onBlur:a,style:{"--slider-percent":`${c}%`}})]}),ws=({label:e,colors:n,value:s,onChange:o})=>t("div",{className:D.row,children:[t("div",{className:D.rowHeader,children:t("span",{className:D.rowLabel,children:e})}),t("div",{className:D.swatches,children:[n.map(r=>t("button",{type:"button","aria-label":`${e} ${r}`,"aria-pressed":s.toLowerCase()===r.toLowerCase(),onClick:()=>o(r),className:`${D.swatch} ${s.toLowerCase()===r.toLowerCase()?D.swatchPicked:""}`,style:{backgroundColor:r}},r)),t("input",{type:"color","aria-label":`Custom ${e.toLowerCase()}`,className:D.colorInput,value:s,"data-speed-boost-ignore":"true",onInput:r=>o(r.target.value),onMouseDown:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),onTouchStart:r=>r.stopPropagation()})]})]});function Cs({label:e,options:n,value:s,onChange:o}){return t("div",{className:D.row,children:[t("div",{className:D.rowHeader,children:t("span",{className:D.rowLabel,children:e})}),t("div",{className:D.segmented,role:"group","aria-label":e,children:n.map(r=>t("button",{type:"button","aria-pressed":s===r,onClick:()=>o(r),children:[t("span",{children:r}),s===r&&t(Y,{name:"check",size:10})]},r))})]})}const oe=10,he=500,pe=e=>Math.max(0,Math.min(he,Math.round(e))),ks=({isOpen:e,ms:n,onChange:s,onApply:o,onClose:r,testClipActive:i,onTestClip:c})=>e?t("div",{role:"dialog","aria-label":"Calibrate audio video sync","data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),style:{position:"absolute",right:8,bottom:112,width:"min(260px, calc(100% - 16px))",maxHeight:"calc(100% - 124px)",overflowY:"auto",overflowX:"hidden",zIndex:60,display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:12,borderRadius:"var(--radius-lg)",border:"1px solid var(--glass-border)",background:"rgba(18, 18, 22, 0.95)",boxShadow:"var(--glass-shadow)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxSizing:"border-box"},children:[t("div",{style:{fontSize:"0.8rem",fontWeight:800,color:"var(--text-primary)"},children:"A/V sync"}),t("div",{children:t(G,{size:"sm",variant:"secondary",onClick:c,children:i?"Back to video":"Preview test clip"})}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexWrap:"wrap"},children:[t(G,{size:"sm",onClick:()=>s(pe(n-oe)),"aria-label":"Decrease delay by 10 milliseconds",children:["− ",oe,"ms"]}),t("div",{style:{fontSize:"1.1rem",fontWeight:800,minWidth:64,textAlign:"center"},children:[n,"ms"]}),t(G,{size:"sm",onClick:()=>s(pe(n+oe)),"aria-label":"Increase delay by 10 milliseconds",children:["+ ",oe,"ms"]})]}),t(qn,{label:"Video delay",display:`${n}ms`,min:0,max:he,step:5,value:n,percent:n/he*100,onChange:p=>s(pe(p))}),t("div",{style:{display:"flex",gap:8,justifyContent:"center",flexWrap:"wrap"},children:[t(G,{size:"sm",variant:"secondary",onClick:r,children:"Cancel"}),t(G,{size:"sm",onClick:o,children:["Apply ",n,"ms"]})]})]}):null;function xs({videoRef:e,sourceType:n,resetKey:s,onEnd:o}){const r=w(!1),i=w(o);i.current=o,j(()=>{r.current=!1},[s]);const c=E(()=>{const a=e.current?.duration;!a||!Number.isFinite(a)||console.info(`[playback] duration ${a.toFixed(2)}s`)},[e]);return{checkEnd:E((a=!1)=>{const u=e.current;!u||n==="iframe"||r.current||!a&&!wt(u.currentTime,u.duration)||(r.current=!0,console.info(`[playback] end reached at ${u.currentTime.toFixed(2)}s / ${u.duration.toFixed(2)}s`),i.current())},[n,e]),logDuration:c}}function Ts(e,n,s){const o=ft(),r=w({watch:o,selection:n,loading:s});r.current={watch:o,selection:n,loading:s};const[i,c]=P(!1),p=w(""),a=w(""),u=w(""),_=w(!1),x=!!o.session&&!o.session.host;j(()=>(!o.session&&_.current&&e.applyRemotePlayback(void 0,!1,1),_.current=!!o.session,e.setPlaybackLocked(!!o.session&&(x||!o.connected)),o.session&&!o.connected&&e.applyRemotePlayback(void 0,!1,1),()=>e.setPlaybackLocked(!1)),[e,x,o.connected,o.session]);const g=E((A=!1)=>{const{watch:l,selection:d,loading:C}=r.current,f=e.mediaRef.current;if(!l.session||!l.room||!f)return;if(l.session.host){l.connected&&l.selfId!==u.current&&!C&&d&&f.readyState>=1&&(u.current=l.selfId,je(d,l.room.selection)&&e.applyRemotePlayback(l.room.position,!1,l.room.rate));return}const h=l.room,y=d&&je(d,h.selection);if(!l.connected||C||!y||f.readyState<1){e.applyRemotePlayback(void 0,!1,h.rate);return}const B=Date.now()+l.clock.offset-h.updatedAt<15e3;if(h.playing&&!B){e.applyRemotePlayback(void 0,!1,h.rate);return}const m=h.playing&&h.hostOnline&&B,T=Math.min(f.duration||1/0,mt({...h,playing:m},Date.now()+l.clock.offset)),N=T-f.currentTime,b=Math.abs(N)>(m?1.25:.15),$=m&&!b&&Math.abs(N)>.15?Math.min(4,Math.max(.25,h.rate*(N>0?1.03:.97))):h.rate,O=e.getState().playBlocked;e.applyRemotePlayback(b?T:void 0,m&&(!O||A),$),c(O&&m)},[e]);return j(()=>{if(!o.session)return;const A=()=>{const{watch:m,selection:T,loading:N}=r.current,b=e.mediaRef.current;if(!m.connected||!m.session?.host||!m.room)return;if(!T||N||!b||b.readyState<1){m.room.playing&&m.send({type:"update",...m.room,playing:!1});return}g();const $=e.getState(),O=!b.paused&&!b.ended&&!$.isBuffering,V={type:"update",selection:T,position:b.currentTime+(O?m.clock.latency/1e3*b.playbackRate:0),playing:O,rate:b.playbackRate},I=JSON.stringify(V);!O&&a.current===I||(a.current=I,m.send(V))},l=()=>{const{watch:m,selection:T,loading:N}=r.current,b=e.getState(),$=e.mediaRef.current,O=b.error||!N&&!T?"error":b.playBlocked?"blocked":N||!$||$.readyState<1?"loading":b.isBuffering?"buffering":"ready";m.connected&&`${m.selfId}:${O}`!==p.current&&(p.current=`${m.selfId}:${O}`,m.send({type:"status",status:O})),g()};let d=null;const C=["play","pause","seeked","ratechange","playing","waiting","canplay","ended"];let f;const h=()=>{clearTimeout(f),f=setTimeout(A,100)},y=setInterval(()=>{const m=e.mediaRef.current;d!==m&&(C.forEach(T=>d?.removeEventListener(T,h)),d=m,C.forEach(T=>d?.addEventListener(T,h))),l()},500),B=setInterval(A,3e3);return()=>{clearInterval(y),clearInterval(B),clearTimeout(f),C.forEach(T=>d?.removeEventListener(T,h));const{watch:m}=r.current;m.session?.host&&m.room&&m.connected&&m.send({type:"update",...m.room,playing:!1,position:e.mediaRef.current?.currentTime??m.room.position})}},[e,o.session,g]),j(()=>{g()},[o.room,o.connected,n,s,g]),{needsPlayback:i,enablePlayback:()=>g(!0)}}export{Ss as A,ts as B,is as C,Cs as D,ps as E,U as F,Q as G,qn as M,ls as P,os as R,ws as S,es as T,cs as a,ms as b,Yn as c,Xn as d,ss as e,rs as f,Zn as g,Ts as h,gs as i,bs as j,_s as k,xs as l,ys as m,vs as n,Gn as o,ds as p,as as q,Jn as r,Mr as s,on as t,hs as u,Qn as v,ks as w,us as x,fs as y,ns as z};
|