@serifpersia/dango 4.0.6 → 4.0.7

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.
Files changed (55) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-ZMgtR741.js → AnimeCard-CcvD-9Bi.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-CmDzxK-x.js → AnimeInfo-t3qfap0B.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-BtMHG64S.js → AnimeInfoPage-D3vtcWL7.js} +2 -2
  5. package/client/dist/assets/Asmr-GHxClLoM.js +2 -0
  6. package/client/dist/assets/{AsmrPopup-ER6dDxFM.js → AsmrPopup-Bt7wZkV8.js} +1 -1
  7. package/client/dist/assets/{AsmrResetProgressModal-CmDqGKma.js → AsmrResetProgressModal-Di6VgAZx.js} +1 -1
  8. package/client/dist/assets/{Home-CWsXJfHc.js → Home-C9caLBqU.js} +1 -1
  9. package/client/dist/assets/{Insights-Dlu3LypY.js → Insights-B-jf5_UY.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-L4Lyt1BV.js → LibraryListPage-B5q00Vno.js} +1 -1
  11. package/client/dist/assets/{ListeningList-CEiZWAUS.js → ListeningList-BNUrMPyA.js} +1 -1
  12. package/client/dist/assets/{Manga-CazCyWIh.js → Manga-SYhXSYV_.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-8ZsayGOJ.js → MangaInfoPage-CsGcpQ4g.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-CG59Zuhi.js → MangaReadPage-B0BKdQeU.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-CmIGgwJc.js → MangaResetProgressModal-8Q_Jp8Tk.js} +1 -1
  16. package/client/dist/assets/{Mature-Dw4DVRVT.js → Mature-DtyWIW42.js} +1 -1
  17. package/client/dist/assets/{MatureConsentModal-CBGHgiBA.js → MatureConsentModal-DoPl5ONK.js} +1 -1
  18. package/client/dist/assets/MediaCard-Ce90T0yC.js +1 -0
  19. package/client/dist/assets/{OptionListMenu-BdiwBX1S.js → OptionListMenu-CHqo2pTO.js} +1 -1
  20. package/client/dist/assets/{Player-DJSkQVjM.js → Player-CYrY9dNs.js} +2 -2
  21. package/client/dist/assets/{PlayerProvider-C6humJW5.js → PlayerProvider-CjctET1A.js} +1 -1
  22. package/client/dist/assets/{PlayerSettings-C3MmSKgQ.js → PlayerSettings-uDMPYAlP.js} +1 -1
  23. package/client/dist/assets/{PlayerSurface-C0SuP9xJ.js → PlayerSurface-B_rgFBYD.js} +1 -1
  24. package/client/dist/assets/{QueueOptionsButton-C1o8UacJ.js → QueueOptionsButton-BHkP1DB_.js} +1 -1
  25. package/client/dist/assets/{QueueRail-Dj_zPCND.js → QueueRail-CxtCW4xn.js} +1 -1
  26. package/client/dist/assets/{ReadingList-CMo85dG4.js → ReadingList-C0hu5BhB.js} +1 -1
  27. package/client/dist/assets/{ResetProgressModal-udBYaYWc.js → ResetProgressModal-CncQLVw1.js} +1 -1
  28. package/client/dist/assets/{Search-vE5ITchW.js → Search-J3jIU8gd.js} +1 -1
  29. package/client/dist/assets/{Settings-DTdakL-f.js → Settings-B8jClutS.js} +1 -1
  30. package/client/dist/assets/{SkeletonGrid-CKVHMLEB.js → SkeletonGrid-zCAxRZIz.js} +1 -1
  31. package/client/dist/assets/{Trackers-Cbuzzhap.js → Trackers-DTlCK6Gw.js} +1 -1
  32. package/client/dist/assets/{Tv-z-RzIer_.js → Tv-CnahgiVt.js} +1 -1
  33. package/client/dist/assets/{TvInfo-DBdRrmSJ.js → TvInfo-Co-CnIbQ.js} +1 -1
  34. package/client/dist/assets/{TvPopup-C_TEPZqV.js → TvPopup-Ci4SXMWf.js} +1 -1
  35. package/client/dist/assets/{TvSearch-DhZt3CXR.js → TvSearch-dkkP831q.js} +1 -1
  36. package/client/dist/assets/{TvWatchlist-Dg7X14X1.js → TvWatchlist-CTxHqUB9.js} +1 -1
  37. package/client/dist/assets/{VirtualKeyboard-BkfL6fYx.js → VirtualKeyboard-ClY9H0vl.js} +1 -1
  38. package/client/dist/assets/{WatchAlong-D-Wdl6L6.js → WatchAlong-RAJe62YS.js} +1 -1
  39. package/client/dist/assets/{WatchAlongPanel-BtiB_ErQ.js → WatchAlongPanel-G2j2eopw.js} +1 -1
  40. package/client/dist/assets/{Watchlist-DFXVM31Q.js → Watchlist-D8prt4l1.js} +1 -1
  41. package/client/dist/assets/index-BOJFs4B4.js +180 -0
  42. package/client/dist/assets/{libraryInvalidation-DWCCaTbI.js → libraryInvalidation-1xwHWgGv.js} +1 -1
  43. package/client/dist/assets/{playbackCompletion-DzRc-CrM.js → playbackCompletion-BpEGpC-Z.js} +1 -1
  44. package/client/dist/assets/{useAnimeInfoData-Di0AjMa7.js → useAnimeInfoData-CvV6vRjn.js} +1 -1
  45. package/client/dist/assets/{useMangaLibrary-DQvZO29f.js → useMangaLibrary-OgS0RRdO.js} +1 -1
  46. package/client/dist/assets/{useMangaPopup-BiaJvL8C.js → useMangaPopup-Eyed-Gg3.js} +1 -1
  47. package/client/dist/assets/{useTv-Daayom0r.js → useTv-SLXsIWFQ.js} +1 -1
  48. package/client/dist/assets/{useTvLibrary-7zDxMjFz.js → useTvLibrary-F0S6WnwD.js} +1 -1
  49. package/client/dist/assets/{useWatchAlongPlayer-BNJCb3D5.js → useWatchAlongPlayer-D-fPdbp2.js} +1 -1
  50. package/client/dist/index.html +1 -1
  51. package/package.json +2 -2
  52. package/server/package.json +1 -1
  53. package/client/dist/assets/Asmr-Ct7Pp0i7.js +0 -2
  54. package/client/dist/assets/MediaCard-Bd24Icus.js +0 -1
  55. package/client/dist/assets/index-hrS3r0UE.js +0 -179
@@ -1 +1 @@
1
- import{x as Se,X as Le,u as m,A,q as ye,h as X,d as oe,T as me,_ as Fe,C as ve}from"./vendor-core-DfaOB3Rn.js";import{I as re}from"./vendor-icons-C1Pj_eSX.js";import{a4 as ke,p as ge,i as he}from"./index-hrS3r0UE.js";const Ee=Le(null);function q(){const n=Se(Ee);if(!n)throw new Error("Player controls must be inside a PlayerProvider.");return n}function we(n,r){const t=q(),a=A(r);a.current=r;const u=n?.url,p=n?.hls,s=ye(k=>{t.mediaRef.current=k,t.connect()},[t]);return X(()=>{if(u)return t.loadSource({url:u,hls:p},a.current)},[t,u,p]),s}function rt({source:n,sourceOptions:r,...t}){const a=we(n,r);return m("video",{playsInline:!0,disablePictureInPicture:!0,...t,ref:a})}function at({source:n,sourceOptions:r,...t}){const a=we(n,r);return m("audio",{...t,ref:a})}const _e="_shell_qjnah_1",Me="_stage_qjnah_38",Re="_topBarTitleInfo_qjnah_59",xe="_streamDetails_qjnah_65",Ce="_modeTag_qjnah_86",Ae="_shellFill_qjnah_122",Be="_shellFullscreen_qjnah_130",De="_uiLayer_qjnah_145",Ie="_engineStatus_qjnah_156",$e="_volumeWrap_qjnah_169",Ne="_volumeSlider_qjnah_175",pe={shell:_e,stage:Me,topBarTitleInfo:Re,streamDetails:xe,modeTag:Ce,shellFill:Ae,shellFullscreen:Be,uiLayer:De,engineStatus:Ie,volumeWrap:$e,volumeSlider:Ne},qe=({classes:n,videoRef:r,duration:t,formatTime:a,isScrubbing:u,buffered:p="auto",onSeek:s,onScrubStart:k,onScrubMove:v,onScrubEnd:M,timeLabelRef:E,children:w})=>{const b=A(null),L=A(null),S=A(null),g=A(null),T=A(null),f=A(!1),l=A(u);l.current=u;const y=A({onScrubMove:v,onScrubEnd:M});y.current={onScrubMove:v,onScrubEnd:M};const[N,C]=oe({time:0,position:null});X(()=>{const c=r.current;if(!c)return;const d=D=>{const V=D/t*100||0;b.current?.setAttribute("aria-valuenow",String(Math.round(D))),b.current?.setAttribute("aria-valuetext",`${a(D)} of ${a(t)}`),L.current&&(L.current.style.width=`${V}%`),S.current&&(S.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${a(D)} / ${a(t)}`)},x=()=>{u||d(c.currentTime)},B=()=>{if(p==="auto"&&c.buffered.length>0){const V=c.buffered.end(c.buffered.length-1)/t*100||0;g.current&&(g.current.style.width=`${V}%`)}};return d(c.currentTime),B(),c.addEventListener("timeupdate",x),c.addEventListener("progress",B),()=>{c.removeEventListener("timeupdate",x),c.removeEventListener("progress",B)}},[r,t,u,p,a,E]);const O=c=>{if(!b.current)return 0;const d=b.current.getBoundingClientRect();return d.width<=0?0:Math.min(1,Math.max(0,(c-d.left)/d.width))},Q=c=>{const d=c*t;b.current?.setAttribute("aria-valuenow",String(Math.round(d))),b.current?.setAttribute("aria-valuetext",`${a(d)} of ${a(t)}`);const x=d/t*100||0;L.current&&(L.current.style.width=`${x}%`),S.current&&(S.current.style.left=`${x}%`),E?.current&&(E.current.innerText=`${a(d)} / ${a(t)}`);const B=b.current?.getBoundingClientRect();C({time:d,position:B?c*B.width:null})};X(()=>{if(!u){T.current=null;return}const c=x=>{if(T.current!==null&&x.pointerId!==T.current||!t)return;const B=O(x.clientX);y.current.onScrubMove(B);const D=B*t;b.current?.setAttribute("aria-valuenow",String(Math.round(D))),b.current?.setAttribute("aria-valuetext",`${a(D)} of ${a(t)}`);const V=D/t*100||0;L.current&&(L.current.style.width=`${V}%`),S.current&&(S.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${a(D)} / ${a(t)}`);const ee=b.current?.getBoundingClientRect();C({time:D,position:ee?B*ee.width:null})},d=x=>{T.current!==null&&x.pointerId!==T.current||(T.current=null,f.current=!0,x.pointerType!=="mouse"&&C({time:0,position:null}),y.current.onScrubEnd())};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d)}},[u,t,a,E]);const J=c=>{if(c.pointerType==="mouse"&&c.button!==0||!r.current||!t)return;c.preventDefault(),T.current=c.pointerId;try{b.current?.setPointerCapture(c.pointerId)}catch{}l.current||(l.current=!0,k());const d=O(c.clientX);v(d),Q(d)},ae=c=>{if(!t||l.current||c.pointerType!=="mouse")return;const d=O(c.clientX);C({time:d*t,position:c.clientX-(b.current?.getBoundingClientRect().left??0)})},G=c=>{if(!(T.current!==null&&c.pointerId!==T.current)&&l.current){T.current=null,f.current=!0,c.pointerType!=="mouse"&&C({time:0,position:null});try{b.current?.hasPointerCapture(c.pointerId)&&b.current.releasePointerCapture(c.pointerId)}catch{}M()}};return m("div",{className:`${n.container} ${u&&n.scrubbing?n.scrubbing:""}`,ref:b,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.round(t||0),"aria-valuenow":Math.round(r.current?.currentTime||0),"aria-disabled":!t,tabIndex:0,onClick:c=>{if(f.current){f.current=!1;return}!r.current||isNaN(t)||t===0||s(O(c.clientX))},onPointerDown:J,onPointerMove:ae,onPointerUp:G,onPointerCancel:G,onMouseMove:c=>{if(u||!t)return;const d=O(c.clientX);C({time:d*t,position:c.clientX-(b.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{u||C({time:0,position:null})},onKeyDown:c=>{if(!(!r.current||!t)&&((c.key==="Home"||c.key==="End")&&(c.preventDefault(),s(c.key==="Home"?0:1)),c.key==="ArrowRight"||c.key==="ArrowLeft")){c.preventDefault();const d=(c.key==="ArrowRight"?5:-5)/t,x=r.current.currentTime/t||0;s(Math.min(1,Math.max(0,x+d)))}},children:[N.position!==null&&m("div",{className:n.timeBubble,style:{left:N.position},children:a(N.time)}),m("div",{className:n.bar,children:[m("div",{className:n.buffered,ref:g,style:p==="full"?{width:"100%"}:void 0}),m("div",{className:n.watched,ref:L}),m("div",{className:n.thumb,ref:S,onMouseDown:c=>{c.preventDefault(),r.current&&(l.current||k())}}),w]})]})};function ue(){try{if(typeof window>"u")return!1;const n=window.matchMedia?.("(pointer: coarse)").matches??!1,t=(navigator.maxTouchPoints??0)>0||"ontouchstart"in window;return n||t}catch{return!1}}function Ve(){const[n,r]=oe(ue);return X(()=>{r(ue());let t=null;const a=()=>r(ue());try{t=window.matchMedia("(pointer: coarse)"),t.addEventListener?t.addEventListener("change",a):t.addListener(a)}catch{}return window.addEventListener("touchstart",a,{passive:!0,once:!0}),()=>{try{t&&(t.removeEventListener?t.removeEventListener("change",a):t.removeListener(a))}catch{}window.removeEventListener("touchstart",a)}},[]),n}const je=450,He=({muted:n,volume:r,volumeIcon:t,buttonClassName:a,sliderClassName:u,onToggleMute:p,onVolumeChange:s,onExpandedChange:k})=>{const v=Ve(),[M,E]=oe(!1),w=A(null),b=A(!1),L=A(null),S=ye(y=>{E(y),k?.(y)},[k]);X(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),X(()=>{if(!M)return;const y=N=>{L.current&&!L.current.contains(N.target)&&S(!1)};return document.addEventListener("pointerdown",y),()=>document.removeEventListener("pointerdown",y)},[M,S]);const g=n?0:r,T=()=>{b.current=!1,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{b.current=!0,S(!0)},je)},f=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},l=y=>{if(y.stopPropagation(),b.current){b.current=!1;return}if(v){M?p():S(!0);return}p()};return m("div",{ref:L,className:pe.volumeWrap,"data-expanded":M?"true":"false",onContextMenu:y=>y.preventDefault(),children:[m("button",{type:"button",className:a,onClick:l,onPointerDown:T,onPointerUp:f,onPointerLeave:f,onContextMenu:y=>y.preventDefault(),"aria-label":n?"Unmute":"Mute","aria-expanded":M,children:t}),m("input",{type:"range",min:"0",max:"1",step:"0.05",value:g,onChange:y=>s(parseFloat(y.currentTarget.value)),onClick:y=>y.stopPropagation(),onPointerDown:y=>y.stopPropagation(),onContextMenu:y=>y.preventDefault(),className:`${pe.volumeSlider} ${u??""}`,style:{"--volume-percent":`${g*100}%`},"aria-label":"Volume"})]})};let te=null,le=null;async function Ue(){return te||(le||(le=ke(()=>import("./hls-BOLXTnjL.js"),[]).then(n=>(te=n.default,te)).catch(()=>null)),le)}function Ke(n){return n.canPlayType("application/vnd.apple.mpegurl")!==""||n.canPlayType("application/x-mpegURL")!==""}let ne=null,ce=null;async function Oe(){return ne||(ce||(ce=ke(()=>import("./dash.all.min-CsDAls03.js"),[]).then(n=>(ne=We(n),ne)).catch(()=>null)),ce)}function We(n){const r=n,t=r?.default?.MediaPlayer??r?.MediaPlayer??r?.default;return typeof t!="function"?null:{MediaPlayer:t}}function se(){return document}function fe(n){const r=se();if(document.fullscreenElement)return document.fullscreenElement;if(r.webkitFullscreenElement)return r.webkitFullscreenElement;const t=n;return t?.webkitDisplayingFullscreen?t:null}function Te(n){return fe(n)!==null}async function Xe(n,r){if(fe(r))return;const t=n;try{if(typeof n.requestFullscreen=="function"){await n.requestFullscreen();return}if(typeof t.webkitRequestFullscreen=="function"){await t.webkitRequestFullscreen();return}if(typeof t.webkitRequestFullScreen=="function"){await t.webkitRequestFullScreen();return}}catch{}const a=r;if(a&&typeof a.webkitEnterFullscreen=="function"){if(a.webkitSupportsFullscreen===!1)return;try{await a.webkitEnterFullscreen()}catch{}}}async function Qe(n){const r=se();try{if(document.fullscreenElement&&typeof document.exitFullscreen=="function"){await document.exitFullscreen();return}if(r.webkitFullscreenElement&&typeof r.webkitExitFullscreen=="function"){await r.webkitExitFullscreen();return}}catch{}const t=n;if(t?.webkitDisplayingFullscreen&&typeof t.webkitExitFullscreen=="function"){try{t.webkitExitFullscreen()}catch{}return}try{typeof r.webkitCancelFullScreen=="function"?r.webkitCancelFullScreen():!document.fullscreenElement&&typeof document.exitFullscreen=="function"&&(document.fullscreenElement??r.webkitFullscreenElement)&&await document.exitFullscreen()}catch{}}async function Ge(n,r){!n&&!r||(Te(r)?await Qe(r):n&&await Xe(n,r))}function ze(n,r){const t=()=>{try{r(Te(n()))}catch{}},a=se(),u=t;a.addEventListener("fullscreenchange",t),a.addEventListener("webkitfullscreenchange",u),a.addEventListener("webkitbeginfullscreen",u,!0),a.addEventListener("webkitendfullscreen",u,!0);const p=n();return p?.addEventListener("webkitbeginfullscreen",u),p?.addEventListener("webkitendfullscreen",u),()=>{a.removeEventListener("fullscreenchange",t),a.removeEventListener("webkitfullscreenchange",u),a.removeEventListener("webkitbeginfullscreen",u,!0),a.removeEventListener("webkitendfullscreen",u,!0),p?.removeEventListener("webkitbeginfullscreen",u),p?.removeEventListener("webkitendfullscreen",u)}}let U=null;function be(n){try{return n?ge.getItem(n):null}catch{return null}}function Z(n,r){try{n&&ge.setItem(n,String(r))}catch{}}function Je(n={}){const r=Number.parseFloat(be(n.volumeKey)??"");let t={isPlaying:!1,isBuffering:!1,isMuted:be(n.mutedKey)==="true",volume:Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,duration:0,playbackRate:1,isScrubbing:!1,isFullscreen:!1,showControls:!0,isSpeedBoostActive:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1,error:null,playBlocked:!1,playbackLocked:!1},a={currentTime:0,bufferedEnd:0};const u=new Set,p=new Set,s={current:null},k={current:null};let v=null,M=()=>{},E=()=>{},w=0,b=!1,L=1,S=!1,g=null,T=null,f=!1;function l(e){Object.entries(e).every(([i,o])=>Object.is(t[i],o))||(t={...t,...e},u.forEach(i=>i()))}function y(e){a.currentTime===e.currentTime&&a.bufferedEnd===e.bufferedEnd||(a=e,p.forEach(i=>i()))}function N(e){if(!e)return;let i=0;for(let o=0;o<e.buffered.length;o++)if(e.buffered.start(o)<=e.currentTime&&e.buffered.end(o)>=e.currentTime){i=e.buffered.end(o);break}y({currentTime:Number.isFinite(e.currentTime)?e.currentTime:0,bufferedEnd:i})}function C(){N(s.current)}function O(){const e=s.current;if(v===e||(v&&(U===v&&(U=e),N(v),E(),v.pause(),v.removeAttribute("src"),v.load()),M(),v=e,!e))return;S=!1,U||(U=e),e.volume=t.volume,e.muted=t.isMuted,e.playbackRate=t.playbackRate;const i=()=>{const h=Array.from(e.textTracks);if(!h.length)return;const j=h.findIndex(H=>H.mode==="showing");l({subtitleTracks:h.map((H,z)=>({id:z,label:H.label||H.language||`Track ${z+1}`,language:H.language})),...j>=0?{activeSubtitleTrack:j}:{}})},o={play:()=>{U=e,l({isPlaying:!0,playBlocked:!1,error:null})},playing:()=>l({isPlaying:!0,isBuffering:!1,playBlocked:!1}),pause:()=>l({isPlaying:!1,isBuffering:!1}),ended:()=>{l({isPlaying:!1,isBuffering:!1}),C()},waiting:()=>{!e.paused&&(e.readyState<3||e.seeking)&&l({isBuffering:!0})},canplay:()=>l({isBuffering:!1}),seeking:()=>{e.paused||l({isBuffering:!0}),C()},seeked:()=>{l({isBuffering:!1}),C()},timeupdate:()=>{C(),!e.paused&&!e.seeking&&l({isBuffering:!1})},progress:C,loadedmetadata:()=>{e.playbackRate=t.playbackRate,l({duration:Number.isFinite(e.duration)?e.duration:0}),i()},durationchange:()=>l({duration:Number.isFinite(e.duration)?e.duration:0}),ratechange:()=>{t.isSpeedBoostActive||(L=e.playbackRate),e.defaultPlaybackRate!==e.playbackRate&&(e.defaultPlaybackRate=e.playbackRate),l({playbackRate:e.playbackRate})},volumechange:()=>{l({volume:e.volume,isMuted:e.muted}),Z(n.volumeKey,e.volume),Z(n.mutedKey,e.muted)},error:()=>l({error:e.error?.message||"Unable to play this source.",isPlaying:!1,isBuffering:!1})};Object.entries(o).forEach(([h,j])=>e.addEventListener(h,j)),e.textTracks.addEventListener("addtrack",i),e.textTracks.addEventListener("removetrack",i),e.textTracks.addEventListener("change",i);const F=()=>e.tagName==="VIDEO"?e:null,W=()=>{const h=fe(F());l({isFullscreen:h!==null&&(h===e||h===k.current)})},I=typeof document>"u"?()=>{}:ze(F,W);typeof document<"u"&&W(),M=()=>{Object.entries(o).forEach(([h,j])=>e.removeEventListener(h,j)),I(),e.textTracks.removeEventListener("addtrack",i),e.textTracks.removeEventListener("removetrack",i),e.textTracks.removeEventListener("change",i)}}async function Q(){if(t.playbackLocked&&!f)return!1;const e=s.current;if(!e)return!1;U=e;const i=w;try{return await e.play(),i===w}catch(o){if(i===w){const F=o instanceof Error&&o.name==="NotAllowedError",W=o instanceof Error&&o.name==="AbortError";l({isPlaying:!1,isBuffering:!1,playBlocked:F,...!F&&!W?{error:o instanceof Error?o.message:"Playback failed."}:{}})}return!1}}function J(){t.playbackLocked&&!f||s.current?.pause()}function ae(){s.current?.paused?Q():J()}function G(e){if(t.playbackLocked&&!f)return;const i=s.current;if(!i||!Number.isFinite(e))return;let o=Math.max(0,e);if(Number.isFinite(i.duration))o=Math.min(i.duration,o);else if(i.seekable.length)for(let F=0;F<i.seekable.length;F++){if(o<=i.seekable.end(F)){o=Math.max(i.seekable.start(F),o);break}F===i.seekable.length-1&&(o=i.seekable.end(F))}i.currentTime=o,C()}function c(e){G((s.current?.currentTime??a.currentTime)+e)}function d(e){if(!Number.isFinite(e))return;const i=Math.max(0,Math.min(1,e));l({volume:i,isMuted:i===0}),s.current&&(s.current.volume=i,s.current.muted=i===0),Z(n.volumeKey,i),Z(n.mutedKey,i===0)}function x(){const e=!t.isMuted;!e&&t.volume===0&&d(.5),l({isMuted:e}),s.current&&(s.current.muted=e),Z(n.mutedKey,e)}function B(e){if(t.playbackLocked&&!f||!Number.isFinite(e)||e<.25||e>4)return;L=e;const i=t.isSpeedBoostActive?2:e;l({playbackRate:i}),s.current&&(s.current.playbackRate=i)}function D(){t.playbackLocked||t.isScrubbing||(b=!!s.current&&!s.current.paused,l({isScrubbing:!0}),J())}function V(){t.isScrubbing&&(l({isScrubbing:!1}),b&&Q(),b=!1)}function ee(e,i={}){E(),O();const o=s.current,F=++w;if(!o)return()=>{};let W=!1,I=null;const h=()=>!W&&w===F&&s.current===o;o.pause(),o.removeAttribute("src"),o.load(),l({duration:0,isPlaying:!1,isBuffering:!0,isScrubbing:!1,error:null,playBlocked:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1}),y({currentTime:0,bufferedEnd:0});const j=()=>{h()&&i.initialTime&&i.initialTime>0&&G(i.initialTime)};o.addEventListener("loadedmetadata",j,{once:!0});const H=()=>{h()&&(i.onReady?.(),i.autoPlay&&h()&&Q())},z=P=>{if(!h())return;const R=P instanceof Error?P:new Error(String(P));l({error:R.message,isPlaying:!1,isBuffering:!1}),i.onError?.(R)},Y=()=>{W||(W=!0,o.removeEventListener("loadedmetadata",j),o.removeEventListener("error",de),I?.destroy(),g===I&&(g=null),I=null,T?.destroy(),T=null,w===F&&w++)},de=()=>{z(new Error(o.error?.message||"Unable to play this source.")),Y()};return o.addEventListener("error",de),E=Y,(async()=>{if(e.dash){const P=await Oe();if(!h())return;if(!P)throw new Error("DASH playback is unavailable in this browser.");const R=P.MediaPlayer().create();if(T=R,R.on("streamActivated",H),R.on("error",ie=>{const _=ie,$=_?.error?.message||_?.message||"DASH stream failed.";z(new Error($)),Y()}),!h())return;i.onDash?.(R),R.initialize(o,e.url);return}if(e.hls){const P=await Ue();if(!h())return;if(P?.isSupported()){I=new P({enableWorker:!0,startPosition:i.initialTime??-1,...i.hlsConfig}),g=I;const R=I,ie=()=>{h()&&l({audioTracks:R.audioTracks.map((_,$)=>({id:$,label:_.name||_.lang||`Track ${$+1}`,language:_.lang})),...o.querySelector("track")?{}:{subtitleTracks:R.subtitleTracks.map((_,$)=>({id:$,label:_.name||_.lang||`Track ${$+1}`,language:_.lang}))},qualities:R.levels.map((_,$)=>({id:$,label:_.height?`${_.height}p`:`${Math.round(_.bitrate/1e3)}k`})),activeAudioTrack:R.audioTrack,...o.querySelector("track")?{}:{activeSubtitleTrack:R.subtitleTrack},activeQuality:R.currentLevel})};for(const _ of[P.Events.MANIFEST_PARSED,P.Events.AUDIO_TRACKS_UPDATED,P.Events.AUDIO_TRACK_SWITCHED,P.Events.SUBTITLE_TRACKS_UPDATED,P.Events.SUBTITLE_TRACK_SWITCH,P.Events.LEVEL_SWITCHED])R.on(_,ie);if(I.on(P.Events.ERROR,(_,$)=>{$.fatal&&h()&&(z(new Error(`Stream failed (${$.details}). Try another source or reload.`)),Y())}),I.once(P.Events.MANIFEST_PARSED,H),i.onHls?.(I,P),!h())return;I.loadSource(e.url),I.attachMedia(o);return}if(!Ke(o))throw new Error("HLS playback is unavailable in this browser.")}h()&&(o.src=e.url,o.load(),H())})().catch(P=>{z(P),Y()}),Y}return{mediaRef:s,containerRef:k,connect:O,getState:()=>t,getTimeline:()=>a,getHls:()=>g,isActive:()=>U===s.current,subscribe:e=>(u.add(e),()=>{u.delete(e)}),subscribeTimeline:e=>(p.add(e),()=>{p.delete(e)}),play:Q,pause:J,togglePlay:ae,seek:G,seekRelative:c,setVolume:d,toggleMute:x,setPlaybackRate:B,setPlaybackLocked:e=>l({playbackLocked:e}),applyRemotePlayback:(e,i,o)=>{f=!0;try{e!==void 0&&G(e),Math.abs(t.playbackRate-o)>.001&&B(o),i&&s.current?.paused?Q():!i&&!s.current?.paused&&J()}finally{f=!1}},setAudioTrack:e=>{g&&t.audioTracks.some(i=>i.id===e)&&(g.audioTrack=e,l({activeAudioTrack:e}))},setSubtitleTrack:e=>{if(e!==-1&&!t.subtitleTracks.some(o=>o.id===e))return;const i=s.current;i?.querySelector("track")?Array.from(i.textTracks).forEach((o,F)=>{o.mode=F===e?"showing":"disabled"}):g&&(g.subtitleTrack=e),l({activeSubtitleTrack:e})},setQuality:e=>{g&&(e===-1||t.qualities.some(i=>i.id===e))&&(g.currentLevel=e,l({activeQuality:e}))},setSpeedBoost:e=>{if(t.playbackLocked)return;const i=e?2:L;l({isSpeedBoostActive:e,playbackRate:i}),s.current&&(s.current.playbackRate=i)},setShowControls:e=>l({showControls:e}),startScrubbing:D,endScrubbing:V,loadSource:ee,unload:()=>{const e=s.current;N(e),E(),e&&(e.pause(),e.removeAttribute("src"),e.load()),l({isPlaying:!1,isBuffering:!1,duration:0,error:null}),y({currentTime:0,bufferedEnd:0})},toggleFullscreen:()=>{const e=s.current;Ge(k.current,e?.tagName==="VIDEO"?e:null).catch(i=>l({error:i instanceof Error?i.message:"Fullscreen failed."}))},reset:()=>{l({duration:0,isBuffering:!1,error:null}),y({currentTime:0,bufferedEnd:0})},destroy:()=>{if(S)return;S=!0;const e=v??s.current;N(e),M(),v=null,E(),e?.pause(),e?.removeAttribute("src"),e?.load(),U===e&&(U=null)}}}function K(n){return ve(n.subscribe,n.getState)}function Pe(n){return ve(n.subscribeTimeline,n.getTimeline)}function it(n={}){const r=A(n),t=me(()=>Je(r.current),[]);return Fe(()=>{t.connect()}),X(()=>()=>t.destroy(),[t]),me(()=>({engine:t,mediaRef:t.mediaRef}),[t])}function Ye({children:n,...r}){const t=q(),{isPlaying:a,playbackLocked:u}=K(t);return m("button",{type:"button","aria-label":a?"Pause":"Play",...r,disabled:u||r.disabled,onClick:t.togglePlay,children:n??m(re,{name:a?"pause":"play"})})}function ut({seconds:n,children:r,...t}){const a=q(),{playbackLocked:u}=K(a);return m("button",{type:"button","aria-label":`Seek ${n<0?"back":"forward"} ${Math.abs(n)} seconds`,...t,disabled:u||t.disabled,onClick:()=>a.seekRelative(n),children:r??m(re,{name:n<0?"replay-10":"forward-10"})})}function lt(n){const r=q(),{isFullscreen:t}=K(r);return m("button",{type:"button","aria-label":t?"Exit Fullscreen":"Fullscreen",...n,onClick:r.toggleFullscreen,children:m(re,{name:t?"compress":"expand"})})}function ct({buttonClassName:n,onExpandedChange:r}){const t=q(),{isMuted:a,volume:u}=K(t);return m(He,{muted:a,volume:u,volumeIcon:m(re,{name:a||u===0?"volume-mute":u<.5?"volume-down":"volume-up"}),buttonClassName:n,onToggleMute:t.toggleMute,onVolumeChange:t.setVolume,onExpandedChange:r})}function ot({className:n}){const r=q(),{volume:t,isMuted:a}=K(r);return m("input",{type:"range",min:0,max:1,step:.01,value:a?0:t,onChange:u=>r.setVolume(Number(u.currentTarget.value)),className:n,style:{"--volume-percent":`${(a?0:t)*100}%`},"aria-label":"Volume"})}function st({classes:n,timeLabelRef:r,children:t}){const a=q(),{duration:u,isScrubbing:p,playbackLocked:s}=K(a);return m("div",{inert:s||void 0,style:{display:"contents"},children:m(qe,{classes:n,videoRef:a.mediaRef,duration:u,formatTime:he,isScrubbing:p,onSeek:k=>a.seek(k*u),onScrubStart:a.startScrubbing,onScrubMove:k=>a.seek(k*u),onScrubEnd:a.endScrubbing,timeLabelRef:r,children:t})})}function ft({className:n}){const r=q(),{currentTime:t,bufferedEnd:a}=Pe(r),{duration:u,playbackLocked:p}=K(r),s=u?Math.min(100,t/u*100):0,k=u?Math.min(100,Math.max(s,a/u*100)):0;return m("input",{type:"range",disabled:p,min:0,max:u,step:.1,value:Math.min(t,u),onChange:v=>r.seek(Number(v.currentTarget.value)),onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),r.startScrubbing()},onPointerUp:r.endScrubbing,onPointerCancel:r.endScrubbing,onLostPointerCapture:r.endScrubbing,className:n,style:{"--played-percent":`${s}%`,"--buffered-percent":`${k}%`},"aria-label":"Seek"})}function dt({className:n,durationOnly:r=!1}){const t=q(),{currentTime:a}=Pe(t),{duration:u}=K(t);return m("span",{className:n,children:he(r?u:a)})}function mt(){const n=q(),{error:r,playBlocked:t,isBuffering:a,playbackLocked:u}=K(n);return r?m("div",{role:"alert",children:r}):t&&u?m("span",{children:"Enable playback from the watch-along panel."}):t?m(Ye,{children:"Tap to play"}):a?m("div",{role:"status","aria-label":"Buffering",children:"Loading…"}):null}const Ze='input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable]:not([contenteditable="false"]), [data-player-ui="true"], [data-speed-boost-ignore="true"]';function pt(n,r,t=!0){const a=A(r);a.current=r,X(()=>{if(!t)return;let u=!1,p=!1,s=!1,k,v,M=!1;const E=()=>{const f=p||s;f!==M&&(M=f,n.setSpeedBoost(f))},w=f=>f instanceof Element&&!!f.closest(Ze),b=f=>{if(!n.isActive()||!n.mediaRef.current||f.defaultPrevented||f.ctrlKey||f.metaKey||f.altKey||w(f.target))return;if(f.code==="Space"){if(f.preventDefault(),u)return;u=!0,k=setTimeout(()=>{k=void 0,p=!0,E()},180),a.current();return}const l=f.key.toLowerCase();["k","j","l","arrowleft","arrowright","arrowup","arrowdown","m","f"].includes(l)&&(f.preventDefault(),!(f.repeat&&["k","m","f"].includes(l))&&(l==="k"&&n.togglePlay(),(l==="j"||l==="arrowleft")&&n.seekRelative(-10),(l==="l"||l==="arrowright")&&n.seekRelative(10),l==="arrowup"&&n.setVolume(n.getState().volume+.1),l==="arrowdown"&&n.setVolume(n.getState().volume-.1),l==="m"&&n.toggleMute(),l==="f"&&n.toggleFullscreen(),a.current()))},L=f=>{f.code!=="Space"||!u||(f.preventDefault(),u=!1,clearTimeout(k),k=void 0,p?(p=!1,E()):n.togglePlay(),a.current())},S=f=>{const l=f.target;f.button!==0||!(l instanceof Element)||w(l)||!n.containerRef.current?.contains(l)||(clearTimeout(v),v=setTimeout(()=>{v=void 0,s=!0,E()},180))},g=()=>{clearTimeout(v),v=void 0,s=!1,E()},T=()=>{clearTimeout(k),k=void 0,u=!1,p=!1,g()};return document.addEventListener("keydown",b),document.addEventListener("keyup",L),document.addEventListener("pointerdown",S),document.addEventListener("pointerup",g),document.addEventListener("pointercancel",g),window.addEventListener("blur",T),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",L),document.removeEventListener("pointerdown",S),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",g),window.removeEventListener("blur",T),T()}},[n,t])}function bt({engine:n,children:r}){return m(Ee.Provider,{value:n,children:r})}export{lt as F,st as P,ut as S,ot as V,Ye as a,ct as b,rt as c,K as d,bt as e,q as f,Pe as g,pt as h,dt as i,ft as j,mt as k,at as l,Te as m,Ve as n,pe as s,it as u};
1
+ import{x as Se,X as Le,u as m,A,q as ye,h as X,d as oe,T as me,_ as Fe,C as ve}from"./vendor-core-DfaOB3Rn.js";import{I as re}from"./vendor-icons-C1Pj_eSX.js";import{a4 as ke,p as ge,i as he}from"./index-BOJFs4B4.js";const Ee=Le(null);function q(){const n=Se(Ee);if(!n)throw new Error("Player controls must be inside a PlayerProvider.");return n}function we(n,r){const t=q(),a=A(r);a.current=r;const u=n?.url,p=n?.hls,s=ye(k=>{t.mediaRef.current=k,t.connect()},[t]);return X(()=>{if(u)return t.loadSource({url:u,hls:p},a.current)},[t,u,p]),s}function rt({source:n,sourceOptions:r,...t}){const a=we(n,r);return m("video",{playsInline:!0,disablePictureInPicture:!0,...t,ref:a})}function at({source:n,sourceOptions:r,...t}){const a=we(n,r);return m("audio",{...t,ref:a})}const _e="_shell_qjnah_1",Me="_stage_qjnah_38",Re="_topBarTitleInfo_qjnah_59",xe="_streamDetails_qjnah_65",Ce="_modeTag_qjnah_86",Ae="_shellFill_qjnah_122",Be="_shellFullscreen_qjnah_130",De="_uiLayer_qjnah_145",Ie="_engineStatus_qjnah_156",$e="_volumeWrap_qjnah_169",Ne="_volumeSlider_qjnah_175",pe={shell:_e,stage:Me,topBarTitleInfo:Re,streamDetails:xe,modeTag:Ce,shellFill:Ae,shellFullscreen:Be,uiLayer:De,engineStatus:Ie,volumeWrap:$e,volumeSlider:Ne},qe=({classes:n,videoRef:r,duration:t,formatTime:a,isScrubbing:u,buffered:p="auto",onSeek:s,onScrubStart:k,onScrubMove:v,onScrubEnd:M,timeLabelRef:E,children:w})=>{const b=A(null),L=A(null),S=A(null),g=A(null),T=A(null),f=A(!1),l=A(u);l.current=u;const y=A({onScrubMove:v,onScrubEnd:M});y.current={onScrubMove:v,onScrubEnd:M};const[N,C]=oe({time:0,position:null});X(()=>{const c=r.current;if(!c)return;const d=D=>{const V=D/t*100||0;b.current?.setAttribute("aria-valuenow",String(Math.round(D))),b.current?.setAttribute("aria-valuetext",`${a(D)} of ${a(t)}`),L.current&&(L.current.style.width=`${V}%`),S.current&&(S.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${a(D)} / ${a(t)}`)},x=()=>{u||d(c.currentTime)},B=()=>{if(p==="auto"&&c.buffered.length>0){const V=c.buffered.end(c.buffered.length-1)/t*100||0;g.current&&(g.current.style.width=`${V}%`)}};return d(c.currentTime),B(),c.addEventListener("timeupdate",x),c.addEventListener("progress",B),()=>{c.removeEventListener("timeupdate",x),c.removeEventListener("progress",B)}},[r,t,u,p,a,E]);const O=c=>{if(!b.current)return 0;const d=b.current.getBoundingClientRect();return d.width<=0?0:Math.min(1,Math.max(0,(c-d.left)/d.width))},Q=c=>{const d=c*t;b.current?.setAttribute("aria-valuenow",String(Math.round(d))),b.current?.setAttribute("aria-valuetext",`${a(d)} of ${a(t)}`);const x=d/t*100||0;L.current&&(L.current.style.width=`${x}%`),S.current&&(S.current.style.left=`${x}%`),E?.current&&(E.current.innerText=`${a(d)} / ${a(t)}`);const B=b.current?.getBoundingClientRect();C({time:d,position:B?c*B.width:null})};X(()=>{if(!u){T.current=null;return}const c=x=>{if(T.current!==null&&x.pointerId!==T.current||!t)return;const B=O(x.clientX);y.current.onScrubMove(B);const D=B*t;b.current?.setAttribute("aria-valuenow",String(Math.round(D))),b.current?.setAttribute("aria-valuetext",`${a(D)} of ${a(t)}`);const V=D/t*100||0;L.current&&(L.current.style.width=`${V}%`),S.current&&(S.current.style.left=`${V}%`),E?.current&&(E.current.innerText=`${a(D)} / ${a(t)}`);const ee=b.current?.getBoundingClientRect();C({time:D,position:ee?B*ee.width:null})},d=x=>{T.current!==null&&x.pointerId!==T.current||(T.current=null,f.current=!0,x.pointerType!=="mouse"&&C({time:0,position:null}),y.current.onScrubEnd())};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d)}},[u,t,a,E]);const J=c=>{if(c.pointerType==="mouse"&&c.button!==0||!r.current||!t)return;c.preventDefault(),T.current=c.pointerId;try{b.current?.setPointerCapture(c.pointerId)}catch{}l.current||(l.current=!0,k());const d=O(c.clientX);v(d),Q(d)},ae=c=>{if(!t||l.current||c.pointerType!=="mouse")return;const d=O(c.clientX);C({time:d*t,position:c.clientX-(b.current?.getBoundingClientRect().left??0)})},G=c=>{if(!(T.current!==null&&c.pointerId!==T.current)&&l.current){T.current=null,f.current=!0,c.pointerType!=="mouse"&&C({time:0,position:null});try{b.current?.hasPointerCapture(c.pointerId)&&b.current.releasePointerCapture(c.pointerId)}catch{}M()}};return m("div",{className:`${n.container} ${u&&n.scrubbing?n.scrubbing:""}`,ref:b,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.round(t||0),"aria-valuenow":Math.round(r.current?.currentTime||0),"aria-disabled":!t,tabIndex:0,onClick:c=>{if(f.current){f.current=!1;return}!r.current||isNaN(t)||t===0||s(O(c.clientX))},onPointerDown:J,onPointerMove:ae,onPointerUp:G,onPointerCancel:G,onMouseMove:c=>{if(u||!t)return;const d=O(c.clientX);C({time:d*t,position:c.clientX-(b.current?.getBoundingClientRect().left??0)})},onMouseLeave:()=>{u||C({time:0,position:null})},onKeyDown:c=>{if(!(!r.current||!t)&&((c.key==="Home"||c.key==="End")&&(c.preventDefault(),s(c.key==="Home"?0:1)),c.key==="ArrowRight"||c.key==="ArrowLeft")){c.preventDefault();const d=(c.key==="ArrowRight"?5:-5)/t,x=r.current.currentTime/t||0;s(Math.min(1,Math.max(0,x+d)))}},children:[N.position!==null&&m("div",{className:n.timeBubble,style:{left:N.position},children:a(N.time)}),m("div",{className:n.bar,children:[m("div",{className:n.buffered,ref:g,style:p==="full"?{width:"100%"}:void 0}),m("div",{className:n.watched,ref:L}),m("div",{className:n.thumb,ref:S,onMouseDown:c=>{c.preventDefault(),r.current&&(l.current||k())}}),w]})]})};function ue(){try{if(typeof window>"u")return!1;const n=window.matchMedia?.("(pointer: coarse)").matches??!1,t=(navigator.maxTouchPoints??0)>0||"ontouchstart"in window;return n||t}catch{return!1}}function Ve(){const[n,r]=oe(ue);return X(()=>{r(ue());let t=null;const a=()=>r(ue());try{t=window.matchMedia("(pointer: coarse)"),t.addEventListener?t.addEventListener("change",a):t.addListener(a)}catch{}return window.addEventListener("touchstart",a,{passive:!0,once:!0}),()=>{try{t&&(t.removeEventListener?t.removeEventListener("change",a):t.removeListener(a))}catch{}window.removeEventListener("touchstart",a)}},[]),n}const je=450,He=({muted:n,volume:r,volumeIcon:t,buttonClassName:a,sliderClassName:u,onToggleMute:p,onVolumeChange:s,onExpandedChange:k})=>{const v=Ve(),[M,E]=oe(!1),w=A(null),b=A(!1),L=A(null),S=ye(y=>{E(y),k?.(y)},[k]);X(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),X(()=>{if(!M)return;const y=N=>{L.current&&!L.current.contains(N.target)&&S(!1)};return document.addEventListener("pointerdown",y),()=>document.removeEventListener("pointerdown",y)},[M,S]);const g=n?0:r,T=()=>{b.current=!1,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{b.current=!0,S(!0)},je)},f=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},l=y=>{if(y.stopPropagation(),b.current){b.current=!1;return}if(v){M?p():S(!0);return}p()};return m("div",{ref:L,className:pe.volumeWrap,"data-expanded":M?"true":"false",onContextMenu:y=>y.preventDefault(),children:[m("button",{type:"button",className:a,onClick:l,onPointerDown:T,onPointerUp:f,onPointerLeave:f,onContextMenu:y=>y.preventDefault(),"aria-label":n?"Unmute":"Mute","aria-expanded":M,children:t}),m("input",{type:"range",min:"0",max:"1",step:"0.05",value:g,onChange:y=>s(parseFloat(y.currentTarget.value)),onClick:y=>y.stopPropagation(),onPointerDown:y=>y.stopPropagation(),onContextMenu:y=>y.preventDefault(),className:`${pe.volumeSlider} ${u??""}`,style:{"--volume-percent":`${g*100}%`},"aria-label":"Volume"})]})};let te=null,le=null;async function Ue(){return te||(le||(le=ke(()=>import("./hls-BOLXTnjL.js"),[]).then(n=>(te=n.default,te)).catch(()=>null)),le)}function Ke(n){return n.canPlayType("application/vnd.apple.mpegurl")!==""||n.canPlayType("application/x-mpegURL")!==""}let ne=null,ce=null;async function Oe(){return ne||(ce||(ce=ke(()=>import("./dash.all.min-CsDAls03.js"),[]).then(n=>(ne=We(n),ne)).catch(()=>null)),ce)}function We(n){const r=n,t=r?.default?.MediaPlayer??r?.MediaPlayer??r?.default;return typeof t!="function"?null:{MediaPlayer:t}}function se(){return document}function fe(n){const r=se();if(document.fullscreenElement)return document.fullscreenElement;if(r.webkitFullscreenElement)return r.webkitFullscreenElement;const t=n;return t?.webkitDisplayingFullscreen?t:null}function Te(n){return fe(n)!==null}async function Xe(n,r){if(fe(r))return;const t=n;try{if(typeof n.requestFullscreen=="function"){await n.requestFullscreen();return}if(typeof t.webkitRequestFullscreen=="function"){await t.webkitRequestFullscreen();return}if(typeof t.webkitRequestFullScreen=="function"){await t.webkitRequestFullScreen();return}}catch{}const a=r;if(a&&typeof a.webkitEnterFullscreen=="function"){if(a.webkitSupportsFullscreen===!1)return;try{await a.webkitEnterFullscreen()}catch{}}}async function Qe(n){const r=se();try{if(document.fullscreenElement&&typeof document.exitFullscreen=="function"){await document.exitFullscreen();return}if(r.webkitFullscreenElement&&typeof r.webkitExitFullscreen=="function"){await r.webkitExitFullscreen();return}}catch{}const t=n;if(t?.webkitDisplayingFullscreen&&typeof t.webkitExitFullscreen=="function"){try{t.webkitExitFullscreen()}catch{}return}try{typeof r.webkitCancelFullScreen=="function"?r.webkitCancelFullScreen():!document.fullscreenElement&&typeof document.exitFullscreen=="function"&&(document.fullscreenElement??r.webkitFullscreenElement)&&await document.exitFullscreen()}catch{}}async function Ge(n,r){!n&&!r||(Te(r)?await Qe(r):n&&await Xe(n,r))}function ze(n,r){const t=()=>{try{r(Te(n()))}catch{}},a=se(),u=t;a.addEventListener("fullscreenchange",t),a.addEventListener("webkitfullscreenchange",u),a.addEventListener("webkitbeginfullscreen",u,!0),a.addEventListener("webkitendfullscreen",u,!0);const p=n();return p?.addEventListener("webkitbeginfullscreen",u),p?.addEventListener("webkitendfullscreen",u),()=>{a.removeEventListener("fullscreenchange",t),a.removeEventListener("webkitfullscreenchange",u),a.removeEventListener("webkitbeginfullscreen",u,!0),a.removeEventListener("webkitendfullscreen",u,!0),p?.removeEventListener("webkitbeginfullscreen",u),p?.removeEventListener("webkitendfullscreen",u)}}let U=null;function be(n){try{return n?ge.getItem(n):null}catch{return null}}function Z(n,r){try{n&&ge.setItem(n,String(r))}catch{}}function Je(n={}){const r=Number.parseFloat(be(n.volumeKey)??"");let t={isPlaying:!1,isBuffering:!1,isMuted:be(n.mutedKey)==="true",volume:Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,duration:0,playbackRate:1,isScrubbing:!1,isFullscreen:!1,showControls:!0,isSpeedBoostActive:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1,error:null,playBlocked:!1,playbackLocked:!1},a={currentTime:0,bufferedEnd:0};const u=new Set,p=new Set,s={current:null},k={current:null};let v=null,M=()=>{},E=()=>{},w=0,b=!1,L=1,S=!1,g=null,T=null,f=!1;function l(e){Object.entries(e).every(([i,o])=>Object.is(t[i],o))||(t={...t,...e},u.forEach(i=>i()))}function y(e){a.currentTime===e.currentTime&&a.bufferedEnd===e.bufferedEnd||(a=e,p.forEach(i=>i()))}function N(e){if(!e)return;let i=0;for(let o=0;o<e.buffered.length;o++)if(e.buffered.start(o)<=e.currentTime&&e.buffered.end(o)>=e.currentTime){i=e.buffered.end(o);break}y({currentTime:Number.isFinite(e.currentTime)?e.currentTime:0,bufferedEnd:i})}function C(){N(s.current)}function O(){const e=s.current;if(v===e||(v&&(U===v&&(U=e),N(v),E(),v.pause(),v.removeAttribute("src"),v.load()),M(),v=e,!e))return;S=!1,U||(U=e),e.volume=t.volume,e.muted=t.isMuted,e.playbackRate=t.playbackRate;const i=()=>{const h=Array.from(e.textTracks);if(!h.length)return;const j=h.findIndex(H=>H.mode==="showing");l({subtitleTracks:h.map((H,z)=>({id:z,label:H.label||H.language||`Track ${z+1}`,language:H.language})),...j>=0?{activeSubtitleTrack:j}:{}})},o={play:()=>{U=e,l({isPlaying:!0,playBlocked:!1,error:null})},playing:()=>l({isPlaying:!0,isBuffering:!1,playBlocked:!1}),pause:()=>l({isPlaying:!1,isBuffering:!1}),ended:()=>{l({isPlaying:!1,isBuffering:!1}),C()},waiting:()=>{!e.paused&&(e.readyState<3||e.seeking)&&l({isBuffering:!0})},canplay:()=>l({isBuffering:!1}),seeking:()=>{e.paused||l({isBuffering:!0}),C()},seeked:()=>{l({isBuffering:!1}),C()},timeupdate:()=>{C(),!e.paused&&!e.seeking&&l({isBuffering:!1})},progress:C,loadedmetadata:()=>{e.playbackRate=t.playbackRate,l({duration:Number.isFinite(e.duration)?e.duration:0}),i()},durationchange:()=>l({duration:Number.isFinite(e.duration)?e.duration:0}),ratechange:()=>{t.isSpeedBoostActive||(L=e.playbackRate),e.defaultPlaybackRate!==e.playbackRate&&(e.defaultPlaybackRate=e.playbackRate),l({playbackRate:e.playbackRate})},volumechange:()=>{l({volume:e.volume,isMuted:e.muted}),Z(n.volumeKey,e.volume),Z(n.mutedKey,e.muted)},error:()=>l({error:e.error?.message||"Unable to play this source.",isPlaying:!1,isBuffering:!1})};Object.entries(o).forEach(([h,j])=>e.addEventListener(h,j)),e.textTracks.addEventListener("addtrack",i),e.textTracks.addEventListener("removetrack",i),e.textTracks.addEventListener("change",i);const F=()=>e.tagName==="VIDEO"?e:null,W=()=>{const h=fe(F());l({isFullscreen:h!==null&&(h===e||h===k.current)})},I=typeof document>"u"?()=>{}:ze(F,W);typeof document<"u"&&W(),M=()=>{Object.entries(o).forEach(([h,j])=>e.removeEventListener(h,j)),I(),e.textTracks.removeEventListener("addtrack",i),e.textTracks.removeEventListener("removetrack",i),e.textTracks.removeEventListener("change",i)}}async function Q(){if(t.playbackLocked&&!f)return!1;const e=s.current;if(!e)return!1;U=e;const i=w;try{return await e.play(),i===w}catch(o){if(i===w){const F=o instanceof Error&&o.name==="NotAllowedError",W=o instanceof Error&&o.name==="AbortError";l({isPlaying:!1,isBuffering:!1,playBlocked:F,...!F&&!W?{error:o instanceof Error?o.message:"Playback failed."}:{}})}return!1}}function J(){t.playbackLocked&&!f||s.current?.pause()}function ae(){s.current?.paused?Q():J()}function G(e){if(t.playbackLocked&&!f)return;const i=s.current;if(!i||!Number.isFinite(e))return;let o=Math.max(0,e);if(Number.isFinite(i.duration))o=Math.min(i.duration,o);else if(i.seekable.length)for(let F=0;F<i.seekable.length;F++){if(o<=i.seekable.end(F)){o=Math.max(i.seekable.start(F),o);break}F===i.seekable.length-1&&(o=i.seekable.end(F))}i.currentTime=o,C()}function c(e){G((s.current?.currentTime??a.currentTime)+e)}function d(e){if(!Number.isFinite(e))return;const i=Math.max(0,Math.min(1,e));l({volume:i,isMuted:i===0}),s.current&&(s.current.volume=i,s.current.muted=i===0),Z(n.volumeKey,i),Z(n.mutedKey,i===0)}function x(){const e=!t.isMuted;!e&&t.volume===0&&d(.5),l({isMuted:e}),s.current&&(s.current.muted=e),Z(n.mutedKey,e)}function B(e){if(t.playbackLocked&&!f||!Number.isFinite(e)||e<.25||e>4)return;L=e;const i=t.isSpeedBoostActive?2:e;l({playbackRate:i}),s.current&&(s.current.playbackRate=i)}function D(){t.playbackLocked||t.isScrubbing||(b=!!s.current&&!s.current.paused,l({isScrubbing:!0}),J())}function V(){t.isScrubbing&&(l({isScrubbing:!1}),b&&Q(),b=!1)}function ee(e,i={}){E(),O();const o=s.current,F=++w;if(!o)return()=>{};let W=!1,I=null;const h=()=>!W&&w===F&&s.current===o;o.pause(),o.removeAttribute("src"),o.load(),l({duration:0,isPlaying:!1,isBuffering:!0,isScrubbing:!1,error:null,playBlocked:!1,audioTracks:[],subtitleTracks:[],qualities:[],activeAudioTrack:-1,activeSubtitleTrack:-1,activeQuality:-1}),y({currentTime:0,bufferedEnd:0});const j=()=>{h()&&i.initialTime&&i.initialTime>0&&G(i.initialTime)};o.addEventListener("loadedmetadata",j,{once:!0});const H=()=>{h()&&(i.onReady?.(),i.autoPlay&&h()&&Q())},z=P=>{if(!h())return;const R=P instanceof Error?P:new Error(String(P));l({error:R.message,isPlaying:!1,isBuffering:!1}),i.onError?.(R)},Y=()=>{W||(W=!0,o.removeEventListener("loadedmetadata",j),o.removeEventListener("error",de),I?.destroy(),g===I&&(g=null),I=null,T?.destroy(),T=null,w===F&&w++)},de=()=>{z(new Error(o.error?.message||"Unable to play this source.")),Y()};return o.addEventListener("error",de),E=Y,(async()=>{if(e.dash){const P=await Oe();if(!h())return;if(!P)throw new Error("DASH playback is unavailable in this browser.");const R=P.MediaPlayer().create();if(T=R,R.on("streamActivated",H),R.on("error",ie=>{const _=ie,$=_?.error?.message||_?.message||"DASH stream failed.";z(new Error($)),Y()}),!h())return;i.onDash?.(R),R.initialize(o,e.url);return}if(e.hls){const P=await Ue();if(!h())return;if(P?.isSupported()){I=new P({enableWorker:!0,startPosition:i.initialTime??-1,...i.hlsConfig}),g=I;const R=I,ie=()=>{h()&&l({audioTracks:R.audioTracks.map((_,$)=>({id:$,label:_.name||_.lang||`Track ${$+1}`,language:_.lang})),...o.querySelector("track")?{}:{subtitleTracks:R.subtitleTracks.map((_,$)=>({id:$,label:_.name||_.lang||`Track ${$+1}`,language:_.lang}))},qualities:R.levels.map((_,$)=>({id:$,label:_.height?`${_.height}p`:`${Math.round(_.bitrate/1e3)}k`})),activeAudioTrack:R.audioTrack,...o.querySelector("track")?{}:{activeSubtitleTrack:R.subtitleTrack},activeQuality:R.currentLevel})};for(const _ of[P.Events.MANIFEST_PARSED,P.Events.AUDIO_TRACKS_UPDATED,P.Events.AUDIO_TRACK_SWITCHED,P.Events.SUBTITLE_TRACKS_UPDATED,P.Events.SUBTITLE_TRACK_SWITCH,P.Events.LEVEL_SWITCHED])R.on(_,ie);if(I.on(P.Events.ERROR,(_,$)=>{$.fatal&&h()&&(z(new Error(`Stream failed (${$.details}). Try another source or reload.`)),Y())}),I.once(P.Events.MANIFEST_PARSED,H),i.onHls?.(I,P),!h())return;I.loadSource(e.url),I.attachMedia(o);return}if(!Ke(o))throw new Error("HLS playback is unavailable in this browser.")}h()&&(o.src=e.url,o.load(),H())})().catch(P=>{z(P),Y()}),Y}return{mediaRef:s,containerRef:k,connect:O,getState:()=>t,getTimeline:()=>a,getHls:()=>g,isActive:()=>U===s.current,subscribe:e=>(u.add(e),()=>{u.delete(e)}),subscribeTimeline:e=>(p.add(e),()=>{p.delete(e)}),play:Q,pause:J,togglePlay:ae,seek:G,seekRelative:c,setVolume:d,toggleMute:x,setPlaybackRate:B,setPlaybackLocked:e=>l({playbackLocked:e}),applyRemotePlayback:(e,i,o)=>{f=!0;try{e!==void 0&&G(e),Math.abs(t.playbackRate-o)>.001&&B(o),i&&s.current?.paused?Q():!i&&!s.current?.paused&&J()}finally{f=!1}},setAudioTrack:e=>{g&&t.audioTracks.some(i=>i.id===e)&&(g.audioTrack=e,l({activeAudioTrack:e}))},setSubtitleTrack:e=>{if(e!==-1&&!t.subtitleTracks.some(o=>o.id===e))return;const i=s.current;i?.querySelector("track")?Array.from(i.textTracks).forEach((o,F)=>{o.mode=F===e?"showing":"disabled"}):g&&(g.subtitleTrack=e),l({activeSubtitleTrack:e})},setQuality:e=>{g&&(e===-1||t.qualities.some(i=>i.id===e))&&(g.currentLevel=e,l({activeQuality:e}))},setSpeedBoost:e=>{if(t.playbackLocked)return;const i=e?2:L;l({isSpeedBoostActive:e,playbackRate:i}),s.current&&(s.current.playbackRate=i)},setShowControls:e=>l({showControls:e}),startScrubbing:D,endScrubbing:V,loadSource:ee,unload:()=>{const e=s.current;N(e),E(),e&&(e.pause(),e.removeAttribute("src"),e.load()),l({isPlaying:!1,isBuffering:!1,duration:0,error:null}),y({currentTime:0,bufferedEnd:0})},toggleFullscreen:()=>{const e=s.current;Ge(k.current,e?.tagName==="VIDEO"?e:null).catch(i=>l({error:i instanceof Error?i.message:"Fullscreen failed."}))},reset:()=>{l({duration:0,isBuffering:!1,error:null}),y({currentTime:0,bufferedEnd:0})},destroy:()=>{if(S)return;S=!0;const e=v??s.current;N(e),M(),v=null,E(),e?.pause(),e?.removeAttribute("src"),e?.load(),U===e&&(U=null)}}}function K(n){return ve(n.subscribe,n.getState)}function Pe(n){return ve(n.subscribeTimeline,n.getTimeline)}function it(n={}){const r=A(n),t=me(()=>Je(r.current),[]);return Fe(()=>{t.connect()}),X(()=>()=>t.destroy(),[t]),me(()=>({engine:t,mediaRef:t.mediaRef}),[t])}function Ye({children:n,...r}){const t=q(),{isPlaying:a,playbackLocked:u}=K(t);return m("button",{type:"button","aria-label":a?"Pause":"Play",...r,disabled:u||r.disabled,onClick:t.togglePlay,children:n??m(re,{name:a?"pause":"play"})})}function ut({seconds:n,children:r,...t}){const a=q(),{playbackLocked:u}=K(a);return m("button",{type:"button","aria-label":`Seek ${n<0?"back":"forward"} ${Math.abs(n)} seconds`,...t,disabled:u||t.disabled,onClick:()=>a.seekRelative(n),children:r??m(re,{name:n<0?"replay-10":"forward-10"})})}function lt(n){const r=q(),{isFullscreen:t}=K(r);return m("button",{type:"button","aria-label":t?"Exit Fullscreen":"Fullscreen",...n,onClick:r.toggleFullscreen,children:m(re,{name:t?"compress":"expand"})})}function ct({buttonClassName:n,onExpandedChange:r}){const t=q(),{isMuted:a,volume:u}=K(t);return m(He,{muted:a,volume:u,volumeIcon:m(re,{name:a||u===0?"volume-mute":u<.5?"volume-down":"volume-up"}),buttonClassName:n,onToggleMute:t.toggleMute,onVolumeChange:t.setVolume,onExpandedChange:r})}function ot({className:n}){const r=q(),{volume:t,isMuted:a}=K(r);return m("input",{type:"range",min:0,max:1,step:.01,value:a?0:t,onChange:u=>r.setVolume(Number(u.currentTarget.value)),className:n,style:{"--volume-percent":`${(a?0:t)*100}%`},"aria-label":"Volume"})}function st({classes:n,timeLabelRef:r,children:t}){const a=q(),{duration:u,isScrubbing:p,playbackLocked:s}=K(a);return m("div",{inert:s||void 0,style:{display:"contents"},children:m(qe,{classes:n,videoRef:a.mediaRef,duration:u,formatTime:he,isScrubbing:p,onSeek:k=>a.seek(k*u),onScrubStart:a.startScrubbing,onScrubMove:k=>a.seek(k*u),onScrubEnd:a.endScrubbing,timeLabelRef:r,children:t})})}function ft({className:n}){const r=q(),{currentTime:t,bufferedEnd:a}=Pe(r),{duration:u,playbackLocked:p}=K(r),s=u?Math.min(100,t/u*100):0,k=u?Math.min(100,Math.max(s,a/u*100)):0;return m("input",{type:"range",disabled:p,min:0,max:u,step:.1,value:Math.min(t,u),onChange:v=>r.seek(Number(v.currentTarget.value)),onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),r.startScrubbing()},onPointerUp:r.endScrubbing,onPointerCancel:r.endScrubbing,onLostPointerCapture:r.endScrubbing,className:n,style:{"--played-percent":`${s}%`,"--buffered-percent":`${k}%`},"aria-label":"Seek"})}function dt({className:n,durationOnly:r=!1}){const t=q(),{currentTime:a}=Pe(t),{duration:u}=K(t);return m("span",{className:n,children:he(r?u:a)})}function mt(){const n=q(),{error:r,playBlocked:t,isBuffering:a,playbackLocked:u}=K(n);return r?m("div",{role:"alert",children:r}):t&&u?m("span",{children:"Enable playback from the watch-along panel."}):t?m(Ye,{children:"Tap to play"}):a?m("div",{role:"status","aria-label":"Buffering",children:"Loading…"}):null}const Ze='input, textarea, button, select, a, [role="button"], [role="slider"], [contenteditable]:not([contenteditable="false"]), [data-player-ui="true"], [data-speed-boost-ignore="true"]';function pt(n,r,t=!0){const a=A(r);a.current=r,X(()=>{if(!t)return;let u=!1,p=!1,s=!1,k,v,M=!1;const E=()=>{const f=p||s;f!==M&&(M=f,n.setSpeedBoost(f))},w=f=>f instanceof Element&&!!f.closest(Ze),b=f=>{if(!n.isActive()||!n.mediaRef.current||f.defaultPrevented||f.ctrlKey||f.metaKey||f.altKey||w(f.target))return;if(f.code==="Space"){if(f.preventDefault(),u)return;u=!0,k=setTimeout(()=>{k=void 0,p=!0,E()},180),a.current();return}const l=f.key.toLowerCase();["k","j","l","arrowleft","arrowright","arrowup","arrowdown","m","f"].includes(l)&&(f.preventDefault(),!(f.repeat&&["k","m","f"].includes(l))&&(l==="k"&&n.togglePlay(),(l==="j"||l==="arrowleft")&&n.seekRelative(-10),(l==="l"||l==="arrowright")&&n.seekRelative(10),l==="arrowup"&&n.setVolume(n.getState().volume+.1),l==="arrowdown"&&n.setVolume(n.getState().volume-.1),l==="m"&&n.toggleMute(),l==="f"&&n.toggleFullscreen(),a.current()))},L=f=>{f.code!=="Space"||!u||(f.preventDefault(),u=!1,clearTimeout(k),k=void 0,p?(p=!1,E()):n.togglePlay(),a.current())},S=f=>{const l=f.target;f.button!==0||!(l instanceof Element)||w(l)||!n.containerRef.current?.contains(l)||(clearTimeout(v),v=setTimeout(()=>{v=void 0,s=!0,E()},180))},g=()=>{clearTimeout(v),v=void 0,s=!1,E()},T=()=>{clearTimeout(k),k=void 0,u=!1,p=!1,g()};return document.addEventListener("keydown",b),document.addEventListener("keyup",L),document.addEventListener("pointerdown",S),document.addEventListener("pointerup",g),document.addEventListener("pointercancel",g),window.addEventListener("blur",T),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",L),document.removeEventListener("pointerdown",S),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",g),window.removeEventListener("blur",T),T()}},[n,t])}function bt({engine:n,children:r}){return m(Ee.Provider,{value:n,children:r})}export{lt as F,st as P,ut as S,ot as V,Ye as a,ct as b,rt as c,K as d,bt as e,q as f,Pe as g,pt as h,dt as i,ft as j,mt as k,at as l,Te as m,Ve as n,pe as s,it as u};
@@ -1 +1 @@
1
- import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{u as ae,p as se}from"./index-hrS3r0UE.js";import{I as o}from"./vendor-icons-C1Pj_eSX.js";import{S as le}from"./SettingsShell-ByVlsU3X.js";import{O as A,S as ie,A as ce,a as re}from"./OptionListMenu-BdiwBX1S.js";import"./vendor-query-BBT5_sHx.js";import"./useWatchAlongPlayer-BNJCb3D5.js";import"./PlayerProvider-C6humJW5.js";import"./playbackCompletion-DzRc-CrM.js";const oe="_settingsPanel_mcacu_1",me="_header_mcacu_35",de="_backBtn_mcacu_58",ue="_contentWrapper_mcacu_78",he="_menuContent_mcacu_84",pe="_menuItem_mcacu_91",be="_selected_mcacu_116",ge="_currentValue_mcacu_136",ke="_menuNote_mcacu_143",ve="_menuError_mcacu_152",n={settingsPanel:oe,header:me,backBtn:de,contentWrapper:ue,menuContent:he,menuItem:pe,selected:be,currentValue:ge,menuNote:ke,menuError:ve},ye=($,P)=>{const{isOpen:g,onClose:Ce,videoSources:fe,currentSource:C,currentLink:f,onSourceChange:V,subtitles:O,activeSubtitleTrack:k,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:N,anime4kProfile:c,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:y}=$,{lowEndMode:F}=ae(),[a,i]=ne("main");w.useEffect(()=>{if(!g){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[g]);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:f?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:k||"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),se.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),N&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),N&&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&&y&&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,r)=>(parseInt(r.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.link,label:s.resolutionStr,selected:f?.link===s.link})),onSelect:s=>{const r=t.find(l=>l.link===s);r&&V(C,r)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:k==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:k===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(ie,{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 r=navigator.userAgent.toLowerCase();return r.includes("chrome")||r.includes("chromium")||r.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} ${c==="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"})]}),c==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="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(ce,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&y?e("div",{className:n.menuContent,children:e(re,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:y})}):null;return g?e(le,{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},Oe=w.forwardRef(ye);export{Oe as default};
1
+ import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{u as ae,p as se}from"./index-BOJFs4B4.js";import{I as o}from"./vendor-icons-C1Pj_eSX.js";import{S as le}from"./SettingsShell-ByVlsU3X.js";import{O as A,S as ie,A as ce,a as re}from"./OptionListMenu-CHqo2pTO.js";import"./vendor-query-BBT5_sHx.js";import"./useWatchAlongPlayer-D-fPdbp2.js";import"./PlayerProvider-CjctET1A.js";import"./playbackCompletion-BpEGpC-Z.js";const oe="_settingsPanel_mcacu_1",me="_header_mcacu_35",de="_backBtn_mcacu_58",ue="_contentWrapper_mcacu_78",he="_menuContent_mcacu_84",pe="_menuItem_mcacu_91",be="_selected_mcacu_116",ge="_currentValue_mcacu_136",ke="_menuNote_mcacu_143",ve="_menuError_mcacu_152",n={settingsPanel:oe,header:me,backBtn:de,contentWrapper:ue,menuContent:he,menuItem:pe,selected:be,currentValue:ge,menuNote:ke,menuError:ve},ye=($,P)=>{const{isOpen:g,onClose:Ce,videoSources:fe,currentSource:C,currentLink:f,onSourceChange:V,subtitles:O,activeSubtitleTrack:k,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:N,anime4kProfile:c,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:y}=$,{lowEndMode:F}=ae(),[a,i]=ne("main");w.useEffect(()=>{if(!g){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[g]);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:f?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:k||"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),se.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),N&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),N&&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&&y&&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,r)=>(parseInt(r.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.link,label:s.resolutionStr,selected:f?.link===s.link})),onSelect:s=>{const r=t.find(l=>l.link===s);r&&V(C,r)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:k==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:k===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(ie,{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 r=navigator.userAgent.toLowerCase();return r.includes("chrome")||r.includes("chromium")||r.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} ${c==="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"})]}),c==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${c==="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"})]}),c==="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(ce,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&y?e("div",{className:n.menuContent,children:e(re,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:y})}):null;return g?e(le,{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},Oe=w.forwardRef(ye);export{Oe as default};
@@ -1 +1 @@
1
- import{u as t,A as h,q as m,h as k}from"./vendor-core-DfaOB3Rn.js";import{S as T,a as g,d as H,n as L,h as q,e as A,s as i,k as E}from"./PlayerProvider-C6humJW5.js";const R="_centerControls_1oa5h_1",U="_centerSkipBtn_1oa5h_14",j="_centerPlayPause_1oa5h_15",y={centerControls:R,centerSkipBtn:U,centerPlayPause:j},J=()=>t("div",{className:y.centerControls,onClick:e=>e.stopPropagation(),children:[t(T,{seconds:-10,className:y.centerSkipBtn}),t(g,{className:y.centerPlayPause,"data-speed-boost-ignore":"true"}),t(T,{seconds:10,className:y.centerSkipBtn})]});function z(e){return e instanceof Element&&!!e.closest('button, input, select, textarea, a, [role="button"], [role="slider"], [data-player-ui="true"]')}function K({engine:e,topBar:_,centerControls:v,bottomBar:B,settingsPanel:C,overlays:N,isInteracting:a=!1,nativeControls:n=!1,chromeDisabled:p=!1,className:F,onStageClick:M,children:x}){const r=H(e),w=L(),S=h(void 0),o=h(void 0),P=h(0),d=h(a);d.current=a;const c=m(()=>{clearTimeout(S.current),S.current=void 0},[]),l=m(()=>{c();const s=e.getState();!s.isPlaying||s.isScrubbing||d.current||n||(S.current=setTimeout(()=>{const u=e.getState();d.current||u.isScrubbing||!u.isPlaying||e.setShowControls(!1)},w?5e3:3e3))},[e,w,n,c]),f=m(()=>{e.setShowControls(!0),l()},[e,l]);q(e,f,!n&&!p),k(()=>(a||r.isScrubbing||!r.isPlaying?(e.setShowControls(!0),c()):l(),c),[e,a,r.isPlaying,r.isScrubbing,r.showControls,c,l]),k(()=>()=>{clearTimeout(o.current)},[]);const $=s=>{if(z(s.target)||n||p)return;M?.();const u=Date.now();if(u-P.current<280){clearTimeout(o.current),o.current=void 0,P.current=0,e.toggleFullscreen();return}P.current=u,clearTimeout(o.current),o.current=setTimeout(()=>{o.current=void 0,e.setShowControls(!e.getState().showControls),l()},280)},b=r.showControls||r.isScrubbing||a||!r.isPlaying;return t(A,{engine:e,children:t("div",{ref:e.containerRef,"data-player-root":"true",className:`${i.shell} ${r.isFullscreen?i.shellFullscreen:""} ${F??""}`,style:{cursor:!b&&r.isFullscreen?"none":"default"},onContextMenu:s=>s.preventDefault(),onPointerMove:s=>{s.pointerType==="mouse"&&f()},onFocusIn:f,onMouseLeave:()=>{window.matchMedia?.("(hover: hover) and (pointer: fine)").matches&&e.getState().isPlaying&&!d.current&&e.setShowControls(!1)},children:[t("div",{className:i.stage,onClick:$,children:x}),N,(r.error||r.playBlocked)&&t("div",{className:i.engineStatus,"data-player-ui":"true",children:t(E,{})}),!p&&!n&&t("div",{className:i.uiLayer,children:[t("div",{"data-player-ui":"true",children:_}),b&&v&&t("div",{"data-player-ui":"true",children:v}),t("div",{"data-player-ui":"true",children:B}),C&&t("div",{"data-player-ui":"true",children:C})]})]})})}export{J as C,K as P};
1
+ import{u as t,A as h,q as m,h as k}from"./vendor-core-DfaOB3Rn.js";import{S as T,a as g,d as H,n as L,h as q,e as A,s as i,k as E}from"./PlayerProvider-CjctET1A.js";const R="_centerControls_1oa5h_1",U="_centerSkipBtn_1oa5h_14",j="_centerPlayPause_1oa5h_15",y={centerControls:R,centerSkipBtn:U,centerPlayPause:j},J=()=>t("div",{className:y.centerControls,onClick:e=>e.stopPropagation(),children:[t(T,{seconds:-10,className:y.centerSkipBtn}),t(g,{className:y.centerPlayPause,"data-speed-boost-ignore":"true"}),t(T,{seconds:10,className:y.centerSkipBtn})]});function z(e){return e instanceof Element&&!!e.closest('button, input, select, textarea, a, [role="button"], [role="slider"], [data-player-ui="true"]')}function K({engine:e,topBar:_,centerControls:v,bottomBar:B,settingsPanel:C,overlays:N,isInteracting:a=!1,nativeControls:n=!1,chromeDisabled:p=!1,className:F,onStageClick:M,children:x}){const r=H(e),w=L(),S=h(void 0),o=h(void 0),P=h(0),d=h(a);d.current=a;const c=m(()=>{clearTimeout(S.current),S.current=void 0},[]),l=m(()=>{c();const s=e.getState();!s.isPlaying||s.isScrubbing||d.current||n||(S.current=setTimeout(()=>{const u=e.getState();d.current||u.isScrubbing||!u.isPlaying||e.setShowControls(!1)},w?5e3:3e3))},[e,w,n,c]),f=m(()=>{e.setShowControls(!0),l()},[e,l]);q(e,f,!n&&!p),k(()=>(a||r.isScrubbing||!r.isPlaying?(e.setShowControls(!0),c()):l(),c),[e,a,r.isPlaying,r.isScrubbing,r.showControls,c,l]),k(()=>()=>{clearTimeout(o.current)},[]);const $=s=>{if(z(s.target)||n||p)return;M?.();const u=Date.now();if(u-P.current<280){clearTimeout(o.current),o.current=void 0,P.current=0,e.toggleFullscreen();return}P.current=u,clearTimeout(o.current),o.current=setTimeout(()=>{o.current=void 0,e.setShowControls(!e.getState().showControls),l()},280)},b=r.showControls||r.isScrubbing||a||!r.isPlaying;return t(A,{engine:e,children:t("div",{ref:e.containerRef,"data-player-root":"true",className:`${i.shell} ${r.isFullscreen?i.shellFullscreen:""} ${F??""}`,style:{cursor:!b&&r.isFullscreen?"none":"default"},onContextMenu:s=>s.preventDefault(),onPointerMove:s=>{s.pointerType==="mouse"&&f()},onFocusIn:f,onMouseLeave:()=>{window.matchMedia?.("(hover: hover) and (pointer: fine)").matches&&e.getState().isPlaying&&!d.current&&e.setShowControls(!1)},children:[t("div",{className:i.stage,onClick:$,children:x}),N,(r.error||r.playBlocked)&&t("div",{className:i.engineStatus,"data-player-ui":"true",children:t(E,{})}),!p&&!n&&t("div",{className:i.uiLayer,children:[t("div",{"data-player-ui":"true",children:_}),b&&v&&t("div",{"data-player-ui":"true",children:v}),t("div",{"data-player-ui":"true",children:B}),C&&t("div",{"data-player-ui":"true",children:C})]})]})})}export{J as C,K as P};
@@ -1 +1 @@
1
- import{b as T}from"./vendor-query-BBT5_sHx.js";import{q as z,t as A,y as J,aq as W,ar as X,as as Y}from"./index-hrS3r0UE.js";import{d as Z,T as R,q as r,u as t,$ as w,S as ee}from"./vendor-core-DfaOB3Rn.js";import{a as te,c as ne,d as se,b as ae,o as oe,f as ie,s as re}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-C1Pj_eSX.js";function Ee(n){return T({queryKey:[z.showMeta,n],queryFn:async()=>n?A.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",pe="_menuTitle_1vova_51",de="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",o={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:pe,menuItem:de,removeItem:ge,menuEmpty:fe},ve=8,Pe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:D="",activeClassName:F="",align:M="right",onMenuOpenChange:d})=>{const{data:q=[]}=J(),E=W(),P=X(),[m,f]=Z(!1),{refs:Q,floatingStyles:x,context:C}=te({open:m,onOpenChange:e=>{e||(f(!1),d?.(!1))},placement:M==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ie({padding:8}),re({padding:8})],whileElementsMounted:ae}),I=ne(C,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:S,getFloatingProps:K}=se([I]),l=R(()=>q.filter(e=>e.showId===n),[q,n]),{data:L}=T({queryKey:[z.suggestedEpisode,n],queryFn:()=>A.watchlist.queueSuggested.query({showId:n}),enabled:!!n}),{data:$,isFetching:N}=Y(n,m),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),d?.(!0)},[d]),c=r(()=>{f(!1),d?.(!1)},[d]),p=l.length>0,a=s.length>0,g=L?.episodeNumber,i=r(e=>{!n||e.length===0||(E.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,E,c]),O=r(()=>{!n||l.length===0||(P.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,P,c]),U=r(()=>{a?i([s[0]]):g&&i([String(g)])},[a,s,g,i]),G=r(()=>{a&&i(s.slice(0,3))},[a,s,i]),V=r(()=>{a&&i([...s])},[a,s,i]),B=s[0],j=s[Math.min(2,s.length-1)],H=t("div",{className:o.trigger,ref:Q.setReference,children:t("span",{className:`${o.triggerBtn} ${D} ${p?F:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":p?"Queued":"Queue",...S(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[p?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),p?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:o.chevron})]})});return t(ee,{children:[H,m&&w(t("div",{ref:Q.setFloating,className:o.menu,style:x,role:"menu",...K(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:o.menuTitle,children:"Queue episodes"}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a&&!g,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+3 — EP ${B}${s.length>1?`-${j}`:""}`:"+3"})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),V()},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:o.menuEmpty,children:p?"All episodes are already queued":"No remaining unwatched episodes"}),p&&t("button",{className:`${o.menuItem} ${o.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{Pe as Q,Ee as u};
1
+ import{b as T}from"./vendor-query-BBT5_sHx.js";import{q as z,t as A,y as J,aq as W,ar as X,as as Y}from"./index-BOJFs4B4.js";import{d as Z,T as R,q as r,u as t,$ as w,S as ee}from"./vendor-core-DfaOB3Rn.js";import{a as te,c as ne,d as se,b as ae,o as oe,f as ie,s as re}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-C1Pj_eSX.js";function Ee(n){return T({queryKey:[z.showMeta,n],queryFn:async()=>n?A.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",pe="_menuTitle_1vova_51",de="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",o={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:pe,menuItem:de,removeItem:ge,menuEmpty:fe},ve=8,Pe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:D="",activeClassName:F="",align:M="right",onMenuOpenChange:d})=>{const{data:q=[]}=J(),E=W(),P=X(),[m,f]=Z(!1),{refs:Q,floatingStyles:x,context:C}=te({open:m,onOpenChange:e=>{e||(f(!1),d?.(!1))},placement:M==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ie({padding:8}),re({padding:8})],whileElementsMounted:ae}),I=ne(C,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:S,getFloatingProps:K}=se([I]),l=R(()=>q.filter(e=>e.showId===n),[q,n]),{data:L}=T({queryKey:[z.suggestedEpisode,n],queryFn:()=>A.watchlist.queueSuggested.query({showId:n}),enabled:!!n}),{data:$,isFetching:N}=Y(n,m),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),d?.(!0)},[d]),c=r(()=>{f(!1),d?.(!1)},[d]),p=l.length>0,a=s.length>0,g=L?.episodeNumber,i=r(e=>{!n||e.length===0||(E.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,E,c]),O=r(()=>{!n||l.length===0||(P.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,P,c]),U=r(()=>{a?i([s[0]]):g&&i([String(g)])},[a,s,g,i]),G=r(()=>{a&&i(s.slice(0,3))},[a,s,i]),V=r(()=>{a&&i([...s])},[a,s,i]),B=s[0],j=s[Math.min(2,s.length-1)],H=t("div",{className:o.trigger,ref:Q.setReference,children:t("span",{className:`${o.triggerBtn} ${D} ${p?F:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":p?"Queued":"Queue",...S(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[p?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),p?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:o.chevron})]})});return t(ee,{children:[H,m&&w(t("div",{ref:Q.setFloating,className:o.menu,style:x,role:"menu",...K(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:o.menuTitle,children:"Queue episodes"}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a&&!g,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+3 — EP ${B}${s.length>1?`-${j}`:""}`:"+3"})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),V()},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:o.menuEmpty,children:p?"All episodes are already queued":"No remaining unwatched episodes"}),p&&t("button",{className:`${o.menuItem} ${o.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{Pe as Q,Ee as u};
@@ -1 +1 @@
1
- import{g as s,u as n,a as G}from"./vendor-core-DfaOB3Rn.js";import{I as D}from"./vendor-icons-C1Pj_eSX.js";import{d as X,F as Y,f as L}from"./index-hrS3r0UE.js";const z="_section_5peha_1",O="_header_5peha_10",j="_headerToggle_5peha_20",J="_headerActions_5peha_34",K="_title_5peha_40",V="_badge_5peha_50",W="_clearBtn_5peha_65",Z="_nextBtn_5peha_83",ee="_list_5peha_101",ne="_item_5peha_115",te="_active_5peha_135",ae="_dragging_5peha_143",re="_dragHandle_5peha_150",oe="_thumbnail_5peha_168",ce="_meta_5peha_176",se="_name_5peha_183",le="_episode_5peha_205",ie="_iconBtn_5peha_211",ue="_metaGap_5peha_257",a={section:z,header:O,headerToggle:j,headerActions:J,title:K,badge:V,clearBtn:W,nextBtn:Z,list:ee,item:ne,active:te,dragging:ae,dragHandle:re,thumbnail:oe,meta:ce,name:se,episode:le,iconBtn:ie,metaGap:ue},de=({item:r,isActive:I,index:g,onRemove:v,onTouchPointerDown:x,onTouchPointerMove:B,onTouchPointerUp:w,onTouchPointerCancel:y,shouldIgnoreClick:_,onDragStart:R,onDragEnter:f,onDragEnd:c,isDragging:b})=>{const o=G(),{titlePreference:l}=X(),i=r[l]||r.name||"Unknown show";return n("div",{"data-queue-index":g,className:`${a.item} ${I?a.active:""} ${b?a.dragging:""}`,draggable:!0,onDragStart:R,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:c,onPointerDown:u=>x(g,u),onPointerMove:B,onPointerUp:w,onPointerCancel:y,children:[n("button",{className:a.dragHandle,type:"button","aria-label":"Drag queue item",children:n(D,{name:"bars"})}),n(Y,{className:a.thumbnail,src:L(r.thumbnail||"",72,96),alt:i,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:a.meta,children:[n("button",{className:a.name,type:"button",onClick:()=>{_()||o(`/watch/${r.showId}/${r.episodeNumber}`)},children:i}),n("div",{className:a.episode,children:["Episode ",r.episodeNumber]})]}),n("button",{className:a.iconBtn,type:"button",onClick:()=>{_()||v(r)},"aria-label":`Remove ${i} episode ${r.episodeNumber} from queue`,children:n(D,{name:"times"})})]})},ge=({title:r="Queue",eyebrow:I,items:g,currentShowId:v,currentEpisode:x,onRemove:B,onReorder:w,onNextQueue:y,onClear:_,showClearAll:R=!1,defaultExpanded:f=!0})=>{const[c,b]=s.useState([]),[o,l]=s.useState(null),[i,u]=s.useState(f),N=s.useRef(null),T=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{b(g)},[g]),s.useEffect(()=>{u(f)},[f]);const $=e=>{l(e)},k=e=>{if(o===null||o===e)return;const t=[...c],p=t[o];t.splice(o,1),t.splice(e,0,p),l(e),b(t)},A=()=>{o!==null&&w(c.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),l(null)},E=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&h.current&&(w(c.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),C.current=!0,window.setTimeout(()=>{C.current=!1},0)),N.current=null,T.current=null,h.current=!1,l(null)},Q=(e,t)=>{if(t.pointerType==="mouse")return;const p=t.currentTarget,m=t.pointerId;N.current=t.pointerId,T.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{h.current=!0,l(e);try{p.setPointerCapture(m)}catch{}},220)},S=e=>{if(e.pointerType==="mouse"||N.current!==e.pointerId)return;if(!h.current&&T.current){const H=Math.abs(e.clientX-T.current.x),F=Math.abs(e.clientY-T.current.y);(H>8||F>8)&&E(!1);return}if(!h.current)return;e.preventDefault();const p=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),m=p?Number(p.dataset.queueIndex):NaN;if(Number.isNaN(m)||o===null||m===o)return;const P=[...c],U=P[o];P.splice(o,1),P.splice(m,0,U),l(m),b(P)},q=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(h.current)},M=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(!1)};return c.length===0?null:n("section",{className:a.section,children:[n("div",{className:a.header,children:[n("button",{className:a.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":i,"aria-label":i?`Collapse ${r}`:`Expand ${r}`,children:[n("span",{className:a.title,children:[n("span",{className:"title-stack",children:[I&&n("div",{className:"section-eyebrow",children:I}),n("span",{children:r})]}),n("span",{className:a.badge,children:c.length})]}),i?n(D,{name:"chevron-up"}):n(D,{name:"chevron-down"})]}),R&&_&&n("div",{className:a.headerActions,children:[y&&c.length>1&&n("button",{className:a.nextBtn,type:"button",onClick:y,children:"Next"}),n("button",{className:a.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),i&&n("div",{className:a.list,children:c.map((e,t)=>n(de,{item:e,isActive:e.showId===v&&e.episodeNumber===x,index:t,onRemove:B,onTouchPointerDown:Q,onTouchPointerMove:S,onTouchPointerUp:q,onTouchPointerCancel:M,shouldIgnoreClick:()=>C.current,onDragStart:()=>$(t),onDragEnter:()=>k(t),onDragEnd:A,isDragging:o===t},e.id))})]})};export{ge as Q,a as s};
1
+ import{g as s,u as n,a as G}from"./vendor-core-DfaOB3Rn.js";import{I as D}from"./vendor-icons-C1Pj_eSX.js";import{d as X,F as Y,f as L}from"./index-BOJFs4B4.js";const z="_section_5peha_1",O="_header_5peha_10",j="_headerToggle_5peha_20",J="_headerActions_5peha_34",K="_title_5peha_40",V="_badge_5peha_50",W="_clearBtn_5peha_65",Z="_nextBtn_5peha_83",ee="_list_5peha_101",ne="_item_5peha_115",te="_active_5peha_135",ae="_dragging_5peha_143",re="_dragHandle_5peha_150",oe="_thumbnail_5peha_168",ce="_meta_5peha_176",se="_name_5peha_183",le="_episode_5peha_205",ie="_iconBtn_5peha_211",ue="_metaGap_5peha_257",a={section:z,header:O,headerToggle:j,headerActions:J,title:K,badge:V,clearBtn:W,nextBtn:Z,list:ee,item:ne,active:te,dragging:ae,dragHandle:re,thumbnail:oe,meta:ce,name:se,episode:le,iconBtn:ie,metaGap:ue},de=({item:r,isActive:I,index:g,onRemove:v,onTouchPointerDown:x,onTouchPointerMove:B,onTouchPointerUp:w,onTouchPointerCancel:y,shouldIgnoreClick:_,onDragStart:R,onDragEnter:f,onDragEnd:c,isDragging:b})=>{const o=G(),{titlePreference:l}=X(),i=r[l]||r.name||"Unknown show";return n("div",{"data-queue-index":g,className:`${a.item} ${I?a.active:""} ${b?a.dragging:""}`,draggable:!0,onDragStart:R,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:c,onPointerDown:u=>x(g,u),onPointerMove:B,onPointerUp:w,onPointerCancel:y,children:[n("button",{className:a.dragHandle,type:"button","aria-label":"Drag queue item",children:n(D,{name:"bars"})}),n(Y,{className:a.thumbnail,src:L(r.thumbnail||"",72,96),alt:i,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:a.meta,children:[n("button",{className:a.name,type:"button",onClick:()=>{_()||o(`/watch/${r.showId}/${r.episodeNumber}`)},children:i}),n("div",{className:a.episode,children:["Episode ",r.episodeNumber]})]}),n("button",{className:a.iconBtn,type:"button",onClick:()=>{_()||v(r)},"aria-label":`Remove ${i} episode ${r.episodeNumber} from queue`,children:n(D,{name:"times"})})]})},ge=({title:r="Queue",eyebrow:I,items:g,currentShowId:v,currentEpisode:x,onRemove:B,onReorder:w,onNextQueue:y,onClear:_,showClearAll:R=!1,defaultExpanded:f=!0})=>{const[c,b]=s.useState([]),[o,l]=s.useState(null),[i,u]=s.useState(f),N=s.useRef(null),T=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{b(g)},[g]),s.useEffect(()=>{u(f)},[f]);const $=e=>{l(e)},k=e=>{if(o===null||o===e)return;const t=[...c],p=t[o];t.splice(o,1),t.splice(e,0,p),l(e),b(t)},A=()=>{o!==null&&w(c.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),l(null)},E=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&h.current&&(w(c.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),C.current=!0,window.setTimeout(()=>{C.current=!1},0)),N.current=null,T.current=null,h.current=!1,l(null)},Q=(e,t)=>{if(t.pointerType==="mouse")return;const p=t.currentTarget,m=t.pointerId;N.current=t.pointerId,T.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{h.current=!0,l(e);try{p.setPointerCapture(m)}catch{}},220)},S=e=>{if(e.pointerType==="mouse"||N.current!==e.pointerId)return;if(!h.current&&T.current){const H=Math.abs(e.clientX-T.current.x),F=Math.abs(e.clientY-T.current.y);(H>8||F>8)&&E(!1);return}if(!h.current)return;e.preventDefault();const p=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),m=p?Number(p.dataset.queueIndex):NaN;if(Number.isNaN(m)||o===null||m===o)return;const P=[...c],U=P[o];P.splice(o,1),P.splice(m,0,U),l(m),b(P)},q=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(h.current)},M=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(!1)};return c.length===0?null:n("section",{className:a.section,children:[n("div",{className:a.header,children:[n("button",{className:a.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":i,"aria-label":i?`Collapse ${r}`:`Expand ${r}`,children:[n("span",{className:a.title,children:[n("span",{className:"title-stack",children:[I&&n("div",{className:"section-eyebrow",children:I}),n("span",{children:r})]}),n("span",{className:a.badge,children:c.length})]}),i?n(D,{name:"chevron-up"}):n(D,{name:"chevron-down"})]}),R&&_&&n("div",{className:a.headerActions,children:[y&&c.length>1&&n("button",{className:a.nextBtn,type:"button",onClick:y,children:"Next"}),n("button",{className:a.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),i&&n("div",{className:a.list,children:c.map((e,t)=>n(de,{item:e,isActive:e.showId===v&&e.episodeNumber===x,index:t,onRemove:B,onTouchPointerDown:Q,onTouchPointerMove:S,onTouchPointerUp:q,onTouchPointerCancel:M,shouldIgnoreClick:()=>C.current,onDragStart:()=>$(t),onDragEnter:()=>k(t),onDragEnd:A,isDragging:o===t},e.id))})]})};export{ge as Q,a as s};
@@ -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-Bd24Icus.js";import{L as F}from"./LibraryListPage-L4Lyt1BV.js";import{u as _,M as q}from"./useMangaPopup-BiaJvL8C.js";import{M as D}from"./MangaResetProgressModal-CmIGgwJc.js";import{m as G}from"./index-hrS3r0UE.js";import{n as O,b as Q,h as Y,j,u as z,o as H,q as K,s as V,M as R,m as Z,i as J,a as W}from"./useMangaLibrary-DQvZO29f.js";import"./vendor-icons-C1Pj_eSX.js";import"./MediaPopupShell-BewMMT93.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-CBGHgiBA.js";import"./SkeletonGrid-CKVHMLEB.js";import"./ErrorMessage-hMt90aG4.js";import"./LibraryListPage.module-r6k9nyT9.js";import"./usePopup-DS9jMzp6.js";import"./ResetProgressModal-udBYaYWc.js";import"./vendor-query-BBT5_sHx.js";import"./libraryInvalidation-DWCCaTbI.js";const X=["All","Continue Reading",...R],h=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 Ia(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=O(r?"All":e,g,h),s=Q(100),I=Y(),T=j(),{toggle:L,bookmarkedIds:C}=z(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:f}=_(),M=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.watchlistStatus??"",contentRating:a.contentRating||void 0,chapterLabel:a.chapterNumber?`Ch. ${a.chapterNumber}`:void 0,progressPercent:l>0?o/l*100:0,progressLabel:a.chapterNumber&&l>0?`Ch. ${a.chapterNumber} · p. ${o}/${l}`:void 0,detailTarget:a.chapterId&&a.provider&&a.mangaId?`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}/read?chapter=${encodeURIComponent(a.chapterId)}`:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`}}):(n.data?.data??[]).map(a=>({key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title||"",altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.lastChapterNumber?`Ch. ${a.lastChapterNumber}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`})),[r,s.data,n.data]),$=r?s.data?.total??0:n.data?.total??0,A=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...R],entries:S,total:$,isLoading:A,error:N,page:g,pageSize:h,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)=>M.mutate({ids:a,status:o}),onBulkRemove:a=>{r?B.mutate({ids: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:G(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(q,{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:f}),i(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{Ia as default};
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-Ce90T0yC.js";import{L as F}from"./LibraryListPage-B5q00Vno.js";import{u as _,M as q}from"./useMangaPopup-Eyed-Gg3.js";import{M as D}from"./MangaResetProgressModal-8Q_Jp8Tk.js";import{m as G}from"./index-BOJFs4B4.js";import{n as O,b as Q,h as Y,j,u as z,o as H,q as K,s as V,M as R,m as Z,i as J,a as W}from"./useMangaLibrary-OgS0RRdO.js";import"./vendor-icons-C1Pj_eSX.js";import"./MediaPopupShell-BewMMT93.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-DoPl5ONK.js";import"./SkeletonGrid-zCAxRZIz.js";import"./ErrorMessage-hMt90aG4.js";import"./LibraryListPage.module-r6k9nyT9.js";import"./usePopup-DS9jMzp6.js";import"./ResetProgressModal-CncQLVw1.js";import"./vendor-query-BBT5_sHx.js";import"./libraryInvalidation-1xwHWgGv.js";const X=["All","Continue Reading",...R],h=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 Ia(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=O(r?"All":e,g,h),s=Q(100),I=Y(),T=j(),{toggle:L,bookmarkedIds:C}=z(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:f}=_(),M=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.watchlistStatus??"",contentRating:a.contentRating||void 0,chapterLabel:a.chapterNumber?`Ch. ${a.chapterNumber}`:void 0,progressPercent:l>0?o/l*100:0,progressLabel:a.chapterNumber&&l>0?`Ch. ${a.chapterNumber} · p. ${o}/${l}`:void 0,detailTarget:a.chapterId&&a.provider&&a.mangaId?`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}/read?chapter=${encodeURIComponent(a.chapterId)}`:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`}}):(n.data?.data??[]).map(a=>({key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title||"",altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.lastChapterNumber?`Ch. ${a.lastChapterNumber}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`})),[r,s.data,n.data]),$=r?s.data?.total??0:n.data?.total??0,A=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...R],entries:S,total:$,isLoading:A,error:N,page:g,pageSize:h,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)=>M.mutate({ids:a,status:o}),onBulkRemove:a=>{r?B.mutate({ids: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:G(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(q,{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:f}),i(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{Ia as default};
@@ -1 +1 @@
1
- import{d as f,h as u,u as e}from"./vendor-core-DfaOB3Rn.js";import{S as a,B as c}from"./index-hrS3r0UE.js";const g=({isOpen:o,itemName:n,progressKind:d,listLabel:i,onClose:s,onConfirm:h})=>{const[l,r]=f(!1);return u(()=>{o&&r(!1)},[o]),e(a,{isOpen:o,onClose:()=>{r(!1),s()},title:"Reset Progress",children:[e(a.Body,{children:[e("p",{children:["Are you sure you want to remove your ",d,' progress for "',n,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:l,onChange:t=>r(t.currentTarget.checked)}),"Also remove from ",i]})]}),e(a.Actions,{children:[e(c,{variant:"secondary",onClick:()=>{r(!1),s()},children:"No"}),e(c,{variant:"danger",onClick:()=>{const t=l;r(!1),h(t),s()},children:"Yes"})]})]})};export{g as R};
1
+ import{d as f,h as u,u as e}from"./vendor-core-DfaOB3Rn.js";import{S as a,B as c}from"./index-BOJFs4B4.js";const g=({isOpen:o,itemName:n,progressKind:d,listLabel:i,onClose:s,onConfirm:h})=>{const[l,r]=f(!1);return u(()=>{o&&r(!1)},[o]),e(a,{isOpen:o,onClose:()=>{r(!1),s()},title:"Reset Progress",children:[e(a.Body,{children:[e("p",{children:["Are you sure you want to remove your ",d,' progress for "',n,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:l,onChange:t=>r(t.currentTarget.checked)}),"Also remove from ",i]})]}),e(a.Actions,{children:[e(c,{variant:"secondary",onClick:()=>{r(!1),s()},children:"No"}),e(c,{variant:"danger",onClick:()=>{const t=l;r(!1),h(t),s()},children:"Yes"})]})]})};export{g as R};
@@ -1 +1 @@
1
- import{h as G,p as pe,a as fe,d as c,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-C1Pj_eSX.js";import{P as te}from"./MediaCard-Bd24Icus.js";import{A as Ae}from"./AnimeCard-ZMgtR741.js";import{S as Se}from"./SkeletonGrid-CKVHMLEB.js";import{t as ye,u as be,I as Ce,a8 as le,B as U,a9 as Ne}from"./index-hrS3r0UE.js";import{E as Te}from"./ErrorMessage-hMt90aG4.js";import{A as Ee}from"./ActiveFilterChips-olGfwxle.js";import{s as t}from"./Search.module-DjQZ0jox.js";import"./MediaPopupShell-BewMMT93.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-CBGHgiBA.js";import"./useAnimeInfoData-Di0AjMa7.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-C1o8UacJ.js";import"./playbackCompletion-DzRc-CrM.js";const Re=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Ie=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],Pe=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],De=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Oe=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function Je(){G(()=>{document.title="Search - dango"},[]);const[r,se]=pe(),k=fe(),[d,$]=c(r.get("query")||""),[v,F]=c(parseInt(r.get("page")||"1")),[h,g]=c(r.get("type")||"ALL"),[L,A]=c(r.get("season")||"ALL"),[S,y]=c(r.get("year")||"ALL"),[M,D]=c(r.get("country")||"ALL"),[V,re]=c(r.get("provider")||"anilist"),[j,O]=c(r.get("sortBy")||"POPULARITY_DESC"),[q,w]=c(r.get("status")||""),[b,ne]=c(!1),[ie,z]=c(null);G(()=>{let e=!1;return ye.data.anilistStatus.query().then(s=>{e||z(s.available)}).catch(()=>{e||z(!0)}),()=>{e=!0}},[]);const{lowEndMode:oe}=be(),_=ge(null),{data:ce}=Ce(),H=ce?.genres||[],[C,N]=c(()=>{const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],i=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return s.forEach(l=>l&&(e[l]="include")),i.forEach(l=>l&&(e[l]="exclude")),e}),W=new URLSearchParams(r);W.delete("page");const J=W.toString(),{data:p=[],isLoading:T,isError:ue,error:de}=le(J,v,14),{data:K}=le(J,v+1,14),[x,he]=c(!1),E=Le.useMemo(()=>V==="anilist"&&h==="ADULT"||x?p:p.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[p,x,V,h]);G(()=>{$(r.get("query")||""),g(r.get("type")||"ALL"),A(r.get("season")||"ALL"),y(r.get("year")||"ALL"),D(r.get("country")||"ALL"),re(r.get("provider")||"anilist"),O(r.get("sortBy")||"POPULARITY_DESC"),w(r.get("status")||""),F(parseInt(r.get("page")||"1"));const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],i=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];s.forEach(l=>l&&(e[l]="include")),i.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const u=(e=1,s={})=>{Ne();const i=s.type??h,l=s.status??q,R=s.season??L,I=s.year??S,Z=s.country??M,P=s.sort??j,ee=s.genreState??C,ve=s.showMature??x,o=new URLSearchParams;d.trim()&&o.set("query",d.trim()),i!=="ALL"&&o.set("type",i),l&&o.set("status",l),R!=="ALL"&&o.set("season",R),I!=="ALL"&&o.set("year",I),Z!=="ALL"&&o.set("country",Z),P!=="POPULARITY_DESC"&&o.set("sortBy",P);const Y=Object.entries(ee).filter(([,n])=>n==="include").map(([n])=>n),ae=Object.entries(ee).filter(([,n])=>n==="exclude").map(([n])=>n);if(Y.some(n=>n.toLowerCase()==="hentai")){const n=new URLSearchParams;n.set("provider","anilist"),d.trim()&&n.set("query",d.trim()),l&&n.set("status",l),R!=="ALL"&&n.set("season",R),I!=="ALL"&&n.set("year",I),P!=="POPULARITY_DESC"&&n.set("sortBy",P),k(`/mature?${n.toString()}`);return}Y.length>0&&o.set("genres",Y.join(",")),ae.length>0&&o.set("excludeGenres",ae.join(",")),i!=="ADULT"&&!ve&&o.set("adult","false"),o.set("provider","anilist"),e>1&&o.set("page",e.toString()),se(o),e!==v&&F(e)},Q=e=>{if(u(e),_.current){const s=_.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:s,behavior:"smooth"})}},B=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:B-1980+1},(e,s)=>({value:String(B-s),label:String(B-s)}))],X=p.length>=14&&K&&K.length>0,m=[];h!=="ALL"&&m.push({key:"type",label:`Type: ${h}`,onRemove:()=>{g("ALL"),u(1,{type:"ALL"})}}),L!=="ALL"&&m.push({key:"season",label:`Season: ${L}`,onRemove:()=>{A("ALL"),u(1,{season:"ALL"})}}),S!=="ALL"&&m.push({key:"year",label:`Year: ${S}`,onRemove:()=>{y("ALL"),u(1,{year:"ALL"})}});for(const[e,s]of Object.entries(C))m.push({key:e,label:s==="include"?`+ ${e}`:`-${e}`,tone:s==="include"?"primary":"danger",onRemove:()=>{const i={...C};delete i[e],N(i),u(1,{genreState:i})}});return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(f,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:d,onInput:e=>$(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&u()})]}),a("div",{className:t.searchActions,children:[a(U,{onClick:()=>u(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${b?t.active:""}`,onClick:()=>ne(!b),children:[a(f,{name:"filter",size:14}),a("span",{children:"Filters"}),b?a(f,{name:"chevron-up",size:12}):a(f,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${b?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:h,onChange:e=>{if(e.currentTarget.value==="ADULT"){k("/mature?provider=mal");return}g(e.currentTarget.value)},children:Re.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:q,onChange:e=>w(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Oe.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:L,onChange:e=>A(e.currentTarget.value),children:Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:S,onChange:e=>y(e.currentTarget.value),children:me.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",ie===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only - ignored by fallback providers"})]}),a("select",{value:M,onChange:e=>D(e.currentTarget.value),children:Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:j,onChange:e=>O(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),H.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:H.map(e=>a("button",{className:`${t.genreButton} ${t[C[e]||""]}`,onClick:()=>{N(s=>{const i=s[e],l={...s};return i==="include"?l[e]="exclude":i==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(U,{variant:"secondary",onClick:()=>{N({}),g("ALL"),A("ALL"),y("ALL"),D("ALL"),O("POPULARITY_DESC"),w(""),he(!1),u(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(U,{onClick:()=>u(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ue&&a(Te,{message:de?.message||"Error"}),m.length>0&&a(Ee,{chips:m}),a("div",{className:t.resultsHeader,ref:_,children:[a("h2",{className:t.resultsTitle,children:d?`Search Results for "${d}"`:"Discover Anime"}),E.length>0&&a(te,{page:v,canGoNext:X,onChange:Q,isLoading:T})]}),a("div",{className:`${t.resultsGrid} ${oe?t.lowEnd:""}`,children:T?a(Se,{}):E.map(e=>a(Ae,{anime:e},e._id))}),!T&&E.length===0&&a("div",{className:t.noResults,children:[a(f,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),E.length>0&&a("div",{className:t.bottomPagination,children:a(te,{page:v,canGoNext:X,onChange:Q,isLoading:T,variant:"labeled"})})]})}export{Je as default};
1
+ import{h as G,p as pe,a as fe,d as c,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-C1Pj_eSX.js";import{P as te}from"./MediaCard-Ce90T0yC.js";import{A as Ae}from"./AnimeCard-CcvD-9Bi.js";import{S as Se}from"./SkeletonGrid-zCAxRZIz.js";import{t as ye,u as be,I as Ce,a8 as le,B as U,a9 as Ne}from"./index-BOJFs4B4.js";import{E as Te}from"./ErrorMessage-hMt90aG4.js";import{A as Ee}from"./ActiveFilterChips-olGfwxle.js";import{s as t}from"./Search.module-DjQZ0jox.js";import"./MediaPopupShell-BewMMT93.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-DoPl5ONK.js";import"./useAnimeInfoData-CvV6vRjn.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-BHkP1DB_.js";import"./playbackCompletion-BpEGpC-Z.js";const Re=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Ie=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],Pe=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],De=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Oe=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function Je(){G(()=>{document.title="Search - dango"},[]);const[r,se]=pe(),k=fe(),[d,$]=c(r.get("query")||""),[v,F]=c(parseInt(r.get("page")||"1")),[h,g]=c(r.get("type")||"ALL"),[L,A]=c(r.get("season")||"ALL"),[S,y]=c(r.get("year")||"ALL"),[M,D]=c(r.get("country")||"ALL"),[V,re]=c(r.get("provider")||"anilist"),[j,O]=c(r.get("sortBy")||"POPULARITY_DESC"),[q,w]=c(r.get("status")||""),[b,ne]=c(!1),[ie,z]=c(null);G(()=>{let e=!1;return ye.data.anilistStatus.query().then(s=>{e||z(s.available)}).catch(()=>{e||z(!0)}),()=>{e=!0}},[]);const{lowEndMode:oe}=be(),_=ge(null),{data:ce}=Ce(),H=ce?.genres||[],[C,N]=c(()=>{const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],i=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return s.forEach(l=>l&&(e[l]="include")),i.forEach(l=>l&&(e[l]="exclude")),e}),W=new URLSearchParams(r);W.delete("page");const J=W.toString(),{data:p=[],isLoading:T,isError:ue,error:de}=le(J,v,14),{data:K}=le(J,v+1,14),[x,he]=c(!1),E=Le.useMemo(()=>V==="anilist"&&h==="ADULT"||x?p:p.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[p,x,V,h]);G(()=>{$(r.get("query")||""),g(r.get("type")||"ALL"),A(r.get("season")||"ALL"),y(r.get("year")||"ALL"),D(r.get("country")||"ALL"),re(r.get("provider")||"anilist"),O(r.get("sortBy")||"POPULARITY_DESC"),w(r.get("status")||""),F(parseInt(r.get("page")||"1"));const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],i=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];s.forEach(l=>l&&(e[l]="include")),i.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const u=(e=1,s={})=>{Ne();const i=s.type??h,l=s.status??q,R=s.season??L,I=s.year??S,Z=s.country??M,P=s.sort??j,ee=s.genreState??C,ve=s.showMature??x,o=new URLSearchParams;d.trim()&&o.set("query",d.trim()),i!=="ALL"&&o.set("type",i),l&&o.set("status",l),R!=="ALL"&&o.set("season",R),I!=="ALL"&&o.set("year",I),Z!=="ALL"&&o.set("country",Z),P!=="POPULARITY_DESC"&&o.set("sortBy",P);const Y=Object.entries(ee).filter(([,n])=>n==="include").map(([n])=>n),ae=Object.entries(ee).filter(([,n])=>n==="exclude").map(([n])=>n);if(Y.some(n=>n.toLowerCase()==="hentai")){const n=new URLSearchParams;n.set("provider","anilist"),d.trim()&&n.set("query",d.trim()),l&&n.set("status",l),R!=="ALL"&&n.set("season",R),I!=="ALL"&&n.set("year",I),P!=="POPULARITY_DESC"&&n.set("sortBy",P),k(`/mature?${n.toString()}`);return}Y.length>0&&o.set("genres",Y.join(",")),ae.length>0&&o.set("excludeGenres",ae.join(",")),i!=="ADULT"&&!ve&&o.set("adult","false"),o.set("provider","anilist"),e>1&&o.set("page",e.toString()),se(o),e!==v&&F(e)},Q=e=>{if(u(e),_.current){const s=_.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:s,behavior:"smooth"})}},B=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:B-1980+1},(e,s)=>({value:String(B-s),label:String(B-s)}))],X=p.length>=14&&K&&K.length>0,m=[];h!=="ALL"&&m.push({key:"type",label:`Type: ${h}`,onRemove:()=>{g("ALL"),u(1,{type:"ALL"})}}),L!=="ALL"&&m.push({key:"season",label:`Season: ${L}`,onRemove:()=>{A("ALL"),u(1,{season:"ALL"})}}),S!=="ALL"&&m.push({key:"year",label:`Year: ${S}`,onRemove:()=>{y("ALL"),u(1,{year:"ALL"})}});for(const[e,s]of Object.entries(C))m.push({key:e,label:s==="include"?`+ ${e}`:`-${e}`,tone:s==="include"?"primary":"danger",onRemove:()=>{const i={...C};delete i[e],N(i),u(1,{genreState:i})}});return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(f,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:d,onInput:e=>$(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&u()})]}),a("div",{className:t.searchActions,children:[a(U,{onClick:()=>u(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${b?t.active:""}`,onClick:()=>ne(!b),children:[a(f,{name:"filter",size:14}),a("span",{children:"Filters"}),b?a(f,{name:"chevron-up",size:12}):a(f,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${b?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:h,onChange:e=>{if(e.currentTarget.value==="ADULT"){k("/mature?provider=mal");return}g(e.currentTarget.value)},children:Re.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:q,onChange:e=>w(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Oe.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:L,onChange:e=>A(e.currentTarget.value),children:Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:S,onChange:e=>y(e.currentTarget.value),children:me.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",ie===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only - ignored by fallback providers"})]}),a("select",{value:M,onChange:e=>D(e.currentTarget.value),children:Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:j,onChange:e=>O(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),H.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:H.map(e=>a("button",{className:`${t.genreButton} ${t[C[e]||""]}`,onClick:()=>{N(s=>{const i=s[e],l={...s};return i==="include"?l[e]="exclude":i==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(U,{variant:"secondary",onClick:()=>{N({}),g("ALL"),A("ALL"),y("ALL"),D("ALL"),O("POPULARITY_DESC"),w(""),he(!1),u(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(U,{onClick:()=>u(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ue&&a(Te,{message:de?.message||"Error"}),m.length>0&&a(Ee,{chips:m}),a("div",{className:t.resultsHeader,ref:_,children:[a("h2",{className:t.resultsTitle,children:d?`Search Results for "${d}"`:"Discover Anime"}),E.length>0&&a(te,{page:v,canGoNext:X,onChange:Q,isLoading:T})]}),a("div",{className:`${t.resultsGrid} ${oe?t.lowEnd:""}`,children:T?a(Se,{}):E.map(e=>a(Ae,{anime:e},e._id))}),!T&&E.length===0&&a("div",{className:t.noResults,children:[a(f,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),E.length>0&&a("div",{className:t.bottomPagination,children:a(te,{page:v,canGoNext:X,onChange:Q,isLoading:T,variant:"labeled"})})]})}export{Je as default};
@@ -1,4 +1,4 @@
1
- import{d as r,u as e,S as le,A as X,h as z,q as pe,T as qe,p as ze,g as be,_ as Ue}from"./vendor-core-DfaOB3Rn.js";import{b as fe,u as ee}from"./vendor-query-BBT5_sHx.js";import{U as Z,V as Q,W as U,X as Ce,B as C,Y as Ee,S as K,d as Ke,O as Te,t as k,w as Fe,r as $e,L as ke,Z as J,q as H,_ as Se,$ as We,a0 as He,u as Be,g as je,a1 as Qe,N as de,p as Ve,a2 as Ye,a3 as Je}from"./index-hrS3r0UE.js";import{I as j}from"./vendor-icons-C1Pj_eSX.js";import{T as F}from"./ToggleSwitch-CN_ppEc9.js";import{l as Xe,s as Ze}from"./playbackCompletion-DzRc-CrM.js";import{M as et}from"./MatureConsentModal-CBGHgiBA.js";const tt="_sectionCard_1vuib_1",at="_dangerCard_1vuib_20",nt="_settingRow_1vuib_31",_={sectionCard:tt,dangerCard:at,settingRow:nt};function rt(){const{data:t}=fe(Z),{data:s}=fe({queryKey:["profiles"],queryFn:()=>Q("/api/profiles/status"),enabled:!!t?.owner}),c=ee(),[p,d]=r(null),[y,S]=r(""),[h,o]=r(""),[a,g]=r(""),[v,m]=r(""),[x,l]=r(""),[f,T]=r(!1),[I,G]=r(null),[P,w]=r(null),[L,A]=r(""),M=async i=>{T(!0),l("");try{await Q("/api/profiles/update",{method:"POST",body:JSON.stringify(i)}),await c.invalidateQueries({queryKey:Z.queryKey}),S(""),o(""),l("Profile saved")}catch(R){l(R.message)}finally{T(!1)}};return t?e("section",{className:_.sectionCard,children:[e("h3",{children:"Your profile"}),e("p",{children:"Keep using this profile, rename it, or add another person with their own library and connections."}),e("div",{className:U.avatarRow,children:[e(Ce,{image:t.image,name:t.name}),e("label",{className:U.uploadButton,children:[e(j,{name:"upload"}),e("span",{children:"Upload image"}),e("input",{className:U.fileInput,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",disabled:f,onChange:async i=>{const R=i.currentTarget.files?.[0];if(i.currentTarget.value="",!R)return;if(R.size>2*1024*1024){l("Image must be smaller than 2 MB");return}const D=new FileReader;D.onerror=()=>l("Could not read image"),D.onload=()=>{M({avatar:D.result})},D.readAsDataURL(R)}})]}),t.avatar&&e(C,{variant:"secondary",disabled:f,onClick:()=>M({avatar:null}),children:"Clear uploaded image"})]}),e("p",{children:"Your uploaded image takes priority, followed by your active cloud account image, then the default user icon."}),e("form",{className:U.form,onSubmit:i=>{i.preventDefault(),M({name:p??t.name})},children:[e("label",{className:U.field,children:["Profile name",e("input",{value:p??t.name,maxLength:60,required:!0,onChange:i=>d(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save name"})]}),e("form",{className:U.form,onSubmit:i=>{i.preventDefault(),M({password:y,currentPassword:h})},children:[t.protected&&e("label",{className:U.field,children:["Current password",e("input",{type:"password",autoComplete:"current-password",value:h,required:!0,maxLength:256,onChange:i=>o(i.currentTarget.value)})]}),e("label",{className:U.field,children:[t.protected?"New password (empty removes protection)":"Protect this profile",e("input",{type:"password",autoComplete:"new-password",value:y,minLength:8,maxLength:256,onChange:i=>S(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save password"})]}),e(C,{variant:"secondary",disabled:f,onClick:async()=>{T(!0);try{await Q("/api/profiles/logout",{method:"POST"}),Ee()}catch(i){l(i.message),T(!1)}},children:"Switch profile / sign out"}),t.owner&&e("form",{className:U.form,onSubmit:async i=>{i.preventDefault(),T(!0),l("");try{await Q("/api/profiles/create",{method:"POST",body:JSON.stringify({name:a,password:v})}),g(""),m(""),await c.invalidateQueries({queryKey:["profiles"]}),l("Profile created. Sign out to switch to it.")}catch(R){l(R.message)}finally{T(!1)}},children:[e("h3",{children:"Add another profile"}),e("p",{children:"Protect your owner profile first. New profiles start empty and do not inherit your accounts. A profile without a password is accessible to anyone who passes the LAN lock."}),e("label",{className:U.field,children:["Name",e("input",{required:!0,maxLength:60,value:a,onChange:i=>g(i.currentTarget.value)})]}),e("label",{className:U.field,children:["Password (optional)",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,value:v,onChange:i=>m(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f||!t.protected,children:"Create profile"})]}),t.owner&&s?.profiles.some(i=>!i.owner)&&e(le,{children:[e("h3",{children:"Other profiles"}),e("ul",{className:U.profileList,children:s.profiles.filter(i=>!i.owner).map(i=>e("li",{children:[e("span",{className:U.smallAvatar,children:e(Ce,{image:i.avatar??i.cloudAvatar,name:i.name})}),e("span",{className:U.profileName,children:i.name}),e(C,{variant:"secondary",size:"sm",disabled:f,onClick:()=>{l(""),A(""),w(i)},children:"Reset password"}),e(C,{variant:"danger",size:"sm",disabled:f,onClick:()=>{l(""),G(i)},children:"Delete"})]},i.id))})]}),e(K,{isOpen:!!P,onClose:f?void 0:()=>w(null),title:"Reset password",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>w(null),children:"Cancel"}),e(C,{loading:f,onClick:async()=>{if(P){T(!0),l("");try{await Q("/api/profiles/reset-password",{method:"POST",body:JSON.stringify({id:P.id,password:L})}),await c.invalidateQueries({queryKey:["profiles"]}),w(null),A(""),l("Password updated. The profile has been signed out.")}catch(i){l(i.message)}finally{T(!1)}}},children:"Save password"})]}),children:[e("p",{children:["Set a new password for ",e("strong",{children:P?.name}),". They will be signed out and must use the new password next time."]}),e("label",{className:U.field,children:["New password",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,placeholder:"Leave empty to remove their password",value:L,onChange:i=>A(i.currentTarget.value)})]})]}),e(K,{isOpen:!!I,onClose:f?void 0:()=>G(null),title:"Delete profile?",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>G(null),children:"Cancel"}),e(C,{variant:"danger",loading:f,onClick:async()=>{if(I){T(!0);try{await Q("/api/profiles/delete",{method:"POST",body:JSON.stringify({id:I.id,confirm:!0})}),await c.invalidateQueries({queryKey:["profiles"]}),G(null),l("Profile deleted. Local files will be removed when Dango restarts.")}catch(i){l(i.message),G(null)}finally{T(!1)}}},children:"Delete profile"})]}),children:[e("p",{children:["Delete ",e("strong",{children:I?.name}),"? This signs them out immediately. Their local libraries, settings and connections will be removed when Dango next restarts."]}),e("p",{children:"Cloud backups and tracker lists will stay intact. Export any library you want to keep before deleting."})]}),x&&e("p",{role:"status",children:x})]}):null}const ue={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},he=["name","nativeName","englishName"],ge={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},st=()=>{const{titlePreference:t,setTitlePreference:s,loading:c}=Ke(),p=Te(),[d,y]=r(ge[t]),[S,h]=r(!1),o=X(null);z(()=>{c||y(ge[t])},[t,c]);const a=async()=>{if(S)return;h(!0);const v=(he.indexOf(t)+1)%he.length,m=he[v],x=ge[m];o.current&&(o.current.style.transform="translateX(-100%)",o.current.style.opacity="0"),setTimeout(async()=>{y(x),s(m),o.current&&(o.current.style.transition="none",o.current.style.transform="translateX(100%)",o.current.style.opacity="0",o.current.offsetWidth,o.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",o.current.style.transform="translateX(0)",o.current.style.opacity="1");try{await p.mutateAsync({key:"titlePreference",value:m})}catch(l){console.error("Error saving title preference:",l)}finally{h(!1)}},300)};return c?e("p",{children:"Loading title preference..."}):e("div",{className:ue["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ue["toggle-button"],disabled:S,children:e("span",{ref:o,className:ue["toggle-label"],children:d})})]})},it="_settingsHeader_gfwoa_1",ot="_pageTitle_gfwoa_6",lt="_pageSubtitle_gfwoa_14",ct="_settingsLayout_gfwoa_20",dt="_sidebar_gfwoa_27",ut="_sidebarIndicator_gfwoa_35",ht="_sidebarItem_gfwoa_50",gt="_active_gfwoa_72",mt="_mainContent_gfwoa_80",pt="_tabContent_gfwoa_85",ft="_settingItem_gfwoa_103",yt="_shortcutContainer_gfwoa_108",vt="_shortcutGroup_gfwoa_115",wt="_shortcutGroupTitle_gfwoa_121",bt="_shortcutGrid_gfwoa_130",Ct="_shortcutCard_gfwoa_136",kt="_controls_gfwoa_170",St="_status_gfwoa_176",u={settingsHeader:it,pageTitle:ot,pageSubtitle:lt,settingsLayout:ct,sidebar:dt,sidebarIndicator:ut,sidebarItem:ht,active:gt,mainContent:mt,tabContent:pt,settingItem:ft,shortcutContainer:yt,shortcutGroup:vt,shortcutGroupTitle:wt,shortcutGrid:bt,shortcutCard:Ct,controls:kt,status:St},Nt="_title_tm30b_11",_t="_signIn_tm30b_18",Tt="_userInfo_tm30b_25",Pt="_warning_tm30b_47",It="_formGroup_tm30b_54",Lt="_label_tm30b_58",xt="_inputWrapper_tm30b_68",Rt="_input_tm30b_68",Dt="_select_tm30b_92",Ot="_actions_tm30b_109",At="_hr_tm30b_117",b={title:Nt,signIn:_t,userInfo:Tt,warning:Pt,formGroup:It,label:Lt,inputWrapper:xt,input:Rt,select:Dt,actions:Ot,hr:At},Mt=()=>{const t=ee(),[s,c]=r(!0),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(null),[a,g]=r({status:"idle"}),[v,m]=r(!1),[x,l]=r(""),[f,T]=r(!1),I=X(null),[G,P]=r({show:!1,message:"",type:"info"}),w=()=>{I.current&&(window.clearInterval(I.current),I.current=null)},L=pe(N=>{S(N.authenticated),o(N.user||N.device.user||null),g(N.device),m(!!N.hasCustomClientId)},[]),A=pe(async()=>{const N=await k.auth.githubStatus.query();L(N)},[L]),M=async()=>{try{const N=await k.auth.githubPoll.query();g(N),N.status==="success"?(w(),await t.invalidateQueries({queryKey:Z.queryKey}),await A(),P({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):N.status==="error"&&(w(),P({show:!0,message:N.error||"GitHub authentication failed.",type:"error"}))}catch{w(),P({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},i=(N=5)=>{w(),I.current=window.setInterval(M,Math.max(N,5)*1e3)};z(()=>(A().catch(()=>{P({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>c(!1)),w),[A]);const R=async()=>{d(!0);try{const N=await k.auth.githubStart.mutate();g(N),i(N.verification?.interval)}catch(N){P({show:!0,message:N instanceof Error?N.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},D=async()=>{try{await k.auth.githubLogout.mutate(),await t.invalidateQueries({queryKey:Z.queryKey}),S(!1),o(null),g({status:"idle"}),P({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{P({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},W=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:x}),l(""),await A(),P({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{P({show:!0,message:"Failed to save override.",type:"error"})}finally{T(!1)}},te=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:""}),l(""),await A(),P({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{P({show:!0,message:"Failed to clear override.",type:"error"})}finally{T(!1)}};return s?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"GitHub Cloud Sync"}),e("p",{className:b.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),y&&h?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:h.name||h.login})]}),e(C,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:b.signIn,children:e(C,{onClick:R,disabled:p||a.status==="pending",children:p||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(le,{children:[e("hr",{className:b.hr}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Verification URL"}),e("div",{className:b.inputWrapper,children:[e("input",{className:b.input,value:a.verification.verification_uri,readOnly:!0}),e(C,{onClick:()=>{const N=a.verification?.verification_uri;N&&/^https?:\/\//i.test(N)&&window.open(N,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Device Code"}),e("input",{className:b.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:b.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",v?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:x,onChange:N=>l(N.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:b.actions,children:[e(C,{onClick:W,disabled:f,children:"Save override"}),e(C,{variant:"secondary",onClick:te,disabled:f,children:"Use dango defaults"})]})]}),e(K,{isOpen:G.show,onClose:()=>P(N=>({...N,show:!1})),width:"sm",children:[e(K.Body,{children:e("p",{children:G.message})}),e(K.Actions,{children:e(C,{onClick:()=>P(N=>({...N,show:!1})),children:"OK"})})]})]})},Gt=()=>{const[t,s]=r(!0),[c,p]=r(null),[d,y]=r(!1),[S,h]=r(!1),[o,a]=r(""),[g,v]=r(""),[m,x]=r(""),[l,f]=r(!1),[T,I]=r({show:!1,message:"",type:"info"}),G=async()=>{try{const R=await k.auth.user.query();p(R?.email?R:null)}catch{p(null)}},P=async()=>{try{const[i,R]=await Promise.all([k.auth.configStatus.query(),k.auth.googleAuth.query()]);y(!!i.hasConfig),h(!!(R.hasCustomWorkerUrl||R.hasCustomClientId||R.hasClientSecret))}catch(i){console.error("Failed to fetch config status",i)}};z(()=>{(async()=>{s(!0),await Promise.all([G(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await G(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const R=D=>{D.origin===window.location.origin&&typeof D.data=="object"&&D.data!==null&&D.data.type==="GOOGLE_AUTH_SUCCESS"&&(p(D.data.user),window.location.reload())};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[]);const w=async()=>{try{const i=await k.auth.googleLogin.mutate();if(i.authenticated){window.location.reload();return}if(i.url){if(typeof window.DangoBridge<"u"){window.location.href=i.url;return}const D=600,W=700,te=window.innerWidth/2-D/2,N=window.innerHeight/2-W/2;window.open(i.url,"GoogleAuth",`width=${D},height=${W},top=${N},left=${te}`)}else throw new Error("Auth URL not available")}catch{I({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},L=async()=>{try{await k.auth.logout.mutate(),p(null),I({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(i){console.error("Sign out failed",i),I({show:!0,message:"Failed to sign out.",type:"error"})}},A=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:o,clientId:g,clientSecret:m}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{I({show:!0,message:"Failed to save override.",type:"error"})}finally{f(!1)}},M=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{I({show:!0,message:"Failed to clear override.",type:"error"})}finally{f(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Google Drive Sync"}),c?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:c.name})," (",c.email,")"]}),e(C,{variant:"danger",onClick:L,children:"Sign Out"})]}):e("div",{className:b.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(C,{onClick:w,disabled:!d,children:"Sign in with Google"}),!d&&e("p",{className:b.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",S?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Worker URL (optional)"}),e("input",{className:b.input,value:o,onChange:i=>a(i.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:g,onChange:i=>v(i.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:b.input,value:m,onChange:i=>x(i.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:b.actions,children:[e(C,{onClick:A,disabled:l,children:"Save override"}),e(C,{variant:"secondary",onClick:M,disabled:l,children:"Use dango defaults"})]})]}),e(K,{isOpen:T.show,onClose:()=>I(i=>({...i,show:!1})),width:"sm",children:[e(K.Body,{children:e("p",{children:T.message})}),e(K.Actions,{children:e(C,{onClick:()=>I(i=>({...i,show:!1})),children:"OK"})})]})]})},qt="_settingItem_3qq0n_1",zt="_modalOverlay_3qq0n_6",Ut="_modal_3qq0n_6",Et="_modalActions_3qq0n_41",Kt="_modalSecondary_3qq0n_47",Ft="_modalPrimary_3qq0n_57",B={settingItem:qt,modalOverlay:zt,modal:Ut,modalActions:Et,modalSecondary:Kt,modalPrimary:Ft},$t={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},Wt=(t,s)=>{if(t==null)return s;const c=String(t);return c==="true"||c==="1"?!0:c==="false"||c==="0"?!1:s},Ne=(t,s,c)=>{const[p,d]=r(s),[y,S]=r(!1),h=ee();return z(()=>{(async()=>{try{const g=await k.settings.getByKey.query({key:t});d(Wt(g.value,s))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,s]),{value:p,setValue:d,isUpdating:y,toggle:async()=>{if(y)return;S(!0);const a=!p;d(a);try{await k.settings.set.mutate({key:t,value:a});for(const g of c)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),d(!a)}finally{S(!1)}}}},Ht=()=>{const{contentType:t}=Fe(),s=$t[t],[c,p]=r(!1),[d,y]=r(!0),[S,h]=r(!1),o=Ne(s.ignoreKey,!0,s.invalidateKeys),a=Ne(s.listOnlyKey,!1,s.invalidateKeys),[g,v]=r(null),[m,x]=r(!1),l=ee(),f=$e();z(()=>{y(!0),(async()=>{try{const L=await k.settings.getByKey.query({key:s.skipKey});String(L.value)==="true"||String(L.value)==="1"?p(!0):p(!1)}catch(L){console.error("Failed to fetch setting",L)}finally{y(!1)}})()},[s.skipKey]);const T=async()=>{if(S)return;h(!0);const w=!c;p(w);try{await k.settings.set.mutate({key:s.skipKey,value:w})}catch(L){console.error("Error saving setting:",L),p(!w)}finally{h(!1)}},I=async()=>{if(!o.isUpdating){if(o.value)try{let w;if(t==="anime"?w=(await k.continueWatching.adultCount.query()).count:t==="manga"?w=(await k.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await k.asmrProgress.adultCount.query()).count:w=(await k.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){v(w);return}}catch(w){console.error("Failed to fetch adult count",w)}o.toggle()}},G=()=>{v(null),o.toggle()},P=async()=>{if(!m){x(!0);try{let w;t==="anime"?w=(await k.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await k.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await k.asmrProgress.purgeAdult.mutate()).removed:w=(await k.tvProgress.purgeAdult.mutate()).removed,ke.success(s.purgeDoneText(w??0));for(const L of s.invalidateKeys)l.invalidateQueries({queryKey:L});t==="anime"&&l.invalidateQueries(f.continueWatching.pathFilter()),t==="manga"&&l.invalidateQueries(f.mangaProgress.pathFilter()),t==="asmr"&&l.invalidateQueries(f.asmrProgress.pathFilter()),t==="tv"&&l.invalidateQueries(f.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),ke.error("Failed to remove adult entries")}finally{x(!1),v(null)}o.toggle()}};return d?e("div",{children:"Loading settings..."}):e("div",{className:_.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(F,{isChecked:c,onChange:T,id:"skip-confirmation-toggle",disabled:S})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(F,{isChecked:o.value,onChange:I,id:"ignore-adult-toggle",disabled:o.isUpdating})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(F,{isChecked:a.value,onChange:a.toggle,id:"cw-watchlist-only-toggle",disabled:a.isUpdating})]})}),g!==null&&e("div",{className:B.modalOverlay,onClick:()=>v(null),children:e("div",{className:B.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",s.listNoun," ",g===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:B.modalActions,children:[e("button",{type:"button",className:B.modalSecondary,onClick:G,disabled:m,children:"Show them"}),e("button",{type:"button",className:B.modalPrimary,onClick:P,disabled:m,children:m?"Purging...":`Purge ${g}`})]})]})})]})},Bt="_statsGrid_o4nf0_1",jt="_statCard_o4nf0_8",Qt="_statLabel_o4nf0_18",Vt="_statValue_o4nf0_26",Yt="_statMeta_o4nf0_32",Jt="_statusBanner_o4nf0_38",Xt="_statusSuccess_o4nf0_49",Zt="_statusUpdating_o4nf0_55",ea="_statusError_o4nf0_61",ta="_sha_o4nf0_67",aa="_settingItem_o4nf0_74",na="_settingTitle_o4nf0_79",ra="_settingSubtitle_o4nf0_85",sa="_actionsRow_o4nf0_92",O={statsGrid:Bt,statCard:jt,statLabel:Qt,statValue:Vt,statMeta:Yt,statusBanner:Jt,statusSuccess:Xt,statusUpdating:Zt,statusError:ea,sha:ta,settingItem:aa,settingTitle:na,settingSubtitle:ra,actionsRow:sa},ia=()=>{const[t,s]=r(null),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r(!1),o=X(null),a=async()=>{try{const l=await k.settings.offlineDbInfo.query();return s(l),l}catch(l){console.error("Failed to fetch offline DB info:",l)}finally{p(!1)}return null};z(()=>(a(),()=>{o.current&&window.clearInterval(o.current)}),[]),z(()=>{t?.isRefreshing?o.current||(o.current=window.setInterval(async()=>{const l=await a();l&&!l.isRefreshing&&o.current&&(window.clearInterval(o.current),o.current=null)},2e3)):o.current&&(window.clearInterval(o.current),o.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||d)return;const l=!t.autoUpdateEnabled;y(!0),s({...t,autoUpdateEnabled:l});try{await k.settings.setOfflineDbAutoUpdate.mutate({enabled:l})}catch(f){console.error("Failed to update auto update setting:",f),s({...t,autoUpdateEnabled:!l})}finally{y(!1)}},v=async()=>{if(!(t?.isRefreshing||S)){h(!0);try{await k.settings.triggerOfflineDbUpdate.mutate(),s(l=>l?{...l,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(l){console.error("Failed to trigger offline DB update:",l)}finally{h(!1)}}},m=l=>{if(!l)return"Never";try{return new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return l}},x=t?.isRefreshing||S;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:O.statsGrid,children:[e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"MAL Mapped"}),e("span",{className:O.statValue,children:c?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Release"}),e("span",{className:O.statMeta,children:c?"-":t?.releaseTag??"Never"})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Checked"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastCheckedAt??null)})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Updated"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${O.statusBanner} ${t.lastStatus==="failed"?O.statusError:t.lastStatus==="updating"?O.statusUpdating:O.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:O.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:O.settingItem,children:e("div",{className:_.settingRow,children:[e("div",{children:[e("span",{className:O.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:O.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(F,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:c||d})]})}),e("div",{className:O.actionsRow,children:e(C,{onClick:v,disabled:c||x,children:x?"Updating Database...":"Update Offline Database Now"})})]})},oa="_status_1wbo0_1",la="_warningText_1wbo0_7",ca="_ackLabel_1wbo0_11",me={status:oa,warningText:la,ackLabel:ca},da=()=>{const t=ee(),[s,c]=r(!1),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(""),a=()=>{d(!1),o(""),c(!0)},g=()=>{y||(c(!1),d(!1))},v=async()=>{if(!(!p||y)){S(!0),o("");try{const m=await J("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),x=await m.json();if(!m.ok)throw new Error(x.error||"Failed to clear database");const l=x.deleted,f=x.deletedManga,T=x.deletedTv,I=x.deletedAsmr,G=Object.values(l).reduce((A,M)=>A+(M||0),0)+Object.values(f??{}).reduce((A,M)=>A+(M||0),0)+Object.values(T??{}).reduce((A,M)=>A+(M||0),0)+Object.values(I??{}).reduce((A,M)=>A+(M||0),0),P=(f?.manga_library??0)+(f?.manga_progress??0),w=(T?.tv_library??0)+(T?.tv_progress??0),L=(I?.asmr_library??0)+(I?.asmr_progress??0);o(`Library cleared - ${l.watchlist??0} watchlist entries, ${P} manga rows, ${w} TV rows, ${L} ASMR rows and ${G} total rows removed.`),t.invalidateQueries({queryKey:[H.watchlist]}),t.invalidateQueries({queryKey:[H.continueWatching]}),t.invalidateQueries({queryKey:[H.mangaLibrary]}),t.invalidateQueries({queryKey:[H.mangaContinueReading]}),t.invalidateQueries({queryKey:[H.tvLibrary]}),t.invalidateQueries({queryKey:[H.tvContinueWatching]}),t.invalidateQueries({queryKey:[H.asmrLibrary]}),t.invalidateQueries({queryKey:[H.asmrContinueListening]}),c(!1)}catch(m){o(m.message)}finally{S(!1),d(!1)}}};return e("div",{className:`${_.sectionCard} ${_.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(C,{variant:"danger",onClick:a,children:"Clear Library Data"}),h&&e("p",{className:me.status,children:h}),e(K,{isOpen:s,onClose:g,title:"Clear library data?",width:"sm",children:[e(K.Body,{children:[e("p",{className:me.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:me.ackLabel,children:[e("input",{type:"checkbox",checked:p,onChange:m=>d(m.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(K.Actions,{children:[e(C,{variant:"secondary",onClick:g,disabled:y,children:"Cancel"}),e(C,{variant:"danger",onClick:v,disabled:!p||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},ua=()=>{const[t,s]=r(""),[c,p]=r([]),[d,y]=r(null),[S,h]=r(!0),[o,a]=r({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const m=await k.auth.rcloneSettings.query();s(m.remote||""),p(m.availableRemotes||[]),y(m.activeRemote||null)}catch(m){console.error("Failed to fetch Rclone settings",m)}finally{h(!1)}};z(()=>{g()},[]);const v=async()=>{try{await k.auth.saveRclone.mutate({remote:t}),a({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g()}catch{a({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return S?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Rclone Cloud Sync"}),e("p",{className:b.signIn,children:"Configure which Rclone remote to use for database synchronization."}),d?e("div",{className:b.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:d})]})}):e("p",{className:b.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Remote Name"}),e("div",{className:b.inputWrapper,children:e("select",{className:b.select,value:t,onChange:m=>s(m.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),c.map(m=>e("option",{value:m,children:m},m)),t&&!c.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:b.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:b.actions,children:e(C,{onClick:v,children:"Save Rclone Settings"})}),e(K,{isOpen:o.show,onClose:()=>a(m=>({...m,show:!1})),width:"sm",children:[e(K.Body,{children:e("p",{children:o.message})}),e(K.Actions,{children:e(C,{onClick:()=>a(m=>({...m,show:!1})),children:"OK"})})]})]})},ha=()=>{const t=ee(),[s,c]=r(null),[p,d]=r(!0),y=async()=>{try{const a=await k.auth.syncSettings.query();c(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};z(()=>{y()},[]);const S=async a=>{const g=a.currentTarget.value;try{const v=await k.auth.saveSyncProvider.mutate({provider:g});c(m=>m?{...m,activeProvider:v.activeProvider}:null),await y(),await t.invalidateQueries({queryKey:Z.queryKey}),Se.success(`Sync provider updated to ${g==="default"?"Default Order":g}`)}catch{Se.error("Failed to update sync provider")}};if(p||!s)return null;const h=[{value:"default",label:"Default (Priority Based)"}];s.authenticatedProviders.github&&h.push({value:"github",label:"GitHub"}),s.authenticatedProviders.google&&h.push({value:"google",label:"Google Drive"}),s.authenticatedProviders.rclone&&h.push({value:"rclone",label:"Rclone"}),h.push({value:"none",label:"None (Local Only)"});const o=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:o(s.actualActiveProvider)})]}),e("div",{className:_.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:s.activeProvider,onChange:S,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:h.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ga(){return"javascript:"+encodeURIComponent(`(function(){
1
+ import{d as r,u as e,S as le,A as X,h as z,q as pe,T as qe,p as ze,g as be,_ as Ue}from"./vendor-core-DfaOB3Rn.js";import{b as fe,u as ee}from"./vendor-query-BBT5_sHx.js";import{U as Z,V as Q,W as U,X as Ce,B as C,Y as Ee,S as K,d as Ke,O as Te,t as k,w as Fe,r as $e,L as ke,Z as J,q as H,_ as Se,$ as We,a0 as He,u as Be,g as je,a1 as Qe,N as de,p as Ve,a2 as Ye,a3 as Je}from"./index-BOJFs4B4.js";import{I as j}from"./vendor-icons-C1Pj_eSX.js";import{T as F}from"./ToggleSwitch-CN_ppEc9.js";import{l as Xe,s as Ze}from"./playbackCompletion-BpEGpC-Z.js";import{M as et}from"./MatureConsentModal-DoPl5ONK.js";const tt="_sectionCard_1vuib_1",at="_dangerCard_1vuib_20",nt="_settingRow_1vuib_31",_={sectionCard:tt,dangerCard:at,settingRow:nt};function rt(){const{data:t}=fe(Z),{data:s}=fe({queryKey:["profiles"],queryFn:()=>Q("/api/profiles/status"),enabled:!!t?.owner}),c=ee(),[p,d]=r(null),[y,S]=r(""),[h,o]=r(""),[a,g]=r(""),[v,m]=r(""),[x,l]=r(""),[f,T]=r(!1),[I,G]=r(null),[P,w]=r(null),[L,A]=r(""),M=async i=>{T(!0),l("");try{await Q("/api/profiles/update",{method:"POST",body:JSON.stringify(i)}),await c.invalidateQueries({queryKey:Z.queryKey}),S(""),o(""),l("Profile saved")}catch(R){l(R.message)}finally{T(!1)}};return t?e("section",{className:_.sectionCard,children:[e("h3",{children:"Your profile"}),e("p",{children:"Keep using this profile, rename it, or add another person with their own library and connections."}),e("div",{className:U.avatarRow,children:[e(Ce,{image:t.image,name:t.name}),e("label",{className:U.uploadButton,children:[e(j,{name:"upload"}),e("span",{children:"Upload image"}),e("input",{className:U.fileInput,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",disabled:f,onChange:async i=>{const R=i.currentTarget.files?.[0];if(i.currentTarget.value="",!R)return;if(R.size>2*1024*1024){l("Image must be smaller than 2 MB");return}const D=new FileReader;D.onerror=()=>l("Could not read image"),D.onload=()=>{M({avatar:D.result})},D.readAsDataURL(R)}})]}),t.avatar&&e(C,{variant:"secondary",disabled:f,onClick:()=>M({avatar:null}),children:"Clear uploaded image"})]}),e("p",{children:"Your uploaded image takes priority, followed by your active cloud account image, then the default user icon."}),e("form",{className:U.form,onSubmit:i=>{i.preventDefault(),M({name:p??t.name})},children:[e("label",{className:U.field,children:["Profile name",e("input",{value:p??t.name,maxLength:60,required:!0,onChange:i=>d(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save name"})]}),e("form",{className:U.form,onSubmit:i=>{i.preventDefault(),M({password:y,currentPassword:h})},children:[t.protected&&e("label",{className:U.field,children:["Current password",e("input",{type:"password",autoComplete:"current-password",value:h,required:!0,maxLength:256,onChange:i=>o(i.currentTarget.value)})]}),e("label",{className:U.field,children:[t.protected?"New password (empty removes protection)":"Protect this profile",e("input",{type:"password",autoComplete:"new-password",value:y,minLength:8,maxLength:256,onChange:i=>S(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save password"})]}),e(C,{variant:"secondary",disabled:f,onClick:async()=>{T(!0);try{await Q("/api/profiles/logout",{method:"POST"}),Ee()}catch(i){l(i.message),T(!1)}},children:"Switch profile / sign out"}),t.owner&&e("form",{className:U.form,onSubmit:async i=>{i.preventDefault(),T(!0),l("");try{await Q("/api/profiles/create",{method:"POST",body:JSON.stringify({name:a,password:v})}),g(""),m(""),await c.invalidateQueries({queryKey:["profiles"]}),l("Profile created. Sign out to switch to it.")}catch(R){l(R.message)}finally{T(!1)}},children:[e("h3",{children:"Add another profile"}),e("p",{children:"Protect your owner profile first. New profiles start empty and do not inherit your accounts. A profile without a password is accessible to anyone who passes the LAN lock."}),e("label",{className:U.field,children:["Name",e("input",{required:!0,maxLength:60,value:a,onChange:i=>g(i.currentTarget.value)})]}),e("label",{className:U.field,children:["Password (optional)",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,value:v,onChange:i=>m(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f||!t.protected,children:"Create profile"})]}),t.owner&&s?.profiles.some(i=>!i.owner)&&e(le,{children:[e("h3",{children:"Other profiles"}),e("ul",{className:U.profileList,children:s.profiles.filter(i=>!i.owner).map(i=>e("li",{children:[e("span",{className:U.smallAvatar,children:e(Ce,{image:i.avatar??i.cloudAvatar,name:i.name})}),e("span",{className:U.profileName,children:i.name}),e(C,{variant:"secondary",size:"sm",disabled:f,onClick:()=>{l(""),A(""),w(i)},children:"Reset password"}),e(C,{variant:"danger",size:"sm",disabled:f,onClick:()=>{l(""),G(i)},children:"Delete"})]},i.id))})]}),e(K,{isOpen:!!P,onClose:f?void 0:()=>w(null),title:"Reset password",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>w(null),children:"Cancel"}),e(C,{loading:f,onClick:async()=>{if(P){T(!0),l("");try{await Q("/api/profiles/reset-password",{method:"POST",body:JSON.stringify({id:P.id,password:L})}),await c.invalidateQueries({queryKey:["profiles"]}),w(null),A(""),l("Password updated. The profile has been signed out.")}catch(i){l(i.message)}finally{T(!1)}}},children:"Save password"})]}),children:[e("p",{children:["Set a new password for ",e("strong",{children:P?.name}),". They will be signed out and must use the new password next time."]}),e("label",{className:U.field,children:["New password",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,placeholder:"Leave empty to remove their password",value:L,onChange:i=>A(i.currentTarget.value)})]})]}),e(K,{isOpen:!!I,onClose:f?void 0:()=>G(null),title:"Delete profile?",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>G(null),children:"Cancel"}),e(C,{variant:"danger",loading:f,onClick:async()=>{if(I){T(!0);try{await Q("/api/profiles/delete",{method:"POST",body:JSON.stringify({id:I.id,confirm:!0})}),await c.invalidateQueries({queryKey:["profiles"]}),G(null),l("Profile deleted. Local files will be removed when Dango restarts.")}catch(i){l(i.message),G(null)}finally{T(!1)}}},children:"Delete profile"})]}),children:[e("p",{children:["Delete ",e("strong",{children:I?.name}),"? This signs them out immediately. Their local libraries, settings and connections will be removed when Dango next restarts."]}),e("p",{children:"Cloud backups and tracker lists will stay intact. Export any library you want to keep before deleting."})]}),x&&e("p",{role:"status",children:x})]}):null}const ue={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},he=["name","nativeName","englishName"],ge={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},st=()=>{const{titlePreference:t,setTitlePreference:s,loading:c}=Ke(),p=Te(),[d,y]=r(ge[t]),[S,h]=r(!1),o=X(null);z(()=>{c||y(ge[t])},[t,c]);const a=async()=>{if(S)return;h(!0);const v=(he.indexOf(t)+1)%he.length,m=he[v],x=ge[m];o.current&&(o.current.style.transform="translateX(-100%)",o.current.style.opacity="0"),setTimeout(async()=>{y(x),s(m),o.current&&(o.current.style.transition="none",o.current.style.transform="translateX(100%)",o.current.style.opacity="0",o.current.offsetWidth,o.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",o.current.style.transform="translateX(0)",o.current.style.opacity="1");try{await p.mutateAsync({key:"titlePreference",value:m})}catch(l){console.error("Error saving title preference:",l)}finally{h(!1)}},300)};return c?e("p",{children:"Loading title preference..."}):e("div",{className:ue["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ue["toggle-button"],disabled:S,children:e("span",{ref:o,className:ue["toggle-label"],children:d})})]})},it="_settingsHeader_gfwoa_1",ot="_pageTitle_gfwoa_6",lt="_pageSubtitle_gfwoa_14",ct="_settingsLayout_gfwoa_20",dt="_sidebar_gfwoa_27",ut="_sidebarIndicator_gfwoa_35",ht="_sidebarItem_gfwoa_50",gt="_active_gfwoa_72",mt="_mainContent_gfwoa_80",pt="_tabContent_gfwoa_85",ft="_settingItem_gfwoa_103",yt="_shortcutContainer_gfwoa_108",vt="_shortcutGroup_gfwoa_115",wt="_shortcutGroupTitle_gfwoa_121",bt="_shortcutGrid_gfwoa_130",Ct="_shortcutCard_gfwoa_136",kt="_controls_gfwoa_170",St="_status_gfwoa_176",u={settingsHeader:it,pageTitle:ot,pageSubtitle:lt,settingsLayout:ct,sidebar:dt,sidebarIndicator:ut,sidebarItem:ht,active:gt,mainContent:mt,tabContent:pt,settingItem:ft,shortcutContainer:yt,shortcutGroup:vt,shortcutGroupTitle:wt,shortcutGrid:bt,shortcutCard:Ct,controls:kt,status:St},Nt="_title_tm30b_11",_t="_signIn_tm30b_18",Tt="_userInfo_tm30b_25",Pt="_warning_tm30b_47",It="_formGroup_tm30b_54",Lt="_label_tm30b_58",xt="_inputWrapper_tm30b_68",Rt="_input_tm30b_68",Dt="_select_tm30b_92",Ot="_actions_tm30b_109",At="_hr_tm30b_117",b={title:Nt,signIn:_t,userInfo:Tt,warning:Pt,formGroup:It,label:Lt,inputWrapper:xt,input:Rt,select:Dt,actions:Ot,hr:At},Mt=()=>{const t=ee(),[s,c]=r(!0),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(null),[a,g]=r({status:"idle"}),[v,m]=r(!1),[x,l]=r(""),[f,T]=r(!1),I=X(null),[G,P]=r({show:!1,message:"",type:"info"}),w=()=>{I.current&&(window.clearInterval(I.current),I.current=null)},L=pe(N=>{S(N.authenticated),o(N.user||N.device.user||null),g(N.device),m(!!N.hasCustomClientId)},[]),A=pe(async()=>{const N=await k.auth.githubStatus.query();L(N)},[L]),M=async()=>{try{const N=await k.auth.githubPoll.query();g(N),N.status==="success"?(w(),await t.invalidateQueries({queryKey:Z.queryKey}),await A(),P({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):N.status==="error"&&(w(),P({show:!0,message:N.error||"GitHub authentication failed.",type:"error"}))}catch{w(),P({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},i=(N=5)=>{w(),I.current=window.setInterval(M,Math.max(N,5)*1e3)};z(()=>(A().catch(()=>{P({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>c(!1)),w),[A]);const R=async()=>{d(!0);try{const N=await k.auth.githubStart.mutate();g(N),i(N.verification?.interval)}catch(N){P({show:!0,message:N instanceof Error?N.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},D=async()=>{try{await k.auth.githubLogout.mutate(),await t.invalidateQueries({queryKey:Z.queryKey}),S(!1),o(null),g({status:"idle"}),P({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{P({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},W=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:x}),l(""),await A(),P({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{P({show:!0,message:"Failed to save override.",type:"error"})}finally{T(!1)}},te=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:""}),l(""),await A(),P({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{P({show:!0,message:"Failed to clear override.",type:"error"})}finally{T(!1)}};return s?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"GitHub Cloud Sync"}),e("p",{className:b.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),y&&h?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:h.name||h.login})]}),e(C,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:b.signIn,children:e(C,{onClick:R,disabled:p||a.status==="pending",children:p||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(le,{children:[e("hr",{className:b.hr}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Verification URL"}),e("div",{className:b.inputWrapper,children:[e("input",{className:b.input,value:a.verification.verification_uri,readOnly:!0}),e(C,{onClick:()=>{const N=a.verification?.verification_uri;N&&/^https?:\/\//i.test(N)&&window.open(N,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Device Code"}),e("input",{className:b.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:b.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",v?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:x,onChange:N=>l(N.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:b.actions,children:[e(C,{onClick:W,disabled:f,children:"Save override"}),e(C,{variant:"secondary",onClick:te,disabled:f,children:"Use dango defaults"})]})]}),e(K,{isOpen:G.show,onClose:()=>P(N=>({...N,show:!1})),width:"sm",children:[e(K.Body,{children:e("p",{children:G.message})}),e(K.Actions,{children:e(C,{onClick:()=>P(N=>({...N,show:!1})),children:"OK"})})]})]})},Gt=()=>{const[t,s]=r(!0),[c,p]=r(null),[d,y]=r(!1),[S,h]=r(!1),[o,a]=r(""),[g,v]=r(""),[m,x]=r(""),[l,f]=r(!1),[T,I]=r({show:!1,message:"",type:"info"}),G=async()=>{try{const R=await k.auth.user.query();p(R?.email?R:null)}catch{p(null)}},P=async()=>{try{const[i,R]=await Promise.all([k.auth.configStatus.query(),k.auth.googleAuth.query()]);y(!!i.hasConfig),h(!!(R.hasCustomWorkerUrl||R.hasCustomClientId||R.hasClientSecret))}catch(i){console.error("Failed to fetch config status",i)}};z(()=>{(async()=>{s(!0),await Promise.all([G(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await G(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const R=D=>{D.origin===window.location.origin&&typeof D.data=="object"&&D.data!==null&&D.data.type==="GOOGLE_AUTH_SUCCESS"&&(p(D.data.user),window.location.reload())};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[]);const w=async()=>{try{const i=await k.auth.googleLogin.mutate();if(i.authenticated){window.location.reload();return}if(i.url){if(typeof window.DangoBridge<"u"){window.location.href=i.url;return}const D=600,W=700,te=window.innerWidth/2-D/2,N=window.innerHeight/2-W/2;window.open(i.url,"GoogleAuth",`width=${D},height=${W},top=${N},left=${te}`)}else throw new Error("Auth URL not available")}catch{I({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},L=async()=>{try{await k.auth.logout.mutate(),p(null),I({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(i){console.error("Sign out failed",i),I({show:!0,message:"Failed to sign out.",type:"error"})}},A=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:o,clientId:g,clientSecret:m}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{I({show:!0,message:"Failed to save override.",type:"error"})}finally{f(!1)}},M=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{I({show:!0,message:"Failed to clear override.",type:"error"})}finally{f(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Google Drive Sync"}),c?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:c.name})," (",c.email,")"]}),e(C,{variant:"danger",onClick:L,children:"Sign Out"})]}):e("div",{className:b.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(C,{onClick:w,disabled:!d,children:"Sign in with Google"}),!d&&e("p",{className:b.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",S?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Worker URL (optional)"}),e("input",{className:b.input,value:o,onChange:i=>a(i.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:g,onChange:i=>v(i.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:b.input,value:m,onChange:i=>x(i.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:b.actions,children:[e(C,{onClick:A,disabled:l,children:"Save override"}),e(C,{variant:"secondary",onClick:M,disabled:l,children:"Use dango defaults"})]})]}),e(K,{isOpen:T.show,onClose:()=>I(i=>({...i,show:!1})),width:"sm",children:[e(K.Body,{children:e("p",{children:T.message})}),e(K.Actions,{children:e(C,{onClick:()=>I(i=>({...i,show:!1})),children:"OK"})})]})]})},qt="_settingItem_3qq0n_1",zt="_modalOverlay_3qq0n_6",Ut="_modal_3qq0n_6",Et="_modalActions_3qq0n_41",Kt="_modalSecondary_3qq0n_47",Ft="_modalPrimary_3qq0n_57",B={settingItem:qt,modalOverlay:zt,modal:Ut,modalActions:Et,modalSecondary:Kt,modalPrimary:Ft},$t={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},Wt=(t,s)=>{if(t==null)return s;const c=String(t);return c==="true"||c==="1"?!0:c==="false"||c==="0"?!1:s},Ne=(t,s,c)=>{const[p,d]=r(s),[y,S]=r(!1),h=ee();return z(()=>{(async()=>{try{const g=await k.settings.getByKey.query({key:t});d(Wt(g.value,s))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,s]),{value:p,setValue:d,isUpdating:y,toggle:async()=>{if(y)return;S(!0);const a=!p;d(a);try{await k.settings.set.mutate({key:t,value:a});for(const g of c)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),d(!a)}finally{S(!1)}}}},Ht=()=>{const{contentType:t}=Fe(),s=$t[t],[c,p]=r(!1),[d,y]=r(!0),[S,h]=r(!1),o=Ne(s.ignoreKey,!0,s.invalidateKeys),a=Ne(s.listOnlyKey,!1,s.invalidateKeys),[g,v]=r(null),[m,x]=r(!1),l=ee(),f=$e();z(()=>{y(!0),(async()=>{try{const L=await k.settings.getByKey.query({key:s.skipKey});String(L.value)==="true"||String(L.value)==="1"?p(!0):p(!1)}catch(L){console.error("Failed to fetch setting",L)}finally{y(!1)}})()},[s.skipKey]);const T=async()=>{if(S)return;h(!0);const w=!c;p(w);try{await k.settings.set.mutate({key:s.skipKey,value:w})}catch(L){console.error("Error saving setting:",L),p(!w)}finally{h(!1)}},I=async()=>{if(!o.isUpdating){if(o.value)try{let w;if(t==="anime"?w=(await k.continueWatching.adultCount.query()).count:t==="manga"?w=(await k.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await k.asmrProgress.adultCount.query()).count:w=(await k.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){v(w);return}}catch(w){console.error("Failed to fetch adult count",w)}o.toggle()}},G=()=>{v(null),o.toggle()},P=async()=>{if(!m){x(!0);try{let w;t==="anime"?w=(await k.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await k.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await k.asmrProgress.purgeAdult.mutate()).removed:w=(await k.tvProgress.purgeAdult.mutate()).removed,ke.success(s.purgeDoneText(w??0));for(const L of s.invalidateKeys)l.invalidateQueries({queryKey:L});t==="anime"&&l.invalidateQueries(f.continueWatching.pathFilter()),t==="manga"&&l.invalidateQueries(f.mangaProgress.pathFilter()),t==="asmr"&&l.invalidateQueries(f.asmrProgress.pathFilter()),t==="tv"&&l.invalidateQueries(f.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),ke.error("Failed to remove adult entries")}finally{x(!1),v(null)}o.toggle()}};return d?e("div",{children:"Loading settings..."}):e("div",{className:_.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(F,{isChecked:c,onChange:T,id:"skip-confirmation-toggle",disabled:S})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(F,{isChecked:o.value,onChange:I,id:"ignore-adult-toggle",disabled:o.isUpdating})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(F,{isChecked:a.value,onChange:a.toggle,id:"cw-watchlist-only-toggle",disabled:a.isUpdating})]})}),g!==null&&e("div",{className:B.modalOverlay,onClick:()=>v(null),children:e("div",{className:B.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",s.listNoun," ",g===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:B.modalActions,children:[e("button",{type:"button",className:B.modalSecondary,onClick:G,disabled:m,children:"Show them"}),e("button",{type:"button",className:B.modalPrimary,onClick:P,disabled:m,children:m?"Purging...":`Purge ${g}`})]})]})})]})},Bt="_statsGrid_o4nf0_1",jt="_statCard_o4nf0_8",Qt="_statLabel_o4nf0_18",Vt="_statValue_o4nf0_26",Yt="_statMeta_o4nf0_32",Jt="_statusBanner_o4nf0_38",Xt="_statusSuccess_o4nf0_49",Zt="_statusUpdating_o4nf0_55",ea="_statusError_o4nf0_61",ta="_sha_o4nf0_67",aa="_settingItem_o4nf0_74",na="_settingTitle_o4nf0_79",ra="_settingSubtitle_o4nf0_85",sa="_actionsRow_o4nf0_92",O={statsGrid:Bt,statCard:jt,statLabel:Qt,statValue:Vt,statMeta:Yt,statusBanner:Jt,statusSuccess:Xt,statusUpdating:Zt,statusError:ea,sha:ta,settingItem:aa,settingTitle:na,settingSubtitle:ra,actionsRow:sa},ia=()=>{const[t,s]=r(null),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r(!1),o=X(null),a=async()=>{try{const l=await k.settings.offlineDbInfo.query();return s(l),l}catch(l){console.error("Failed to fetch offline DB info:",l)}finally{p(!1)}return null};z(()=>(a(),()=>{o.current&&window.clearInterval(o.current)}),[]),z(()=>{t?.isRefreshing?o.current||(o.current=window.setInterval(async()=>{const l=await a();l&&!l.isRefreshing&&o.current&&(window.clearInterval(o.current),o.current=null)},2e3)):o.current&&(window.clearInterval(o.current),o.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||d)return;const l=!t.autoUpdateEnabled;y(!0),s({...t,autoUpdateEnabled:l});try{await k.settings.setOfflineDbAutoUpdate.mutate({enabled:l})}catch(f){console.error("Failed to update auto update setting:",f),s({...t,autoUpdateEnabled:!l})}finally{y(!1)}},v=async()=>{if(!(t?.isRefreshing||S)){h(!0);try{await k.settings.triggerOfflineDbUpdate.mutate(),s(l=>l?{...l,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(l){console.error("Failed to trigger offline DB update:",l)}finally{h(!1)}}},m=l=>{if(!l)return"Never";try{return new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return l}},x=t?.isRefreshing||S;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:O.statsGrid,children:[e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"MAL Mapped"}),e("span",{className:O.statValue,children:c?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Release"}),e("span",{className:O.statMeta,children:c?"-":t?.releaseTag??"Never"})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Checked"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastCheckedAt??null)})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Updated"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${O.statusBanner} ${t.lastStatus==="failed"?O.statusError:t.lastStatus==="updating"?O.statusUpdating:O.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:O.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:O.settingItem,children:e("div",{className:_.settingRow,children:[e("div",{children:[e("span",{className:O.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:O.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(F,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:c||d})]})}),e("div",{className:O.actionsRow,children:e(C,{onClick:v,disabled:c||x,children:x?"Updating Database...":"Update Offline Database Now"})})]})},oa="_status_1wbo0_1",la="_warningText_1wbo0_7",ca="_ackLabel_1wbo0_11",me={status:oa,warningText:la,ackLabel:ca},da=()=>{const t=ee(),[s,c]=r(!1),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(""),a=()=>{d(!1),o(""),c(!0)},g=()=>{y||(c(!1),d(!1))},v=async()=>{if(!(!p||y)){S(!0),o("");try{const m=await J("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),x=await m.json();if(!m.ok)throw new Error(x.error||"Failed to clear database");const l=x.deleted,f=x.deletedManga,T=x.deletedTv,I=x.deletedAsmr,G=Object.values(l).reduce((A,M)=>A+(M||0),0)+Object.values(f??{}).reduce((A,M)=>A+(M||0),0)+Object.values(T??{}).reduce((A,M)=>A+(M||0),0)+Object.values(I??{}).reduce((A,M)=>A+(M||0),0),P=(f?.manga_library??0)+(f?.manga_progress??0),w=(T?.tv_library??0)+(T?.tv_progress??0),L=(I?.asmr_library??0)+(I?.asmr_progress??0);o(`Library cleared - ${l.watchlist??0} watchlist entries, ${P} manga rows, ${w} TV rows, ${L} ASMR rows and ${G} total rows removed.`),t.invalidateQueries({queryKey:[H.watchlist]}),t.invalidateQueries({queryKey:[H.continueWatching]}),t.invalidateQueries({queryKey:[H.mangaLibrary]}),t.invalidateQueries({queryKey:[H.mangaContinueReading]}),t.invalidateQueries({queryKey:[H.tvLibrary]}),t.invalidateQueries({queryKey:[H.tvContinueWatching]}),t.invalidateQueries({queryKey:[H.asmrLibrary]}),t.invalidateQueries({queryKey:[H.asmrContinueListening]}),c(!1)}catch(m){o(m.message)}finally{S(!1),d(!1)}}};return e("div",{className:`${_.sectionCard} ${_.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(C,{variant:"danger",onClick:a,children:"Clear Library Data"}),h&&e("p",{className:me.status,children:h}),e(K,{isOpen:s,onClose:g,title:"Clear library data?",width:"sm",children:[e(K.Body,{children:[e("p",{className:me.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:me.ackLabel,children:[e("input",{type:"checkbox",checked:p,onChange:m=>d(m.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(K.Actions,{children:[e(C,{variant:"secondary",onClick:g,disabled:y,children:"Cancel"}),e(C,{variant:"danger",onClick:v,disabled:!p||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},ua=()=>{const[t,s]=r(""),[c,p]=r([]),[d,y]=r(null),[S,h]=r(!0),[o,a]=r({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const m=await k.auth.rcloneSettings.query();s(m.remote||""),p(m.availableRemotes||[]),y(m.activeRemote||null)}catch(m){console.error("Failed to fetch Rclone settings",m)}finally{h(!1)}};z(()=>{g()},[]);const v=async()=>{try{await k.auth.saveRclone.mutate({remote:t}),a({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g()}catch{a({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return S?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Rclone Cloud Sync"}),e("p",{className:b.signIn,children:"Configure which Rclone remote to use for database synchronization."}),d?e("div",{className:b.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:d})]})}):e("p",{className:b.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Remote Name"}),e("div",{className:b.inputWrapper,children:e("select",{className:b.select,value:t,onChange:m=>s(m.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),c.map(m=>e("option",{value:m,children:m},m)),t&&!c.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:b.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:b.actions,children:e(C,{onClick:v,children:"Save Rclone Settings"})}),e(K,{isOpen:o.show,onClose:()=>a(m=>({...m,show:!1})),width:"sm",children:[e(K.Body,{children:e("p",{children:o.message})}),e(K.Actions,{children:e(C,{onClick:()=>a(m=>({...m,show:!1})),children:"OK"})})]})]})},ha=()=>{const t=ee(),[s,c]=r(null),[p,d]=r(!0),y=async()=>{try{const a=await k.auth.syncSettings.query();c(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};z(()=>{y()},[]);const S=async a=>{const g=a.currentTarget.value;try{const v=await k.auth.saveSyncProvider.mutate({provider:g});c(m=>m?{...m,activeProvider:v.activeProvider}:null),await y(),await t.invalidateQueries({queryKey:Z.queryKey}),Se.success(`Sync provider updated to ${g==="default"?"Default Order":g}`)}catch{Se.error("Failed to update sync provider")}};if(p||!s)return null;const h=[{value:"default",label:"Default (Priority Based)"}];s.authenticatedProviders.github&&h.push({value:"github",label:"GitHub"}),s.authenticatedProviders.google&&h.push({value:"google",label:"Google Drive"}),s.authenticatedProviders.rclone&&h.push({value:"rclone",label:"Rclone"}),h.push({value:"none",label:"None (Local Only)"});const o=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:o(s.actualActiveProvider)})]}),e("div",{className:_.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:s.activeProvider,onChange:S,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:h.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ga(){return"javascript:"+encodeURIComponent(`(function(){
2
2
  if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
3
  var t=null;
4
4
  try{
@@ -1 +1 @@
1
- import{u as o,g as r}from"./vendor-core-DfaOB3Rn.js";import{u as l}from"./index-hrS3r0UE.js";const a="_skeletonCard_qtypb_1",i="_poster_qtypb_11",d="_line_qtypb_20",c="_info_qtypb_38",_="_short_qtypb_54",m="_lowEnd_qtypb_69",e={skeletonCard:a,poster:i,line:d,"skeleton-wave":"_skeleton-wave_qtypb_1",info:c,short:_,lowEnd:m},p=({layout:n="vertical"})=>{const{lowEndMode:t}=l();return o("div",{className:`${e.skeletonCard} ${e[n]} ${t?e.lowEnd:""}`,children:[o("div",{className:e.poster}),o("div",{className:e.info,children:[o("div",{className:e.line}),o("div",{className:`${e.line} ${e.short}`})]})]})},v=({count:n=14,layout:t="vertical"})=>o("div",{className:"grid-container",children:Array.from({length:n}).map((k,s)=>o(p,{layout:t},s))}),w=r.memo(v);export{p as A,w as S};
1
+ import{u as o,g as r}from"./vendor-core-DfaOB3Rn.js";import{u as l}from"./index-BOJFs4B4.js";const a="_skeletonCard_qtypb_1",i="_poster_qtypb_11",d="_line_qtypb_20",c="_info_qtypb_38",_="_short_qtypb_54",m="_lowEnd_qtypb_69",e={skeletonCard:a,poster:i,line:d,"skeleton-wave":"_skeleton-wave_qtypb_1",info:c,short:_,lowEnd:m},p=({layout:n="vertical"})=>{const{lowEndMode:t}=l();return o("div",{className:`${e.skeletonCard} ${e[n]} ${t?e.lowEnd:""}`,children:[o("div",{className:e.poster}),o("div",{className:e.info,children:[o("div",{className:e.line}),o("div",{className:`${e.line} ${e.short}`})]})]})},v=({count:n=14,layout:t="vertical"})=>o("div",{className:"grid-container",children:Array.from({length:n}).map((k,s)=>o(p,{layout:t},s))}),w=r.memo(v);export{p as A,w as S};