@serifpersia/dango 3.4.6 → 3.4.8
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-BVdH0EeW.js → AnimeCard-B7cefekM.js} +1 -1
- package/client/dist/assets/{AnimeInfo-Dw2Nop6Q.js → AnimeInfo-DMleDwpO.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-Cw-Tq3YX.js → AnimeInfoPage-Du5wVhlb.js} +2 -2
- package/client/dist/assets/Asmr-BEubWJv6.js +2 -0
- package/client/dist/assets/Asmr-D1KuQwQy.css +1 -0
- package/client/dist/assets/Asmr.module-CdWlioTY.js +1 -0
- package/client/dist/assets/{AsmrResetProgressModal-CYjpcYpb.js → AsmrResetProgressModal-JdeXEtzw.js} +1 -1
- package/client/dist/assets/AvSyncCalibrator-C8O-jXE2.js +10 -0
- package/client/dist/assets/{AvSyncCalibrator-D0FYSwiz.css → AvSyncCalibrator-gEONBv5a.css} +1 -1
- package/client/dist/assets/Home-BA1aR58g.js +1 -0
- package/client/dist/assets/{Insights-DDWry-t1.js → Insights-BcNziBXm.js} +1 -1
- package/client/dist/assets/{LibraryListPage-CV8Z9JlO.js → LibraryListPage-LNGakFTd.js} +1 -1
- package/client/dist/assets/ListeningList-BfncQnid.js +1 -0
- package/client/dist/assets/Manga-BFbh8cAL.js +1 -0
- package/client/dist/assets/Manga-CqAceKxR.css +1 -0
- package/client/dist/assets/Manga.module-depGEacJ.js +1 -0
- package/client/dist/assets/MangaInfoPage-RRo8y5sK.js +1 -0
- package/client/dist/assets/MangaReadPage-D-aR9Ck5.js +1 -0
- package/client/dist/assets/{MangaResetProgressModal-DyhQYBDy.js → MangaResetProgressModal-DdrlfAZg.js} +1 -1
- package/client/dist/assets/Mature-RY2k6mWW.js +1 -0
- package/client/dist/assets/{MediaCard-BcLjlpfR.js → MediaCard-oKcm5MSZ.js} +1 -1
- package/client/dist/assets/Music-DdWEZu8G.js +1 -0
- package/client/dist/assets/OptionListMenu-CS_pi1k6.js +1 -0
- package/client/dist/assets/Player-l_fBmJFq.js +56 -0
- package/client/dist/assets/PlayerSettings-BCDbbq_C.js +1 -0
- package/client/dist/assets/{QueueOptionsButton-ClVTpH8J.js → QueueOptionsButton-D9GEQjtt.js} +1 -1
- package/client/dist/assets/{QueueRail-DeJKVRs5.js → QueueRail-BUgbi6pG.js} +1 -1
- package/client/dist/assets/Radio-sAmz2Qkm.js +1 -0
- package/client/dist/assets/ReadingList-B5XpEzwr.js +1 -0
- package/client/dist/assets/{ResetProgressModal-C6ukct_c.js → ResetProgressModal-s5lo44l6.js} +1 -1
- package/client/dist/assets/{Search-DjjKA_Wu.js → Search-DGCMxhOc.js} +1 -1
- package/client/dist/assets/{Settings-DQt_S5Qw.js → Settings-BK5OI9UW.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-nx2HEi4P.js → SkeletonGrid-wvCaX1Is.js} +1 -1
- package/client/dist/assets/{Trackers-BcGzeqj2.js → Trackers-pjidQVul.js} +1 -1
- package/client/dist/assets/Tv-Oug_dloh.js +4 -0
- package/client/dist/assets/{TvInfo-CUd1agFy.js → TvInfo-D87T3k4V.js} +1 -1
- package/client/dist/assets/{TvPopup-CJeu3tgc.js → TvPopup-CxgFIcTH.js} +1 -1
- package/client/dist/assets/{TvSearch-BIypjbU3.js → TvSearch-k85EJOCp.js} +1 -1
- package/client/dist/assets/{TvWatchlist-DZrBdiqZ.js → TvWatchlist-ChIG_58m.js} +1 -1
- package/client/dist/assets/{Watchlist-Dw8cPe0n.js → Watchlist-7GSr-qnx.js} +1 -1
- package/client/dist/assets/{hls-B3_1VuDP.js → hls-BSoZifHa.js} +1 -1
- package/client/dist/assets/index-Yj2llWtE.js +178 -0
- package/client/dist/assets/page-DRvjODkg.css +1 -0
- package/client/dist/assets/page.module-C1MlZzf3.js +1 -0
- package/client/dist/assets/{useAnimeInfoData-_iOLEAa8.js → useAnimeInfoData-Dqyfnfj2.js} +1 -1
- package/client/dist/assets/{useAsmr-Blk4v41t.js → useAsmr-o_9VI-IG.js} +1 -1
- package/client/dist/assets/useAsmrPopup-CzC9zH_3.js +1 -0
- package/client/dist/assets/{useMangaLibrary-B60at6ni.js → useMangaLibrary-CaPmKLVt.js} +1 -1
- package/client/dist/assets/useMangaPopup-cYPGrsdj.js +1 -0
- package/client/dist/assets/usePopup-DS9jMzp6.js +1 -0
- package/client/dist/assets/useProviders-CqHa2hsg.js +1 -0
- package/client/dist/assets/{useTv-WJCDL5_5.js → useTv-C8wM7Ky_.js} +1 -1
- package/client/dist/assets/{useTvLibrary-Fgn5i9rJ.js → useTvLibrary-DpwQCFjx.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/Asmr-BrjzzyOi.js +0 -2
- package/client/dist/assets/Asmr-Cq2ua6Zk.css +0 -1
- package/client/dist/assets/Asmr.module-ChUXDZKx.js +0 -1
- package/client/dist/assets/AvSyncCalibrator-BuHurVgo.js +0 -10
- package/client/dist/assets/Home-KdnP7sNM.js +0 -1
- package/client/dist/assets/ListeningList-DSMbMZT7.js +0 -1
- package/client/dist/assets/Manga-Dp_-l1Pw.css +0 -1
- package/client/dist/assets/Manga-J6XoqEKq.js +0 -1
- package/client/dist/assets/Manga.module-BcfOdsNP.js +0 -1
- package/client/dist/assets/MangaInfoPage-N7TxsN5u.js +0 -1
- package/client/dist/assets/MangaReadPage-D_VzSNWq.js +0 -1
- package/client/dist/assets/Mature-Db53R-LR.js +0 -1
- package/client/dist/assets/Music-DjxQjJOl.js +0 -1
- package/client/dist/assets/OptionListMenu-DngTgHxH.js +0 -1
- package/client/dist/assets/Player-Be_7Ne5p.js +0 -56
- package/client/dist/assets/PlayerSettings-D47ItGDR.js +0 -1
- package/client/dist/assets/Radio-DU0ma3GA.js +0 -1
- package/client/dist/assets/ReadingList-qXW7Dk5z.js +0 -1
- package/client/dist/assets/Tv-COvyHdeJ.js +0 -4
- package/client/dist/assets/index-gMxawd-E.js +0 -178
- package/client/dist/assets/useAsmrPopup-D9SQIgZa.js +0 -1
- package/client/dist/assets/useMangaPopup-DEfGjWSu.js +0 -1
- package/client/dist/assets/useProviders-Ca0bZWt7.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as F,A as I,q as Z,h as u,u as e,S as J,o as ce,p as le,a as de,T as ue}from"./vendor-core-DfaOB3Rn.js";import{E as ge}from"./ErrorMessage-DAxegITP.js";import{I as x}from"./vendor-icons-DrybRNxP.js";import{u as he}from"./vendor-query-BBT5_sHx.js";import{t as me,v as pe,m as fe,k as ve,r as be,n as Ne,w as we,q as ye,s as Ce}from"./useMangaLibrary-B60at6ni.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import{e as Ie,d as Se,t as G}from"./index-gMxawd-E.js";const ee="mangaReadMode",te="mangaFitMode";function $e(){try{return localStorage.getItem(ee)==="page"?"page":"strip"}catch{return"strip"}}function ke(){try{return localStorage.getItem(te)==="height"?"height":"width"}catch{return"width"}}const Pe=({provider:d,mangaTitle:h,chapter:p,chapters:b,onBack:N,onOpenChapter:v,initialPage:l=0,onProgress:D,savedPage:$=0})=>{const[c,U]=F($e),[i,_]=F(ke),[g,M]=F(0),[T,m]=F(new Set),[w,S]=F(0),E=I(null),B=I([]),z=he(),{data:V,isLoading:k,isError:L}=me(d,p.id),a=V?.pages??[],K=a.map(n=>pe(d,n)),y=I(0),Q=I(0),P=I(!1);Q.current=a.length;const s=b.findIndex(n=>n.id===p.id),o=s>0?[...b.slice(0,s)].reverse().find(n=>!n.externalUrl)??null:null,C=s>=0?b.slice(s+1).find(n=>!n.externalUrl)??null:null,R=Z(n=>{P.current=!0,M(r=>{const f=r+n;return f<0?(o&&v(o),0):f>=a.length?(C&&v(C),r):f})},[a.length,o,C,v]);u(()=>{P.current=!1,y.current=Math.max(0,l),M(Math.max(0,l)),m(new Set),B.current=[],l<=0&&window.scrollTo(0,0)},[p.id,l]);const H=I(D);H.current=D;const X=I("");u(()=>{y.current=g,a.length!==0&&H.current?.(Math.min(g+1,a.length),a.length)},[g,a.length]),u(()=>{l<=0||P.current||y.current===0&&(P.current=!1,y.current=l,M(l))},[l]),u(()=>{if(c!=="strip"||a.length===0||l<=0)return;const n=`${p.id}:${l}`;if(X.current===n)return;X.current=n;const r=window.setTimeout(()=>{B.current[Math.min(l,a.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[c,a.length,l,p.id]),u(()=>{document.title=`${h} Ch. ${p.number} - dango`},[h,p.number]),u(()=>{try{localStorage.setItem(ee,c)}catch{}},[c]),u(()=>{try{localStorage.setItem(te,i)}catch{}},[i]),u(()=>{c==="page"&&window.scrollTo(0,0)},[c]),u(()=>{if(c!=="page"||a.length===0)return;const n=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),R(1)):r.key==="ArrowLeft"&&(r.preventDefault(),R(-1))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c,a.length,R]),u(()=>{if(c!=="strip"||a.length===0)return;const n=new IntersectionObserver(r=>{for(const f of r)if(f.isIntersecting){const W=Number(f.target.dataset.pageIndex);Number.isNaN(W)||(W!==y.current&&(P.current=!0),M(W))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return B.current.forEach(r=>r&&n.observe(r)),()=>n.disconnect()},[c,a.length,V]);const ne=n=>{E.current=n.touches[0].clientX},ae=n=>{if(E.current===null)return;const r=n.changedTouches[0].clientX-E.current;E.current=null,!(Math.abs(r)<50)&&R(r<0?1:-1)},q=n=>{n&&v(n)},O=n=>m(r=>{if(r.has(n))return r;const f=new Set(r);return f.add(n),f}),re=n=>{m(r=>{const f=new Set(r);return f.delete(n),f}),S(r=>r+1)},se=()=>{m(new Set),S(n=>n+1),z.invalidateQueries({queryKey:["mangaPages",d,p.id]})},ie=a.length>0&&T.size>=a.length,Y=n=>w>0?`${n}&n=${w}`:n,j=n=>e("div",{className:t.deadPage,role:"alert",children:[e("span",{children:["Page ",n+1," failed to load"]}),e("button",{className:t.pageBtn,onClick:()=>re(n),children:[e(x,{name:"sync-alt",size:12})," Retry"]})]}),A=i==="height",oe=$>0?$-1:-1;return e("div",{className:t.readerShell,children:[e("div",{className:t.readerBar,children:[e("button",{className:t.readerIconBtn,onClick:N,"aria-label":"Back to chapters",children:e(x,{name:"chevron-left",size:14})}),e("span",{className:t.readerTitle,children:[h," — Ch. ",p.number,p.title?` ${p.title}`:""]}),a.length>0&&e("span",{className:t.readerCounter,children:[Math.min(g+1,a.length)," / ",a.length]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":c==="strip",className:c==="strip"?t.readerSegmentActive:"",onClick:()=>U("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":c==="page",className:c==="page"?t.readerSegmentActive:"",onClick:()=>U("page"),children:"Page"})]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!A,className:A?"":t.readerSegmentActive,onClick:()=>_("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":A,className:A?t.readerSegmentActive:"",onClick:()=>_("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:t.readerIconBtn,disabled:!o,onClick:()=>q(o),"aria-label":"Previous chapter",children:e(x,{name:"chevron-left",size:14})}),e("button",{className:t.readerIconBtn,disabled:!C,onClick:()=>q(C),"aria-label":"Next chapter",children:e(x,{name:"chevron-right",size:14})})]}),L?e("p",{className:t.statusMsg,children:"Failed to load pages. Please try again."}):k?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((n,r)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):a.length===0?e("p",{className:t.statusMsg,children:"No pages found for this chapter."}):ie?e("div",{className:t.failedBox,children:[e("p",{className:t.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:t.pageBtn,onClick:se,children:[e(x,{name:"sync-alt",size:12})," Reload pages"]})]}):c==="strip"?e("div",{className:`${t.readerPages} ${A?t.readerPagesTall:""}`,children:K.map((n,r)=>e("div",{ref:f=>{B.current[r]=f},"data-page-index":r,className:t.readerPageWrap,children:[r===oe&&e("div",{className:t.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(x,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",$]})]}),T.has(r)?j(r):e("img",{className:t.readerPage,src:Y(n),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>O(r)})]},`${r}-${a[r].slice(-32)}`))}):e(J,{children:[e("div",{className:`${t.pageView} ${A?t.pageViewTall:""}`,onTouchStart:ne,onTouchEnd:ae,children:[e("button",{className:`${t.tapZone} ${t.tapZoneLeft}`,onClick:()=>R(-1),"aria-label":"Previous page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-left",size:16})})}),T.has(g)?j(g):e("img",{className:t.pageImage,src:Y(K[g]),alt:`Page ${g+1} of ${a.length}`,decoding:"async",draggable:!1,onError:()=>O(g)},`${g}-${a[g].slice(-32)}`),e("button",{className:`${t.tapZone} ${t.tapZoneRight}`,onClick:()=>R(1),"aria-label":"Next page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-right",size:16})})})]}),e("nav",{className:t.pagination,"aria-label":"Page navigation",children:[e("button",{className:t.pageBtn,disabled:g<=0,onClick:()=>R(-1),children:"Previous page"}),e("span",{className:t.pageIndicator,children:[g+1," / ",a.length]}),e("button",{className:t.pageBtn,disabled:g>=a.length-1,onClick:()=>R(1),children:"Next page"})]})]}),(o||C)&&e("nav",{className:t.pagination,children:[e("button",{className:t.pageBtn,disabled:!o,onClick:()=>q(o),children:"Previous chapter"}),e("button",{className:t.pageBtn,disabled:!C,onClick:()=>q(C),children:"Next chapter"})]})]})},Re=800,xe=5e3;function ze(){const{provider:d="",id:h=""}=ce(),[p]=le(),b=de(),N=p.get("chapter")||"",v=p.get("rating")||"safe",{hasConsent:l}=Ie(),D=l?v:"safe",$=d&&h?fe(d,h):"",c=d.toLowerCase()==="anilist";u(()=>{c&&h&&b(`/manga/anilist/${encodeURIComponent(h)}`,{replace:!0})},[c,h,b]);const U=ve(!c&&d?d:null,!c&&h?h:null,D,l),i=U.data,{titlePreference:_}=Se(),g=i?be(i,_):"Manga",M=Ne($||void 0),T=we(),m=i&&N?i.chapters.find(s=>s.id===N)??null:null,w=ye(N),S=w!=null&&i?Ce(i.chapters,w):null;u(()=>{if(w!=null&&S&&S.id!==N){const s=new URLSearchParams;s.set("chapter",S.id),l&&v!=="safe"&&s.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${s.toString()}`,{replace:!0})}},[w,S,N,l,v,d,h,b]);const E=w!=null&&!!i&&!!S,B=w!=null&&!!i&&!S,z=ue(()=>{const s=(M.data?.progress??[]).find(o=>o.chapterId===N);return s&&s.page>0?s.page:0},[M.data,N]),V=z>1?z-1:0,k=I(null),L=I(null),a=Z(()=>{k.current&&(clearTimeout(k.current),k.current=null);const s=L.current;L.current=null,s&&$&&T.mutate({mangaId:$,chapterId:s.chapterId,chapterNumber:s.chapterNumber,page:s.page,pageCount:s.pageCount,title:i?.title??null,cover:i?.cover??null,provider:d||null,altTitle:i?.altTitle??null,contentRating:i?.contentRating??null})},[$,T,i?.title,i?.cover,i?.altTitle,i?.contentRating,d]),K=Z((s,o)=>{m&&(L.current={chapterId:m.id,chapterNumber:m.number,page:s,pageCount:o},k.current&&clearTimeout(k.current),k.current=setTimeout(a,Re))},[m,a]);u(()=>{a()},[N,a]),u(()=>()=>a(),[a]),u(()=>{const s=window.setInterval(()=>{L.current&&a()},xe);return()=>window.clearInterval(s)},[a]),u(()=>{const s=()=>{document.visibilityState==="hidden"&&a()},o=()=>a();return document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",o)}},[a]);const y=I("");y.current||(y.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),u(()=>{if(!i||!m)return;const s=i.contentRating==="erotica"||i.contentRating==="pornographic"||i.type==="doujinshi",o=()=>{G.discord.mangaPresence.mutate({title:i.title,chapterLabel:`Chapter ${m.number}`,isPlaying:!0,thumbnail:i.cover||"",thumbnails:[i.cover].filter(Boolean),isAdult:s,sessionId:y.current}).catch(()=>{}),G.discord.heartbeat.mutate({sessionId:y.current}).catch(()=>{})};o();const C=window.setInterval(o,6e4);return()=>window.clearInterval(C)},[i,m]);const Q=s=>{if(a(),s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),l&&v!=="safe"&&o.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${o.toString()}`)},P=()=>{a();const s=new URLSearchParams;l&&v!=="safe"&&s.set("rating",v);const o=s.toString()?`?${s.toString()}`:"";b(`/manga/${d}/${encodeURIComponent(h)}${o}`)};return c?null:e("div",{className:t.page,children:U.isLoading||E?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((s,o)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!i||!m?e(J,{children:[e("button",{className:t.backBtn,onClick:P,children:"Back to title"}),e(ge,{message:B?`Chapter ${w} isn't available from ${d} for this title.`:"Failed to load this chapter. Please try again."})]}):e(Pe,{provider:d,mangaTitle:g,chapter:m,chapters:i.chapters,onBack:P,onOpenChapter:Q,initialPage:V,onProgress:K,savedPage:z},m.id)})}export{ze as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as t,a as we,p as ke,h as de,d as l,T as ue,S as me}from"./vendor-core-DfaOB3Rn.js";import{b as he}from"./vendor-query-BBT5_sHx.js";import{B as O,M as $e,h as qe,e as Fe,U as xe,t as x,z as Ue}from"./index-gMxawd-E.js";import{I as ge}from"./vendor-icons-DrybRNxP.js";import{S as Ye,P as pe}from"./SkeletonGrid-nx2HEi4P.js";import{A as Ve}from"./AnimeCard-BVdH0EeW.js";import{E as We}from"./ErrorMessage-DAxegITP.js";import{u as je}from"./useProviders-Ca0bZWt7.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-_iOLEAa8.js";import"./QueueOptionsButton-ClVTpH8J.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-BcLjlpfR.js";import"./useIsMobile-Dvx1uJ82.js";const He=({isOpen:u,onClose:c,onGrant:s})=>t($e,{isOpen:u,title:"Content Warning",onClose:c,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(O,{variant:"secondary",onClick:c,children:"Go Back"}),t(O,{onClick:s,children:"I'm 18+, Continue"})]})]})}),Ke="_shrinkSelect_130sm_1",Qe="_tightGrid_130sm_7",Q={shrinkSelect:Ke,tightGrid:Qe},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],Ze=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"FAVOURITES_DESC",label:"Favourites"}],Je=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Xe=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],et={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},tt=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=u=>u.split("-").map(c=>c&&c[0].toUpperCase()+c.slice(1)).join(" "),at=new Set(["page","limit","year","minScore","minEpisodes"]),rt=new Set(["provider","query","page","limit","type","status","season","year","country","genres","genre","excludeGenres","sortBy","order","studio","blacklist","minScore","minEpisodes"]);function st(u){const c=new URLSearchParams(u),s={};for(const[y,b]of c.entries())rt.has(y)&&(at.has(y)?s[y]=Number(b)||0:s[y]=b);return s}function bt(){const u=we(),c=qe(),[s,y]=ke(),{hasConsent:b,grant:fe}=Fe();de(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(s.get("provider")||"anilist"),[C,z]=l(s.get("query")||""),[T,U]=l(s.get("query")||""),[I,g]=l(parseInt(s.get("page")||"1",10)||1),[_,Y]=l(()=>{const e=s.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[M,Z]=l(s.get("sortBy")||""),[N,ye]=l(s.get("status")||""),[D,be]=l(s.get("season")||"ALL"),[G,Ce]=l(s.get("year")||"ALL"),[p,B]=l(s.get("genre")||s.get("genres")||""),[V,Ne]=l(s.get("order")||"recent"),[W,Ae]=l(s.get("studio")||""),[w,Ee]=l(s.get("studio")||""),[J,X]=l([]),[j,Pe]=l(!1),[Re,ee]=l(null),{options:te}=je(),ae=ue(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=ue(()=>[...ze,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:k}=he({...c.data.matureFilters.queryOptions(),enabled:b,staleTime:1/0}),d=i==="anilist"||i==="mal",H=d?void 0:k?.providers?.[i],P=H?.browse,R=H?.genres??[],A=H?.orders??[],se=A.length>0&&!A.includes(V)?A[0]:V,$=!d&&(P?.genre===!0||R.length>0||J.length>0),v=!d&&(P?.order===!0||A.length>0),E=!d&&P?.studio===!0,ie=!d&&P?.sort===!0,q=d?14:P?.pageSize??14,f=e=>{const r=new URLSearchParams;if(e.provider!=="anilist"&&r.set("provider",e.provider),e.query.trim()&&r.set("query",e.query.trim()),e.page>1&&r.set("page",String(e.page)),e.provider==="anilist")e.sort!=="POPULARITY_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status),e.season!=="ALL"&&r.set("season",e.season),e.year!=="ALL"&&r.set("year",e.year);else if(e.provider==="mal")e.sort!=="SCORE_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status);else{const n=k?.providers?.[e.provider]?.browse,m=k?.providers?.[e.provider]?.orders??[],o=m.length>0&&!m.includes(e.remoteOrder)?m[0]:e.remoteOrder;(!n||n.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!n||n.genre)&&e.genre&&r.set("genre",e.genre),(!n||n.order)&&o!==(m[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}y(r,{replace:!0})},S=(e={})=>({provider:i,query:T,page:I,sort:_,remoteSort:M,status:N,season:D,year:G,genre:p,remoteOrder:V,studio:w,...e}),Le=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(I)),e.set("limit",String(q)),i==="anilist"&&(e.set("sortBy",_),N&&e.set("status",N),D!=="ALL"&&e.set("season",D),G!=="ALL"&&e.set("year",G)),i==="mal"?(e.set("sortBy",_),N&&e.set("status",N)):d||($&&p&&e.set("genre",p),v&&e.set("order",se),ie&&M&&e.set("sortBy",M),E&&w.trim()&&e.set("studio",w.trim())),e.toString()})(),{data:h,isLoading:Oe,isError:Te,error:Ie}=he({...c.data.matureSearch.queryOptions(st(Le)),enabled:b});de(()=>{const e=h?.genres;!d&&R.length===0&&e&&e.length>0&&X(r=>{const n=new Set(r.map(o=>o.slug)),m=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),m.push(o));return m.length===r.length?r:m})},[h,i,d,R.length]);const F=(h?.data||[]).map(e=>({...e,isAdult:!0})),le=h?.hasMore??!1,L=()=>{xe(),g(1);let e=p;!d&&!v&&C.trim()&&(e=""),B(e),E&&Ee(W),U(C),f(S({query:C,page:1,genre:e,studio:E?W:w}))},_e=e=>{Se(e),g(1),Z(""),B(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(C),f(S({provider:e,page:1,remoteSort:"",genre:"",query:C}))},Me=e=>{B(e),g(1),e&&(z(""),U("")),f(S({genre:e,page:1,query:e?"":T}))},ne=e=>{g(e),f(S({page:e})),window.scrollTo({top:0,behavior:"smooth"})},De=async(e,r)=>{const n=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Re)){ee(n);try{if(i!=="anilist"){let o=!1;try{o=(await x.data.anilistStatus.query())?.available===!0}catch{o=!1}if(o){const ce=await x.data.matureResolve.query({title:r.name});u(`/anime/${ce.id}`);return}const oe=await x.data.matureAllocate.mutate({provider:i,nativeId:n,title:r.name,thumbnail:r.thumbnail});if(!oe?.id)throw new Error("Allocate failed");u(`/anime/${oe.id}`);return}const m=await x.data.matureResolve.query({title:r.name});u(`/anime/${m.id}`)}catch{Ue.error("Could not match this title on AniList")}finally{ee(null)}}},K=new Date().getFullYear(),Ge=[{value:"ALL",label:"All Years"},...Array.from({length:K-1980+1},(e,r)=>({value:String(K-r),label:String(K-r)}))],Be=R.length>0?R.map(e=>({value:e,label:ve(e)})):J.map(e=>({value:e.slug,label:e.name}));return b?t("div",{className:"page-container",children:[t("div",{className:a.header,children:[t("h1",{className:a.pageTitle,children:"Mature"}),t("p",{className:a.pageSubtitle,children:"Browse 18+ titles across AniList and streaming providers"})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(ge,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:C,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:L,className:a.searchBtn,children:"Search"}),d&&t("button",{onClick:()=>Pe(!j),className:`${a.filterToggleBtn} ${j?a.active:""}`,children:[t(ge,{name:"filter"})," Filters"]}),ie&&t("select",{value:M,onChange:e=>{Z(e.target.value),g(1),f(S({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Xe.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${j?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:_,onChange:e=>Y(e.currentTarget.value),children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Status"}),t("select",{value:N,onChange:e=>ye(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(me,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:D,onChange:e=>be(e.currentTarget.value),children:tt.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:G,onChange:e=>Ce(e.currentTarget.value),children:Ge.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]}),!d&&!!k&&($||v||E)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${Q.tightGrid}`,children:[v&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:se,onChange:e=>{Ne(e.target.value),g(1),f(S({remoteOrder:e.target.value,page:1}))},children:(A.length>0?A:["recent"]).map(e=>t("option",{value:e,children:et[e]||e},e))})]}),$&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:p,onChange:e=>{v?(B(e.target.value),g(1),f(S({genre:e.target.value,page:1}))):Me(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),E&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:W,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]})]}),p&&$&&!v&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(p)," genre — search text is ignored while a genre is selected."]}),(v||E)&&t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(We,{message:Ie?.message||"Search failed"}),Oe?t(Ye,{count:q}):F.length===0?t("div",{className:a.noResults,children:[t("h3",{children:"No results found"}),t("p",{children:"Try a different query, genre or provider"})]}):t(me,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[h?.total??F.length," result",(h?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>De(r,e),children:t(Ve,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})})]})]}):t(He,{isOpen:!0,onClose:()=>u("/"),onGrant:fe})}export{bt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as L,d as b,g as _e,h as F,u as e,S as w,$ as Ve,p as Ze,T as G}from"./vendor-core-DfaOB3Rn.js";import{t as Ce,W as je,h as O,z as P}from"./index-gMxawd-E.js";import{I as g}from"./vendor-icons-DrybRNxP.js";import{a as n}from"./Asmr.module-ChUXDZKx.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Pe,a as Re}from"./vendor-query-BBT5_sHx.js";function Be(a){if(!Number.isFinite(a)||a<0)return"0:00";const s=Math.floor(a/60),f=Math.floor(a%60);return`${s}:${String(f).padStart(2,"0")}`}const Je=({track:a,shuffle:s,onToggleShuffle:f,onTrackStep:R,onTrackFailed:be,onClose:se,liked:W,likeVisible:K,likePending:re,onToggleLike:X})=>{const M=L(null),ee=L(!1),[H,I]=b(!1),[he,u]=b(!0),[k,U]=b(!1),[$,A]=b(0),[z,oe]=b(0),[T,Y]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[E,le]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),V=L(T);V.current=T;const N=L(E);N.current=E;const y=L(0),D=L(0),B=L(null),Q=L("");Q.current||(Q.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const te=`/api/music/audio?videoId=${encodeURIComponent(a.id)}`,q=_e.useCallback(()=>{B.current&&(window.clearTimeout(B.current),B.current=null)},[]),Z=_e.useCallback(r=>{const o=M.current;if(!o)return;q(),u(!0),U(!1);const v=()=>{if(o.removeEventListener("loadedmetadata",v),r>5&&Number.isFinite(o.duration)&&r<o.duration-5)try{o.currentTime=r}catch{}};o.addEventListener("loadedmetadata",v),o.src=te,o.load(),o.volume=V.current,o.play().catch(()=>{})},[te,q]),ve=()=>{u(!1),U(!0),be?.(a),N.current&&R(1)},ce=()=>{if(!B.current){if(D.current>=3){ve();return}D.current+=1,B.current=window.setTimeout(()=>{B.current=null,Z(y.current)},5e3)}},ke=()=>{D.current=0,Z(y.current)};F(()=>{y.current=0,D.current=0,I(!1),A(0),oe(0);const r=M.current;return Z(y.current),()=>{q(),r&&r.removeAttribute("src")}},[Z,q]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=a.thumbnails?.[a.thumbnails.length-1]?.url??null,ne=_e.useCallback(r=>{const o=M.current;Ce.discord.musicPresence.mutate({title:a.title,artistLabel:a.artists,isPlaying:r,thumbnail:_||"",currentTime:o?.currentTime??0,duration:Number.isFinite(o?.duration??NaN)?o?.duration:0,sessionId:Q.current}).catch(()=>{}),Ce.discord.heartbeat.mutate({sessionId:Q.current}).catch(()=>{})},[a,_]);F(()=>{ne(H)},[ne,H,a.id]),F(()=>{if(!H)return;const r=window.setInterval(()=>ne(!0),15e3);return()=>window.clearInterval(r)},[H,ne]),F(()=>{const r=Q.current,o=()=>je(r),v=()=>o(),ae=()=>{document.visibilityState==="hidden"&&o()};return window.addEventListener("pagehide",v),window.addEventListener("beforeunload",v),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("pagehide",v),window.removeEventListener("beforeunload",v),document.removeEventListener("visibilitychange",ae),o()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,ge]=b(!1);F(()=>{ge(!1)},[_]);const ue=`${a.title} — ${a.artists}`,we=e(w,{children:[e("div",{className:n.playerButtons,children:[e("button",{className:n.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${n.playerBtn} ${n.playBtn}`,onClick:pe,"aria-label":H?"Pause":"Play",children:H?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:n.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),k&&e("button",{className:n.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:n.seekRow,children:[e("span",{className:n.timeLabel,children:Be($)}),e("input",{className:n.seekBar,type:"range",min:0,max:z||0,step:.1,value:Math.min($,z||0),onChange:r=>{const o=M.current;!o||!Number.isFinite(o.duration)||(o.currentTime=parseFloat(r.target.value),A(o.currentTime))},onPointerDown:()=>{ee.current=!0},onPointerUp:()=>{ee.current=!1},style:{"--played-percent":`${z>0?$/z*100:0}%`},"aria-label":"Seek"}),e("span",{className:n.timeLabel,children:Be(z)}),he&&!k&&e("span",{className:n.timeLabel,children:"loading…"})]})]}),fe=e(w,{children:[a.thumbnails?.[0]?.url&&!Ne&&e("img",{src:a.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>ge(!0)}),e("div",{className:n.playerInfo,children:[e("p",{className:n.playerTitle,title:ue,children:ue}),e("p",{className:n.playerTrack,children:a.artists})]}),e("div",{className:n.playerControls,children:we}),e("div",{className:n.playerRight,children:[T===0?e(g,{name:"volume-mute",className:n.volumeIcon}):T<.5?e(g,{name:"volume-down",className:n.volumeIcon}):e(g,{name:"volume-up",className:n.volumeIcon}),e("input",{className:n.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const o=parseFloat(r.target.value);Y(o),localStorage.setItem("musicVolume",String(o))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:n.playerActions,children:[K&&X&&e("button",{className:`${n.playerBtn} ${W?n.playerBtnActive:""}`,onClick:X,disabled:re,title:W?"Remove from Liked Music":"Add to Liked Music","aria-label":W?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!W,children:e(g,{name:"heart"})}),e("button",{className:`${n.playerBtn} ${s?n.playerBtnActive:""}`,onClick:f,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(g,{name:"shuffle"})}),e("button",{className:`${n.playerBtn} ${E?n.playerBtnActive:""}`,onClick:()=>{le(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:E?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":E,children:e(g,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(a.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:n.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(g,{name:"external-link-alt"})}),e("button",{className:n.playerBtn,onClick:se,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return Ve(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{I(!0),u(!1),U(!1),D.current=0,q()},onPause:()=>I(!1),onWaiting:()=>{k||u(!0)},onPlaying:()=>{u(!1),D.current=0,q()},onTimeUpdate:r=>{const o=r.target.currentTime;y.current=o,q(),ee.current||A(o)},onStalled:()=>{ce()},onLoadedMetadata:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onDurationChange:r=>{const o=r.target.duration;Number.isFinite(o)&&oe(o)},onError:()=>{ce()},onEnded:()=>{N.current&&R(1)}}),e("div",{className:n.playerBar,children:fe})]}),document.body)},Ke=()=>e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Where to get the cookie"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Google marks its login cookies unreadable to page scripts, so this has to come from DevTools — it takes about 20 seconds:"}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Open"," ",e("a",{href:"https://music.youtube.com/",target:"_blank",rel:"noopener noreferrer",children:"music.youtube.com"})," ","and make sure you are logged in."]}),e("li",{children:["Press ",e("kbd",{children:"F12"}),", go to the ",e("strong",{children:"Network"})," tab, and type ",e("kbd",{children:"browse"})," ","in the filter box."]}),e("li",{children:["Click any ",e("kbd",{children:"POST"})," browse entry, then scroll to Request Headers."]}),e("li",{children:[e("strong",{children:"Right-click"})," the ",e("kbd",{children:"Cookie"})," value and choose"," ",e("strong",{children:"Copy value"})," — right-click copies the full unwrapped value, selecting the text by hand truncates it."]}),e("li",{children:"Paste it into the sign-in box above and press Sign in."})]})]}),me=300*1e3,Xe=()=>{const a=O();return J({...a.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},et=()=>{const a=O(),s=Pe();return Re(a.music.authStart.mutationOptions({onSuccess:(f,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),s.invalidateQueries(a.music.pathFilter())}}))},tt=()=>{const a=O(),s=Pe();return Re(a.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},nt=a=>{const s=O();return J({...s.music.search.queryOptions({q:a}),enabled:a.trim().length>0,staleTime:me,retry:1})},at=a=>{const s=O();return J({...s.music.library.queryOptions(),enabled:a,staleTime:me,retry:1})},it=a=>{const s=O();return J({...s.music.track.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},st=a=>{const s=O();return J({...s.music.playlist.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},rt=a=>{const s=O();return J({...s.music.upnext.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},ot=a=>{const s=O();return J({...s.music.likes.queryOptions(),enabled:a,staleTime:120*1e3,retry:1})},lt=()=>{const a=O(),s=Pe();return Re(a.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(a.music.pathFilter())}}))},ct="_authRow_10tvv_1",ut="_btn_10tvv_9",dt="_btnGhost_10tvv_42",mt="_cookieForm_10tvv_74",ht="_cookieInput_10tvv_83",pt="_link_10tvv_99",gt="_contentLayout_10tvv_109",ft="_mainCol_10tvv_116",yt="_upnextAside_10tvv_120",bt="_upnextHeader_10tvv_131",vt="_upnextTitle_10tvv_139",kt="_upnextActions_10tvv_149",Nt="_nowPlayingLabel_10tvv_156",wt="_nowPlayingWrap_10tvv_168",St="_likeBtn_10tvv_172",Tt="_likeActive_10tvv_196",p={authRow:ct,btn:ut,btnGhost:dt,cookieForm:mt,cookieInput:ht,link:pt,contentLayout:gt,mainCol:ft,upnextAside:yt,upnextHeader:bt,upnextTitle:vt,upnextActions:kt,nowPlayingLabel:Nt,nowPlayingWrap:wt,likeBtn:St,likeActive:Tt};function Fe(a){const s=a.trim();if(!s)return null;const f=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return f||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const xt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",It=()=>{const[a,s]=Ze(),f=Fe(a.get("v")??""),[R,be]=b(""),[se,W]=b(""),[K,re]=b(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[X,M]=b(!1),[ee,H]=b(()=>localStorage.getItem("musicShuffle")==="true"),[I,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[u,k]=b(null),[U,$]=b([]),[A,z]=b(null),[oe,T]=b({}),Y=L([]);Y.current=U;const E=L(null);E.current=u;const le=L(!1),V=L(new Set),{data:N}=Xe(),y=et(),D=tt(),B=typeof navigator<"u"?navigator.userAgent:"",Q=/android/i.test(B),te=/firefox|fxios/i.test(B)&&!Q,q=!te&&!Q&&/chrome|chromium|edg|brave/i.test(B),Z=te||q,ve=()=>{if(X)return;M(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",c),M(!1),P.error("Helper not detected — install the Dango Helper extension first.")},3e3),c=d=>{let m;try{m=JSON.parse(d.detail)}catch{return}if(!(!m||m.requestId!==t))if(window.clearTimeout(i),window.removeEventListener("dango:ytmusic-cookie",c),M(!1),m?.ok&&m.cookie){const l=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(l.includes("…")||l.includes("...")){P.error(`Helper returned a truncated cookie (${l.length} chars) — reload music.youtube.com and Extract again.`);return}re(l),P.success("Cookie extracted from helper — signing in…"),y.mutate({cookie:l})}else m?.error==="NO_COOKIE"?P.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):P.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",c),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ce,isLoading:ke}=nt(se),{data:_,isLoading:ne,isFetching:pe,error:Ne,refetch:ge}=at(N?.authenticated===!0),{data:ue,isLoading:we}=st(A?.id??null),{data:fe,isLoading:Se}=rt(u?.id??null),{data:r}=ot(N?.authenticated===!0),o=lt(),v=G(()=>ce?.tracks||[],[ce]),ae=G(()=>_?.playlists||[],[_]),C=G(()=>_?.tracks||[],[_]),j=G(()=>ue?.tracks||[],[ue]),S=G(()=>{const t=fe?.tracks||[];return u?t.filter(i=>i.id!==u.id):t},[fe,u]),Oe=G(()=>new Set(r?.likedIds||[]),[r]),Te=t=>oe[t.id]??(Oe.has(t.id)||t.liked===!0);F(()=>{N?.authenticated!==!0&&T({})},[N?.authenticated]);const De=G(()=>[...v,...j,...C,...S],[v,j,C,S]),qe=f&&u?.id!==f&&!De.some(t=>t.id===f)?f:null,{data:Ie}=it(qe),xe=u?.id;F(()=>{document.title=u?`${u.title} - dango`:"Music - dango"},[u]),F(()=>{if(!f){xe&&k(null);return}if(xe===f)return;const t=d=>{const m=d.find(l=>l.id===f);return m?(k(m),$(l=>l.some(ie=>ie.id===f)?l:d.length>0?d:[m]),!0):!1};if(t(v)||t(j)||t(C))return;const i=S.find(d=>d.id===f);if(i){k(i),$(d=>d.some(m=>m.id===i.id)?d:[i]);return}const c=Ie?.track;c&&c.id===f&&(k(c),$(d=>d.some(m=>m.id===c.id)?d:[c]))},[f,xe,v,j,C,S,Ie]);const Le=(t,i)=>{V.current.delete(t.id),k(t),$(i.length>0?i:[t]),s({v:t.id})},He=t=>{V.current.add(t.id),P.error(`Couldn't play “${t.title}” — skipped.`)},Ue=async()=>{if(le.current)return;const t=Y.current,i=t[t.length-1]??E.current;if(i){le.current=!0;try{const c=await Ce.music.upnext.query({id:i.id}),d=new Set(t.map(l=>l.id)),m=(c.tracks||[]).filter(l=>!d.has(l.id)&&!V.current.has(l.id));if(m.length===0){const l=Y.current[0];l&&(k(l),s({v:l.id}));return}$([...Y.current,...m]),k(m[0]),s({v:m[0].id})}catch{const c=Y.current[0];c&&(k(c),s({v:c.id}))}finally{le.current=!1}}},ze=t=>{const i=Y.current,c=E.current;if(!c||i.length===0)return;const d=i.findIndex(x=>x.id===c.id);if(t>0&&I&&(d<0||d===i.length-1)){Ue();return}const m=x=>V.current.has(x.id),l=i.length;let ie;if(ee&&l>1){let x=Math.floor(Math.random()*l);for(let Me=0;Me<l&&(x===d||m(i[x]));Me++)x=Math.floor(Math.random()*l);ie=i[x]}else{const x=t>0?1:-1;let ye=(((d<0?x>0?-1:0:d)+x)%l+l)%l;for(let Ee=1;Ee<l&&m(i[ye]);Ee++)ye=((ye+x)%l+l)%l;ie=i[ye]}k(ie),s({v:ie.id})},Ye=()=>{if(I){he(!1),localStorage.setItem("musicRadio","false");return}const t=E.current;if(!t)return;if(S.length===0){P.error("No radio suggestions for this song yet.");return}const i=new Set,c=[];for(const d of[t,...S])i.has(d.id)||(i.add(d.id),c.push(d));he(!0),localStorage.setItem("musicRadio","true"),$(c),P.success(`Radio started — ${S.length} songs queued.`)},$e=t=>{if(N?.authenticated!==!0){P.error("Sign in to like songs.");return}const i=!Te(t);T(c=>({...c,[t.id]:i})),o.mutate({id:t.id,like:i},{onError:()=>{T(c=>{const d={...c};return delete d[t.id],d}),P.error("Like action failed — try again.")}})},Qe=()=>{H(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ge=t=>e("button",{className:h.stationRow,onClick:()=>z(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),de=(t,i,c)=>{const d=u?.id===t.id,m=Te(t),l=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${d?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Le(t,i),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,l?` · ${l}`:""]})]})]}),N?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${m?p.likeActive:""}`,onClick:()=>$e(t),disabled:o.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(g,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(g,{name:"external-link-alt"})})]},t.id)},Ae=G(()=>{if(!u)return S;const t=new Set,i=[];for(const c of[u,...S])t.has(c.id)||(t.add(c.id),i.push(c));return i},[u,S]),We=t=>{Le(t,Ae)};return e("div",{className:`${n.page} ${u?n.pageWithPlayer:""}`,children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:n.searchForm,onSubmit:t=>{t.preventDefault();const i=Fe(R);i?(W(""),s({v:i})):W(R)},children:[e("input",{className:n.searchInput,value:R,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:n.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[N?.authenticated?e(w,{children:[e("span",{className:n.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>D.mutate(),disabled:D.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=K.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){P.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==K&&re(i),y.mutate({cookie:i})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:K,onChange:t=>re(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:y.isPending||!K.trim(),children:y.isPending?"Checking…":"Sign in"}),Z&&e("button",{className:p.btnGhost,type:"button",onClick:ve,disabled:X||y.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:X?"Extracting…":"Extract from helper"})]}),Z&&e("p",{className:n.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:xt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",te?e(w,{children:[e("code",{children:"about:debugging"})," → ",e("strong",{children:"This Firefox"})," →"," ",e("strong",{children:"Load Temporary Add-on"})," →"," ",e("code",{children:"dango-extension/firefox/manifest.json"})]}):e(w,{children:[e("code",{children:"chrome://extensions"})," → ",e("strong",{children:"Developer mode"})," →"," ",e("strong",{children:"Load unpacked"})," → ",e("code",{children:"dango-extension/chrome"})]}),", log in on a music.youtube.com tab, and click Extract."]}),e(Ke,{})]}),y.isSuccess&&e("p",{className:n.statusMsg,children:["Signed in — found ",y.data.tracks," songs and ",y.data.playlists," ","playlists."]}),y.isError&&e("p",{className:n.statusMsg,children:y.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!N?.authenticated&&!y.isError&&!y.isSuccess&&e("p",{className:n.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:u?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:se?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",se,"”"]}),ke?e("p",{className:n.statusMsg,children:"Searching…"}):v.length===0?e("p",{className:n.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:v.map(t=>de(t,v))})]}):N?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ne?e("p",{className:n.statusMsg,children:"Loading library…"}):ae.length===0&&C.length===0&&!A?e(w,{children:[e("p",{className:n.statusMsg,children:Ne?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{ge()},disabled:pe,"aria-label":"Retry loading library",children:pe?"Retrying…":"Retry"})}),e("p",{className:n.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[ae.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:ae.map(t=>Ge(t))})]}),C.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",C.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Le(C[0],C),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:C.map(t=>de(t,C))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>z(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),we?e("p",{className:n.statusMsg,children:"Loading playlist…"}):j.length===0?e("p",{className:n.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:j.map(t=>de(t,j))})]}):null]})]}):e("p",{className:n.statusMsg,children:"Search above, or sign in to see your library."})}),u&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),de(u,U.length>0?U:[u])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:Ye,disabled:!I&&(Se||S.length===0),"aria-pressed":I,title:I?"Stop the radio — the queue will loop instead of fetching more songs":"Queue these suggestions after the current song and keep the mix going",children:I?"Stop radio":"Start radio"})}),Se?e("p",{className:n.statusMsg,children:"Loading suggestions…"}):S.length===0?e("p",{className:n.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:S.map(t=>de(t,Ae,We))})]})]}),u&&e(Je,{track:u,queue:U,shuffle:ee,onToggleShuffle:Qe,onTrackStep:ze,onTrackFailed:He,onClose:()=>{k(null),s({})},liked:u?Te(u):!1,likeVisible:N?.authenticated===!0,likePending:o.isPending,onToggleLike:()=>$e(u)})]})};export{It as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as e,S as p,d as y,h as S}from"./vendor-core-DfaOB3Rn.js";import{I as m}from"./vendor-icons-DrybRNxP.js";import{M as s,z as b,T as g,B as f,D as k,F as C}from"./AvSyncCalibrator-BuHurVgo.js";const O=({classes:n,title:i,titleTag:o="span",showBack:l=!0,onBack:t,panelRef:d,onPanelClick:a,children:c})=>{const r=o;return e("div",{ref:d,className:n.panel,onClick:a,"data-speed-boost-ignore":"true",children:[e("div",{className:n.header,children:[l&&e("button",{className:n.backBtn,onClick:t,children:e(m,{name:"chevron-left"})}),e(r,{className:n.title||void 0,children:i})]}),e("div",{className:n.content,children:c})]})},z=({classes:n,values:i,onChange:o})=>{const l=()=>{const t=C;o("fontSize",t.fontSize),o("position",t.position),o("bgOpacity",t.bgOpacity),o("bgColor",t.bgColor),o("textColor",t.textColor),o("edge",t.edge),o("bold",t.bold)};return e(p,{children:[e(s,{label:"Font Size",display:i.fontSize.toFixed(1),min:.5,max:10,step:.5,value:i.fontSize,percent:(i.fontSize-.5)/9.5*100,onChange:t=>{Number.isFinite(t)&&o("fontSize",t)}}),e(s,{label:"Vertical Position",display:`${i.position}`,min:0,max:100,step:1,value:i.position,percent:i.position,onChange:t=>{Number.isFinite(t)&&o("position",Math.round(t))}}),e(s,{label:"Background Opacity",display:`${Math.round(i.bgOpacity*100)}%`,min:0,max:1,step:.05,value:i.bgOpacity,percent:i.bgOpacity*100,onChange:t=>{Number.isFinite(t)&&o("bgOpacity",t)}}),e(b,{label:"Text Color",colors:g,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:f,value:i.bgColor,onChange:t=>o("bgColor",t)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:i.edge,onChange:t=>o("edge",t)}),e("button",{type:"button",className:`${n.item} ${i.bold?n.active:""}`,onClick:()=>o("bold",!i.bold),children:[e("span",{children:"Bold Text"}),i.bold&&e(m,{name:"check",size:12})]}),e("button",{type:"button",className:n.item,onClick:l,children:e("span",{children:"Reset to Defaults"})})]})},M=({classes:n,enabled:i,delayMs:o,onToggle:l,onDelayChange:t,onCalibrate:d})=>{const[a,c]=y(null),r=a??o;S(()=>{c(null)},[o]);const u=()=>{a!==null&&(t(a),c(null))};return e(p,{children:[e("button",{type:"button",className:`${n.item} ${i?n.active:""}`,onClick:()=>l(!i),children:[e("span",{children:"Video delay"}),i&&e(m,{name:"check",size:12})]}),e(s,{label:"Video delay",display:`${r}ms`,min:0,max:500,step:5,value:r,percent:r/500*100,onChange:h=>c(Math.round(h)),onCommit:u}),e("div",{className:n.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),d&&e("button",{type:"button",className:n.item,onClick:d,children:e("span",{children:"Calibrate…"})})]})},E=({classes:n,options:i,onSelect:o})=>e(p,{children:i.map(l=>e("button",{type:"button",className:`${n.item} ${l.selected?n.active:""}`,onClick:()=>o(l.key),children:[e("span",{children:l.label}),l.selected&&e(m,{name:"check",size:12})]},l.key))});export{M as A,E as O,O as S,z as a};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-D47ItGDR.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-DngTgHxH.js","assets/AvSyncCalibrator-BuHurVgo.js","assets/index-gMxawd-E.js","assets/vendor-query-BBT5_sHx.js","assets/index-Cc1Up_NI.css","assets/AvSyncCalibrator-D0FYSwiz.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{g as Ot,h as x,u as r,P as Lr,z as Ir,d as H,A as f,q as O,y as Dr,T as ot,o as $r,a as Fr,c as Wr,_ as Or,S as kt}from"./vendor-core-DfaOB3Rn.js";import{_ as fr,S as xt,h as Vr,t as Te,z as Ge,P as Ur,e as qr,l as Qr,m as zr,n as Gr,o as Kr,d as Hr,u as jr,M as Le,B as Ze,Q as Yr,f as Xr}from"./index-gMxawd-E.js";import{u as hr,b as cr,a as jt}from"./vendor-query-BBT5_sHx.js";import{C as Jr,S as Zr,U as en,a as tn,p as Yt,s as rn,l as nn,u as sn,b as on,i as an,c as ur,d as ln,e as dr,f as pr,g as cn,h as un,j as dn,r as pn,k as ze,E as mn,m as fn,n as d,o as hn,A as vn,P as gn,q as bn,t as yn}from"./AvSyncCalibrator-BuHurVgo.js";import{I as j}from"./vendor-icons-DrybRNxP.js";import{l as Sn}from"./hls-B3_1VuDP.js";import{u as En}from"./useIsMobile-Dvx1uJ82.js";import{s as et,Q as wn}from"./QueueRail-DeJKVRs5.js";import{u as Tn,Q as kn}from"./QueueOptionsButton-ClVTpH8J.js";import{u as vr}from"./useProviders-Ca0bZWt7.js";import{A as Cn}from"./AnimeMetaDetails-BogOi_bM.js";import{S as Mn}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const Rn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},_n={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Nn=["direct","cookie","embed"],Pn="_controlsOverlay_1b7ea_1",xn="_hidden_1b7ea_21",An="_topControls_1b7ea_27",Bn="_backBtn_1b7ea_47",Ln="_videoTitleInfo_1b7ea_67",In="_animeTitle_1b7ea_73",Dn="_episodeNumber_1b7ea_81",$n="_bottomControls_1b7ea_89",Fn="_progressBarContainer_1b7ea_108",Wn="_progressBar_1b7ea_108",On="_thumb_1b7ea_127",Vn="_scrubbing_1b7ea_142",Un="_watchedBar_1b7ea_146",qn="_bufferedBar_1b7ea_147",Qn="_timeBubble_1b7ea_185",zn="_skipSegment_1b7ea_219",Gn="_op_1b7ea_229",Kn="_ed_1b7ea_232",Hn="_recap_1b7ea_235",jn="_bottomControlsRow_1b7ea_239",Yn="_leftControls_1b7ea_247",Xn="_rightControls_1b7ea_248",Jn="_controlBtn_1b7ea_255",Zn="_theaterBtn_1b7ea_296",es="_nextEpisodeBtn_1b7ea_300",ts="_active_1b7ea_317",rs="_timeDisplay_1b7ea_321",ns="_skipControls_1b7ea_329",ss="_skipBtn_1b7ea_335",os="_volumeContainer_1b7ea_376",as="_volumeSlider_1b7ea_382",is="_playerPageLayout_1b7ea_440",ls="_videoPlayerWrapper_1b7ea_444",cs="_playerInfoContainer_1b7ea_449",us="_visible_1b7ea_566",ds="_shortcuts_1b7ea_584",k={controlsOverlay:Pn,hidden:xn,topControls:An,backBtn:Bn,videoTitleInfo:Ln,animeTitle:In,episodeNumber:Dn,bottomControls:$n,progressBarContainer:Fn,progressBar:Wn,thumb:On,scrubbing:Vn,watchedBar:Un,bufferedBar:qn,timeBubble:Qn,skipSegment:zn,op:Gn,ed:Kn,recap:Hn,bottomControlsRow:jn,leftControls:Yn,rightControls:Xn,controlBtn:Jn,theaterBtn:Zn,nextEpisodeBtn:es,active:ts,timeDisplay:rs,skipControls:ns,skipBtn:ss,volumeContainer:os,volumeSlider:as,playerPageLayout:is,videoPlayerWrapper:ls,playerInfoContainer:cs,visible:us,shortcuts:ds},ps=Ir(()=>fr(()=>import("./PlayerSettings-D47ItGDR.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),ms=({player:n,isAutoplayEnabled:v,onAutoplayChange:C,showNextEpisodeButton:Y,onNextEpisode:g,videoSources:R,selectedSource:E,selectedLink:I,onSourceChange:L,loadingVideo:Q,skipIntervals:ke,animeTitle:e,episodeNumber:m,isTheaterMode:Ce,onTheaterModeToggle:N,anime4kEnabled:ie,onAnime4kToggle:We,anime4kSupported:V,anime4kProfile:B,onAnime4kProfileChange:$,anime4kInitializing:Oe,anime4kError:Ke,videoDelayEnabled:a,onVideoDelayToggle:u,videoDelayMs:w,onVideoDelayChange:ge,onCalibrateAvSync:Ve,fallbackChoice:Ie,onFallbackChoiceChange:De,children:He,overlays:ne,isInteractingExtra:Me=!1,className:c,hideChrome:y=!1})=>{const{state:o,refs:h,actions:b}=n,{showSettings:F}=o,{setShowSettings:ye,setShowVolumeSlider:Z}=b,U=Ot.useRef(null),le=Ot.useRef(null);x(()=>{const p=P=>{U.current&&!U.current.contains(P.target)&&le.current&&!le.current.contains(P.target)&&F&&ye(!1)};return F&&document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[F,ye]);const Se=Ot.useRef(null),tt=p=>{h.videoRef.current&&(h.videoRef.current.volume=p,h.videoRef.current.muted=p===0,localStorage.setItem("playerVolume",p.toString()))},je=p=>{!h.videoRef.current||isNaN(o.duration)||o.duration===0||(h.videoRef.current.currentTime=p*o.duration,b.sendProgressUpdate(!1,!0))},ht=()=>{h.videoRef.current&&(b.setIsScrubbing(!0),b.wasPlayingBeforeScrub.current=!h.videoRef.current.paused,h.videoRef.current.pause())},z=p=>{!h.videoRef.current||!o.duration||(h.videoRef.current.currentTime=p*o.duration)},rt=()=>{b.setIsScrubbing(!1),b.wasPlayingBeforeScrub.current&&h.videoRef.current?.play()},at=p=>{if(!h.videoRef.current)return;b.setActiveSubtitleTrack(p);try{if(p===null||p==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const M=o.availableSubtitles.find(qe=>qe.label===p||qe.lang===p);M?localStorage.setItem("playerLastSubtitle",rn(M)):localStorage.setItem("playerLastSubtitle",p)}}catch{}let P=!1;Array.from(h.videoRef.current.textTracks).forEach(M=>{const $e=p!==null&&p!=="off"&&(M.language===p||M.label===p)&&!P;M.mode=$e?"showing":"hidden",$e&&(P=!0)})},se=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off",ue=()=>{if(!h.videoRef.current)return;if(se){at("off");return}if(o.availableSubtitles.length===0)return;let p=null;try{p=localStorage.getItem("playerLastSubtitle")}catch{}const P=Yt(o.availableSubtitles,{lastKey:p,enabled:!0});if(P<0)return;const M=o.availableSubtitles[P];at(M.label||M.lang)},Re=()=>o.isMuted||o.volume===0?r(j,{name:"volume-mute"}):o.volume<.5?r(j,{name:"volume-down"}):r(j,{name:"volume-up"}),vt=r("div",{className:`${k.controlsOverlay} ${!o.showControls&&!F&&!o.isScrubbing?k.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:k.topControls,onClick:p=>p.stopPropagation(),children:[r("button",{className:k.backBtn,onClick:p=>{p.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(j,{name:"chevron-left"})}),r("div",{className:k.videoTitleInfo,children:[r("span",{className:k.animeTitle,children:e}),m&&r("span",{className:k.episodeNumber,children:["Episode ",m]})]})]})}),W=!Q&&!o.isBuffering&&o.duration>0?r(Jr,{isPlaying:o.isPlaying,onTogglePlay:b.togglePlay,onSkipBack:()=>b.seek(-10),onSkipForward:()=>b.seek(10)}):null,Ue=r("div",{className:`${k.controlsOverlay} ${!o.showControls&&!F&&!o.isScrubbing?k.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:k.bottomControls,"data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),children:[r(Zr,{classes:{container:k.progressBarContainer,scrubbing:k.scrubbing,timeBubble:k.timeBubble,bar:k.progressBar,buffered:k.bufferedBar,watched:k.watchedBar,thumb:k.thumb},videoRef:h.videoRef,duration:o.duration,formatTime:b.formatTime,isScrubbing:o.isScrubbing,onSeek:je,onScrubStart:ht,onScrubMove:z,onScrubEnd:rt,timeLabelRef:Se,children:[o.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${k.skipSegment} ${k[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}% `}}),ke.map(p=>{const P=p.start_time/o.duration*100,M=(p.end_time-p.start_time)/o.duration*100;return r("div",{className:`${k.skipSegment} ${k[p.skip_type]} `,style:{left:`${P}% `,width:`${M}% `},title:p.skip_type.toUpperCase()},p.skip_id)})]}),r("div",{className:k.bottomControlsRow,children:[r("div",{className:k.leftControls,children:[r("button",{className:k.controlBtn,onClick:b.togglePlay,"aria-label":o.isPlaying?"Pause":"Play",children:o.isPlaying?r(j,{name:"pause"}):r(j,{name:"play"})}),r(en,{muted:o.isMuted,volume:o.volume,volumeIcon:Re(),buttonClassName:k.controlBtn,onToggleMute:b.toggleMute,onVolumeChange:tt,onExpandedChange:p=>Z(p)}),r("span",{className:k.timeDisplay,ref:Se,children:[b.formatTime(0)," / ",b.formatTime(o.duration)]}),o.currentSkipInterval&&!o.isAutoSkipEnabled&&r("button",{className:k.controlBtn,onClick:()=>{h.videoRef.current&&o.currentSkipInterval&&(h.videoRef.current.currentTime=o.currentSkipInterval.end_time,b.setCurrentSkipInterval(null))},children:["Skip ",o.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:k.rightControls,children:[r("div",{className:k.skipControls,children:Y&&r("button",{className:k.nextEpisodeBtn,onClick:g,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${k.controlBtn} ${se?k.active:""}`,onClick:ue,title:se?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(j,{name:"closed-captioning",size:22})}),r("button",{ref:le,className:`${k.controlBtn} ${F?k.active:""} `,onClick:()=>ye(!F),"aria-label":"Settings",children:r(j,{name:"cog"})}),r("button",{className:`${k.controlBtn} ${k.theaterBtn} ${Ce?k.active:""} `,onClick:p=>{p.stopPropagation(),N()},title:Ce?"Exit Theater Mode":"Theater Mode","aria-label":Ce?"Exit Theater Mode":"Theater Mode",children:r(j,{name:"tv"})}),r("button",{className:k.controlBtn,onClick:b.toggleFullscreen,"aria-label":o.isFullscreen?"Exit Fullscreen":"Fullscreen",children:o.isFullscreen?r(j,{name:"compress"}):r(j,{name:"expand"})})]})]})]})}),it=r(Lr,{fallback:null,children:r(ps,{ref:U,isOpen:F,onClose:()=>ye(!1),videoSources:R,currentSource:E,currentLink:I,onSourceChange:L,subtitles:o.availableSubtitles,activeSubtitleTrack:o.activeSubtitleTrack,onSubtitleChange:at,subtitleSettings:{fontSize:o.subtitleFontSize,position:o.subtitlePosition,bgOpacity:o.subtitleBgOpacity,bgColor:o.subtitleBgColor,textColor:o.subtitleTextColor,edge:o.subtitleEdge,bold:o.subtitleBold},onSubtitleSettingsChange:(p,P)=>{const M=(qe,$e)=>{try{localStorage.setItem(qe,String($e))}catch{}};switch(p){case"fontSize":b.setSubtitleFontSize(P),M("subtitleFontSize",P);break;case"position":b.setSubtitlePosition(P),M("subtitlePosition",P);break;case"bgOpacity":b.setSubtitleBgOpacity(P),M("subtitleBgOpacity",P);break;case"bgColor":b.setSubtitleBgColor(P),M("subtitleBgColor",P);break;case"textColor":b.setSubtitleTextColor(P),M("subtitleTextColor",P);break;case"edge":b.setSubtitleEdge(P),M("subtitleEdge",P);break;case"bold":b.setSubtitleBold(P),M("subtitleBold",P);break}},useNativeControls:o.useNativeControls,onNativeControlsToggle:b.setUseNativeControls,anime4kEnabled:ie,onAnime4kToggle:We,anime4kSupported:V,anime4kProfile:B,onAnime4kProfileChange:$,anime4kInitializing:Oe,anime4kError:Ke,videoDelayEnabled:a,onVideoDelayToggle:u,videoDelayMs:w,onVideoDelayChange:ge,onCalibrateAvSync:Ve,isAutoSkipEnabled:o.isAutoSkipEnabled,onAutoSkipChange:p=>{b.setIsAutoSkipEnabled(p);try{localStorage.setItem("autoSkipEnabled",p.toString())}catch{}},isAutoplayEnabled:v,onAutoplayChange:C,fallbackChoice:Ie,onFallbackChoiceChange:De})}),nt=F?r("div",{"data-speed-boost-ignore":"true",onClick:p=>p.stopPropagation(),children:it}):null;return r(tn,{player:n,topBar:vt,centerControls:W,bottomBar:!Q&&o.duration>0?Ue:null,settingsPanel:nt,overlays:ne,isInteracting:Me,className:c,chromeDisabled:y,children:He})},fs=({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(xt,{width:"60px",height:"1.2rem",variant:"text"})}),r(j,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:et.list,children:Array.from({length:n}).map((v,C)=>r("div",{className:et.item,style:{pointerEvents:"none"},children:[r("div",{className:et.dragHandle,style:{opacity:.2},children:r(xt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:et.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(xt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:et.meta,children:[r(xt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(xt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},C))})]}),hs="_sourceSelectionContainer_c5tub_76",vs="_providerSelectContainer_c5tub_89",gs="_providerSelect_c5tub_89",bs="_sourceSelect_c5tub_76",ys="_sourceButtons_c5tub_145",Ss="_sourceButton_c5tub_145",Es="_active_c5tub_170",ft={sourceSelectionContainer:hs,providerSelectContainer:vs,providerSelect:gs,sourceSelect:bs,sourceButtons:ys,sourceButton:Ss,active:Es},ws=({selectedProvider:n,onProviderChange:v,isAdult:C,options:Y})=>{const g=Y&&Y.length>0?Y:[],R=C===void 0?g:g.filter(E=>E.mature===C);return r("div",{className:ft.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:ft.providerSelect,value:n,onChange:E=>v(E.target.value),children:Nn.map(E=>{const I=R.filter(L=>(L.tier??"direct")===E);return I.length===0?null:r("optgroup",{label:_n[E],children:I.map(L=>r("option",{value:L.value,children:L.sub?`${L.label} (${Rn[L.sub]})`:L.label},L.value))},E)})})]})},Ts=({videoSources:n,selectedSource:v,selectedLink:C,onSourceChange:Y,onLinkChange:g})=>{const R=Array.isArray(n)?n:[];if(R.length===0)return null;const E=v?.type==="iframe"&&(v.links?.length??0)>1;return r("div",{className:ft.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:ft.sourceButtons,children:R.map((I,L)=>r("button",{className:`${ft.sourceButton} ${v?.sourceName===I.sourceName?ft.active:""} `,onClick:()=>Y(I),children:I.sourceName},`${I.sourceName}-${L}`))}),E&&r("select",{className:ft.sourceSelect,"aria-label":"Fallback embed quality",value:C?.link??v.links[0]?.link??"",onChange:I=>{const L=v.links.find(Q=>Q.link===I.target.value);L&&g(L)},children:v.links.map(I=>r("option",{value:I.link,children:I.resolutionStr},I.link))})]})},ks=Ot.memo(Ts,(n,v)=>n.selectedSource?.sourceName===v.selectedSource?.sourceName&&n.selectedLink?.link===v.selectedLink?.link&&n.videoSources===v.videoSources),Cs={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}},Ms={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Rs=5,_s=15e3,Ns=`
|
|
3
|
-
@group(0) @binding(0) var extTex: texture_external;
|
|
4
|
-
@group(0) @binding(1) var extSamp: sampler;
|
|
5
|
-
struct VSOut {
|
|
6
|
-
@builtin(position) pos: vec4f,
|
|
7
|
-
@location(0) uv: vec2f,
|
|
8
|
-
};
|
|
9
|
-
@vertex
|
|
10
|
-
fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
|
|
11
|
-
var positions = array<vec2f, 6>(
|
|
12
|
-
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
13
|
-
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
14
|
-
);
|
|
15
|
-
var uvs = array<vec2f, 6>(
|
|
16
|
-
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
17
|
-
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
18
|
-
);
|
|
19
|
-
var out: VSOut;
|
|
20
|
-
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
21
|
-
out.uv = uvs[idx];
|
|
22
|
-
return out;
|
|
23
|
-
}
|
|
24
|
-
@fragment
|
|
25
|
-
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
26
|
-
return textureSampleBaseClampToEdge(extTex, extSamp, uv);
|
|
27
|
-
}
|
|
28
|
-
`;function Ps({videoRef:n,canvasRef:v,profile:C="balanced",delayMs:Y=0}){const[g,R]=H(!1),[E,I]=H(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[L,Q]=H(!1),[ke,e]=H(null),[m,Ce]=H(0),N=f(0),ie=f(null),We=f(null),V=f(null),B=f(null),$=f(null),Oe=f(null),Ke=f(null),a=f(null),u=f(null),w=f(!1),ge=f(-1),Ve=f(0),Ie=f(Y);Ie.current=Y;const De=f([]),He=f(!1),ne=f(!1),Me=f(!1),c=f(null),y=f(-1),o=f(-1),h=f(!1),b=f(0);x(()=>{async function Z(){if(typeof navigator>"u"||!navigator.gpu){R(!1);return}try{const U=await navigator.gpu.requestAdapter();R(!!U)}catch{R(!1)}}Z()},[]),x(()=>{if(!E||!g)return;let Z=!1;const U=++N.current,le=z=>{if(z)try{z.close()}catch{}},Se=()=>{for(const z of De.current)le(z.bitmap);De.current=[]},tt=z=>Math.max(8,Math.min(40,Math.ceil(z/16.7)+4));function je(){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}async function ht(){let z=n.current;const rt=v.current;if(!z||!rt||N.current!==U)return;const at=performance.now()+_s;for(;(!z||z.videoWidth===0)&&performance.now()<at;){if(await new Promise(M=>requestAnimationFrame(M)),Z||N.current!==U)return;z=n.current}if(!z||z.videoWidth===0){!Z&&N.current===U&&(e("Timed out waiting for video metadata"),Q(!1),I(!1));return}const se=z.videoWidth,ue=z.videoHeight,Re=Math.max(se,ue),vt=window.innerWidth,W=window.innerHeight,Ue=Math.max(vt,W),it=Re<Ue?Ue/Re:1,nt=Cs[C],p=Re<=480?nt.sd:Re<=720?nt.hd:Re<=1080?nt.fhd:1,P=Math.min(p,it);rt.width=Math.round(se*P),rt.height=Math.round(ue*P),Q(!0),e(null),Ve.current=0,ge.current=-1,y.current=-1,o.current=-1,h.current=!1,b.current=0,Se(),w.current=!1;try{let M=function(){Z||N.current!==U||(je(),u.current=requestAnimationFrame(()=>{Mt()}))};const{ModeA:qe,ModeB:$e,ModeC:Vt,ModeAA:Ct}=await fr(async()=>{const{ModeA:D,ModeB:X,ModeC:xe,ModeAA:me}=await import("./index-BOKlZEHq.js").then(fe=>fe.i);return{ModeA:D,ModeB:X,ModeC:xe,ModeAA:me}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const Ye=await navigator.gpu.requestAdapter();if(!Ye)throw new Error("No GPU adapter found");const T=await Ye.requestDevice();if(!T)throw new Error("Failed to get GPU device");const lt=rt.getContext("webgpu");if(!lt)throw new Error("Failed to get WebGPU context");const gt=navigator.gpu.getPreferredCanvasFormat();lt.configure({device:T,format:gt,alphaMode:"premultiplied"});const de=T.createTexture({size:[se,ue],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),ct=Ms[C],Qe=Math.round(se*P),_e=Math.round(ue*P),Ne=(()=>{switch(ct){case"ModeB":return new $e({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}});case"ModeC":return new Vt({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}});case"ModeAA":return new Ct({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}});default:return new qe({device:T,inputTexture:de,nativeDimensions:{width:se,height:ue},targetDimensions:{width:Qe,height:_e}})}})(),Xe=Ne.getOutputTexture(),bt=T.createSampler({magFilter:"linear",minFilter:"linear"}),Pe=T.createShaderModule({code:`
|
|
29
|
-
@group(0) @binding(0) var tex: texture_2d<f32>;
|
|
30
|
-
@group(0) @binding(1) var samp: sampler;
|
|
31
|
-
struct VertexOutput {
|
|
32
|
-
@builtin(position) pos: vec4f,
|
|
33
|
-
@location(0) uv: vec2f,
|
|
34
|
-
}
|
|
35
|
-
@vertex
|
|
36
|
-
fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
|
|
37
|
-
var positions = array<vec2f, 6>(
|
|
38
|
-
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
39
|
-
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
40
|
-
);
|
|
41
|
-
var uvs = array<vec2f, 6>(
|
|
42
|
-
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
43
|
-
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
44
|
-
);
|
|
45
|
-
var out: VertexOutput;
|
|
46
|
-
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
47
|
-
out.uv = uvs[idx];
|
|
48
|
-
return out;
|
|
49
|
-
}
|
|
50
|
-
@fragment
|
|
51
|
-
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
52
|
-
return textureSample(tex, samp, uv);
|
|
53
|
-
}
|
|
54
|
-
`}),yt=T.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),St=T.createRenderPipeline({layout:T.createPipelineLayout({bindGroupLayouts:[yt]}),vertex:{module:Pe,entryPoint:"vs"},fragment:{module:Pe,entryPoint:"fs",targets:[{format:gt}]},primitive:{topology:"triangle-list"}}),ut=T.createBindGroup({layout:yt,entries:[{binding:0,resource:Xe.createView()},{binding:1,resource:bt}]});try{const D=T.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),X=T.createShaderModule({code:Ns}),xe=T.createRenderPipeline({layout:T.createPipelineLayout({bindGroupLayouts:[D]}),vertex:{module:X,entryPoint:"vs"},fragment:{module:X,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:xe,layout:D,inputView:de.createView()}}catch{c.current=null}if(N.current!==U){de.destroy(),T.destroy();return}ie.current=T,We.current=lt,V.current=Ne,B.current=de,$.current=Xe,Oe.current=St,Ke.current=bt,a.current=yt,ne.current=!1,Me.current=!1;async function At(){const D=c.current;if(!D||ne.current)return!1;const X=n.current;if(!X)return!1;const xe=!Me.current;xe&&T.pushErrorScope("validation");try{const me=T.importExternalTexture({source:X}),fe=T.createBindGroup({layout:D.layout,entries:[{binding:0,resource:me},{binding:1,resource:bt}]}),G=T.createCommandEncoder(),be=G.beginRenderPass({colorAttachments:[{view:D.inputView,loadOp:"load",storeOp:"store"}]});be.setPipeline(D.pipeline),be.setBindGroup(0,fe),be.draw(6),be.end(),T.queue.submit([G.finish()])}catch{return ne.current=!0,c.current=null,!1}if(xe){const me=await T.popErrorScope().catch(()=>null);if(me)return console.warn("[anime4k] blit probe failed:",me.message),ne.current=!0,c.current=null,!1;Me.current=!0}return!0}Q(!1);async function Mt(){if(Z||N.current!==U)return;const D=n.current;if(!D||D.videoWidth===0){M();return}if(D!==z||D.videoWidth!==se||D.videoHeight!==ue){Ce(fe=>fe+1);return}if(D.paused||D.ended||document.hidden||D.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){M();return}const X=D.getVideoPlaybackQuality().totalVideoFrames;if(X===o.current){M();return}if(w.current){M();return}const xe=D.currentTime;(D.seeking||y.current>=0&&Math.abs(xe-y.current)>.5)&&(Se(),h.current=!1,b.current=0,o.current=-1),y.current=xe;const me=Math.max(0,Ie.current||0);me>b.current&&(h.current=!1),w.current=!0;try{const fe=performance.now();let G=null,be=!1;if(me<=0){De.current.length>0&&Se(),h.current=!1,b.current=0;let Fe=!1;if(!He.current)try{T.queue.copyExternalImageToTexture({source:D},{texture:de},[se,ue]),o.current=X,Fe=!0}catch(J){if(J instanceof TypeError)He.current=!0;else throw J}if(!Fe&&!ne.current&&c.current&&await At()&&(o.current=X,Fe=!0),!Fe){const J=await createImageBitmap(D);o.current=X,T.queue.copyExternalImageToTexture({source:J},{texture:de},[se,ue]),le(J)}}else{const Fe=await createImageBitmap(D);o.current=X;const J=De.current;J.push({bitmap:Fe,capture:fe});const Rt=tt(me);for(;J.length>Rt;)le(J.shift()?.bitmap);let _t=-1;for(let Ee=J.length-1;Ee>=0;Ee--)if(fe-J[Ee].capture>=me){_t=Ee;break}if(_t!==-1){for(let ce=0;ce<_t;ce++)le(J.shift()?.bitmap);const Ee=J.shift();Ee?(G=Ee.bitmap,h.current=!0,b.current=me):(G=Fe,be=!0)}else if(!h.current)G=Fe,be=!0;else{const Ee=J.shift();G=Ee?Ee.bitmap:Fe,Ee||(be=!0)}if(!G){w.current=!1,M();return}T.queue.copyExternalImageToTexture({source:G},{texture:de},[se,ue]),be||le(G)}const Et=T.createCommandEncoder();await Ne.pass(Et);const A=Et.beginRenderPass({colorAttachments:[{view:lt.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});A.setPipeline(St),A.setBindGroup(0,ut),A.draw(6),A.end(),T.queue.submit([Et.finish()]),ge.current=X,Ve.current=0,T.queue.onSubmittedWorkDone().then(()=>{N.current===U&&(w.current=!1)})}catch(fe){if(w.current=!1,Ve.current+=1,Ve.current>=Rs&&!Z&&N.current===U){console.error(fe),e(fe instanceof Error?fe.message:"Render error"),I(!1);return}}M()}M()}catch(M){!Z&&N.current===U&&(e(M instanceof Error?M.message:"Failed to initialize upscaler"),Q(!1),I(!1))}}return ht(),()=>{Z=!0,N.current+=1,je(),Se(),B.current&&(B.current.destroy(),B.current=null),$.current&&($.current.destroy(),$.current=null),ie.current&&(ie.current.destroy(),ie.current=null),V.current=null,Oe.current=null,Ke.current=null,a.current=null,c.current=null,We.current=null,w.current=!1}},[E,g,n,v,C,m]);const F=O(Z=>{I(Z);try{localStorage.setItem("anime4kEnabled",String(Z))}catch{}},[]),ye=O(()=>{I(Z=>{const U=!Z;try{localStorage.setItem("anime4kEnabled",String(U))}catch{}return U})},[]);return{isWebGPUSupported:g,isEnabled:E,isInitializing:L,error:ke,toggle:ye,setEnabled:F}}const xs=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",As=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},Bs=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:xs(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:nn(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:As(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Ls(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};default:return n}}async function mr(n,v,C,Y,g=!1){if(!n||!v)throw new Error("Missing params");try{const[R,E,I,L]=await Promise.all([Te.data.video.query({showId:n,episodeNumber:v,mode:C.currentMode,provider:C.selectedProvider}).catch(()=>null),Te.progress.getEpisode.query({showId:n,episodeNumber:v}).catch(()=>null),Te.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Te.data.skipTimes.query({showId:n,episodeNumber:v}).catch(()=>[])]),Q=I?.value,ke=R?.filter(B=>{const $=B.sourceName.toLowerCase();return C.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ke.length>0?ke:R??[];let m=e.length>0?e[0]:null;if(Q){const B=e.find($=>$.sourceName===Q);B&&(m=B)}const Ce=m&&m.links.length>0?m.links.sort((B,$)=>(parseInt($.resolutionStr)||0)-(parseInt(B.resolutionStr)||0))[0]:null,N=E?.currentTime||0,ie=E?.duration||0,V=(Array.isArray(L)?L:L?.results||[]).map(B=>({skip_id:B.skip_id||"",skip_type:B.skip_type||"",start_time:B.interval?.start_time??B.start_time??0,end_time:B.interval?.end_time??B.end_time??0})).filter(B=>B.end_time>0);return(!R||R.length===0)&&(g||Ge.error(`No video sources found for ${C.selectedProvider}`)),{videoSources:R,selectedSource:m,selectedLink:Ce,resumeTime:N,resumeDuration:ie,showResumeModal:N>5&&m?.type!=="iframe",skipIntervals:V,fetchedEpisodeNumber:v}}catch(R){const E=R;if(E.message==="AUTH_REQUIRED")return Y({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:E.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:v};throw R}}const Is=(n,v,C,Y)=>{const[g,R]=Dr(Ls,C,c=>({...Bs(),showMeta:c?.name?{name:c.name,thumbnail:c.thumbnail,nativeName:c.nativeName,englishName:c.englishName,names:{romaji:c.name||c.englishName,english:c.englishName||c.name,native:c.nativeName}}:{}})),E=hr(),I=Vr(),L=f(null),Q=f(null),{options:ke}=vr(),e=ot(()=>ke.filter(c=>(c.kind??"anime")==="anime"),[ke]),m=v||g.initialEpisode,Ce=f(m);x(()=>{Ce.current!==m&&(Ce.current=m,R({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[m,R]),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)&&g.selectedProvider!=="animepahe"&&L.current!==n&&(L.current=n,R({type:"SET_PROVIDER",payload:"animepahe"}))},[n,g.selectedProvider]);const{data:N,isLoading:ie,error:We}=Tn(n),{data:V}=cr({queryKey:["player-data",n,g.currentMode,g.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const F=await Te.data.episodes.query({showId:n,mode:g.currentMode,provider:g.selectedProvider}).catch(()=>null);if(F?.episodes?.length)return F}catch{}return null},[y,o,h]=await Promise.all([c(),Te.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Te.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),b=y?.episodes?y.episodes.sort((F,ye)=>parseFloat(F)-parseFloat(ye)):[];return{description:y?.description||"",episodes:b,inWatchlist:o.inWatchlist,watchlistStatus:o.status??null,watchedEpisodes:h}},enabled:!!n});x(()=>{!v&&V?.episodes&&V.episodes.length>0&&!v&&R({type:"SET_STATE",payload:{initialEpisode:V.episodes[0]}})},[V,v]),x(()=>{if(N?.isAdult===void 0)return;const y=new Set(e.filter(o=>o.mature).map(o=>o.value)).has(g.selectedProvider);if(Q.current!==n){if(N.isAdult&&!y){const o=e.find(h=>h.mature);if(!o)return;Q.current=n,R({type:"SET_PROVIDER",payload:o.value}),localStorage.setItem("preferredProvider",o.value)}if(!N.isAdult&&y){const o=e.find(h=>!h.mature);if(!o)return;Q.current=n,R({type:"SET_PROVIDER",payload:o.value}),localStorage.setItem("preferredProvider",o.value)}}},[N?.isAdult,g.selectedProvider,n,e]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||Q.current===`temp:${n}`)return;const c=N?.provider;c&&(Q.current=`temp:${n}`,c!==g.selectedProvider&&R({type:"SET_PROVIDER",payload:c}))},[n,N,g.selectedProvider]);const{data:B,isLoading:$,error:Oe}=cr({queryKey:["video-sources",n,m,g.selectedProvider,g.currentMode],queryFn:()=>mr(n,m,g,R),enabled:!!n&&!!m&&!(g.showMeta?.isAdult===!0&&!Y?.hasMatureConsent)}),{mutateAsync:Ke}=jt({mutationFn:async({wasIn:c,showMeta:y})=>{if(!n)throw new Error("Missing showId");if(c)await Te.watchlist.remove.mutate({id:n});else{const o=y.name||y.names?.romaji;if(!o)throw new Error("Missing show name");await Te.watchlist.add.mutate({id:n,name:o,thumbnail:y.thumbnail,nativeName:y.names?.native,englishName:y.names?.english,type:y.type,isAdult:y.isAdult})}return!c},onSuccess:c=>{Ge.success(c?"Added to watchlist":"Removed from watchlist"),E.invalidateQueries({queryKey:["player-data",n]}),E.invalidateQueries({queryKey:["show-data",n]}),E.invalidateQueries({queryKey:["watchlist"]})},onError:c=>Ge.error(c instanceof Error?c.message:"Failed to update watchlist")}),a=O(async()=>{!n||!N||await Ke({wasIn:!!V?.inWatchlist,showMeta:N})},[n,N,V?.inWatchlist,Ke]),u=O(async c=>{try{await Te.settings.set.mutate({key:"preferredSource",value:c})}catch(y){console.error(y)}},[]),{mutateAsync:w,isPending:ge}=jt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Te.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{R({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),Ge.success(`Moved to ${c}`),E.invalidateQueries({queryKey:["show-data",n]}),E.invalidateQueries({queryKey:["watchlist"]}),E.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Ge.error("Failed to update watchlist status")}),Ve=O(async()=>{await w({status:"Completed"})},[w]),{mutateAsync:Ie}=jt({mutationFn:async({episodeNumber:c,duration:y,showMeta:o,episodes:h})=>{await Te.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:y,duration:y,showName:o.name,showThumbnail:o.thumbnail,nativeName:o.names?.native,englishName:o.names?.english,genres:o.genres?.map(b=>b.name),popularityScore:Ur(o.score??o.stats?.averageScore),type:o.type,status:o.status,episodeCount:h.length,isAdult:o.isAdult})},onSuccess:(c,y)=>{Ge.success(`Episode ${y.episodeNumber} marked as watched`),E.invalidateQueries({queryKey:["player-data",n]}),E.invalidateQueries({queryKey:["show-meta",n]}),E.invalidateQueries({queryKey:["video-sources",n,y.episodeNumber]}),E.invalidateQueries({queryKey:["allContinueWatching"]}),E.invalidateQueries({queryKey:["thisWeekSchedule"]}),E.invalidateQueries(I.continueWatching.pathFilter())},onError:()=>Ge.error("Failed to mark episode as watched")}),De=O(async(c,y)=>{!n||!N||await Ie({episodeNumber:c,duration:y,showMeta:N,episodes:V?.episodes||[]})},[n,N,V?.episodes,Ie]),He=O(async()=>{R({type:"SET_STATE",payload:{showCombinedDetails:!g.showCombinedDetails}})},[g.showCombinedDetails]),ne=ot(()=>{const c=We||Oe,y=c?c.message:null,o=y==="AUTH_REQUIRED"?null:y,h=B&&B.fetchedEpisodeNumber===m?B:null,b=!!B&&!h;return{...g,currentEpisode:m,showMeta:{...g.showMeta||{},...N||{}},episodes:V?.episodes||[],watchedEpisodes:V?.watchedEpisodes||[],inWatchlist:!!V?.inWatchlist,watchlistStatus:V?.watchlistStatus??g.watchlistStatus??null,videoSources:h?.videoSources||[],selectedSource:g.selectedSource||h?.selectedSource||null,selectedLink:g.selectedLink||h?.selectedLink||null,resumeTime:h?.resumeTime||0,resumeDuration:h?.resumeDuration||0,showResumeModal:g.showResumeModal&&(h?.showResumeModal??!1),skipIntervals:h?.skipIntervals||[],loadingShowData:ie,loadingVideo:$||b,error:o,fetchedEpisodeNumber:h?.fetchedEpisodeNumber}},[g,N,V,B,ie,$,We,Oe,m]),Me=O((c,y)=>{const o=y||n;if(!o||!c||o===n&&c===m)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(o)&&g.selectedProvider!=="animepahe"?"animepahe":g.selectedProvider,F=["video-sources",o,c,b,g.currentMode];E.getQueryState(F)?.status!=="success"&&E.prefetchQuery({queryKey:F,queryFn:()=>mr(o,c,{selectedProvider:b,currentMode:g.currentMode},R,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,m,E,g,R]);return{state:ne,dispatch:R,toggleWatchlist:a,moveToCompleted:Ve,setPreferredSource:u,handleToggleDetails:He,markEpisodeWatched:De,prefetchEpisodeSources:Me,isMarkingWatched:Ie.isPending,isUpdatingWatchlistStatus:ge}},Xt="fallbackChoice";function Ds(){try{const n=localStorage.getItem(Xt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function $s(n){try{n===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,n)}catch{}}const to=()=>{const{id:n,episodeNumber:v}=$r(),C=Fr(),Y=hr(),g=Wr(),{hasConsent:R,grant:E}=qr(),{options:I}=vr(),L=ot(()=>I.filter(t=>(t.kind??"anime")==="anime"),[I]),Q=ot(()=>L.map(t=>t.value),[L]),ke=ot(()=>new Set(L.filter(t=>t.mature).map(t=>t.value)),[L]),{state:e,dispatch:m,toggleWatchlist:Ce,moveToCompleted:N,setPreferredSource:ie,handleToggleDetails:We,markEpisodeWatched:V,prefetchEpisodeSources:B,isMarkingWatched:$,isUpdatingWatchlistStatus:Oe}=Is(n,v,g.state||null,{hasMatureConsent:R});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}`;C(t,{replace:!0})}},[n,e.showMeta?.id,v,C]);const Ke=ot(()=>{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=sn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:Ke}),{refs:u,actions:w}=a,ge=f(null),Ve=En(),Ie=f(null),De=f(null),He=f(null),ne=f(0),Me=f(e.resumeTime),c=f(e.showResumeModal),[y,o]=H(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[h,b]=H(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[F,ye]=H(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[Z,U]=H(!1),[le,Se]=H(!1),tt=f(null),je=f(null),ht=(t,s)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(s))}catch{}},z=t=>{const s=Math.max(0,Math.min(500,Math.round(t)));b(s);try{localStorage.setItem("playerVideoDelayMs",String(s))}catch{}},rt=()=>{tt.current={enabled:F,ms:h},ye(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}w.setShowSettings(!1),U(!0)},at=()=>{const t=tt.current;tt.current=null,t&&(b(t.ms),ye(t.enabled),ht(t.ms,t.enabled)),Se(!1),U(!1)},se=()=>{tt.current=null,ye(!0),ht(h,!0),Se(!1),U(!1)},ue=()=>{if(le){Se(!1);return}const t=u.videoRef.current;t&&!isNaN(t.currentTime)&&(je.current=t.currentTime),Se(!0)},Re=F?h:0,vt=f(null),W=Ps({videoRef:u.videoRef,canvasRef:De,profile:y,delayMs:Re}),Ue=W.isEnabled&&W.isWebGPUSupported,it=`${n??""}:${e.currentEpisode??""}`,nt=f(null),p=f(!1),P=f(!1),M=f(W.setEnabled);M.current=W.setEnabled,x(()=>{const t=nt.current;nt.current=it,!(t===null||t===it)&&(!W.isEnabled||!W.isWebGPUSupported||(p.current=!0,P.current=!1,M.current(!1)))},[it,W.isEnabled,W.isWebGPUSupported]),x(()=>{if(!p.current)return;if(W.isEnabled){P.current&&(p.current=!1);return}if(P.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){p.current=!1,M.current(!0);return}const t=u.videoRef.current;if(!t)return;let s,i=!1;const l=()=>{i||(i=!0,p.current=!1,M.current(!0))};if(t.readyState>=2)return s=window.setTimeout(l,500),()=>window.clearTimeout(s);const _=()=>{window.setTimeout(l,500)};return t.addEventListener("canplay",_,{once:!0}),t.addEventListener("playing",_,{once:!0}),s=window.setTimeout(l,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",_),t.removeEventListener("playing",_)}},[W.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,u.videoRef]),on({videoRef:u.videoRef,canvasRef:vt,delayMs:Re,enabled:F&&!Ue});const qe=F&&!Ue,$e=Ue||qe;x(()=>{Me.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[Vt,Ct]=H(!1),[Ye,T]=H(!1),[lt,gt]=H(!1),de=f(!1),[ct,Qe]=H(null),_e=f(!1),Ne=f([]),Xe=f(!1),[bt,Pe]=H(null),[yt,St]=H(!1),[ut,At]=H(!1),[Mt,D]=H(()=>Ds()??"ask"),X=O(t=>{D(t),$s(t==="ask"?null:t)},[]),xe=f(Mt);xe.current=Mt;const me=f(e.videoSources);me.current=e.videoSources;const fe=f(()=>{}),[G,be]=H(null),Et=f(v);x(()=>{Et.current!==v&&(Et.current=v,be(null),Qe(null),de.current=!1,Se(!1),U(!1))},[v]),x(()=>{_e.current=!1,Ne.current=[],Xe.current=!1,Pe(null),St(!1)},[n,e.currentEpisode]),x(()=>{Ye||(de.current=!1)},[Ye]);const{data:A=[],isLoading:Fe}=Qr(),J=zr(),Rt=f(J);Rt.current=J;const _t=Gr(),Ee=Kr(),[ce,Ut]=H(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});x(()=>{try{ce?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)}}},[ce]),Or(()=>{if(a.state.isFullscreen||ce)return;const t=u.playerContainerRef.current,s=Ie.current;if(!t||!s)return;const i=()=>{const _=t.getBoundingClientRect().height;s.style.height=`${_}px`};i();const l=new ResizeObserver(i);return l.observe(t),()=>l.disconnect()},[a.state.isFullscreen,ce,u.playerContainerRef]);const dt=ot(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),qt=dt>0?e.episodes[dt-1]:null,Ae=dt>=0&&dt<e.episodes.length-1?e.episodes[dt+1]:null,Qt=dt>-1&&dt<e.episodes.length-1,zt=an(e.resumeTime,e.resumeDuration)||Ye,st=zt&&ur(e.episodes,e.currentEpisode,e.showMeta.status),Jt=e.showResumeModal&&(st||!zt),Bt=zt&&!st&&A.length===0&&!G&&(e.showResumeModal||Ye),pt=Jt||Bt;ln(a,!!e.selectedLink&&!ce&&!pt),x(()=>{const t=u.videoRef.current;if(!t)return;let s=!1;for(ge.current&&(ge.current.destroy(),ge.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(le)return t.src="/av-sync-test.mp4",t.play().catch(()=>{w.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ne.current=0;return}je.current!=null?(ne.current=je.current,je.current=null):Me.current>5&&!c.current?ne.current=Me.current:c.current&&(ne.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 pe=localStorage.getItem("playerSubtitlesEnabled")!=="false";let we=null;try{we=localStorage.getItem("playerLastSubtitle")}catch{}const ee=Yt(e.selectedSource.subtitles,{lastKey:we,enabled:pe}),Be=ee>=0?e.selectedSource.subtitles[ee]:null;e.selectedSource.subtitles.forEach(ve=>{const te=document.createElement("track");te.kind="subtitles",te.label=ve.label,te.srclang=ve.lang;const S=ve.src??ve.url;if(S){let re=`/api/subtitle-proxy?url=${encodeURIComponent(S)}`;const ae=e.selectedLink?.headers?.Referer,wt=S.includes("anilight.live")?"https://anilight.live/":"",Wt=ae||wt;Wt&&(re+=`&referer=${encodeURIComponent(Wt)}`),te.src=re}Be&&ve.label===Be.label&&ve.lang===Be.lang&&(te.default=!0),t.appendChild(te)}),pe||w.setActiveSubtitleTrack("off"),w.setAvailableSubtitles(e.selectedSource.subtitles)}const l=ne.current;ne.current=0;const _=()=>{l>0&&(t.currentTime=l)};t.addEventListener("loadedmetadata",_,{once:!0});const he=!(c.current&&Me.current>5),K=()=>{he&&t.play().catch(()=>{w.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const pe=await Sn();if(s)return;if(!pe||!pe.isSupported()){t.src=i,K();return}const we=document.body.classList.contains("low-end"),ee=new pe({maxBufferLength:we?15:30,maxMaxBufferLength:we?30:60,maxBufferSize:we?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ge.current=ee,ee.on(pe.Events.ERROR,(te,S)=>{S.fatal&&!_e.current&&fe.current()});const Be=(e.selectedSource?.subtitles?.length??0)>0,ve=()=>{try{Be&&typeof ee.subtitleTrack=="number"&&ee.subtitleTrack!==-1&&(ee.subtitleTrack=-1)}catch{}};ee.on(pe.Events.SUBTITLE_TRACK_SWITCH,(te,S)=>{S?.id!==-1&&ve()}),ve(),ee.loadSource(i),ee.attachMedia(t),ee.once(pe.Events.MANIFEST_PARSED,()=>{s||K()})})():(t.src=i,K());const q=localStorage.getItem("playerVolume"),oe=localStorage.getItem("playerMuted");return q!==null&&(t.volume=parseFloat(q)),oe!==null&&(t.muted=oe==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",_),ge.current&&(ge.current.destroy(),ge.current=null)}},[e.selectedSource,e.selectedLink,u.videoRef,w,e.loadingVideo,le]);const Lt=O(t=>{if(_e.current)return;_e.current=!0;const s=t.links[0];ie(t.sourceName),m({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),Pe(null)},[m,ie]),It=O(()=>{const s=me.current.find(i=>i.type==="iframe");return s?.links?.length?s:null},[]),Dt=O(async()=>{const t=e.showMeta?.isAdult,s=Q.filter(i=>{if(Ne.current.includes(i))return!1;const l=ke.has(i);return t===void 0?!0:l===t});St(!0);try{for(const i of s){Ne.current.push(i);let l=null;try{l=await Te.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:i})}catch{continue}const _=(l??[]).filter(q=>{const oe=q.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((_.length>0?_:l??[]).find(q=>q.type!=="iframe"&&q.links?.length)){Ne.current=[e.selectedProvider],Xe.current=!1,m({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),Pe(null),Ge.success(`Switched to ${i} (direct stream)`);return}}Pe({retryFailed:!0}),Ge.error("No working direct stream found on other providers")}finally{St(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,m,Q,ke]),Zt=O(()=>{if(_e.current||Xe.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;Ne.current.includes(e.selectedProvider)||Ne.current.push(e.selectedProvider);const s=xe.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}w.setShowControls(!0),Pe({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,w]);fe.current=Zt;const gr=O(()=>{Xe.current=!0,Pe(null),At(!1)},[]),br=O(()=>{ut&&X("iframe");const t=It();t?Lt(t):Pe(null)},[ut,X,It,Lt]),yr=O(()=>{ut&&X("retry"),Dt()},[ut,X,Dt]),Nt=(t,s,i)=>t.showId===s||!!i&&t.showId===i,$t=O(()=>{w.onEnded();const t=A.find(i=>Nt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(A.length>0){const i=A.findIndex(_=>Nt(_,n,e.showMeta?.id)&&_.episodeNumber===e.currentEpisode),l=i>=0?A[i+1]||null:A[0];be({nextItem:l,playedItem:t||null}),Qe(2)}else t&&Rt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&A.length===0){const i=e.episodes.findIndex(l=>l===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const l=e.episodes[i+1];Y.invalidateQueries({queryKey:["allContinueWatching"]}),C(`/watch/${n}/${l}`),s=!0}}!s&&A.length===0&&!G&&!de.current&&ur(e.episodes,e.currentEpisode,e.showMeta.status)&&m({type:"SET_STATE",payload:{showResumeModal:!0}})},[w,C,A,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,G,m,Y]),Gt=O(()=>{if(A.length===0)return;w.onEnded();const t=A.find(l=>Nt(l,n,e.showMeta?.id)&&l.episodeNumber===e.currentEpisode),s=A.findIndex(l=>Nt(l,n,e.showMeta?.id)&&l.episodeNumber===e.currentEpisode),i=s>=0?A[s+1]||null:A[0];t&&J.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?C(`/watch/${i.showId}/${i.episodeNumber}`):t&&m({type:"SET_STATE",payload:{showResumeModal:!0}})},[w,C,A,J,n,e.showMeta?.id,e.currentEpisode,m]),Pt=O(()=>{Ae&&(Y.invalidateQueries({queryKey:["allContinueWatching"]}),T(!1),C(`/watch/${n}/${Ae}`)),m({type:"SET_STATE",payload:{showResumeModal:!1}})},[Ae,C,n,m,Y]),er=O(()=>{A.length>0?Gt():Ae?Pt():Ge.error("No next episode available")},[A.length,Gt,Pt,Ae]),Sr=()=>{qt&&C(`/watch/${n}/${qt}`)};x(()=>{const t=u.videoRef.current;if(!t)return;const s=()=>{le||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,u.videoRef,le]),x(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&$t()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[$t,e.selectedSource?.type]),x(()=>{if(!G||ct===null)return;if(ct<=0){const{nextItem:s,playedItem:i}=G;be(null),Qe(null),i&&Rt.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),s?C(`/watch/${s.showId}/${s.episodeNumber}`):i&&m({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{Qe(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[G,ct,C,m]),x(()=>{pt&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[pt,a.state.isFullscreen,a.actions]),x(()=>{pt&&u.videoRef.current&&u.videoRef.current.pause()},[pt,u.videoRef]);const{titlePreference:Ft}=Hr(),{lowEndMode:Er}=jr(),mt=ot(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Ft==="name"?t||"Loading...":Ft==="nativeName"?s?.native||t||"Loading...":Ft==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Ft,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())&&(w.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{w.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&er(),s.key.toLowerCase()==="t")){const l=!ce;Ut(l),localStorage.setItem("playerTheaterMode",l.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[w,a.actions.inactivityTimer,er,ce]);const{setAvailableSubtitles:tr,setActiveSubtitleTrack:Kt}=w;x(()=>{const t=u.videoRef.current;if(!t)return;const s=()=>{const i=Array.from(t.textTracks).map(l=>({label:l.label,lang:l.language,src:void 0,mode:l.mode}));tr(i)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[u.videoRef,tr]),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=Yt(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Kt("off");return}const i=a.state.availableSubtitles[s];Kt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,Kt]),x(()=>{const t=u.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(_=>{_.mode="hidden"});return}let l=!1;if(Array.from(t.textTracks).forEach(_=>{const K=(_.language===s||_.label===s)&&!l;_.mode=K?"showing":"hidden",K&&(l=!0)}),!l&&t.textTracks.length>0){const _=Array.from(t.textTracks).find(he=>he.language==="en"||he.label==="English")||t.textTracks[0];_&&(_.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,u.videoRef]);const[rr,wr]=H(0);x(()=>{const t=u.videoRef.current;if(!t)return;const s=()=>wr(t.clientHeight||0);s();const i=new ResizeObserver(s);return i.observe(t),()=>i.disconnect()},[u.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=dr(i);const l=u.videoRef.current;if(!l)return;const _=pr(a.state.subtitleFontSize,rr||l.clientHeight||720);s.textContent=dr({...i,fontSize:_});const he=()=>{const S=Number(a.state.subtitlePosition),re=isNaN(S)?0:Math.max(0,Math.min(100,S));return Math.max(0,Math.min(100,100-re))},K=(S,re)=>{try{const ae=S;ae.snapToLines=!1,ae.line=re}catch{}},q=()=>{const S=_*16,re=l.videoHeight||l.clientHeight||720,ae=l.videoWidth||l.clientWidth||1280;return{step:S*1.3/re*100,chars:Math.max(20,Math.floor(ae/(S*.55)))}},oe=S=>{const re=he(),ae=Array.from(S.activeCues??[]);if(ae.length<=1){ae.forEach(Tt=>K(Tt,re));return}const{step:wt,chars:Wt}=q();let ir=re;for(let Tt=ae.length-1;Tt>=0;Tt--){const xr=String(ae[Tt].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
-
`).reduce((Ar,Br)=>Ar+Math.max(1,Math.ceil(Br.length/Wt)),0),lr=ir-xr*wt;K(ae[Tt],Math.max(0,lr)),ir=lr-wt*.4}},pe=S=>{if(!S.cues)return;const re=he();Array.from(S.cues).forEach(ae=>K(ae,re)),S.mode==="showing"&&oe(S)},we=()=>{Array.from(l.textTracks).forEach(pe)};we();const ee=S=>{const re=S.target;re.mode==="showing"&&oe(re)};Array.from(l.textTracks).forEach(S=>{S.addEventListener("cuechange",ee)});const Be=()=>{Array.from(l.textTracks).forEach(S=>{S.removeEventListener("cuechange",ee),S.addEventListener("cuechange",ee)}),we()};l.textTracks.addEventListener("addtrack",Be),l.textTracks.addEventListener("removetrack",Be);const ve=Array.from(l.querySelectorAll("track")),te=()=>{we()};return ve.forEach(S=>{S.addEventListener("load",te)}),()=>{Array.from(l.textTracks).forEach(S=>{S.removeEventListener("cuechange",ee)}),l.textTracks.removeEventListener("addtrack",Be),l.textTracks.removeEventListener("removetrack",Be),ve.forEach(S=>{S.removeEventListener("load",te)})}},[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,u.videoRef,rr]),x(()=>{if(!$e)return;const t=u.videoRef.current,s=He.current;if(!t||!s)return;const i=localStorage.getItem("playerSubtitlesEnabled")!=="false",l=a.state.activeSubtitleTrack;function _(){if(s.innerHTML="",!i||l==="off"||l===null)return;const q=Array.from(t.textTracks).find(te=>te.language===l||te.label===l);if(!q||q.mode!=="showing")return;const oe=Re/1e3;let pe;if(oe>0&&q.cues){const te=t.currentTime-oe;pe=Array.from(q.cues).filter(S=>S.startTime<=te&&te<=S.endTime)}else pe=Array.from(q.activeCues??[]);if(pe.length===0)return;const we={fontSize:pr(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},ee=cn(we),Be=un(t,we.position),ve=Array.from(pe);ve.forEach((te,S)=>{const re=String(te.text??"");if(!dn(re).trim())return;const ae=document.createElement("div"),wt=(ve.length-1-S)*1.7;ae.style.cssText=`${ee}
|
|
56
|
-
bottom: calc(${Be}px + ${wt}em);`,ae.innerHTML=pn(re),s.appendChild(ae)})}const he=()=>_(),K=()=>_();return Array.from(t.textTracks).forEach(q=>{q.addEventListener("cuechange",he)}),t.addEventListener("timeupdate",K),_(),()=>{Array.from(t.textTracks).forEach(q=>{q.removeEventListener("cuechange",he)}),t.removeEventListener("timeupdate",K),s.innerHTML=""}},[W.isEnabled,W.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,u.videoRef,$e,Re]),x(()=>{try{localStorage.setItem("anime4kProfile",y)}catch{}},[y]);const Tr=()=>{u.videoRef.current&&(u.videoRef.current.currentTime=e.resumeTime,u.videoRef.current.play()),m({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{u.videoRef.current&&(u.videoRef.current.currentTime=0,u.videoRef.current.play()),m({type:"SET_STATE",payload:{showResumeModal:!1}})},nr=O(()=>{st&&(de.current=!0),Bt&&T(!1),m({type:"SET_STATE",payload:{showResumeModal:!1}})},[m,st,Bt]),Cr=O(()=>{if(T(!1),u.videoRef.current)try{u.videoRef.current.currentTime=0,u.videoRef.current.play().catch(()=>{})}catch{}m({type:"SET_STATE",payload:{showResumeModal:!1}})},[m,u]),Mr=O(async()=>{try{await N(),m({type:"SET_STATE",payload:{showResumeModal:!1}}),C("/")}catch{}},[N,m,C]),sr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${d.episodeNavBtn} ${d.secondary}`,onClick:Sr,disabled:!qt,type:"button",children:[r(j,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${d.episodeNavBtn} ${d.primary}`,onClick:Pt,disabled:!Ae,type:"button",children:["Next EP",r(j,{name:"chevron-right",size:12})]}),s==="mobile"&&Ve&&r("button",{className:`${d.episodeNavBtn} ${d.episodePickerBtn}`,onClick:()=>gt(!0),type:"button",children:[r(j,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{Ye&&(e.showResumeModal||A.length>0||G||de.current||st&&m({type:"SET_STATE",payload:{showResumeModal:!0}}))},[Ye,st,e.showResumeModal,A.length,G,m]);const Rr=t=>{m({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),yn(t)},or=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),_r=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Ht=f(B);Ht.current=B;const ar=f("");x(()=>{const t=u.videoRef.current;if(Ct(!1),T(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const i=t.duration,l=t.currentTime;if(!i||Number.isNaN(i)){Ct(!1),T(!1);return}const _=l/i;if(i-l<=60){const he=A.findIndex(oe=>Nt(oe,n,e.showMeta?.id)&&oe.episodeNumber===e.currentEpisode),K=A.length>0?he>=0?A[he+1]||null:A[0]:null,q=K?`${K.showId}:${K.episodeNumber}`:Qt?`${n}:${Ae}`:"";q&&ar.current!==q&&(ar.current=q,K?Ht.current(K.episodeNumber,K.showId):Ht.current(Ae))}Ct(Qt&&_>=.8),T(l>=Math.max(i*.98,i-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[u.videoRef,Qt,e.currentEpisode,e.selectedSource,Ae,n,A,e.showMeta?.id]);const Nr=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=u.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await V(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,V,$,u.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 Je=e.loadingShowData||e.loadingVideo,Pr=t=>{ce&&t.target===t.currentTarget&&(Ut(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!R?r("div",{className:ze.playerPageLayout,children:r(Le,{isOpen:!0,title:"Content Warning",onClose:()=>C("/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:()=>C("/home"),children:"Go Back"}),r(Ze,{onClick:E,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${ze.playerPageLayout} ${ce?ze.theaterMode:""}`,onClick:Pr,children:[r(Le,{isOpen:Jt,onClose:nr,title:st?"Show Completed!":"Resume Playback?",width:"sm",children:st?r(kt,{children:[r(Le.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Le.Actions,{children:r(Ze,{onClick:Mr,disabled:Oe,children:Oe?"Saving...":"Move to Completed"})})]}):r(kt,{children:[r(Le.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Le.Actions,{children:[r(Ze,{variant:"secondary",onClick:kr,children:"Start Over"}),r(Ze,{onClick:Tr,children:"Resume"})]})]})}),r(Le,{isOpen:Bt,onClose:nr,title:"Episode Completed",width:"sm",children:[r(Le.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Ae?" Would you like to watch the next episode?":""]})}),r(Le.Actions,{children:[r(Ze,{variant:"secondary",onClick:Cr,children:"Replay"}),Ae&&r(Ze,{onClick:Pt,children:`Watch EP ${Ae}`})]})]}),r(Le,{isOpen:!!bt,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Le.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),bt?.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:ut,onChange:t=>At(t.target.checked)}),"Remember my choice"]})]}),r(Le.Actions,{children:[r(Ze,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(Ze,{onClick:yr,disabled:yt,children:yt?"Searching…":"Try another provider"})]})]}),r(Yr,{isOpen:!!e.showCookieModal,onClose:()=>m({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{Y.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ce&&r("aside",{ref:Ie,className:ze.episodeSidebar,children:e.loadingShowData?r(mn,{variant:"sidebar"}):r(fn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>C(`/watch/${n}/${t}`)})}),r("div",{className:ze.playerMain,children:[r("div",{className:`${d.videoContainer} ${a.state.isFullscreen?"":ze.videoPlayerWrapper} ${a.state.isFullscreen?d.fullscreenActive:""}`,style:{...pt?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(ms,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Rr,fallbackChoice:Mt,onFallbackChoiceChange:X,showNextEpisodeButton:!pt&&Vt&&A.length===0,onNextEpisode:Pt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{u.videoRef.current&&!isNaN(u.videoRef.current.currentTime)&&(ne.current=u.videoRef.current.currentTime),ie(t.sourceName),m({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Je,skipIntervals:e.skipIntervals,animeTitle:mt,episodeNumber:e.currentEpisode,isTheaterMode:ce,onTheaterModeToggle:()=>{const t=!ce;Ut(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:W.isEnabled,onAnime4kToggle:W.toggle,anime4kSupported:W.isWebGPUSupported,anime4kProfile:y,onAnime4kProfileChange:o,anime4kInitializing:W.isInitializing,anime4kError:W.error,videoDelayEnabled:F,onVideoDelayToggle:t=>{ye(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:h,onVideoDelayChange:z,onCalibrateAvSync:rt,isInteractingExtra:lt||Z,className:hn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(kt,{children:[a.state.isSpeedBoostActive&&r("div",{className:d.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(j,{name:"forward",size:12})]}),ct!==null&&G?.nextItem&&r("div",{className:d.queueCountdown,children:["Queue next in ",ct,"s"]})]}),children:[Je&&r("div",{className:d.loadingOverlay,children:r("div",{className:d.loadingDots,children:[r("div",{className:d.dot}),r("div",{className:d.dot}),r("div",{className:d.dot})]})}),a.state.isBuffering&&!Je&&e.selectedSource?.type!=="iframe"&&r("div",{className:d.bufferingOverlay,children:r("div",{className:d.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Je&&r("iframe",{src:e.selectedLink?.link,className:d.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(kt,{children:[!Je&&e.videoSources.length===0&&r("div",{className:d.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:d.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:d.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Je&&e.videoSources.length>0&&r("video",{ref:u.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:w.onPlay,onPause:w.onPause,onLoadedMetadata:w.onLoadedMetadata,onTimeUpdate:()=>{le||(w.onTimeUpdate(),G&&u.videoRef.current&&u.videoRef.current.currentTime<u.videoRef.current.duration-1&&(be(null),Qe(null)))},onProgress:w.onProgress,onVolumeChange:w.onVolumeChange,onWaiting:w.onWaiting,onPlaying:w.onPlaying,onCanPlay:w.onCanPlay,onError:Zt,onContextMenu:t=>t.preventDefault(),className:$e?d.videoElementHidden:""}),W.isWebGPUSupported&&!Je&&e.videoSources.length>0&&r("canvas",{ref:De,className:`${d.upscalerCanvas} ${Ue?d.upscalerActive:""}`}),!Ue&&!Je&&e.videoSources.length>0&&r("canvas",{ref:vt,className:`${d.upscalerCanvas} ${qe?d.upscalerActive:""}`}),W.isEnabled&&W.isWebGPUSupported&&W.isInitializing&&r("div",{className:d.upscalerStatusBadge,children:"Preparing upscaler…"}),$e&&r("div",{ref:He,className:d.subtitleOverlay}),r(vn,{isOpen:Z,ms:h,onChange:z,onApply:se,onClose:at,testClipActive:le,onTestClip:ue})]})]})}),!ce&&r(gn,{}),!ce&&r(kt,{children:[Fe&&A.length===0?r(fs,{count:3}):r(wn,{title:"Queue",items:A,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Gt,onRemove:t=>J.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>_t.mutate(),showClearAll:!0,onReorder:t=>Ee.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:d.providerAndEpisodeRow,children:[r(ws,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:L,onProviderChange:t=>{_e.current=!1,Ne.current=[],Xe.current=!1,Pe(null),m({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),sr(`${d.episodeActions} ${d.desktopEpisodeActions}`,"desktop")]}),Je?r("div",{className:d.sourceLoader,children:r("div",{className:d.spinner})}):r(kt,{children:r(ks,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{u.videoRef.current&&!isNaN(u.videoRef.current.currentTime)&&(ne.current=u.videoRef.current.currentTime);const i=(t.links||[]).sort((l,_)=>(parseInt(_.resolutionStr)||0)-(parseInt(l.resolutionStr)||0))[0]||null;ie(t.sourceName),m({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(ie(e.selectedSource.sourceName),m({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:ze.playerInfoContainer,children:[r("div",{className:ze.playerInfoHeader,children:[r("div",{className:ze.playerAnimeCard,children:r("img",{src:Xr(e.showMeta.thumbnail||""),alt:mt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:ze.videoTitleSection,children:[r("div",{className:d.titleContainer,children:[r("h1",{children:mt}),r("div",{className:d.scheduleInfo,children:[e.showMeta.status&&r("span",{className:d.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:d.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:d.controls,children:[r("button",{className:`${d.watchlistBtn} ${e.inWatchlist?d.inList:""}`,onClick:Ce,children:[e.inWatchlist?r(j,{name:"check",size:14}):r(j,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(kn,{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:`${d.watchlistBtn} ${d.queueBtn}`,activeClassName:d.queueActive}),_r&&r("button",{className:`${d.watchlistBtn} ${d.markWatchedBtn} ${or?d.markWatchedDone:""}`,onClick:Nr,disabled:$||!e.currentEpisode,children:[r(j,{name:"check",size:14}),$?"Saving...":or?"Watched":"Mark Watched"]}),r("button",{className:`${d.watchlistBtn} ${d.modeToggleBtn} ${e.currentMode==="dub"?d.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";_e.current=!1,Ne.current=[],Xe.current=!1,Pe(null),m({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),Er&&r("button",{className:`${d.watchlistBtn} ${d.modeToggleBtn} ${a.state.useNativeControls?d.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"})]})]})]}),sr(`${d.episodeActions} ${d.mobileEpisodeActions}`,"mobile"),r("div",{className:d.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(Mn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:d.detailsToggleBtn,onClick:We,children:[e.showCombinedDetails?r(j,{name:"chevron-up"}):r(j,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(Cn,{showMeta:e.showMeta,styles:d})]})]})]}),r(bn,{isOpen:lt,onClose:()=>gt(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{gt(!1),C(`/watch/${n}/${t}`)}})]})};export{to as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as I,d as X,T as Y,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as Z,O as _,a as ee,A as ne}from"./OptionListMenu-DngTgHxH.js";import{u as te}from"./index-gMxawd-E.js";import"./AvSyncCalibrator-BuHurVgo.js";import"./vendor-query-BBT5_sHx.js";const ae="_settingsPanel_y6z3b_1",se="_header_y6z3b_33",le="_backBtn_y6z3b_56",ie="_contentWrapper_y6z3b_76",re="_menuContent_y6z3b_82",ce="_menuItem_y6z3b_89",oe="_selected_y6z3b_114",de="_currentValue_y6z3b_134",me="_menuNote_y6z3b_141",ue="_menuError_y6z3b_150",n={settingsPanel:ae,header:se,backBtn:le,contentWrapper:ie,menuContent:re,menuItem:ce,selected:oe,currentValue:de,menuNote:me,menuError:ue},he=(A,z)=>{const{isOpen:b,onClose:pe,videoSources:be,currentSource:v,currentLink:k,onSourceChange:w,subtitles:$,activeSubtitleTrack:y,onSubtitleChange:P,subtitleSettings:V,onSubtitleSettingsChange:O,useNativeControls:g,onNativeControlsToggle:E,anime4kEnabled:u,onAnime4kToggle:U,anime4kSupported:C,anime4kProfile:i,onAnime4kProfileChange:h,anime4kInitializing:B,anime4kError:f,videoDelayEnabled:N,onVideoDelayToggle:T,videoDelayMs:S,onVideoDelayChange:D,onCalibrateAvSync:M,isAutoSkipEnabled:d,onAutoSkipChange:x,isAutoplayEnabled:m,onAutoplayChange:L,fallbackChoice:p,onFallbackChoiceChange:W}=A,{lowEndMode:G}=te(),[a,r]=X("main");I.useEffect(()=>{if(!b){const t=setTimeout(()=>r("main"),300);return()=>clearTimeout(t)}},[b]);const j=()=>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"})}),G&&e("button",{className:`${n.menuItem} ${g?n.selected:""}`,onClick:()=>{const t=!g;E(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:()=>{U(!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"})]})]}),q=()=>{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)}})})},F=()=>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)})}),Q=()=>e("div",{className:n.menuContent,children:e(ee,{classes:{item:n.menuItem,active:n.selected},values:V,onChange:O})}),R=Y(()=>{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}},[]),H=()=>e("div",{className:n.menuContent,children:[B&&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]}),!R&&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})]})]}),K=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>x(!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:()=>L(!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."})]}),J=()=>e("div",{className:n.menuContent,children:e(ne,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:N,delayMs:S,onToggle:T,onDelayChange:D,onCalibrate:M})});return b?e(Z,{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"&&j(),a==="quality"&&q(),a==="subtitles"&&F(),a==="subtitle-style"&&Q(),a==="upscaler"&&H(),a==="av-sync"&&J(),a==="playback"&&K()]}):null},Ne=I.forwardRef(he);export{Ne as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as h,A as O,h as y,g as ne,u as e,S as L,$ as _,T as J}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{b as Y}from"./vendor-query-BBT5_sHx.js";import{h as Z,t as K,W as se}from"./index-gMxawd-E.js";import{a}from"./Asmr.module-ChUXDZKx.js";import{r as i}from"./Radio.module-DGSZLpKM.js";const x=300*1e3,re="https://cdn.listen.moe/covers/";function W(n){return n?n.startsWith("http")?n:`${re}${n}`:null}function le(n){return n?W(n.albums[0]?.image)||W(n.artists[0]?.image)||W(n.sources[0]?.image):null}function F(n){return n?n.artists.map(s=>s.nameRomaji||s.name).join(", "):""}const oe=()=>{const n=Z();return Y({...n.radio.stations.queryOptions(),staleTime:x})},ie=n=>{const s=Z();return Y({...s.radio.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:x})},G={song:null,lastPlayed:[],listeners:0,startTime:null},ce=n=>{const[s,p]=h(G),[l,c]=h(!1),d=O(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 N=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}))},N)}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:s,connected:l}};function X(n){if(!n)return"";const s=Math.max(0,Math.floor((Date.now()-new Date(n).getTime())/1e3)),p=Math.floor(s/60),l=s%60;return`${p}:${String(l).padStart(2,"0")}`}const de=({station:n,nowPlaying:s,connected:p,expanded:l,onStationStep:c,onExpandedChange:d,onClose:m})=>{const f=O(null),[v,u]=h(!1),[N,U]=h(!0),[S,I]=h(!1),[P,k]=h(!0),[M,T]=h(""),[b,A]=h(()=>{const t=parseFloat(localStorage.getItem("radioVolume")||"");return Number.isFinite(t)?t:1}),r=O(""),g=O(b);g.current=b,r.current||(r.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`radio-${Date.now()}-${Math.random().toString(36).slice(2)}`);const w=s.song,C=le(w)||n.favicon||null,[E,q]=h(!1);y(()=>{q(!1)},[C]);const B=E?null:C,V=!!B,R=w?`${F(w)} — ${w.title}`:n.name;y(()=>{const t=f.current;if(t)return u(!1),t.src=n.streamUrl,t.load(),t.volume=g.current,t.play().catch(()=>u(!1)),()=>{t.removeAttribute("src")}},[n.id,n.streamUrl]),y(()=>{const t=f.current;t&&(t.volume=b)},[b]),y(()=>{if(l)return document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")},[l]),y(()=>{l&&k(!0)},[l]);const ee=t=>t?Math.max(0,Math.floor((Date.now()-new Date(t).getTime())/1e3)):0,D=ne.useCallback(t=>{n&&(K.discord.radioPresence.mutate({title:R,stationLabel:n.name,isPlaying:t,thumbnail:B||"",currentTime:ee(s.startTime),sessionId:r.current}).catch(()=>{}),K.discord.heartbeat.mutate({sessionId:r.current}).catch(()=>{}))},[n,R,B,s.startTime]);y(()=>{D(v)},[D,v,n.id,R,l]),y(()=>{if(!v)return;const t=window.setInterval(()=>D(!0),15e3);return()=>window.clearInterval(t)},[v,D]),y(()=>{const t=r.current,$=()=>se(t),H=()=>$(),Q=()=>{document.visibilityState==="hidden"&&$()};return window.addEventListener("pagehide",H),window.addEventListener("beforeunload",H),document.addEventListener("visibilitychange",Q),()=>{window.removeEventListener("pagehide",H),window.removeEventListener("beforeunload",H),document.removeEventListener("visibilitychange",Q),$()}},[]),y(()=>{if(!s.startTime){T("");return}T(X(s.startTime));const t=window.setInterval(()=>T(X(s.startTime)),1e3);return()=>window.clearInterval(t)},[s.startTime,s.song?.id]),y(()=>{if(!l)return;const t=$=>{$.key==="Escape"&&(S?I(!1):d(!1))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[l,S,d]);const te=()=>{const t=f.current;t&&(t.paused?(t.load(),t.play().catch(()=>{})):t.pause())},ae=e(L,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>c(-1),"aria-label":"Previous station",children:e(o,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:te,"aria-label":v?"Pause":"Play",children:v?e(o,{name:"pause"}):e(o,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>c(1),"aria-label":"Next station",children:e(o,{name:"step-forward"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:i.liveBadge,children:[e(o,{name:"broadcast-tower",size:10})," LIVE"]}),M&&e("span",{className:a.timeLabel,children:M}),p&&s.listeners>0&&e("span",{className:a.timeLabel,children:[s.listeners," listening"]}),!p&&n.source==="listen.moe"&&e("span",{className:a.timeLabel,children:"connecting…"})]})]}),z=e(L,{children:[e("button",{className:`${a.playerBtn} ${a.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:a.playerInfo,children:[e("p",{className:a.playerTitle,title:R,children:R}),e("p",{className:a.playerTrack,children:n.name})]}),e("div",{className:a.playerControls,children:ae}),e("div",{className:a.playerRight,children:[b===0?e(o,{name:"volume-mute",className:a.volumeIcon}):b<.5?e(o,{name:"volume-down",className:a.volumeIcon}):e(o,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:b,onChange:t=>{const $=parseFloat(t.target.value);A($),localStorage.setItem("radioVolume",String($))},style:{"--volume-percent":`${b*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[l&&V&&e("button",{className:a.playerBtn,onClick:()=>U(t=>!t),"aria-label":N?"Hide art":"Show art",title:N?"Hide art":"Show art",children:N?e(o,{name:"eye-slash"}):e(o,{name:"image"})}),l&&s.lastPlayed.length>0&&e("button",{className:`${a.playerBtn} ${S?a.playerBtnActive:""}`,onClick:()=>I(t=>!t),"aria-label":S?"Hide history":"Show history",title:"Recently played",children:e(o,{name:"list-ol"})}),e("button",{className:a.playerBtn,onClick:m,"aria-label":"Close player",children:e(o,{name:"times"})})]})]}),j=e("audio",{ref:f,preload:"none",onPlay:()=>u(!0),onPause:()=>u(!1)});return l?_(e(L,{children:[j,e("div",{className:`${a.npOverlay} ${P?"":a.npOverlayControlsHidden}`,children:[e("div",{className:`${a.npStage} ${!N||!V?a.npStageBlank:""}`,onClick:()=>k(t=>!t),children:N&&V&&B&&e("div",{className:i.coverWrap,children:e("img",{src:B,alt:R,loading:"lazy",decoding:"async",draggable:!1,className:i.cover,onError:()=>q(!0)})})}),e("div",{className:`${a.playerBar} ${a.playerBarDocked} ${P?"":a.playerBarDockedHidden}`,onClick:t=>t.stopPropagation(),children:[z,S&&e(L,{children:[e("div",{className:a.npBackdrop,onClick:()=>I(!1)}),e("div",{className:a.chapterPanel,children:s.lastPlayed.map(t=>e("div",{className:a.chapterRow,children:e("span",{className:a.chapterRowLabel,title:`${F(t)} — ${t.title}`,children:[F(t)," — ",t.title]})},t.id))})]})]})]})]}),document.body):_(e(L,{children:[j,e("div",{className:a.playerBar,children:z})]}),document.body)},ve=()=>{y(()=>{document.title="Radio - dango"},[]);const[n,s]=h(""),[p,l]=h(""),[c,d]=h(null),[m,f]=h(!0),{data:v,isLoading:u}=oe(),{data:N,isLoading:U}=ie(p),S=J(()=>v?.stations||[],[v]),I=J(()=>N?.stations||[],[N]),P=p?I:S,{nowPlaying:k,connected:M}=ce(c?.gateway),T=r=>{d(r),f(!0)},b=r=>{const g=P.length>0?P:S;if(g.length===0||!c)return;const w=g.findIndex(E=>E.id===c.id),C=g[(w<0?0:w+r+g.length)%g.length];d(C)},A=r=>{const g=c?.id===r.id,w=g&&k.song?`${F(k.song)} — ${k.song.title}`:null,C=[r.codec,r.bitrate?`${r.bitrate}k`:"",r.tags].filter(Boolean).join(" · ");return e("button",{className:`${i.stationRow} ${g?i.stationRowActive:""}`,onClick:()=>T(r),children:[r.favicon?e("img",{src:r.favicon,alt:"",className:i.stationThumb,loading:"lazy",decoding:"async",onError:E=>{E.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:r.name}),C&&e("span",{className:i.stationSub,children:C})]}),w&&e("span",{className:i.stationNowPlaying,children:w})]},r.id)};return e("div",{className:`${a.page} ${c?a.pageWithPlayer:""}`,children:[e("div",{className:a.header,children:[e("h1",{className:a.pageTitle,children:[e(o,{name:"broadcast-tower"})," Radio"]}),e("form",{className:a.searchForm,onSubmit:r=>{r.preventDefault(),l(n)},children:[e("input",{className:a.searchInput,value:n,onChange:r=>s(r.target.value),placeholder:"Search stations (anime, j-pop, k-pop…)","aria-label":"Search radio stations"}),e("button",{className:a.searchBtn,type:"submit","aria-label":"Search",children:e(o,{name:"search"})})]})]}),p?e(L,{children:[e("h2",{className:i.sectionTitle,children:["Results for “",p,"”"]}),U?e("p",{className:a.statusMsg,children:"Searching…"}):I.length===0?e("p",{className:a.statusMsg,children:"No stations found."}):e("div",{className:i.stationList,children:I.map(A)})]}):e(L,{children:[e("h2",{className:i.sectionTitle,children:"Featured"}),u?e("p",{className:a.statusMsg,children:"Loading…"}):e("div",{className:i.stationList,children:S.map(A)})]}),c&&e(de,{station:c,nowPlaying:k,connected:M,expanded:m,onStationStep:b,onExpandedChange:f,onClose:()=>d(null)})]})};export{ve as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as U,d as v,h as b,T as w,u as i,S as E}from"./vendor-core-DfaOB3Rn.js";import{M as x}from"./MediaCard-BcLjlpfR.js";import{L as F}from"./LibraryListPage-CV8Z9JlO.js";import{u as _,M as z}from"./useMangaPopup-DEfGjWSu.js";import{M as D}from"./MangaResetProgressModal-DyhQYBDy.js";import{x as G,d as O,o as Q,p as Y,u as q,y as H,z as K,A as V,M as h,m as Z,i as j,b as J,c as W}from"./useMangaLibrary-B60at6ni.js";import"./vendor-ui-3qrARCPr.js";import"./vendor-icons-DrybRNxP.js";import"./index-gMxawd-E.js";import"./vendor-query-BBT5_sHx.js";import"./useIsMobile-Dvx1uJ82.js";import"./SkeletonGrid-nx2HEi4P.js";import"./ErrorMessage-DAxegITP.js";import"./Watchlist.module-XGtVQr1d.js";import"./ResetProgressModal-C6ukct_c.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=G(r?"All":e,g,R),s=O(100),I=Q(),T=Y(),{toggle:L,bookmarkedIds:C}=q(),{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]),A=r?s.data?.total??0:n.data?.total??0,$=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:A,isLoading:$,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(z,{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(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{va as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{d as y,A as E,h as S,u as t,S as Ae,o as Rr,p as $r,a as Dr,T as Ie,q as T}from"./vendor-core-DfaOB3Rn.js";import{u as Or}from"./vendor-query-BBT5_sHx.js";import{g as un,e as Vr,t as yt,z as Fr,W as jr,M as cn,B as Ce}from"./index-gMxawd-E.js";import{I as O}from"./vendor-icons-DrybRNxP.js";import{M as Wr,v as cr,f as $n,e as zr,C as Hr,S as Ur,U as qr,a as Kr,p as Dn,u as Yr,b as Qr,d as Gr,l as Xr,t as Jr,i as Pn,w as Zr,x as es,y as or,s as Ln,g as ts,h as ns,j as rs,r as ss,k as at,m as as,E as os,A as is,P as ls,n as be,q as cs}from"./AvSyncCalibrator-BuHurVgo.js";import{O as mn,S as ds,a as us,A as ms}from"./OptionListMenu-DngTgHxH.js";import{u as hs}from"./useProviders-Ca0bZWt7.js";import{d as ps,g as gs,h as fs,f as vs,e as bs,j as ys,k as Ss}from"./useTvLibrary-Fgn5i9rJ.js";import{l as _s,c as Cs}from"./hls-B3_1VuDP.js";import{u as Ts}from"./useIsMobile-Dvx1uJ82.js";import{S as ks}from"./SynopsisText-B3Sa5pRv.js";const Es="_fullscreenFlat_1xij1_1",xs="_timeDisplay_1xij1_15",Ns="_bottomControls_1xij1_19",ws="_leftControls_1xij1_23",Is="_rightControls_1xij1_24",Bs="_controlBtn_1xij1_28",Ms="_controlsOverlay_1xij1_47",As="_hidden_1xij1_67",Ps="_topControls_1xij1_73",Ls="_backBtn_1xij1_93",Rs="_videoTitleInfo_1xij1_113",$s="_animeTitle_1xij1_119",Ds="_episodeLabel_1xij1_127",Os="_speedBoostBadge_1xij1_134",Vs="_progressBarContainer_1xij1_180",Fs="_progressBar_1xij1_180",js="_thumb_1xij1_199",Ws="_bufferedBar_1xij1_217",zs="_watchedBar_1xij1_227",Hs="_scrubbing_1xij1_252",Us="_timeBubble_1xij1_256",qs="_bottomControlsRow_1xij1_270",Ks="_nextEpisodeBtn_1xij1_293",Ys="_active_1xij1_346",Qs="_settingsPanel_1xij1_421",Gs="_settingsHeader_1xij1_440",Xs="_settingsBackBtn_1xij1_448",Js="_settingsTitle_1xij1_466",Zs="_settingsContent_1xij1_477",ea="_currentValue_1xij1_486",ta="_menuItem_1xij1_501",na="_menuNote_1xij1_534",ra="_loadingOverlay_1xij1_547",sa="_loadingDots_1xij1_558",aa="_dot_1xij1_563",oa="_bufferingOverlay_1xij1_592",ia="_bufferingSpinner_1xij1_601",a={fullscreenFlat:Es,timeDisplay:xs,bottomControls:Ns,leftControls:ws,rightControls:Is,controlBtn:Bs,controlsOverlay:Ms,hidden:As,topControls:Ps,backBtn:Ls,videoTitleInfo:Rs,animeTitle:$s,episodeLabel:Ds,speedBoostBadge:Os,progressBarContainer:Vs,progressBar:Fs,thumb:js,bufferedBar:Ws,watchedBar:zs,scrubbing:Hs,timeBubble:Us,bottomControlsRow:qs,nextEpisodeBtn:Ks,active:Ys,settingsPanel:Qs,settingsHeader:Gs,settingsBackBtn:Xs,settingsTitle:Js,settingsContent:Zs,currentValue:ea,menuItem:ta,menuNote:na,loadingOverlay:ra,loadingDots:sa,dot:aa,bufferingOverlay:oa,bufferingSpinner:ia},dn=-6e4,Rn=6e4,ir=500,la=({classes:m,delayMs:k,onDelayChange:H})=>{const[V,L]=y(null),x=V??k,r=E(H);r.current=H;const M=E(k);M.current=k;const o=E(null);o.current=V,S(()=>{L(null)},[k]),S(()=>()=>{const q=o.current;q!==null&&q!==M.current&&r.current(q)},[]);const se=q=>{M.current=q,o.current=null,r.current(q),L(null)},ae=q=>{const f=o.current??M.current,ye=Math.max(dn,Math.min(Rn,f+q));se(ye)};return t(Ae,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:m.item,onClick:()=>ae(-ir),"aria-label":"Show subtitles 0.5 seconds earlier",style:{flex:1,justifyContent:"center"},children:t("span",{children:"-0.5s"})}),t("button",{type:"button",className:m.item,onClick:()=>ae(ir),"aria-label":"Show subtitles 0.5 seconds later",style:{flex:1,justifyContent:"center"},children:t("span",{children:"+0.5s"})}),t("button",{type:"button",className:m.item,onClick:()=>se(0),disabled:x===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(Wr,{label:"Subtitle timing",display:cr(x),min:dn,max:Rn,step:100,value:x,percent:(x-dn)/(Rn-dn)*100,onChange:q=>{const f=Math.round(q);o.current=f,L(f)},onCommit:()=>{const q=o.current;q!==null&&se(q)}}),t("div",{className:m.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},ca=({classes:m,tracks:k,selected:H,onChange:V})=>t(mn,{classes:m,options:k.map((L,x)=>({key:String(x),label:L.label||L.language,selected:x===H})),onSelect:L=>V(Number(L))}),da=({player:m,title:k,episodeLabel:H,audioTracks:V,selectedAudioTrack:L,onAudioTrackChange:x,subtitles:r,selectedSubtitle:M,onSubtitleChange:o,streams:se,qualityIdx:ae,onQualityChange:q,onBack:f,children:ye,movyServers:A=[],selectedMovyServer:St="atlanta",onMovyServerSelect:me,isMovySource:je=!1,videoDelayEnabled:_t=!1,onVideoDelayToggle:Ct,videoDelayMs:Tt=0,onVideoDelayChange:hn,onCalibrateAvSync:pn,subtitleDelayMs:kt=0,onSubtitleDelayChange:oe,showNextEpisodeButton:$t=!1,onNextEpisode:Dt,isLoading:Be=!1})=>{const{state:_,refs:Pe,actions:C}=m,X=Pe.videoRef,{subtitleFontSize:Le,subtitlePosition:he,subtitleBgOpacity:We,subtitleBgColor:pe,subtitleTextColor:ze,subtitleEdge:J,subtitleBold:Te}=_,[N,Q]=y(null),He=E(null),[Ot,Et]=y(0);S(()=>{const i=X.current;if(!i)return;const d=()=>Et(i.clientHeight||0);d();const $e=new ResizeObserver(d);return $e.observe(i),()=>$e.disconnect()},[X,se]);const ie=(i,d)=>{try{localStorage.setItem(i,String(d))}catch{}},ne=(i,d)=>{switch(i){case"fontSize":typeof d=="number"&&(C.setSubtitleFontSize(d),ie("subtitleFontSize",d));break;case"position":typeof d=="number"&&(C.setSubtitlePosition(d),ie("subtitlePosition",d));break;case"bgOpacity":typeof d=="number"&&(C.setSubtitleBgOpacity(d),ie("subtitleBgOpacity",d));break;case"bgColor":typeof d=="string"&&(C.setSubtitleBgColor(d),ie("subtitleBgColor",d));break;case"textColor":typeof d=="string"&&(C.setSubtitleTextColor(d),ie("subtitleTextColor",d));break;case"edge":(d==="shadow"||d==="outline"||d==="none")&&(C.setSubtitleEdge(d),ie("subtitleEdge",d));break;case"bold":typeof d=="boolean"&&(C.setSubtitleBold(d),ie("subtitleBold",d));break}};S(()=>{const i="tv-player-subtitle-style";let d=document.getElementById(i);d||(d=document.createElement("style"),d.id=i,document.head.appendChild(d));const $e={fontSize:Le,position:he,bgOpacity:We,bgColor:pe,textColor:ze,edge:J,bold:Te},ee=X.current,Kt=$n(Le,Ot||ee?.clientHeight||720);if(d.textContent=zr({...$e,fontSize:Kt}),ee){const Yt=()=>{const I=Number(he);return isNaN(I)?0:Math.max(0,Math.min(100,I))},Nt=(I,z)=>{try{const l=I;l.snapToLines=!1,l.line=z}catch{}},fn=()=>{const I=Kt*16,z=ee.videoHeight||ee.clientHeight||720,l=ee.videoWidth||ee.clientWidth||1280;return{step:I*1.3/z*100,chars:Math.max(20,Math.floor(l/(I*.55)))}},ct=I=>{const z=Math.max(0,Math.min(100,100-Yt())),l=Array.from(I.activeCues??[]);if(l.length<=1){l.forEach(_e=>Nt(_e,z));return}const{step:Ge,chars:$}=fn();let wt=z;for(let _e=l.length-1;_e>=0;_e--){const bn=String(l[_e].text??"").replace(/<[^>]*>/g,"").split(`
|
|
2
|
-
`).reduce((Gt,mt)=>Gt+Math.max(1,Math.ceil(mt.length/$)),0),Qt=wt-bn*Ge;Nt(l[_e],Math.max(0,Qt)),wt=Qt-Ge*.4}},Ye=()=>{const I=Math.max(0,Math.min(100,100-Yt()));Array.from(ee.textTracks).forEach(z=>{z.cues&&(Array.from(z.cues).forEach(l=>Nt(l,I)),z.mode==="showing"&&ct(z))})};Ye();const K=I=>{const z=I.target;z.mode==="showing"&&ct(z)},dt=()=>{Array.from(ee.textTracks).forEach(I=>{I.removeEventListener("cuechange",K),I.addEventListener("cuechange",K)}),Ye()};Array.from(ee.textTracks).forEach(I=>{I.addEventListener("cuechange",K)}),ee.textTracks.addEventListener("addtrack",dt);const ut=Array.from(ee.querySelectorAll("track")),Qe=()=>Ye();return ut.forEach(I=>I.addEventListener("load",Qe)),()=>{Array.from(ee.textTracks).forEach(I=>{I.removeEventListener("cuechange",K)}),ee.textTracks.removeEventListener("addtrack",dt),ut.forEach(I=>I.removeEventListener("load",Qe))}}},[Le,he,We,pe,ze,J,Te,M,r,X,Ot]);const Vt=i=>{const d=X.current;!d||isNaN(_.duration)||_.duration===0||(d.currentTime=i*_.duration)},xt=()=>{X.current&&(C.setIsScrubbing(!0),C.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},R=i=>{const d=X.current;d&&_.duration&&(d.currentTime=i*_.duration)},Z=()=>{C.setIsScrubbing(!1),C.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Ft=i=>{const d=X.current;d&&(d.volume=i,d.muted=i===0,localStorage.setItem("playerVolume",i.toString()))},jt=()=>{C.toggleMute()},Re=r.length>0,v=M>=0,c=()=>{Q("main"),C.setShowControls(!0)},le=()=>{if(v){o(-1);return}let i=null;try{i=localStorage.getItem("tvLastSubtitle")}catch{}o(Dn(r,{lastKey:i,enabled:!0}))},re=()=>{Q(null)},Wt=()=>t(Ae,{children:[se.length>1&&t("button",{className:a.menuItem,onClick:()=>Q("quality"),children:[t("span",{children:"Quality"}),t("span",{className:a.currentValue,children:se[ae]?.quality||"Auto"})]}),je&&A.length>0&&t("button",{className:a.menuItem,onClick:()=>Q("server"),children:[t("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t(O,{name:"server",size:12})," Movy Server"]}),t("span",{className:a.currentValue,style:{textTransform:"capitalize"},children:St})]}),Re&&t("button",{className:a.menuItem,onClick:()=>Q("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:a.currentValue,children:v?r[M]?.label||r[M]?.language:"Off"})]}),Re&&t("button",{className:a.menuItem,onClick:()=>Q("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:a.currentValue,children:[Le.toFixed(1),"x · ",he]})]}),Re&&t("button",{className:a.menuItem,onClick:()=>Q("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:a.currentValue,children:cr(kt)})]}),V.length>0&&t("button",{className:a.menuItem,onClick:()=>Q("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:a.currentValue,children:V[L]?.label||V[L]?.language})]}),t("button",{className:a.menuItem,onClick:()=>Q("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:a.currentValue,children:_t?`${Tt}ms`:"Off"})]})]}),zt=()=>t(mn,{classes:{item:a.menuItem,active:a.active},options:se.map((i,d)=>({key:String(d),label:i.quality,selected:d===ae})),onSelect:i=>q(Number(i))}),Ue=()=>t(mn,{classes:{item:a.menuItem,active:a.active},options:[{key:"off",label:"Off",selected:!v},...r.map((i,d)=>({key:String(d),label:i.label||i.language,selected:d===M}))],onSelect:i=>o(i==="off"?-1:Number(i))}),Ht=()=>t(us,{classes:{item:a.menuItem,active:a.active},values:{fontSize:Le,position:he,bgOpacity:We,bgColor:pe,textColor:ze,edge:J,bold:Te},onChange:ne}),qe=()=>t(la,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},delayMs:kt,onDelayChange:i=>oe?.(i)}),ot=()=>t(ca,{classes:{item:a.menuItem,active:a.active},tracks:V,selected:L,onChange:x}),gn=()=>t(mn,{classes:{item:a.menuItem,active:a.active},options:A.map(i=>({key:i,label:t("span",{style:{textTransform:"capitalize"},children:i}),selected:St===i})),onSelect:i=>me?.(i)}),it=()=>t(ms,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},enabled:_t,delayMs:Tt,onToggle:i=>Ct?.(i),onDelayChange:i=>hn?.(i),onCalibrate:()=>{Q(null),pn?.()}}),Se=_.isMuted?t(O,{name:"volume-mute"}):_.volume<.5?t(O,{name:"volume-down"}):t(O,{name:"volume-up"}),Ke=t("div",{className:`${a.controlsOverlay} ${!_.showControls&&!N?a.hidden:""}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:t("div",{className:a.topControls,onClick:i=>i.stopPropagation(),children:[t("button",{className:a.backBtn,onClick:f,title:"Back","aria-label":"Back",children:t(O,{name:"chevron-left"})}),t("div",{className:a.videoTitleInfo,children:[t("span",{className:a.animeTitle,children:k}),H&&t("span",{className:a.episodeLabel,children:H})]})]})}),lt=!Be&&!_.isBuffering&&_.duration>0?t(Hr,{isPlaying:_.isPlaying,onTogglePlay:C.togglePlay,onSkipBack:()=>C.seek(-10),onSkipForward:()=>C.seek(10)}):null,ge=t("div",{className:`${a.controlsOverlay} ${!_.showControls&&!N?a.hidden:""}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:a.bottomControls,onClick:i=>i.stopPropagation(),children:[t(Ur,{classes:{container:a.progressBarContainer,scrubbing:a.scrubbing,timeBubble:a.timeBubble,bar:a.progressBar,buffered:a.bufferedBar,watched:a.watchedBar,thumb:a.thumb},videoRef:X,duration:_.duration,formatTime:un,isScrubbing:_.isScrubbing,buffered:"full",onSeek:Vt,onScrubStart:xt,onScrubMove:R,onScrubEnd:Z,timeLabelRef:He}),t("div",{className:a.bottomControlsRow,children:[t("div",{className:a.leftControls,children:[t("button",{className:a.controlBtn,onClick:C.togglePlay,"aria-label":_.isPlaying?"Pause":"Play",children:_.isPlaying?t(O,{name:"pause"}):t(O,{name:"play"})}),t(qr,{muted:_.isMuted,volume:_.volume,volumeIcon:Se,buttonClassName:a.controlBtn,onToggleMute:jt,onVolumeChange:Ft,onExpandedChange:i=>C.setShowVolumeSlider(i)}),t("span",{className:a.timeDisplay,ref:He,children:[un(0)," / ",un(_.duration)]})]}),t("div",{className:a.rightControls,children:[$t&&t("button",{className:a.nextEpisodeBtn,onClick:Dt,title:"Play next episode",children:"Next EP"}),Re&&t("button",{className:`${a.controlBtn} ${v?a.active:""}`,onClick:le,"aria-label":v?"Turn subtitles off":"Turn subtitles on",children:t(O,{name:"closed-captioning"})}),t("button",{className:`${a.controlBtn} ${N?a.active:""}`,onClick:()=>N?re():c(),"aria-label":"Settings",children:t(O,{name:"cog"})}),t("button",{className:a.controlBtn,onClick:C.toggleFullscreen,"aria-label":_.isFullscreen?"Exit Fullscreen":"Fullscreen",children:_.isFullscreen?t(O,{name:"compress"}):t(O,{name:"expand"})})]})]})]})}),Ut=N?t("div",{"data-speed-boost-ignore":"true",onClick:i=>i.stopPropagation(),children:t(ds,{classes:{panel:a.settingsPanel,header:a.settingsHeader,backBtn:a.settingsBackBtn,title:a.settingsTitle,content:a.settingsContent},title:N==="main"?"Settings":N==="subtitle-style"?"Subtitle Style":N==="subtitle-timing"?"Subtitle Timing":N==="audio"?"Audio Track":N==="server"?"Movy Server":N==="av-sync"?"A/V Sync":N.charAt(0).toUpperCase()+N.slice(1),onBack:()=>N==="main"?re():Q("main"),children:[N==="main"&&Wt(),N==="quality"&&zt(),N==="subtitles"&&Ue(),N==="subtitle-style"&&Ht(),N==="subtitle-timing"&&qe(),N==="audio"&&ot(),N==="server"&&gn(),N==="av-sync"&&it()]})}):null,qt=t(Ae,{children:[Be&&t("div",{className:a.loadingOverlay,"aria-hidden":"true",children:t("div",{className:a.loadingDots,children:[t("div",{className:a.dot}),t("div",{className:a.dot}),t("div",{className:a.dot})]})}),_.isBuffering&&!Be&&t("div",{className:a.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:a.bufferingSpinner})}),_.isSpeedBoostActive&&t("div",{className:a.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(O,{name:"forward",size:12})]})]});return t(Kr,{player:m,topBar:Ke,centerControls:lt,bottomBar:!Be&&_.duration>0?ge:null,settingsPanel:Ut,overlays:qt,isInteracting:!!N,className:_.isFullscreen?a.fullscreenFlat:"",children:ye})};function ua(m,k,H){const V=()=>{const x=Array.isArray(m.audioTracks)?m.audioTracks.length:0,r=H.getWant(),M=x>0?Math.min(Math.max(0,r),x-1):r;m.audioTrack=M,M!==r&&H.onResolve(M)},L=(x,r)=>{const M=H.getWant(),o=Array.isArray(m.audioTracks)?m.audioTracks.length:0;if(r.id!==M&&M>=0&&M<o){m.audioTrack!==M&&(m.audioTrack=M);return}H.onResolve(r.id)};return m.on(k.MANIFEST_PARSED,V),m.on(k.AUDIO_TRACK_SWITCHED,L),()=>{m.off(k.MANIFEST_PARSED,V),m.off(k.AUDIO_TRACK_SWITCHED,L)}}const ma="_page_263ma_1",ha="_header_263ma_7",pa="_pageTitle_263ma_11",ga="_searchForm_263ma_21",fa="_searchInput_263ma_27",va="_searchBtn_263ma_42",ba="_suggestions_263ma_58",ya="_suggestionPill_263ma_65",Sa="_statusMsg_263ma_81",_a="_error_263ma_87",Ca="_textOnly_263ma_91",Ta="_spinner_263ma_96",ka="_spin_263ma_96",Ea="_grid_263ma_110",xa="_skeletonCard_263ma_116",Na="_skeletonThumb_263ma_121",wa="_skeletonLine_263ma_127",Ia="_shimmer_263ma_134",Ba="_backBtn_263ma_154",Ma="_meta_263ma_172",Aa="_headerActions_263ma_180",Pa="_watchlistBtn_263ma_187",La="_active_263ma_205",Ra="_year_263ma_215",$a="_rating_263ma_220",Da="_typeBadge_263ma_229",Oa="_tv_263ma_237",Va="_movie_263ma_242",Fa="_tvSeries_263ma_247",ja="_tvMiniSeries_263ma_252",Wa="_overview_263ma_257",za="_controls_263ma_264",Ha="_controlLabel_263ma_272",Ua="_select_263ma_282",qa="_playerSection_263ma_293",Ka="_video_263ma_297",Ya="_videoHidden_263ma_319",Qa="_delayCanvas_263ma_324",Ga="_delayCanvasActive_263ma_337",Xa="_subtitleOverlay_263ma_341",Ja="_videoIframe_263ma_360",Za="_retryButton_263ma_368",eo="_sidebarSeason_263ma_383",to="_mobileSeasonRow_263ma_399",no="_sidebarPosterCard_263ma_413",ro="_sidebarPosterMeta_263ma_428",so="_providerSelectWrap_263ma_445",ao="_genreRow_263ma_457",oo="_genreChip_263ma_464",io="_metaRow_263ma_474",lo="_detailGrid_263ma_483",co="_detailItem_263ma_490",uo="_imdbLink_263ma_512",b={page:ma,header:ha,pageTitle:pa,searchForm:ga,searchInput:fa,searchBtn:va,suggestions:ba,suggestionPill:ya,statusMsg:Sa,error:_a,textOnly:Ca,spinner:Ta,spin:ka,grid:Ea,skeletonCard:xa,skeletonThumb:Na,skeletonLine:wa,shimmer:Ia,backBtn:Ba,meta:Ma,headerActions:Aa,watchlistBtn:Pa,active:La,year:Ra,rating:$a,typeBadge:Da,tv:Oa,movie:Va,tvSeries:Fa,tvMiniSeries:ja,overview:Wa,controls:za,controlLabel:Ha,select:Ua,playerSection:qa,video:Ka,videoHidden:Ya,delayCanvas:Qa,delayCanvasActive:Ga,subtitleOverlay:Xa,videoIframe:Ja,retryButton:Za,sidebarSeason:eo,mobileSeasonRow:to,sidebarPosterCard:no,sidebarPosterMeta:ro,providerSelectWrap:so,genreRow:ao,genreChip:oo,metaRow:io,detailGrid:lo,detailItem:co,imdbLink:uo},mo=[],ho=[];function lr({error:m,servers:k,selectedServer:H,onRetry:V,onSelect:L}){return t("div",{className:`${b.statusMsg} ${b.error}`,style:{flexDirection:"column",alignItems:"stretch",gap:8},children:[t("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t("span",{style:{flex:1},children:m}),t("button",{className:b.retryButton,onClick:V,children:"Retry"})]}),k.length>0&&t("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center",marginTop:4},children:[t("span",{style:{fontSize:"0.8rem",opacity:.9,fontWeight:600},children:"Servers:"}),k.map(x=>t("button",{onClick:()=>L(x),className:b.retryButton,style:{padding:"4px 8px",fontSize:"0.75rem",textTransform:"capitalize",background:H===x?"var(--accent)":void 0,color:H===x?"white":void 0},children:x},x))]})]})}const xo=()=>{const{id:m}=Rr(),[k]=$r(),H=E(k);H.current=k;const V=Dr(),L=Or(),x=k.get("type"),[r,M]=y(null),[o,se]=y(()=>parseInt(k.get("s")||"1",10)||1),[ae,q]=y([]),[f,ye]=y(()=>parseInt(k.get("e")||"1",10)||1),[A,St]=y(()=>{try{return localStorage.getItem("tvProvider")||""}catch{return""}}),[me,je]=y([]),[_t,Ct]=y(""),{options:Tt,isFallback:hn,isLoading:pn}=hs(),kt=Ie(()=>Tt.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.value,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[Tt]),oe=hn||kt.length===0?mo:kt,$t=oe.filter(e=>e.tier==="direct"),Dt=oe.filter(e=>e.tier==="embed"),[Be,_]=y(!1),[Pe,C]=y(""),[X,Le]=y([]),[he,We]=y(0),[pe,ze]=y([]),[J,Te]=y(-1),[N,Q]=y(0),[He,Ot]=y(""),[Et,ie]=y(""),[ne,Vt]=y(()=>{try{return localStorage.getItem("movyServer")||""}catch{return""}}),xt=Ie(()=>oe.find(e=>e.id===A),[oe,A]),R=xt?.tier==="embed",Z=Ie(()=>xt?.servers??[],[xt]),Ft=E([]);S(()=>{Ft.current=me},[me]);const jt=E(he);S(()=>{jt.current=he},[he]);const Re=E(J);S(()=>{Re.current=J},[J]);const v=Yr({skipIntervals:ho}),c=v.refs.videoRef,le=E(null),re=E([]),Wt=E(null),zt=E(null),[Ue,Ht]=y(()=>{try{const e=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(e)&&e>=0&&e<=500)return Math.round(e)}catch{}return 180}),[qe,ot]=y(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[gn,it]=y(!1),[Se,Ke]=y(!1),lt=E(null),ge=E(null),Ut=(e,n)=>{try{localStorage.setItem("playerVideoDelayMs",String(e)),localStorage.setItem("playerVideoDelayEnabled",String(n))}catch{}},qt=e=>{const n=Math.max(0,Math.min(500,Math.round(e)));Ht(n);try{localStorage.setItem("playerVideoDelayMs",String(n))}catch{}},[i,d]=y(()=>{try{const e=Number(localStorage.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),$e=E(i);$e.current=i;const ee=T(e=>{const n=Math.max(-6e4,Math.min(6e4,Math.round(e)));if($e.current!==n){$e.current=n,d(n);try{localStorage.setItem("tvSubtitleDelayMs",String(n))}catch{}}},[]),Kt=()=>{lt.current={enabled:qe,ms:Ue},ot(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}it(!0)},Yt=()=>{const e=lt.current;lt.current=null,e&&(Ht(e.ms),ot(e.enabled),Ut(e.ms,e.enabled)),Ke(!1),it(!1)},Nt=()=>{lt.current=null,ot(!0),Ut(Ue,!0),Ke(!1),it(!1)},fn=()=>{if(Se){Ke(!1);return}const e=c.current;e&&!isNaN(e.currentTime)&&(ge.current=e.currentTime),Ke(!0)},ct=qe?Ue:0;Qr({videoRef:c,canvasRef:Wt,delayMs:ct,enabled:qe});const Ye=qe,K=Ye||i!==0,dt=E(K);dt.current=K;const ut=T(()=>{if(!dt.current)return;const e=c.current;e&&Array.from(e.textTracks).forEach(n=>{n.mode!=="hidden"&&(n.mode="hidden")})},[c]),{hasConsent:Qe,grant:I}=Vr(),z=E("");z.current||(z.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const l=x==="movie",Ge=m?ps(x||"tv",m):"",$=Ge,wt=gs(),_e=fs(),{toggle:vn,bookmarkedIds:bn,pending:Qt}=vs(),{data:Gt}=bs(r?Ge:void 0),mt=Gt?!!Gt.inLibrary:Ge?bn.has(Ge):!1,dr=T(()=>{!r||!m||vn({tmdbId:Number(m),mediaType:x||"tv",title:r.title,poster:r.poster,year:r.year,adult:r.adult})},[r,m,x,vn]),{data:Xe,isFetched:On,isPending:Vn}=ys($||void 0,o,f),Xt=Ie(()=>ae.map(e=>e.episode_number).sort((e,n)=>e-n),[ae]),Je=Xt.indexOf(f),yn=Je>0?Xt[Je-1]:null,w=Je>=0&&Je<Xt.length-1?Xt[Je+1]:null,Jt=Ie(()=>(r?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,n)=>e-n),[r]),fe=Ie(()=>{if(l||w!=null)return null;const e=Jt.indexOf(o);return e>=0&&e<Jt.length-1?Jt[e+1]:(r?.number_of_seasons??0)>o?o+1:null},[l,w,Jt,o,r?.number_of_seasons]),Fn=Xe?.currentTime??0,jn=Xe?.duration??0,Sn=Xe?.completed===!0||Xe?.completed===1||Pn(Fn,jn),[ke,Me]=y(!1),Ee=E(!1),_n=E(null),It=E(null);S(()=>{Ee.current=!1,It.current=null,Me(!1)},[$,o,f]);const[xe,Zt]=y(!1),[ht,Wn]=y(0),[Ze,zn]=y(!1),[De,et]=y(!1),[ur,Cn]=y(!1),[mr,Hn]=y(""),[en,hr]=y(!1),[pr,Tn]=y(!1);Gr(v,(me.length>0||Et!=="")&&!xe&&!ke&&!De);const gr=Ts(),[pt,fr]=y(Xr),vr=T(e=>{fr(e),Jr(e)},[]),ce=E(!1),tt=E(null),kn=E(0),Un=E(!1),qn=E(0),te=E(null),Bt=E(""),br=or(Fn,jn),Mt=!ce.current&&!Ee.current&&(xe||ke||De||Sn||br),gt=E(Mt);gt.current=Mt;const ft=E(!1);S(()=>{ft.current=Ze},[Ze]);const Oe=T((e,n)=>{if(!$||!n||n<30)return;const s=Pn(e,n),u=s?n:e;Math.abs(u-kn.current)<10&&!s||(kn.current=u,wt.mutate({mediaId:$,season:o,episode:f,currentTime:Math.floor(u),duration:Math.floor(n),completed:s,title:r?.title??null,poster:r?.poster??null,backdrop:r?.backdrop??null,year:r?.year??null,overview:r?.overview??null,tmdbId:r?.id??null,mediaType:x||"tv",adult:r?.adult?1:0}))},[$,o,f,wt,r,x]),Ne=T((e,n)=>{Ke(!1),it(!1);const s=new URLSearchParams(k);s.set("type",k.get("type")||"tv"),s.set("s",String(e)),s.set("e",String(n)),V(`${window.location.pathname}?${s.toString()}`)},[k,V]),At=T(()=>{const e=c.current;if(!e||l||w==null){Cn(!1);return}const n=e.duration||0,s=e.currentTime||0;Cn(n>0&&s/n>=.8)},[l,w,c]),tn=T((e,n)=>["tv-sources",A,l?"movie":"tv",m,e,n,ne],[A,l,m,ne]),nn=T(async(e,n)=>{if(!r||!m||!A)return{valid:!1,sources:[]};const s=l?"movie":"tv",u=await yt.tv.sources.query({provider:A,type:s,tmdbId:String(m),season:e,episode:n,title:r.title||"",year:r.year||"",totalSeasons:String(r.number_of_seasons||1),imdbId:r.imdb_id||"",...Z.length>0&&ne?{server:ne}:{}});return{valid:"valid"in u?u.valid:!1,error:"error"in u?u.error:void 0,sources:u.sources,referer:"referer"in u?u.referer:void 0,audioTracks:u.audioTracks,subtitles:"subtitles"in u?u.subtitles:void 0}},[r,m,A,l,Z,ne]),Kn=T(()=>{if(l||!r||!m||!A||R||w==null)return;const e=tn(o,w);L.getQueryState(e)?.status!=="success"&&L.prefetchQuery({queryKey:e,queryFn:()=>nn(o,w),staleTime:300*1e3,gcTime:1800*1e3})},[l,r,m,A,R,w,o,L,tn,nn]),yr=T(()=>{if(Se)return;At();const e=c.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&Kn(),tt.current&&clearTimeout(tt.current),tt.current=setTimeout(()=>{Oe(e.currentTime,e.duration||0)},5e3))},[Oe,c,Se,At,Kn]),Sr=T(()=>{const e=c.current;if(!e||!r)return;tt.current&&clearTimeout(tt.current),Oe(e.currentTime,e.duration||0),Un.current=!0;const n=Zr({seekInduced:Date.now()-qn.current<es,autoplayEnabled:pt,hasNext:!l&&w!=null,isFinal:l||w==null});n==="advance"&&w!=null?(ye(w),Ne(o,w)):n==="prompt-next"?(Ee.current=!1,ce.current=!0,Me(!0)):n==="prompt-complete"&&(Hn(l?r.title:`${r.title} — Season ${o}`),et(!0),Ee.current=!0,ce.current=!0)},[l,r,o,w,pt,Oe,Ne,c]),_r=T(()=>{Un.current=!1,v.actions.onPlay()},[v.actions]),Cr=T(()=>{v.actions.onPause();const e=c.current;e&&!e.ended&&Oe(e.currentTime,e.duration||0)},[v.actions,Oe,c]),Tr=T(()=>{v.actions.onLoadedMetadata();const e=c.current;if(e){try{const n=parseFloat(localStorage.getItem("playerVolume")||"");isNaN(n)||(e.volume=Math.max(0,Math.min(1,n))),e.muted=localStorage.getItem("playerMuted")==="true"}catch{}if(te.current!=null&&te.current>0){try{e.currentTime=te.current}catch{}te.current=null}At()}},[v.actions,c,At]),vt=T(()=>{const e=c.current;if(e&&te.current!=null&&te.current>0){try{e.currentTime=te.current}catch{}te.current=null}},[c]),kr=T(()=>{ht>0&&(te.current=ht);const e=c.current;if(e&&ht>0){try{e.currentTime=ht,te.current=null}catch{}e.play().catch(()=>{})}Zt(!1),ce.current=!0},[ht,c]),Yn=T(()=>{te.current=null;const e=c.current;e&&(e.currentTime=0,e.play().catch(()=>{})),Zt(!1),ce.current=!0},[c]),Er=T(()=>{Ee.current=!0,Me(!1),ce.current=!0},[]),xr=T(()=>{Ee.current=!0,Me(!1),ce.current=!0,te.current=null;const e=c.current;if(e){try{e.currentTime=0}catch{}e.play().catch(()=>{})}},[c]),Qn=T(()=>{w!=null&&(Ee.current=!0,Me(!1),ce.current=!0,ye(w),Ne(o,w))},[w,o,Ne]),Gn=T(()=>{fe!=null&&(Ee.current=!0,Me(!1),et(!1),ce.current=!0,se(fe),ye(1),Ne(fe,1))},[fe,Ne]),Nr=T(async()=>{if($)try{await _e.mutateAsync({id:$,status:"Completed"}),et(!1),Me(!1),V("/")}catch{}},[$,_e,V]);S(()=>{ce.current=!1,_n.current=null,Zt(!1),Cn(!1),Wn(0),zn(!1),ft.current=!1,te.current=null,Bt.current=`${$}:${o}:${f}`,kn.current=0},[$,o,f]),S(()=>{On&&(zn(!0),ft.current=!0)},[On,$,o,f]),S(()=>{if(!Xe||ce.current)return;const e=`${$}:${o}:${f}`;if(_n.current===e)return;_n.current=e;const n=Xe,s=n.currentTime??0,u=n.duration??0;or(s,u)&&(Wn(s),Zt(!0))},[Xe,$,o,f]),S(()=>{if(!Ze||ce.current||Ee.current||xe||De||ke)return;const e=`${$}:${o}:${f}`;if(It.current!==e){if(!Sn){Vn||(It.current=e);return}if(l){It.current=e,Me(!0);return}if(!(!r||Je<0||ae.length===0)){if(It.current=e,w==null&&fe==null){r&&ae.length>0&&(Hn(`${r.title} — Season ${o}`),et(!0),Ee.current=!0,ce.current=!0);return}Me(!0)}}},[Ze,Sn,Vn,xe,De,ke,l,w,fe,r,Je,ae.length,$,o,f]),S(()=>{(xe||ke)&&c.current&&c.current.pause()},[xe,ke,c]),S(()=>{const e=c.current;return()=>{tt.current&&clearTimeout(tt.current),e&&!e.ended&&Oe(e.currentTime,e.duration||0)}},[Oe,c]);const En=T(e=>{let n=null,s=!0;try{n=localStorage.getItem("tvLastSubtitle"),s=localStorage.getItem("tvSubtitlesEnabled")!=="false"}catch{}return Dn(e,{lastKey:n,enabled:s})},[]),xn=T(e=>{if(!(e<0))try{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),Xn=T(e=>{if(e.length===0)return 0;let n=null;try{n=localStorage.getItem("tvLastAudio")}catch{}if(n){const s=e.findIndex(F=>Ln(F)===n);if(s>=0)return s;const u=n.indexOf("|||"),h=u>=0?n.slice(0,u):n,p=u>=0?n.slice(u+3):n,g=e.findIndex(F=>F.language===h||F.label===p);if(g>=0)return g}return Dn(e,{lastKey:null,enabled:!0})},[]),{data:Jn}=Ss($||void 0),Zn=Ie(()=>(Jn?.progress??[]).filter(n=>n.season===o&&(n.completed===!0||n.completed===1||Pn(n.currentTime,n.duration))).map(n=>String(n.episode)),[Jn,o]),er=Ie(()=>ae.map(e=>({id:String(e.episode_number),label:`Episode ${e.episode_number}`,sublabel:e.name||void 0,thumbnail:e.still_path?`https://image.tmdb.org/t/p/w185${e.still_path}`:void 0})),[ae]),tr=Ie(()=>(r?.genres??[]).map(e=>e.name).slice(0,5),[r]),Nn=Ie(()=>[r?.year,r?.status,r?.number_of_seasons?`${r.number_of_seasons} Season${r.number_of_seasons>1?"s":""}`:null,r?.number_of_episodes?`${r.number_of_episodes} Episodes`:null].filter(Boolean),[r]);S(()=>{if(oe.length!==0&&!oe.some(e=>e.id===A)){const e=oe.find(n=>n.tier==="direct")?.id??oe[0].id;St(e);try{localStorage.setItem("tvProvider",e)}catch{}}},[oe,A]),S(()=>{if(Z.length!==0&&!Z.includes(ne)){Vt(Z[0]);try{localStorage.setItem("movyServer",Z[0])}catch{}}},[Z,ne]),S(()=>{if(!m){M(null),je([]),Ct(""),C(""),ie("");return}const e=Number(m),n=x||"tv";M(null),je([]),Ct(""),C(""),ie("");const s=parseInt(H.current.get("s")||"",10),u=parseInt(H.current.get("e")||"",10);se(isNaN(s)?1:s),ye(isNaN(u)?1:u),Q(0),yt.tv.details.query({type:n,id:String(e)}).then(h=>{const p={id:h.id,title:h.title||"",overview:h.overview||"",vote_average:h.vote_average,year:h.year,poster:h.poster,backdrop:h.backdrop,imdb_id:h.imdb_id||void 0,adult:h.adult,seasons:h.seasons,number_of_seasons:h.number_of_seasons};M(p),p.seasons&&p.seasons.length>0&&isNaN(s)&&se(p.seasons[0].season_number)}).catch(()=>{})},[m,x]),S(()=>{if(!r||!m)return;if(!(r.seasons!==void 0||r.number_of_seasons!==void 0)){q([]);return}const n=parseInt(k.get("e")||"",10);yt.tv.episodes.query({id:String(m),season:String(o)}).then(s=>{const u=(s.episodes||[]).map(h=>({episode_number:h.episode_number,name:h.name||"",vote_average:h.vote_average,overview:h.overview||"",still_path:h.still_path||""}));q(u),u.length!==0&&ye(h=>!isNaN(n)&&u.some(p=>p.episode_number===n)?n:u.some(p=>p.episode_number===h)?h:u[0].episode_number)}).catch(()=>{})},[r,m,o,k]),S(()=>{if(!R||!r||!m)return;fetch(`/api/tv/embed/${A}/${l?"movie":"tv"}/${m}?season=${o}&episode=${f}`).then(n=>n.json()).then(n=>{if(n.url)return ie(n.url),fetch(`/api/resolve?url=${encodeURIComponent(n.url)}`).then(s=>s.json()).then(s=>{s.finalUrl&&ie(s.finalUrl)})}).catch(()=>{})},[A,r,m,o,f,l,R]);const rn=T(async()=>{if(!r||!m||!A||R||r.adult&&!Qe)return;const e=`${$}:${o}:${f}`;Ft.current.length>0?C(""):(_(!0),C(""),je([]),Q(0),Le([]),ze([]));try{const s=await L.fetchQuery({queryKey:tn(o,f),queryFn:()=>nn(o,f),staleTime:3e5,gcTime:18e5});if(Bt.current!==e)return;if(_(!1),!s.valid||!s.sources?.length){C(s.error?`${s.error}`:Z.length>0?`No streams from ${ne}. Try another server.`:"No streams available.");return}je(s.sources),Ct(e),Q(0),s.referer&&Ot(s.referer);const u=s.audioTracks||[];Le(u),We(u.length>0?Xn(u):0);const h=s.subtitles||[];if(ze(h),h.length>0){const F=En(h);Te(F),xn(F)}else Te(-1);const p=l?"movie":"tv",g=m;yt.tv.subtitles.query({type:p,tmdbId:String(g),season:String(o),episode:String(f)}).then(F=>{if(Bt.current!==e)return;const ve=Array.isArray(F.subtitles)?F.subtitles:[];ve.length!==0&&ze(U=>{const B=[...U,...ve.filter(D=>!U.some(P=>P.url===D.url))];if(U.length===0){const D=En(B);Te(D),xn(D)}return B})}).catch(()=>{}),C("")}catch{if(Bt.current!==e)return;_(!1),C("Failed to load streams.")}},[r,m,A,o,f,l,R,Qe,Z,ne,En,xn,Xn,$,L,tn,nn]),wn=T(e=>{const n=e.toLowerCase();Vt(n);try{localStorage.setItem("movyServer",n)}catch{}C("")},[]),wr=T(e=>{St(e);try{localStorage.setItem("tvProvider",e)}catch{}},[]);S(()=>{A&&r&&!R&&rn()},[A,r,rn,R]),S(()=>{if(!c.current||(le.current&&(le.current.destroy(),le.current=null),R))return;let e=!1;if(Se){const p=c.current;return p&&(p.pause(),p.removeAttribute("src"),p.load(),p.src="/av-sync-test.mp4",gt.current||p.play().catch(()=>{})),()=>{e=!0}}const n=_t===`${$}:${o}:${f}`&&me[N]?.url||"";if(!n){try{c.current?.pause()}catch{}return}const s=c.current;if(Bt.current===`${$}:${o}:${f}`&&te.current==null&&!gt.current)try{!s.ended&&s.currentTime>1&&(te.current=s.currentTime)}catch{}s.pause(),s.removeAttribute("src"),s.load(),v.actions.resetMediaState();const u=`/api/tv/stream-proxy?url=${encodeURIComponent(n)}&referer=${encodeURIComponent(He)}`;me[N]?.type==="hls"?(async()=>{const p=await _s();if(!e)if(p&&p.isSupported()){const g=new p({enableWorker:!0});le.current=g,g.on(p.Events.ERROR,(U,B)=>{B.fatal&&(C(`Stream failed (${B.details}). Try another source or reload.`),_(!1),g.destroy(),le.current=null)}),g.loadSource(u),g.attachMedia(s);const F=()=>{let U=!1,B=0;try{U=localStorage.getItem("tvSubtitlesEnabled")==="true";const D=parseInt(localStorage.getItem("tvSelectedSubtitle")||"0",10);!isNaN(D)&&D>=0&&(B=D)}catch{}return{enabled:U,index:B}},ve=()=>{if(typeof g.subtitleTrack!="number")return;if(re.current.length>0){g.subtitleTrack=-1;return}const U=Array.isArray(g.subtitleTracks)?g.subtitleTracks:[];if(U.length===0){g.subtitleTrack=-1;return}const B=F();if(B.enabled){const D=B.index<U.length?B.index:0;g.subtitleTrack=D,Te(D),ut()}else g.subtitleTrack=-1};ua(g,p.Events,{getWant:()=>jt.current,onResolve:U=>We(U)}),g.on(p.Events.MANIFEST_PARSED,()=>{ve(),ge.current!=null&&(s.currentTime=ge.current,ge.current=null),vt(),!gt.current&&ft.current&&s.play().catch(()=>{})}),g.on(p.Events.SUBTITLE_TRACKS_UPDATED,()=>{ve()}),g.on(p.Events.SUBTITLE_TRACK_SWITCH,(U,B)=>{if(re.current.length>0){if(B.id!==-1)try{g.subtitleTrack=-1}catch{}return}const D=Array.isArray(g.subtitleTracks)?g.subtitleTracks:[];if(D.length!==0){if(B.id===-1){const P=F();if(P.enabled){const Y=P.index<D.length?P.index:0;g.subtitleTrack=Y;return}}Te(B.id),ut()}})}else Cs(s)&&(s.src=u,ge.current!=null&&(s.currentTime=ge.current,ge.current=null),vt(),!gt.current&&ft.current&&s.play().catch(()=>{C("Failed to play stream. Try another source.")}))})():(s.src=u,ge.current!=null&&(s.currentTime=ge.current,ge.current=null),vt(),!gt.current&&ft.current&&s.play().catch(()=>{C("Failed to play stream. Try another source.")}));const h=()=>{const F=s.error?.code===4?"Video source not supported or not found":"Failed to load video stream";C(`${F}. The source may be invalid or expired. Try switching source or reloading.`),_(!1)};return s.addEventListener("error",h),()=>{e=!0,s.removeEventListener("error",h)}},[me,_t,N,A,He,R,c,Se,$,o,f,vt,ut,v.actions]),S(()=>{if(!Ze||xe||ke||De||Mt||R||Se)return;const e=c.current;!e||!e.paused||e.ended||e.readyState<1||(vt(),e.play().catch(()=>{}))},[Ze,xe,ke,De,Mt,R,Se,vt,c]),S(()=>{const e=le.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=he)},[he]),S(()=>{const e=le.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||re.current.length>0||(J>=0?e.subtitleTrack=J:e.subtitleTrack=-1)},[J]),S(()=>{const e=c.current;if(!(!e||R)&&(e.querySelectorAll("track").forEach(n=>n.remove()),re.current=[],pe.length!==0&&(pe.forEach(n=>{const s=document.createElement("track");s.kind="subtitles",s.label=n.label||n.language||"Unknown",s.srclang=n.language||n.label||"en";const u=`/api/subtitle-proxy?url=${encodeURIComponent(n.url)}&referer=${encodeURIComponent(He)}`;s.src=u,s.addEventListener("load",()=>{const h=re.current.indexOf(s),p=s.track;if(p&&h>=0){const g=h===Re.current;p.mode=g&&!dt.current?"showing":"hidden"}}),e.appendChild(s),re.current.push(s)}),pe.length>0)))try{const n=le.current;n&&typeof n.subtitleTrack=="number"&&n.subtitleTrack!==-1&&(n.subtitleTrack=-1)}catch{}},[pe,He,R,A,c]),S(()=>{const e=c.current;if(!e||R)return;const n=le.current;re.current.length>0&&n&&typeof n.subtitleTrack=="number"&&Array.isArray(n.subtitleTracks)&&n.subtitleTracks.length>0&&(n.subtitleTrack=-1);const s=()=>{const p=$n(v.state.subtitleFontSize,e.clientHeight||720),g=Math.max(0,Math.min(100,100-v.state.subtitlePosition)),F=()=>{const P=p*16,Y=e.videoHeight||e.clientHeight||720,G=e.videoWidth||e.clientWidth||1280;return{step:P*1.3/Y*100,chars:Math.max(20,Math.floor(G/(P*.55)))}},ve=(P,Y)=>{const G=P;G.snapToLines=!1,G.line=Y},U=P=>{if(!P.cues)return;Array.from(P.cues).forEach(de=>ve(de,g));const Y=Array.from(P.activeCues??[]);if(Y.length<=1){Y.forEach(de=>ve(de,g));return}const{step:G,chars:j}=F();let nt=g;for(let de=Y.length-1;de>=0;de--){const Ve=String(Y[de].text??"").replace(/<[^>]*>/g,"").split(`
|
|
3
|
-
`).reduce((on,Lt)=>on+Math.max(1,Math.ceil(Lt.length/j)),0);nt=Math.max(0,nt-Ve*G),ve(Y[de],nt),nt-=G*.4}},B=re.current;if(B.length>0){B.forEach((P,Y)=>{const G=P.track;if(!G)return;const j=Y===J;G.mode=j&&!K?"showing":"hidden",j&&!K&&U(G)});return}const D=Array.from(e.textTracks);D.length!==0&&D.forEach((P,Y)=>{const G=Y===J;P.mode=G&&!K?"showing":"hidden",G&&!K&&U(P)})};s();const u=()=>s();e.textTracks.addEventListener("addtrack",u),e.addEventListener("loadedmetadata",s,{once:!0});const h=window.setTimeout(s,600);return()=>{e.textTracks.removeEventListener("addtrack",u),e.removeEventListener("loadedmetadata",s),window.clearTimeout(h)}},[J,pe,R,A,c,K,v.state.subtitleFontSize,v.state.subtitlePosition]),S(()=>{if(!K)return;const e=c.current,n=zt.current;if(!e||!n)return;const s=i/1e3,u=ct/1e3,h=new Set;let p=[],g=-1,F=-1,ve=-1,U=-1,B=0,D=0,P=!1;const Y=()=>{const W=Re.current;if(W<0)return null;const Fe=re.current;return Fe.length>0?Fe[W]?.track??null:Array.from(e.textTracks)[W]??null},G=(W,Fe)=>{const ue=W.cues;if(!ue||ue.length===0)return Array.from(W.activeCues??[]);let rt=0,st=ue.length;for(;rt<st;){const we=rt+st>>>1;ue[we].endTime+s<Fe?rt=we+1:st=we}const Rt=[];for(let we=rt;we<ue.length;we++){const ln=ue[we];if(ln.startTime+s>Fe)break;ln.endTime+s>=Fe&&Rt.push(ln)}return Rt},j=()=>{const W=Y(),Fe=e.currentTime-u,ue=W?G(W,Fe):[],rt=e.clientWidth,st=e.clientHeight,Rt=e.videoWidth,we=e.videoHeight;if(ue.length===p.length&&ue.every((Bn,Mn)=>Bn===p[Mn])&&rt===g&&st===F&&Rt===ve&&we===U||(p=ue,g=rt,F=st,ve=Rt,U=we,n.textContent="",ue.length===0))return;const sr={fontSize:$n(v.state.subtitleFontSize,st),position:v.state.subtitlePosition,bgOpacity:v.state.subtitleBgOpacity,bgColor:v.state.subtitleBgColor,textColor:v.state.subtitleTextColor,edge:v.state.subtitleEdge,bold:v.state.subtitleBold},Ar=ts(sr),Pr=ns(e,sr.position);ue.forEach((Bn,Mn)=>{const ar=String(Bn.text??"");if(!rs(ar).trim())return;const An=document.createElement("div"),Lr=(ue.length-1-Mn)*1.7;An.style.cssText=`${Ar}
|
|
4
|
-
bottom: calc(${Pr}px + ${Lr}em);`,An.innerHTML=ss(ar),n.appendChild(An)})},nt=()=>{Array.from(e.textTracks).forEach(W=>{h.has(W)||(h.add(W),W.addEventListener("cuechange",j))})},de=()=>{nt(),j()},In=()=>{if(P||D)return;const W=()=>{D=0,!(P||e.paused||e.ended)&&(j(),In())};D=window.requestAnimationFrame(W)},Ve=e,on=()=>{B=0,j(),!P&&Ve.requestVideoFrameCallback&&(B=Ve.requestVideoFrameCallback(on))},Lt=()=>{j(),Ve.requestVideoFrameCallback?B||(B=Ve.requestVideoFrameCallback(on)):In()};nt(),e.textTracks.addEventListener("addtrack",de),e.textTracks.addEventListener("removetrack",de),e.addEventListener("timeupdate",j),e.addEventListener("seeked",j),e.addEventListener("loadedmetadata",j),e.addEventListener("play",Lt);const nr=Array.from(e.querySelectorAll("track"));nr.forEach(W=>W.addEventListener("load",j));const rr=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>j());return rr?.observe(e),j(),Lt(),()=>{P=!0,h.forEach(W=>W.removeEventListener("cuechange",j)),e.textTracks.removeEventListener("addtrack",de),e.textTracks.removeEventListener("removetrack",de),e.removeEventListener("timeupdate",j),e.removeEventListener("seeked",j),e.removeEventListener("loadedmetadata",j),e.removeEventListener("play",Lt),nr.forEach(W=>W.removeEventListener("load",j)),rr?.disconnect(),D&&window.cancelAnimationFrame(D),B&&Ve.cancelVideoFrameCallback&&Ve.cancelVideoFrameCallback(B),n.textContent=""}},[K,i,J,pe,ct,c,v.state.subtitleFontSize,v.state.subtitlePosition,v.state.subtitleBgOpacity,v.state.subtitleBgColor,v.state.subtitleTextColor,v.state.subtitleEdge,v.state.subtitleBold]);const sn=()=>{M(null),je([]),ie(""),V(-1)},Ir=T(e=>{se(e),ye(1),Ne(e,1)},[Ne]),an=!l&&r?.seasons&&r.seasons.length>1?t("label",{className:b.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{value:o,onChange:e=>Ir(parseInt(e.target.value,10)||1),className:b.select,children:r.seasons.map(e=>t("option",{value:e.season_number,children:["Season ",e.season_number," (",e.episode_count," ep)"]},e.season_number))})]}):null,bt=T(e=>{const n=parseInt(e,10);if(!isNaN(n)){try{c.current?.pause()}catch{}ye(n),Ne(o,n)}Tn(!1)},[o,Ne,c]);S(()=>{if(l)return;const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="n"&&(w!=null?bt(String(w)):Fr.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[l,w,bt]);const Br=e=>{We(e);try{const s=X[e];s&&localStorage.setItem("tvLastAudio",Ln(s))}catch{}const n=le.current;n&&n.audioTrack!==void 0&&(n.audioTrack=e)},Mr=e=>{Te(e);try{if(e===-1)localStorage.setItem("tvSubtitlesEnabled","false");else{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e));const h=pe[e];h&&localStorage.setItem("tvLastSubtitle",Ln(h))}}catch{}const n=c.current,s=le.current;if(s&&typeof s.subtitleTrack=="number"&&Array.isArray(s.subtitleTracks)&&s.subtitleTracks.length>0&&(s.subtitleTrack=re.current.length>0||e<0?-1:e),!n)return;const u=re.current;if(u.length>0){u.forEach((h,p)=>{const g=h.track;if(!g)return;const F=p===e;g.mode=F&&!K?"showing":"hidden"});return}Array.from(n.textTracks).forEach((h,p)=>{const g=p===e;h.mode=g&&!K?"showing":"hidden"})},Pt=T(()=>{if(!r)return;const e=c.current,n=l?"":`S${String(o).padStart(2,"0")}E${String(f).padStart(2,"0")}`;yt.discord.tvPresence.mutate({title:r.title,episodeLabel:n,isPlaying:e?!e.paused&&!e.ended:!0,thumbnail:r.poster,currentTime:e?e.currentTime:0,duration:e&&e.duration||0,isAdult:r.adult===!0,sessionId:z.current}).catch(()=>{}),yt.discord.heartbeat.mutate({sessionId:z.current}).catch(()=>{})},[r,l,o,f,c]);return S(()=>{if(!r)return;Pt();const e=window.setInterval(()=>{const n=c.current;(!n||!n.paused)&&Pt()},15e3);return()=>window.clearInterval(e)},[Pt,r,c]),S(()=>{if(!r||R||Be||Pe||me.length===0)return;const e=c.current;if(!e)return;const n=()=>Pt();return e.addEventListener("play",n),e.addEventListener("pause",n),e.addEventListener("seeked",n),()=>{e.removeEventListener("play",n),e.removeEventListener("pause",n),e.removeEventListener("seeked",n)}},[r,R,Be,Pe,me,Pt,c]),S(()=>{const e=z.current,n=()=>jr(e),s=()=>n();return window.addEventListener("pagehide",s),window.addEventListener("beforeunload",s),()=>{window.removeEventListener("pagehide",s),window.removeEventListener("beforeunload",s),n()}},[]),S(()=>{if(!r){document.title="TV & Movies - dango";return}document.title=l?`${r.title} - dango`:`${r.title} - Season ${o} Episode ${f} - dango`},[r,l,o,f]),S(()=>{if(!r||l)return;const e=new URLSearchParams(k),n=e.get("s"),s=e.get("e"),u=String(o),h=String(f);n===u&&s===h||(e.set("type",k.get("type")||"tv"),e.set("s",u),e.set("e",h),V(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[r,l,o,f,k,V]),t("div",{className:at.playerPageLayout,children:[t("aside",{className:at.episodeSidebar,children:r?l?t("div",{className:b.sidebarPosterCard,children:[r.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"}),t("div",{className:b.sidebarPosterMeta,children:[t("strong",{children:r.title}),t("span",{children:r.year})]})]}):t(as,{episodes:er,currentEpisode:String(f),watchedEpisodes:Zn,onEpisodeClick:bt,header:an}):l?t("div",{className:b.statusMsg,children:[t(O,{name:"spinner",className:b.spinner})," Loading..."]}):t(os,{variant:"sidebar"})}),t("div",{className:at.playerMain,children:[r&&t("div",{className:b.playerSection,onContextMenu:e=>e.preventDefault(),style:r.adult&&!Qe?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:R&&Et?t("iframe",{src:Et,className:b.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!R&&(me.length>0||Be)?t(Ae,{children:[Pe&&t(lr,{error:Pe,servers:Z,selectedServer:ne,onRetry:rn,onSelect:wn}),t(da,{player:v,title:r.title,episodeLabel:l?void 0:`S${o} E${f}`,audioTracks:X,selectedAudioTrack:he,onAudioTrackChange:Br,subtitles:pe,selectedSubtitle:J,onSubtitleChange:Mr,streams:me,qualityIdx:N,onQualityChange:Q,onBack:sn,movyServers:Z,selectedMovyServer:ne,onMovyServerSelect:wn,isMovySource:Z.length>0,videoDelayEnabled:qe,onVideoDelayToggle:e=>{ot(e);try{localStorage.setItem("playerVideoDelayEnabled",String(e))}catch{}},videoDelayMs:Ue,onVideoDelayChange:qt,onCalibrateAvSync:Kt,subtitleDelayMs:i,onSubtitleDelayChange:ee,showNextEpisodeButton:ur&&!xe&&!ke&&!De,onNextEpisode:Qn,isLoading:Be,children:[t("video",{ref:c,autoPlay:Ze&&!Mt,playsInline:!0,disablePictureInPicture:!0,className:`${b.video} ${Ye?b.videoHidden:""}`,onTimeUpdate:yr,onEnded:()=>{Se||Sr()},onPlay:_r,onPause:Cr,onSeeked:()=>{qn.current=Date.now(),At()},onLoadedMetadata:Tr,onVolumeChange:v.actions.onVolumeChange,onWaiting:v.actions.onWaiting,onPlaying:v.actions.onPlaying,onCanPlay:v.actions.onCanPlay,onContextMenu:e=>e.preventDefault(),onError:()=>{C("Video failed to load. Try another server or reload."),_(!1)}}),t("canvas",{ref:Wt,className:`${b.delayCanvas} ${Ye?b.delayCanvasActive:""}`}),K&&t("div",{ref:zt,className:b.subtitleOverlay}),t(is,{isOpen:gn,ms:Ue,onChange:qt,onApply:Nt,onClose:Yt,testClipActive:Se,onTestClip:fn})]})]}):Pe&&!R?t(lr,{error:Pe,servers:Z,selectedServer:ne,onRetry:rn,onSelect:wn}):null}),r&&t(ls,{showTheater:!1}),an&&t("div",{className:b.mobileSeasonRow,children:an}),r&&t("div",{className:b.providerSelectWrap,children:t("label",{className:b.controlLabel,children:["Source",t("select",{value:A,onChange:e=>wr(e.target.value),className:b.select,disabled:oe.length===0,children:pn?t("option",{value:"",children:"Loading…"}):oe.length===0?t("option",{value:"",children:"No providers available"}):t(Ae,{children:[$t.length>0&&t("optgroup",{label:"Direct HLS",children:$t.map(e=>t("option",{value:e.id,children:e.label},e.id))}),Dt.length>0&&t("optgroup",{label:"Embeds",children:Dt.map(e=>t("option",{value:e.id,children:e.label},e.id))})]})})]})}),r&&t("div",{className:at.playerInfoContainer,children:[t("div",{className:at.playerInfoHeader,children:[t("div",{className:at.playerAnimeCard,children:r.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"})}),t("div",{className:at.videoTitleSection,children:[t("div",{className:be.titleContainer,children:[t("h1",{children:r.title}),t("div",{className:b.meta,children:[t("span",{className:b.year,children:r.year}),r.vote_average!=null&&r.vote_average>0&&t("span",{className:b.rating,children:[t(O,{name:"star",size:12}),Number(r.vote_average).toFixed(1)]}),t("span",{className:`${b.typeBadge} ${b[l?"movie":"tv"]}`,children:l?"Movie":"TV Show"})]}),tr.length>0&&t("div",{className:b.genreRow,children:tr.map(e=>t("span",{className:b.genreChip,children:e},e))}),Nn.length>0&&t("div",{className:b.metaRow,children:Nn.map((e,n)=>t("span",{children:[e,n<Nn.length-1?" · ":""]},`${e}-${n}`))})]}),t("div",{className:be.controls,children:[t("button",{className:`${be.watchlistBtn} ${mt?be.inList:""}`,onClick:dr,disabled:Qt,type:"button",children:[mt?t(O,{name:"check",size:14}):t(O,{name:"plus",size:14}),mt?"In Watchlist":"Add to Watchlist"]}),!l&&t(Ae,{children:[t("button",{className:`${be.watchlistBtn}`,onClick:()=>yn!=null&&bt(String(yn)),disabled:yn==null,type:"button",children:[t(O,{name:"chevron-left",size:14}),"Prev EP"]}),t("button",{className:`${be.watchlistBtn}`,onClick:()=>w!=null&&bt(String(w)),disabled:w==null,type:"button",children:["Next EP",t(O,{name:"chevron-right",size:14})]}),!l&&t("button",{className:`${be.watchlistBtn} ${be.modeToggleBtn} ${pt?be.modeToggleActive:""}`,onClick:()=>vr(!pt),type:"button","aria-pressed":pt,children:pt?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),gr&&t("button",{className:`${be.watchlistBtn}`,onClick:()=>Tn(!0),type:"button",children:[t(O,{name:"list-ul",size:14}),"Episodes"]})]})]})]})]}),t("div",{className:be.descriptionSection,children:[t("h3",{children:"Synopsis"}),t(ks,{text:r.overview,emptyText:"No description available."})]}),t("button",{className:be.detailsToggleBtn,onClick:()=>hr(!en),type:"button",children:[en?t(O,{name:"chevron-up"}):t(O,{name:"chevron-down"}),en?"Hide Details":"Show Details"]}),en&&t("div",{className:b.detailGrid,children:[r.first_air_date&&t("div",{className:b.detailItem,children:[t("strong",{children:l?"Release Date":"First Air Date"}),t("span",{children:r.first_air_date})]}),r.last_air_date&&t("div",{className:b.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:r.last_air_date})]}),r.networks&&r.networks.length>0&&t("div",{className:b.detailItem,children:[t("strong",{children:"Networks"}),t("span",{children:r.networks.map(e=>e.name).join(", ")})]}),r.created_by&&r.created_by.length>0&&t("div",{className:b.detailItem,children:[t("strong",{children:"Created By"}),t("span",{children:r.created_by.map(e=>e.name).join(", ")})]}),r.episode_run_time&&r.episode_run_time.length>0&&t("div",{className:b.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[r.episode_run_time[0]," min"]})]}),r.imdb_id&&t("div",{className:b.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${r.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:b.imdbLink,children:"View on IMDb"})]})]})]}),!l&&t(cs,{isOpen:pr,onClose:()=>Tn(!1),episodes:er,currentEpisode:String(f),watchedEpisodes:Zn,onEpisodeClick:bt,header:an}),r?.adult&&!Qe&&t(cn,{isOpen:!0,title:"Content Warning",onClose:sn,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(Ce,{variant:"secondary",onClick:sn,children:"Go Back"}),t(Ce,{onClick:I,children:"I'm 18+, Continue"})]})]})}),t(cn,{isOpen:xe,onClose:Yn,title:"Resume Watching",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:["You were at ",t("strong",{children:un(ht)})]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(Ce,{variant:"secondary",onClick:Yn,children:"Start from Beginning"}),t(Ce,{onClick:kr,children:"Resume"})]})]})}),t(cn,{isOpen:ke,onClose:Er,title:l?"Movie Completed":"Episode Completed",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:l?t(Ae,{children:"You've already watched this movie."}):t(Ae,{children:["You've already watched"," ",t("strong",{children:["Season ",o," Episode ",f]}),". Would you like to continue?"]})}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(Ce,{variant:"secondary",onClick:xr,children:"Replay"}),w!=null?t(Ce,{onClick:Qn,children:["Watch EP ",w]}):fe!=null?t(Ce,{onClick:Gn,children:["Start Season ",fe]}):null]})]})}),t(cn,{isOpen:De,onClose:()=>et(!1),title:l?"Movie Completed!":fe!=null?"Season Complete!":"Show Completed!",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t(O,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)",marginBottom:"0.5rem"}}),t("p",{style:{fontSize:"1.1rem",fontWeight:600},children:mr}),t("p",{style:{color:"var(--text-secondary)"},children:l?"You finished this movie!":fe!=null?`You finished Season ${o}.`:"Congratulations! You finished all available episodes."}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(Ce,{variant:"secondary",onClick:()=>et(!1),children:"Close"}),fe!=null?t(Ce,{onClick:Gn,children:["Start Season ",fe]}):t(Ae,{children:[t(Ce,{onClick:()=>{et(!1),sn()},children:"Back to Details"}),mt&&t(Ce,{onClick:Nr,disabled:_e.isPending,children:_e.isPending?"Saving...":"Move to Completed"})]})]})]})}),!r&&t("div",{className:b.statusMsg,children:[t(O,{name:"spinner",className:b.spinner})," Loading..."]})]})]})};export{xo as default};
|