@serifpersia/dango 3.3.5 → 3.3.6
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-CXx2EIN7.js → AnimeCard-OKU7LaSN.js} +1 -1
- package/client/dist/assets/{AnimeInfo-C6ehrfYW.js → AnimeInfo-BCyLw0yz.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-pgnMg0On.js → AnimeInfoPage-BZWl-TJY.js} +2 -2
- package/client/dist/assets/{Asmr-DfA8xB-U.js → Asmr-4S6uoevp.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-QUNnEh9C.js → AsmrResetProgressModal-C8i6weqW.js} +1 -1
- package/client/dist/assets/{AvSyncCalibrator-C1_iBSyL.css → AvSyncCalibrator-BPa6KaGC.css} +1 -1
- package/client/dist/assets/AvSyncCalibrator-oK6LlG61.js +10 -0
- package/client/dist/assets/{Home-Csx6zT32.js → Home-CQ4Ikeja.js} +1 -1
- package/client/dist/assets/{Insights-MW8oRqeX.js → Insights-DiAo0UAc.js} +1 -1
- package/client/dist/assets/{LibraryListPage-VYaHXgXt.js → LibraryListPage-B0MDTnEc.js} +1 -1
- package/client/dist/assets/{ListeningList-BzbQwmh0.js → ListeningList-Dxkhy6E2.js} +1 -1
- package/client/dist/assets/{Manga-223panCD.js → Manga-pJEpcUpo.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-DBqX-Ord.js → MangaInfoPage-BEQsjTHH.js} +1 -1
- package/client/dist/assets/{MangaReadPage-DuXdVyTd.js → MangaReadPage-C0WAtK-1.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-6C3iaR6g.js → MangaResetProgressModal-WjKH_G_f.js} +1 -1
- package/client/dist/assets/{Mature-3VlywJMR.js → Mature-Ckx99wFj.js} +1 -1
- package/client/dist/assets/{MediaCard-xfJv6irD.js → MediaCard-DszKDA4s.js} +1 -1
- package/client/dist/assets/{Music-DkIeCRq1.js → Music-CU6TBHF5.js} +1 -1
- package/client/dist/assets/{OptionListMenu-JQ_--ggT.js → OptionListMenu-CkK2BvEz.js} +1 -1
- package/client/dist/assets/{Player-Czg_D7FN.js → Player-C3yWQkXb.js} +5 -5
- package/client/dist/assets/{PlayerSettings-KrFECely.js → PlayerSettings-CBdTzo0E.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-BKNDfpCl.js → QueueOptionsButton-DKWi-9kd.js} +1 -1
- package/client/dist/assets/{QueueRail-Cgljhm64.js → QueueRail-DAcIex5B.js} +1 -1
- package/client/dist/assets/{Radio-wbxhaiqy.js → Radio-BhTsgGGd.js} +1 -1
- package/client/dist/assets/{ReadingList-DNJAx_LW.js → ReadingList-BLnkwB--.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-By-iSYwL.js → ResetProgressModal-8mcLXaAb.js} +1 -1
- package/client/dist/assets/{Search-63TcSgOa.js → Search-DxX021dj.js} +1 -1
- package/client/dist/assets/{Settings-BeS0llCE.js → Settings-bSA7BG7h.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-CnE_aoEU.js → SkeletonGrid-Du10CNfq.js} +1 -1
- package/client/dist/assets/{Trackers-ACFHfLXZ.js → Trackers-BXSONaRD.js} +1 -1
- package/client/dist/assets/Tv-C2SWcVzN.css +1 -0
- package/client/dist/assets/Tv-DJTbg4VW.js +4 -0
- package/client/dist/assets/{TvInfo-fFNHV1RJ.js → TvInfo-Z0c1Wh3i.js} +1 -1
- package/client/dist/assets/{TvPopup-DYKTHRrD.js → TvPopup-CP41CncZ.js} +1 -1
- package/client/dist/assets/{TvSearch-CpenLEBz.js → TvSearch-BlqTQYJa.js} +1 -1
- package/client/dist/assets/{TvWatchlist-CTUZAvfa.js → TvWatchlist-COCWPkgh.js} +1 -1
- package/client/dist/assets/{Watchlist-B10pIG1F.js → Watchlist-BHLshSPX.js} +1 -1
- package/client/dist/assets/{hls-Cbou9Eb-.js → hls-B_yo8-yR.js} +1 -1
- package/client/dist/assets/{index-CfvzoNYQ.js → index-lo-bz7f2.js} +2 -2
- package/client/dist/assets/{useAnimeInfoData-D-vEehTG.js → useAnimeInfoData-CbNnHRj8.js} +1 -1
- package/client/dist/assets/{useAsmr-B-3EYd-B.js → useAsmr-BEcgHwxg.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-D9BxuTDg.js → useAsmrPopup-BXD3y2m1.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-DtRKgk2x.js → useMangaLibrary-BXhgN-dl.js} +1 -1
- package/client/dist/assets/{useMangaPopup-BNWJ5pR2.js → useMangaPopup-BvgtZ53s.js} +1 -1
- package/client/dist/assets/{useProviders-jxh6fvMH.js → useProviders-xlftutIo.js} +1 -1
- package/client/dist/assets/{useTv-CP4mofvR.js → useTv-DTqrJEWp.js} +1 -1
- package/client/dist/assets/{useTvLibrary-DeGkJuvp.js → useTvLibrary-BHeWSd1F.js} +1 -1
- package/client/dist/index.html +1 -1
- package/package.json +2 -2
- package/server/package.json +1 -1
- package/client/dist/assets/AvSyncCalibrator-Bs4iejCG.js +0 -10
- package/client/dist/assets/Tv-BCmNLUsp.js +0 -4
- package/client/dist/assets/Tv-CuEl3Iol.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-
|
|
2
|
-
import{g as Dt,h as x,u as r,P as Br,z as Ir,d as q,A as f,q as O,y as Lr,T as ct,n as $r,a as Dr,c as Fr,_ as Or,S as Et}from"./vendor-core-8R2fFbyN.js";import{_ as ur,S as Nt,q as $e,z as Qe,N as Wr,j as Vr,k as Ur,l as Qr,m as qr,d as zr,M as Ae,B as Ze,O as Gr,f as Hr}from"./index-CfvzoNYQ.js";import{u as dr,b as ar,a as Gt}from"./vendor-query-BXRECSI6.js";import{C as Kr,S as jr,U as Yr,a as Jr,p as Ht,s as Xr,l as Zr,u as en,b as tn,c as rn,i as nn,d as ir,f as lr,e as sn,g as on,h as an,r as ln,j as Ue,E as cn,k as un,m as u,n as dn,A as pn,P as mn,o as hn,q as fn}from"./AvSyncCalibrator-Bs4iejCG.js";import{I as W}from"./vendor-icons-CDMuNDeL.js";import{l as vn}from"./hls-Cbou9Eb-.js";import{u as gn}from"./useMatureConsent-CT7-KfzG.js";import{u as bn}from"./useIsMobile-Dm_b6Ob3.js";import{s as et,Q as yn}from"./QueueRail-Cgljhm64.js";import{u as Sn,Q as En}from"./QueueOptionsButton-BKNDfpCl.js";import{u as pr}from"./useProviders-jxh6fvMH.js";import{A as wn}from"./AnimeMetaDetails-BPvv5xIl.js";import{S as kn}from"./SynopsisText-BcpwT5iw.js";import"./vendor-ui-CUDCvRS_.js";const Tn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Cn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Mn=["direct","cookie","embed"],Rn="_controlsOverlay_1b7ea_1",_n="_hidden_1b7ea_21",Nn="_topControls_1b7ea_27",xn="_backBtn_1b7ea_47",Pn="_videoTitleInfo_1b7ea_67",An="_animeTitle_1b7ea_73",Bn="_episodeNumber_1b7ea_81",In="_bottomControls_1b7ea_89",Ln="_progressBarContainer_1b7ea_108",$n="_progressBar_1b7ea_108",Dn="_thumb_1b7ea_127",Fn="_scrubbing_1b7ea_142",On="_watchedBar_1b7ea_146",Wn="_bufferedBar_1b7ea_147",Vn="_timeBubble_1b7ea_185",Un="_skipSegment_1b7ea_219",Qn="_op_1b7ea_229",qn="_ed_1b7ea_232",zn="_recap_1b7ea_235",Gn="_bottomControlsRow_1b7ea_239",Hn="_leftControls_1b7ea_247",Kn="_rightControls_1b7ea_248",jn="_controlBtn_1b7ea_255",Yn="_theaterBtn_1b7ea_296",Jn="_nextEpisodeBtn_1b7ea_300",Xn="_active_1b7ea_317",Zn="_timeDisplay_1b7ea_321",es="_skipControls_1b7ea_329",ts="_skipBtn_1b7ea_335",rs="_volumeContainer_1b7ea_376",ns="_volumeSlider_1b7ea_382",ss="_playerPageLayout_1b7ea_440",os="_videoPlayerWrapper_1b7ea_444",as="_playerInfoContainer_1b7ea_449",is="_visible_1b7ea_566",ls="_shortcuts_1b7ea_584",E={controlsOverlay:Rn,hidden:_n,topControls:Nn,backBtn:xn,videoTitleInfo:Pn,animeTitle:An,episodeNumber:Bn,bottomControls:In,progressBarContainer:Ln,progressBar:$n,thumb:Dn,scrubbing:Fn,watchedBar:On,bufferedBar:Wn,timeBubble:Vn,skipSegment:Un,op:Qn,ed:qn,recap:zn,bottomControlsRow:Gn,leftControls:Hn,rightControls:Kn,controlBtn:jn,theaterBtn:Yn,nextEpisodeBtn:Jn,active:Xn,timeDisplay:Zn,skipControls:es,skipBtn:ts,volumeContainer:rs,volumeSlider:ns,playerPageLayout:ss,videoPlayerWrapper:os,playerInfoContainer:as,visible:is,shortcuts:ls},cs=Ir(()=>ur(()=>import("./PlayerSettings-KrFECely.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),us=({player:n,isAutoplayEnabled:v,onAutoplayChange:w,showNextEpisodeButton:K,onNextEpisode:b,videoSources:C,selectedSource:S,selectedLink:P,onSourceChange:R,skipIntervals:ie,animeTitle:ye,episodeNumber:e,isTheaterMode:g,onTheaterModeToggle:V,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,fallbackChoice:Fe,onFallbackChoiceChange:Be,children:Ie,overlays:ze,isInteractingExtra:ee=!1,className:Re,hideChrome:l=!1})=>{const{state:o,refs:d,actions:p}=n,{showSettings:B}=o,{setShowSettings:Q,setShowVolumeSlider:j}=p,te=Dt.useRef(null),Ee=Dt.useRef(null);x(()=>{const h=_=>{te.current&&!te.current.contains(_.target)&&Ee.current&&!Ee.current.contains(_.target)&&B&&Q(!1)};return B&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[B,Q]);const we=Dt.useRef(null),Ge=h=>{d.videoRef.current&&(d.videoRef.current.volume=h,d.videoRef.current.muted=h===0,localStorage.setItem("playerVolume",h.toString()))},He=h=>{!d.videoRef.current||isNaN(o.duration)||o.duration===0||(d.videoRef.current.currentTime=h*o.duration,p.sendProgressUpdate(!1,!0))},tt=()=>{d.videoRef.current&&(p.setIsScrubbing(!0),p.wasPlayingBeforeScrub.current=!d.videoRef.current.paused,d.videoRef.current.pause())},G=h=>{!d.videoRef.current||!o.duration||(d.videoRef.current.currentTime=h*o.duration)},Ke=()=>{p.setIsScrubbing(!1),p.wasPlayingBeforeScrub.current&&d.videoRef.current?.play()},ut=h=>{if(!d.videoRef.current)return;p.setActiveSubtitleTrack(h);try{if(h===null||h==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const I=o.availableSubtitles.find(Y=>Y.label===h||Y.lang===h);I?localStorage.setItem("playerLastSubtitle",Xr(I)):localStorage.setItem("playerLastSubtitle",h)}}catch{}let _=!1;Array.from(d.videoRef.current.textTracks).forEach(I=>{const nt=h!==null&&h!=="off"&&(I.language===h||I.label===h)&&!_;I.mode=nt?"showing":"hidden",nt&&(_=!0)})},re=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off",pe=()=>{if(!d.videoRef.current)return;if(re){ut("off");return}if(o.availableSubtitles.length===0)return;let h=null;try{h=localStorage.getItem("playerLastSubtitle")}catch{}const _=Ht(o.availableSubtitles,{lastKey:h,enabled:!0});if(_<0)return;const I=o.availableSubtitles[_];ut(I.label||I.lang)},je=()=>o.isMuted||o.volume===0?r(W,{name:"volume-mute"}):o.volume<.5?r(W,{name:"volume-down"}):r(W,{name:"volume-up"}),rt=r("div",{className:`${E.controlsOverlay} ${!o.showControls&&!B&&!o.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:E.topControls,onClick:h=>h.stopPropagation(),children:[r("button",{className:E.backBtn,onClick:h=>{h.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(W,{name:"chevron-left"})}),r("div",{className:E.videoTitleInfo,children:[r("span",{className:E.animeTitle,children:ye}),e&&r("span",{className:E.episodeNumber,children:["Episode ",e]})]})]})}),ht=r(Kr,{isPlaying:o.isPlaying,onTogglePlay:p.togglePlay,onSkipBack:()=>p.seek(-10),onSkipForward:()=>p.seek(10)}),ne=r("div",{className:`${E.controlsOverlay} ${!o.showControls&&!B&&!o.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:E.bottomControls,"data-speed-boost-ignore":"true",onClick:h=>h.stopPropagation(),children:[r(jr,{classes:{container:E.progressBarContainer,scrubbing:E.scrubbing,timeBubble:E.timeBubble,bar:E.progressBar,buffered:E.bufferedBar,watched:E.watchedBar,thumb:E.thumb},videoRef:d.videoRef,duration:o.duration,formatTime:p.formatTime,isScrubbing:o.isScrubbing,onSeek:He,onScrubStart:tt,onScrubMove:G,onScrubEnd:Ke,timeLabelRef:we,children:[o.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${E.skipSegment} ${E[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/o.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/o.duration*100}% `}}),ie.map(h=>{const _=h.start_time/o.duration*100,I=(h.end_time-h.start_time)/o.duration*100;return r("div",{className:`${E.skipSegment} ${E[h.skip_type]} `,style:{left:`${_}% `,width:`${I}% `},title:h.skip_type.toUpperCase()},h.skip_id)})]}),r("div",{className:E.bottomControlsRow,children:[r("div",{className:E.leftControls,children:[r("button",{className:E.controlBtn,onClick:p.togglePlay,"aria-label":o.isPlaying?"Pause":"Play",children:o.isPlaying?r(W,{name:"pause"}):r(W,{name:"play"})}),r(Yr,{muted:o.isMuted,volume:o.volume,volumeIcon:je(),buttonClassName:E.controlBtn,onToggleMute:p.toggleMute,onVolumeChange:Ge,onExpandedChange:h=>j(h)}),r("span",{className:E.timeDisplay,ref:we,children:[p.formatTime(0)," / ",p.formatTime(o.duration)]}),o.currentSkipInterval&&!o.isAutoSkipEnabled&&r("button",{className:E.controlBtn,onClick:()=>{d.videoRef.current&&o.currentSkipInterval&&(d.videoRef.current.currentTime=o.currentSkipInterval.end_time,p.setCurrentSkipInterval(null))},children:["Skip ",o.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:E.rightControls,children:[r("div",{className:E.skipControls,children:K&&r("button",{className:E.nextEpisodeBtn,onClick:b,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${E.controlBtn} ${re?E.active:""}`,onClick:pe,title:re?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(W,{name:"closed-captioning",size:22})}),r("button",{ref:Ee,className:`${E.controlBtn} ${B?E.active:""} `,onClick:()=>Q(!B),"aria-label":"Settings",children:r(W,{name:"cog"})}),r("button",{className:`${E.controlBtn} ${E.theaterBtn} ${g?E.active:""} `,onClick:h=>{h.stopPropagation(),V()},title:g?"Exit Theater Mode":"Theater Mode","aria-label":g?"Exit Theater Mode":"Theater Mode",children:r(W,{name:"tv"})}),r("button",{className:E.controlBtn,onClick:p.toggleFullscreen,"aria-label":o.isFullscreen?"Exit Fullscreen":"Fullscreen",children:o.isFullscreen?r(W,{name:"compress"}):r(W,{name:"expand"})})]})]})]})}),Ye=r(Br,{fallback:null,children:r(cs,{ref:te,isOpen:B,onClose:()=>Q(!1),videoSources:C,currentSource:S,currentLink:P,onSourceChange:R,subtitles:o.availableSubtitles,activeSubtitleTrack:o.activeSubtitleTrack,onSubtitleChange:ut,subtitleSettings:{fontSize:o.subtitleFontSize,position:o.subtitlePosition,bgOpacity:o.subtitleBgOpacity,bgColor:o.subtitleBgColor,textColor:o.subtitleTextColor,edge:o.subtitleEdge,bold:o.subtitleBold},onSubtitleSettingsChange:(h,_)=>{const I=(Y,nt)=>{try{localStorage.setItem(Y,String(nt))}catch{}};switch(h){case"fontSize":p.setSubtitleFontSize(_),I("subtitleFontSize",_);break;case"position":p.setSubtitlePosition(_),I("subtitlePosition",_);break;case"bgOpacity":p.setSubtitleBgOpacity(_),I("subtitleBgOpacity",_);break;case"bgColor":p.setSubtitleBgColor(_),I("subtitleBgColor",_);break;case"textColor":p.setSubtitleTextColor(_),I("subtitleTextColor",_);break;case"edge":p.setSubtitleEdge(_),I("subtitleEdge",_);break;case"bold":p.setSubtitleBold(_),I("subtitleBold",_);break}},useNativeControls:o.useNativeControls,onNativeControlsToggle:p.setUseNativeControls,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,isAutoSkipEnabled:o.isAutoSkipEnabled,onAutoSkipChange:h=>{p.setIsAutoSkipEnabled(h);try{localStorage.setItem("autoSkipEnabled",h.toString())}catch{}},isAutoplayEnabled:v,onAutoplayChange:w,fallbackChoice:Fe,onFallbackChoiceChange:Be})});return r(Jr,{player:n,topBar:rt,centerControls:ht,bottomBar:ne,settingsPanel:Ye,overlays:ze,isInteracting:ee,className:Re,chromeDisabled:l,children:Ie})},ds=({count:n=3})=>r("section",{className:et.section,children:[r("div",{className:et.header,children:r("button",{className:et.headerToggle,disabled:!0,children:[r("span",{className:et.title,children:r(Nt,{width:"60px",height:"1.2rem",variant:"text"})}),r(W,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:et.list,children:Array.from({length:n}).map((v,w)=>r("div",{className:et.item,style:{pointerEvents:"none"},children:[r("div",{className:et.dragHandle,style:{opacity:.2},children:r(Nt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:et.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(Nt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:et.meta,children:[r(Nt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(Nt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},w))})]}),ps="_sourceSelectionContainer_c5tub_76",ms="_providerSelectContainer_c5tub_89",hs="_providerSelect_c5tub_89",fs="_sourceSelect_c5tub_76",vs="_sourceButtons_c5tub_145",gs="_sourceButton_c5tub_145",bs="_active_c5tub_170",mt={sourceSelectionContainer:ps,providerSelectContainer:ms,providerSelect:hs,sourceSelect:fs,sourceButtons:vs,sourceButton:gs,active:bs},ys=({selectedProvider:n,onProviderChange:v,isAdult:w,options:K})=>{const b=K&&K.length>0?K:[],C=w===void 0?b:b.filter(S=>S.mature===w);return r("div",{className:mt.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:mt.providerSelect,value:n,onChange:S=>v(S.target.value),children:Mn.map(S=>{const P=C.filter(R=>(R.tier??"direct")===S);return P.length===0?null:r("optgroup",{label:Cn[S],children:P.map(R=>r("option",{value:R.value,children:R.sub?`${R.label} (${Tn[R.sub]})`:R.label},R.value))},S)})})]})},Ss=({videoSources:n,selectedSource:v,selectedLink:w,onSourceChange:K,onLinkChange:b})=>{const C=Array.isArray(n)?n:[];if(C.length===0)return null;const S=v?.type==="iframe"&&(v.links?.length??0)>1;return r("div",{className:mt.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:mt.sourceButtons,children:C.map((P,R)=>r("button",{className:`${mt.sourceButton} ${v?.sourceName===P.sourceName?mt.active:""} `,onClick:()=>K(P),children:P.sourceName},`${P.sourceName}-${R}`))}),S&&r("select",{className:mt.sourceSelect,"aria-label":"Fallback embed quality",value:w?.link??v.links[0]?.link??"",onChange:P=>{const R=v.links.find(ie=>ie.link===P.target.value);R&&b(R)},children:v.links.map(P=>r("option",{value:P.link,children:P.resolutionStr},P.link))})]})},Es=Dt.memo(Ss,(n,v)=>n.selectedSource?.sourceName===v.selectedSource?.sourceName&&n.selectedLink?.link===v.selectedLink?.link&&n.videoSources===v.videoSources),ws={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}},ks={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Ts=5,Cs=15e3,Ms=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-CBdTzo0E.js","assets/vendor-core-8R2fFbyN.js","assets/vendor-icons-CDMuNDeL.js","assets/OptionListMenu-CkK2BvEz.js","assets/AvSyncCalibrator-oK6LlG61.js","assets/index-lo-bz7f2.js","assets/vendor-query-BXRECSI6.js","assets/index-CUm1meqr.css","assets/AvSyncCalibrator-BPa6KaGC.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as Dt,h as x,u as r,P as Br,z as Ir,d as q,A as f,q as O,y as Lr,T as ct,n as $r,a as Dr,c as Fr,_ as Or,S as Et}from"./vendor-core-8R2fFbyN.js";import{_ as ur,S as Nt,q as $e,z as Qe,N as Wr,j as Vr,k as Ur,l as Qr,m as qr,d as zr,M as Ae,B as Ze,O as Gr,f as Hr}from"./index-lo-bz7f2.js";import{u as dr,b as ar,a as Gt}from"./vendor-query-BXRECSI6.js";import{C as Kr,S as jr,U as Yr,a as Jr,p as Ht,s as Xr,l as Zr,u as en,b as tn,i as rn,c as nn,d as ir,f as lr,e as sn,g as on,h as an,r as ln,j as Ue,E as cn,k as un,m as u,n as dn,A as pn,P as mn,o as hn,q as fn}from"./AvSyncCalibrator-oK6LlG61.js";import{I as W}from"./vendor-icons-CDMuNDeL.js";import{l as vn}from"./hls-B_yo8-yR.js";import{u as gn}from"./useMatureConsent-CT7-KfzG.js";import{u as bn}from"./useIsMobile-Dm_b6Ob3.js";import{s as et,Q as yn}from"./QueueRail-DAcIex5B.js";import{u as Sn,Q as En}from"./QueueOptionsButton-DKWi-9kd.js";import{u as pr}from"./useProviders-xlftutIo.js";import{A as wn}from"./AnimeMetaDetails-BPvv5xIl.js";import{S as kn}from"./SynopsisText-BcpwT5iw.js";import"./vendor-ui-CUDCvRS_.js";const Tn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Cn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Mn=["direct","cookie","embed"],Rn="_controlsOverlay_1b7ea_1",_n="_hidden_1b7ea_21",Nn="_topControls_1b7ea_27",xn="_backBtn_1b7ea_47",Pn="_videoTitleInfo_1b7ea_67",An="_animeTitle_1b7ea_73",Bn="_episodeNumber_1b7ea_81",In="_bottomControls_1b7ea_89",Ln="_progressBarContainer_1b7ea_108",$n="_progressBar_1b7ea_108",Dn="_thumb_1b7ea_127",Fn="_scrubbing_1b7ea_142",On="_watchedBar_1b7ea_146",Wn="_bufferedBar_1b7ea_147",Vn="_timeBubble_1b7ea_185",Un="_skipSegment_1b7ea_219",Qn="_op_1b7ea_229",qn="_ed_1b7ea_232",zn="_recap_1b7ea_235",Gn="_bottomControlsRow_1b7ea_239",Hn="_leftControls_1b7ea_247",Kn="_rightControls_1b7ea_248",jn="_controlBtn_1b7ea_255",Yn="_theaterBtn_1b7ea_296",Jn="_nextEpisodeBtn_1b7ea_300",Xn="_active_1b7ea_317",Zn="_timeDisplay_1b7ea_321",es="_skipControls_1b7ea_329",ts="_skipBtn_1b7ea_335",rs="_volumeContainer_1b7ea_376",ns="_volumeSlider_1b7ea_382",ss="_playerPageLayout_1b7ea_440",os="_videoPlayerWrapper_1b7ea_444",as="_playerInfoContainer_1b7ea_449",is="_visible_1b7ea_566",ls="_shortcuts_1b7ea_584",E={controlsOverlay:Rn,hidden:_n,topControls:Nn,backBtn:xn,videoTitleInfo:Pn,animeTitle:An,episodeNumber:Bn,bottomControls:In,progressBarContainer:Ln,progressBar:$n,thumb:Dn,scrubbing:Fn,watchedBar:On,bufferedBar:Wn,timeBubble:Vn,skipSegment:Un,op:Qn,ed:qn,recap:zn,bottomControlsRow:Gn,leftControls:Hn,rightControls:Kn,controlBtn:jn,theaterBtn:Yn,nextEpisodeBtn:Jn,active:Xn,timeDisplay:Zn,skipControls:es,skipBtn:ts,volumeContainer:rs,volumeSlider:ns,playerPageLayout:ss,videoPlayerWrapper:os,playerInfoContainer:as,visible:is,shortcuts:ls},cs=Ir(()=>ur(()=>import("./PlayerSettings-CBdTzo0E.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),us=({player:n,isAutoplayEnabled:v,onAutoplayChange:w,showNextEpisodeButton:K,onNextEpisode:b,videoSources:C,selectedSource:S,selectedLink:P,onSourceChange:R,skipIntervals:ie,animeTitle:ye,episodeNumber:e,isTheaterMode:g,onTheaterModeToggle:V,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,fallbackChoice:Fe,onFallbackChoiceChange:Be,children:Ie,overlays:ze,isInteractingExtra:ee=!1,className:Re,hideChrome:l=!1})=>{const{state:o,refs:d,actions:p}=n,{showSettings:B}=o,{setShowSettings:Q,setShowVolumeSlider:j}=p,te=Dt.useRef(null),Ee=Dt.useRef(null);x(()=>{const h=_=>{te.current&&!te.current.contains(_.target)&&Ee.current&&!Ee.current.contains(_.target)&&B&&Q(!1)};return B&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[B,Q]);const we=Dt.useRef(null),Ge=h=>{d.videoRef.current&&(d.videoRef.current.volume=h,d.videoRef.current.muted=h===0,localStorage.setItem("playerVolume",h.toString()))},He=h=>{!d.videoRef.current||isNaN(o.duration)||o.duration===0||(d.videoRef.current.currentTime=h*o.duration,p.sendProgressUpdate(!1,!0))},tt=()=>{d.videoRef.current&&(p.setIsScrubbing(!0),p.wasPlayingBeforeScrub.current=!d.videoRef.current.paused,d.videoRef.current.pause())},G=h=>{!d.videoRef.current||!o.duration||(d.videoRef.current.currentTime=h*o.duration)},Ke=()=>{p.setIsScrubbing(!1),p.wasPlayingBeforeScrub.current&&d.videoRef.current?.play()},ut=h=>{if(!d.videoRef.current)return;p.setActiveSubtitleTrack(h);try{if(h===null||h==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const I=o.availableSubtitles.find(Y=>Y.label===h||Y.lang===h);I?localStorage.setItem("playerLastSubtitle",Xr(I)):localStorage.setItem("playerLastSubtitle",h)}}catch{}let _=!1;Array.from(d.videoRef.current.textTracks).forEach(I=>{const nt=h!==null&&h!=="off"&&(I.language===h||I.label===h)&&!_;I.mode=nt?"showing":"hidden",nt&&(_=!0)})},re=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off",pe=()=>{if(!d.videoRef.current)return;if(re){ut("off");return}if(o.availableSubtitles.length===0)return;let h=null;try{h=localStorage.getItem("playerLastSubtitle")}catch{}const _=Ht(o.availableSubtitles,{lastKey:h,enabled:!0});if(_<0)return;const I=o.availableSubtitles[_];ut(I.label||I.lang)},je=()=>o.isMuted||o.volume===0?r(W,{name:"volume-mute"}):o.volume<.5?r(W,{name:"volume-down"}):r(W,{name:"volume-up"}),rt=r("div",{className:`${E.controlsOverlay} ${!o.showControls&&!B&&!o.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:E.topControls,onClick:h=>h.stopPropagation(),children:[r("button",{className:E.backBtn,onClick:h=>{h.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(W,{name:"chevron-left"})}),r("div",{className:E.videoTitleInfo,children:[r("span",{className:E.animeTitle,children:ye}),e&&r("span",{className:E.episodeNumber,children:["Episode ",e]})]})]})}),ft=r(Kr,{isPlaying:o.isPlaying,onTogglePlay:p.togglePlay,onSkipBack:()=>p.seek(-10),onSkipForward:()=>p.seek(10)}),ne=r("div",{className:`${E.controlsOverlay} ${!o.showControls&&!B&&!o.isScrubbing?E.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:E.bottomControls,"data-speed-boost-ignore":"true",onClick:h=>h.stopPropagation(),children:[r(jr,{classes:{container:E.progressBarContainer,scrubbing:E.scrubbing,timeBubble:E.timeBubble,bar:E.progressBar,buffered:E.bufferedBar,watched:E.watchedBar,thumb:E.thumb},videoRef:d.videoRef,duration:o.duration,formatTime:p.formatTime,isScrubbing:o.isScrubbing,onSeek:He,onScrubStart:tt,onScrubMove:G,onScrubEnd:Ke,timeLabelRef:we,children:[o.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${E.skipSegment} ${E[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/o.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/o.duration*100}% `}}),ie.map(h=>{const _=h.start_time/o.duration*100,I=(h.end_time-h.start_time)/o.duration*100;return r("div",{className:`${E.skipSegment} ${E[h.skip_type]} `,style:{left:`${_}% `,width:`${I}% `},title:h.skip_type.toUpperCase()},h.skip_id)})]}),r("div",{className:E.bottomControlsRow,children:[r("div",{className:E.leftControls,children:[r("button",{className:E.controlBtn,onClick:p.togglePlay,"aria-label":o.isPlaying?"Pause":"Play",children:o.isPlaying?r(W,{name:"pause"}):r(W,{name:"play"})}),r(Yr,{muted:o.isMuted,volume:o.volume,volumeIcon:je(),buttonClassName:E.controlBtn,onToggleMute:p.toggleMute,onVolumeChange:Ge,onExpandedChange:h=>j(h)}),r("span",{className:E.timeDisplay,ref:we,children:[p.formatTime(0)," / ",p.formatTime(o.duration)]}),o.currentSkipInterval&&!o.isAutoSkipEnabled&&r("button",{className:E.controlBtn,onClick:()=>{d.videoRef.current&&o.currentSkipInterval&&(d.videoRef.current.currentTime=o.currentSkipInterval.end_time,p.setCurrentSkipInterval(null))},children:["Skip ",o.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:E.rightControls,children:[r("div",{className:E.skipControls,children:K&&r("button",{className:E.nextEpisodeBtn,onClick:b,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${E.controlBtn} ${re?E.active:""}`,onClick:pe,title:re?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(W,{name:"closed-captioning",size:22})}),r("button",{ref:Ee,className:`${E.controlBtn} ${B?E.active:""} `,onClick:()=>Q(!B),"aria-label":"Settings",children:r(W,{name:"cog"})}),r("button",{className:`${E.controlBtn} ${E.theaterBtn} ${g?E.active:""} `,onClick:h=>{h.stopPropagation(),V()},title:g?"Exit Theater Mode":"Theater Mode","aria-label":g?"Exit Theater Mode":"Theater Mode",children:r(W,{name:"tv"})}),r("button",{className:E.controlBtn,onClick:p.toggleFullscreen,"aria-label":o.isFullscreen?"Exit Fullscreen":"Fullscreen",children:o.isFullscreen?r(W,{name:"compress"}):r(W,{name:"expand"})})]})]})]})}),Ye=r(Br,{fallback:null,children:r(cs,{ref:te,isOpen:B,onClose:()=>Q(!1),videoSources:C,currentSource:S,currentLink:P,onSourceChange:R,subtitles:o.availableSubtitles,activeSubtitleTrack:o.activeSubtitleTrack,onSubtitleChange:ut,subtitleSettings:{fontSize:o.subtitleFontSize,position:o.subtitlePosition,bgOpacity:o.subtitleBgOpacity,bgColor:o.subtitleBgColor,textColor:o.subtitleTextColor,edge:o.subtitleEdge,bold:o.subtitleBold},onSubtitleSettingsChange:(h,_)=>{const I=(Y,nt)=>{try{localStorage.setItem(Y,String(nt))}catch{}};switch(h){case"fontSize":p.setSubtitleFontSize(_),I("subtitleFontSize",_);break;case"position":p.setSubtitlePosition(_),I("subtitlePosition",_);break;case"bgOpacity":p.setSubtitleBgOpacity(_),I("subtitleBgOpacity",_);break;case"bgColor":p.setSubtitleBgColor(_),I("subtitleBgColor",_);break;case"textColor":p.setSubtitleTextColor(_),I("subtitleTextColor",_);break;case"edge":p.setSubtitleEdge(_),I("subtitleEdge",_);break;case"bold":p.setSubtitleBold(_),I("subtitleBold",_);break}},useNativeControls:o.useNativeControls,onNativeControlsToggle:p.setUseNativeControls,anime4kEnabled:U,onAnime4kToggle:le,anime4kSupported:z,anime4kProfile:ve,onAnime4kProfileChange:A,anime4kInitializing:$,anime4kError:De,videoDelayEnabled:qe,onVideoDelayToggle:a,videoDelayMs:m,onVideoDelayChange:k,onCalibrateAvSync:Se,isAutoSkipEnabled:o.isAutoSkipEnabled,onAutoSkipChange:h=>{p.setIsAutoSkipEnabled(h);try{localStorage.setItem("autoSkipEnabled",h.toString())}catch{}},isAutoplayEnabled:v,onAutoplayChange:w,fallbackChoice:Fe,onFallbackChoiceChange:Be})});return r(Jr,{player:n,topBar:rt,centerControls:ft,bottomBar:ne,settingsPanel:Ye,overlays:ze,isInteracting:ee,className:Re,chromeDisabled:l,children:Ie})},ds=({count:n=3})=>r("section",{className:et.section,children:[r("div",{className:et.header,children:r("button",{className:et.headerToggle,disabled:!0,children:[r("span",{className:et.title,children:r(Nt,{width:"60px",height:"1.2rem",variant:"text"})}),r(W,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:et.list,children:Array.from({length:n}).map((v,w)=>r("div",{className:et.item,style:{pointerEvents:"none"},children:[r("div",{className:et.dragHandle,style:{opacity:.2},children:r(Nt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:et.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(Nt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:et.meta,children:[r(Nt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(Nt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},w))})]}),ps="_sourceSelectionContainer_c5tub_76",ms="_providerSelectContainer_c5tub_89",hs="_providerSelect_c5tub_89",fs="_sourceSelect_c5tub_76",vs="_sourceButtons_c5tub_145",gs="_sourceButton_c5tub_145",bs="_active_c5tub_170",ht={sourceSelectionContainer:ps,providerSelectContainer:ms,providerSelect:hs,sourceSelect:fs,sourceButtons:vs,sourceButton:gs,active:bs},ys=({selectedProvider:n,onProviderChange:v,isAdult:w,options:K})=>{const b=K&&K.length>0?K:[],C=w===void 0?b:b.filter(S=>S.mature===w);return r("div",{className:ht.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:ht.providerSelect,value:n,onChange:S=>v(S.target.value),children:Mn.map(S=>{const P=C.filter(R=>(R.tier??"direct")===S);return P.length===0?null:r("optgroup",{label:Cn[S],children:P.map(R=>r("option",{value:R.value,children:R.sub?`${R.label} (${Tn[R.sub]})`:R.label},R.value))},S)})})]})},Ss=({videoSources:n,selectedSource:v,selectedLink:w,onSourceChange:K,onLinkChange:b})=>{const C=Array.isArray(n)?n:[];if(C.length===0)return null;const S=v?.type==="iframe"&&(v.links?.length??0)>1;return r("div",{className:ht.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:ht.sourceButtons,children:C.map((P,R)=>r("button",{className:`${ht.sourceButton} ${v?.sourceName===P.sourceName?ht.active:""} `,onClick:()=>K(P),children:P.sourceName},`${P.sourceName}-${R}`))}),S&&r("select",{className:ht.sourceSelect,"aria-label":"Fallback embed quality",value:w?.link??v.links[0]?.link??"",onChange:P=>{const R=v.links.find(ie=>ie.link===P.target.value);R&&b(R)},children:v.links.map(P=>r("option",{value:P.link,children:P.resolutionStr},P.link))})]})},Es=Dt.memo(Ss,(n,v)=>n.selectedSource?.sourceName===v.selectedSource?.sourceName&&n.selectedLink?.link===v.selectedLink?.link&&n.videoSources===v.videoSources),ws={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}},ks={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Ts=5,Cs=15e3,Ms=`
|
|
3
3
|
@group(0) @binding(0) var extTex: texture_external;
|
|
4
4
|
@group(0) @binding(1) var extSamp: sampler;
|
|
5
5
|
struct VSOut {
|
|
@@ -25,7 +25,7 @@ import{g as Dt,h as x,u as r,P as Br,z as Ir,d as q,A as f,q as O,y as Lr,T as c
|
|
|
25
25
|
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
26
26
|
return textureSampleBaseClampToEdge(extTex, extSamp, uv);
|
|
27
27
|
}
|
|
28
|
-
`;function Rs({videoRef:n,canvasRef:v,profile:w="balanced",delayMs:K=0}){const[b,C]=q(!1),[S,P]=q(!1),[R,ie]=q(!1),[ye,e]=q(null),[g,V]=q(0),U=f(0),le=f(null),z=f(null),ve=f(null),A=f(null),$=f(null),De=f(null),qe=f(null),a=f(null),m=f(null),k=f(!1),Se=f(-1),Fe=f(0),Be=f(K);Be.current=K;const Ie=f([]),ze=f(!1),ee=f(!1),Re=f(!1),l=f(null),o=f(-1),d=f(-1),p=f(!1),B=f(0);x(()=>{async function j(){if(typeof navigator>"u"||!navigator.gpu){C(!1);return}try{const te=await navigator.gpu.requestAdapter();C(!!te)}catch{C(!1)}}j()},[]),x(()=>{if(!S||!b)return;let j=!1;const te=++U.current,Ee=G=>{if(G)try{G.close()}catch{}},we=()=>{for(const G of Ie.current)Ee(G.bitmap);Ie.current=[]},Ge=G=>Math.max(8,Math.min(40,Math.ceil(G/16.7)+4));function He(){m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}async function tt(){let G=n.current;const Ke=v.current;if(!G||!Ke||U.current!==te)return;const ut=performance.now()+Cs;for(;(!G||G.videoWidth===0)&&performance.now()<ut;){if(await new Promise(Y=>requestAnimationFrame(Y)),j||U.current!==te)return;G=n.current}if(!G||G.videoWidth===0){!j&&U.current===te&&(e("Timed out waiting for video metadata"),ie(!1),P(!1));return}const re=G.videoWidth,pe=G.videoHeight,je=Math.max(re,pe),rt=window.innerWidth,
|
|
28
|
+
`;function Rs({videoRef:n,canvasRef:v,profile:w="balanced",delayMs:K=0}){const[b,C]=q(!1),[S,P]=q(!1),[R,ie]=q(!1),[ye,e]=q(null),[g,V]=q(0),U=f(0),le=f(null),z=f(null),ve=f(null),A=f(null),$=f(null),De=f(null),qe=f(null),a=f(null),m=f(null),k=f(!1),Se=f(-1),Fe=f(0),Be=f(K);Be.current=K;const Ie=f([]),ze=f(!1),ee=f(!1),Re=f(!1),l=f(null),o=f(-1),d=f(-1),p=f(!1),B=f(0);x(()=>{async function j(){if(typeof navigator>"u"||!navigator.gpu){C(!1);return}try{const te=await navigator.gpu.requestAdapter();C(!!te)}catch{C(!1)}}j()},[]),x(()=>{if(!S||!b)return;let j=!1;const te=++U.current,Ee=G=>{if(G)try{G.close()}catch{}},we=()=>{for(const G of Ie.current)Ee(G.bitmap);Ie.current=[]},Ge=G=>Math.max(8,Math.min(40,Math.ceil(G/16.7)+4));function He(){m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}async function tt(){let G=n.current;const Ke=v.current;if(!G||!Ke||U.current!==te)return;const ut=performance.now()+Cs;for(;(!G||G.videoWidth===0)&&performance.now()<ut;){if(await new Promise(Y=>requestAnimationFrame(Y)),j||U.current!==te)return;G=n.current}if(!G||G.videoWidth===0){!j&&U.current===te&&(e("Timed out waiting for video metadata"),ie(!1),P(!1));return}const re=G.videoWidth,pe=G.videoHeight,je=Math.max(re,pe),rt=window.innerWidth,ft=window.innerHeight,ne=Math.max(rt,ft),Ye=je<ne?ne/je:1,h=ws[w],_=je<=480?h.sd:je<=720?h.hd:je<=1080?h.fhd:1,I=Math.min(_,Ye);Ke.width=Math.round(re*I),Ke.height=Math.round(pe*I),ie(!0),e(null),Fe.current=0,Se.current=-1,k.current=!1;try{let Y=function(){j||U.current!==te||(He(),m.current=requestAnimationFrame(()=>{dt()}))};const{ModeA:nt,ModeB:wt,ModeC:st,ModeAA:ot}=await ur(async()=>{const{ModeA:L,ModeB:ce,ModeC:Ne,ModeAA:D}=await import("./index-BOKlZEHq.js").then(ue=>ue.i);return{ModeA:L,ModeB:ce,ModeC:Ne,ModeAA:D}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const kt=await navigator.gpu.requestAdapter();if(!kt)throw new Error("No GPU adapter found");const M=await kt.requestDevice();if(!M)throw new Error("Failed to get GPU device");const Oe=Ke.getContext("webgpu");if(!Oe)throw new Error("Failed to get WebGPU context");const at=navigator.gpu.getPreferredCanvasFormat();Oe.configure({device:M,format:at,alphaMode:"premultiplied"});const me=M.createTexture({size:[re,pe],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Je=ks[w],ke=Math.round(re*I),Le=Math.round(pe*I),vt=(()=>{switch(Je){case"ModeB":return new wt({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});case"ModeC":return new st({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});case"ModeAA":return new ot({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}});default:return new nt({device:M,inputTexture:me,nativeDimensions:{width:re,height:pe},targetDimensions:{width:ke,height:Le}})}})(),_e=vt.getOutputTexture(),gt=M.createSampler({magFilter:"linear",minFilter:"linear"}),bt=M.createShaderModule({code:`
|
|
29
29
|
@group(0) @binding(0) var tex: texture_2d<f32>;
|
|
30
30
|
@group(0) @binding(1) var samp: sampler;
|
|
31
31
|
struct VertexOutput {
|
|
@@ -51,6 +51,6 @@ import{g as Dt,h as x,u as r,P as Br,z as Ir,d as q,A as f,q as O,y as Lr,T as c
|
|
|
51
51
|
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
52
52
|
return textureSample(tex, samp, uv);
|
|
53
53
|
}
|
|
54
|
-
`}),Xe=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Tt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[Xe]}),vertex:{module:gt,entryPoint:"vs"},fragment:{module:gt,entryPoint:"fs",targets:[{format:at}]},primitive:{topology:"triangle-list"}}),Ct=M.createBindGroup({layout:Xe,entries:[{binding:0,resource:_e.createView()},{binding:1,resource:vt}]});try{const L=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),ce=M.createShaderModule({code:Ms}),Ne=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[L]}),vertex:{module:ce,entryPoint:"vs"},fragment:{module:ce,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});l.current={pipeline:Ne,layout:L,inputView:me.createView()}}catch{l.current=null}if(U.current!==te){me.destroy(),M.destroy();return}le.current=M,z.current=Oe,ve.current=ft,A.current=me,$.current=_e,De.current=Tt,qe.current=vt,a.current=Xe,ee.current=!1,Re.current=!1;async function Ft(){const L=l.current;if(!L||ee.current)return!1;const ce=n.current;if(!ce)return!1;const Ne=!Re.current;Ne&&M.pushErrorScope("validation");try{const D=M.importExternalTexture({source:ce}),ue=M.createBindGroup({layout:L.layout,entries:[{binding:0,resource:D},{binding:1,resource:vt}]}),Te=M.createCommandEncoder(),T=Te.beginRenderPass({colorAttachments:[{view:L.inputView,loadOp:"load",storeOp:"store"}]});T.setPipeline(L.pipeline),T.setBindGroup(0,ue),T.draw(6),T.end(),M.queue.submit([Te.finish()])}catch{return ee.current=!0,l.current=null,!1}if(Ne){const D=await M.popErrorScope().catch(()=>null);if(D)return console.warn("[anime4k] blit probe failed:",D.message),ee.current=!0,l.current=null,!1;Re.current=!0}return!0}ie(!1);async function dt(){if(j||U.current!==te)return;const L=n.current;if(!L||L.videoWidth===0){Y();return}if(L!==G||L.videoWidth!==re||L.videoHeight!==pe){V(ue=>ue+1);return}if(L.paused||L.ended||document.hidden||L.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){Y();return}const ce=L.getVideoPlaybackQuality().totalVideoFrames;if(ce===d.current){Y();return}if(k.current){Y();return}const Ne=L.currentTime;(L.seeking||o.current>=0&&Math.abs(Ne-o.current)>.5)&&(we(),p.current=!1,B.current=0,d.current=-1),o.current=Ne;const D=Math.max(0,Be.current||0);D>B.current&&(p.current=!1),k.current=!0;try{const ue=performance.now();let Te=null,T=!1;if(D<=0){Ie.current.length>0&&we(),p.current=!1,B.current=0;let Ce=!1;if(!ze.current)try{M.queue.copyExternalImageToTexture({source:L},{texture:me},[re,pe]),d.current=ce,Ce=!0}catch(he){if(he instanceof TypeError)ze.current=!0;else throw he}if(!Ce&&!ee.current&&l.current&&await Ft()&&(d.current=ce,Ce=!0),!Ce){const he=await createImageBitmap(L);d.current=ce,M.queue.copyExternalImageToTexture({source:he},{texture:me},[re,pe]),Ee(he)}}else{const Ce=await createImageBitmap(L);d.current=ce;const he=Ie.current;he.push({bitmap:Ce,capture:ue});const Ot=Ge(D);for(;he.length>Ot;)Ee(he.shift()?.bitmap);let se=-1;for(let ge=he.length-1;ge>=0;ge--)if(ue-he[ge].capture>=D){se=ge;break}if(se!==-1){for(let Ve=0;Ve<se;Ve++)Ee(he.shift()?.bitmap);const ge=he.shift();ge?(Te=ge.bitmap,p.current=!0,B.current=D):(Te=Ce,T=!0)}else if(!p.current)Te=Ce,T=!0;else{const ge=he.shift();Te=ge?ge.bitmap:Ce,ge||(T=!0)}if(!Te){k.current=!1,Y();return}M.queue.copyExternalImageToTexture({source:Te},{texture:me},[re,pe]),T||Ee(Te)}const Mt=M.createCommandEncoder();await ft.pass(Mt);const We=Mt.beginRenderPass({colorAttachments:[{view:Oe.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(Tt),We.setBindGroup(0,Ct),We.draw(6),We.end(),M.queue.submit([Mt.finish()]),Se.current=ce,Fe.current=0,M.queue.onSubmittedWorkDone().then(()=>{U.current===te&&(k.current=!1)})}catch(ue){if(k.current=!1,Fe.current+=1,Fe.current>=Ts&&!j&&U.current===te){console.error(ue),e(ue instanceof Error?ue.message:"Render error"),P(!1);return}}Y()}Y()}catch(Y){!j&&U.current===te&&(e(Y instanceof Error?Y.message:"Failed to initialize upscaler"),ie(!1),P(!1))}}return tt(),()=>{j=!0,U.current+=1,He(),we(),A.current&&(A.current.destroy(),A.current=null),$.current&&($.current.destroy(),$.current=null),le.current&&(le.current.destroy(),le.current=null),ve.current=null,De.current=null,qe.current=null,a.current=null,l.current=null,z.current=null,k.current=!1}},[S,b,n,v,w,g]);const Q=O(()=>{P(j=>!j)},[]);return{isWebGPUSupported:b,isEnabled:S,isInitializing:R,error:ye,toggle:Q}}const _s=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ns=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},mr=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:_s(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,forceNativePlayer:localStorage.getItem("forceNativePlayer")==="true",isAutoplayEnabled:Zr(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ns(),loadingShowData:!0,loadingVideo:!1,loadingDetails:!1,error:null,detailsError:null,showCookieModal:!1,cookieProvider:null});mr();function xs(n,v){switch(v.type){case"SET_STATE":return{...n,...v.payload};case"SET_MODE":return{...n,currentMode:v.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:v.payload};case"SET_OVERRIDE_SOURCE":return{...n,selectedSource:v.payload?.source??null,selectedLink:v.payload?.link??null};default:return n}}async function cr(n,v,w,K,b=!1){if(!n||!v)throw new Error("Missing params");try{const[C,S,P,R]=await Promise.all([$e(`/api/video?showId=${n}&episodeNumber=${v}&mode=${w.currentMode}&provider=${w.selectedProvider}`).catch(()=>null),$e(`/api/episode-progress/${n}/${v}`).catch(()=>null),$e("/api/settings?key=preferredSource").catch(()=>null),$e(`/api/skip-times/${n}/${v}`).catch(()=>[])]),ie=P?.value,ye=C?.filter(A=>{const $=A.sourceName.toLowerCase();return w.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ye.length>0?ye:C??[];let g=e.length>0?e[0]:null;if(ie){const A=e.find($=>$.sourceName===ie);A&&(g=A)}const V=g&&g.links.length>0?g.links.sort((A,$)=>(parseInt($.resolutionStr)||0)-(parseInt(A.resolutionStr)||0))[0]:null,U=S?.currentTime||0,le=S?.duration||0,ve=(Array.isArray(R)?R:R?.results||[]).map(A=>({skip_id:A.skip_id||"",skip_type:A.skip_type||"",start_time:A.interval?.start_time??A.start_time??0,end_time:A.interval?.end_time??A.end_time??0})).filter(A=>A.end_time>0);return(!C||C.length===0)&&(b||Qe.error(`No video sources found for ${w.selectedProvider}`)),{videoSources:C,selectedSource:g,selectedLink:V,resumeTime:U,resumeDuration:le,showResumeModal:U>5&&g?.type!=="iframe",skipIntervals:ve,fetchedEpisodeNumber:v}}catch(C){const S=C;if(S.message==="AUTH_REQUIRED")return K({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:S.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:v};throw C}}const Ps=(n,v,w,K)=>{const[b,C]=Lr(xs,w,l=>({...mr(),showMeta:l?.name?{name:l.name,thumbnail:l.thumbnail,nativeName:l.nativeName,englishName:l.englishName,names:{romaji:l.name||l.englishName,english:l.englishName||l.name,native:l.nativeName}}:{}})),S=dr(),P=f(null),R=f(null),{options:ie}=pr(),ye=ct(()=>ie.filter(l=>(l.kind??"anime")==="anime"),[ie]),e=v||b.initialEpisode,g=f(e);x(()=>{g.current!==e&&(g.current=e,C({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[e,C]),x(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&b.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,C({type:"SET_PROVIDER",payload:"animepahe"}))},[n,b.selectedProvider]);const{data:V,isLoading:U,error:le}=Sn(n),{data:z}=ar({queryKey:["player-data",n,b.currentMode,b.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const l=async()=>{try{const Q=await $e(`/api/episodes?showId=${n}&mode=${b.currentMode}&provider=${b.selectedProvider}`);if(Q?.episodes?.length)return Q}catch{}return null},[o,d,p]=await Promise.all([l(),$e(`/api/watchlist/check/${n}`).catch(()=>({inWatchlist:!1})),$e(`/api/watched-episodes/${n}`).catch(()=>[])]),B=o?.episodes?o.episodes.sort((Q,j)=>parseFloat(Q)-parseFloat(j)):[];return{description:o?.description||"",episodes:B,inWatchlist:d.inWatchlist,watchlistStatus:d.status??null,watchedEpisodes:p}},enabled:!!n});x(()=>{!v&&z?.episodes&&z.episodes.length>0&&!v&&C({type:"SET_STATE",payload:{initialEpisode:z.episodes[0]}})},[z,v]),x(()=>{if(V?.isAdult===void 0)return;const o=new Set(ye.filter(d=>d.mature).map(d=>d.value)).has(b.selectedProvider);if(R.current!==n){if(V.isAdult&&!o){R.current=n;const d=ye.find(p=>p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}if(!V.isAdult&&o){R.current=n;const d=ye.find(p=>!p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}}},[V?.isAdult,b.selectedProvider,n,ye]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||R.current===`temp:${n}`)return;const l=V?.provider;l&&(R.current=`temp:${n}`,l!==b.selectedProvider&&C({type:"SET_PROVIDER",payload:l}))},[n,V,b.selectedProvider]);const{data:ve,isLoading:A,error:$}=ar({queryKey:["video-sources",n,e,b.selectedProvider,b.currentMode],queryFn:()=>cr(n,e,b,C),enabled:!!n&&!!e&&!(b.showMeta?.isAdult===!0&&!K?.hasMatureConsent)}),De=!1,{mutateAsync:qe}=Gt({mutationFn:async({wasIn:l,showMeta:o})=>{const d=l?"/api/watchlist/remove":"/api/watchlist/add",p={id:n,name:o.name||o.names?.romaji,thumbnail:o.thumbnail,nativeName:o.names?.native,englishName:o.names?.english,type:o.type,isAdult:o.isAdult},B=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!B.ok){const Q=await B.json().catch(()=>null);throw new Error(Q?.error||"Failed to update watchlist")}return!l},onSuccess:l=>{Qe.success(l?"Added to watchlist":"Removed from watchlist"),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]})},onError:l=>Qe.error(l instanceof Error?l.message:"Failed to update watchlist")}),a=O(async()=>{!n||!V||await qe({wasIn:!!z?.inWatchlist,showMeta:V})},[n,V,z?.inWatchlist,qe]),m=O(async l=>{try{await $e("/api/settings",{method:"POST",body:JSON.stringify({key:"preferredSource",value:l})})}catch(o){console.error(o)}},[]),{mutateAsync:k,isPending:Se}=Gt({mutationFn:async({status:l})=>{if(!n)throw new Error("Missing showId");return await $e("/api/watchlist/status",{method:"POST",body:JSON.stringify({id:n,status:l})}),l},onSuccess:l=>{C({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:l}}),Qe.success(`Moved to ${l}`),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]}),S.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Qe.error("Failed to update watchlist status")}),Fe=O(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:Be}=Gt({mutationFn:async({episodeNumber:l,duration:o,showMeta:d,episodes:p})=>{await $e("/api/update-progress",{method:"POST",body:JSON.stringify({showId:n,episodeNumber:l,currentTime:o,duration:o,showName:d.name,showThumbnail:d.thumbnail,nativeName:d.names?.native,englishName:d.names?.english,genres:d.genres?.map(B=>B.name),popularityScore:Wr(d.score??d.stats?.averageScore),type:d.type,status:d.status,episodeCount:p.length,isAdult:d.isAdult}),keepalive:!0})},onSuccess:(l,o)=>{Qe.success(`Episode ${o.episodeNumber} marked as watched`),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-meta",n]}),S.invalidateQueries({queryKey:["video-sources",n,o.episodeNumber]}),S.invalidateQueries({queryKey:["allContinueWatching"]}),S.invalidateQueries({queryKey:["thisWeekSchedule"]})},onError:()=>Qe.error("Failed to mark episode as watched")}),Ie=O(async(l,o)=>{!n||!V||await Be({episodeNumber:l,duration:o,showMeta:V,episodes:z?.episodes||[]})},[n,V,z?.episodes,Be]),ze=O(async()=>{C({type:"SET_STATE",payload:{showCombinedDetails:!b.showCombinedDetails}})},[b.showCombinedDetails]),ee=ct(()=>{const l=le||$,o=l?l.message:null,d=o==="AUTH_REQUIRED"?null:o,p=ve&&ve.fetchedEpisodeNumber===e?ve:null,B=!!ve&&!p;return{...b,currentEpisode:e,showMeta:{...b.showMeta||{},...V||{}},episodes:z?.episodes||[],watchedEpisodes:z?.watchedEpisodes||[],inWatchlist:!!z?.inWatchlist,watchlistStatus:z?.watchlistStatus??b.watchlistStatus??null,videoSources:p?.videoSources||[],selectedSource:b.selectedSource||p?.selectedSource||null,selectedLink:b.selectedLink||p?.selectedLink||null,resumeTime:p?.resumeTime||0,resumeDuration:p?.resumeDuration||0,showResumeModal:b.showResumeModal&&(p?.showResumeModal??!1),skipIntervals:p?.skipIntervals||[],loadingShowData:U,loadingVideo:A||B,loadingDetails:De,error:d,fetchedEpisodeNumber:p?.fetchedEpisodeNumber}},[b,V,z,ve,U,A,De,le,$,e]),Re=O((l,o)=>{const d=o||n;if(!d||!l||d===n&&l===e)return;const B=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(d)&&b.selectedProvider!=="animepahe"?"animepahe":b.selectedProvider,Q=["video-sources",d,l,B,b.currentMode];S.getQueryState(Q)?.status!=="success"&&S.prefetchQuery({queryKey:Q,queryFn:()=>cr(d,l,{selectedProvider:B,currentMode:b.currentMode},C,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,e,S,b,C]);return{state:ee,dispatch:C,toggleWatchlist:a,moveToCompleted:Fe,setPreferredSource:m,handleToggleDetails:ze,markEpisodeWatched:Ie,prefetchEpisodeSources:Re,isMarkingWatched:Be.isPending,isUpdatingWatchlistStatus:Se}},Kt="fallbackChoice";function As(){try{const n=localStorage.getItem(Kt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Bs(n){try{n===null?localStorage.removeItem(Kt):localStorage.setItem(Kt,n)}catch{}}const Xs=()=>{const{id:n,episodeNumber:v}=$r(),w=Dr(),K=dr(),b=Fr(),{hasConsent:C,grant:S}=gn(),{options:P}=pr(),R=ct(()=>P.filter(t=>(t.kind??"anime")==="anime"),[P]),ie=ct(()=>R.map(t=>t.value),[R]),ye=ct(()=>new Set(R.filter(t=>t.mature).map(t=>t.value)),[R]),{state:e,dispatch:g,toggleWatchlist:V,moveToCompleted:U,setPreferredSource:le,handleToggleDetails:z,markEpisodeWatched:ve,prefetchEpisodeSources:A,isMarkingWatched:$,isUpdatingWatchlistStatus:De}=Ps(n,v,b.state||null,{hasMatureConsent:C});x(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=v?`/watch/${e.showMeta.id}/${v}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;w(t,{replace:!0})}},[n,e.showMeta?.id,v,w]);const qe=ct(()=>{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]),a=en({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:qe}),{refs:m,actions:k}=a,Se=f(null),Fe=bn(),Be=f(null),Ie=f(null),ze=f(null),ee=f(0),Re=f(e.resumeTime),l=f(e.showResumeModal),[o,d]=q(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[p,B]=q(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[Q,j]=q(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[te,Ee]=q(!1),[we,Ge]=q(!1),He=f(null),tt=f(null),G=(t,s)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(s))}catch{}},Ke=t=>{const s=Math.max(0,Math.min(500,Math.round(t)));B(s);try{localStorage.setItem("playerVideoDelayMs",String(s))}catch{}},ut=()=>{He.current={enabled:Q,ms:p},j(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}k.setShowSettings(!1),Ee(!0)},re=()=>{const t=He.current;He.current=null,t&&(B(t.ms),j(t.enabled),G(t.ms,t.enabled)),Ge(!1),Ee(!1)},pe=()=>{He.current=null,j(!0),G(p,!0),Ge(!1),Ee(!1)},je=()=>{if(we){Ge(!1);return}const t=m.videoRef.current;t&&!isNaN(t.currentTime)&&(tt.current=t.currentTime),Ge(!0)},rt=Q?p:0,ht=f(null),ne=Rs({videoRef:m.videoRef,canvasRef:Ie,profile:o,delayMs:rt}),Ye=ne.isEnabled&&ne.isWebGPUSupported;tn({videoRef:m.videoRef,canvasRef:ht,delayMs:rt,enabled:Q&&!Ye});const h=Q&&!Ye,_=Ye||h;x(()=>{Re.current=e.resumeTime,l.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[I,Y]=q(null),[nt,wt]=q(!1),[st,ot]=q(!1),[kt,M]=q(!1),Oe=f(!1),[at,me]=q(null),Je=f(!1),ke=f([]),Le=f(!1),[ft,_e]=q(null),[vt,gt]=q(!1),[Xe,Tt]=q(!1),[Ct,Ft]=q(()=>As()??"ask"),dt=O(t=>{Ft(t),Bs(t==="ask"?null:t)},[]),L=f(Ct);L.current=Ct;const ce=f(e.videoSources);ce.current=e.videoSources;const Ne=f(()=>{}),[D,ue]=q(null),Te=f(v);x(()=>{Te.current!==v&&(Te.current=v,ue(null),me(null),Oe.current=!1,Ge(!1),Ee(!1))},[v]),x(()=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),gt(!1)},[n,e.currentEpisode]),x(()=>{st||(Oe.current=!1)},[st]);const{data:T=[],isLoading:Mt}=Vr(),We=Ur(),Ce=f(We);Ce.current=We;const he=Qr(),Ot=qr(),[se,ge]=q(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});rn(a,!!e.selectedLink&&!se),x(()=>{try{se?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(t){console.error(t)}return()=>{try{document.body.classList.remove("theater-mode")}catch(t){console.error(t)}}},[se]),Or(()=>{if(a.state.isFullscreen||se)return;const t=m.playerContainerRef.current,s=Be.current;if(!t||!s)return;const i=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};i();const c=new ResizeObserver(i);return c.observe(t),()=>c.disconnect()},[a.state.isFullscreen,se,m.playerContainerRef]);const Ve=ct(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),Wt=Ve>0?e.episodes[Ve-1]:null,xe=Ve>=0&&Ve<e.episodes.length-1?e.episodes[Ve+1]:null,Vt=Ve>-1&&Ve<e.episodes.length-1,hr=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,fr=String(e.showMeta.status||"").trim().toLowerCase(),vr=["finished","completed","complete","ended"].some(t=>fr.includes(t)),Ut=nn(e.resumeTime,e.resumeDuration)||st,it=hr&&vr&&Ut,jt=e.showResumeModal&&(it||!Ut),xt=Ut&&!it&&T.length===0&&!D&&(e.showResumeModal||st),bt=jt||xt;x(()=>{const t=m.videoRef.current;if(!t)return;let s=!1;for(Se.current&&(Se.current.destroy(),Se.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(we)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ee.current=0;return}tt.current!=null?(ee.current=tt.current,tt.current=null):Re.current>5&&!l.current?ee.current=Re.current:l.current&&(ee.current=0);let i=e.selectedLink.link;if(i.startsWith("/api/proxy")||(i=`/api/proxy?url=${encodeURIComponent(i)}`,e.selectedLink.headers?.Referer&&(i+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const fe=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Me=null;try{Me=localStorage.getItem("playerLastSubtitle")}catch{}const J=Ht(e.selectedSource.subtitles,{lastKey:Me,enabled:fe}),Pe=J>=0?e.selectedSource.subtitles[J]:null;e.selectedSource.subtitles.forEach(be=>{const X=document.createElement("track");X.kind="subtitles",X.label=be.label,X.srclang=be.lang;const y=be.src??be.url;if(y){let Z=`/api/subtitle-proxy?url=${encodeURIComponent(y)}`;const ae=e.selectedLink?.headers?.Referer,yt=y.includes("anilight.live")?"https://anilight.live/":"",$t=ae||yt;$t&&(Z+=`&referer=${encodeURIComponent($t)}`),X.src=Z}Pe&&be.label===Pe.label&&be.lang===Pe.lang&&(X.default=!0),t.appendChild(X)}),fe||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const c=ee.current;ee.current=0;const N=()=>{c>0&&(t.currentTime=c)};t.addEventListener("loadedmetadata",N,{once:!0});const de=!(l.current&&Re.current>5),H=()=>{de&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const fe=await vn();if(s)return;if(!fe||!fe.isSupported()){t.src=i,H();return}const Me=document.body.classList.contains("low-end"),J=new fe({maxBufferLength:Me?15:30,maxMaxBufferLength:Me?30:60,maxBufferSize:Me?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});Se.current=J,J.on(fe.Events.ERROR,(X,y)=>{y.fatal&&!Je.current&&Ne.current()});const Pe=(e.selectedSource?.subtitles?.length??0)>0,be=()=>{try{Pe&&typeof J.subtitleTrack=="number"&&J.subtitleTrack!==-1&&(J.subtitleTrack=-1)}catch{}};J.on(fe.Events.SUBTITLE_TRACK_SWITCH,(X,y)=>{y?.id!==-1&&be()}),be(),J.loadSource(i),J.attachMedia(t),J.once(fe.Events.MANIFEST_PARSED,()=>{s||H()})})():(t.src=i,H());const F=localStorage.getItem("playerVolume"),oe=localStorage.getItem("playerMuted");return F!==null&&(t.volume=parseFloat(F)),oe!==null&&(t.muted=oe==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),Se.current&&(Se.current.destroy(),Se.current=null)}},[e.selectedSource,e.selectedLink,m.videoRef,k,e.loadingVideo,we]);const Pt=O(t=>{if(Je.current)return;Je.current=!0;const s=t.links[0];le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),_e(null)},[g,le]),At=O(()=>{const s=ce.current.find(i=>i.type==="iframe");return s?.links?.length?s:null},[]),Bt=O(async()=>{const t=e.showMeta?.isAdult,s=ie.filter(i=>{if(ke.current.includes(i))return!1;const c=ye.has(i);return t===void 0?!0:c===t});gt(!0);try{for(const i of s){ke.current.push(i);let c=null;try{c=await $e(`/api/video?showId=${n}&episodeNumber=${e.currentEpisode}&mode=${e.currentMode}&provider=${i}`)}catch{continue}const N=(c??[]).filter(F=>{const oe=F.sourceName.toLowerCase();return e.currentMode==="dub"?oe.includes("eng")||oe.includes("dub"):oe.includes("jpn")||oe.includes("sub")||!oe.includes("eng")&&!oe.includes("dub")});if((N.length>0?N:c??[]).find(F=>F.type!=="iframe"&&F.links?.length)){ke.current=[e.selectedProvider],Le.current=!1,g({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),_e(null),Qe.success(`Switched to ${i} (direct stream)`);return}}_e({retryFailed:!0}),Qe.error("No working direct stream found on other providers")}finally{gt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,g,ie,ye]),Yt=O(()=>{if(Je.current||Le.current||e.selectedSource?.type!=="player")return;const t=At();if(!t)return;ke.current.includes(e.selectedProvider)||ke.current.push(e.selectedProvider);const s=L.current;if(s==="iframe"){Pt(t);return}if(s==="retry"){Bt();return}k.setShowControls(!0),_e({retryFailed:!1})},[e.selectedSource,e.selectedProvider,At,Pt,Bt,k]);Ne.current=Yt;const gr=O(()=>{Le.current=!0,_e(null),Tt(!1)},[]),br=O(()=>{Xe&&dt("iframe");const t=At();t?Pt(t):_e(null)},[Xe,dt,At,Pt]),yr=O(()=>{Xe&&dt("retry"),Bt()},[Xe,dt,Bt]),Rt=(t,s,i)=>t.showId===s||!!i&&t.showId===i,It=O(()=>{k.onEnded();const t=T.find(i=>Rt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(T.length>0){const i=T.findIndex(N=>Rt(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),c=i>=0?T[i+1]||null:T[0];ue({nextItem:c,playedItem:t||null}),me(2)}else t&&Ce.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&T.length===0){const i=e.episodes.findIndex(c=>c===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const c=e.episodes[i+1];K.invalidateQueries({queryKey:["allContinueWatching"]}),w(`/watch/${n}/${c}`),s=!0}}if(!s&&T.length===0&&!D&&!Oe.current){const i=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,c=String(e.showMeta.status||"").trim().toLowerCase(),N=["finished","completed","complete","ended"].some(de=>c.includes(de));i&&N&&g({type:"SET_STATE",payload:{showResumeModal:!0}})}},[k,w,T,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,D,g,K]),Qt=O(()=>{if(T.length===0)return;k.onEnded();const t=T.find(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),s=T.findIndex(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),i=s>=0?T[s+1]||null:T[0];t&&We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?w(`/watch/${i.showId}/${i.episodeNumber}`):t&&g({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,w,T,We,n,e.showMeta?.id,e.currentEpisode,g]),_t=O(()=>{xe&&(K.invalidateQueries({queryKey:["allContinueWatching"]}),ot(!1),w(`/watch/${n}/${xe}`)),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[xe,w,n,g,K]),Jt=O(()=>{T.length>0?Qt():xe?_t():Qe.error("No next episode available")},[T.length,Qt,_t,xe]),Sr=()=>{Wt&&w(`/watch/${n}/${Wt}`)};x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>{we||It()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[It,m.videoRef,a.state.isFullscreen,we]),x(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&It()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[It,e.selectedSource?.type]),x(()=>{if(!D||at===null)return;if(at<=0){const{nextItem:s,playedItem:i}=D;ue(null),me(null),i&&Ce.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),s?w(`/watch/${s.showId}/${s.episodeNumber}`):i&&g({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{me(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[D,at,w,g]),x(()=>{bt&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[bt,a.state.isFullscreen,a.actions]),x(()=>{bt&&m.videoRef.current&&m.videoRef.current.pause()},[bt,m.videoRef]);const{titlePreference:Lt}=zr(),pt=ct(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Lt==="name"?t||"Loading...":Lt==="nativeName"?s?.native||t||"Loading...":Lt==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Lt,e.loadingShowData]);x(()=>{pt&&pt!=="Loading..."&&e.currentEpisode&&(document.title=`► ${pt} Episode ${e.currentEpisode} - dango`)},[pt,e.currentEpisode]),x(()=>{const t=s=>{if(!s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')&&(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&Jt(),s.key.toLowerCase()==="t")){const c=!se;ge(c),localStorage.setItem("playerTheaterMode",c.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,a.actions.inactivityTimer,Jt,se]);const{setAvailableSubtitles:Xt,setActiveSubtitleTrack:qt}=k;x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>{const i=Array.from(t.textTracks).map(c=>({label:c.label,lang:c.language,src:void 0,mode:c.mode}));Xt(i)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[m.videoRef,Xt]),x(()=>{if(a.state.activeSubtitleTrack===null&&a.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Ht(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){qt("off");return}const i=a.state.availableSubtitles[s];qt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,qt]),x(()=>{const t=m.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const s=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let c=!1;if(Array.from(t.textTracks).forEach(N=>{const H=(N.language===s||N.label===s)&&!c;N.mode=H?"showing":"hidden",H&&(c=!0)}),!c&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(de=>de.language==="en"||de.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,m.videoRef]);const[Zt,Er]=q(0);x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>Er(t.clientHeight||0);s();const i=new ResizeObserver(s);return i.observe(t),()=>i.disconnect()},[m.videoRef,e.selectedSource,e.selectedLink]),x(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const i={fontSize:a.state.subtitleFontSize,position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold};s.textContent=ir(i);const c=m.videoRef.current;if(!c)return;const N=lr(a.state.subtitleFontSize,Zt||c.clientHeight||720);s.textContent=ir({...i,fontSize:N});const de=()=>{const y=Number(a.state.subtitlePosition),Z=isNaN(y)?0:Math.max(0,Math.min(100,y));return Math.max(0,Math.min(100,100-Z))},H=(y,Z)=>{try{const ae=y;ae.snapToLines=!1,ae.line=Z}catch{}},F=()=>{const y=N*16,Z=c.videoHeight||c.clientHeight||720,ae=c.videoWidth||c.clientWidth||1280;return{step:y*1.3/Z*100,chars:Math.max(20,Math.floor(ae/(y*.55)))}},oe=y=>{const Z=de(),ae=Array.from(y.activeCues??[]);if(ae.length<=1){ae.forEach(St=>H(St,Z));return}const{step:yt,chars:$t}=F();let sr=Z;for(let St=ae.length-1;St>=0;St--){const xr=String(ae[St].text??"").replace(/<[^>]*>/g,"").split(`
|
|
54
|
+
`}),Xe=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Tt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[Xe]}),vertex:{module:bt,entryPoint:"vs"},fragment:{module:bt,entryPoint:"fs",targets:[{format:at}]},primitive:{topology:"triangle-list"}}),Ct=M.createBindGroup({layout:Xe,entries:[{binding:0,resource:_e.createView()},{binding:1,resource:gt}]});try{const L=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),ce=M.createShaderModule({code:Ms}),Ne=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[L]}),vertex:{module:ce,entryPoint:"vs"},fragment:{module:ce,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});l.current={pipeline:Ne,layout:L,inputView:me.createView()}}catch{l.current=null}if(U.current!==te){me.destroy(),M.destroy();return}le.current=M,z.current=Oe,ve.current=vt,A.current=me,$.current=_e,De.current=Tt,qe.current=gt,a.current=Xe,ee.current=!1,Re.current=!1;async function Ft(){const L=l.current;if(!L||ee.current)return!1;const ce=n.current;if(!ce)return!1;const Ne=!Re.current;Ne&&M.pushErrorScope("validation");try{const D=M.importExternalTexture({source:ce}),ue=M.createBindGroup({layout:L.layout,entries:[{binding:0,resource:D},{binding:1,resource:gt}]}),Te=M.createCommandEncoder(),T=Te.beginRenderPass({colorAttachments:[{view:L.inputView,loadOp:"load",storeOp:"store"}]});T.setPipeline(L.pipeline),T.setBindGroup(0,ue),T.draw(6),T.end(),M.queue.submit([Te.finish()])}catch{return ee.current=!0,l.current=null,!1}if(Ne){const D=await M.popErrorScope().catch(()=>null);if(D)return console.warn("[anime4k] blit probe failed:",D.message),ee.current=!0,l.current=null,!1;Re.current=!0}return!0}ie(!1);async function dt(){if(j||U.current!==te)return;const L=n.current;if(!L||L.videoWidth===0){Y();return}if(L!==G||L.videoWidth!==re||L.videoHeight!==pe){V(ue=>ue+1);return}if(L.paused||L.ended||document.hidden||L.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){Y();return}const ce=L.getVideoPlaybackQuality().totalVideoFrames;if(ce===d.current){Y();return}if(k.current){Y();return}const Ne=L.currentTime;(L.seeking||o.current>=0&&Math.abs(Ne-o.current)>.5)&&(we(),p.current=!1,B.current=0,d.current=-1),o.current=Ne;const D=Math.max(0,Be.current||0);D>B.current&&(p.current=!1),k.current=!0;try{const ue=performance.now();let Te=null,T=!1;if(D<=0){Ie.current.length>0&&we(),p.current=!1,B.current=0;let Ce=!1;if(!ze.current)try{M.queue.copyExternalImageToTexture({source:L},{texture:me},[re,pe]),d.current=ce,Ce=!0}catch(he){if(he instanceof TypeError)ze.current=!0;else throw he}if(!Ce&&!ee.current&&l.current&&await Ft()&&(d.current=ce,Ce=!0),!Ce){const he=await createImageBitmap(L);d.current=ce,M.queue.copyExternalImageToTexture({source:he},{texture:me},[re,pe]),Ee(he)}}else{const Ce=await createImageBitmap(L);d.current=ce;const he=Ie.current;he.push({bitmap:Ce,capture:ue});const Ot=Ge(D);for(;he.length>Ot;)Ee(he.shift()?.bitmap);let se=-1;for(let ge=he.length-1;ge>=0;ge--)if(ue-he[ge].capture>=D){se=ge;break}if(se!==-1){for(let Ve=0;Ve<se;Ve++)Ee(he.shift()?.bitmap);const ge=he.shift();ge?(Te=ge.bitmap,p.current=!0,B.current=D):(Te=Ce,T=!0)}else if(!p.current)Te=Ce,T=!0;else{const ge=he.shift();Te=ge?ge.bitmap:Ce,ge||(T=!0)}if(!Te){k.current=!1,Y();return}M.queue.copyExternalImageToTexture({source:Te},{texture:me},[re,pe]),T||Ee(Te)}const Mt=M.createCommandEncoder();await vt.pass(Mt);const We=Mt.beginRenderPass({colorAttachments:[{view:Oe.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(Tt),We.setBindGroup(0,Ct),We.draw(6),We.end(),M.queue.submit([Mt.finish()]),Se.current=ce,Fe.current=0,M.queue.onSubmittedWorkDone().then(()=>{U.current===te&&(k.current=!1)})}catch(ue){if(k.current=!1,Fe.current+=1,Fe.current>=Ts&&!j&&U.current===te){console.error(ue),e(ue instanceof Error?ue.message:"Render error"),P(!1);return}}Y()}Y()}catch(Y){!j&&U.current===te&&(e(Y instanceof Error?Y.message:"Failed to initialize upscaler"),ie(!1),P(!1))}}return tt(),()=>{j=!0,U.current+=1,He(),we(),A.current&&(A.current.destroy(),A.current=null),$.current&&($.current.destroy(),$.current=null),le.current&&(le.current.destroy(),le.current=null),ve.current=null,De.current=null,qe.current=null,a.current=null,l.current=null,z.current=null,k.current=!1}},[S,b,n,v,w,g]);const Q=O(()=>{P(j=>!j)},[]);return{isWebGPUSupported:b,isEnabled:S,isInitializing:R,error:ye,toggle:Q}}const _s=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ns=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},mr=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:_s(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,forceNativePlayer:localStorage.getItem("forceNativePlayer")==="true",isAutoplayEnabled:Zr(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ns(),loadingShowData:!0,loadingVideo:!1,loadingDetails:!1,error:null,detailsError:null,showCookieModal:!1,cookieProvider:null});mr();function xs(n,v){switch(v.type){case"SET_STATE":return{...n,...v.payload};case"SET_MODE":return{...n,currentMode:v.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:v.payload};case"SET_OVERRIDE_SOURCE":return{...n,selectedSource:v.payload?.source??null,selectedLink:v.payload?.link??null};default:return n}}async function cr(n,v,w,K,b=!1){if(!n||!v)throw new Error("Missing params");try{const[C,S,P,R]=await Promise.all([$e(`/api/video?showId=${n}&episodeNumber=${v}&mode=${w.currentMode}&provider=${w.selectedProvider}`).catch(()=>null),$e(`/api/episode-progress/${n}/${v}`).catch(()=>null),$e("/api/settings?key=preferredSource").catch(()=>null),$e(`/api/skip-times/${n}/${v}`).catch(()=>[])]),ie=P?.value,ye=C?.filter(A=>{const $=A.sourceName.toLowerCase();return w.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ye.length>0?ye:C??[];let g=e.length>0?e[0]:null;if(ie){const A=e.find($=>$.sourceName===ie);A&&(g=A)}const V=g&&g.links.length>0?g.links.sort((A,$)=>(parseInt($.resolutionStr)||0)-(parseInt(A.resolutionStr)||0))[0]:null,U=S?.currentTime||0,le=S?.duration||0,ve=(Array.isArray(R)?R:R?.results||[]).map(A=>({skip_id:A.skip_id||"",skip_type:A.skip_type||"",start_time:A.interval?.start_time??A.start_time??0,end_time:A.interval?.end_time??A.end_time??0})).filter(A=>A.end_time>0);return(!C||C.length===0)&&(b||Qe.error(`No video sources found for ${w.selectedProvider}`)),{videoSources:C,selectedSource:g,selectedLink:V,resumeTime:U,resumeDuration:le,showResumeModal:U>5&&g?.type!=="iframe",skipIntervals:ve,fetchedEpisodeNumber:v}}catch(C){const S=C;if(S.message==="AUTH_REQUIRED")return K({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:S.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:v};throw C}}const Ps=(n,v,w,K)=>{const[b,C]=Lr(xs,w,l=>({...mr(),showMeta:l?.name?{name:l.name,thumbnail:l.thumbnail,nativeName:l.nativeName,englishName:l.englishName,names:{romaji:l.name||l.englishName,english:l.englishName||l.name,native:l.nativeName}}:{}})),S=dr(),P=f(null),R=f(null),{options:ie}=pr(),ye=ct(()=>ie.filter(l=>(l.kind??"anime")==="anime"),[ie]),e=v||b.initialEpisode,g=f(e);x(()=>{g.current!==e&&(g.current=e,C({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[e,C]),x(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&b.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,C({type:"SET_PROVIDER",payload:"animepahe"}))},[n,b.selectedProvider]);const{data:V,isLoading:U,error:le}=Sn(n),{data:z}=ar({queryKey:["player-data",n,b.currentMode,b.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const l=async()=>{try{const Q=await $e(`/api/episodes?showId=${n}&mode=${b.currentMode}&provider=${b.selectedProvider}`);if(Q?.episodes?.length)return Q}catch{}return null},[o,d,p]=await Promise.all([l(),$e(`/api/watchlist/check/${n}`).catch(()=>({inWatchlist:!1})),$e(`/api/watched-episodes/${n}`).catch(()=>[])]),B=o?.episodes?o.episodes.sort((Q,j)=>parseFloat(Q)-parseFloat(j)):[];return{description:o?.description||"",episodes:B,inWatchlist:d.inWatchlist,watchlistStatus:d.status??null,watchedEpisodes:p}},enabled:!!n});x(()=>{!v&&z?.episodes&&z.episodes.length>0&&!v&&C({type:"SET_STATE",payload:{initialEpisode:z.episodes[0]}})},[z,v]),x(()=>{if(V?.isAdult===void 0)return;const o=new Set(ye.filter(d=>d.mature).map(d=>d.value)).has(b.selectedProvider);if(R.current!==n){if(V.isAdult&&!o){R.current=n;const d=ye.find(p=>p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}if(!V.isAdult&&o){R.current=n;const d=ye.find(p=>!p.mature);if(!d)return;C({type:"SET_PROVIDER",payload:d.value}),localStorage.setItem("preferredProvider",d.value)}}},[V?.isAdult,b.selectedProvider,n,ye]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||R.current===`temp:${n}`)return;const l=V?.provider;l&&(R.current=`temp:${n}`,l!==b.selectedProvider&&C({type:"SET_PROVIDER",payload:l}))},[n,V,b.selectedProvider]);const{data:ve,isLoading:A,error:$}=ar({queryKey:["video-sources",n,e,b.selectedProvider,b.currentMode],queryFn:()=>cr(n,e,b,C),enabled:!!n&&!!e&&!(b.showMeta?.isAdult===!0&&!K?.hasMatureConsent)}),De=!1,{mutateAsync:qe}=Gt({mutationFn:async({wasIn:l,showMeta:o})=>{const d=l?"/api/watchlist/remove":"/api/watchlist/add",p={id:n,name:o.name||o.names?.romaji,thumbnail:o.thumbnail,nativeName:o.names?.native,englishName:o.names?.english,type:o.type,isAdult:o.isAdult},B=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!B.ok){const Q=await B.json().catch(()=>null);throw new Error(Q?.error||"Failed to update watchlist")}return!l},onSuccess:l=>{Qe.success(l?"Added to watchlist":"Removed from watchlist"),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]})},onError:l=>Qe.error(l instanceof Error?l.message:"Failed to update watchlist")}),a=O(async()=>{!n||!V||await qe({wasIn:!!z?.inWatchlist,showMeta:V})},[n,V,z?.inWatchlist,qe]),m=O(async l=>{try{await $e("/api/settings",{method:"POST",body:JSON.stringify({key:"preferredSource",value:l})})}catch(o){console.error(o)}},[]),{mutateAsync:k,isPending:Se}=Gt({mutationFn:async({status:l})=>{if(!n)throw new Error("Missing showId");return await $e("/api/watchlist/status",{method:"POST",body:JSON.stringify({id:n,status:l})}),l},onSuccess:l=>{C({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:l}}),Qe.success(`Moved to ${l}`),S.invalidateQueries({queryKey:["show-data",n]}),S.invalidateQueries({queryKey:["watchlist"]}),S.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Qe.error("Failed to update watchlist status")}),Fe=O(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:Be}=Gt({mutationFn:async({episodeNumber:l,duration:o,showMeta:d,episodes:p})=>{await $e("/api/update-progress",{method:"POST",body:JSON.stringify({showId:n,episodeNumber:l,currentTime:o,duration:o,showName:d.name,showThumbnail:d.thumbnail,nativeName:d.names?.native,englishName:d.names?.english,genres:d.genres?.map(B=>B.name),popularityScore:Wr(d.score??d.stats?.averageScore),type:d.type,status:d.status,episodeCount:p.length,isAdult:d.isAdult}),keepalive:!0})},onSuccess:(l,o)=>{Qe.success(`Episode ${o.episodeNumber} marked as watched`),S.invalidateQueries({queryKey:["player-data",n]}),S.invalidateQueries({queryKey:["show-meta",n]}),S.invalidateQueries({queryKey:["video-sources",n,o.episodeNumber]}),S.invalidateQueries({queryKey:["allContinueWatching"]}),S.invalidateQueries({queryKey:["thisWeekSchedule"]})},onError:()=>Qe.error("Failed to mark episode as watched")}),Ie=O(async(l,o)=>{!n||!V||await Be({episodeNumber:l,duration:o,showMeta:V,episodes:z?.episodes||[]})},[n,V,z?.episodes,Be]),ze=O(async()=>{C({type:"SET_STATE",payload:{showCombinedDetails:!b.showCombinedDetails}})},[b.showCombinedDetails]),ee=ct(()=>{const l=le||$,o=l?l.message:null,d=o==="AUTH_REQUIRED"?null:o,p=ve&&ve.fetchedEpisodeNumber===e?ve:null,B=!!ve&&!p;return{...b,currentEpisode:e,showMeta:{...b.showMeta||{},...V||{}},episodes:z?.episodes||[],watchedEpisodes:z?.watchedEpisodes||[],inWatchlist:!!z?.inWatchlist,watchlistStatus:z?.watchlistStatus??b.watchlistStatus??null,videoSources:p?.videoSources||[],selectedSource:b.selectedSource||p?.selectedSource||null,selectedLink:b.selectedLink||p?.selectedLink||null,resumeTime:p?.resumeTime||0,resumeDuration:p?.resumeDuration||0,showResumeModal:b.showResumeModal&&(p?.showResumeModal??!1),skipIntervals:p?.skipIntervals||[],loadingShowData:U,loadingVideo:A||B,loadingDetails:De,error:d,fetchedEpisodeNumber:p?.fetchedEpisodeNumber}},[b,V,z,ve,U,A,De,le,$,e]),Re=O((l,o)=>{const d=o||n;if(!d||!l||d===n&&l===e)return;const B=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(d)&&b.selectedProvider!=="animepahe"?"animepahe":b.selectedProvider,Q=["video-sources",d,l,B,b.currentMode];S.getQueryState(Q)?.status!=="success"&&S.prefetchQuery({queryKey:Q,queryFn:()=>cr(d,l,{selectedProvider:B,currentMode:b.currentMode},C,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,e,S,b,C]);return{state:ee,dispatch:C,toggleWatchlist:a,moveToCompleted:Fe,setPreferredSource:m,handleToggleDetails:ze,markEpisodeWatched:Ie,prefetchEpisodeSources:Re,isMarkingWatched:Be.isPending,isUpdatingWatchlistStatus:Se}},Kt="fallbackChoice";function As(){try{const n=localStorage.getItem(Kt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Bs(n){try{n===null?localStorage.removeItem(Kt):localStorage.setItem(Kt,n)}catch{}}const Xs=()=>{const{id:n,episodeNumber:v}=$r(),w=Dr(),K=dr(),b=Fr(),{hasConsent:C,grant:S}=gn(),{options:P}=pr(),R=ct(()=>P.filter(t=>(t.kind??"anime")==="anime"),[P]),ie=ct(()=>R.map(t=>t.value),[R]),ye=ct(()=>new Set(R.filter(t=>t.mature).map(t=>t.value)),[R]),{state:e,dispatch:g,toggleWatchlist:V,moveToCompleted:U,setPreferredSource:le,handleToggleDetails:z,markEpisodeWatched:ve,prefetchEpisodeSources:A,isMarkingWatched:$,isUpdatingWatchlistStatus:De}=Ps(n,v,b.state||null,{hasMatureConsent:C});x(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=v?`/watch/${e.showMeta.id}/${v}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;w(t,{replace:!0})}},[n,e.showMeta?.id,v,w]);const qe=ct(()=>{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]),a=en({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:qe}),{refs:m,actions:k}=a,Se=f(null),Fe=bn(),Be=f(null),Ie=f(null),ze=f(null),ee=f(0),Re=f(e.resumeTime),l=f(e.showResumeModal),[o,d]=q(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[p,B]=q(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[Q,j]=q(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[te,Ee]=q(!1),[we,Ge]=q(!1),He=f(null),tt=f(null),G=(t,s)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(s))}catch{}},Ke=t=>{const s=Math.max(0,Math.min(500,Math.round(t)));B(s);try{localStorage.setItem("playerVideoDelayMs",String(s))}catch{}},ut=()=>{He.current={enabled:Q,ms:p},j(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}k.setShowSettings(!1),Ee(!0)},re=()=>{const t=He.current;He.current=null,t&&(B(t.ms),j(t.enabled),G(t.ms,t.enabled)),Ge(!1),Ee(!1)},pe=()=>{He.current=null,j(!0),G(p,!0),Ge(!1),Ee(!1)},je=()=>{if(we){Ge(!1);return}const t=m.videoRef.current;t&&!isNaN(t.currentTime)&&(tt.current=t.currentTime),Ge(!0)},rt=Q?p:0,ft=f(null),ne=Rs({videoRef:m.videoRef,canvasRef:Ie,profile:o,delayMs:rt}),Ye=ne.isEnabled&&ne.isWebGPUSupported;tn({videoRef:m.videoRef,canvasRef:ft,delayMs:rt,enabled:Q&&!Ye});const h=Q&&!Ye,_=Ye||h;x(()=>{Re.current=e.resumeTime,l.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[I,Y]=q(null),[nt,wt]=q(!1),[st,ot]=q(!1),[kt,M]=q(!1),Oe=f(!1),[at,me]=q(null),Je=f(!1),ke=f([]),Le=f(!1),[vt,_e]=q(null),[gt,bt]=q(!1),[Xe,Tt]=q(!1),[Ct,Ft]=q(()=>As()??"ask"),dt=O(t=>{Ft(t),Bs(t==="ask"?null:t)},[]),L=f(Ct);L.current=Ct;const ce=f(e.videoSources);ce.current=e.videoSources;const Ne=f(()=>{}),[D,ue]=q(null),Te=f(v);x(()=>{Te.current!==v&&(Te.current=v,ue(null),me(null),Oe.current=!1,Ge(!1),Ee(!1))},[v]),x(()=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),bt(!1)},[n,e.currentEpisode]),x(()=>{st||(Oe.current=!1)},[st]);const{data:T=[],isLoading:Mt}=Vr(),We=Ur(),Ce=f(We);Ce.current=We;const he=Qr(),Ot=qr(),[se,ge]=q(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});x(()=>{try{se?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(t){console.error(t)}return()=>{try{document.body.classList.remove("theater-mode")}catch(t){console.error(t)}}},[se]),Or(()=>{if(a.state.isFullscreen||se)return;const t=m.playerContainerRef.current,s=Be.current;if(!t||!s)return;const i=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};i();const c=new ResizeObserver(i);return c.observe(t),()=>c.disconnect()},[a.state.isFullscreen,se,m.playerContainerRef]);const Ve=ct(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),Wt=Ve>0?e.episodes[Ve-1]:null,xe=Ve>=0&&Ve<e.episodes.length-1?e.episodes[Ve+1]:null,Vt=Ve>-1&&Ve<e.episodes.length-1,hr=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,fr=String(e.showMeta.status||"").trim().toLowerCase(),vr=["finished","completed","complete","ended"].some(t=>fr.includes(t)),Ut=rn(e.resumeTime,e.resumeDuration)||st,it=hr&&vr&&Ut,jt=e.showResumeModal&&(it||!Ut),xt=Ut&&!it&&T.length===0&&!D&&(e.showResumeModal||st),pt=jt||xt;nn(a,!!e.selectedLink&&!se&&!pt),x(()=>{const t=m.videoRef.current;if(!t)return;let s=!1;for(Se.current&&(Se.current.destroy(),Se.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(we)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ee.current=0;return}tt.current!=null?(ee.current=tt.current,tt.current=null):Re.current>5&&!l.current?ee.current=Re.current:l.current&&(ee.current=0);let i=e.selectedLink.link;if(i.startsWith("/api/proxy")||(i=`/api/proxy?url=${encodeURIComponent(i)}`,e.selectedLink.headers?.Referer&&(i+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const fe=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Me=null;try{Me=localStorage.getItem("playerLastSubtitle")}catch{}const J=Ht(e.selectedSource.subtitles,{lastKey:Me,enabled:fe}),Pe=J>=0?e.selectedSource.subtitles[J]:null;e.selectedSource.subtitles.forEach(be=>{const X=document.createElement("track");X.kind="subtitles",X.label=be.label,X.srclang=be.lang;const y=be.src??be.url;if(y){let Z=`/api/subtitle-proxy?url=${encodeURIComponent(y)}`;const ae=e.selectedLink?.headers?.Referer,yt=y.includes("anilight.live")?"https://anilight.live/":"",$t=ae||yt;$t&&(Z+=`&referer=${encodeURIComponent($t)}`),X.src=Z}Pe&&be.label===Pe.label&&be.lang===Pe.lang&&(X.default=!0),t.appendChild(X)}),fe||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const c=ee.current;ee.current=0;const N=()=>{c>0&&(t.currentTime=c)};t.addEventListener("loadedmetadata",N,{once:!0});const de=!(l.current&&Re.current>5),H=()=>{de&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const fe=await vn();if(s)return;if(!fe||!fe.isSupported()){t.src=i,H();return}const Me=document.body.classList.contains("low-end"),J=new fe({maxBufferLength:Me?15:30,maxMaxBufferLength:Me?30:60,maxBufferSize:Me?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});Se.current=J,J.on(fe.Events.ERROR,(X,y)=>{y.fatal&&!Je.current&&Ne.current()});const Pe=(e.selectedSource?.subtitles?.length??0)>0,be=()=>{try{Pe&&typeof J.subtitleTrack=="number"&&J.subtitleTrack!==-1&&(J.subtitleTrack=-1)}catch{}};J.on(fe.Events.SUBTITLE_TRACK_SWITCH,(X,y)=>{y?.id!==-1&&be()}),be(),J.loadSource(i),J.attachMedia(t),J.once(fe.Events.MANIFEST_PARSED,()=>{s||H()})})():(t.src=i,H());const F=localStorage.getItem("playerVolume"),oe=localStorage.getItem("playerMuted");return F!==null&&(t.volume=parseFloat(F)),oe!==null&&(t.muted=oe==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),Se.current&&(Se.current.destroy(),Se.current=null)}},[e.selectedSource,e.selectedLink,m.videoRef,k,e.loadingVideo,we]);const Pt=O(t=>{if(Je.current)return;Je.current=!0;const s=t.links[0];le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),_e(null)},[g,le]),At=O(()=>{const s=ce.current.find(i=>i.type==="iframe");return s?.links?.length?s:null},[]),Bt=O(async()=>{const t=e.showMeta?.isAdult,s=ie.filter(i=>{if(ke.current.includes(i))return!1;const c=ye.has(i);return t===void 0?!0:c===t});bt(!0);try{for(const i of s){ke.current.push(i);let c=null;try{c=await $e(`/api/video?showId=${n}&episodeNumber=${e.currentEpisode}&mode=${e.currentMode}&provider=${i}`)}catch{continue}const N=(c??[]).filter(F=>{const oe=F.sourceName.toLowerCase();return e.currentMode==="dub"?oe.includes("eng")||oe.includes("dub"):oe.includes("jpn")||oe.includes("sub")||!oe.includes("eng")&&!oe.includes("dub")});if((N.length>0?N:c??[]).find(F=>F.type!=="iframe"&&F.links?.length)){ke.current=[e.selectedProvider],Le.current=!1,g({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),_e(null),Qe.success(`Switched to ${i} (direct stream)`);return}}_e({retryFailed:!0}),Qe.error("No working direct stream found on other providers")}finally{bt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,g,ie,ye]),Yt=O(()=>{if(Je.current||Le.current||e.selectedSource?.type!=="player")return;const t=At();if(!t)return;ke.current.includes(e.selectedProvider)||ke.current.push(e.selectedProvider);const s=L.current;if(s==="iframe"){Pt(t);return}if(s==="retry"){Bt();return}k.setShowControls(!0),_e({retryFailed:!1})},[e.selectedSource,e.selectedProvider,At,Pt,Bt,k]);Ne.current=Yt;const gr=O(()=>{Le.current=!0,_e(null),Tt(!1)},[]),br=O(()=>{Xe&&dt("iframe");const t=At();t?Pt(t):_e(null)},[Xe,dt,At,Pt]),yr=O(()=>{Xe&&dt("retry"),Bt()},[Xe,dt,Bt]),Rt=(t,s,i)=>t.showId===s||!!i&&t.showId===i,It=O(()=>{k.onEnded();const t=T.find(i=>Rt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(T.length>0){const i=T.findIndex(N=>Rt(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),c=i>=0?T[i+1]||null:T[0];ue({nextItem:c,playedItem:t||null}),me(2)}else t&&Ce.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&T.length===0){const i=e.episodes.findIndex(c=>c===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const c=e.episodes[i+1];K.invalidateQueries({queryKey:["allContinueWatching"]}),w(`/watch/${n}/${c}`),s=!0}}if(!s&&T.length===0&&!D&&!Oe.current){const i=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,c=String(e.showMeta.status||"").trim().toLowerCase(),N=["finished","completed","complete","ended"].some(de=>c.includes(de));i&&N&&g({type:"SET_STATE",payload:{showResumeModal:!0}})}},[k,w,T,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,D,g,K]),Qt=O(()=>{if(T.length===0)return;k.onEnded();const t=T.find(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),s=T.findIndex(c=>Rt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),i=s>=0?T[s+1]||null:T[0];t&&We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?w(`/watch/${i.showId}/${i.episodeNumber}`):t&&g({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,w,T,We,n,e.showMeta?.id,e.currentEpisode,g]),_t=O(()=>{xe&&(K.invalidateQueries({queryKey:["allContinueWatching"]}),ot(!1),w(`/watch/${n}/${xe}`)),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[xe,w,n,g,K]),Jt=O(()=>{T.length>0?Qt():xe?_t():Qe.error("No next episode available")},[T.length,Qt,_t,xe]),Sr=()=>{Wt&&w(`/watch/${n}/${Wt}`)};x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>{we||It()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[It,m.videoRef,we]),x(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&It()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[It,e.selectedSource?.type]),x(()=>{if(!D||at===null)return;if(at<=0){const{nextItem:s,playedItem:i}=D;ue(null),me(null),i&&Ce.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),s?w(`/watch/${s.showId}/${s.episodeNumber}`):i&&g({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{me(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[D,at,w,g]),x(()=>{pt&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[pt,a.state.isFullscreen,a.actions]),x(()=>{pt&&m.videoRef.current&&m.videoRef.current.pause()},[pt,m.videoRef]);const{titlePreference:Lt}=zr(),mt=ct(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Lt==="name"?t||"Loading...":Lt==="nativeName"?s?.native||t||"Loading...":Lt==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Lt,e.loadingShowData]);x(()=>{mt&&mt!=="Loading..."&&e.currentEpisode&&(document.title=`► ${mt} Episode ${e.currentEpisode} - dango`)},[mt,e.currentEpisode]),x(()=>{const t=s=>{if(!s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')&&(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&Jt(),s.key.toLowerCase()==="t")){const c=!se;ge(c),localStorage.setItem("playerTheaterMode",c.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,a.actions.inactivityTimer,Jt,se]);const{setAvailableSubtitles:Xt,setActiveSubtitleTrack:qt}=k;x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>{const i=Array.from(t.textTracks).map(c=>({label:c.label,lang:c.language,src:void 0,mode:c.mode}));Xt(i)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[m.videoRef,Xt]),x(()=>{if(a.state.activeSubtitleTrack===null&&a.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Ht(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){qt("off");return}const i=a.state.availableSubtitles[s];qt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,qt]),x(()=>{const t=m.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const s=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let c=!1;if(Array.from(t.textTracks).forEach(N=>{const H=(N.language===s||N.label===s)&&!c;N.mode=H?"showing":"hidden",H&&(c=!0)}),!c&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(de=>de.language==="en"||de.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,m.videoRef]);const[Zt,Er]=q(0);x(()=>{const t=m.videoRef.current;if(!t)return;const s=()=>Er(t.clientHeight||0);s();const i=new ResizeObserver(s);return i.observe(t),()=>i.disconnect()},[m.videoRef,e.selectedSource,e.selectedLink]),x(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const i={fontSize:a.state.subtitleFontSize,position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold};s.textContent=ir(i);const c=m.videoRef.current;if(!c)return;const N=lr(a.state.subtitleFontSize,Zt||c.clientHeight||720);s.textContent=ir({...i,fontSize:N});const de=()=>{const y=Number(a.state.subtitlePosition),Z=isNaN(y)?0:Math.max(0,Math.min(100,y));return Math.max(0,Math.min(100,100-Z))},H=(y,Z)=>{try{const ae=y;ae.snapToLines=!1,ae.line=Z}catch{}},F=()=>{const y=N*16,Z=c.videoHeight||c.clientHeight||720,ae=c.videoWidth||c.clientWidth||1280;return{step:y*1.3/Z*100,chars:Math.max(20,Math.floor(ae/(y*.55)))}},oe=y=>{const Z=de(),ae=Array.from(y.activeCues??[]);if(ae.length<=1){ae.forEach(St=>H(St,Z));return}const{step:yt,chars:$t}=F();let sr=Z;for(let St=ae.length-1;St>=0;St--){const xr=String(ae[St].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
55
|
`).reduce((Pr,Ar)=>Pr+Math.max(1,Math.ceil(Ar.length/$t)),0),or=sr-xr*yt;H(ae[St],Math.max(0,or)),sr=or-yt*.4}},fe=y=>{if(!y.cues)return;const Z=de();Array.from(y.cues).forEach(ae=>H(ae,Z)),y.mode==="showing"&&oe(y)},Me=()=>{Array.from(c.textTracks).forEach(fe)};Me();const J=y=>{const Z=y.target;Z.mode==="showing"&&oe(Z)};Array.from(c.textTracks).forEach(y=>{y.addEventListener("cuechange",J)});const Pe=()=>{Array.from(c.textTracks).forEach(y=>{y.removeEventListener("cuechange",J),y.addEventListener("cuechange",J)}),Me()};c.textTracks.addEventListener("addtrack",Pe),c.textTracks.addEventListener("removetrack",Pe);const be=Array.from(c.querySelectorAll("track")),X=()=>{Me()};return be.forEach(y=>{y.addEventListener("load",X)}),()=>{Array.from(c.textTracks).forEach(y=>{y.removeEventListener("cuechange",J)}),c.textTracks.removeEventListener("addtrack",Pe),c.textTracks.removeEventListener("removetrack",Pe),be.forEach(y=>{y.removeEventListener("load",X)})}},[a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,a.state.availableSubtitles,e.selectedSource,e.selectedLink,m.videoRef,Zt]),x(()=>{if(!_)return;const t=m.videoRef.current,s=ze.current;if(!t||!s)return;const i=localStorage.getItem("playerSubtitlesEnabled")!=="false",c=a.state.activeSubtitleTrack;function N(){if(s.innerHTML="",!i||c==="off"||c===null)return;const F=Array.from(t.textTracks).find(X=>X.language===c||X.label===c);if(!F||F.mode!=="showing")return;const oe=rt/1e3;let fe;if(oe>0&&F.cues){const X=t.currentTime-oe;fe=Array.from(F.cues).filter(y=>y.startTime<=X&&X<=y.endTime)}else fe=Array.from(F.activeCues??[]);if(fe.length===0)return;const Me={fontSize:lr(a.state.subtitleFontSize,t.clientHeight||0),position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold},J=sn(Me),Pe=on(t,Me.position),be=Array.from(fe);be.forEach((X,y)=>{const Z=String(X.text??"");if(!an(Z).trim())return;const ae=document.createElement("div"),yt=(be.length-1-y)*1.7;ae.style.cssText=`${J}
|
|
56
|
-
bottom: calc(${Pe}px + ${yt}em);`,ae.innerHTML=ln(Z),s.appendChild(ae)})}const de=()=>N(),H=()=>N();return Array.from(t.textTracks).forEach(F=>{F.addEventListener("cuechange",de)}),t.addEventListener("timeupdate",H),N(),()=>{Array.from(t.textTracks).forEach(F=>{F.removeEventListener("cuechange",de)}),t.removeEventListener("timeupdate",H),s.innerHTML=""}},[ne.isEnabled,ne.isWebGPUSupported,a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,m.videoRef,_,rt]),x(()=>{try{localStorage.setItem("anime4kProfile",o)}catch{}},[o]);const wr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=e.resumeTime,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=0,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},er=O(()=>{it&&(Oe.current=!0),xt&&ot(!1),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,it,xt]),Tr=O(()=>{if(ot(!1),m.videoRef.current)try{m.videoRef.current.currentTime=0,m.videoRef.current.play().catch(()=>{})}catch{}g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,m]),Cr=O(async()=>{try{await U(),g({type:"SET_STATE",payload:{showResumeModal:!1}}),w("/")}catch{}},[U,g,w]),tr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${u.episodeNavBtn} ${u.secondary}`,onClick:Sr,disabled:!Wt,type:"button",children:[r(W,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${u.episodeNavBtn} ${u.primary}`,onClick:_t,disabled:!xe,type:"button",children:["Next EP",r(W,{name:"chevron-right",size:12})]}),s==="mobile"&&Fe&&r("button",{className:`${u.episodeNavBtn} ${u.episodePickerBtn}`,onClick:()=>M(!0),type:"button",children:[r(W,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{st&&(e.showResumeModal||T.length>0||D||Oe.current||it&&g({type:"SET_STATE",payload:{showResumeModal:!0}}))},[st,it,e.showResumeModal,T.length,D,g]);const Mr=t=>{g({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),fn(t)},rr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Rr=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",zt=f(A);zt.current=A;const nr=f("");x(()=>{const t=m.videoRef.current;if(wt(!1),ot(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const i=t.duration,c=t.currentTime;if(!i||Number.isNaN(i)){wt(!1),ot(!1);return}const N=c/i;if(i-c<=60){const de=T.findIndex(oe=>Rt(oe,n,e.showMeta?.id)&&oe.episodeNumber===e.currentEpisode),H=T.length>0?de>=0?T[de+1]||null:T[0]:null,F=H?`${H.showId}:${H.episodeNumber}`:Vt?`${n}:${xe}`:"";F&&nr.current!==F&&(nr.current=F,H?zt.current(H.episodeNumber,H.showId):zt.current(xe))}wt(Vt&&N>=.8),ot(c>=Math.max(i*.98,i-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[m.videoRef,Vt,e.currentEpisode,e.selectedSource,xe,n,T,e.showMeta?.id]);const _r=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=m.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await ve(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,ve,$,m.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const lt=e.loadingShowData||e.loadingVideo,Nr=t=>{se&&t.target===t.currentTarget&&(ge(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!C?r("div",{className:Ue.playerPageLayout,children:r(Ae,{isOpen:!0,title:"Content Warning",onClose:()=>w("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(Ze,{variant:"secondary",onClick:()=>w("/home"),children:"Go Back"}),r(Ze,{onClick:S,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Ue.playerPageLayout} ${se?Ue.theaterMode:""}`,onClick:Nr,children:[r(Ae,{isOpen:jt,onClose:er,title:it?"Show Completed!":"Resume Playback?",width:"sm",children:it?r(Et,{children:[r(Ae.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Ae.Actions,{children:r(Ze,{onClick:Cr,disabled:De,children:De?"Saving...":"Move to Completed"})})]}):r(Et,{children:[r(Ae.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:kr,children:"Start Over"}),r(Ze,{onClick:wr,children:"Resume"})]})]})}),r(Ae,{isOpen:xt,onClose:er,title:"Episode Completed",width:"sm",children:[r(Ae.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",xe?" Would you like to watch the next episode?":""]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:Tr,children:"Replay"}),xe&&r(Ze,{onClick:_t,children:`Watch EP ${xe}`})]})]}),r(Ae,{isOpen:!!ft,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Ae.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),ft?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:Xe,onChange:t=>Tt(t.target.checked)}),"Remember my choice"]})]}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(Ze,{onClick:yr,disabled:vt,children:vt?"Searching…":"Try another provider"})]})]}),r(Gr,{isOpen:!!e.showCookieModal,onClose:()=>g({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{K.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!se&&r("aside",{ref:Be,className:Ue.episodeSidebar,children:e.loadingShowData?r(cn,{variant:"sidebar"}):r(un,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>w(`/watch/${n}/${t}`)})}),r("div",{className:Ue.playerMain,children:[r("div",{className:`${u.videoContainer} ${a.state.isFullscreen?"":Ue.videoPlayerWrapper} ${a.state.isFullscreen?u.fullscreenActive:""}`,style:{...bt?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(us,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Mr,fallbackChoice:Ct,onFallbackChoiceChange:dt,showNextEpisodeButton:!bt&&nt&&T.length===0,onNextEpisode:_t,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(ee.current=m.videoRef.current.currentTime),le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:e.loadingVideo,skipIntervals:e.skipIntervals,animeTitle:pt,episodeNumber:e.currentEpisode,isTheaterMode:se,onTheaterModeToggle:()=>{const t=!se;ge(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:ne.isEnabled,onAnime4kToggle:ne.toggle,anime4kSupported:ne.isWebGPUSupported,anime4kProfile:o,onAnime4kProfileChange:d,anime4kInitializing:ne.isInitializing,anime4kError:ne.error,videoDelayEnabled:Q,onVideoDelayToggle:t=>{j(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:p,onVideoDelayChange:Ke,onCalibrateAvSync:ut,isInteractingExtra:kt||te,className:dn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Et,{children:[a.state.isSpeedBoostActive&&r("div",{className:u.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(W,{name:"forward",size:12})]}),at!==null&&D?.nextItem&&r("div",{className:u.queueCountdown,children:["Queue next in ",at,"s"]})]}),children:[I&&r("div",{className:`${u.skipIndicatorContainer} ${I.side==="left"?u.leftSkip:u.rightSkip} `,children:r("div",{className:u.skipBubble,children:[r("div",{className:u.skipIcon,children:I.side==="left"?r(W,{name:"backward"}):r(W,{name:"forward"})}),r("div",{className:u.skipText,children:"15s"})]})}),lt&&r("div",{className:u.loadingOverlay,children:r("div",{className:u.loadingDots,children:[r("div",{className:u.dot}),r("div",{className:u.dot}),r("div",{className:u.dot})]})}),a.state.isBuffering&&!lt&&e.selectedSource?.type!=="iframe"&&r("div",{className:u.bufferingOverlay,children:r("div",{className:u.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!lt&&r("iframe",{src:e.selectedLink?.link,className:u.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}):r(Et,{children:[!lt&&e.videoSources.length===0&&r("div",{className:u.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:u.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:u.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!lt&&e.videoSources.length>0&&r("video",{ref:m.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{we||(k.onTimeUpdate(),D&&m.videoRef.current&&m.videoRef.current.currentTime<m.videoRef.current.duration-1&&(ue(null),me(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onError:Yt,onContextMenu:t=>t.preventDefault(),className:_?u.videoElementHidden:""}),ne.isWebGPUSupported&&!lt&&e.videoSources.length>0&&r("canvas",{ref:Ie,className:`${u.upscalerCanvas} ${Ye?u.upscalerActive:""}`}),!Ye&&!lt&&e.videoSources.length>0&&r("canvas",{ref:ht,className:`${u.upscalerCanvas} ${h?u.upscalerActive:""}`}),ne.isEnabled&&ne.isWebGPUSupported&&ne.isInitializing&&r("div",{className:u.upscalerStatusBadge,children:"Preparing upscaler…"}),_&&r("div",{ref:ze,className:u.subtitleOverlay}),r(pn,{isOpen:te,ms:p,onChange:Ke,onApply:pe,onClose:re,testClipActive:we,onTestClip:je})]})]})}),!se&&r(mn,{}),!se&&r(Et,{children:[Mt&&T.length===0?r(ds,{count:3}):r(yn,{title:"Queue",items:T,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>he.mutate(),showClearAll:!0,onReorder:t=>Ot.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:u.providerAndEpisodeRow,children:[r(ys,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:R,onProviderChange:t=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),tr(`${u.episodeActions} ${u.desktopEpisodeActions}`,"desktop")]}),lt?r("div",{className:u.sourceLoader,children:r("div",{className:u.spinner})}):r(Et,{children:r(Es,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(ee.current=m.videoRef.current.currentTime);const i=(t.links||[]).sort((c,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(c.resolutionStr)||0))[0]||null;le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(le(e.selectedSource.sourceName),g({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Ue.playerInfoContainer,children:[r("div",{className:Ue.playerInfoHeader,children:[r("div",{className:Ue.playerAnimeCard,children:r("img",{src:Hr(e.showMeta.thumbnail||""),alt:pt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Ue.videoTitleSection,children:[r("div",{className:u.titleContainer,children:[r("h1",{children:pt}),r("div",{className:u.scheduleInfo,children:[e.showMeta.status&&r("span",{className:u.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:u.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:u.controls,children:[r("button",{className:`${u.watchlistBtn} ${e.inWatchlist?u.inList:""}`,onClick:V,children:[e.inWatchlist?r(W,{name:"check",size:14}):r(W,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(En,{showId:n,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:`${u.watchlistBtn} ${u.queueBtn}`,activeClassName:u.queueActive}),Rr&&r("button",{className:`${u.watchlistBtn} ${u.markWatchedBtn} ${rr?u.markWatchedDone:""}`,onClick:_r,disabled:$||!e.currentEpisode,children:[r(W,{name:"check",size:14}),$?"Saving...":rr?"Watched":"Mark Watched"]}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${e.currentMode==="dub"?u.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${a.state.useNativeControls?u.modeToggleActive:""}`,onClick:()=>{const t=!a.state.useNativeControls;a.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:a.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),tr(`${u.episodeActions} ${u.mobileEpisodeActions}`,"mobile"),r("div",{className:u.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(kn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:u.detailsToggleBtn,onClick:z,children:[e.showCombinedDetails?r(W,{name:"chevron-up"}):r(W,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(wn,{showMeta:e.showMeta,styles:u})]})]})]}),r(hn,{isOpen:kt,onClose:()=>M(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{M(!1),w(`/watch/${n}/${t}`)}})]})};export{Xs as default};
|
|
56
|
+
bottom: calc(${Pe}px + ${yt}em);`,ae.innerHTML=ln(Z),s.appendChild(ae)})}const de=()=>N(),H=()=>N();return Array.from(t.textTracks).forEach(F=>{F.addEventListener("cuechange",de)}),t.addEventListener("timeupdate",H),N(),()=>{Array.from(t.textTracks).forEach(F=>{F.removeEventListener("cuechange",de)}),t.removeEventListener("timeupdate",H),s.innerHTML=""}},[ne.isEnabled,ne.isWebGPUSupported,a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,m.videoRef,_,rt]),x(()=>{try{localStorage.setItem("anime4kProfile",o)}catch{}},[o]);const wr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=e.resumeTime,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{m.videoRef.current&&(m.videoRef.current.currentTime=0,m.videoRef.current.play()),g({type:"SET_STATE",payload:{showResumeModal:!1}})},er=O(()=>{it&&(Oe.current=!0),xt&&ot(!1),g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,it,xt]),Tr=O(()=>{if(ot(!1),m.videoRef.current)try{m.videoRef.current.currentTime=0,m.videoRef.current.play().catch(()=>{})}catch{}g({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,m]),Cr=O(async()=>{try{await U(),g({type:"SET_STATE",payload:{showResumeModal:!1}}),w("/")}catch{}},[U,g,w]),tr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${u.episodeNavBtn} ${u.secondary}`,onClick:Sr,disabled:!Wt,type:"button",children:[r(W,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${u.episodeNavBtn} ${u.primary}`,onClick:_t,disabled:!xe,type:"button",children:["Next EP",r(W,{name:"chevron-right",size:12})]}),s==="mobile"&&Fe&&r("button",{className:`${u.episodeNavBtn} ${u.episodePickerBtn}`,onClick:()=>M(!0),type:"button",children:[r(W,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{st&&(e.showResumeModal||T.length>0||D||Oe.current||it&&g({type:"SET_STATE",payload:{showResumeModal:!0}}))},[st,it,e.showResumeModal,T.length,D,g]);const Mr=t=>{g({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),fn(t)},rr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Rr=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",zt=f(A);zt.current=A;const nr=f("");x(()=>{const t=m.videoRef.current;if(wt(!1),ot(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const i=t.duration,c=t.currentTime;if(!i||Number.isNaN(i)){wt(!1),ot(!1);return}const N=c/i;if(i-c<=60){const de=T.findIndex(oe=>Rt(oe,n,e.showMeta?.id)&&oe.episodeNumber===e.currentEpisode),H=T.length>0?de>=0?T[de+1]||null:T[0]:null,F=H?`${H.showId}:${H.episodeNumber}`:Vt?`${n}:${xe}`:"";F&&nr.current!==F&&(nr.current=F,H?zt.current(H.episodeNumber,H.showId):zt.current(xe))}wt(Vt&&N>=.8),ot(c>=Math.max(i*.98,i-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[m.videoRef,Vt,e.currentEpisode,e.selectedSource,xe,n,T,e.showMeta?.id]);const _r=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=m.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await ve(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,ve,$,m.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const lt=e.loadingShowData||e.loadingVideo,Nr=t=>{se&&t.target===t.currentTarget&&(ge(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!C?r("div",{className:Ue.playerPageLayout,children:r(Ae,{isOpen:!0,title:"Content Warning",onClose:()=>w("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(Ze,{variant:"secondary",onClick:()=>w("/home"),children:"Go Back"}),r(Ze,{onClick:S,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Ue.playerPageLayout} ${se?Ue.theaterMode:""}`,onClick:Nr,children:[r(Ae,{isOpen:jt,onClose:er,title:it?"Show Completed!":"Resume Playback?",width:"sm",children:it?r(Et,{children:[r(Ae.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Ae.Actions,{children:r(Ze,{onClick:Cr,disabled:De,children:De?"Saving...":"Move to Completed"})})]}):r(Et,{children:[r(Ae.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:kr,children:"Start Over"}),r(Ze,{onClick:wr,children:"Resume"})]})]})}),r(Ae,{isOpen:xt,onClose:er,title:"Episode Completed",width:"sm",children:[r(Ae.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",xe?" Would you like to watch the next episode?":""]})}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:Tr,children:"Replay"}),xe&&r(Ze,{onClick:_t,children:`Watch EP ${xe}`})]})]}),r(Ae,{isOpen:!!vt,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Ae.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),vt?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:Xe,onChange:t=>Tt(t.target.checked)}),"Remember my choice"]})]}),r(Ae.Actions,{children:[r(Ze,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(Ze,{onClick:yr,disabled:gt,children:gt?"Searching…":"Try another provider"})]})]}),r(Gr,{isOpen:!!e.showCookieModal,onClose:()=>g({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{K.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!se&&r("aside",{ref:Be,className:Ue.episodeSidebar,children:e.loadingShowData?r(cn,{variant:"sidebar"}):r(un,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>w(`/watch/${n}/${t}`)})}),r("div",{className:Ue.playerMain,children:[r("div",{className:`${u.videoContainer} ${a.state.isFullscreen?"":Ue.videoPlayerWrapper} ${a.state.isFullscreen?u.fullscreenActive:""}`,style:{...pt?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(us,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Mr,fallbackChoice:Ct,onFallbackChoiceChange:dt,showNextEpisodeButton:!pt&&nt&&T.length===0,onNextEpisode:_t,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(ee.current=m.videoRef.current.currentTime),le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:e.loadingVideo,skipIntervals:e.skipIntervals,animeTitle:mt,episodeNumber:e.currentEpisode,isTheaterMode:se,onTheaterModeToggle:()=>{const t=!se;ge(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:ne.isEnabled,onAnime4kToggle:ne.toggle,anime4kSupported:ne.isWebGPUSupported,anime4kProfile:o,onAnime4kProfileChange:d,anime4kInitializing:ne.isInitializing,anime4kError:ne.error,videoDelayEnabled:Q,onVideoDelayToggle:t=>{j(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:p,onVideoDelayChange:Ke,onCalibrateAvSync:ut,isInteractingExtra:kt||te,className:dn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Et,{children:[a.state.isSpeedBoostActive&&r("div",{className:u.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(W,{name:"forward",size:12})]}),at!==null&&D?.nextItem&&r("div",{className:u.queueCountdown,children:["Queue next in ",at,"s"]})]}),children:[I&&r("div",{className:`${u.skipIndicatorContainer} ${I.side==="left"?u.leftSkip:u.rightSkip} `,children:r("div",{className:u.skipBubble,children:[r("div",{className:u.skipIcon,children:I.side==="left"?r(W,{name:"backward"}):r(W,{name:"forward"})}),r("div",{className:u.skipText,children:"15s"})]})}),lt&&r("div",{className:u.loadingOverlay,children:r("div",{className:u.loadingDots,children:[r("div",{className:u.dot}),r("div",{className:u.dot}),r("div",{className:u.dot})]})}),a.state.isBuffering&&!lt&&e.selectedSource?.type!=="iframe"&&r("div",{className:u.bufferingOverlay,children:r("div",{className:u.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!lt&&r("iframe",{src:e.selectedLink?.link,className:u.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}):r(Et,{children:[!lt&&e.videoSources.length===0&&r("div",{className:u.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:u.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:u.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!lt&&e.videoSources.length>0&&r("video",{ref:m.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{we||(k.onTimeUpdate(),D&&m.videoRef.current&&m.videoRef.current.currentTime<m.videoRef.current.duration-1&&(ue(null),me(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onError:Yt,onContextMenu:t=>t.preventDefault(),className:_?u.videoElementHidden:""}),ne.isWebGPUSupported&&!lt&&e.videoSources.length>0&&r("canvas",{ref:Ie,className:`${u.upscalerCanvas} ${Ye?u.upscalerActive:""}`}),!Ye&&!lt&&e.videoSources.length>0&&r("canvas",{ref:ft,className:`${u.upscalerCanvas} ${h?u.upscalerActive:""}`}),ne.isEnabled&&ne.isWebGPUSupported&&ne.isInitializing&&r("div",{className:u.upscalerStatusBadge,children:"Preparing upscaler…"}),_&&r("div",{ref:ze,className:u.subtitleOverlay}),r(pn,{isOpen:te,ms:p,onChange:Ke,onApply:pe,onClose:re,testClipActive:we,onTestClip:je})]})]})}),!se&&r(mn,{}),!se&&r(Et,{children:[Mt&&T.length===0?r(ds,{count:3}):r(yn,{title:"Queue",items:T,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>We.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>he.mutate(),showClearAll:!0,onReorder:t=>Ot.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:u.providerAndEpisodeRow,children:[r(ys,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:R,onProviderChange:t=>{Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),tr(`${u.episodeActions} ${u.desktopEpisodeActions}`,"desktop")]}),lt?r("div",{className:u.sourceLoader,children:r("div",{className:u.spinner})}):r(Et,{children:r(Es,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{m.videoRef.current&&!isNaN(m.videoRef.current.currentTime)&&(ee.current=m.videoRef.current.currentTime);const i=(t.links||[]).sort((c,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(c.resolutionStr)||0))[0]||null;le(t.sourceName),g({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(le(e.selectedSource.sourceName),g({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Ue.playerInfoContainer,children:[r("div",{className:Ue.playerInfoHeader,children:[r("div",{className:Ue.playerAnimeCard,children:r("img",{src:Hr(e.showMeta.thumbnail||""),alt:mt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Ue.videoTitleSection,children:[r("div",{className:u.titleContainer,children:[r("h1",{children:mt}),r("div",{className:u.scheduleInfo,children:[e.showMeta.status&&r("span",{className:u.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:u.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:u.controls,children:[r("button",{className:`${u.watchlistBtn} ${e.inWatchlist?u.inList:""}`,onClick:V,children:[e.inWatchlist?r(W,{name:"check",size:14}):r(W,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(En,{showId:n,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:`${u.watchlistBtn} ${u.queueBtn}`,activeClassName:u.queueActive}),Rr&&r("button",{className:`${u.watchlistBtn} ${u.markWatchedBtn} ${rr?u.markWatchedDone:""}`,onClick:_r,disabled:$||!e.currentEpisode,children:[r(W,{name:"check",size:14}),$?"Saving...":rr?"Watched":"Mark Watched"]}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${e.currentMode==="dub"?u.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Je.current=!1,ke.current=[],Le.current=!1,_e(null),g({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${a.state.useNativeControls?u.modeToggleActive:""}`,onClick:()=>{const t=!a.state.useNativeControls;a.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:a.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),tr(`${u.episodeActions} ${u.mobileEpisodeActions}`,"mobile"),r("div",{className:u.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(kn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:u.detailsToggleBtn,onClick:z,children:[e.showCombinedDetails?r(W,{name:"chevron-up"}):r(W,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(wn,{showMeta:e.showMeta,styles:u})]})]})]}),r(hn,{isOpen:kt,onClose:()=>M(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{M(!1),w(`/watch/${n}/${t}`)}})]})};export{Xs as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as I,d as J,T as X,u as e}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{S as Y,O as _,a as Z,A as ee}from"./OptionListMenu-
|
|
1
|
+
import{g as I,d as J,T as X,u as e}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{S as Y,O as _,a as Z,A as ee}from"./OptionListMenu-CkK2BvEz.js";import"./AvSyncCalibrator-oK6LlG61.js";import"./index-lo-bz7f2.js";import"./vendor-query-BXRECSI6.js";const ne="_settingsPanel_y6z3b_1",te="_header_y6z3b_33",ae="_backBtn_y6z3b_56",se="_contentWrapper_y6z3b_76",le="_menuContent_y6z3b_82",ie="_menuItem_y6z3b_89",re="_selected_y6z3b_114",ce="_currentValue_y6z3b_134",oe="_menuNote_y6z3b_141",de="_menuError_y6z3b_150",n={settingsPanel:ne,header:te,backBtn:ae,contentWrapper:se,menuContent:le,menuItem:ie,selected:re,currentValue:ce,menuNote:oe,menuError:de},me=(A,z)=>{const{isOpen:b,onClose:ue,videoSources:he,currentSource:v,currentLink:k,onSourceChange:w,subtitles:$,activeSubtitleTrack:y,onSubtitleChange:P,subtitleSettings:V,onSubtitleSettingsChange:O,useNativeControls:g,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:C,anime4kProfile:i,onAnime4kProfileChange:h,anime4kInitializing:E,anime4kError:f,videoDelayEnabled:N,onVideoDelayToggle:T,videoDelayMs:S,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:d,onAutoSkipChange:L,isAutoplayEnabled:m,onAutoplayChange:M,fallbackChoice:p,onFallbackChoiceChange:W}=A,[a,r]=J("main");I.useEffect(()=>{if(!b){const t=setTimeout(()=>r("main"),300);return()=>clearTimeout(t)}},[b]);const G=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>r("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:k?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:y||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),e("button",{className:`${n.menuItem} ${g?n.selected:""}`,onClick:()=>{const t=!g;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),g&&e(o,{name:"check",size:12})]}),C&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),C&&u&&e("button",{className:n.menuItem,onClick:()=>r("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>r("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:N?`${S}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[d?"Auto-skip On":null,m?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]})]}),j=()=>{const t=v?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:k?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&w(v,c)}})})},q=()=>e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:y==="off"},...$.map(t=>({key:t.label||t.lang,label:t.label,selected:y===(t.label||t.lang)}))],onSelect:t=>P(t)})}),F=()=>e("div",{className:n.menuContent,children:e(Z,{classes:{item:n.menuItem,active:n.selected},values:V,onChange:O})}),Q=X(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),R=()=>e("div",{className:n.menuContent,children:[E&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),f&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",f]}),!Q&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${i==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),i==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),i==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),i==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),i==="denoise"&&e(o,{name:"check",size:12})]})]}),H=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>L(!d),"aria-pressed":d,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>M(!m),"aria-pressed":m,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>W(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),K=()=>e("div",{className:n.menuContent,children:e(ee,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:N,delayMs:S,onToggle:T,onDelayChange:D,onCalibrate:x})});return b?e(Y,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>r("main"),panelRef:z,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&G(),a==="quality"&&j(),a==="subtitles"&&q(),a==="subtitle-style"&&F(),a==="upscaler"&&R(),a==="av-sync"&&K(),a==="playback"&&H()]}):null},Ce=I.forwardRef(me);export{Ce as default};
|
package/client/dist/assets/{QueueOptionsButton-BKNDfpCl.js → QueueOptionsButton-DKWi-9kd.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as A}from"./vendor-query-BXRECSI6.js";import{q as V,j as Z,Z as H,$ as J,a0 as W}from"./index-
|
|
1
|
+
import{b as A}from"./vendor-query-BXRECSI6.js";import{q as V,j as Z,Z as H,$ as J,a0 as W}from"./index-lo-bz7f2.js";import{d as X,T as R,q as r,u as t,$ as Y,S as w}from"./vendor-core-8R2fFbyN.js";import{a as ee,c as te,d as ne,b as se,o as oe,f as ae,s as ie}from"./vendor-ui-CUDCvRS_.js";import{I as u}from"./vendor-icons-CDMuNDeL.js";function Pe(n){return A({queryKey:["show-meta",n],queryFn:async()=>n?V(`/api/show-meta/${n}`):{},enabled:!!n,staleTime:3e4})}async function re(n){const d=await fetch(`/api/queue/suggested/${n}`);if(!d.ok)throw new Error("Failed to resolve suggested episode");return d.json()}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",pe="_menuTitle_1vova_51",de="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",a={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:pe,menuItem:de,removeItem:ge,menuEmpty:fe},ve=8,$e=({showId:n,showName:d,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:F="",activeClassName:T="",align:z="right",onMenuOpenChange:g})=>{const{data:E=[]}=Z(),P=H(),$=J(),[m,v]=X(!1),{refs:q,floatingStyles:D,context:x}=ee({open:m,onOpenChange:e=>{e||(v(!1),g?.(!1))},placement:z==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ae({padding:8}),ie({padding:8})],whileElementsMounted:se}),I=te(x,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:M,getFloatingProps:S}=ne([I]),l=R(()=>E.filter(e=>e.showId===n),[E,n]),{data:C}=A({queryKey:["suggestedEpisode",n],queryFn:()=>re(n),enabled:!!n}),{data:Q,isFetching:N}=W(n,m),s=R(()=>Q?.episodes||[],[Q]),k=r(()=>{v(!0),g?.(!0)},[g]),c=r(()=>{v(!1),g?.(!1)},[g]),p=l.length>0,o=s.length>0,f=C?.episodeNumber,i=r(e=>{!n||e.length===0||(P.mutate({showId:n,episodeNumbers:e,showName:d,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,d,h,y,_,b,P,c]),K=r(()=>{!n||l.length===0||($.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,$,c]),j=r(()=>{o?i([s[0]]):f&&i([String(f)])},[o,s,f,i]),L=r(()=>{o&&i(s.slice(0,3))},[o,s,i]),O=r(()=>{o&&i([...s])},[o,s,i]),B=s[0],U=s[Math.min(2,s.length-1)],G=t("div",{className:a.trigger,ref:q.setReference,children:t("span",{className:`${a.triggerBtn} ${F} ${p?T:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":p?"Queued":"Queue",...M(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[p?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),p?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:a.chevron})]})});return t(w,{children:[G,m&&Y(t("div",{ref:q.setFloating,className:a.menu,style:D,role:"menu",...S(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:a.menuTitle,children:"Queue episodes"}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o&&!f,onClick:e=>{e.stopPropagation(),j()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+1 — EP ${B}`:`+1 — EP ${f||"?"}`})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),L()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+3 — EP ${B}${s.length>1?`-${U}`:""}`:"+3"})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:a.menuEmpty,children:p?"All episodes are already queued":"No remaining unwatched episodes"}),p&&t("button",{className:`${a.menuItem} ${a.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),K()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{$e as Q,Pe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as s,u as n,a as Y}from"./vendor-core-8R2fFbyN.js";import{I as P}from"./vendor-icons-CDMuNDeL.js";import{d as L,f as z}from"./index-
|
|
1
|
+
import{g as s,u as n,a as Y}from"./vendor-core-8R2fFbyN.js";import{I as P}from"./vendor-icons-CDMuNDeL.js";import{d as L,f as z}from"./index-lo-bz7f2.js";const F="_section_1pwqc_1",O="_header_1pwqc_10",j="_headerToggle_1pwqc_20",G="_headerActions_1pwqc_34",J="_title_1pwqc_40",K="_badge_1pwqc_50",V="_clearBtn_1pwqc_65",W="_nextBtn_1pwqc_83",Z="_list_1pwqc_101",ee="_item_1pwqc_114",ne="_active_1pwqc_134",te="_dragging_1pwqc_142",re="_dragHandle_1pwqc_149",ce="_thumbnail_1pwqc_167",ae="_meta_1pwqc_175",oe="_name_1pwqc_182",se="_episode_1pwqc_204",ie="_iconBtn_1pwqc_210",r={section:F,header:O,headerToggle:j,headerActions:G,title:J,badge:K,clearBtn:V,nextBtn:W,list:Z,item:ee,active:ne,dragging:te,dragHandle:re,thumbnail:ce,meta:ae,name:oe,episode:se,iconBtn:ie},le=({item:c,isActive:T,index:m,onRemove:D,onTouchPointerDown:v,onTouchPointerMove:x,onTouchPointerUp:q,onTouchPointerCancel:I,shouldIgnoreClick:_,onDragStart:B,onDragEnter:f,onDragEnd:o,isDragging:w})=>{const a=Y(),{titlePreference:i}=L(),l=c[i]||c.name||"Unknown show";return n("div",{"data-queue-index":m,className:`${r.item} ${T?r.active:""} ${w?r.dragging:""}`,draggable:!0,onDragStart:B,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:o,onPointerDown:u=>v(m,u),onPointerMove:x,onPointerUp:q,onPointerCancel:I,children:[n("button",{className:r.dragHandle,type:"button","aria-label":"Drag queue item",children:n(P,{name:"bars"})}),n("img",{className:r.thumbnail,src:z(c.thumbnail||"",72,96),alt:l,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:r.meta,children:[n("button",{className:r.name,type:"button",onClick:()=>{_()||a(`/watch/${c.showId}/${c.episodeNumber}`)},children:l}),n("div",{className:r.episode,children:["Episode ",c.episodeNumber]})]}),n("button",{className:r.iconBtn,type:"button",onClick:()=>{_()||D(c)},"aria-label":`Remove ${l} episode ${c.episodeNumber} from queue`,children:n(P,{name:"times"})})]})},he=({title:c="Queue",eyebrow:T,items:m,currentShowId:D,currentEpisode:v,onRemove:x,onReorder:q,onNextQueue:I,onClear:_,showClearAll:B=!1,defaultExpanded:f=!0})=>{const[o,w]=s.useState([]),[a,i]=s.useState(null),[l,u]=s.useState(f),b=s.useRef(null),N=s.useRef(null),d=s.useRef(null),p=s.useRef(!1),R=s.useRef(!1);s.useEffect(()=>{w(m)},[m]),s.useEffect(()=>{u(f)},[f]);const E=e=>{i(e)},$=e=>{if(a===null||a===e)return;const t=[...o],h=t[a];t.splice(a,1),t.splice(e,0,h),i(e),w(t)},k=()=>{a!==null&&q(o.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),i(null)},C=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&p.current&&(q(o.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),R.current=!0,window.setTimeout(()=>{R.current=!1},0)),b.current=null,N.current=null,p.current=!1,i(null)},A=(e,t)=>{if(t.pointerType==="mouse")return;const h=t.currentTarget,g=t.pointerId;b.current=t.pointerId,N.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{p.current=!0,i(e);try{h.setPointerCapture(g)}catch{}},220)},Q=e=>{if(e.pointerType==="mouse"||b.current!==e.pointerId)return;if(!p.current&&N.current){const H=Math.abs(e.clientX-N.current.x),X=Math.abs(e.clientY-N.current.y);(H>8||X>8)&&C(!1);return}if(!p.current)return;e.preventDefault();const h=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),g=h?Number(h.dataset.queueIndex):NaN;if(Number.isNaN(g)||a===null||g===a)return;const y=[...o],U=y[a];y.splice(a,1),y.splice(g,0,U),i(g),w(y)},S=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(p.current)},M=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(!1)};return o.length===0?null:n("section",{className:r.section,children:[n("div",{className:r.header,children:[n("button",{className:r.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":l,"aria-label":l?`Collapse ${c}`:`Expand ${c}`,children:[n("span",{className:r.title,children:[n("span",{className:"title-stack",children:[T&&n("div",{className:"section-eyebrow",children:T}),n("span",{children:c})]}),n("span",{className:r.badge,children:o.length})]}),l?n(P,{name:"chevron-up"}):n(P,{name:"chevron-down"})]}),B&&_&&n("div",{className:r.headerActions,children:[I&&o.length>1&&n("button",{className:r.nextBtn,type:"button",onClick:I,children:"Next"}),n("button",{className:r.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),l&&n("div",{className:r.list,children:o.map((e,t)=>n(le,{item:e,isActive:e.showId===D&&e.episodeNumber===v,index:t,onRemove:x,onTouchPointerDown:A,onTouchPointerMove:Q,onTouchPointerUp:S,onTouchPointerCancel:M,shouldIgnoreClick:()=>R.current,onDragStart:()=>E(t),onDragEnter:()=>$(t),onDragEnd:k,isDragging:a===t},e.id))})]})};export{he as Q,r as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as h,A as j,h as y,g as ne,u as e,S as C,$ as Q,T as _}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{b as Y}from"./vendor-query-BXRECSI6.js";import{q as Z}from"./index-CfvzoNYQ.js";import{a as t}from"./Asmr.module-ChUXDZKx.js";import{r as i}from"./Radio.module-DGSZLpKM.js";const x=300*1e3,se="https://cdn.listen.moe/covers/";function q(n){return n?n.startsWith("http")?n:`${se}${n}`:null}function re(n){return n?q(n.albums[0]?.image)||q(n.artists[0]?.image)||q(n.sources[0]?.image):null}function F(n){return n?n.artists.map(r=>r.nameRomaji||r.name).join(", "):""}const le=()=>Y({queryKey:["radioStations"],queryFn:()=>Z("/api/radio/stations"),staleTime:x}),oe=n=>Y({queryKey:["radioSearch",n],queryFn:()=>Z(`/api/radio/search?q=${encodeURIComponent(n)}`),enabled:n.trim().length>0,staleTime:x}),G={song:null,lastPlayed:[],listeners:0,startTime:null},ie=n=>{const[r,p]=h(G),[l,c]=h(!1),d=j(null);return y(()=>{if(p(G),c(!1),!n)return;let m=null,f=!1;try{m=new WebSocket(n)}catch{return}return m.onopen=()=>{f||c(!0)},m.onmessage=v=>{try{const u=JSON.parse(v.data);if(u.op===0){const b=u.d?.heartbeat||35e3;d.current&&window.clearInterval(d.current),d.current=window.setInterval(()=>{m&&m.readyState===WebSocket.OPEN&&m.send(JSON.stringify({op:9}))},b)}else u.op===1&&p({song:u.d?.song||null,lastPlayed:u.d?.lastPlayed||[],listeners:u.d?.listeners||0,startTime:u.d?.startTime||null})}catch{}},m.onclose=()=>{f||c(!1)},()=>{f=!0,d.current&&window.clearInterval(d.current),d.current=null,m&&m.close()}},[n]),{nowPlaying:r,connected:l}};function X(n){if(!n)return"";const r=Math.max(0,Math.floor((Date.now()-new Date(n).getTime())/1e3)),p=Math.floor(r/60),l=r%60;return`${p}:${String(l).padStart(2,"0")}`}const ce=({station:n,nowPlaying:r,connected:p,expanded:l,onStationStep:c,onExpandedChange:d,onClose:m})=>{const f=j(null),[v,u]=h(!1),[b,H]=h(!0),[S,I]=h(!1),[L,T]=h(!0),[O,P]=h(""),[N,A]=h(()=>{const a=parseFloat(localStorage.getItem("radioVolume")||"");return Number.isFinite(a)?a:1}),s=j(""),g=j(N);g.current=N,s.current||(s.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`radio-${Date.now()}-${Math.random().toString(36).slice(2)}`);const w=r.song,k=re(w)||n.favicon||null,[R,J]=h(!1);y(()=>{J(!1)},[k]);const E=R?null:k,U=!!E,B=w?`${F(w)} — ${w.title}`:n.name;y(()=>{const a=f.current;if(a)return u(!1),a.src=n.streamUrl,a.load(),a.volume=g.current,a.play().catch(()=>u(!1)),()=>{a.removeAttribute("src")}},[n.id,n.streamUrl]),y(()=>{const a=f.current;a&&(a.volume=N)},[N]),y(()=>{if(l)return document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")},[l]),y(()=>{l&&T(!0)},[l]);const ee=a=>a?Math.max(0,Math.floor((Date.now()-new Date(a).getTime())/1e3)):0,M=ne.useCallback(a=>{n&&(fetch("/api/discord/radio",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:B,stationLabel:n.name,isPlaying:a,thumbnail:E||"",currentTime:ee(r.startTime),sessionId:s.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s.current})}).catch(()=>{}))},[n,B,E,r.startTime]);y(()=>{M(v)},[M,v,n.id,B,l]),y(()=>{if(!v)return;const a=window.setInterval(()=>M(!0),15e3);return()=>window.clearInterval(a)},[v,M]),y(()=>{const a=s.current,$=()=>{if(!a)return;const K=JSON.stringify({sessionId:a});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([K],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:a,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:K,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a,bye:!0}),keepalive:!0}).catch(()=>{}))},D=()=>$(),W=()=>{document.visibilityState==="hidden"&&$()};return window.addEventListener("pagehide",D),window.addEventListener("beforeunload",D),document.addEventListener("visibilitychange",W),()=>{window.removeEventListener("pagehide",D),window.removeEventListener("beforeunload",D),document.removeEventListener("visibilitychange",W),$()}},[]),y(()=>{if(!r.startTime){P("");return}P(X(r.startTime));const a=window.setInterval(()=>P(X(r.startTime)),1e3);return()=>window.clearInterval(a)},[r.startTime,r.song?.id]),y(()=>{if(!l)return;const a=$=>{$.key==="Escape"&&(S?I(!1):d(!1))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l,S,d]);const ae=()=>{const a=f.current;a&&(a.paused?(a.load(),a.play().catch(()=>{})):a.pause())},te=e(C,{children:[e("div",{className:t.playerButtons,children:[e("button",{className:t.playerBtn,onClick:()=>c(-1),"aria-label":"Previous station",children:e(o,{name:"step-backward"})}),e("button",{className:`${t.playerBtn} ${t.playBtn}`,onClick:ae,"aria-label":v?"Pause":"Play",children:v?e(o,{name:"pause"}):e(o,{name:"play"})}),e("button",{className:t.playerBtn,onClick:()=>c(1),"aria-label":"Next station",children:e(o,{name:"step-forward"})})]}),e("div",{className:t.seekRow,children:[e("span",{className:i.liveBadge,children:[e(o,{name:"broadcast-tower",size:10})," LIVE"]}),O&&e("span",{className:t.timeLabel,children:O}),p&&r.listeners>0&&e("span",{className:t.timeLabel,children:[r.listeners," listening"]}),!p&&n.source==="listen.moe"&&e("span",{className:t.timeLabel,children:"connecting…"})]})]}),V=e(C,{children:[e("button",{className:`${t.playerBtn} ${t.playerToggle}`,onClick:()=>d(!l),"aria-label":l?"Minimize player":"Expand player",title:l?"Minimize to browse":"Expand",children:l?e(o,{name:"chevron-down"}):e(o,{name:"chevron-up"})}),e("div",{className:t.playerInfo,children:[e("p",{className:t.playerTitle,title:B,children:B}),e("p",{className:t.playerTrack,children:n.name})]}),e("div",{className:t.playerControls,children:te}),e("div",{className:t.playerRight,children:[N===0?e(o,{name:"volume-mute",className:t.volumeIcon}):N<.5?e(o,{name:"volume-down",className:t.volumeIcon}):e(o,{name:"volume-up",className:t.volumeIcon}),e("input",{className:t.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:a=>{const $=parseFloat(a.target.value);A($),localStorage.setItem("radioVolume",String($))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:t.playerActions,children:[l&&U&&e("button",{className:t.playerBtn,onClick:()=>H(a=>!a),"aria-label":b?"Hide art":"Show art",title:b?"Hide art":"Show art",children:b?e(o,{name:"eye-slash"}):e(o,{name:"image"})}),l&&r.lastPlayed.length>0&&e("button",{className:`${t.playerBtn} ${S?t.playerBtnActive:""}`,onClick:()=>I(a=>!a),"aria-label":S?"Hide history":"Show history",title:"Recently played",children:e(o,{name:"list-ol"})}),e("button",{className:t.playerBtn,onClick:m,"aria-label":"Close player",children:e(o,{name:"times"})})]})]}),z=e("audio",{ref:f,preload:"none",onPlay:()=>u(!0),onPause:()=>u(!1)});return l?Q(e(C,{children:[z,e("div",{className:`${t.npOverlay} ${L?"":t.npOverlayControlsHidden}`,children:[e("div",{className:`${t.npStage} ${!b||!U?t.npStageBlank:""}`,onClick:()=>T(a=>!a),children:b&&U&&E&&e("div",{className:i.coverWrap,children:e("img",{src:E,alt:B,loading:"lazy",decoding:"async",draggable:!1,className:i.cover,onError:()=>J(!0)})})}),e("div",{className:`${t.playerBar} ${t.playerBarDocked} ${L?"":t.playerBarDockedHidden}`,onClick:a=>a.stopPropagation(),children:[V,S&&e(C,{children:[e("div",{className:t.npBackdrop,onClick:()=>I(!1)}),e("div",{className:t.chapterPanel,children:r.lastPlayed.map(a=>e("div",{className:t.chapterRow,children:e("span",{className:t.chapterRowLabel,title:`${F(a)} — ${a.title}`,children:[F(a)," — ",a.title]})},a.id))})]})]})]})]}),document.body):Q(e(C,{children:[z,e("div",{className:t.playerBar,children:V})]}),document.body)},fe=()=>{y(()=>{document.title="Radio - dango"},[]);const[n,r]=h(""),[p,l]=h(""),[c,d]=h(null),[m,f]=h(!0),{data:v,isLoading:u}=le(),{data:b,isLoading:H}=oe(p),S=_(()=>v?.stations||[],[v]),I=_(()=>b?.stations||[],[b]),L=p?I:S,{nowPlaying:T,connected:O}=ie(c?.gateway),P=s=>{d(s),f(!0)},N=s=>{const g=L.length>0?L:S;if(g.length===0||!c)return;const w=g.findIndex(R=>R.id===c.id),k=g[(w<0?0:w+s+g.length)%g.length];d(k)},A=s=>{const g=c?.id===s.id,w=g&&T.song?`${F(T.song)} — ${T.song.title}`:null,k=[s.codec,s.bitrate?`${s.bitrate}k`:"",s.tags].filter(Boolean).join(" · ");return e("button",{className:`${i.stationRow} ${g?i.stationRowActive:""}`,onClick:()=>P(s),children:[s.favicon?e("img",{src:s.favicon,alt:"",className:i.stationThumb,loading:"lazy",decoding:"async",onError:R=>{R.target.style.display="none"}}):e("span",{className:i.stationThumbPlaceholder,children:e(o,{name:"broadcast-tower"})}),e("span",{className:i.stationMeta,children:[e("span",{className:i.stationName,children:s.name}),k&&e("span",{className:i.stationSub,children:k})]}),w&&e("span",{className:i.stationNowPlaying,children:w})]},s.id)};return e("div",{className:`${t.page} ${c?t.pageWithPlayer:""}`,children:[e("div",{className:t.header,children:[e("h1",{className:t.pageTitle,children:[e(o,{name:"broadcast-tower"})," Radio"]}),e("form",{className:t.searchForm,onSubmit:s=>{s.preventDefault(),l(n)},children:[e("input",{className:t.searchInput,value:n,onChange:s=>r(s.target.value),placeholder:"Search stations (anime, j-pop, k-pop…)","aria-label":"Search radio stations"}),e("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:e(o,{name:"search"})})]})]}),p?e(C,{children:[e("h2",{className:i.sectionTitle,children:["Results for “",p,"”"]}),H?e("p",{className:t.statusMsg,children:"Searching…"}):I.length===0?e("p",{className:t.statusMsg,children:"No stations found."}):e("div",{className:i.stationList,children:I.map(A)})]}):e(C,{children:[e("h2",{className:i.sectionTitle,children:"Featured"}),u?e("p",{className:t.statusMsg,children:"Loading…"}):e("div",{className:i.stationList,children:S.map(A)})]}),c&&e(ce,{station:c,nowPlaying:T,connected:O,expanded:m,onStationStep:N,onExpandedChange:f,onClose:()=>d(null)})]})};export{fe as default};
|
|
1
|
+
import{d as h,A as j,h as y,g as ne,u as e,S as C,$ as Q,T as _}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{b as Y}from"./vendor-query-BXRECSI6.js";import{q as Z}from"./index-lo-bz7f2.js";import{a as t}from"./Asmr.module-ChUXDZKx.js";import{r as i}from"./Radio.module-DGSZLpKM.js";const x=300*1e3,se="https://cdn.listen.moe/covers/";function q(n){return n?n.startsWith("http")?n:`${se}${n}`:null}function re(n){return n?q(n.albums[0]?.image)||q(n.artists[0]?.image)||q(n.sources[0]?.image):null}function F(n){return n?n.artists.map(r=>r.nameRomaji||r.name).join(", "):""}const le=()=>Y({queryKey:["radioStations"],queryFn:()=>Z("/api/radio/stations"),staleTime:x}),oe=n=>Y({queryKey:["radioSearch",n],queryFn:()=>Z(`/api/radio/search?q=${encodeURIComponent(n)}`),enabled:n.trim().length>0,staleTime:x}),G={song:null,lastPlayed:[],listeners:0,startTime:null},ie=n=>{const[r,p]=h(G),[l,c]=h(!1),d=j(null);return y(()=>{if(p(G),c(!1),!n)return;let m=null,f=!1;try{m=new WebSocket(n)}catch{return}return m.onopen=()=>{f||c(!0)},m.onmessage=v=>{try{const u=JSON.parse(v.data);if(u.op===0){const b=u.d?.heartbeat||35e3;d.current&&window.clearInterval(d.current),d.current=window.setInterval(()=>{m&&m.readyState===WebSocket.OPEN&&m.send(JSON.stringify({op:9}))},b)}else u.op===1&&p({song:u.d?.song||null,lastPlayed:u.d?.lastPlayed||[],listeners:u.d?.listeners||0,startTime:u.d?.startTime||null})}catch{}},m.onclose=()=>{f||c(!1)},()=>{f=!0,d.current&&window.clearInterval(d.current),d.current=null,m&&m.close()}},[n]),{nowPlaying:r,connected:l}};function X(n){if(!n)return"";const r=Math.max(0,Math.floor((Date.now()-new Date(n).getTime())/1e3)),p=Math.floor(r/60),l=r%60;return`${p}:${String(l).padStart(2,"0")}`}const ce=({station:n,nowPlaying:r,connected:p,expanded:l,onStationStep:c,onExpandedChange:d,onClose:m})=>{const f=j(null),[v,u]=h(!1),[b,H]=h(!0),[S,I]=h(!1),[L,T]=h(!0),[O,P]=h(""),[N,A]=h(()=>{const a=parseFloat(localStorage.getItem("radioVolume")||"");return Number.isFinite(a)?a:1}),s=j(""),g=j(N);g.current=N,s.current||(s.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`radio-${Date.now()}-${Math.random().toString(36).slice(2)}`);const w=r.song,k=re(w)||n.favicon||null,[R,J]=h(!1);y(()=>{J(!1)},[k]);const E=R?null:k,U=!!E,B=w?`${F(w)} — ${w.title}`:n.name;y(()=>{const a=f.current;if(a)return u(!1),a.src=n.streamUrl,a.load(),a.volume=g.current,a.play().catch(()=>u(!1)),()=>{a.removeAttribute("src")}},[n.id,n.streamUrl]),y(()=>{const a=f.current;a&&(a.volume=N)},[N]),y(()=>{if(l)return document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")},[l]),y(()=>{l&&T(!0)},[l]);const ee=a=>a?Math.max(0,Math.floor((Date.now()-new Date(a).getTime())/1e3)):0,M=ne.useCallback(a=>{n&&(fetch("/api/discord/radio",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:B,stationLabel:n.name,isPlaying:a,thumbnail:E||"",currentTime:ee(r.startTime),sessionId:s.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s.current})}).catch(()=>{}))},[n,B,E,r.startTime]);y(()=>{M(v)},[M,v,n.id,B,l]),y(()=>{if(!v)return;const a=window.setInterval(()=>M(!0),15e3);return()=>window.clearInterval(a)},[v,M]),y(()=>{const a=s.current,$=()=>{if(!a)return;const K=JSON.stringify({sessionId:a});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([K],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:a,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:K,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a,bye:!0}),keepalive:!0}).catch(()=>{}))},D=()=>$(),W=()=>{document.visibilityState==="hidden"&&$()};return window.addEventListener("pagehide",D),window.addEventListener("beforeunload",D),document.addEventListener("visibilitychange",W),()=>{window.removeEventListener("pagehide",D),window.removeEventListener("beforeunload",D),document.removeEventListener("visibilitychange",W),$()}},[]),y(()=>{if(!r.startTime){P("");return}P(X(r.startTime));const a=window.setInterval(()=>P(X(r.startTime)),1e3);return()=>window.clearInterval(a)},[r.startTime,r.song?.id]),y(()=>{if(!l)return;const a=$=>{$.key==="Escape"&&(S?I(!1):d(!1))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l,S,d]);const ae=()=>{const a=f.current;a&&(a.paused?(a.load(),a.play().catch(()=>{})):a.pause())},te=e(C,{children:[e("div",{className:t.playerButtons,children:[e("button",{className:t.playerBtn,onClick:()=>c(-1),"aria-label":"Previous station",children:e(o,{name:"step-backward"})}),e("button",{className:`${t.playerBtn} ${t.playBtn}`,onClick:ae,"aria-label":v?"Pause":"Play",children:v?e(o,{name:"pause"}):e(o,{name:"play"})}),e("button",{className:t.playerBtn,onClick:()=>c(1),"aria-label":"Next station",children:e(o,{name:"step-forward"})})]}),e("div",{className:t.seekRow,children:[e("span",{className:i.liveBadge,children:[e(o,{name:"broadcast-tower",size:10})," LIVE"]}),O&&e("span",{className:t.timeLabel,children:O}),p&&r.listeners>0&&e("span",{className:t.timeLabel,children:[r.listeners," listening"]}),!p&&n.source==="listen.moe"&&e("span",{className:t.timeLabel,children:"connecting…"})]})]}),V=e(C,{children:[e("button",{className:`${t.playerBtn} ${t.playerToggle}`,onClick:()=>d(!l),"aria-label":l?"Minimize player":"Expand player",title:l?"Minimize to browse":"Expand",children:l?e(o,{name:"chevron-down"}):e(o,{name:"chevron-up"})}),e("div",{className:t.playerInfo,children:[e("p",{className:t.playerTitle,title:B,children:B}),e("p",{className:t.playerTrack,children:n.name})]}),e("div",{className:t.playerControls,children:te}),e("div",{className:t.playerRight,children:[N===0?e(o,{name:"volume-mute",className:t.volumeIcon}):N<.5?e(o,{name:"volume-down",className:t.volumeIcon}):e(o,{name:"volume-up",className:t.volumeIcon}),e("input",{className:t.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:a=>{const $=parseFloat(a.target.value);A($),localStorage.setItem("radioVolume",String($))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:t.playerActions,children:[l&&U&&e("button",{className:t.playerBtn,onClick:()=>H(a=>!a),"aria-label":b?"Hide art":"Show art",title:b?"Hide art":"Show art",children:b?e(o,{name:"eye-slash"}):e(o,{name:"image"})}),l&&r.lastPlayed.length>0&&e("button",{className:`${t.playerBtn} ${S?t.playerBtnActive:""}`,onClick:()=>I(a=>!a),"aria-label":S?"Hide history":"Show history",title:"Recently played",children:e(o,{name:"list-ol"})}),e("button",{className:t.playerBtn,onClick:m,"aria-label":"Close player",children:e(o,{name:"times"})})]})]}),z=e("audio",{ref:f,preload:"none",onPlay:()=>u(!0),onPause:()=>u(!1)});return l?Q(e(C,{children:[z,e("div",{className:`${t.npOverlay} ${L?"":t.npOverlayControlsHidden}`,children:[e("div",{className:`${t.npStage} ${!b||!U?t.npStageBlank:""}`,onClick:()=>T(a=>!a),children:b&&U&&E&&e("div",{className:i.coverWrap,children:e("img",{src:E,alt:B,loading:"lazy",decoding:"async",draggable:!1,className:i.cover,onError:()=>J(!0)})})}),e("div",{className:`${t.playerBar} ${t.playerBarDocked} ${L?"":t.playerBarDockedHidden}`,onClick:a=>a.stopPropagation(),children:[V,S&&e(C,{children:[e("div",{className:t.npBackdrop,onClick:()=>I(!1)}),e("div",{className:t.chapterPanel,children:r.lastPlayed.map(a=>e("div",{className:t.chapterRow,children:e("span",{className:t.chapterRowLabel,title:`${F(a)} — ${a.title}`,children:[F(a)," — ",a.title]})},a.id))})]})]})]})]}),document.body):Q(e(C,{children:[z,e("div",{className:t.playerBar,children:V})]}),document.body)},fe=()=>{y(()=>{document.title="Radio - dango"},[]);const[n,r]=h(""),[p,l]=h(""),[c,d]=h(null),[m,f]=h(!0),{data:v,isLoading:u}=le(),{data:b,isLoading:H}=oe(p),S=_(()=>v?.stations||[],[v]),I=_(()=>b?.stations||[],[b]),L=p?I:S,{nowPlaying:T,connected:O}=ie(c?.gateway),P=s=>{d(s),f(!0)},N=s=>{const g=L.length>0?L:S;if(g.length===0||!c)return;const w=g.findIndex(R=>R.id===c.id),k=g[(w<0?0:w+s+g.length)%g.length];d(k)},A=s=>{const g=c?.id===s.id,w=g&&T.song?`${F(T.song)} — ${T.song.title}`:null,k=[s.codec,s.bitrate?`${s.bitrate}k`:"",s.tags].filter(Boolean).join(" · ");return e("button",{className:`${i.stationRow} ${g?i.stationRowActive:""}`,onClick:()=>P(s),children:[s.favicon?e("img",{src:s.favicon,alt:"",className:i.stationThumb,loading:"lazy",decoding:"async",onError:R=>{R.target.style.display="none"}}):e("span",{className:i.stationThumbPlaceholder,children:e(o,{name:"broadcast-tower"})}),e("span",{className:i.stationMeta,children:[e("span",{className:i.stationName,children:s.name}),k&&e("span",{className:i.stationSub,children:k})]}),w&&e("span",{className:i.stationNowPlaying,children:w})]},s.id)};return e("div",{className:`${t.page} ${c?t.pageWithPlayer:""}`,children:[e("div",{className:t.header,children:[e("h1",{className:t.pageTitle,children:[e(o,{name:"broadcast-tower"})," Radio"]}),e("form",{className:t.searchForm,onSubmit:s=>{s.preventDefault(),l(n)},children:[e("input",{className:t.searchInput,value:n,onChange:s=>r(s.target.value),placeholder:"Search stations (anime, j-pop, k-pop…)","aria-label":"Search radio stations"}),e("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:e(o,{name:"search"})})]})]}),p?e(C,{children:[e("h2",{className:i.sectionTitle,children:["Results for “",p,"”"]}),H?e("p",{className:t.statusMsg,children:"Searching…"}):I.length===0?e("p",{className:t.statusMsg,children:"No stations found."}):e("div",{className:i.stationList,children:I.map(A)})]}):e(C,{children:[e("h2",{className:i.sectionTitle,children:"Featured"}),u?e("p",{className:t.statusMsg,children:"Loading…"}):e("div",{className:i.stationList,children:S.map(A)})]}),c&&e(ce,{station:c,nowPlaying:T,connected:O,expanded:m,onStationStep:N,onExpandedChange:f,onClose:()=>d(null)})]})};export{fe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as U,d as v,h as b,T as w,u as i,S as E}from"./vendor-core-8R2fFbyN.js";import{M as x}from"./MediaCard-
|
|
1
|
+
import{n as U,d as v,h as b,T as w,u as i,S as E}from"./vendor-core-8R2fFbyN.js";import{M as x}from"./MediaCard-DszKDA4s.js";import{L as F}from"./LibraryListPage-B0MDTnEc.js";import{u as _,M as D}from"./useMangaPopup-BvgtZ53s.js";import{M as G}from"./MangaResetProgressModal-WjKH_G_f.js";import{s as O,d as Q,l as Y,n as q,u as z,t as H,v as K,w as V,M as h,m as Z,i as j,b as J,c as W}from"./useMangaLibrary-BXhgN-dl.js";import"./vendor-ui-CUDCvRS_.js";import"./vendor-icons-CDMuNDeL.js";import"./index-lo-bz7f2.js";import"./vendor-query-BXRECSI6.js";import"./useIsMobile-Dm_b6Ob3.js";import"./SkeletonGrid-Du10CNfq.js";import"./ErrorMessage-z4f4WGgP.js";import"./Watchlist.module-XGtVQr1d.js";import"./ResetProgressModal-8mcLXaAb.js";const X=["All","Continue Reading",...h],R=24,y=e=>({provider:e.provider,mangaId:e.mangaId,title:e.title,altTitle:e.altTitle,cover:e.cover,contentRating:e.contentRating,readTarget:e.detailTarget,progressLabel:e.progressLabel});function va(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=O(r?"All":e,g,R),s=Q(100),I=Y(),T=q(),{toggle:L,bookmarkedIds:C}=z(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:M}=_(),f=H(),P=K(),B=V(),S=w(()=>r?(s.data?.data??[]).map(a=>{const o=a.page??0,l=a.pageCount??0;return{key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title,altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.chapterNumber?`Ch. ${a.chapterNumber}`:void 0,progressPercent:l>0?o/l*100:0,progressLabel:a.chapterNumber&&l>0?`Ch. ${a.chapterNumber} · p. ${o}/${l}`:void 0,detailTarget:a.chapterId&&a.provider&&a.mangaId?`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}/read?chapter=${encodeURIComponent(a.chapterId)}`:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`}}):(n.data?.data??[]).map(a=>({key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title,altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.lastChapterNumber?`Ch. ${a.lastChapterNumber}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`})),[r,s.data,n.data]),$=r?s.data?.total??0:n.data?.total??0,A=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...h],entries:S,total:$,isLoading:A,error:N,page:g,pageSize:R,onPageChange:p,emptyTitle:"Your reading list is looking a bit lonely",emptyFilteredText:"No titles match this filter.",emptyAllText:"Let's find something to read!",browseLabel:"Browse Manga",browseTarget:"/manga",removeListLabel:"Remove from Reading List",listNoun:"reading list",skipConfirmKey:"mangaSkipRemoveConfirmation",onBulkStatus:(a,o)=>f.mutate({ids:a,status:o}),onBulkRemove:a=>{r?B.mutate(a):P.mutate(a)},onStatusChange:(a,o)=>T.mutate({id:a,status:o}),onRemoveItem:a=>I.mutate(a),renderCard:a=>i(x,{item:{id:a.libId,title:a.title,...W({title:a.title,altTitle:a.altTitle}),thumbnail:J(a.provider,a.cover),chapterBadge:a.chapterLabel??null,isAdult:j(a)},linkTo:a.detailTarget,hoverIcon:"book",progress:a.progressPercent!==void 0&&a.progressLabel?{percent:a.progressPercent,label:a.progressLabel}:void 0,showProgress:r,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:r?()=>u(a):void 0,onOpenDetails:o=>k(o,y(a)),onPopupHoverIntent:o=>o?m():c(),rawThumbnail:!0}),modals:i(E,{children:[t&&t.data.provider&&i(D,{data:t.data,anchorRect:t.rect,bookmarked:C.has(Z(t.data.provider,t.data.mangaId)),onToggleBookmark:()=>L({id:t.data.mangaId,provider:t.data.provider,title:t.data.title,cover:t.data.cover,altTitle:t.data.altTitle??void 0,contentRating:t.data.contentRating}),onMouseEnter:m,onMouseLeave:c,onRequestClose:M}),i(G,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{va as default};
|
package/client/dist/assets/{ResetProgressModal-By-iSYwL.js → ResetProgressModal-8mcLXaAb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e}from"./vendor-core-8R2fFbyN.js";import{M as r,B as n}from"./index-
|
|
1
|
+
import{u as e}from"./vendor-core-8R2fFbyN.js";import{M as r,B as n}from"./index-lo-bz7f2.js";const p=({isOpen:t,itemName:c,progressKind:i,listLabel:s,alsoRemove:a,onAlsoRemoveChange:d,onClose:o,onConfirm:l})=>e(r,{isOpen:t,onClose:o,title:"Reset Progress",children:[e(r.Body,{children:[e("p",{children:["Are you sure you want to remove your ",i,' progress for "',c,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:a,onChange:h=>d(h.target.checked)}),"Also remove from ",s]})]}),e(r.Actions,{children:[e(n,{variant:"secondary",onClick:o,children:"No"}),e(n,{variant:"danger",onClick:l,children:"Yes"})]})]});export{p as R};
|