@serifpersia/dango 3.6.1 → 3.6.3
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-DbrG4Bo-.js → AnimeCard-Cwc6Z9rO.js} +1 -1
- package/client/dist/assets/{AnimeInfo-CgSQGjef.js → AnimeInfo-ad7aMRq5.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-DSybdvf_.js → AnimeInfoPage-B795AIlr.js} +2 -2
- package/client/dist/assets/{Asmr-DFFV-7y4.js → Asmr-jqhD7q69.js} +2 -2
- package/client/dist/assets/{AsmrResetProgressModal-Brdfu_22.js → AsmrResetProgressModal-Bey2zoeh.js} +1 -1
- package/client/dist/assets/{AvSyncCalibrator-DBBUzoHn.js → AvSyncCalibrator-B2fQmjbo.js} +1 -1
- package/client/dist/assets/{Home-DjGl-3os.js → Home-rRTAnTfL.js} +1 -1
- package/client/dist/assets/{Insights-4O52Z1t2.js → Insights-CN2bm8wf.js} +1 -1
- package/client/dist/assets/{LibraryListPage-Z0w_rmHP.js → LibraryListPage-BlNQWLrf.js} +1 -1
- package/client/dist/assets/{ListeningList-DjbzDs1E.js → ListeningList-Pi1Baxgd.js} +1 -1
- package/client/dist/assets/{Manga-BRIDluzF.js → Manga-7Jt2tJyE.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-Q4CjEGJH.js → MangaInfoPage-45jPSjxB.js} +1 -1
- package/client/dist/assets/{MangaReadPage-BbJK5FY6.js → MangaReadPage-BWgX9bSn.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-BCFPXDF6.js → MangaResetProgressModal-DLgJrIVT.js} +1 -1
- package/client/dist/assets/{Mature-DjQzs66p.js → Mature-2I4mvoWk.js} +1 -1
- package/client/dist/assets/{MediaCard-DedwE5DX.js → MediaCard-cSWL_NlR.js} +1 -1
- package/client/dist/assets/{Music-z2RkiMDf.js → Music-bUuge7On.js} +1 -1
- package/client/dist/assets/{OptionListMenu-CetjZizt.js → OptionListMenu-D4ejupic.js} +1 -1
- package/client/dist/assets/Player-Fm7-Iaym.js +56 -0
- package/client/dist/assets/{PlayerSettings-ne_DQSTl.js → PlayerSettings-e_PohoiO.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-CIKT4YcD.js → QueueOptionsButton-BMl804vN.js} +1 -1
- package/client/dist/assets/{QueueRail-DPclldS0.js → QueueRail-BfNg-4sG.js} +1 -1
- package/client/dist/assets/{Radio-aeqPTMht.js → Radio-BbkMYqMU.js} +1 -1
- package/client/dist/assets/{ReadingList-p6G7NHtC.js → ReadingList-BN03nBXY.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-B7UuuL3X.js → ResetProgressModal-CuoM4S_P.js} +1 -1
- package/client/dist/assets/{Search-BzyHVByR.js → Search-DnBPEHjw.js} +1 -1
- package/client/dist/assets/{Settings-DMmtLUsL.js → Settings-CqiYnqx7.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-B5JXhZO4.js → SkeletonGrid-CYZ3cstC.js} +1 -1
- package/client/dist/assets/{Trackers-tLL1afjB.js → Trackers-DlkQl9Qs.js} +1 -1
- package/client/dist/assets/Tv-Ac8wPuCw.js +4 -0
- package/client/dist/assets/{TvInfo-DmrBLjgK.js → TvInfo-Dhv0lmCc.js} +1 -1
- package/client/dist/assets/{TvPopup-D1mSlOZt.js → TvPopup-5lwvCCOQ.js} +1 -1
- package/client/dist/assets/{TvSearch-BGQRUq9E.js → TvSearch-B3_Vf8Dk.js} +1 -1
- package/client/dist/assets/{TvWatchlist-DdLkpeQT.js → TvWatchlist-B_jtSOjL.js} +1 -1
- package/client/dist/assets/{Watchlist-BObmM6QB.js → Watchlist-BtFidAWI.js} +1 -1
- package/client/dist/assets/{hls-qCuNYJym.js → hls-CEWF8efn.js} +1 -1
- package/client/dist/assets/{index-B4AdKbhW.js → index-C93G341i.js} +2 -2
- package/client/dist/assets/{useAnimeInfoData-CSnwUBuU.js → useAnimeInfoData-gz0XXrYm.js} +1 -1
- package/client/dist/assets/{useAsmr-BKAaWEXn.js → useAsmr-BrRbA9AW.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-DDLRBLzz.js → useAsmrPopup-C4gKdZId.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-C6XEMuSr.js → useMangaLibrary-DkGSBFSX.js} +1 -1
- package/client/dist/assets/{useMangaPopup-wfCJubPD.js → useMangaPopup-DwKm2HYt.js} +1 -1
- package/client/dist/assets/{useProviders-C7jrBgxf.js → useProviders-C3E0fPpP.js} +1 -1
- package/client/dist/assets/{useTv-DM5KtzEc.js → useTv-BQ3K3Xdh.js} +1 -1
- package/client/dist/assets/{useTvLibrary-73NkS_5R.js → useTvLibrary-DizEfaXg.js} +1 -1
- package/client/dist/index.html +1 -1
- package/package.json +2 -2
- package/server/dist/lib/anilist.js +32 -4
- package/server/dist/providers/title-matching.js +2 -0
- package/server/dist/trpc/routers/data.js +1 -1
- package/server/package.json +1 -1
- package/client/dist/assets/Player-DD-9SgWU.js +0 -56
- package/client/dist/assets/Tv-CluLN4KA.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as y,h as A,u as e,A as R,g as Ie,S,$ as tt,p as nt,T as j}from"./vendor-core-DfaOB3Rn.js";import{t as Pe,O as it,h as H,z as $}from"./index-B4AdKbhW.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{r as p}from"./Radio.module-DGSZLpKM.js";import{a}from"./Asmr.module-CdWlioTY.js";import{b as ne,u as Ae,a as Ee}from"./vendor-query-BBT5_sHx.js";import{p as te}from"./page.module-C1MlZzf3.js";const pe=new Set,ue=new Map,qe=n=>`/api/image-proxy?url=${encodeURIComponent(n)}&strict=1`,ze=n=>/googleusercontent\.com/.test(n)?n.replace(/=w\d+-h\d+(?:-l\d+)?(?:-rj)?$/,"=w544-h544-l90-rj"):n,Ye=/^[A-Za-z0-9_-]{11}$/;function st(n,s){const l=[],b=n?ue.get(n):void 0;b&&!pe.has(b)&&l.push(b);for(const x of s??[]){if(!x?.url)continue;const w=qe(ze(x.url));pe.has(w)||l.includes(w)||l.push(w)}if(n&&Ye.test(n)){const x=qe(`https://i.ytimg.com/vi/${n}/hqdefault.jpg`);!pe.has(x)&&!l.includes(x)&&l.push(x)}return l}function at(n,s){const l=s?.[0]?.url;return l?ze(l):n&&Ye.test(n)?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:""}function rt(n,s){!n||pe.has(s)||(ue.set(n,s),ue.size>500&&ue.clear())}function ot(n){pe.add(n);for(const[s,l]of ue)l===n&&ue.delete(s)}function $e({id:n,thumbnails:s}){const[l,b]=y(0),[x,w]=y(!1);A(()=>{b(0),w(!1)},[n]);const _=st(n,s),E=_[l];return x||!E?e("span",{className:p.stationThumbPlaceholder,children:e(f,{name:"headphones"})}):e("img",{src:E,alt:"",className:p.stationThumb,loading:"lazy",decoding:"async",onLoad:()=>rt(n,E),onError:()=>{ot(E),l+1<_.length?b(l+1):w(!0)}})}function Ue(n){if(!Number.isFinite(n)||n<0)return"0:00";const s=Math.floor(n/60),l=Math.floor(n%60);return`${s}:${String(l).padStart(2,"0")}`}const ct=({track:n,shuffle:s,onToggleShuffle:l,onTrackStep:b,onTrackFailed:x,onClose:w,liked:_,likeVisible:E,likePending:de,onToggleLike:ie})=>{const O=R(null),me=R(!1),[T,se]=y(!1),[h,v]=y(!0),[V,B]=y(!1),[F,ae]=y(0),[Z,J]=y(0),[N,re]=y(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[z,oe]=y(()=>localStorage.getItem("musicAutoplay")!=="false"),L=R(N);L.current=N;const k=R(z);k.current=z;const W=R(0),D=R(0),Y=R(null),G=R("");G.current||(G.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const fe=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,q=Ie.useCallback(()=>{Y.current&&(window.clearTimeout(Y.current),Y.current=null)},[]),ce=Ie.useCallback(r=>{const c=O.current;if(!c)return;q(),v(!0),B(!1);const I=()=>{if(c.removeEventListener("loadedmetadata",I),r>5&&Number.isFinite(c.duration)&&r<c.duration-5)try{c.currentTime=r}catch{}};c.addEventListener("loadedmetadata",I),c.src=fe,c.load(),c.volume=L.current,c.play().catch(()=>{})},[fe,q]),ye=()=>{v(!1),B(!0),x?.(n),k.current&&b(1)},be=()=>{if(!Y.current){if(D.current>=3){ye();return}D.current+=1,Y.current=window.setTimeout(()=>{Y.current=null,ce(W.current)},5e3)}},Q=()=>{D.current=0,ce(W.current)};A(()=>{W.current=0,D.current=0,se(!1),ae(0),J(0);const r=O.current;return ce(W.current),()=>{q(),r&&r.removeAttribute("src")}},[ce,q]),A(()=>{const r=O.current;r&&(r.volume=N)},[N]),A(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const ve=at(n.id,n.thumbnails),K=Ie.useCallback(r=>{const c=O.current;Pe.discord.musicPresence.mutate({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:ve||"",currentTime:c?.currentTime??0,duration:Number.isFinite(c?.duration??NaN)?c?.duration:0,sessionId:G.current}).catch(()=>{}),Pe.discord.heartbeat.mutate({sessionId:G.current}).catch(()=>{})},[n,ve]);A(()=>{K(T)},[K,T,n.id]),A(()=>{if(!T)return;const r=window.setInterval(()=>K(!0),15e3);return()=>window.clearInterval(r)},[T,K]),A(()=>{const r=G.current,c=()=>it(r),I=()=>c(),U=()=>{document.visibilityState==="hidden"&&c()};return window.addEventListener("pagehide",I),window.addEventListener("beforeunload",I),document.addEventListener("visibilitychange",U),()=>{window.removeEventListener("pagehide",I),window.removeEventListener("beforeunload",I),document.removeEventListener("visibilitychange",U),c()}},[]);const Se=()=>{const r=O.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},ke=`${n.title} — ${n.artists}`,Ne=e(S,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>b(-1),"aria-label":"Previous track",children:e(f,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:Se,"aria-label":T?"Pause":"Play",children:T?e(f,{name:"pause"}):e(f,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>b(1),"aria-label":"Next track",children:e(f,{name:"step-forward"})}),V&&e("button",{className:a.playerBtn,onClick:Q,title:"Retry playback","aria-label":"Retry playback",children:e(f,{name:"redo"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:a.timeLabel,children:Ue(F)}),e("input",{className:a.seekBar,type:"range",min:0,max:Z||0,step:.1,value:Math.min(F,Z||0),onChange:r=>{const c=O.current;!c||!Number.isFinite(c.duration)||(c.currentTime=parseFloat(r.target.value),ae(c.currentTime))},onPointerDown:()=>{me.current=!0},onPointerUp:()=>{me.current=!1},style:{"--played-percent":`${Z>0?F/Z*100:0}%`},"aria-label":"Seek"}),e("span",{className:a.timeLabel,children:Ue(Z)}),h&&!V&&e("span",{className:a.timeLabel,children:"loading…"})]})]}),xe=e(S,{children:[e($e,{id:n.id,thumbnails:n.thumbnails}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:ke,children:ke}),e("p",{className:a.playerTrack,children:n.artists})]}),e("div",{className:a.playerControls,children:Ne}),e("div",{className:a.playerRight,children:[N===0?e(f,{name:"volume-mute",className:a.volumeIcon}):N<.5?e(f,{name:"volume-down",className:a.volumeIcon}):e(f,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:r=>{const c=parseFloat(r.target.value);re(c),localStorage.setItem("musicVolume",String(c))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[E&&ie&&e("button",{className:`${a.playerBtn} ${_?a.playerBtnActive:""}`,onClick:ie,disabled:de,title:_?"Remove from Liked Music":"Add to Liked Music","aria-label":_?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!_,children:e(f,{name:"heart"})}),e("button",{className:`${a.playerBtn} ${s?a.playerBtnActive:""}`,onClick:l,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(f,{name:"shuffle"})}),e("button",{className:`${a.playerBtn} ${z?a.playerBtnActive:""}`,onClick:()=>{oe(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:z?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":z,children:e(f,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:a.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(f,{name:"external-link-alt"})}),e("button",{className:a.playerBtn,onClick:w,"aria-label":"Close player",children:e(f,{name:"times"})})]})]});return tt(e(S,{children:[e("audio",{ref:O,preload:"none",onPlay:()=>{se(!0),v(!1),B(!1),D.current=0,q()},onPause:()=>se(!1),onWaiting:()=>{V||v(!0)},onPlaying:()=>{v(!1),D.current=0,q()},onTimeUpdate:r=>{const c=r.target.currentTime;W.current=c,q(),me.current||ae(c)},onStalled:()=>{be()},onLoadedMetadata:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onDurationChange:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onError:()=>{be()},onEnded:()=>{k.current&&b(1)}}),e("div",{className:a.playerBar,children:xe})]}),document.body)},lt=()=>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."})]})]}),ge=300*1e3,ut=()=>{const n=H();return ne({...n.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},dt=()=>{const n=H(),s=Ae();return Ee(n.music.authStart.mutationOptions({onSuccess:(l,b)=>{localStorage.setItem("ytmusic_cookie",b.cookie??""),s.invalidateQueries(n.music.pathFilter())}}))},mt=()=>{const n=H(),s=Ae();return Ee(n.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},ht=n=>{const s=H();return ne({...s.music.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:ge,retry:1})},pt=n=>{const s=H();return ne({...s.music.library.queryOptions(),enabled:n,staleTime:ge,retry:1})},gt=n=>{const s=H();return ne({...s.music.track.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},ft=n=>{const s=H();return ne({...s.music.playlist.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},yt=n=>{const s=H();return ne({...s.music.upnext.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},bt=n=>{const s=H();return ne({...s.music.likes.queryOptions(),enabled:n,staleTime:120*1e3,retry:1})},vt=()=>{const n=H(),s=Ae();return Ee(n.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},kt="_authRow_10tvv_1",Nt="_btn_10tvv_9",wt="_btnGhost_10tvv_42",St="_cookieForm_10tvv_74",xt="_cookieInput_10tvv_83",Tt="_link_10tvv_99",Lt="_contentLayout_10tvv_109",Mt="_mainCol_10tvv_116",_t="_upnextAside_10tvv_120",Ct="_upnextHeader_10tvv_131",Rt="_upnextTitle_10tvv_139",It="_upnextActions_10tvv_149",Pt="_nowPlayingLabel_10tvv_156",$t="_nowPlayingWrap_10tvv_168",At="_likeBtn_10tvv_172",Et="_likeActive_10tvv_196",g={authRow:kt,btn:Nt,btnGhost:wt,cookieForm:St,cookieInput:xt,link:Tt,contentLayout:Lt,mainCol:Mt,upnextAside:_t,upnextHeader:Ct,upnextTitle:Rt,upnextActions:It,nowPlayingLabel:Pt,nowPlayingWrap:$t,likeBtn:At,likeActive:Et};function He(n){const s=n.trim();if(!s)return null;const l=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return l||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const Ot="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Yt=()=>{const[n,s]=nt(),l=He(n.get("v")??""),[b,x]=y(()=>n.get("q")??""),w=n.get("q")??"";A(()=>{x(w)},[w]);const[_,E]=y(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[de,ie]=y(!1),[O,me]=y(()=>localStorage.getItem("musicShuffle")==="true"),[T,se]=y(()=>localStorage.getItem("musicRadio")!=="false"),[h,v]=y(null),[V,B]=y([]),[F,ae]=y(null),[Z,J]=y({}),N=R([]);N.current=V;const re=R(null);re.current=h;const z=R(!1),oe=R(new Set),{data:L}=ut(),k=dt(),W=mt(),D=typeof navigator<"u"?navigator.userAgent:"",Y=/android/i.test(D),G=/firefox|fxios/i.test(D)&&!Y,fe=!G&&!Y&&/chrome|chromium|edg|brave/i.test(D),q=G||fe,ce=()=>{if(de)return;ie(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),$.error("Helper not detected — install the Dango Helper extension first.")},3e3),o=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",o),ie(!1),m?.ok&&m.cookie){const u=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(u.includes("…")||u.includes("...")){$.error(`Helper returned a truncated cookie (${u.length} chars) — reload music.youtube.com and Extract again.`);return}E(u),$.success("Cookie extracted from helper — signing in…"),k.mutate({cookie:u})}else m?.error==="NO_COOKIE"?$.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):$.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",o),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ye,isLoading:be}=ht(w),{data:Q,isLoading:ve,isFetching:K,error:Se,refetch:ke}=pt(L?.authenticated===!0),{data:Ne,isLoading:xe}=ft(F?.id??null),{data:Te,isLoading:r}=yt(h?.id??null),{data:c}=bt(L?.authenticated===!0),I=vt(),U=j(()=>ye?.tracks||[],[ye]),Le=j(()=>Q?.playlists||[],[Q]),P=j(()=>Q?.tracks||[],[Q]),X=j(()=>Ne?.tracks||[],[Ne]),M=j(()=>{const t=Te?.tracks||[];return h?t.filter(i=>i.id!==h.id):t},[Te,h]),Ge=j(()=>new Set(c?.likedIds||[]),[c]),Me=t=>Z[t.id]??(Ge.has(t.id)||t.liked===!0);A(()=>{L?.authenticated!==!0&&J({})},[L?.authenticated]);const Qe=j(()=>[...U,...X,...P,...M],[U,X,P,M]),Ve=l&&h?.id!==l&&!Qe.some(t=>t.id===l)?l:null,{data:Oe}=gt(Ve),_e=h?.id;A(()=>{document.title=h?`${h.title} - dango`:"Music - dango"},[h]),A(()=>{if(!l){_e&&v(null);return}if(_e===l)return;const t=d=>{const m=d.find(u=>u.id===l);return m?(v(m),B(u=>u.some(le=>le.id===l)?u:d.length>0?d:[m]),!0):!1};if(t(U)||t(X)||t(P))return;const i=M.find(d=>d.id===l);if(i){v(i),B(d=>d.some(m=>m.id===i.id)?d:[i]);return}const o=Oe?.track;o&&o.id===l&&(v(o),B(d=>d.some(m=>m.id===o.id)?d:[o]))},[l,_e,U,X,P,M,Oe]);const ee=t=>{s(i=>{const o=new URLSearchParams(i);return t?o.set("v",t):o.delete("v"),o})},Ce=(t,i)=>{oe.current.delete(t.id),v(t),B(i.length>0?i:[t]),ee(t.id)},We=t=>{oe.current.add(t.id),$.error(`Couldn't play “${t.title}” — skipped.`)},je=async()=>{if(z.current)return;const t=N.current,i=t[t.length-1]??re.current;if(i){z.current=!0;try{const o=await Pe.music.upnext.query({id:i.id}),d=new Set(t.map(u=>u.id)),m=(o.tracks||[]).filter(u=>!d.has(u.id)&&!oe.current.has(u.id));if(m.length===0){const u=N.current[0];u&&(v(u),ee(u.id));return}B([...N.current,...m]),v(m[0]),ee(m[0].id)}catch{const o=N.current[0];o&&(v(o),ee(o.id))}finally{z.current=!1}}},Ze=t=>{const i=N.current,o=re.current;if(!o||i.length===0)return;const d=i.findIndex(C=>C.id===o.id);if(t>0&&T&&(d<0||d===i.length-1)){je();return}const m=C=>oe.current.has(C.id),u=i.length;let le;if(O&&u>1){let C=Math.floor(Math.random()*u);for(let Re=0;Re<u&&(C===d||m(i[C]));Re++)C=Math.floor(Math.random()*u);le=i[C]}else{const C=t>0?1:-1;let we=(((d<0?C>0?-1:0:d)+C)%u+u)%u;for(let De=1;De<u&&m(i[we]);De++)we=((we+C)%u+u)%u;le=i[we]}v(le),ee(le.id)},Je=()=>{if(T){se(!1),localStorage.setItem("musicRadio","false");return}const t=re.current;if(!t)return;if(M.length===0){$.error("No radio suggestions for this song yet.");return}const i=new Set,o=[];for(const d of[t,...M])i.has(d.id)||(i.add(d.id),o.push(d));se(!0),localStorage.setItem("musicRadio","true"),B(o),$.success(`Radio started — ${M.length} songs queued.`)},Be=t=>{if(L?.authenticated!==!0){$.error("Sign in to like songs.");return}const i=!Me(t);J(o=>({...o,[t.id]:i})),I.mutate({id:t.id,like:i},{onError:()=>{J(o=>{const d={...o};return delete d[t.id],d}),$.error("Like action failed — try again.")}})},Ke=()=>{me(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Xe=t=>e("button",{className:p.stationRow,onClick:()=>ae(t),"aria-label":`Open ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),t.subtitle&&e("span",{className:p.stationSub,children:t.subtitle})]})]},t.id),he=(t,i,o)=>{const d=h?.id===t.id,m=Me(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${p.stationRow} ${d?p.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>o?o(t):Ce(t,i),className:p.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),e("span",{className:p.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),L?.authenticated===!0&&e("button",{className:`${g.likeBtn} ${m?g.likeActive:""}`,onClick:()=>Be(t),disabled:I.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(f,{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(f,{name:"external-link-alt"})})]},t.id)},Fe=j(()=>{if(!h)return M;const t=new Set,i=[];for(const o of[h,...M])t.has(o.id)||(t.add(o.id),i.push(o));return i},[h,M]),et=t=>{Ce(t,Fe)};return e("div",{className:`${te.page} ${h?te.pageWithPlayer:""}`,children:[e("div",{className:te.header,children:[e("h1",{className:te.pageTitle,children:[e(f,{name:"headphones"})," Music"]}),e("form",{className:te.searchForm,onSubmit:t=>{t.preventDefault();const i=He(b);if(i)ee(i);else{const o=b.trim();s(d=>{const m=new URLSearchParams(d);return o?m.set("q",o):m.delete("q"),m})}},children:[e("input",{className:te.searchInput,value:b,onChange:t=>x(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:te.searchBtn,type:"submit","aria-label":"Search",children:e(f,{name:"search"})})]})]}),e("div",{className:g.authRow,children:[L?.authenticated?e(S,{children:[e("span",{className:a.statusMsg,children:["Signed in to YouTube Music",Q&&` — ${Q.tracks.length} songs, ${Q.playlists.length} playlists`]}),e("button",{className:g.btnGhost,onClick:()=>W.mutate(),disabled:W.isPending,children:"Sign out"})]}):e(S,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=_.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){$.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==_&&E(i),k.mutate({cookie:i})}},className:g.cookieForm,children:[e("input",{className:g.cookieInput,value:_,onChange:t=>E(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:g.btn,type:"submit",disabled:k.isPending||!_.trim(),children:k.isPending?"Checking…":"Sign in"}),q&&e("button",{className:g.btnGhost,type:"button",onClick:ce,disabled:de||k.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:de?"Extracting…":"Extract from helper"})]}),q&&e("p",{className:a.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Ot,target:"_blank",rel:"noreferrer",className:g.link,children:"dango-extension.zip"})," ","then"," ",G?e(S,{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(S,{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(lt,{})]}),k.isSuccess&&e("p",{className:a.statusMsg,children:["Signed in — found ",k.data.tracks," songs and ",k.data.playlists," ","playlists."]}),k.isError&&e("p",{className:a.statusMsg,children:k.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!L?.authenticated&&!k.isError&&!k.isSuccess&&e("p",{className:a.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:h?g.contentLayout:void 0,children:[e("div",{className:g.mainCol,children:w?e(S,{children:[e("h2",{className:p.sectionTitle,children:["Results for “",w,"”"]}),be?e("p",{className:a.statusMsg,children:"Searching…"}):U.length===0?e("p",{className:a.statusMsg,children:"No tracks found."}):e("div",{className:p.stationList,children:U.map(t=>he(t,U))})]}):L?.authenticated?e(S,{children:[e("h2",{className:p.sectionTitle,children:"Your library"}),ve?e("p",{className:a.statusMsg,children:"Loading library…"}):Le.length===0&&P.length===0&&!F?e(S,{children:[e("p",{className:a.statusMsg,children:Se?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>{ke()},disabled:K,"aria-label":"Retry loading library",children:K?"Retrying…":"Retry"})}),e("p",{className:a.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(S,{children:[Le.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:"Playlists"}),e("div",{className:p.stationList,children:Le.map(t=>Xe(t))})]}),P.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:["Liked songs (",P.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>Ce(P[0],P),"aria-label":"Play all liked songs",children:[e(f,{name:"play"})," Play all"]})}),e("div",{className:p.stationList,children:P.map(t=>he(t,P))})]}),F?e(S,{children:[e("button",{className:g.btnGhost,onClick:()=>ae(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:p.sectionTitle,children:F.title}),xe?e("p",{className:a.statusMsg,children:"Loading playlist…"}):X.length===0?e("p",{className:a.statusMsg,children:"No tracks in this playlist."}):e("div",{className:p.stationList,children:X.map(t=>he(t,X))})]}):null]})]}):e("p",{className:a.statusMsg,children:"Search above, or sign in to see your library."})}),h&&e("aside",{className:g.upnextAside,"aria-label":"Up next",children:[e("div",{className:g.upnextHeader,children:e("span",{className:g.upnextTitle,children:[e(f,{name:"list-ul"})," Up Next"]})}),e("div",{className:g.nowPlayingWrap,children:[e("p",{className:g.nowPlayingLabel,children:"Now playing"}),he(h,V.length>0?V:[h])]}),e("div",{className:g.upnextActions,children:e("button",{className:g.btnGhost,onClick:Je,disabled:!T&&(r||M.length===0),"aria-pressed":T,title:T?"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:T?"Stop radio":"Start radio"})}),r?e("p",{className:a.statusMsg,children:"Loading suggestions…"}):M.length===0?e("p",{className:a.statusMsg,children:"No suggestions for this song."}):e("div",{className:p.stationList,children:M.map(t=>he(t,Fe,et))})]})]}),h&&e(ct,{track:h,queue:V,shuffle:O,onToggleShuffle:Ke,onTrackStep:Ze,onTrackFailed:We,onClose:()=>{v(null),ee(null)},liked:h?Me(h):!1,likeVisible:L?.authenticated===!0,likePending:I.isPending,onToggleLike:()=>Be(h)})]})};export{Yt as default};
|
|
1
|
+
import{d as y,h as A,u as e,A as R,g as Pe,S,$ as tt,p as nt,T as j}from"./vendor-core-DfaOB3Rn.js";import{t as Ie,P as it,h as H,z as $}from"./index-C93G341i.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{r as p}from"./Radio.module-DGSZLpKM.js";import{a}from"./Asmr.module-CdWlioTY.js";import{b as ne,u as Ae,a as Ee}from"./vendor-query-BBT5_sHx.js";import{p as te}from"./page.module-C1MlZzf3.js";const pe=new Set,ue=new Map,qe=n=>`/api/image-proxy?url=${encodeURIComponent(n)}&strict=1`,ze=n=>/googleusercontent\.com/.test(n)?n.replace(/=w\d+-h\d+(?:-l\d+)?(?:-rj)?$/,"=w544-h544-l90-rj"):n,Ye=/^[A-Za-z0-9_-]{11}$/;function st(n,s){const l=[],b=n?ue.get(n):void 0;b&&!pe.has(b)&&l.push(b);for(const x of s??[]){if(!x?.url)continue;const w=qe(ze(x.url));pe.has(w)||l.includes(w)||l.push(w)}if(n&&Ye.test(n)){const x=qe(`https://i.ytimg.com/vi/${n}/hqdefault.jpg`);!pe.has(x)&&!l.includes(x)&&l.push(x)}return l}function at(n,s){const l=s?.[0]?.url;return l?ze(l):n&&Ye.test(n)?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:""}function rt(n,s){!n||pe.has(s)||(ue.set(n,s),ue.size>500&&ue.clear())}function ot(n){pe.add(n);for(const[s,l]of ue)l===n&&ue.delete(s)}function $e({id:n,thumbnails:s}){const[l,b]=y(0),[x,w]=y(!1);A(()=>{b(0),w(!1)},[n]);const _=st(n,s),E=_[l];return x||!E?e("span",{className:p.stationThumbPlaceholder,children:e(f,{name:"headphones"})}):e("img",{src:E,alt:"",className:p.stationThumb,loading:"lazy",decoding:"async",onLoad:()=>rt(n,E),onError:()=>{ot(E),l+1<_.length?b(l+1):w(!0)}})}function Ue(n){if(!Number.isFinite(n)||n<0)return"0:00";const s=Math.floor(n/60),l=Math.floor(n%60);return`${s}:${String(l).padStart(2,"0")}`}const ct=({track:n,shuffle:s,onToggleShuffle:l,onTrackStep:b,onTrackFailed:x,onClose:w,liked:_,likeVisible:E,likePending:de,onToggleLike:ie})=>{const O=R(null),me=R(!1),[T,se]=y(!1),[h,v]=y(!0),[V,B]=y(!1),[F,ae]=y(0),[Z,J]=y(0),[N,re]=y(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[z,oe]=y(()=>localStorage.getItem("musicAutoplay")!=="false"),L=R(N);L.current=N;const k=R(z);k.current=z;const W=R(0),D=R(0),Y=R(null),G=R("");G.current||(G.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const fe=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,q=Pe.useCallback(()=>{Y.current&&(window.clearTimeout(Y.current),Y.current=null)},[]),ce=Pe.useCallback(r=>{const c=O.current;if(!c)return;q(),v(!0),B(!1);const P=()=>{if(c.removeEventListener("loadedmetadata",P),r>5&&Number.isFinite(c.duration)&&r<c.duration-5)try{c.currentTime=r}catch{}};c.addEventListener("loadedmetadata",P),c.src=fe,c.load(),c.volume=L.current,c.play().catch(()=>{})},[fe,q]),ye=()=>{v(!1),B(!0),x?.(n),k.current&&b(1)},be=()=>{if(!Y.current){if(D.current>=3){ye();return}D.current+=1,Y.current=window.setTimeout(()=>{Y.current=null,ce(W.current)},5e3)}},Q=()=>{D.current=0,ce(W.current)};A(()=>{W.current=0,D.current=0,se(!1),ae(0),J(0);const r=O.current;return ce(W.current),()=>{q(),r&&r.removeAttribute("src")}},[ce,q]),A(()=>{const r=O.current;r&&(r.volume=N)},[N]),A(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const ve=at(n.id,n.thumbnails),K=Pe.useCallback(r=>{const c=O.current;Ie.discord.musicPresence.mutate({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:ve||"",currentTime:c?.currentTime??0,duration:Number.isFinite(c?.duration??NaN)?c?.duration:0,sessionId:G.current}).catch(()=>{}),Ie.discord.heartbeat.mutate({sessionId:G.current}).catch(()=>{})},[n,ve]);A(()=>{K(T)},[K,T,n.id]),A(()=>{if(!T)return;const r=window.setInterval(()=>K(!0),15e3);return()=>window.clearInterval(r)},[T,K]),A(()=>{const r=G.current,c=()=>it(r),P=()=>c(),U=()=>{document.visibilityState==="hidden"&&c()};return window.addEventListener("pagehide",P),window.addEventListener("beforeunload",P),document.addEventListener("visibilitychange",U),()=>{window.removeEventListener("pagehide",P),window.removeEventListener("beforeunload",P),document.removeEventListener("visibilitychange",U),c()}},[]);const Se=()=>{const r=O.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},ke=`${n.title} — ${n.artists}`,Ne=e(S,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>b(-1),"aria-label":"Previous track",children:e(f,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:Se,"aria-label":T?"Pause":"Play",children:T?e(f,{name:"pause"}):e(f,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>b(1),"aria-label":"Next track",children:e(f,{name:"step-forward"})}),V&&e("button",{className:a.playerBtn,onClick:Q,title:"Retry playback","aria-label":"Retry playback",children:e(f,{name:"redo"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:a.timeLabel,children:Ue(F)}),e("input",{className:a.seekBar,type:"range",min:0,max:Z||0,step:.1,value:Math.min(F,Z||0),onChange:r=>{const c=O.current;!c||!Number.isFinite(c.duration)||(c.currentTime=parseFloat(r.target.value),ae(c.currentTime))},onPointerDown:()=>{me.current=!0},onPointerUp:()=>{me.current=!1},style:{"--played-percent":`${Z>0?F/Z*100:0}%`},"aria-label":"Seek"}),e("span",{className:a.timeLabel,children:Ue(Z)}),h&&!V&&e("span",{className:a.timeLabel,children:"loading…"})]})]}),xe=e(S,{children:[e($e,{id:n.id,thumbnails:n.thumbnails}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:ke,children:ke}),e("p",{className:a.playerTrack,children:n.artists})]}),e("div",{className:a.playerControls,children:Ne}),e("div",{className:a.playerRight,children:[N===0?e(f,{name:"volume-mute",className:a.volumeIcon}):N<.5?e(f,{name:"volume-down",className:a.volumeIcon}):e(f,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:r=>{const c=parseFloat(r.target.value);re(c),localStorage.setItem("musicVolume",String(c))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[E&&ie&&e("button",{className:`${a.playerBtn} ${_?a.playerBtnActive:""}`,onClick:ie,disabled:de,title:_?"Remove from Liked Music":"Add to Liked Music","aria-label":_?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!_,children:e(f,{name:"heart"})}),e("button",{className:`${a.playerBtn} ${s?a.playerBtnActive:""}`,onClick:l,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(f,{name:"shuffle"})}),e("button",{className:`${a.playerBtn} ${z?a.playerBtnActive:""}`,onClick:()=>{oe(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:z?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":z,children:e(f,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:a.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(f,{name:"external-link-alt"})}),e("button",{className:a.playerBtn,onClick:w,"aria-label":"Close player",children:e(f,{name:"times"})})]})]});return tt(e(S,{children:[e("audio",{ref:O,preload:"none",onPlay:()=>{se(!0),v(!1),B(!1),D.current=0,q()},onPause:()=>se(!1),onWaiting:()=>{V||v(!0)},onPlaying:()=>{v(!1),D.current=0,q()},onTimeUpdate:r=>{const c=r.target.currentTime;W.current=c,q(),me.current||ae(c)},onStalled:()=>{be()},onLoadedMetadata:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onDurationChange:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onError:()=>{be()},onEnded:()=>{k.current&&b(1)}}),e("div",{className:a.playerBar,children:xe})]}),document.body)},lt=()=>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."})]})]}),ge=300*1e3,ut=()=>{const n=H();return ne({...n.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},dt=()=>{const n=H(),s=Ae();return Ee(n.music.authStart.mutationOptions({onSuccess:(l,b)=>{localStorage.setItem("ytmusic_cookie",b.cookie??""),s.invalidateQueries(n.music.pathFilter())}}))},mt=()=>{const n=H(),s=Ae();return Ee(n.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},ht=n=>{const s=H();return ne({...s.music.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:ge,retry:1})},pt=n=>{const s=H();return ne({...s.music.library.queryOptions(),enabled:n,staleTime:ge,retry:1})},gt=n=>{const s=H();return ne({...s.music.track.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},ft=n=>{const s=H();return ne({...s.music.playlist.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},yt=n=>{const s=H();return ne({...s.music.upnext.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},bt=n=>{const s=H();return ne({...s.music.likes.queryOptions(),enabled:n,staleTime:120*1e3,retry:1})},vt=()=>{const n=H(),s=Ae();return Ee(n.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},kt="_authRow_10tvv_1",Nt="_btn_10tvv_9",wt="_btnGhost_10tvv_42",St="_cookieForm_10tvv_74",xt="_cookieInput_10tvv_83",Tt="_link_10tvv_99",Lt="_contentLayout_10tvv_109",Mt="_mainCol_10tvv_116",_t="_upnextAside_10tvv_120",Ct="_upnextHeader_10tvv_131",Rt="_upnextTitle_10tvv_139",Pt="_upnextActions_10tvv_149",It="_nowPlayingLabel_10tvv_156",$t="_nowPlayingWrap_10tvv_168",At="_likeBtn_10tvv_172",Et="_likeActive_10tvv_196",g={authRow:kt,btn:Nt,btnGhost:wt,cookieForm:St,cookieInput:xt,link:Tt,contentLayout:Lt,mainCol:Mt,upnextAside:_t,upnextHeader:Ct,upnextTitle:Rt,upnextActions:Pt,nowPlayingLabel:It,nowPlayingWrap:$t,likeBtn:At,likeActive:Et};function He(n){const s=n.trim();if(!s)return null;const l=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return l||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const Ot="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Yt=()=>{const[n,s]=nt(),l=He(n.get("v")??""),[b,x]=y(()=>n.get("q")??""),w=n.get("q")??"";A(()=>{x(w)},[w]);const[_,E]=y(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[de,ie]=y(!1),[O,me]=y(()=>localStorage.getItem("musicShuffle")==="true"),[T,se]=y(()=>localStorage.getItem("musicRadio")!=="false"),[h,v]=y(null),[V,B]=y([]),[F,ae]=y(null),[Z,J]=y({}),N=R([]);N.current=V;const re=R(null);re.current=h;const z=R(!1),oe=R(new Set),{data:L}=ut(),k=dt(),W=mt(),D=typeof navigator<"u"?navigator.userAgent:"",Y=/android/i.test(D),G=/firefox|fxios/i.test(D)&&!Y,fe=!G&&!Y&&/chrome|chromium|edg|brave/i.test(D),q=G||fe,ce=()=>{if(de)return;ie(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),$.error("Helper not detected — install the Dango Helper extension first.")},3e3),o=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",o),ie(!1),m?.ok&&m.cookie){const u=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(u.includes("…")||u.includes("...")){$.error(`Helper returned a truncated cookie (${u.length} chars) — reload music.youtube.com and Extract again.`);return}E(u),$.success("Cookie extracted from helper — signing in…"),k.mutate({cookie:u})}else m?.error==="NO_COOKIE"?$.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):$.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",o),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ye,isLoading:be}=ht(w),{data:Q,isLoading:ve,isFetching:K,error:Se,refetch:ke}=pt(L?.authenticated===!0),{data:Ne,isLoading:xe}=ft(F?.id??null),{data:Te,isLoading:r}=yt(h?.id??null),{data:c}=bt(L?.authenticated===!0),P=vt(),U=j(()=>ye?.tracks||[],[ye]),Le=j(()=>Q?.playlists||[],[Q]),I=j(()=>Q?.tracks||[],[Q]),X=j(()=>Ne?.tracks||[],[Ne]),M=j(()=>{const t=Te?.tracks||[];return h?t.filter(i=>i.id!==h.id):t},[Te,h]),Ge=j(()=>new Set(c?.likedIds||[]),[c]),Me=t=>Z[t.id]??(Ge.has(t.id)||t.liked===!0);A(()=>{L?.authenticated!==!0&&J({})},[L?.authenticated]);const Qe=j(()=>[...U,...X,...I,...M],[U,X,I,M]),Ve=l&&h?.id!==l&&!Qe.some(t=>t.id===l)?l:null,{data:Oe}=gt(Ve),_e=h?.id;A(()=>{document.title=h?`${h.title} - dango`:"Music - dango"},[h]),A(()=>{if(!l){_e&&v(null);return}if(_e===l)return;const t=d=>{const m=d.find(u=>u.id===l);return m?(v(m),B(u=>u.some(le=>le.id===l)?u:d.length>0?d:[m]),!0):!1};if(t(U)||t(X)||t(I))return;const i=M.find(d=>d.id===l);if(i){v(i),B(d=>d.some(m=>m.id===i.id)?d:[i]);return}const o=Oe?.track;o&&o.id===l&&(v(o),B(d=>d.some(m=>m.id===o.id)?d:[o]))},[l,_e,U,X,I,M,Oe]);const ee=t=>{s(i=>{const o=new URLSearchParams(i);return t?o.set("v",t):o.delete("v"),o})},Ce=(t,i)=>{oe.current.delete(t.id),v(t),B(i.length>0?i:[t]),ee(t.id)},We=t=>{oe.current.add(t.id),$.error(`Couldn't play “${t.title}” — skipped.`)},je=async()=>{if(z.current)return;const t=N.current,i=t[t.length-1]??re.current;if(i){z.current=!0;try{const o=await Ie.music.upnext.query({id:i.id}),d=new Set(t.map(u=>u.id)),m=(o.tracks||[]).filter(u=>!d.has(u.id)&&!oe.current.has(u.id));if(m.length===0){const u=N.current[0];u&&(v(u),ee(u.id));return}B([...N.current,...m]),v(m[0]),ee(m[0].id)}catch{const o=N.current[0];o&&(v(o),ee(o.id))}finally{z.current=!1}}},Ze=t=>{const i=N.current,o=re.current;if(!o||i.length===0)return;const d=i.findIndex(C=>C.id===o.id);if(t>0&&T&&(d<0||d===i.length-1)){je();return}const m=C=>oe.current.has(C.id),u=i.length;let le;if(O&&u>1){let C=Math.floor(Math.random()*u);for(let Re=0;Re<u&&(C===d||m(i[C]));Re++)C=Math.floor(Math.random()*u);le=i[C]}else{const C=t>0?1:-1;let we=(((d<0?C>0?-1:0:d)+C)%u+u)%u;for(let De=1;De<u&&m(i[we]);De++)we=((we+C)%u+u)%u;le=i[we]}v(le),ee(le.id)},Je=()=>{if(T){se(!1),localStorage.setItem("musicRadio","false");return}const t=re.current;if(!t)return;if(M.length===0){$.error("No radio suggestions for this song yet.");return}const i=new Set,o=[];for(const d of[t,...M])i.has(d.id)||(i.add(d.id),o.push(d));se(!0),localStorage.setItem("musicRadio","true"),B(o),$.success(`Radio started — ${M.length} songs queued.`)},Be=t=>{if(L?.authenticated!==!0){$.error("Sign in to like songs.");return}const i=!Me(t);J(o=>({...o,[t.id]:i})),P.mutate({id:t.id,like:i},{onError:()=>{J(o=>{const d={...o};return delete d[t.id],d}),$.error("Like action failed — try again.")}})},Ke=()=>{me(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Xe=t=>e("button",{className:p.stationRow,onClick:()=>ae(t),"aria-label":`Open ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),t.subtitle&&e("span",{className:p.stationSub,children:t.subtitle})]})]},t.id),he=(t,i,o)=>{const d=h?.id===t.id,m=Me(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${p.stationRow} ${d?p.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>o?o(t):Ce(t,i),className:p.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),e("span",{className:p.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),L?.authenticated===!0&&e("button",{className:`${g.likeBtn} ${m?g.likeActive:""}`,onClick:()=>Be(t),disabled:P.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(f,{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(f,{name:"external-link-alt"})})]},t.id)},Fe=j(()=>{if(!h)return M;const t=new Set,i=[];for(const o of[h,...M])t.has(o.id)||(t.add(o.id),i.push(o));return i},[h,M]),et=t=>{Ce(t,Fe)};return e("div",{className:`${te.page} ${h?te.pageWithPlayer:""}`,children:[e("div",{className:te.header,children:[e("h1",{className:te.pageTitle,children:[e(f,{name:"headphones"})," Music"]}),e("form",{className:te.searchForm,onSubmit:t=>{t.preventDefault();const i=He(b);if(i)ee(i);else{const o=b.trim();s(d=>{const m=new URLSearchParams(d);return o?m.set("q",o):m.delete("q"),m})}},children:[e("input",{className:te.searchInput,value:b,onChange:t=>x(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:te.searchBtn,type:"submit","aria-label":"Search",children:e(f,{name:"search"})})]})]}),e("div",{className:g.authRow,children:[L?.authenticated?e(S,{children:[e("span",{className:a.statusMsg,children:["Signed in to YouTube Music",Q&&` — ${Q.tracks.length} songs, ${Q.playlists.length} playlists`]}),e("button",{className:g.btnGhost,onClick:()=>W.mutate(),disabled:W.isPending,children:"Sign out"})]}):e(S,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=_.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){$.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==_&&E(i),k.mutate({cookie:i})}},className:g.cookieForm,children:[e("input",{className:g.cookieInput,value:_,onChange:t=>E(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:g.btn,type:"submit",disabled:k.isPending||!_.trim(),children:k.isPending?"Checking…":"Sign in"}),q&&e("button",{className:g.btnGhost,type:"button",onClick:ce,disabled:de||k.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:de?"Extracting…":"Extract from helper"})]}),q&&e("p",{className:a.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Ot,target:"_blank",rel:"noreferrer",className:g.link,children:"dango-extension.zip"})," ","then"," ",G?e(S,{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(S,{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(lt,{})]}),k.isSuccess&&e("p",{className:a.statusMsg,children:["Signed in — found ",k.data.tracks," songs and ",k.data.playlists," ","playlists."]}),k.isError&&e("p",{className:a.statusMsg,children:k.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!L?.authenticated&&!k.isError&&!k.isSuccess&&e("p",{className:a.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:h?g.contentLayout:void 0,children:[e("div",{className:g.mainCol,children:w?e(S,{children:[e("h2",{className:p.sectionTitle,children:["Results for “",w,"”"]}),be?e("p",{className:a.statusMsg,children:"Searching…"}):U.length===0?e("p",{className:a.statusMsg,children:"No tracks found."}):e("div",{className:p.stationList,children:U.map(t=>he(t,U))})]}):L?.authenticated?e(S,{children:[e("h2",{className:p.sectionTitle,children:"Your library"}),ve?e("p",{className:a.statusMsg,children:"Loading library…"}):Le.length===0&&I.length===0&&!F?e(S,{children:[e("p",{className:a.statusMsg,children:Se?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>{ke()},disabled:K,"aria-label":"Retry loading library",children:K?"Retrying…":"Retry"})}),e("p",{className:a.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(S,{children:[Le.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:"Playlists"}),e("div",{className:p.stationList,children:Le.map(t=>Xe(t))})]}),I.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:["Liked songs (",I.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>Ce(I[0],I),"aria-label":"Play all liked songs",children:[e(f,{name:"play"})," Play all"]})}),e("div",{className:p.stationList,children:I.map(t=>he(t,I))})]}),F?e(S,{children:[e("button",{className:g.btnGhost,onClick:()=>ae(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:p.sectionTitle,children:F.title}),xe?e("p",{className:a.statusMsg,children:"Loading playlist…"}):X.length===0?e("p",{className:a.statusMsg,children:"No tracks in this playlist."}):e("div",{className:p.stationList,children:X.map(t=>he(t,X))})]}):null]})]}):e("p",{className:a.statusMsg,children:"Search above, or sign in to see your library."})}),h&&e("aside",{className:g.upnextAside,"aria-label":"Up next",children:[e("div",{className:g.upnextHeader,children:e("span",{className:g.upnextTitle,children:[e(f,{name:"list-ul"})," Up Next"]})}),e("div",{className:g.nowPlayingWrap,children:[e("p",{className:g.nowPlayingLabel,children:"Now playing"}),he(h,V.length>0?V:[h])]}),e("div",{className:g.upnextActions,children:e("button",{className:g.btnGhost,onClick:Je,disabled:!T&&(r||M.length===0),"aria-pressed":T,title:T?"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:T?"Stop radio":"Start radio"})}),r?e("p",{className:a.statusMsg,children:"Loading suggestions…"}):M.length===0?e("p",{className:a.statusMsg,children:"No suggestions for this song."}):e("div",{className:p.stationList,children:M.map(t=>he(t,Fe,et))})]})]}),h&&e(ct,{track:h,queue:V,shuffle:O,onToggleShuffle:Ke,onTrackStep:Ze,onTrackFailed:We,onClose:()=>{v(null),ee(null)},liked:h?Me(h):!1,likeVisible:L?.authenticated===!0,likePending:P.isPending,onToggleLike:()=>Be(h)})]})};export{Yt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,S as s,d as y,h as g}from"./vendor-core-DfaOB3Rn.js";import{I as p}from"./vendor-icons-DrybRNxP.js";import{M as l,I as m,T as S,J as f,K as k,L as x,N}from"./AvSyncCalibrator-
|
|
1
|
+
import{u as e,S as s,d as y,h as g}from"./vendor-core-DfaOB3Rn.js";import{I as p}from"./vendor-icons-DrybRNxP.js";import{M as l,I as m,T as S,J as f,K as k,L as x,N}from"./AvSyncCalibrator-B2fQmjbo.js";const C=({classes:o,title:t,titleTag:i="span",showBack:a=!0,onBack:n,panelRef:b,onPanelClick:r,children:c})=>{const d=i;return e("div",{ref:b,className:o.panel,onClick:r,"data-speed-boost-ignore":"true",children:[e("div",{className:o.header,children:[a&&e("button",{className:o.backBtn,onClick:n,children:e(p,{name:"chevron-left"})}),e(d,{className:o.title||void 0,children:t})]}),e("div",{className:o.content,children:c})]})},$=({classes:o,values:t,onChange:i})=>{const a=()=>{const n=x;i("fontSize",n.fontSize),i("position",n.position),i("bgOpacity",n.bgOpacity),i("bgColor",n.bgColor),i("textColor",n.textColor),i("edge",n.edge),i("bold",n.bold)};return e(s,{children:[e(l,{label:"Font Size",display:t.fontSize.toFixed(1),min:.5,max:10,step:.5,value:t.fontSize,percent:(t.fontSize-.5)/9.5*100,onChange:n=>{Number.isFinite(n)&&i("fontSize",n)}}),e(l,{label:"Vertical Position",display:`${t.position}`,min:0,max:100,step:1,value:t.position,percent:t.position,onChange:n=>{Number.isFinite(n)&&i("position",Math.round(n))}}),e(l,{label:"Background Opacity",display:`${Math.round(t.bgOpacity*100)}%`,min:0,max:1,step:.05,value:t.bgOpacity,percent:t.bgOpacity*100,onChange:n=>{Number.isFinite(n)&&i("bgOpacity",n)}}),e(m,{label:"Text Color",colors:S,value:t.textColor,onChange:n=>i("textColor",n)}),e(m,{label:"Background Color",colors:f,value:t.bgColor,onChange:n=>i("bgColor",n)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:t.edge,onChange:n=>i("edge",n)}),e("button",{type:"button",className:`${o.item} ${t.bold?o.active:""}`,onClick:()=>i("bold",!t.bold),children:[e("span",{children:"Bold Text"}),t.bold&&e(p,{name:"check",size:12})]}),e("button",{type:"button",className:o.item,onClick:a,children:e("span",{children:"Reset to Defaults"})})]})},z=({classes:o,enabled:t,delayMs:i,onToggle:a,onDelayChange:n,onCalibrate:b})=>{const[r,c]=y(null),d=r??i;g(()=>{c(null)},[i]);const h=()=>{r!==null&&(n(r),c(null))};return e(s,{children:[e("button",{type:"button",className:`${o.item} ${t?o.active:""}`,onClick:()=>a(!t),children:[e("span",{children:"Video delay"}),t&&e(p,{name:"check",size:12})]}),e(l,{label:"Video delay",display:`${d}ms`,min:0,max:500,step:5,value:d,percent:d/500*100,onChange:u=>c(Math.round(u)),onCommit:h}),e("div",{className:o.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),b&&e("button",{type:"button",className:o.item,onClick:b,children:e("span",{children:"Calibrate…"})})]})},E=({classes:o,values:t,onChange:i})=>e(s,{children:[e("button",{type:"button",className:`${o.item} ${t.enabled?o.active:""}`,onClick:()=>i({enabled:!t.enabled}),"aria-pressed":t.enabled,children:[e("span",{children:"Ambient light"}),e("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t.enabled?"On":"Off",t.enabled&&e(p,{name:"check",size:12})]})]}),e(l,{label:"Blur",display:`${t.blur}px`,min:0,max:120,step:2,value:t.blur,percent:t.blur/120*100,onChange:a=>i({blur:Math.round(a)})}),e(l,{label:"Saturation",display:`${t.saturation}%`,min:0,max:200,step:5,value:t.saturation,percent:t.saturation/200*100,onChange:a=>i({saturation:Math.round(a)})}),e(l,{label:"Brightness",display:`${t.brightness}%`,min:20,max:120,step:5,value:t.brightness,percent:(t.brightness-20)/100*100,onChange:a=>i({brightness:Math.round(a)})}),e(l,{label:"Opacity",display:`${t.opacity}%`,min:10,max:100,step:5,value:t.opacity,percent:(t.opacity-10)/90*100,onChange:a=>i({opacity:Math.round(a)})}),e("div",{className:o.note,children:"Mirrors the video onto the backdrop behind the player. Turn off for pure black."}),e("button",{type:"button",className:o.item,onClick:()=>i({...N}),children:e("span",{children:"Reset to defaults"})})]}),B=({classes:o,options:t,onSelect:i})=>e(s,{children:t.map(a=>e("button",{type:"button",className:`${o.item} ${a.selected?o.active:""}`,onClick:()=>i(a.key),children:[e("span",{children:a.label}),a.selected&&e(p,{name:"check",size:12})]},a.key))});export{z as A,B as O,C as S,$ as a,E as b};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-e_PohoiO.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-D4ejupic.js","assets/AvSyncCalibrator-B2fQmjbo.js","assets/index-C93G341i.js","assets/vendor-query-BBT5_sHx.js","assets/index-D0Haw_Zl.css","assets/AvSyncCalibrator-ZSpMgUid.css","assets/PlayerSettings-BXGe3F5k.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as r,g as Ut,h as L,P as Lr,z as Ir,d as ue,A as m,q as K,y as Dr,T as Je,o as $r,a as Fr,c as Or,_ as Wr,S as Wt}from"./vendor-core-DfaOB3Rn.js";import{_ as mr,S as _t,h as Ur,t as Ee,z as Oe,J as Vr,K as yt,M as Be,e as qr,l as Qr,m as zr,n as Gr,o as Kr,d as Hr,u as jr,B as it,L as Yr,f as Xr}from"./index-C93G341i.js";import{u as fr,b as cr,a as Yt}from"./vendor-query-BBT5_sHx.js";import{S as Jr,U as Zr,p as Xt,s as en,C as tn,a as rn,b as nn,c as at,l as sn,u as on,d as an,e as ln,f as cn,i as un,g as ur,h as dn,j as pn,k as dr,m as pr,n as hn,o as mn,q as fn,r as vn,t as Ae,A as gn,R as bn,E as yn,v as Sn,w as p,x as En,y as wn,P as kn,z as Tn,B as Cn}from"./AvSyncCalibrator-B2fQmjbo.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Rn}from"./hls-CEWF8efn.js";import{u as Mn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as _n}from"./QueueRail-BfNg-4sG.js";import{u as Nn,Q as Pn}from"./QueueOptionsButton-BMl804vN.js";import{u as vr}from"./useProviders-C3E0fPpP.js";import{A as xn}from"./AnimeMetaDetails-BogOi_bM.js";import{S as An}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const Bn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Ln={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},In=["direct","cookie","embed"],Dn="_controlsOverlay_1h2da_1",$n="_hidden_1h2da_21",Fn="_topControls_1h2da_27",On="_backBtn_1h2da_47",Wn="_videoTitleInfo_1h2da_67",Un="_animeTitle_1h2da_73",Vn="_episodeNumber_1h2da_83",qn="_bottomControls_1h2da_91",Qn="_progressBarContainer_1h2da_110",zn="_progressBar_1h2da_110",Gn="_thumb_1h2da_129",Kn="_scrubbing_1h2da_144",Hn="_watchedBar_1h2da_148",jn="_bufferedBar_1h2da_149",Yn="_timeBubble_1h2da_187",Xn="_skipSegment_1h2da_221",Jn="_op_1h2da_231",Zn="_ed_1h2da_234",es="_recap_1h2da_237",ts="_bottomControlsRow_1h2da_241",rs="_leftControls_1h2da_249",ns="_rightControls_1h2da_250",ss="_controlBtn_1h2da_257",os="_theaterBtn_1h2da_298",is="_nextEpisodeBtn_1h2da_302",as="_active_1h2da_323",ls="_timeDisplay_1h2da_327",cs="_skipControls_1h2da_335",us="_skipBtn_1h2da_341",ds="_volumeContainer_1h2da_382",ps="_volumeSlider_1h2da_388",hs="_playerPageLayout_1h2da_446",ms="_videoPlayerWrapper_1h2da_450",fs="_playerInfoContainer_1h2da_455",vs="_visible_1h2da_572",gs="_shortcuts_1h2da_590",C={controlsOverlay:Dn,hidden:$n,topControls:Fn,backBtn:On,videoTitleInfo:Wn,animeTitle:Un,episodeNumber:Vn,bottomControls:qn,progressBarContainer:Qn,progressBar:zn,thumb:Gn,scrubbing:Kn,watchedBar:Hn,bufferedBar:jn,timeBubble:Yn,skipSegment:Xn,op:Jn,ed:Zn,recap:es,bottomControlsRow:ts,leftControls:rs,rightControls:ns,controlBtn:ss,theaterBtn:os,nextEpisodeBtn:is,active:as,timeDisplay:ls,skipControls:cs,skipBtn:us,volumeContainer:ds,volumeSlider:ps,playerPageLayout:hs,videoPlayerWrapper:ms,playerInfoContainer:fs,visible:vs,shortcuts:gs},bs=({player:n,handlers:l,visible:h,skipIntervals:A,showNextEpisodeButton:f,onNextEpisode:S,isTheaterMode:b,onTheaterModeToggle:B,settingsBtnRef:P,timeDisplayRef:$})=>{const{state:k,refs:e,actions:o}=n,{showSettings:J}=k,g=()=>k.isMuted||k.volume===0?r(Z,{name:"volume-mute"}):k.volume<.5?r(Z,{name:"volume-down"}):r(Z,{name:"volume-up"});return r("div",{className:`${C.controlsOverlay} ${h?"":C.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:C.bottomControls,"data-speed-boost-ignore":"true",onClick:x=>x.stopPropagation(),children:[r(Jr,{classes:{container:C.progressBarContainer,scrubbing:C.scrubbing,timeBubble:C.timeBubble,bar:C.progressBar,buffered:C.bufferedBar,watched:C.watchedBar,thumb:C.thumb},videoRef:e.videoRef,duration:k.duration,formatTime:o.formatTime,isScrubbing:k.isScrubbing,onSeek:l.handleSeek,onScrubStart:l.handleScrubStart,onScrubMove:l.handleScrubMove,onScrubEnd:l.handleScrubEnd,timeLabelRef:$,children:[k.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${C.skipSegment} ${C[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/k.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/k.duration*100}% `}}),A.map(x=>{const de=x.start_time/k.duration*100,U=(x.end_time-x.start_time)/k.duration*100;return r("div",{className:`${C.skipSegment} ${C[x.skip_type]} `,style:{left:`${de}% `,width:`${U}% `},title:x.skip_type.toUpperCase()},x.skip_id)})]}),r("div",{className:C.bottomControlsRow,children:[r("div",{className:C.leftControls,children:[r("button",{className:C.controlBtn,onClick:o.togglePlay,"aria-label":k.isPlaying?"Pause":"Play",children:k.isPlaying?r(Z,{name:"pause"}):r(Z,{name:"play"})}),r(Zr,{muted:k.isMuted,volume:k.volume,volumeIcon:g(),buttonClassName:C.controlBtn,onToggleMute:o.toggleMute,onVolumeChange:l.handleVolumeChange,onExpandedChange:x=>o.setShowVolumeSlider(x)}),r("span",{className:C.timeDisplay,ref:$,children:[o.formatTime(0)," / ",o.formatTime(k.duration)]}),k.currentSkipInterval&&!k.isAutoSkipEnabled&&r("button",{className:C.controlBtn,onClick:()=>{e.videoRef.current&&k.currentSkipInterval&&(e.videoRef.current.currentTime=k.currentSkipInterval.end_time,o.setCurrentSkipInterval(null))},children:["Skip ",k.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:C.rightControls,children:[r("div",{className:C.skipControls,children:f&&r("button",{className:C.nextEpisodeBtn,onClick:S,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${C.controlBtn} ${l.isSubtitleActive?C.active:""}`,onClick:l.handleCCToggle,title:l.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(Z,{name:"closed-captioning",size:22})}),r("button",{ref:P,className:`${C.controlBtn} ${J?C.active:""} `,onClick:()=>o.setShowSettings(!J),"aria-label":"Settings",children:r(Z,{name:"cog"})}),r("button",{className:`${C.controlBtn} ${C.theaterBtn} ${b?C.active:""} `,onClick:x=>{x.stopPropagation(),B()},title:b?"Exit Theater Mode":"Theater Mode","aria-label":b?"Exit Theater Mode":"Theater Mode",children:r(Z,{name:"tv"})}),r("button",{className:C.controlBtn,onClick:o.toggleFullscreen,"aria-label":k.isFullscreen?"Exit Fullscreen":"Fullscreen",children:k.isFullscreen?r(Z,{name:"compress"}):r(Z,{name:"expand"})})]})]})]})})};function ys(n){const{state:l,refs:h,actions:A}=n,f=o=>{h.videoRef.current&&(h.videoRef.current.volume=o,h.videoRef.current.muted=o===0)},S=o=>{!h.videoRef.current||isNaN(l.duration)||l.duration===0||(h.videoRef.current.currentTime=o*l.duration,A.sendProgressUpdate(!1,!0))},b=()=>{h.videoRef.current&&(A.setIsScrubbing(!0),A.wasPlayingBeforeScrub.current=!h.videoRef.current.paused,h.videoRef.current.pause())},B=o=>{!h.videoRef.current||!l.duration||(h.videoRef.current.currentTime=o*l.duration)},P=()=>{A.setIsScrubbing(!1),A.wasPlayingBeforeScrub.current&&h.videoRef.current?.play()},$=o=>{if(!h.videoRef.current)return;A.setActiveSubtitleTrack(o);try{if(o===null||o==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const g=l.availableSubtitles.find(x=>x.label===o||x.lang===o);g?localStorage.setItem("playerLastSubtitle",en(g)):localStorage.setItem("playerLastSubtitle",o)}}catch{}let J=!1;Array.from(h.videoRef.current.textTracks).forEach(g=>{const de=o!==null&&o!=="off"&&(g.language===o||g.label===o)&&!J;g.mode=de?"showing":"hidden",de&&(J=!0)})},k=l.activeSubtitleTrack!==null&&l.activeSubtitleTrack!=="off";return{handleVolumeChange:f,handleSeek:S,handleScrubStart:b,handleScrubMove:B,handleScrubEnd:P,handleSubtitleSelection:$,isSubtitleActive:k,handleCCToggle:()=>{if(!h.videoRef.current)return;if(k){$("off");return}if(l.availableSubtitles.length===0)return;let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const J=Xt(l.availableSubtitles,{lastKey:o,enabled:!0});if(J<0)return;const g=l.availableSubtitles[J];$(g.label||g.lang)}}}const Ss=Ir(()=>mr(()=>import("./PlayerSettings-e_PohoiO.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Es=({player:n,isAutoplayEnabled:l,onAutoplayChange:h,showNextEpisodeButton:A,onNextEpisode:f,videoSources:S,selectedSource:b,selectedLink:B,onSourceChange:P,loadingVideo:$,skipIntervals:k,animeTitle:e,episodeNumber:o,isTheaterMode:J,onTheaterModeToggle:g,anime4kEnabled:x,onAnime4kToggle:de,anime4kSupported:U,anime4kProfile:I,onAnime4kProfileChange:V,anime4kInitializing:Le,anime4kError:We,videoDelayEnabled:i,onVideoDelayToggle:d,videoDelayMs:T,onVideoDelayChange:ve,onCalibrateAvSync:Ie,fallbackChoice:_e,onFallbackChoiceChange:Ne,ambientSettings:Ue,onAmbientChange:oe,children:we,overlays:c,isInteractingExtra:y=!1,className:v,hideChrome:D=!1})=>{const{state:R,actions:q}=n,{showSettings:ye}=R,{setShowSettings:Y}=q,G=ys(n),ke=Ut.useRef(null),De=Ut.useRef(null),St=Ut.useRef(null);L(()=>{const F=O=>{ke.current&&!ke.current.contains(O.target)&&De.current&&!De.current.contains(O.target)&&ye&&Y(!1)};return ye&&document.addEventListener("mousedown",F),()=>{document.removeEventListener("mousedown",F)}},[ye,Y]);const Ze=R.showControls||ye||R.isScrubbing,Et=r(nn,{visible:Ze,title:e,episode:o?`Episode ${o}`:void 0,onBack:()=>window.history.back(),classes:{overlay:C.controlsOverlay,hidden:C.hidden,top:C.topControls,backBtn:C.backBtn,titleInfo:C.videoTitleInfo,title:C.animeTitle,episode:C.episodeNumber}}),H=!$&&!R.isBuffering&&R.duration>0?r(tn,{isPlaying:R.isPlaying,onTogglePlay:q.togglePlay,onSkipBack:()=>q.seek(-10),onSkipForward:()=>q.seek(10)}):null,Pe=r(bs,{player:n,handlers:G,visible:Ze,skipIntervals:k,showNextEpisodeButton:A,onNextEpisode:f,isTheaterMode:J,onTheaterModeToggle:g,settingsBtnRef:De,timeDisplayRef:St}),lt=r(Lr,{fallback:null,children:r(Ss,{ref:ke,isOpen:ye,onClose:()=>Y(!1),videoSources:S,currentSource:b,currentLink:B,onSourceChange:P,subtitles:R.availableSubtitles,activeSubtitleTrack:R.activeSubtitleTrack,onSubtitleChange:G.handleSubtitleSelection,subtitleSettings:{fontSize:R.subtitleFontSize,position:R.subtitlePosition,bgOpacity:R.subtitleBgOpacity,bgColor:R.subtitleBgColor,textColor:R.subtitleTextColor,edge:R.subtitleEdge,bold:R.subtitleBold},onSubtitleSettingsChange:(F,O)=>{const Te=(Ve,Ge)=>{try{localStorage.setItem(Ve,String(Ge))}catch{}};switch(F){case"fontSize":q.setSubtitleFontSize(O),Te("subtitleFontSize",O);break;case"position":q.setSubtitlePosition(O),Te("subtitlePosition",O);break;case"bgOpacity":q.setSubtitleBgOpacity(O),Te("subtitleBgOpacity",O);break;case"bgColor":q.setSubtitleBgColor(O),Te("subtitleBgColor",O);break;case"textColor":q.setSubtitleTextColor(O),Te("subtitleTextColor",O);break;case"edge":q.setSubtitleEdge(O),Te("subtitleEdge",O);break;case"bold":q.setSubtitleBold(O),Te("subtitleBold",O);break}},useNativeControls:R.useNativeControls,onNativeControlsToggle:q.setUseNativeControls,anime4kEnabled:x,onAnime4kToggle:de,anime4kSupported:U,anime4kProfile:I,onAnime4kProfileChange:V,anime4kInitializing:Le,anime4kError:We,videoDelayEnabled:i,onVideoDelayToggle:d,videoDelayMs:T,onVideoDelayChange:ve,onCalibrateAvSync:Ie,isAutoSkipEnabled:R.isAutoSkipEnabled,onAutoSkipChange:F=>{q.setIsAutoSkipEnabled(F);try{localStorage.setItem("autoSkipEnabled",F.toString())}catch{}},isAutoplayEnabled:l,onAutoplayChange:h,fallbackChoice:_e,onFallbackChoiceChange:Ne,isTheaterMode:J,ambientSettings:Ue,onAmbientChange:oe})}),_=ye?r("div",{"data-speed-boost-ignore":"true",onClick:F=>F.stopPropagation(),children:lt}):null;return r(rn,{player:n,topBar:Et,centerControls:H,bottomBar:!$&&R.duration>0?Pe:null,settingsPanel:_,overlays:c,isInteracting:y,className:v,chromeDisabled:D,children:we})},ws=({count:n=3})=>r("section",{className:ze.section,children:[r("div",{className:ze.header,children:r("button",{className:ze.headerToggle,disabled:!0,children:[r("span",{className:ze.title,children:r(_t,{width:"60px",height:"1.2rem",variant:"text"})}),r(Z,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:ze.list,children:Array.from({length:n}).map((l,h)=>r("div",{className:ze.item,style:{pointerEvents:"none"},children:[r("div",{className:ze.dragHandle,style:{opacity:.2},children:r(_t,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:ze.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(_t,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:ze.meta,children:[r(_t,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(_t,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},h))})]}),ks=({selectedProvider:n,onProviderChange:l,isAdult:h,options:A})=>{const f=A&&A.length>0?A:[],S=h===void 0?f:f.filter(b=>b.mature===h);return r("div",{className:at.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:at.providerSelect,value:n,onChange:b=>l(b.target.value),children:In.map(b=>{const B=S.filter(P=>(P.tier??"direct")===b);return B.length===0?null:r("optgroup",{label:Ln[b],children:B.map(P=>r("option",{value:P.value,children:P.sub?`${P.label} (${Bn[P.sub]})`:P.label},P.value))},b)})})]})},Ts=({videoSources:n,selectedSource:l,selectedLink:h,onSourceChange:A,onLinkChange:f})=>{const S=Array.isArray(n)?n:[];if(S.length===0)return null;const b=l?.type==="iframe"&&(l.links?.length??0)>1;return r("div",{className:at.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:at.sourceButtons,children:S.map((B,P)=>r("button",{className:`${at.sourceButton} ${l?.sourceName===B.sourceName?at.active:""} `,onClick:()=>A(B),children:B.sourceName},`${B.sourceName}-${P}`))}),b&&r("select",{className:at.sourceSelect,"aria-label":"Fallback embed quality",value:h?.link??l.links[0]?.link??"",onChange:B=>{const P=l.links.find($=>$.link===B.target.value);P&&f(P)},children:l.links.map(B=>r("option",{value:B.link,children:B.resolutionStr},B.link))})]})},Cs=Ut.memo(Ts,(n,l)=>n.selectedSource?.sourceName===l.selectedSource?.sourceName&&n.selectedLink?.link===l.selectedLink?.link&&n.videoSources===l.videoSources),Rs={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"},_s=5,Ns=15e3,Ps=`
|
|
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 xs({videoRef:n,canvasRef:l,profile:h="balanced",delayMs:A=0}){const[f,S]=ue(!1),[b,B]=ue(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[P,$]=ue(!1),[k,e]=ue(null),[o,J]=ue(0),g=m(0),x=m(null),de=m(null),U=m(null),I=m(null),V=m(null),Le=m(null),We=m(null),i=m(null),d=m(null),T=m(!1),ve=m(-1),Ie=m(0),_e=m(A);_e.current=A;const Ne=m([]),Ue=m(!1),oe=m(!1),we=m(!1),c=m(null),y=m(-1),v=m(-1),D=m(!1),R=m(0);L(()=>{async function Y(){if(typeof navigator>"u"||!navigator.gpu){S(!1);return}try{const G=await navigator.gpu.requestAdapter();S(!!G)}catch{S(!1)}}Y()},[]),L(()=>{if(!b||!f)return;let Y=!1;const G=++g.current,ke=H=>{if(H)try{H.close()}catch{}},De=()=>{for(const H of Ne.current)ke(H.bitmap);Ne.current=[]},St=H=>Math.max(8,Math.min(40,Math.ceil(H/16.7)+4));function Ze(){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)}async function Et(){let H=n.current;const Pe=l.current;if(!H||!Pe||g.current!==G)return;const lt=performance.now()+Ns;for(;(!H||H.videoWidth===0)&&performance.now()<lt;){if(await new Promise(le=>requestAnimationFrame(le)),Y||g.current!==G)return;H=n.current}if(!H||H.videoWidth===0){!Y&&g.current===G&&(e("Timed out waiting for video metadata"),$(!1),B(!1));return}const _=H.videoWidth,F=H.videoHeight,O=Math.max(_,F),Te=window.innerWidth,Ve=window.innerHeight,Ge=Math.max(Te,Ve),ct=O<Ge?Ge/O:1,ut=Rs[h],dt=O<=480?ut.sd:O<=720?ut.hd:O<=1080?ut.fhd:1,pt=Math.min(dt,ct);Pe.width=Math.round(_*pt),Pe.height=Math.round(F*pt),$(!0),e(null),Ie.current=0,ve.current=-1,y.current=-1,v.current=-1,D.current=!1,R.current=0,De(),T.current=!1;try{let le=function(){Y||g.current!==G||(Ze(),d.current=requestAnimationFrame(()=>{At()}))};const{ModeA:Ke,ModeB:He,ModeC:Nt,ModeAA:wt}=await mr(async()=>{const{ModeA:W,ModeB:Q,ModeC:be,ModeAA:pe}=await import("./index-BOKlZEHq.js").then(E=>E.i);return{ModeA:W,ModeB:Q,ModeC:be,ModeAA:pe}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const je=await navigator.gpu.requestAdapter();if(!je)throw new Error("No GPU adapter found");const M=await je.requestDevice();if(!M)throw new Error("Failed to get GPU device");const $e=Pe.getContext("webgpu");if(!$e)throw new Error("Failed to get WebGPU context");const Fe=navigator.gpu.getPreferredCanvasFormat();$e.configure({device:M,format:Fe,alphaMode:"premultiplied"});const ee=M.createTexture({size:[_,F],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Ye=Ms[h],et=Math.round(_*pt),ge=Math.round(F*pt),ht=(()=>{switch(Ye){case"ModeB":return new He({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:ge}});case"ModeC":return new Nt({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:ge}});case"ModeAA":return new wt({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:ge}});default:return new Ke({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:ge}})}})(),mt=ht.getOutputTexture(),qe=M.createSampler({magFilter:"linear",minFilter:"linear"}),kt=M.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
|
+
`}),tt=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Pt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[tt]}),vertex:{module:kt,entryPoint:"vs"},fragment:{module:kt,entryPoint:"fs",targets:[{format:Fe}]},primitive:{topology:"triangle-list"}}),rt=M.createBindGroup({layout:tt,entries:[{binding:0,resource:mt.createView()},{binding:1,resource:qe}]});try{const W=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Q=M.createShaderModule({code:Ps}),be=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[W]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:be,layout:W,inputView:ee.createView()}}catch{c.current=null}if(g.current!==G){ee.destroy(),M.destroy();return}x.current=M,de.current=$e,U.current=ht,I.current=ee,V.current=mt,Le.current=Pt,We.current=qe,i.current=tt,oe.current=!1,we.current=!1;async function xt(){const W=c.current;if(!W||oe.current)return!1;const Q=n.current;if(!Q)return!1;const be=!we.current;be&&M.pushErrorScope("validation");try{const pe=M.importExternalTexture({source:Q}),E=M.createBindGroup({layout:W.layout,entries:[{binding:0,resource:pe},{binding:1,resource:qe}]}),Ce=M.createCommandEncoder(),he=Ce.beginRenderPass({colorAttachments:[{view:W.inputView,loadOp:"load",storeOp:"store"}]});he.setPipeline(W.pipeline),he.setBindGroup(0,E),he.draw(6),he.end(),M.queue.submit([Ce.finish()])}catch{return oe.current=!0,c.current=null,!1}if(be){const pe=await M.popErrorScope().catch(()=>null);if(pe)return console.warn("[anime4k] blit probe failed:",pe.message),oe.current=!0,c.current=null,!1;we.current=!0}return!0}$(!1);async function At(){if(Y||g.current!==G)return;const W=n.current;if(!W||W.videoWidth===0){le();return}if(W!==H||W.videoWidth!==_||W.videoHeight!==F){J(E=>E+1);return}if(W.paused||W.ended||document.hidden||W.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const Q=W.getVideoPlaybackQuality().totalVideoFrames;if(Q===v.current){le();return}if(T.current){le();return}const be=W.currentTime;(W.seeking||y.current>=0&&Math.abs(be-y.current)>.5)&&(De(),D.current=!1,R.current=0,v.current=-1),y.current=be;const pe=Math.max(0,_e.current||0);pe>R.current&&(D.current=!1),T.current=!0;try{const E=performance.now();let Ce=null,he=!1;if(pe<=0){Ne.current.length>0&&De(),D.current=!1,R.current=0;let xe=!1;if(!Ue.current)try{M.queue.copyExternalImageToTexture({source:W},{texture:ee},[_,F]),v.current=Q,xe=!0}catch(z){if(z instanceof TypeError)Ue.current=!0;else throw z}if(!xe&&!oe.current&&c.current&&await xt()&&(v.current=Q,xe=!0),!xe){const z=await createImageBitmap(W);v.current=Q,M.queue.copyExternalImageToTexture({source:z},{texture:ee},[_,F]),ke(z)}}else{const xe=await createImageBitmap(W);v.current=Q;const z=Ne.current;z.push({bitmap:xe,capture:E});const Tt=St(pe);for(;z.length>Tt;)ke(z.shift()?.bitmap);let Ct=-1;for(let te=z.length-1;te>=0;te--)if(E-z[te].capture>=pe){Ct=te;break}if(Ct!==-1){for(let vt=0;vt<Ct;vt++)ke(z.shift()?.bitmap);const te=z.shift();te?(Ce=te.bitmap,D.current=!0,R.current=pe):(Ce=xe,he=!0)}else if(!D.current)Ce=xe,he=!0;else{const te=z.shift();Ce=te?te.bitmap:xe,te||(he=!0)}if(!Ce){T.current=!1,le();return}M.queue.copyExternalImageToTexture({source:Ce},{texture:ee},[_,F]),he||ke(Ce)}const nt=M.createCommandEncoder();await ht.pass(nt);const ft=nt.beginRenderPass({colorAttachments:[{view:$e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});ft.setPipeline(Pt),ft.setBindGroup(0,rt),ft.draw(6),ft.end(),M.queue.submit([nt.finish()]),ve.current=Q,Ie.current=0,M.queue.onSubmittedWorkDone().then(()=>{g.current===G&&(T.current=!1)})}catch(E){if(T.current=!1,Ie.current+=1,Ie.current>=_s&&!Y&&g.current===G){console.error(E),e(E instanceof Error?E.message:"Render error"),B(!1);return}}le()}le()}catch(le){!Y&&g.current===G&&(e(le instanceof Error?le.message:"Failed to initialize upscaler"),$(!1),B(!1))}}return Et(),()=>{Y=!0,g.current+=1,Ze(),De(),I.current&&(I.current.destroy(),I.current=null),V.current&&(V.current.destroy(),V.current=null),x.current&&(x.current.destroy(),x.current=null),U.current=null,Le.current=null,We.current=null,i.current=null,c.current=null,de.current=null,T.current=!1}},[b,f,n,l,h,o]);const q=K(Y=>{B(Y);try{localStorage.setItem("anime4kEnabled",String(Y))}catch{}},[]),ye=K(()=>{B(Y=>{const G=!Y;try{localStorage.setItem("anime4kEnabled",String(G))}catch{}return G})},[]);return{isWebGPUSupported:f,isEnabled:b,isInitializing:P,error:k,toggle:ye,setEnabled:q}}const As=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Bs=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},Ls=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:As(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:sn(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Bs(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Is(n,l){switch(l.type){case"SET_STATE":return{...n,...l.payload};case"SET_MODE":return{...n,currentMode:l.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:l.payload};default:return n}}async function hr(n,l,h,A,f=!1){if(!n||!l)throw new Error("Missing params");try{const[S,b,B,P]=await Promise.all([Ee.data.video.query({showId:n,episodeNumber:l,mode:h.currentMode,provider:h.selectedProvider}).catch(()=>null),Ee.progress.getEpisode.query({showId:n,episodeNumber:l}).catch(()=>null),Ee.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Ee.data.skipTimes.query({showId:n,episodeNumber:l}).catch(()=>[])]),$=B?.value,k=S?.filter(I=>{const V=I.sourceName.toLowerCase();return h.currentMode==="dub"?V.includes("eng")||V.includes("dub"):V.includes("jpn")||V.includes("sub")||!V.includes("eng")&&!V.includes("dub")})??[],e=k.length>0?k:S??[];let o=e.length>0?e[0]:null;if($){const I=e.find(V=>V.sourceName===$);I&&(o=I)}const J=o&&o.links.length>0?o.links.sort((I,V)=>(parseInt(V.resolutionStr)||0)-(parseInt(I.resolutionStr)||0))[0]:null,g=b?.currentTime||0,x=b?.duration||0,U=(Array.isArray(P)?P:P?.results||[]).map(I=>({skip_id:I.skip_id||"",skip_type:I.skip_type||"",start_time:I.interval?.start_time??I.start_time??0,end_time:I.interval?.end_time??I.end_time??0})).filter(I=>I.end_time>0);return(!S||S.length===0)&&(f||Oe.error(`No video sources found for ${h.selectedProvider}`)),{videoSources:S,selectedSource:o,selectedLink:J,resumeTime:g,resumeDuration:x,showResumeModal:g>5&&o?.type!=="iframe",skipIntervals:U,fetchedEpisodeNumber:l}}catch(S){const b=S;if(b.message==="AUTH_REQUIRED")return A({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:b.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:l};throw S}}const Ds=(n,l,h,A)=>{const[f,S]=Dr(Is,h,c=>({...Ls(),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}}:{}})),b=fr(),B=Ur(),P=m(null),$=m(null),{options:k}=vr(),e=Je(()=>k.filter(c=>(c.kind??"anime")==="anime"),[k]),o=l||f.initialEpisode,J=m(o);L(()=>{J.current!==o&&(J.current=o,S({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[o,S]),L(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&f.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,S({type:"SET_PROVIDER",payload:"animepahe"}))},[n,f.selectedProvider]);const{data:g,isLoading:x,error:de}=Nn(n),{data:U}=cr({queryKey:["player-data",n,f.currentMode,f.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const q=await Ee.data.episodes.query({showId:n,mode:f.currentMode,provider:f.selectedProvider}).catch(()=>null);if(q?.episodes?.length)return q}catch{}return null},[y,v,D]=await Promise.all([c(),Ee.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Ee.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),R=y?.episodes?y.episodes.sort((q,ye)=>parseFloat(q)-parseFloat(ye)):[];return{description:y?.description||"",episodes:R,inWatchlist:v.inWatchlist,watchlistStatus:v.status??null,watchedEpisodes:D}},enabled:!!n});L(()=>{!l&&U?.episodes&&U.episodes.length>0&&!l&&S({type:"SET_STATE",payload:{initialEpisode:U.episodes[0]}})},[U,l]),L(()=>{if(g?.isAdult===void 0)return;const y=new Set(e.filter(v=>v.mature).map(v=>v.value)).has(f.selectedProvider);if($.current!==n){if(g.isAdult&&!y){const v=e.find(D=>D.mature);if(!v)return;$.current=n,S({type:"SET_PROVIDER",payload:v.value}),localStorage.setItem("preferredProvider",v.value)}if(!g.isAdult&&y){const v=e.find(D=>!D.mature);if(!v)return;$.current=n,S({type:"SET_PROVIDER",payload:v.value}),localStorage.setItem("preferredProvider",v.value)}}},[g?.isAdult,f.selectedProvider,n,e]),L(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||$.current===`temp:${n}`)return;const c=g?.provider;c&&($.current=`temp:${n}`,c!==f.selectedProvider&&S({type:"SET_PROVIDER",payload:c}))},[n,g,f.selectedProvider]);const{data:I,isLoading:V,error:Le}=cr({queryKey:["video-sources",n,o,f.selectedProvider,f.currentMode],queryFn:()=>hr(n,o,f,S),enabled:!!n&&!!o&&!(f.showMeta?.isAdult===!0&&!A?.hasMatureConsent)}),{mutateAsync:We}=Yt({mutationFn:async({wasIn:c,showMeta:y})=>{if(!n)throw new Error("Missing showId");if(c)await Ee.watchlist.remove.mutate({id:n});else{const v=y.name||y.names?.romaji;if(!v)throw new Error("Missing show name");await Ee.watchlist.add.mutate({id:n,name:v,thumbnail:y.thumbnail,nativeName:y.names?.native,englishName:y.names?.english,type:y.type,isAdult:y.isAdult})}return!c},onSuccess:c=>{Oe.success(c?"Added to watchlist":"Removed from watchlist"),b.invalidateQueries({queryKey:["player-data",n]}),b.invalidateQueries({queryKey:["show-data",n]}),b.invalidateQueries({queryKey:["watchlist"]})},onError:c=>Oe.error(c instanceof Error?c.message:"Failed to update watchlist")}),i=K(async()=>{!n||!g||await We({wasIn:!!U?.inWatchlist,showMeta:g})},[n,g,U?.inWatchlist,We]),d=K(async c=>{try{await Ee.settings.set.mutate({key:"preferredSource",value:c})}catch(y){console.error(y)}},[]),{mutateAsync:T,isPending:ve}=Yt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Ee.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{S({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),Oe.success(`Moved to ${c}`),b.invalidateQueries({queryKey:["show-data",n]}),b.invalidateQueries({queryKey:["watchlist"]}),b.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Oe.error("Failed to update watchlist status")}),Ie=K(async()=>{await T({status:"Completed"})},[T]),{mutateAsync:_e}=Yt({mutationFn:async({episodeNumber:c,duration:y,showMeta:v,episodes:D})=>{await Ee.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:y,duration:y,showName:v.name,showThumbnail:v.thumbnail,nativeName:v.names?.native,englishName:v.names?.english,genres:v.genres?.map(R=>R.name),popularityScore:Vr(v.score??v.stats?.averageScore),type:v.type,status:v.status,episodeCount:D.length,isAdult:v.isAdult})},onSuccess:(c,y)=>{Oe.success(`Episode ${y.episodeNumber} marked as watched`),b.invalidateQueries({queryKey:["player-data",n]}),b.invalidateQueries({queryKey:["show-meta",n]}),b.invalidateQueries({queryKey:["video-sources",n,y.episodeNumber]}),b.invalidateQueries({queryKey:["allContinueWatching"]}),b.invalidateQueries({queryKey:["thisWeekSchedule"]}),b.invalidateQueries(B.continueWatching.pathFilter())},onError:()=>Oe.error("Failed to mark episode as watched")}),Ne=K(async(c,y)=>{!n||!g||await _e({episodeNumber:c,duration:y,showMeta:g,episodes:U?.episodes||[]})},[n,g,U?.episodes,_e]),Ue=K(async()=>{S({type:"SET_STATE",payload:{showCombinedDetails:!f.showCombinedDetails}})},[f.showCombinedDetails]),oe=Je(()=>{const c=de||Le,y=c?c.message:null,v=y==="AUTH_REQUIRED"?null:y,D=I&&I.fetchedEpisodeNumber===o?I:null,R=!!I&&!D;return{...f,currentEpisode:o,showMeta:{...f.showMeta||{},...g||{}},episodes:U?.episodes||[],watchedEpisodes:U?.watchedEpisodes||[],inWatchlist:!!U?.inWatchlist,watchlistStatus:U?.watchlistStatus??f.watchlistStatus??null,videoSources:D?.videoSources||[],selectedSource:f.selectedSource||D?.selectedSource||null,selectedLink:f.selectedLink||D?.selectedLink||null,resumeTime:D?.resumeTime||0,resumeDuration:D?.resumeDuration||0,showResumeModal:f.showResumeModal&&(D?.showResumeModal??!1),skipIntervals:D?.skipIntervals||[],loadingShowData:x,loadingVideo:V||R,error:v,fetchedEpisodeNumber:D?.fetchedEpisodeNumber}},[f,g,U,I,x,V,de,Le,o]),we=K((c,y)=>{const v=y||n;if(!v||!c||v===n&&c===o)return;const R=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v)&&f.selectedProvider!=="animepahe"?"animepahe":f.selectedProvider,q=["video-sources",v,c,R,f.currentMode];b.getQueryState(q)?.status!=="success"&&b.prefetchQuery({queryKey:q,queryFn:()=>hr(v,c,{selectedProvider:R,currentMode:f.currentMode},S,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,o,b,f,S]);return{state:oe,dispatch:S,toggleWatchlist:i,moveToCompleted:Ie,setPreferredSource:d,handleToggleDetails:Ue,markEpisodeWatched:Ne,prefetchEpisodeSources:we,isMarkingWatched:_e.isPending,isUpdatingWatchlistStatus:ve}},$s=({isOpen:n,onClose:l,onSuccess:h})=>{const A=()=>{h?.(),l()};return r(Be,{isOpen:n,onClose:l,title:"MKissa Browser Verification",children:r("div",{className:yt.container,children:[r("p",{children:"Open MKissa in this browser, play an anime episode, and complete any Cloudflare verification it shows. Once playback works there, return to Dango and click Refresh."}),r("div",{className:yt.actions,children:r("a",{className:yt.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),r("div",{className:yt.actions,children:[r("button",{className:yt.secondaryButton,onClick:l,children:"Cancel"}),r("button",{className:yt.button,onClick:A,children:"Refresh Dango"})]})]})})},Jt="fallbackChoice";function Fs(){try{const n=localStorage.getItem(Jt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Os(n){try{n===null?localStorage.removeItem(Jt):localStorage.setItem(Jt,n)}catch{}}const no=()=>{const{id:n,episodeNumber:l}=$r(),h=Fr(),A=fr(),f=Or(),{hasConsent:S,grant:b}=qr(),{options:B}=vr(),P=Je(()=>B.filter(t=>(t.kind??"anime")==="anime"),[B]),$=Je(()=>P.map(t=>t.value),[P]),k=Je(()=>new Set(P.filter(t=>t.mature).map(t=>t.value)),[P]),{state:e,dispatch:o,toggleWatchlist:J,moveToCompleted:g,setPreferredSource:x,handleToggleDetails:de,markEpisodeWatched:U,prefetchEpisodeSources:I,isMarkingWatched:V,isUpdatingWatchlistStatus:Le}=Ds(n,l,f.state||null,{hasMatureConsent:S});L(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=l?`/watch/${e.showMeta.id}/${l}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;h(t,{replace:!0})}},[n,e.showMeta?.id,l,h]);const We=Je(()=>{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]),i=on({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:We}),{refs:d,actions:T}=i,ve=m(null),Ie=Mn(),_e=m(null),Ne=m(null),Ue=m(null),oe=m(0),we=m(e.resumeTime),c=m(e.showResumeModal),[y,v]=ue(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),{videoDelayMs:D,videoDelayEnabled:R,setDelayEnabled:q,handleVideoDelayChange:ye,isCalibrating:Y,testClipActive:G,stopCalibration:ke,openAvSyncCalibrator:De,cancelAvSyncCalibrator:St,applyAvSyncCalibrator:Ze,toggleTestClip:Et,calibReturnRef:H,effectiveVideoDelayMs:Pe}=an(d.videoRef,()=>T.setShowSettings(!1)),lt=m(null),_=xs({videoRef:d.videoRef,canvasRef:Ne,profile:y,delayMs:Pe}),F=_.isEnabled&&_.isWebGPUSupported,O=`${n??""}:${e.currentEpisode??""}`,Te=m(null),Ve=m(!1),Ge=m(!1),ct=m(_.setEnabled);ct.current=_.setEnabled,L(()=>{const t=Te.current;Te.current=O,!(t===null||t===O)&&(!_.isEnabled||!_.isWebGPUSupported||(Ve.current=!0,Ge.current=!1,ct.current(!1)))},[O,_.isEnabled,_.isWebGPUSupported]),L(()=>{if(!Ve.current)return;if(_.isEnabled){Ge.current&&(Ve.current=!1);return}if(Ge.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){Ve.current=!1,ct.current(!0);return}const t=d.videoRef.current;if(!t)return;let s,a=!1;const u=()=>{a||(a=!0,Ve.current=!1,ct.current(!0))};if(t.readyState>=2)return s=window.setTimeout(u,500),()=>window.clearTimeout(s);const N=()=>{window.setTimeout(u,500)};return t.addEventListener("canplay",N,{once:!0}),t.addEventListener("playing",N,{once:!0}),s=window.setTimeout(u,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",N),t.removeEventListener("playing",N)}},[_.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,d.videoRef]),ln({videoRef:d.videoRef,canvasRef:lt,delayMs:Pe,enabled:R&&!F});const ut=R&&!F,dt=F||ut;L(()=>{we.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[pt,le]=ue(!1),[Ke,He]=ue(!1),[Nt,wt]=ue(!1),je=m(!1),[M,$e]=ue(null),Fe=m(!1),ee=m([]),Ye=m(!1),[et,ge]=ue(null),[ht,mt]=ue(!1),[qe,kt]=ue(!1),[tt,Pt]=ue(()=>Fs()??"ask"),rt=K(t=>{Pt(t),Os(t==="ask"?null:t)},[]),xt=m(tt);xt.current=tt;const At=m(e.videoSources);At.current=e.videoSources;const W=m(()=>{}),[Q,be]=ue(null),pe=m(l);L(()=>{pe.current!==l&&(pe.current=l,be(null),$e(null),je.current=!1,ke())},[l,ke]),L(()=>{Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),mt(!1)},[n,e.currentEpisode]),L(()=>{Ke||(je.current=!1)},[Ke]);const{data:E=[],isLoading:Ce}=Qr(),he=zr(),nt=m(he);nt.current=he;const ft=Gr(),xe=Kr(),{isTheaterMode:z,toggleTheaterMode:Tt,handleLayoutClick:Ct}=cn();Wr(()=>{if(i.state.isFullscreen||z)return;const t=d.playerContainerRef.current,s=_e.current;if(!t||!s)return;const a=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};a();const u=new ResizeObserver(a);return u.observe(t),()=>u.disconnect()},[i.state.isFullscreen,z,d.playerContainerRef]);const te=Je(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),vt=te>0?e.episodes[te-1]:null,Re=te>=0&&te<e.episodes.length-1?e.episodes[te+1]:null,Vt=te>-1&&te<e.episodes.length-1,qt=un(e.resumeTime,e.resumeDuration)||Ke,Xe=qt&&ur(e.episodes,e.currentEpisode,e.showMeta.status),Qt=e.showResumeModal&&(Xe||!qt),Bt=qt&&!Xe&&E.length===0&&!Q&&(e.showResumeModal||Ke),st=Qt||Bt;dn(i,!!e.selectedLink&&!z&&!st),L(()=>{const t=d.videoRef.current;if(!t)return;let s=!1;for(ve.current&&(ve.current.destroy(),ve.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(G)return t.src="/av-sync-test.mp4",t.play().catch(()=>{T.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){oe.current=0;return}H.current!=null?(oe.current=H.current,H.current=null):we.current>5&&!c.current?oe.current=we.current:c.current&&(oe.current=0);let a=e.selectedLink.link;if(a.startsWith("/api/proxy")||(a=`/api/proxy?url=${encodeURIComponent(a)}`,e.selectedLink.headers?.Referer&&(a+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const ce=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Se=null;try{Se=localStorage.getItem("playerLastSubtitle")}catch{}const re=Xt(e.selectedSource.subtitles,{lastKey:Se,enabled:ce}),Me=re>=0?e.selectedSource.subtitles[re]:null;e.selectedSource.subtitles.forEach(fe=>{const ne=document.createElement("track");ne.kind="subtitles",ne.label=fe.label,ne.srclang=fe.lang;const w=fe.src??fe.url;if(w){let se=`/api/subtitle-proxy?url=${encodeURIComponent(w)}`;const ae=e.selectedLink?.headers?.Referer,gt=w.includes("anilight.live")?"https://anilight.live/":"",Ot=ae||gt;Ot&&(se+=`&referer=${encodeURIComponent(Ot)}`),ne.src=se}Me&&fe.label===Me.label&&fe.lang===Me.lang&&(ne.default=!0),t.appendChild(ne)}),ce||T.setActiveSubtitleTrack("off"),T.setAvailableSubtitles(e.selectedSource.subtitles)}const u=oe.current;oe.current=0;const N=()=>{u>0&&(t.currentTime=u)};t.addEventListener("loadedmetadata",N,{once:!0});const me=!(c.current&&we.current>5),X=()=>{me&&t.play().catch(()=>{T.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const ce=await Rn();if(s)return;if(!ce||!ce.isSupported()){t.src=a,X();return}const Se=document.body.classList.contains("low-end"),re=new ce({maxBufferLength:Se?15:30,maxMaxBufferLength:Se?30:60,maxBufferSize:Se?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ve.current=re,re.on(ce.Events.ERROR,(ne,w)=>{w.fatal&&!Fe.current&&W.current()});const Me=(e.selectedSource?.subtitles?.length??0)>0,fe=()=>{try{Me&&typeof re.subtitleTrack=="number"&&re.subtitleTrack!==-1&&(re.subtitleTrack=-1)}catch{}};re.on(ce.Events.SUBTITLE_TRACK_SWITCH,(ne,w)=>{w?.id!==-1&&fe()}),fe(),re.loadSource(a),re.attachMedia(t),re.once(ce.Events.MANIFEST_PARSED,()=>{s||X()})})():(t.src=a,X());const j=localStorage.getItem("playerVolume"),ie=localStorage.getItem("playerMuted");return j!==null&&(t.volume=parseFloat(j)),ie!==null&&(t.muted=ie==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),ve.current&&(ve.current.destroy(),ve.current=null)}},[e.selectedSource,e.selectedLink,d.videoRef,H,T,e.loadingVideo,G]);const Lt=K(t=>{if(Fe.current)return;Fe.current=!0;const s=t.links[0];x(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),ge(null)},[o,x]),It=K(()=>{const s=At.current.find(a=>a.type==="iframe");return s?.links?.length?s:null},[]),Dt=K(async()=>{const t=e.showMeta?.isAdult,s=$.filter(a=>{if(ee.current.includes(a))return!1;const u=k.has(a);return t===void 0?!0:u===t});mt(!0);try{for(const a of s){ee.current.push(a);let u=null;try{u=await Ee.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:a})}catch{continue}const N=(u??[]).filter(j=>{const ie=j.sourceName.toLowerCase();return e.currentMode==="dub"?ie.includes("eng")||ie.includes("dub"):ie.includes("jpn")||ie.includes("sub")||!ie.includes("eng")&&!ie.includes("dub")});if((N.length>0?N:u??[]).find(j=>j.type!=="iframe"&&j.links?.length)){ee.current=[e.selectedProvider],Ye.current=!1,o({type:"SET_STATE",payload:{selectedProvider:a,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",a),ge(null),Oe.success(`Switched to ${a} (direct stream)`);return}}ge({retryFailed:!0}),Oe.error("No working direct stream found on other providers")}finally{mt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,o,$,k]),Zt=K(()=>{if(Fe.current||Ye.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;ee.current.includes(e.selectedProvider)||ee.current.push(e.selectedProvider);const s=xt.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}T.setShowControls(!0),ge({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,T]);W.current=Zt;const gr=K(()=>{Ye.current=!0,ge(null),kt(!1)},[]),br=K(()=>{qe&&rt("iframe");const t=It();t?Lt(t):ge(null)},[qe,rt,It,Lt]),yr=K(()=>{qe&&rt("retry"),Dt()},[qe,rt,Dt]),Rt=(t,s,a)=>t.showId===s||!!a&&t.showId===a,$t=K(()=>{T.onEnded();const t=E.find(a=>Rt(a,n,e.showMeta?.id)&&a.episodeNumber===e.currentEpisode);if(E.length>0){const a=E.findIndex(N=>Rt(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),u=a>=0?E[a+1]||null:E[0];be({nextItem:u,playedItem:t||null}),$e(2)}else t&&nt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&E.length===0){const a=e.episodes.findIndex(u=>u===e.currentEpisode);if(a>-1&&a<e.episodes.length-1){const u=e.episodes[a+1];A.invalidateQueries({queryKey:["allContinueWatching"]}),h(`/watch/${n}/${u}`),s=!0}}!s&&E.length===0&&!Q&&!je.current&&ur(e.episodes,e.currentEpisode,e.showMeta.status)&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[T,h,E,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,Q,o,A]),zt=K(()=>{if(E.length===0)return;T.onEnded();const t=E.find(u=>Rt(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),s=E.findIndex(u=>Rt(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),a=s>=0?E[s+1]||null:E[0];t&&he.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),a?h(`/watch/${a.showId}/${a.episodeNumber}`):t&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[T,h,E,he,n,e.showMeta?.id,e.currentEpisode,o]),Mt=K(()=>{Re&&(A.invalidateQueries({queryKey:["allContinueWatching"]}),He(!1),h(`/watch/${n}/${Re}`)),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[Re,h,n,o,A]),er=K(()=>{E.length>0?zt():Re?Mt():Oe.error("No next episode available")},[E.length,zt,Mt,Re]),Sr=()=>{vt&&h(`/watch/${n}/${vt}`)};L(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{G||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,d.videoRef,G]),L(()=>{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]),L(()=>{if(!Q||M===null)return;if(M<=0){const{nextItem:s,playedItem:a}=Q;be(null),$e(null),a&&nt.current.mutate({showId:a.showId,episodeNumber:a.episodeNumber}),s?h(`/watch/${s.showId}/${s.episodeNumber}`):a&&o({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{$e(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[Q,M,h,o]),L(()=>{st&&i.state.isFullscreen&&i.actions.toggleFullscreen()},[st,i.state.isFullscreen,i.actions]),L(()=>{st&&d.videoRef.current&&d.videoRef.current.pause()},[st,d.videoRef]);const{titlePreference:Ft}=Hr(),{lowEndMode:tr}=jr(),{settings:Gt,update:Er}=pn(),wr=z&&Gt.enabled&&!tr&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,ot=Je(()=>{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]);L(()=>{ot&&ot!=="Loading..."&&e.currentEpisode&&(document.title=`► ${ot} Episode ${e.currentEpisode} - dango`)},[ot,e.currentEpisode]),L(()=>{const t=s=>{s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(T.setShowControls(!0),i.actions.inactivityTimer.current&&clearTimeout(i.actions.inactivityTimer.current),i.actions.inactivityTimer.current=window.setTimeout(()=>{T.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&er(),s.key.toLowerCase()==="t"&&Tt())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[T,i.actions.inactivityTimer,er,Tt]);const{setAvailableSubtitles:rr,setActiveSubtitleTrack:Kt}=T;L(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{const a=Array.from(t.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));rr(a)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[d.videoRef,rr]),L(()=>{if(i.state.activeSubtitleTrack===null&&i.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Xt(i.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Kt("off");return}const a=i.state.availableSubtitles[s];Kt(a.lang||a.label)}},[i.state.activeSubtitleTrack,i.state.availableSubtitles,Kt]),L(()=>{const t=d.videoRef.current;if(!t||i.state.availableSubtitles.length===0)return;const s=i.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let u=!1;if(Array.from(t.textTracks).forEach(N=>{const X=(N.language===s||N.label===s)&&!u;N.mode=X?"showing":"hidden",X&&(u=!0)}),!u&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(me=>me.language==="en"||me.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[i.state.activeSubtitleTrack,i.state.availableSubtitles,d.videoRef]);const[nr,kr]=ue(0);L(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>kr(t.clientHeight||0);s();const a=new ResizeObserver(s);return a.observe(t),()=>a.disconnect()},[d.videoRef,e.selectedSource,e.selectedLink]),L(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const a={fontSize:i.state.subtitleFontSize,position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold};s.textContent=dr(a);const u=d.videoRef.current;if(!u)return;const N=pr(i.state.subtitleFontSize,nr||u.clientHeight||720);s.textContent=dr({...a,fontSize:N});const me=()=>{const w=Number(i.state.subtitlePosition),se=isNaN(w)?0:Math.max(0,Math.min(100,w));return Math.max(0,Math.min(100,100-se))},X=(w,se)=>{try{const ae=w;ae.snapToLines=!1,ae.line=se}catch{}},j=()=>{const w=N*16,se=u.videoHeight||u.clientHeight||720,ae=u.videoWidth||u.clientWidth||1280;return{step:w*1.3/se*100,chars:Math.max(20,Math.floor(ae/(w*.55)))}},ie=w=>{const se=me(),ae=Array.from(w.activeCues??[]);if(ae.length<=1){ae.forEach(bt=>X(bt,se));return}const{step:gt,chars:Ot}=j();let ar=se;for(let bt=ae.length-1;bt>=0;bt--){const xr=String(ae[bt].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
+
`).reduce((Ar,Br)=>Ar+Math.max(1,Math.ceil(Br.length/Ot)),0),lr=ar-xr*gt;X(ae[bt],Math.max(0,lr)),ar=lr-gt*.4}},ce=w=>{if(!w.cues)return;const se=me();Array.from(w.cues).forEach(ae=>X(ae,se)),w.mode==="showing"&&ie(w)},Se=()=>{Array.from(u.textTracks).forEach(ce)};Se();const re=w=>{const se=w.target;se.mode==="showing"&&ie(se)};Array.from(u.textTracks).forEach(w=>{w.addEventListener("cuechange",re)});const Me=()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re),w.addEventListener("cuechange",re)}),Se()};u.textTracks.addEventListener("addtrack",Me),u.textTracks.addEventListener("removetrack",Me);const fe=Array.from(u.querySelectorAll("track")),ne=()=>{Se()};return fe.forEach(w=>{w.addEventListener("load",ne)}),()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re)}),u.textTracks.removeEventListener("addtrack",Me),u.textTracks.removeEventListener("removetrack",Me),fe.forEach(w=>{w.removeEventListener("load",ne)})}},[i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold,i.state.activeSubtitleTrack,i.state.availableSubtitles,e.selectedSource,e.selectedLink,d.videoRef,nr]),L(()=>{if(!dt)return;const t=d.videoRef.current,s=Ue.current;if(!t||!s)return;const a=localStorage.getItem("playerSubtitlesEnabled")!=="false",u=i.state.activeSubtitleTrack;function N(){if(s.innerHTML="",!a||u==="off"||u===null)return;const j=Array.from(t.textTracks).find(ne=>ne.language===u||ne.label===u);if(!j||j.mode!=="showing")return;const ie=Pe/1e3;let ce;if(ie>0&&j.cues){const ne=t.currentTime-ie;ce=Array.from(j.cues).filter(w=>w.startTime<=ne&&ne<=w.endTime)}else ce=Array.from(j.activeCues??[]);if(ce.length===0)return;const Se={fontSize:pr(i.state.subtitleFontSize,t.clientHeight||0),position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold},re=hn(Se),Me=mn(t,Se.position),fe=Array.from(ce);fe.forEach((ne,w)=>{const se=String(ne.text??"");if(!fn(se).trim())return;const ae=document.createElement("div"),gt=(fe.length-1-w)*1.7;ae.style.cssText=`${re}
|
|
56
|
+
bottom: calc(${Me}px + ${gt}em);`,ae.innerHTML=vn(se),s.appendChild(ae)})}const me=()=>N(),X=()=>N();return Array.from(t.textTracks).forEach(j=>{j.addEventListener("cuechange",me)}),t.addEventListener("timeupdate",X),N(),()=>{Array.from(t.textTracks).forEach(j=>{j.removeEventListener("cuechange",me)}),t.removeEventListener("timeupdate",X),s.innerHTML=""}},[_.isEnabled,_.isWebGPUSupported,i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold,i.state.activeSubtitleTrack,d.videoRef,dt,Pe]),L(()=>{try{localStorage.setItem("anime4kProfile",y)}catch{}},[y]);const Tr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=e.resumeTime,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Cr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=0,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Ht=K(()=>{Xe&&(je.current=!0),Bt&&He(!1),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,Xe,Bt]),Rr=K(()=>{if(He(!1),d.videoRef.current)try{d.videoRef.current.currentTime=0,d.videoRef.current.play().catch(()=>{})}catch{}o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,d]),Mr=K(async()=>{try{await g(),o({type:"SET_STATE",payload:{showResumeModal:!1}}),h("/")}catch{}},[g,o,h]),sr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${p.episodeNavBtn} ${p.secondary}`,onClick:Sr,disabled:!vt,type:"button",children:[r(Z,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${p.episodeNavBtn} ${p.primary}`,onClick:Mt,disabled:!Re,type:"button",children:["Next EP",r(Z,{name:"chevron-right",size:12})]}),s==="mobile"&&Ie&&r("button",{className:`${p.episodeNavBtn} ${p.episodePickerBtn}`,onClick:()=>wt(!0),type:"button",children:[r(Z,{name:"list-ul",size:12}),"Episodes"]})]});L(()=>{Ke&&(e.showResumeModal||E.length>0||Q||je.current||Xe&&o({type:"SET_STATE",payload:{showResumeModal:!0}}))},[Ke,Xe,e.showResumeModal,E.length,Q,o]);const _r=t=>{o({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),Cn(t)},or=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Nr=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",jt=m(I);jt.current=I;const ir=m("");L(()=>{const t=d.videoRef.current;if(le(!1),He(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const a=t.duration,u=t.currentTime;if(!a||Number.isNaN(a)){le(!1),He(!1);return}const N=u/a;if(a-u<=60){const me=E.findIndex(ie=>Rt(ie,n,e.showMeta?.id)&&ie.episodeNumber===e.currentEpisode),X=E.length>0?me>=0?E[me+1]||null:E[0]:null,j=X?`${X.showId}:${X.episodeNumber}`:Vt?`${n}:${Re}`:"";j&&ir.current!==j&&(ir.current=j,X?jt.current(X.episodeNumber,X.showId):jt.current(Re))}le(Vt&&N>=.8),He(u>=Math.max(a*.98,a-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[d.videoRef,Vt,e.currentEpisode,e.selectedSource,Re,n,E,e.showMeta?.id]);const Pr=K(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||V)return;const t=d.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await U(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,U,V,d.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 Qe=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!S?r("div",{className:Ae.playerPageLayout,children:r(Be,{isOpen:!0,title:"Content Warning",onClose:()=>h("/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(it,{variant:"secondary",onClick:()=>h("/home"),children:"Go Back"}),r(it,{onClick:b,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Ae.playerPageLayout} ${z?Ae.theaterMode:""}`,onClick:Ct,children:[z&&r(gn,{videoRef:d.videoRef,active:wr,settings:Gt}),r(Be,{isOpen:Qt&&Xe,onClose:Ht,title:"Show Completed!",width:"sm",children:[r(Be.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Be.Actions,{children:r(it,{onClick:Mr,disabled:Le,children:Le?"Saving...":"Move to Completed"})})]}),r(bn,{isOpen:Qt&&!Xe,onClose:Ht,title:"Resume Playback?",message:r(Wt,{children:["You were watching at ",r("strong",{children:i.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Tr,onRestart:Cr}),r(Be,{isOpen:Bt,onClose:Ht,title:"Episode Completed",width:"sm",children:[r(Be.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Re?" Would you like to watch the next episode?":""]})}),r(Be.Actions,{children:[r(it,{variant:"secondary",onClick:Rr,children:"Replay"}),Re&&r(it,{onClick:Mt,children:`Watch EP ${Re}`})]})]}),r(Be,{isOpen:!!et,onClose:gr,title:"Direct stream failed",width:"sm",children:[r(Be.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),et?.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:qe,onChange:t=>kt(t.target.checked)}),"Remember my choice"]})]}),r(Be.Actions,{children:[r(it,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(it,{onClick:yr,disabled:ht,children:ht?"Searching…":"Try another provider"})]})]}),r(Yr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{A.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),r($s,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{A.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!z&&r("aside",{ref:_e,className:Ae.episodeSidebar,children:e.loadingShowData?r(yn,{variant:"sidebar"}):r(Sn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>h(`/watch/${n}/${t}`)})}),r("div",{className:Ae.playerMain,children:[r("div",{className:`${p.videoContainer} ${i.state.isFullscreen?"":Ae.videoPlayerWrapper} ${i.state.isFullscreen?p.fullscreenActive:""}`,style:{...st?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(Es,{player:i,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:_r,fallbackChoice:tt,onFallbackChoiceChange:rt,ambientSettings:Gt,onAmbientChange:Er,showNextEpisodeButton:!st&&pt&&E.length===0,onNextEpisode:Mt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime),x(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Qe,skipIntervals:e.skipIntervals,animeTitle:ot,episodeNumber:e.currentEpisode,isTheaterMode:z,onTheaterModeToggle:Tt,anime4kEnabled:_.isEnabled,onAnime4kToggle:_.toggle,anime4kSupported:_.isWebGPUSupported,anime4kProfile:y,onAnime4kProfileChange:v,anime4kInitializing:_.isInitializing,anime4kError:_.error,videoDelayEnabled:R,onVideoDelayToggle:q,videoDelayMs:D,onVideoDelayChange:ye,onCalibrateAvSync:De,isInteractingExtra:Nt||Y,className:En.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Wt,{children:[i.state.isSpeedBoostActive&&r("div",{className:p.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(Z,{name:"forward",size:12})]}),M!==null&&Q?.nextItem&&r("div",{className:p.queueCountdown,children:["Queue next in ",M,"s"]})]}),children:[Qe&&r("div",{className:p.loadingOverlay,children:r("div",{className:p.loadingDots,children:[r("div",{className:p.dot}),r("div",{className:p.dot}),r("div",{className:p.dot})]})}),i.state.isBuffering&&!Qe&&e.selectedSource?.type!=="iframe"&&r("div",{className:p.bufferingOverlay,children:r("div",{className:p.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Qe&&r("iframe",{src:e.selectedLink?.link,className:p.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(Wt,{children:[!Qe&&e.videoSources.length===0&&r("div",{className:p.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:p.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:p.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Qe&&e.videoSources.length>0&&r("video",{ref:d.videoRef,controls:i.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:T.onPlay,onPause:T.onPause,onLoadedMetadata:T.onLoadedMetadata,onTimeUpdate:()=>{G||(T.onTimeUpdate(),Q&&d.videoRef.current&&d.videoRef.current.currentTime<d.videoRef.current.duration-1&&(be(null),$e(null)))},onProgress:T.onProgress,onVolumeChange:T.onVolumeChange,onWaiting:T.onWaiting,onPlaying:T.onPlaying,onCanPlay:T.onCanPlay,onError:Zt,onContextMenu:t=>t.preventDefault(),className:dt?p.videoElementHidden:""}),_.isWebGPUSupported&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:Ne,className:`${p.upscalerCanvas} ${F?p.upscalerActive:""}`}),!F&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:lt,className:`${p.upscalerCanvas} ${ut?p.upscalerActive:""}`}),_.isEnabled&&_.isWebGPUSupported&&_.isInitializing&&r("div",{className:p.upscalerStatusBadge,children:"Preparing upscaler…"}),dt&&r("div",{ref:Ue,className:p.subtitleOverlay}),r(wn,{isOpen:Y,ms:D,onChange:ye,onApply:Ze,onClose:St,testClipActive:G,onTestClip:Et})]})]})}),!z&&r(kn,{}),!z&&r(Wt,{children:[Ce&&E.length===0?r(ws,{count:3}):r(_n,{title:"Queue",items:E,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:zt,onRemove:t=>he.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>ft.mutate(),showClearAll:!0,onReorder:t=>xe.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:p.streamPanel,children:[r(ks,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:P,onProviderChange:t=>{Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),o({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),sr(`${p.episodeActions} ${p.desktopEpisodeActions}`,"desktop"),Qe?r("div",{className:p.sourceLoader,children:r("div",{className:p.spinner})}):r(Cs,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime);const a=(t.links||[]).sort((u,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(u.resolutionStr)||0))[0]||null;x(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:a,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(x(e.selectedSource.sourceName),o({type:"SET_STATE",payload:{selectedLink:t}}))}})]}),r("div",{className:Ae.playerInfoContainer,children:[r("div",{className:Ae.playerInfoHeader,children:[r("div",{className:Ae.playerAnimeCard,children:r("img",{src:Xr(e.showMeta.thumbnail||""),alt:ot,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Ae.videoTitleSection,children:[r("div",{className:p.titleContainer,children:[r("h1",{children:ot}),r("div",{className:p.scheduleInfo,children:[e.showMeta.status&&r("span",{className:p.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:p.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:p.controls,children:[r("button",{className:`${p.watchlistBtn} ${e.inWatchlist?p.inList:""}`,onClick:J,children:[e.inWatchlist?r(Z,{name:"check",size:14}):r(Z,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(Pn,{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:`${p.watchlistBtn} ${p.queueBtn}`,activeClassName:p.queueActive}),Nr&&r("button",{className:`${p.watchlistBtn} ${p.markWatchedBtn} ${or?p.markWatchedDone:""}`,onClick:Pr,disabled:V||!e.currentEpisode,children:[r(Z,{name:"check",size:14}),V?"Saving...":or?"Watched":"Mark Watched"]}),r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${e.currentMode==="dub"?p.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";Fe.current=!1,ee.current=[],Ye.current=!1,ge(null),o({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),tr&&r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${i.state.useNativeControls?p.modeToggleActive:""}`,onClick:()=>{const t=!i.state.useNativeControls;i.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:i.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),sr(`${p.episodeActions} ${p.mobileEpisodeActions}`,"mobile"),r("div",{className:Ae.infoColumns,children:[r("div",{className:`${p.descriptionSection} ${p.synopsisFlat}`,children:[r("h3",{children:"Synopsis"}),r(An,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),r("button",{className:p.detailsToggleBtn,onClick:de,children:[e.showCombinedDetails?r(Z,{name:"chevron-up"}):r(Z,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&r(xn,{showMeta:e.showMeta,styles:p})]})]})]})]}),r(Tn,{isOpen:Nt,onClose:()=>wt(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{wt(!1),h(`/watch/${n}/${t}`)}})]})};export{no as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-
|
|
1
|
+
import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-D4ejupic.js";import{u as re}from"./index-C93G341i.js";import"./AvSyncCalibrator-B2fQmjbo.js";import"./vendor-query-BBT5_sHx.js";const ce="_settingsPanel_1dymm_1",oe="_header_1dymm_33",me="_backBtn_1dymm_56",de="_contentWrapper_1dymm_76",ue="_menuContent_1dymm_82",he="_menuItem_1dymm_89",pe="_selected_1dymm_114",be="_currentValue_1dymm_134",ye="_menuNote_1dymm_141",ge="_menuError_1dymm_150",n={settingsPanel:ce,header:oe,backBtn:me,contentWrapper:de,menuContent:ue,menuItem:he,selected:pe,currentValue:be,menuNote:ye,menuError:ge},ve=($,P)=>{const{isOpen:y,onClose:ke,videoSources:Ce,currentSource:C,currentLink:N,onSourceChange:V,subtitles:O,activeSubtitleTrack:g,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:f,anime4kProfile:r,onAnime4kProfileChange:h,anime4kInitializing:L,anime4kError:S,videoDelayEnabled:_,onVideoDelayToggle:M,videoDelayMs:I,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:m,onAutoSkipChange:W,isAutoplayEnabled:d,onAutoplayChange:G,fallbackChoice:p,onFallbackChoiceChange:j,isTheaterMode:q,ambientSettings:b,onAmbientChange:k}=$,{lowEndMode:F}=re(),[a,i]=ne("main");w.useEffect(()=>{if(!y){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[y]);const Q=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>i("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:N?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:g||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),F&&e("button",{className:`${n.menuItem} ${v?n.selected:""}`,onClick:()=>{const t=!v;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),f&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),f&&u&&e("button",{className:n.menuItem,onClick:()=>i("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>i("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:_?`${I}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[m?"Auto-skip On":null,d?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]}),q&&b&&k&&e("button",{className:n.menuItem,onClick:()=>i("ambient"),children:[e("span",{children:"Ambient Light"}),e("span",{className:n.currentValue,children:b.enabled?"On":"Off"})]})]}),R=()=>{const t=C?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:N?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&V(C,c)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:g==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:g===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(se,{classes:{item:n.menuItem,active:n.selected},values:z,onChange:T})}),J=te(()=>{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}},[]),X=()=>e("div",{className:n.menuContent,children:[L&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),S&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",S]}),!J&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="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"})]}),r==="denoise"&&e(o,{name:"check",size:12})]})]}),Y=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>W(!m),"aria-pressed":m,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:m?"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} ${d?n.selected:""}`,onClick:()=>G(!d),"aria-pressed":d,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:d?"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:()=>j(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."})]}),Z=()=>e("div",{className:n.menuContent,children:e(le,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&k?e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:k})}):null;return y?e(ae,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>i("main"),panelRef:P,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&Q(),a==="quality"&&R(),a==="subtitles"&&H(),a==="subtitle-style"&&K(),a==="upscaler"&&X(),a==="av-sync"&&Z(),a==="playback"&&Y(),a==="ambient"&&ee()]}):null},we=w.forwardRef(ve);export{we as default};
|
package/client/dist/assets/{QueueOptionsButton-CIKT4YcD.js → QueueOptionsButton-BMl804vN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as F}from"./vendor-query-BBT5_sHx.js";import{t as T,l as j,Z as H,$ as J,a0 as W}from"./index-
|
|
1
|
+
import{b as F}from"./vendor-query-BBT5_sHx.js";import{t as T,l as j,Z as H,$ as J,a0 as W}from"./index-C93G341i.js";import{d as X,T as R,q as r,u as t,$ as Y,S as w}from"./vendor-core-DfaOB3Rn.js";import{a as ee,c as te,d as ne,b as se,o as oe,f as ae,s as ie}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-DrybRNxP.js";function Pe(n){return F({queryKey:["show-meta",n],queryFn:async()=>n?T.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}async function re(n){try{return await T.watchlist.queueSuggested.query({showId:n})}catch{throw new Error("Failed to resolve suggested episode")}}const ue="_trigger_1vova_6",le="_triggerBtn_1vova_11",me="_chevron_1vova_25",ce="_menu_1vova_34",de="_menuTitle_1vova_51",pe="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",a={trigger:ue,triggerBtn:le,chevron:me,menu:ce,menuTitle:de,menuItem:pe,removeItem:ge,menuEmpty:fe},ve=8,qe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:z="",activeClassName:A="",align:D="right",onMenuOpenChange:p})=>{const{data:E=[]}=j(),P=H(),q=J(),[l,f]=X(!1),{refs:Q,floatingStyles:M,context:S}=ee({open:l,onOpenChange:e=>{e||(f(!1),p?.(!1))},placement:D==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ae({padding:8}),ie({padding:8})],whileElementsMounted:se}),x=te(S,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:C,getFloatingProps:I}=ne([x]),m=R(()=>E.filter(e=>e.showId===n),[E,n]),{data:K}=F({queryKey:["suggestedEpisode",n],queryFn:()=>re(n),enabled:!!n}),{data:$,isFetching:N}=W(n,l),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),p?.(!0)},[p]),c=r(()=>{f(!1),p?.(!1)},[p]),d=m.length>0,o=s.length>0,g=K?.episodeNumber,i=r(e=>{!n||e.length===0||(P.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,P,c]),L=r(()=>{!n||m.length===0||(q.mutate({showId:n,episodeNumbers:m.map(e=>e.episodeNumber)}),c())},[n,m,q,c]),O=r(()=>{o?i([s[0]]):g&&i([String(g)])},[o,s,g,i]),U=r(()=>{o&&i(s.slice(0,3))},[o,s,i]),G=r(()=>{o&&i([...s])},[o,s,i]),B=s[0],V=s[Math.min(2,s.length-1)],Z=t("div",{className:a.trigger,ref:Q.setReference,children:t("span",{className:`${a.triggerBtn} ${z} ${d?A:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":l,"aria-label":d?"Queued":"Queue",...C(),onClick:e=>{e.preventDefault(),e.stopPropagation(),l?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),l?c():k())},children:[d?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),d?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:a.chevron})]})});return t(w,{children:[Z,l&&Y(t("div",{ref:Q.setFloating,className:a.menu,style:M,role:"menu",...I(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:a.menuTitle,children:"Queue episodes"}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o&&!g,onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+3 — EP ${B}${s.length>1?`-${V}`:""}`:"+3"})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:a.menuEmpty,children:d?"All episodes are already queued":"No remaining unwatched episodes"}),d&&t("button",{className:`${a.menuItem} ${a.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),L()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",m.length>0?` (${m.length})`:""]})]})]}),document.body)]})};export{qe as Q,Pe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as s,u as n,a as Y}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{d as L,f as z}from"./index-
|
|
1
|
+
import{g as s,u as n,a as Y}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{d as L,f as z}from"./index-C93G341i.js";const F="_section_1pwqc_1",O="_header_1pwqc_10",j="_headerToggle_1pwqc_20",G="_headerActions_1pwqc_34",J="_title_1pwqc_40",K="_badge_1pwqc_50",V="_clearBtn_1pwqc_65",W="_nextBtn_1pwqc_83",Z="_list_1pwqc_101",ee="_item_1pwqc_114",ne="_active_1pwqc_134",te="_dragging_1pwqc_142",re="_dragHandle_1pwqc_149",ce="_thumbnail_1pwqc_167",ae="_meta_1pwqc_175",oe="_name_1pwqc_182",se="_episode_1pwqc_204",ie="_iconBtn_1pwqc_210",r={section:F,header:O,headerToggle:j,headerActions:G,title:J,badge:K,clearBtn:V,nextBtn:W,list:Z,item:ee,active:ne,dragging:te,dragHandle:re,thumbnail:ce,meta:ae,name:oe,episode:se,iconBtn:ie},le=({item:c,isActive:T,index:m,onRemove:D,onTouchPointerDown:v,onTouchPointerMove:x,onTouchPointerUp:q,onTouchPointerCancel:I,shouldIgnoreClick:_,onDragStart:B,onDragEnter:f,onDragEnd:o,isDragging:w})=>{const a=Y(),{titlePreference:i}=L(),l=c[i]||c.name||"Unknown show";return n("div",{"data-queue-index":m,className:`${r.item} ${T?r.active:""} ${w?r.dragging:""}`,draggable:!0,onDragStart:B,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:o,onPointerDown:u=>v(m,u),onPointerMove:x,onPointerUp:q,onPointerCancel:I,children:[n("button",{className:r.dragHandle,type:"button","aria-label":"Drag queue item",children:n(P,{name:"bars"})}),n("img",{className:r.thumbnail,src:z(c.thumbnail||"",72,96),alt:l,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:r.meta,children:[n("button",{className:r.name,type:"button",onClick:()=>{_()||a(`/watch/${c.showId}/${c.episodeNumber}`)},children:l}),n("div",{className:r.episode,children:["Episode ",c.episodeNumber]})]}),n("button",{className:r.iconBtn,type:"button",onClick:()=>{_()||D(c)},"aria-label":`Remove ${l} episode ${c.episodeNumber} from queue`,children:n(P,{name:"times"})})]})},he=({title:c="Queue",eyebrow:T,items:m,currentShowId:D,currentEpisode:v,onRemove:x,onReorder:q,onNextQueue:I,onClear:_,showClearAll:B=!1,defaultExpanded:f=!0})=>{const[o,w]=s.useState([]),[a,i]=s.useState(null),[l,u]=s.useState(f),b=s.useRef(null),N=s.useRef(null),d=s.useRef(null),p=s.useRef(!1),R=s.useRef(!1);s.useEffect(()=>{w(m)},[m]),s.useEffect(()=>{u(f)},[f]);const E=e=>{i(e)},$=e=>{if(a===null||a===e)return;const t=[...o],h=t[a];t.splice(a,1),t.splice(e,0,h),i(e),w(t)},k=()=>{a!==null&&q(o.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),i(null)},C=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&p.current&&(q(o.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),R.current=!0,window.setTimeout(()=>{R.current=!1},0)),b.current=null,N.current=null,p.current=!1,i(null)},A=(e,t)=>{if(t.pointerType==="mouse")return;const h=t.currentTarget,g=t.pointerId;b.current=t.pointerId,N.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{p.current=!0,i(e);try{h.setPointerCapture(g)}catch{}},220)},Q=e=>{if(e.pointerType==="mouse"||b.current!==e.pointerId)return;if(!p.current&&N.current){const H=Math.abs(e.clientX-N.current.x),X=Math.abs(e.clientY-N.current.y);(H>8||X>8)&&C(!1);return}if(!p.current)return;e.preventDefault();const h=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),g=h?Number(h.dataset.queueIndex):NaN;if(Number.isNaN(g)||a===null||g===a)return;const y=[...o],U=y[a];y.splice(a,1),y.splice(g,0,U),i(g),w(y)},S=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(p.current)},M=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(!1)};return o.length===0?null:n("section",{className:r.section,children:[n("div",{className:r.header,children:[n("button",{className:r.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":l,"aria-label":l?`Collapse ${c}`:`Expand ${c}`,children:[n("span",{className:r.title,children:[n("span",{className:"title-stack",children:[T&&n("div",{className:"section-eyebrow",children:T}),n("span",{children:c})]}),n("span",{className:r.badge,children:o.length})]}),l?n(P,{name:"chevron-up"}):n(P,{name:"chevron-down"})]}),B&&_&&n("div",{className:r.headerActions,children:[I&&o.length>1&&n("button",{className:r.nextBtn,type:"button",onClick:I,children:"Next"}),n("button",{className:r.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),l&&n("div",{className:r.list,children:o.map((e,t)=>n(le,{item:e,isActive:e.showId===D&&e.episodeNumber===v,index:t,onRemove:x,onTouchPointerDown:A,onTouchPointerMove:Q,onTouchPointerUp:S,onTouchPointerCancel:M,shouldIgnoreClick:()=>R.current,onDragStart:()=>E(t),onDragEnter:()=>$(t),onDragEnd:k,isDragging:a===t},e.id))})]})};export{he as Q,r as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as h,A as F,h as y,g as se,u as e,S as
|
|
1
|
+
import{d as h,A as F,h as y,g as se,u as e,S as P,$ as J,T as K}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{b as Z}from"./vendor-query-BBT5_sHx.js";import{h as x,t as G,P as re}from"./index-C93G341i.js";import{a}from"./Asmr.module-CdWlioTY.js";import{r as i}from"./Radio.module-DGSZLpKM.js";import{p as L}from"./page.module-C1MlZzf3.js";const ee=300*1e3,le="https://cdn.listen.moe/covers/";function z(n){return n?n.startsWith("http")?n:`${le}${n}`:null}function oe(n){return n?z(n.albums[0]?.image)||z(n.artists[0]?.image)||z(n.sources[0]?.image):null}function U(n){return n?n.artists.map(s=>s.nameRomaji||s.name).join(", "):""}const ie=()=>{const n=x();return Z({...n.radio.stations.queryOptions(),staleTime:ee})},ce=n=>{const s=x();return Z({...s.radio.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:ee})},X={song:null,lastPlayed:[],listeners:0,startTime:null},de=n=>{const[s,p]=h(X),[l,c]=h(!1),d=F(null);return y(()=>{if(p(X),c(!1),!n)return;let u=null,f=!1;try{u=new WebSocket(n)}catch{return}return u.onopen=()=>{f||c(!0)},u.onmessage=v=>{try{const m=JSON.parse(v.data);if(m.op===0){const N=m.d?.heartbeat||35e3;d.current&&window.clearInterval(d.current),d.current=window.setInterval(()=>{u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({op:9}))},N)}else m.op===1&&p({song:m.d?.song||null,lastPlayed:m.d?.lastPlayed||[],listeners:m.d?.listeners||0,startTime:m.d?.startTime||null})}catch{}},u.onclose=()=>{f||c(!1)},()=>{f=!0,d.current&&window.clearInterval(d.current),d.current=null,u&&u.close()}},[n]),{nowPlaying:s,connected:l}};function Y(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 me=({station:n,nowPlaying:s,connected:p,expanded:l,onStationStep:c,onExpandedChange:d,onClose:u})=>{const f=F(null),[v,m]=h(!1),[N,V]=h(!0),[S,I]=h(!1),[T,k]=h(!0),[A,E]=h(""),[b,D]=h(()=>{const t=parseFloat(localStorage.getItem("radioVolume")||"");return Number.isFinite(t)?t:1}),r=F(""),g=F(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=oe(w)||n.favicon||null,[B,W]=h(!1);y(()=>{W(!1)},[C]);const M=B?null:C,q=!!M,R=w?`${U(w)} — ${w.title}`:n.name;y(()=>{const t=f.current;if(t)return m(!1),t.src=n.streamUrl,t.load(),t.volume=g.current,t.play().catch(()=>m(!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 te=t=>t?Math.max(0,Math.floor((Date.now()-new Date(t).getTime())/1e3)):0,H=se.useCallback(t=>{n&&(G.discord.radioPresence.mutate({title:R,stationLabel:n.name,isPlaying:t,thumbnail:M||"",currentTime:te(s.startTime),sessionId:r.current}).catch(()=>{}),G.discord.heartbeat.mutate({sessionId:r.current}).catch(()=>{}))},[n,R,M,s.startTime]);y(()=>{H(v)},[H,v,n.id,R,l]),y(()=>{if(!v)return;const t=window.setInterval(()=>H(!0),15e3);return()=>window.clearInterval(t)},[v,H]),y(()=>{const t=r.current,$=()=>re(t),O=()=>$(),_=()=>{document.visibilityState==="hidden"&&$()};return window.addEventListener("pagehide",O),window.addEventListener("beforeunload",O),document.addEventListener("visibilitychange",_),()=>{window.removeEventListener("pagehide",O),window.removeEventListener("beforeunload",O),document.removeEventListener("visibilitychange",_),$()}},[]),y(()=>{if(!s.startTime){E("");return}E(Y(s.startTime));const t=window.setInterval(()=>E(Y(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 ae=()=>{const t=f.current;t&&(t.paused?(t.load(),t.play().catch(()=>{})):t.pause())},ne=e(P,{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:ae,"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"]}),A&&e("span",{className:a.timeLabel,children:A}),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…"})]})]}),j=e(P,{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:ne}),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);D($),localStorage.setItem("radioVolume",String($))},style:{"--volume-percent":`${b*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[l&&q&&e("button",{className:a.playerBtn,onClick:()=>V(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:u,"aria-label":"Close player",children:e(o,{name:"times"})})]})]}),Q=e("audio",{ref:f,preload:"none",onPlay:()=>m(!0),onPause:()=>m(!1)});return l?J(e(P,{children:[Q,e("div",{className:`${a.npOverlay} ${T?"":a.npOverlayControlsHidden}`,children:[e("div",{className:`${a.npStage} ${!N||!q?a.npStageBlank:""}`,onClick:()=>k(t=>!t),children:N&&q&&M&&e("div",{className:i.coverWrap,children:e("img",{src:M,alt:R,loading:"lazy",decoding:"async",draggable:!1,className:i.cover,onError:()=>W(!0)})})}),e("div",{className:`${a.playerBar} ${a.playerBarDocked} ${T?"":a.playerBarDockedHidden}`,onClick:t=>t.stopPropagation(),children:[j,S&&e(P,{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:`${U(t)} — ${t.title}`,children:[U(t)," — ",t.title]})},t.id))})]})]})]})]}),document.body):J(e(P,{children:[Q,e("div",{className:a.playerBar,children:j})]}),document.body)},Ne=()=>{y(()=>{document.title="Radio - dango"},[]);const[n,s]=h(""),[p,l]=h(""),[c,d]=h(null),[u,f]=h(!0),{data:v,isLoading:m}=ie(),{data:N,isLoading:V}=ce(p),S=K(()=>v?.stations||[],[v]),I=K(()=>N?.stations||[],[N]),T=p?I:S,{nowPlaying:k,connected:A}=de(c?.gateway),E=r=>{d(r),f(!0)},b=r=>{const g=T.length>0?T:S;if(g.length===0||!c)return;const w=g.findIndex(B=>B.id===c.id),C=g[(w<0?0:w+r+g.length)%g.length];d(C)},D=r=>{const g=c?.id===r.id,w=g&&k.song?`${U(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:()=>E(r),children:[r.favicon?e("img",{src:r.favicon,alt:"",className:i.stationThumb,loading:"lazy",decoding:"async",onError:B=>{B.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:`${L.page} ${c?L.pageWithPlayer:""}`,children:[e("div",{className:L.header,children:[e("h1",{className:L.pageTitle,children:[e(o,{name:"broadcast-tower"})," Radio"]}),e("form",{className:L.searchForm,onSubmit:r=>{r.preventDefault(),l(n)},children:[e("input",{className:L.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:L.searchBtn,type:"submit","aria-label":"Search",children:e(o,{name:"search"})})]})]}),p?e(P,{children:[e("h2",{className:i.sectionTitle,children:["Results for “",p,"”"]}),V?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(D)})]}):e(P,{children:[e("h2",{className:i.sectionTitle,children:"Featured"}),m?e("p",{className:a.statusMsg,children:"Loading…"}):e("div",{className:i.stationList,children:S.map(D)})]}),c&&e(me,{station:c,nowPlaying:k,connected:A,expanded:u,onStationStep:b,onExpandedChange:f,onClose:()=>d(null)})]})};export{Ne as default};
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-cSWL_NlR.js";import{L as F}from"./LibraryListPage-BlNQWLrf.js";import{u as _,M as z}from"./useMangaPopup-DwKm2HYt.js";import{M as D}from"./MangaResetProgressModal-DLgJrIVT.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-DkGSBFSX.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./vendor-icons-DrybRNxP.js";import"./index-C93G341i.js";import"./vendor-query-BBT5_sHx.js";import"./SkeletonGrid-CYZ3cstC.js";import"./ErrorMessage-DAxegITP.js";import"./Watchlist.module-XGtVQr1d.js";import"./usePopup-DS9jMzp6.js";import"./ResetProgressModal-CuoM4S_P.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 ba(){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{ba as default};
|
package/client/dist/assets/{ResetProgressModal-B7UuuL3X.js → ResetProgressModal-CuoM4S_P.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e}from"./vendor-core-DfaOB3Rn.js";import{M as r,B as n}from"./index-
|
|
1
|
+
import{u as e}from"./vendor-core-DfaOB3Rn.js";import{M as r,B as n}from"./index-C93G341i.js";const p=({isOpen:t,itemName:c,progressKind:i,listLabel:s,alsoRemove:a,onAlsoRemoveChange:d,onClose:o,onConfirm:l})=>e(r,{isOpen:t,onClose:o,title:"Reset Progress",children:[e(r.Body,{children:[e("p",{children:["Are you sure you want to remove your ",i,' progress for "',c,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:a,onChange:h=>d(h.target.checked)}),"Also remove from ",s]})]}),e(r.Actions,{children:[e(n,{variant:"secondary",onClick:o,children:"No"}),e(n,{variant:"danger",onClick:l,children:"Yes"})]})]});export{p as R};
|