@serifpersia/dango 3.7.4 → 3.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/client/dist/assets/{AnimeCard-CBxkRKU-.js → AnimeCard-BxhPLWBG.js} +1 -1
- package/client/dist/assets/{AnimeInfo-D3LmqzJo.js → AnimeInfo-DcpKPBLS.js} +1 -1
- package/client/dist/assets/{AnimeInfoPage-CeJHVkQ0.js → AnimeInfoPage-jKNSPHbX.js} +2 -2
- package/client/dist/assets/{Asmr-CrHIKmJ4.js → Asmr-DlKBykO-.js} +1 -1
- package/client/dist/assets/{AsmrResetProgressModal-C13uw5lH.js → AsmrResetProgressModal-DPHPLqPo.js} +1 -1
- package/client/dist/assets/{Home-CC9XyO9O.js → Home-D7-FNOmo.js} +1 -1
- package/client/dist/assets/{Insights-BZGAhYrz.js → Insights-C9HufjGJ.js} +1 -1
- package/client/dist/assets/{LibraryListPage-DosBFeR_.js → LibraryListPage-BT_xDjEq.js} +1 -1
- package/client/dist/assets/{ListeningList-nq279J8O.js → ListeningList-DL1rdCRi.js} +1 -1
- package/client/dist/assets/{Manga-DiCcXa9I.js → Manga-BfFRq7eK.js} +1 -1
- package/client/dist/assets/{MangaInfoPage-sZn0qDxf.js → MangaInfoPage-wBJjn2FL.js} +1 -1
- package/client/dist/assets/{MangaReadPage-ChgW4VO8.js → MangaReadPage-BAgsRqxt.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-BkNHdClw.js → MangaResetProgressModal-Br5zqZ-U.js} +1 -1
- package/client/dist/assets/{Mature-D7bJH6LQ.js → Mature-MO7ZwJVT.js} +1 -1
- package/client/dist/assets/{MatureConsentModal-B3u3RgAE.js → MatureConsentModal-Beq4JL0b.js} +1 -1
- package/client/dist/assets/{MediaCard-B1llLoho.js → MediaCard-lz7FdOe_.js} +1 -1
- package/client/dist/assets/{OptionListMenu-1QikgQ8d.js → OptionListMenu-BSUcso28.js} +1 -1
- package/client/dist/assets/Player-CnLC-x2S.js +56 -0
- package/client/dist/assets/{PlayerSettings-CWc5Tf-B.js → PlayerSettings-kqYmlLDl.js} +1 -1
- package/client/dist/assets/{QueueOptionsButton-Cpm6Jovo.js → QueueOptionsButton-B8xuoYlH.js} +1 -1
- package/client/dist/assets/{QueueRail-DpUQ2Ba2.js → QueueRail-D1FmM-GR.js} +1 -1
- package/client/dist/assets/{ReadingList-DMxkudSM.js → ReadingList-D8ZiOnWi.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-6X8ciSFl.js → ResetProgressModal-0PvvM2XJ.js} +1 -1
- package/client/dist/assets/{Search-CbXvziWY.js → Search-D1T-PrGX.js} +1 -1
- package/client/dist/assets/{Settings-BEZZSWsj.js → Settings-DALBQcFc.js} +1 -1
- package/client/dist/assets/{SkeletonGrid-BDR-fKs1.js → SkeletonGrid-pA-dcLBM.js} +1 -1
- package/client/dist/assets/Trackers-CvO6aWVx.css +1 -0
- package/client/dist/assets/Trackers-D68sJf1y.js +2 -0
- package/client/dist/assets/{Tv-DP4rcV9T.js → Tv-DO-WeaMv.js} +1 -1
- package/client/dist/assets/{TvInfo-WNJynk-5.js → TvInfo-CpPIymn8.js} +1 -1
- package/client/dist/assets/{TvPopup-Q9_MFJdx.js → TvPopup-BwGJ1Tjg.js} +1 -1
- package/client/dist/assets/{TvSearch-C-RBZ1iq.js → TvSearch-D9SrfJjK.js} +1 -1
- package/client/dist/assets/{TvWatchlist-BXE6yUS0.js → TvWatchlist-25tpA8ln.js} +1 -1
- package/client/dist/assets/{Watchlist-7x__Rf-s.js → Watchlist-mlZQTcqR.js} +1 -1
- package/client/dist/assets/{hls-DIyfUbGZ.js → hls-qvAoYTJt.js} +1 -1
- package/client/dist/assets/index-DlcgJVM6.js +178 -0
- package/client/dist/assets/{index-B7katXv0.css → index-ZssheiHa.css} +1 -1
- package/client/dist/assets/{libraryInvalidation-BFqNv8Cx.js → libraryInvalidation-DdnIPcOQ.js} +1 -1
- package/client/dist/assets/{useAnimeInfoData-D_qedrui.js → useAnimeInfoData-tcGkDs2b.js} +1 -1
- package/client/dist/assets/{useAsmr-CrshwDPO.js → useAsmr-B-FYJW2L.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-HwNC-ZRo.js → useAsmrPopup-Ct9jC6X6.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-BPSi9vcc.js → useMangaLibrary-BacTdrw2.js} +1 -1
- package/client/dist/assets/{useMangaPopup-DdueqAi5.js → useMangaPopup-B_wRaMyP.js} +1 -1
- package/client/dist/assets/{usePlaybackEnd-DjZq1szR.js → usePlaybackEnd-DuEfjKb8.js} +1 -1
- package/client/dist/assets/{useProviders-_ilIsyde.js → useProviders-D0XOHCsj.js} +1 -1
- package/client/dist/assets/{useTv-C558DPdT.js → useTv-IidbSQU4.js} +1 -1
- package/client/dist/assets/{useTvLibrary-CNQcDI7O.js → useTvLibrary-DiCSdUOj.js} +1 -1
- package/client/dist/index.html +2 -2
- package/package.json +2 -2
- package/server/dist/server.js +251 -246
- package/server/dist/shipped-defaults.js +1 -1
- package/server/package.json +1 -1
- package/client/dist/assets/Player-hVrgi0J1.js +0 -56
- package/client/dist/assets/Trackers-D5XBOCDp.css +0 -1
- package/client/dist/assets/Trackers-DO0mA01O.js +0 -2
- package/client/dist/assets/index-D0DdVatn.js +0 -178
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-kqYmlLDl.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-BSUcso28.js","assets/usePlaybackEnd-DuEfjKb8.js","assets/index-DlcgJVM6.js","assets/vendor-query-BBT5_sHx.js","assets/index-ZssheiHa.css","assets/playbackCompletion-IPHm9fp5.js","assets/usePlaybackEnd-DLFOYx3Q.css","assets/PlayerSettings-BXGe3F5k.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as t,g as dt,h as V,P as zt,z as jt,d as ie,A as N,q as Q,y as Ht,T as Me,o as Yt,a as Xt,c as Jt,_ as Zt,S as ct}from"./vendor-core-DfaOB3Rn.js";import{u as Rt,b as Tt,a as yt}from"./vendor-query-BBT5_sHx.js";import{S as er,U as tr,p as St,s as rr,C as nr,a as or,b as sr,c as Ie,d as Ct,f as Nt,e as ar,g as ir,h as lr,r as cr,u as ur,i as dr,j as mr,k as fr,l as hr,m as pr,n as vr,o as be,A as gr,q as yr,R as br,E as Sr,t as Er,v as C,w as wr,x as kr,P as Tr,y as Cr}from"./usePlaybackEnd-DuEfjKb8.js";import{I as Y}from"./vendor-icons-DrybRNxP.js";import{_ as Pt,S as Ye,i as Mr,q as ae,t as me,A as we,O as Rr,P as Ve,M as mt,e as Nr,m as Pr,n as Ar,o as _r,p as xr,d as Br,u as Lr,B as ut,Q as Dr,f as $r}from"./index-DlcgJVM6.js";import{l as Ir,i as Fr,s as Or}from"./playbackCompletion-IPHm9fp5.js";import{M as Wr}from"./MatureConsentModal-Beq4JL0b.js";import{u as Ur}from"./useIsMobile-Dvx1uJ82.js";import{s as Ee,Q as Vr}from"./QueueRail-D1FmM-GR.js";import{u as Qr,Q as Gr}from"./QueueOptionsButton-B8xuoYlH.js";import{u as At}from"./useProviders-D0XOHCsj.js";import{l as qr}from"./hls-qvAoYTJt.js";import{A as Kr}from"./AnimeMetaDetails-D8WIiO4b.js";import{S as zr}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const jr="_controlsOverlay_cejny_1",Hr="_hidden_cejny_21",Yr="_topControls_cejny_27",Xr="_backBtn_cejny_47",Jr="_videoTitleInfo_cejny_67",Zr="_animeTitle_cejny_73",en="_episodeNumber_cejny_83",tn="_bottomControls_cejny_91",rn="_progressBarContainer_cejny_110",nn="_progressBar_cejny_110",on="_thumb_cejny_129",sn="_scrubbing_cejny_144",an="_watchedBar_cejny_148",ln="_bufferedBar_cejny_149",cn="_timeBubble_cejny_187",un="_skipSegment_cejny_221",dn="_bottomControlsRow_cejny_231",mn="_leftControls_cejny_239",fn="_rightControls_cejny_240",hn="_controlBtn_cejny_247",pn="_theaterBtn_cejny_288",vn="_nextEpisodeBtn_cejny_292",gn="_active_cejny_313",yn="_timeDisplay_cejny_317",bn="_skipControls_cejny_325",D={controlsOverlay:jr,hidden:Hr,topControls:Yr,backBtn:Xr,videoTitleInfo:Jr,animeTitle:Zr,episodeNumber:en,bottomControls:tn,progressBarContainer:rn,progressBar:nn,thumb:on,scrubbing:sn,watchedBar:an,bufferedBar:ln,timeBubble:cn,skipSegment:un,bottomControlsRow:dn,leftControls:mn,rightControls:fn,controlBtn:hn,theaterBtn:pn,nextEpisodeBtn:vn,active:gn,timeDisplay:yn,skipControls:bn},Sn=({player:r,handlers:n,visible:a,skipIntervals:u,showNextEpisodeButton:l,onNextEpisode:i,isTheaterMode:s,onTheaterModeToggle:d,settingsBtnRef:c,timeDisplayRef:g})=>{const{state:b,refs:e,actions:o}=r,{showSettings:R}=b,p=()=>b.isMuted||b.volume===0?t(Y,{name:"volume-mute"}):b.volume<.5?t(Y,{name:"volume-down"}):t(Y,{name:"volume-up"});return t("div",{className:`${D.controlsOverlay} ${a?"":D.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:D.bottomControls,"data-speed-boost-ignore":"true",onClick:w=>w.stopPropagation(),children:[t(er,{classes:{container:D.progressBarContainer,scrubbing:D.scrubbing,timeBubble:D.timeBubble,bar:D.progressBar,buffered:D.bufferedBar,watched:D.watchedBar,thumb:D.thumb},videoRef:e.videoRef,duration:b.duration,formatTime:o.formatTime,isScrubbing:b.isScrubbing,onSeek:n.handleSeek,onScrubStart:n.handleScrubStart,onScrubMove:n.handleScrubMove,onScrubEnd:n.handleScrubEnd,timeLabelRef:g,children:[b.duration>0&&r.state.currentSkipInterval&&t("div",{className:`${D.skipSegment} ${D[r.state.currentSkipInterval.skip_type]} `,style:{left:`${r.state.currentSkipInterval.start_time/b.duration*100}% `,width:`${(r.state.currentSkipInterval.end_time-r.state.currentSkipInterval.start_time)/b.duration*100}% `}}),u.map(w=>{const P=w.start_time/b.duration*100,k=(w.end_time-w.start_time)/b.duration*100;return t("div",{className:`${D.skipSegment} ${D[w.skip_type]} `,style:{left:`${P}% `,width:`${k}% `},title:w.skip_type.toUpperCase()},w.skip_id)})]}),t("div",{className:D.bottomControlsRow,children:[t("div",{className:D.leftControls,children:[t("button",{className:D.controlBtn,onClick:o.togglePlay,"aria-label":b.isPlaying?"Pause":"Play",children:b.isPlaying?t(Y,{name:"pause"}):t(Y,{name:"play"})}),t(tr,{muted:b.isMuted,volume:b.volume,volumeIcon:p(),buttonClassName:D.controlBtn,onToggleMute:o.toggleMute,onVolumeChange:n.handleVolumeChange,onExpandedChange:w=>o.setShowVolumeSlider(w)}),t("span",{className:D.timeDisplay,ref:g,children:[o.formatTime(0)," / ",o.formatTime(b.duration)]}),b.currentSkipInterval&&!b.isAutoSkipEnabled&&t("button",{className:D.controlBtn,onClick:()=>{e.videoRef.current&&b.currentSkipInterval&&(e.videoRef.current.currentTime=b.currentSkipInterval.end_time,o.setCurrentSkipInterval(null))},children:["Skip ",b.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),t("div",{className:D.rightControls,children:[t("div",{className:D.skipControls,children:l&&t("button",{className:D.nextEpisodeBtn,onClick:i,title:"Play next episode",children:"Next EP"})}),t("button",{className:`${D.controlBtn} ${n.isSubtitleActive?D.active:""}`,onClick:n.handleCCToggle,title:n.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:t(Y,{name:"closed-captioning",size:22})}),t("button",{ref:c,className:`${D.controlBtn} ${R?D.active:""} `,onClick:()=>o.setShowSettings(!R),"aria-label":"Settings",children:t(Y,{name:"cog"})}),t("button",{className:`${D.controlBtn} ${D.theaterBtn} ${s?D.active:""} `,onClick:w=>{w.stopPropagation(),d()},title:s?"Exit Theater Mode":"Theater Mode","aria-label":s?"Exit Theater Mode":"Theater Mode",children:t(Y,{name:"tv"})}),t("button",{className:D.controlBtn,onClick:o.toggleFullscreen,"aria-label":b.isFullscreen?"Exit Fullscreen":"Fullscreen",children:b.isFullscreen?t(Y,{name:"compress"}):t(Y,{name:"expand"})})]})]})]})})};function En(r){const{state:n,refs:a,actions:u}=r,l=o=>{a.videoRef.current&&(a.videoRef.current.volume=o,a.videoRef.current.muted=o===0)},i=o=>{!a.videoRef.current||isNaN(n.duration)||n.duration===0||(a.videoRef.current.currentTime=o*n.duration,u.sendProgressUpdate(!1,!0))},s=()=>{a.videoRef.current&&(u.setIsScrubbing(!0),u.wasPlayingBeforeScrub.current=!a.videoRef.current.paused,a.videoRef.current.pause())},d=o=>{!a.videoRef.current||!n.duration||(a.videoRef.current.currentTime=o*n.duration)},c=()=>{u.setIsScrubbing(!1),u.wasPlayingBeforeScrub.current&&a.videoRef.current?.play()},g=o=>{if(!a.videoRef.current)return;u.setActiveSubtitleTrack(o);try{if(o===null||o==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const p=n.availableSubtitles.find(w=>w.label===o||w.lang===o);p?localStorage.setItem("playerLastSubtitle",rr(p)):localStorage.setItem("playerLastSubtitle",o)}}catch{}let R=!1;Array.from(a.videoRef.current.textTracks).forEach(p=>{const P=o!==null&&o!=="off"&&(p.language===o||p.label===o)&&!R;p.mode=P?"showing":"hidden",P&&(R=!0)})},b=n.activeSubtitleTrack!==null&&n.activeSubtitleTrack!=="off";return{handleVolumeChange:l,handleSeek:i,handleScrubStart:s,handleScrubMove:d,handleScrubEnd:c,handleSubtitleSelection:g,isSubtitleActive:b,handleCCToggle:()=>{if(!a.videoRef.current)return;if(b){g("off");return}if(n.availableSubtitles.length===0)return;let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const R=St(n.availableSubtitles,{lastKey:o,enabled:!0});if(R<0)return;const p=n.availableSubtitles[R];g(p.label||p.lang)}}}const wn=jt(()=>Pt(()=>import("./PlayerSettings-kqYmlLDl.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),kn=({player:r,isAutoplayEnabled:n,onAutoplayChange:a,showNextEpisodeButton:u,onNextEpisode:l,videoSources:i,selectedSource:s,selectedLink:d,onSourceChange:c,loadingVideo:g,skipIntervals:b,animeTitle:e,episodeNumber:o,isTheaterMode:R,onTheaterModeToggle:p,anime4kEnabled:w,onAnime4kToggle:P,anime4kSupported:k,anime4kProfile:B,onAnime4kProfileChange:y,anime4kInitializing:v,anime4kError:_,videoDelayEnabled:f,onVideoDelayToggle:E,videoDelayMs:x,onVideoDelayChange:X,onCalibrateAvSync:$,fallbackChoice:G,onFallbackChoiceChange:I,ambientSettings:L,onAmbientChange:A,children:F,overlays:O,isInteractingExtra:S=!1,className:m,hideChrome:M=!1})=>{const{state:T,actions:q}=r,{showSettings:J}=T,{setShowSettings:H}=q,K=En(r),ee=dt.useRef(null),Se=dt.useRef(null),Ae=dt.useRef(null);V(()=>{const j=ve=>{ee.current&&!ee.current.contains(ve.target)&&Se.current&&!Se.current.contains(ve.target)&&J&&H(!1)};return J&&document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[J,H]);const Re=T.showControls||J||T.isScrubbing,te=t(sr,{visible:Re,title:e,episode:o?`Episode ${o}`:void 0,onBack:()=>window.history.back(),classes:{overlay:D.controlsOverlay,hidden:D.hidden,top:D.topControls,backBtn:D.backBtn,titleInfo:D.videoTitleInfo,title:D.animeTitle,episode:D.episodeNumber}}),z=!g&&!T.isBuffering&&T.duration>0?t(nr,{isPlaying:T.isPlaying,onTogglePlay:q.togglePlay,onSkipBack:()=>q.seek(-10),onSkipForward:()=>q.seek(10)}):null,ke=t(Sn,{player:r,handlers:K,visible:Re,skipIntervals:b,showNextEpisodeButton:u,onNextEpisode:l,isTheaterMode:R,onTheaterModeToggle:p,settingsBtnRef:Se,timeDisplayRef:Ae}),_e=t(zt,{fallback:null,children:t(wn,{ref:ee,isOpen:J,onClose:()=>H(!1),videoSources:i,currentSource:s,currentLink:d,onSourceChange:c,subtitles:T.availableSubtitles,activeSubtitleTrack:T.activeSubtitleTrack,onSubtitleChange:K.handleSubtitleSelection,subtitleSettings:{fontSize:T.subtitleFontSize,position:T.subtitlePosition,bgOpacity:T.subtitleBgOpacity,bgColor:T.subtitleBgColor,textColor:T.subtitleTextColor,edge:T.subtitleEdge,bold:T.subtitleBold},onSubtitleSettingsChange:q.setSubtitleStyle,useNativeControls:T.useNativeControls,onNativeControlsToggle:q.setUseNativeControls,anime4kEnabled:w,onAnime4kToggle:P,anime4kSupported:k,anime4kProfile:B,onAnime4kProfileChange:y,anime4kInitializing:v,anime4kError:_,videoDelayEnabled:f,onVideoDelayToggle:E,videoDelayMs:x,onVideoDelayChange:X,onCalibrateAvSync:$,isAutoSkipEnabled:T.isAutoSkipEnabled,onAutoSkipChange:j=>{q.setIsAutoSkipEnabled(j);try{localStorage.setItem("autoSkipEnabled",j.toString())}catch{}},isAutoplayEnabled:n,onAutoplayChange:a,fallbackChoice:G,onFallbackChoiceChange:I,isTheaterMode:R,ambientSettings:L,onAmbientChange:A})}),re=J?t("div",{"data-speed-boost-ignore":"true",onClick:j=>j.stopPropagation(),children:_e}):null;return t(or,{player:r,topBar:te,centerControls:z,bottomBar:!g&&T.duration>0?ke:null,settingsPanel:re,overlays:O,isInteracting:S,className:m,chromeDisabled:M,children:F})},Tn=({count:r=3})=>t("section",{className:Ee.section,children:[t("div",{className:Ee.header,children:t("button",{className:Ee.headerToggle,disabled:!0,children:[t("span",{className:Ee.title,children:t(Ye,{width:"60px",height:"1.2rem",variant:"text"})}),t(Y,{name:"chevron-down",style:{opacity:.3}})]})}),t("div",{className:Ee.list,children:Array.from({length:r}).map((n,a)=>t("div",{className:Ee.item,style:{pointerEvents:"none"},children:[t("div",{className:Ee.dragHandle,style:{opacity:.2},children:t(Ye,{width:"16px",height:"16px",variant:"rectangular"})}),t("div",{className:Ee.thumbnail,style:{overflow:"hidden",background:"transparent"},children:t(Ye,{width:"100%",height:"100%",variant:"rectangular"})}),t("div",{className:Ee.meta,children:[t(Ye,{width:"80%",height:"1.2rem",variant:"text",className:Ee.metaGap}),t(Ye,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},a))})]}),Cn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Mn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Rn=["direct","cookie","embed"],Nn=({selectedProvider:r,onProviderChange:n,isAdult:a,options:u})=>{const i=(u&&u.length>0?u:[]).filter(s=>s.mature===(a===!0));return t("div",{className:Ie.providerSelectContainer,children:[t("h4",{children:"Provider"}),t("select",{className:Ie.providerSelect,value:r,onChange:s=>n(s.currentTarget.value),children:Rn.map(s=>{const d=i.filter(c=>(c.tier??"direct")===s);return d.length===0?null:t("optgroup",{label:Mn[s],children:d.map(c=>t("option",{value:c.id,children:c.sub?`${c.label} (${Cn[c.sub]})`:c.label},c.id))},s)})})]})},Pn=({videoSources:r,selectedSource:n,selectedLink:a,onSourceChange:u,onLinkChange:l})=>{const i=Array.isArray(r)?r:[];if(i.length===0)return null;const s=n?.type==="iframe"&&(n.links?.length??0)>1;return t("div",{className:Ie.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:Ie.sourceButtons,children:i.map((d,c)=>t("button",{className:`${Ie.sourceButton} ${n?.sourceName===d.sourceName?Ie.active:""} `,onClick:()=>u(d),children:d.sourceName},`${d.sourceName}-${c}`))}),s&&t("select",{className:Ie.sourceSelect,"aria-label":"Fallback embed quality",value:a?.link??n.links[0]?.link??"",onChange:d=>{const c=n.links.find(g=>g.link===d.currentTarget.value);c&&l(c)},children:n.links.map(d=>t("option",{value:d.link,children:d.resolutionStr},d.link))})]})},An=dt.memo(Pn,(r,n)=>r.selectedSource?.sourceName===n.selectedSource?.sourceName&&r.selectedLink?.link===n.selectedLink?.link&&r.videoSources===n.videoSources),_n={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},xn={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Bn=5,Ln=15e3,Dn=`
|
|
3
|
+
@group(0) @binding(0) var extTex: texture_external;
|
|
4
|
+
@group(0) @binding(1) var extSamp: sampler;
|
|
5
|
+
struct VSOut {
|
|
6
|
+
@builtin(position) pos: vec4f,
|
|
7
|
+
@location(0) uv: vec2f,
|
|
8
|
+
};
|
|
9
|
+
@vertex
|
|
10
|
+
fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
|
|
11
|
+
var positions = array<vec2f, 6>(
|
|
12
|
+
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
13
|
+
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
14
|
+
);
|
|
15
|
+
var uvs = array<vec2f, 6>(
|
|
16
|
+
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
17
|
+
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
18
|
+
);
|
|
19
|
+
var out: VSOut;
|
|
20
|
+
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
21
|
+
out.uv = uvs[idx];
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
@fragment
|
|
25
|
+
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
26
|
+
return textureSampleBaseClampToEdge(extTex, extSamp, uv);
|
|
27
|
+
}
|
|
28
|
+
`;function $n({videoRef:r,canvasRef:n,profile:a="balanced",delayMs:u=0}){const[l,i]=ie(!1),[s,d]=ie(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[c,g]=ie(!1),[b,e]=ie(null),[o,R]=ie(0),p=N(0),w=N(null),P=N(null),k=N(null),B=N(null),y=N(null),v=N(null),_=N(null),f=N(null),E=N(null),x=N(!1),X=N(-1),$=N(0),G=N(u);G.current=u;const I=N([]),L=N(!1),A=N(!1),F=N(!1),O=N(null),S=N(-1),m=N(-1),M=N(!1),T=N(0);V(()=>{async function H(){if(typeof navigator>"u"||!navigator.gpu){i(!1);return}try{const K=await navigator.gpu.requestAdapter();i(!!K)}catch{i(!1)}}H()},[]),V(()=>{if(!s||!l)return;let H=!1;const K=++p.current,ee=z=>{if(z)try{z.close()}catch{}},Se=()=>{for(const z of I.current)ee(z.bitmap);I.current=[]},Ae=z=>Math.max(8,Math.min(40,Math.ceil(z/16.7)+4));function Re(){E.current!==null&&(cancelAnimationFrame(E.current),E.current=null)}async function te(){let z=r.current;const ke=n.current;if(!z||!ke||p.current!==K)return;const _e=performance.now()+Ln;for(;(!z||z.videoWidth===0)&&performance.now()<_e;){if(await new Promise(ce=>requestAnimationFrame(ce)),H||p.current!==K)return;z=r.current}if(!z||z.videoWidth===0){!H&&p.current===K&&(e("Timed out waiting for video metadata"),g(!1),d(!1));return}const re=z.videoWidth,j=z.videoHeight,ve=Math.max(re,j),ft=window.innerWidth,xe=window.innerHeight,Je=Math.max(ft,xe),Ze=ve<Je?Je/ve:1,Qe=_n[a],ht=ve<=480?Qe.sd:ve<=720?Qe.hd:ve<=1080?Qe.fhd:1,le=Math.min(ht,Ze);ke.width=Math.round(re*le),ke.height=Math.round(j*le),g(!0),e(null),$.current=0,X.current=-1,S.current=-1,m.current=-1,M.current=!1,T.current=0,Se(),x.current=!1;try{let ce=function(){H||p.current!==K||(Re(),E.current=requestAnimationFrame(()=>{at()}))};const{ModeA:pt,ModeB:Te,ModeC:et,ModeAA:Ge}=await Pt(async()=>{const{ModeA:U,ModeB:ne,ModeC:he,ModeAA:ue}=await import("./index-BOKlZEHq.js").then(de=>de.i);return{ModeA:U,ModeB:ne,ModeC:he,ModeAA:ue}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const tt=await navigator.gpu.requestAdapter();if(!tt)throw new Error("No GPU adapter found");const W=await tt.requestDevice();if(!W)throw new Error("Failed to get GPU device");const Ne=ke.getContext("webgpu");if(!Ne)throw new Error("Failed to get WebGPU context");const qe=navigator.gpu.getPreferredCanvasFormat();Ne.configure({device:W,format:qe,alphaMode:"premultiplied"});const fe=W.createTexture({size:[re,j],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),rt=xn[a],Fe=Math.round(re*le),Oe=Math.round(j*le),Ke=(()=>{switch(rt){case"ModeB":return new Te({device:W,inputTexture:fe,nativeDimensions:{width:re,height:j},targetDimensions:{width:Fe,height:Oe}});case"ModeC":return new et({device:W,inputTexture:fe,nativeDimensions:{width:re,height:j},targetDimensions:{width:Fe,height:Oe}});case"ModeAA":return new Ge({device:W,inputTexture:fe,nativeDimensions:{width:re,height:j},targetDimensions:{width:Fe,height:Oe}});default:return new pt({device:W,inputTexture:fe,nativeDimensions:{width:re,height:j},targetDimensions:{width:Fe,height:Oe}})}})(),Be=Ke.getOutputTexture(),ze=W.createSampler({magFilter:"linear",minFilter:"linear"}),nt=W.createShaderModule({code:`
|
|
29
|
+
@group(0) @binding(0) var tex: texture_2d<f32>;
|
|
30
|
+
@group(0) @binding(1) var samp: sampler;
|
|
31
|
+
struct VertexOutput {
|
|
32
|
+
@builtin(position) pos: vec4f,
|
|
33
|
+
@location(0) uv: vec2f,
|
|
34
|
+
}
|
|
35
|
+
@vertex
|
|
36
|
+
fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
|
|
37
|
+
var positions = array<vec2f, 6>(
|
|
38
|
+
vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
|
|
39
|
+
vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
|
|
40
|
+
);
|
|
41
|
+
var uvs = array<vec2f, 6>(
|
|
42
|
+
vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
|
|
43
|
+
vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
|
|
44
|
+
);
|
|
45
|
+
var out: VertexOutput;
|
|
46
|
+
out.pos = vec4f(positions[idx], 0.0, 1.0);
|
|
47
|
+
out.uv = uvs[idx];
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
@fragment
|
|
51
|
+
fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
52
|
+
return textureSample(tex, samp, uv);
|
|
53
|
+
}
|
|
54
|
+
`}),Le=W.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),De=W.createRenderPipeline({layout:W.createPipelineLayout({bindGroupLayouts:[Le]}),vertex:{module:nt,entryPoint:"vs"},fragment:{module:nt,entryPoint:"fs",targets:[{format:qe}]},primitive:{topology:"triangle-list"}}),ot=W.createBindGroup({layout:Le,entries:[{binding:0,resource:Be.createView()},{binding:1,resource:ze}]});try{const U=W.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),ne=W.createShaderModule({code:Dn}),he=W.createRenderPipeline({layout:W.createPipelineLayout({bindGroupLayouts:[U]}),vertex:{module:ne,entryPoint:"vs"},fragment:{module:ne,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});O.current={pipeline:he,layout:U,inputView:fe.createView()}}catch{O.current=null}if(p.current!==K){fe.destroy(),W.destroy();return}w.current=W,P.current=Ne,k.current=Ke,B.current=fe,y.current=Be,v.current=De,_.current=ze,f.current=Le,A.current=!1,F.current=!1;async function st(){const U=O.current;if(!U||A.current)return!1;const ne=r.current;if(!ne)return!1;const he=!F.current;he&&W.pushErrorScope("validation");try{const ue=W.importExternalTexture({source:ne}),de=W.createBindGroup({layout:U.layout,entries:[{binding:0,resource:ue},{binding:1,resource:ze}]}),pe=W.createCommandEncoder(),ge=pe.beginRenderPass({colorAttachments:[{view:U.inputView,loadOp:"load",storeOp:"store"}]});ge.setPipeline(U.pipeline),ge.setBindGroup(0,de),ge.draw(6),ge.end(),W.queue.submit([pe.finish()])}catch{return A.current=!0,O.current=null,!1}if(he){const ue=await W.popErrorScope().catch(()=>null);if(ue)return console.warn("[anime4k] blit probe failed:",ue.message),A.current=!0,O.current=null,!1;F.current=!0}return!0}g(!1);async function at(){if(H||p.current!==K||!Ne)return;const U=r.current;if(!U||U.videoWidth===0){ce();return}if(U!==z||U.videoWidth!==re||U.videoHeight!==j){R(de=>de+1);return}if(U.paused||U.ended||document.hidden||U.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){ce();return}const ne=U.getVideoPlaybackQuality().totalVideoFrames;if(ne===m.current){ce();return}if(x.current){ce();return}const he=U.currentTime;(U.seeking||S.current>=0&&Math.abs(he-S.current)>.5)&&(Se(),M.current=!1,T.current=0,m.current=-1),S.current=he;const ue=Math.max(0,G.current||0);ue>T.current&&(M.current=!1),x.current=!0;try{const de=performance.now();let pe=null,ge=!1;if(ue<=0){I.current.length>0&&Se(),M.current=!1,T.current=0;let ye=!1;if(!L.current)try{W.queue.copyExternalImageToTexture({source:U},{texture:fe},[re,j]),m.current=ne,ye=!0}catch(oe){if(oe instanceof TypeError)L.current=!0;else throw oe}if(!ye&&!A.current&&O.current&&await st()&&(m.current=ne,ye=!0),!ye){const oe=await createImageBitmap(U);m.current=ne,W.queue.copyExternalImageToTexture({source:oe},{texture:fe},[re,j]),ee(oe)}}else{const ye=await createImageBitmap(U);m.current=ne;const oe=I.current;oe.push({bitmap:ye,capture:de});const it=Ae(ue);for(;oe.length>it;)ee(oe.shift()?.bitmap);let Ue=-1;for(let se=oe.length-1;se>=0;se--)if(de-oe[se].capture>=ue){Ue=se;break}if(Ue!==-1){for(let He=0;He<Ue;He++)ee(oe.shift()?.bitmap);const se=oe.shift();se?(pe=se.bitmap,M.current=!0,T.current=ue):(pe=ye,ge=!0)}else if(!M.current)pe=ye,ge=!0;else{const se=oe.shift();pe=se?se.bitmap:ye,se||(ge=!0)}if(!pe){x.current=!1,ce();return}W.queue.copyExternalImageToTexture({source:pe},{texture:fe},[re,j]),ge||ee(pe)}const je=W.createCommandEncoder();await Ke.pass(je);const We=je.beginRenderPass({colorAttachments:[{view:Ne.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});We.setPipeline(De),We.setBindGroup(0,ot),We.draw(6),We.end(),W.queue.submit([je.finish()]),X.current=ne,$.current=0,W.queue.onSubmittedWorkDone().then(()=>{p.current===K&&(x.current=!1)})}catch(de){if(x.current=!1,$.current+=1,$.current>=Bn&&!H&&p.current===K){console.error(de),e(de instanceof Error?de.message:"Render error"),d(!1);return}}ce()}ce()}catch(ce){!H&&p.current===K&&(e(ce instanceof Error?ce.message:"Failed to initialize upscaler"),g(!1),d(!1))}}return te(),()=>{H=!0,p.current+=1,Re(),Se(),B.current&&(B.current.destroy(),B.current=null),y.current&&(y.current.destroy(),y.current=null),w.current&&(w.current.destroy(),w.current=null),k.current=null,v.current=null,_.current=null,f.current=null,O.current=null,P.current=null,x.current=!1}},[s,l,r,n,a,o]);const q=Q(H=>{d(H);try{localStorage.setItem("anime4kEnabled",String(H))}catch{}},[]),J=Q(()=>{d(H=>{const K=!H;try{localStorage.setItem("anime4kEnabled",String(K))}catch{}return K})},[]);return{isWebGPUSupported:l,isEnabled:s,isInitializing:c,error:b,toggle:J,setEnabled:q}}function In({videoRef:r,episodeKey:n,isEnabled:a,isSupported:u,mediaReady:l,isIframeSource:i,setEnabled:s}){const d=N(null),c=N(!1),g=N(!1),b=N(s);b.current=s,V(()=>{const e=d.current;d.current=n,!(e===null||e===n)&&(!a||!u||(c.current=!0,g.current=!1,b.current(!1)))},[n,a,u]),V(()=>{if(!c.current)return;if(a){g.current&&(c.current=!1);return}if(g.current=!0,!l)return;if(i){c.current=!1,b.current(!0);return}const e=r.current;if(!e)return;let o,R=!1;const p=()=>{R||(R=!0,c.current=!1,b.current(!0))};if(e.readyState>=2)return o=window.setTimeout(p,500),()=>window.clearTimeout(o);const w=()=>{window.setTimeout(p,500)};return e.addEventListener("canplay",w,{once:!0}),e.addEventListener("playing",w,{once:!0}),o=window.setTimeout(p,5e3),()=>{window.clearTimeout(o),e.removeEventListener("canplay",w),e.removeEventListener("playing",w)}},[a,l,i,r])}const Fn=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",On=/^[a-z0-9-]+$/i,_t=r=>r?"preferredProviderMature":"preferredProvider",xt=r=>{const n=localStorage.getItem(_t(r));return n&&On.test(n)?n:null},Bt=(r,n)=>{localStorage.setItem(_t(n),r)},Wn=()=>xt(!1)??"megaplay",Un=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Fn(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:Ir(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Wn(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Vn(r,n){switch(n.type){case"SET_STATE":return{...r,...n.payload};case"SET_MODE":return{...r,currentMode:n.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...r,selectedProvider:n.payload};default:return r}}async function Mt(r,n,a,u,l=!1){if(!r||!n)throw new Error("Missing params");try{const[i,s,d,c]=await Promise.all([me.data.video.query({showId:r,episodeNumber:n,mode:a.currentMode,provider:a.selectedProvider}).catch(y=>{const v=y.data?.cause;return y.message==="AUTH_REQUIRED"&&v?.provider==="mkissa"&&u({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:"mkissa"}}),null}),me.progress.getEpisode.query({showId:r,episodeNumber:n}).catch(()=>null),me.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),me.data.skipTimes.query({showId:r,episodeNumber:n}).catch(()=>[])]),g=d?.value,b=i?.filter(y=>{const v=y.sourceName.toLowerCase();return a.currentMode==="dub"?v.includes("eng")||v.includes("dub"):v.includes("jpn")||v.includes("sub")||!v.includes("eng")&&!v.includes("dub")})??[],e=b.length>0?b:i??[];let o=e.length>0?e[0]:null;if(g){const y=e.find(v=>v.sourceName===g);y&&(o=y)}const R=o&&o.links.length>0?o.links.sort((y,v)=>(parseInt(v.resolutionStr)||0)-(parseInt(y.resolutionStr)||0))[0]:null,p=s?.currentTime||0,w=s?.duration||0,P=p,B=(Array.isArray(c)?c:c?.results||[]).map(y=>({skip_id:y.skip_id||"",skip_type:y.skip_type||"",start_time:y.interval?.start_time??y.start_time??0,end_time:y.interval?.end_time??y.end_time??0})).filter(y=>y.end_time>0);return(!i||i.length===0)&&(l||we.error(`No video sources found for ${a.selectedProvider}`)),{videoSources:i,selectedSource:o,selectedLink:R,resumeTime:P,resumeDuration:w,showResumeModal:P>5&&o?.type!=="iframe",skipIntervals:B,fetchedEpisodeNumber:n}}catch(i){const s=i;if(s.message==="AUTH_REQUIRED")return u({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:s.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:n};throw i}}const Qn=(r,n,a,u)=>{const[l,i]=Ht(Vn,a,S=>({...Un(),showMeta:S?.name?{name:S.name,thumbnail:S.thumbnail,nativeName:S.nativeName,englishName:S.englishName,names:{romaji:S.name||S.englishName,english:S.englishName||S.name,native:S.nativeName}}:{}})),s=Rt(),d=Mr(),c=N(null),g=N(null),{options:b}=At(),e=Me(()=>b.filter(S=>(S.kind??"anime")==="anime"),[b]),o=n||l.initialEpisode,R=N(o);V(()=>{R.current!==o&&(R.current=o,i({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[o,i]),V(()=>{r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)&&l.selectedProvider!=="animepahe"&&c.current!==r&&(c.current=r,i({type:"SET_PROVIDER",payload:"animepahe"}))},[r,l.selectedProvider]);const{data:p,isLoading:w,error:P}=Qr(r),{data:k}=Tt({queryKey:[ae.playerData,r,l.currentMode,l.selectedProvider],queryFn:async()=>{if(!r)throw new Error("No showId");const S=async()=>{try{const J=await me.data.episodes.query({showId:r,mode:l.currentMode,provider:l.selectedProvider}).catch(()=>null);if(J?.episodes?.length)return J}catch{}return null},[m,M,T]=await Promise.all([S(),me.watchlist.check.query({showId:r}).catch(()=>({inWatchlist:!1,status:null})),me.progress.getWatchedEpisodes.query({showId:r}).catch(()=>[])]),q=m?.episodes?m.episodes.sort((J,H)=>parseFloat(J)-parseFloat(H)):[];return{description:m?.description||"",episodes:q,inWatchlist:M.inWatchlist,watchlistStatus:M.status??null,watchedEpisodes:T}},enabled:!!r});V(()=>{!n&&k?.episodes&&k.episodes.length>0&&!n&&i({type:"SET_STATE",payload:{initialEpisode:k.episodes[0]}})},[k,n]),V(()=>{if(p?.isAdult===void 0||g.current===r)return;const S=p.isAdult===!0,m=e.filter(T=>T.mature===S);if(m.length===0||e.find(T=>T.id===l.selectedProvider)?.mature===S)return;const M=xt(S);g.current=r??null,i({type:"SET_PROVIDER",payload:m.find(T=>T.id===M)?.id??m[0].id})},[p?.isAdult,l.selectedProvider,r,e]),V(()=>{if(!r||!/^dango-mt-\d+$/.test(r)||g.current===`temp:${r}`)return;const S=p?.provider;S&&(g.current=`temp:${r}`,S!==l.selectedProvider&&i({type:"SET_PROVIDER",payload:S}))},[r,p,l.selectedProvider]);const{data:B,isLoading:y,error:v}=Tt({queryKey:[ae.videoSources,r,o,l.selectedProvider,l.currentMode],queryFn:()=>Mt(r,o,l,i),enabled:!!r&&!!o&&!(l.showMeta?.isAdult===!0&&!u?.hasMatureConsent)}),{mutateAsync:_}=yt({mutationFn:async({wasIn:S,showMeta:m})=>{if(!r)throw new Error("Missing showId");if(S)await me.watchlist.remove.mutate({id:r});else{const M=m.name||m.names?.romaji;if(!M)throw new Error("Missing show name");await me.watchlist.add.mutate({id:r,name:M,thumbnail:m.thumbnail,nativeName:m.names?.native,englishName:m.names?.english,type:m.type,isAdult:m.isAdult})}return!S},onSuccess:S=>{we.success(S?"Added to watchlist":"Removed from watchlist"),s.invalidateQueries({queryKey:[ae.playerData,r]}),s.invalidateQueries({queryKey:[ae.showData,r]}),s.invalidateQueries({queryKey:[ae.watchlist]})},onError:S=>we.error(S instanceof Error?S.message:"Failed to update watchlist")}),f=Q(async()=>{!r||!p||await _({wasIn:!!k?.inWatchlist,showMeta:p})},[r,p,k?.inWatchlist,_]),E=Q(async S=>{try{await me.settings.set.mutate({key:"preferredSource",value:S})}catch(m){console.error(m)}},[]),{mutateAsync:x,isPending:X}=yt({mutationFn:async({status:S})=>{if(!r)throw new Error("Missing showId");if(k?.inWatchlist)return await me.watchlist.setStatus.mutate({id:r,status:S}),S;const m=p,M=m?.name||m?.names?.romaji;if(!m||!M)throw new Error("Missing show name");return await me.watchlist.add.mutate({id:r,name:M,thumbnail:m.thumbnail,nativeName:m.names?.native,englishName:m.names?.english,type:m.type,isAdult:m.isAdult,status:S}),S},onSuccess:S=>{i({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:S}}),we.success(`Moved to ${S}`),s.invalidateQueries({queryKey:[ae.showData,r]}),s.invalidateQueries({queryKey:[ae.watchlist]}),s.invalidateQueries({queryKey:[ae.continueWatching]})},onError:()=>we.error("Failed to update watchlist status")}),$=Q(async()=>{await x({status:"Completed"})},[x]),{mutateAsync:G,isPending:I}=yt({mutationFn:async({episodeNumber:S,duration:m,showMeta:M,episodes:T})=>{await me.progress.updateProgress.mutate({showId:r??"",episodeNumber:S,currentTime:m,duration:m,showName:M.name,showThumbnail:M.thumbnail,nativeName:M.names?.native,englishName:M.names?.english,genres:M.genres?.map(q=>q.name),popularityScore:Rr(M.score)??void 0,type:M.type,status:M.status,episodeCount:T.length,isAdult:M.isAdult})},onSuccess:(S,m)=>{we.success(`Episode ${m.episodeNumber} marked as watched`),s.invalidateQueries({queryKey:[ae.playerData,r]}),s.invalidateQueries({queryKey:[ae.showMeta,r]}),s.invalidateQueries({queryKey:[ae.videoSources,r,m.episodeNumber]}),s.invalidateQueries({queryKey:[ae.continueWatching]}),s.invalidateQueries({queryKey:[ae.thisWeekSchedule]}),s.invalidateQueries(d.continueWatching.pathFilter())},onError:()=>we.error("Failed to mark episode as watched")}),L=Q(async(S,m)=>{!r||!p||await G({episodeNumber:S,duration:m,showMeta:p,episodes:k?.episodes||[]})},[r,p,k?.episodes,G]),A=Q(async()=>{i({type:"SET_STATE",payload:{showCombinedDetails:!l.showCombinedDetails}})},[l.showCombinedDetails]),F=Me(()=>{const S=P||v,m=S?S.message:null,M=m==="AUTH_REQUIRED"?null:m,T=B&&B.fetchedEpisodeNumber===o?B:null,q=!!B&&!T;return{...l,currentEpisode:o,showMeta:{...l.showMeta||{},...p||{}},episodes:k?.episodes||[],watchedEpisodes:k?.watchedEpisodes||[],inWatchlist:!!k?.inWatchlist,watchlistStatus:k?.watchlistStatus??l.watchlistStatus??null,videoSources:T?.videoSources||[],selectedSource:l.selectedSource||T?.selectedSource||null,selectedLink:l.selectedLink||T?.selectedLink||null,resumeTime:T?.resumeTime||0,resumeDuration:T?.resumeDuration||0,showResumeModal:l.showResumeModal&&(T?.showResumeModal??!1),skipIntervals:T?.skipIntervals||[],loadingShowData:w,loadingVideo:y||q,error:M,fetchedEpisodeNumber:T?.fetchedEpisodeNumber}},[l,p,k,B,w,y,P,v,o]),O=Q((S,m)=>{const M=m||r;if(!M||!S||M===r&&S===o)return;const q=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(M)&&l.selectedProvider!=="animepahe"?"animepahe":l.selectedProvider,J=["video-sources",M,S,q,l.currentMode];s.getQueryState(J)?.status!=="success"&&s.prefetchQuery({queryKey:J,queryFn:()=>Mt(M,S,{selectedProvider:q,currentMode:l.currentMode},i,!0),staleTime:300*1e3,gcTime:1800*1e3})},[r,o,s,l,i]);return{state:F,dispatch:i,toggleWatchlist:f,moveToCompleted:$,setPreferredSource:E,handleToggleDetails:A,markEpisodeWatched:L,prefetchEpisodeSources:O,isMarkingWatched:I,isUpdatingWatchlistStatus:X}};function Gn({onNext:r,onToggleTheater:n,flashControls:a}){V(()=>{const u=l=>{l.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(l.key.toLowerCase())&&a(),l.key.toLowerCase()==="n"&&r(),l.key.toLowerCase()==="t"&&n())};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[a,r,n])}const Xe=(r,n,a)=>r.showId===n||!!a&&r.showId===a;function qn({testClipActive:r,selectedSourceType:n,onEnded:a,queue:u,removeFromQueue:l,showId:i,showMetaId:s,currentEpisode:d,isAutoplayEnabled:c,nextEpisode:g,previousEpisode:b,navigate:e,invalidateContinueWatching:o,dispatch:R}){const[p,w]=ie(!1),[P,k]=ie(null),[B,y]=ie(null),v=N(l);v.current=l;const _=N(!1);V(()=>{_.current=!1,w(!1)},[i,d]);const f=Q(()=>{if(r||_.current)return;_.current=!0,a();const L=u.find(A=>Xe(A,i,s)&&A.episodeNumber===d);if(u.length>0){const A=u.findIndex(O=>Xe(O,i,s)&&O.episodeNumber===d),F=A>=0?u[A+1]||null:u[0];y({nextItem:F,playedItem:L||null}),k(2);return}if(L&&v.current({showId:L.showId,episodeNumber:L.episodeNumber}),c&&g){o(),e(`/watch/${i}/${g}`);return}g||w(!0)},[a,e,u,i,s,d,g,c,o,r]),E=Q(()=>{if(u.length===0)return;a();const L=u.find(O=>Xe(O,i,s)&&O.episodeNumber===d),A=u.findIndex(O=>Xe(O,i,s)&&O.episodeNumber===d),F=A>=0?u[A+1]||null:u[0];L&&l({showId:L.showId,episodeNumber:L.episodeNumber}),F?e(`/watch/${F.showId}/${F.episodeNumber}`):g||w(!0)},[a,e,u,l,i,s,d,g]),x=Q(()=>{g&&(o(),e(`/watch/${i}/${g}`)),w(!1),R({type:"SET_STATE",payload:{showResumeModal:!1}})},[g,e,i,R,o]),X=Q(()=>{u.length>0?E():g?x():we.error("No next episode available")},[u.length,E,x,g]),$=Q(()=>w(!1),[]),G=Q(()=>{y(null),k(null)},[]),I=Q(()=>{b&&e(`/watch/${i}/${b}`)},[b,e,i]);return V(()=>{const L=A=>{A.origin===window.location.origin&&n==="iframe"&&A.data?.type==="ANI_WEB_MEDIA_ENDED"&&f()};return window.addEventListener("message",L),()=>window.removeEventListener("message",L)},[f,n]),V(()=>{if(!B||P===null)return;if(P<=0){const{nextItem:A,playedItem:F}=B;y(null),k(null),F&&v.current({showId:F.showId,episodeNumber:F.episodeNumber}),A?e(`/watch/${A.showId}/${A.episodeNumber}`):g||w(!0);return}const L=window.setTimeout(()=>{k(A=>A===null?null:A-1)},1e3);return()=>window.clearTimeout(L)},[B,P,e,g]),{showCompleteModal:p,queueCountdown:P,pendingQueueTransition:B,handleQueueTransition:E,handleNextEpisode:x,handleNShortcut:X,handlePreviousEpisode:I,handlePlaybackFinished:f,closeCompleteModal:$,cancelQueueTransition:G}}function Kn({videoRef:r,queue:n,showId:a,showMetaId:u,currentEpisode:l,selectedSource:i,hasNextEpisode:s,nextEpisode:d,prefetchEpisodeSources:c,matchesQueueItem:g}){const[b,e]=ie(!1),o=N(c);o.current=c;const R=N("");V(()=>{e(!1)},[l]);const p=Q(()=>{const w=r.current;if(!w||i?.type==="iframe")return;const P=w.duration,k=w.currentTime;if(!P||Number.isNaN(P)){e(!1);return}if(P-k<=60){const B=n.findIndex(_=>g(_,a,u)&&_.episodeNumber===l),y=n.length>0?B>=0?n[B+1]||null:n[0]:null,v=y?`${y.showId}:${y.episodeNumber}`:s?`${a}:${d}`:"";v&&R.current!==v&&(R.current=v,y?o.current(y.episodeNumber,y.showId):o.current(d??""))}e(s&&Fr(k,P))},[r,i,n,a,u,l,s,d,g]);return{showNextEpisodePrompt:b,handleThresholds:p}}const bt="fallbackChoice";function zn(){try{const r=localStorage.getItem(bt);return r==="iframe"||r==="retry"?r:null}catch{return null}}function jn(r){try{r===null?localStorage.removeItem(bt):localStorage.setItem(bt,r)}catch{}}function Hn({showId:r,episodeNumber:n,currentMode:a,selectedProvider:u,selectedSourceType:l,videoSources:i,isAdult:s,providerOrder:d,matureProviders:c,setPreferredSource:g,dispatch:b,showControls:e}){const o=N(!1),R=N([]),p=N(!1),[w,P]=ie(null),[k,B]=ie(!1),[y,v]=ie(!1),[_,f]=ie(()=>zn()??"ask"),E=Q(m=>{f(m),jn(m==="ask"?null:m)},[]),x=N(_);V(()=>{x.current=_},[_]);const X=N(i);X.current=i;const $=Q(()=>{o.current=!1,R.current=[],p.current=!1,P(null),B(!1)},[]);V(()=>{$()},[$,r,n]);const G=Q(m=>{if(o.current)return;o.current=!0;const M=m.links[0];g(m.sourceName),b({type:"SET_STATE",payload:{selectedSource:m,selectedLink:M}}),P(null)},[b,g]),I=Q(()=>{const M=X.current.find(T=>T.type==="iframe");return M?.links?.length?M:null},[]),L=Q(async()=>{const m=d.filter(M=>{if(R.current.includes(M))return!1;const T=c.has(M);return s===void 0?!0:T===s});B(!0);try{for(const M of m){R.current.push(M);let T=null;try{T=await me.data.video.query({showId:r,episodeNumber:n,mode:a,provider:M})}catch{continue}const q=(T??[]).filter(K=>{const ee=K.sourceName.toLowerCase();return a==="dub"?ee.includes("eng")||ee.includes("dub"):ee.includes("jpn")||ee.includes("sub")||!ee.includes("eng")&&!ee.includes("dub")});if((q.length>0?q:T??[]).find(K=>K.type!=="iframe"&&K.links?.length)){R.current=[u],p.current=!1,b({type:"SET_STATE",payload:{selectedProvider:M,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Bt(M,s===!0),P(null),we.success(`Switched to ${M} (direct stream)`);return}}P({retryFailed:!0}),we.error("No working direct stream found on other providers")}finally{B(!1)}},[r,n,a,s,u,b,d,c]),A=Q(()=>{if(o.current||p.current||l!=="player")return;const m=I();if(!m)return;R.current.includes(u)||R.current.push(u);const M=x.current;if(M==="iframe"){G(m);return}if(M==="retry"){L();return}e(!0),P({retryFailed:!1})},[l,u,I,G,L,e]),F=Q(()=>{p.current=!0,P(null),v(!1)},[]),O=Q(()=>{y&&E("iframe");const m=I();m?G(m):P(null)},[y,E,I,G]),S=Q(()=>{y&&E("retry"),L()},[y,E,L]);return{fallbackPrompt:w,isRetryingProvider:k,rememberFallbackChoice:y,setRememberFallbackChoice:v,fallbackChoice:_,updateFallbackChoice:E,dismissFallbackPrompt:F,chooseIframeFallback:O,chooseProviderRetry:S,handleVideoSourceError:A,resetFallback:$}}function Yn({videoRef:r,selectedSource:n,selectedLink:a,loadingVideo:u,testClipActive:l,resumeTime:i,showResumeModal:s,calibReturnRef:d,setAvailableSubtitles:c,setActiveSubtitleTrack:g,showControls:b,onFatalError:e}){const o=N(null),R=N(0),p=N(i),w=N(s),P=N(e);return P.current=e,V(()=>{p.current=i,w.current=s},[i,s]),V(()=>{const k=r.current;if(!k)return;let B=!1;for(o.current&&(o.current.destroy(),o.current=null),(u||n)&&(k.pause(),k.removeAttribute("src"),k.load());k.firstChild;)k.removeChild(k.firstChild);if(l)return k.src="/av-sync-test.mp4",k.play().catch(()=>{b(!0)}),()=>{B=!0};if(!n||!a)return;if(n.type==="iframe"){R.current=0;return}d.current!=null?(R.current=d.current,d.current=null):p.current>5&&!w.current?R.current=p.current:w.current&&(R.current=0);let y=a.link;if(y.startsWith("/api/proxy")||(y=`/api/proxy?url=${encodeURIComponent(y)}`,a.headers?.Referer&&(y+=`&referer=${encodeURIComponent(a.headers.Referer)}`)),n.subtitles){const $=localStorage.getItem("playerSubtitlesEnabled")!=="false";let G=null;try{G=localStorage.getItem("playerLastSubtitle")}catch{}const I=St(n.subtitles,{lastKey:G,enabled:$}),L=I>=0?n.subtitles[I]:null;n.subtitles.forEach(A=>{const F=document.createElement("track");F.kind="subtitles",F.label=A.label,F.srclang=A.lang;const O=A.src??A.url;if(O){let S=`/api/subtitle-proxy?url=${encodeURIComponent(O)}`;const m=a.headers?.Referer;m&&(S+=`&referer=${encodeURIComponent(m)}`),F.src=S}L&&A.label===L.label&&A.lang===L.lang&&(F.default=!0),k.appendChild(F)}),$||g("off"),c(n.subtitles)}const v=R.current;R.current=0;const _=()=>{v>0&&(k.currentTime=v)};k.addEventListener("loadedmetadata",_,{once:!0});const f=!(w.current&&p.current>5),E=()=>{f&&k.play().catch(()=>{b(!0)})};a.hls?(async()=>{const $=await qr();if(B)return;if(!$||!$.isSupported()){k.src=y,E();return}const G=document.body.classList.contains("low-end"),I=new $({maxBufferLength:G?15:30,maxMaxBufferLength:G?30:60,maxBufferSize:G?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});o.current=I,I.on($.Events.ERROR,(F,O)=>{O.fatal&&P.current()});const L=(n.subtitles?.length??0)>0,A=()=>{try{L&&typeof I.subtitleTrack=="number"&&I.subtitleTrack!==-1&&(I.subtitleTrack=-1)}catch{}};I.on($.Events.SUBTITLE_TRACK_SWITCH,(F,O)=>{O?.id!==-1&&A()}),A(),I.loadSource(y),I.attachMedia(k),I.once($.Events.MANIFEST_PARSED,()=>{B||E()})})():(k.src=y,E());const x=localStorage.getItem("playerVolume"),X=localStorage.getItem("playerMuted");return x!==null&&(k.volume=parseFloat(x)),X!==null&&(k.muted=X==="true"),()=>{B=!0,k.removeEventListener("loadedmetadata",_),o.current&&(o.current.destroy(),o.current=null)}},[n,a,r,d,u,l,g,c,b]),{seekToTimeRef:R}}function Xn({videoRef:r,availableSubtitles:n,activeSubtitleTrack:a,setAvailableSubtitles:u,setActiveSubtitleTrack:l}){V(()=>{const i=r.current;if(!i)return;const s=()=>{const d=Array.from(i.textTracks).map(c=>({label:c.label,lang:c.language,src:void 0,mode:c.mode}));u(d)};return i.textTracks.addEventListener("addtrack",s),i.textTracks.addEventListener("removetrack",s),s(),()=>{i.textTracks.removeEventListener("addtrack",s),i.textTracks.removeEventListener("removetrack",s)}},[r,u]),V(()=>{if(a===null&&n.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let i=null;try{i=localStorage.getItem("playerLastSubtitle")}catch{}const s=St(n,{lastKey:i,enabled:!0});if(s<0){l("off");return}const d=n[s];l(d.lang||d.label)}},[a,n,l]),V(()=>{const i=r.current;if(!i||n.length===0)return;const s=a;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(i.textTracks).forEach(g=>{g.mode="hidden"});return}let c=!1;if(Array.from(i.textTracks).forEach(g=>{const e=(g.language===s||g.label===s)&&!c;g.mode=e?"showing":"hidden",e&&(c=!0)}),!c&&i.textTracks.length>0){const g=Array.from(i.textTracks).find(b=>b.language==="en"||b.label==="English")||i.textTracks[0];g&&(g.mode="showing")}},[a,n,r])}function Jn({videoRef:r,videoBoxH:n,style:a,sourceKey:u,activeSubtitleTrack:l,availableSubtitles:i}){V(()=>{const s="dynamic-subtitle-styles";let d=document.getElementById(s);d||(d=document.createElement("style"),d.id=s,document.head.appendChild(d)),d.textContent=Ct(a);const c=r.current;if(!c)return;const g=Nt(a.fontSize,n||c.clientHeight||720);d.textContent=Ct({...a,fontSize:g});const b=()=>{const v=Number(a.position),_=isNaN(v)?0:Math.max(0,Math.min(100,v));return Math.max(0,Math.min(100,100-_))},e=(v,_)=>{try{const f=v;f.snapToLines=!1,f.line=_}catch{}},o=()=>{const v=g*16,_=c.videoHeight||c.clientHeight||720,f=c.videoWidth||c.clientWidth||1280;return{step:v*1.3/_*100,chars:Math.max(20,Math.floor(f/(v*.55)))}},R=v=>{const _=b(),f=Array.from(v.activeCues??[]);if(f.length<=1){f.forEach($=>e($,_));return}const{step:E,chars:x}=o();let X=_;for(let $=f.length-1;$>=0;$--){const I=String(f[$].text??"").replace(/<[^>]*>/g,"").split(`
|
|
55
|
+
`).reduce((A,F)=>A+Math.max(1,Math.ceil(F.length/x)),0),L=X-I*E;e(f[$],Math.max(0,L)),X=L-E*.4}},p=v=>{if(!v.cues)return;const _=b();Array.from(v.cues).forEach(f=>e(f,_)),v.mode==="showing"&&R(v)},w=()=>{Array.from(c.textTracks).forEach(p)};w();const P=v=>{const _=v.target;_.mode==="showing"&&R(_)};Array.from(c.textTracks).forEach(v=>{v.addEventListener("cuechange",P)});const k=()=>{Array.from(c.textTracks).forEach(v=>{v.removeEventListener("cuechange",P),v.addEventListener("cuechange",P)}),w()};c.textTracks.addEventListener("addtrack",k),c.textTracks.addEventListener("removetrack",k);const B=Array.from(c.querySelectorAll("track")),y=()=>{w()};return B.forEach(v=>{v.addEventListener("load",y)}),()=>{Array.from(c.textTracks).forEach(v=>{v.removeEventListener("cuechange",P)}),c.textTracks.removeEventListener("addtrack",k),c.textTracks.removeEventListener("removetrack",k),B.forEach(v=>{v.removeEventListener("load",y)})}},[a,n,r,u,l,i])}function Zn({videoRef:r,overlayRef:n,style:a,activeSubtitleTrack:u,delayMs:l,enabled:i}){V(()=>{if(!i)return;const s=r.current,d=n.current;if(!s||!d)return;const c=localStorage.getItem("playerSubtitlesEnabled")!=="false",g=()=>{if(d.innerHTML="",!c||u==="off"||u===null)return;const o=Array.from(s.textTracks).find(y=>y.language===u||y.label===u);if(!o||o.mode!=="showing")return;const R=l/1e3;let p;if(R>0&&o.cues){const y=s.currentTime-R;p=Array.from(o.cues).filter(v=>v.startTime<=y&&y<=v.endTime)}else p=Array.from(o.activeCues??[]);if(p.length===0)return;const w={...a,fontSize:Nt(a.fontSize,s.clientHeight||0)},P=ar(w),k=ir(s,w.position),B=Array.from(p);B.forEach((y,v)=>{const _=String(y.text??"");if(!lr(_).trim())return;const f=document.createElement("div"),E=(B.length-1-v)*1.7;f.style.cssText=`${P}
|
|
56
|
+
bottom: calc(${k}px + ${E}em);`,f.innerHTML=cr(_),d.appendChild(f)})},b=()=>g(),e=()=>g();return Array.from(s.textTracks).forEach(o=>{o.addEventListener("cuechange",b)}),s.addEventListener("timeupdate",e),g(),()=>{Array.from(s.textTracks).forEach(o=>{o.removeEventListener("cuechange",b)}),s.removeEventListener("timeupdate",e),d.innerHTML=""}},[u,l,i,n,a,r])}const eo=({isOpen:r,onClose:n,onSuccess:a})=>{const u=()=>{a?.(),n()};return t(mt,{isOpen:r,onClose:n,title:"MKissa Browser Verification",children:t("div",{className:Ve.container,children:[t("p",{children:"Open MKissa in this browser, play an anime episode, and complete any Cloudflare verification it shows. Once playback works there, return to Dango and click Refresh."}),t("div",{className:Ve.actions,children:t("a",{className:Ve.link,href:"https://mkissa.to/anime",target:"_blank",rel:"noreferrer",children:"Open MKissa anime"})}),t("div",{className:Ve.actions,children:[t("button",{className:Ve.secondaryButton,onClick:n,children:"Cancel"}),t("button",{className:Ve.button,onClick:u,children:"Refresh Dango"})]})]})})},yo=()=>{const{id:r,episodeNumber:n}=Yt(),a=Xt(),u=Rt(),l=Jt(),{hasConsent:i,grant:s}=Nr(),{options:d}=At(),c=Me(()=>d.filter(h=>(h.kind??"anime")==="anime"),[d]),g=Me(()=>c.map(h=>h.id),[c]),b=Me(()=>new Set(c.filter(h=>h.mature).map(h=>h.id)),[c]),{state:e,dispatch:o,toggleWatchlist:R,moveToCompleted:p,setPreferredSource:w,handleToggleDetails:P,markEpisodeWatched:k,prefetchEpisodeSources:B,isMarkingWatched:y,isUpdatingWatchlistStatus:v}=Qn(r,n,l.state||null,{hasMatureConsent:i});V(()=>{if(r&&e.showMeta?.id&&e.showMeta.id!==r){const h=n?`/watch/${e.showMeta.id}/${n}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;a(h,{replace:!0})}},[r,e.showMeta?.id,n,a]);const _=Me(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),f=ur({skipIntervals:e.skipIntervals,showId:r,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:_}),{refs:E,actions:x}=f,X=Ur(),$=N(null),G=N(null),I=N(null),[L,A]=ie(()=>{try{const h=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(h)?h:"balanced"}catch{return"balanced"}}),{videoDelayMs:F,videoDelayEnabled:O,setDelayEnabled:S,handleVideoDelayChange:m,isCalibrating:M,testClipActive:T,stopCalibration:q,openAvSyncCalibrator:J,cancelAvSyncCalibrator:H,applyAvSyncCalibrator:K,toggleTestClip:ee,calibReturnRef:Se,effectiveVideoDelayMs:Ae}=dr(E.videoRef,()=>x.setShowSettings(!1)),Re=N(null),te=$n({videoRef:E.videoRef,canvasRef:G,profile:L,delayMs:Ae}),z=te.isEnabled&&te.isWebGPUSupported;In({videoRef:E.videoRef,episodeKey:`${r??""}:${e.currentEpisode??""}`,isEnabled:te.isEnabled,isSupported:te.isWebGPUSupported,mediaReady:!e.loadingVideo&&!!e.selectedLink,isIframeSource:e.selectedSource?.type==="iframe",setEnabled:te.setEnabled}),mr({videoRef:E.videoRef,canvasRef:Re,delayMs:Ae,enabled:O&&!z});const ke=O&&!z,_e=z||ke,[re,j]=ie(!1),ve=N(n);V(()=>{ve.current!==n&&(ve.current=n,q())},[n,q]);const ft=Q(()=>{u.invalidateQueries({queryKey:[ae.continueWatching]})},[u]),{data:xe=[],isLoading:Je}=Pr(),Ze=Ar(),Qe=_r(),ht=xr(),{isTheaterMode:le,toggleTheaterMode:ce,handleLayoutClick:pt}=fr();Zt(()=>{if(f.state.isFullscreen||le)return;const h=E.playerContainerRef.current,Z=$.current;if(!h||!Z)return;const $e=()=>{const gt=h.getBoundingClientRect().height;Z.style.height=`${gt}px`};$e();const lt=new ResizeObserver($e);return lt.observe(h),()=>lt.disconnect()},[f.state.isFullscreen,le,E.playerContainerRef]);const Te=Me(()=>e.episodes.findIndex(h=>h===e.currentEpisode),[e.episodes,e.currentEpisode]),et=Te>0?e.episodes[Te-1]:null,Ge=Te>=0&&Te<e.episodes.length-1?e.episodes[Te+1]:null,tt=Te>-1&&Te<e.episodes.length-1,{showCompleteModal:W,queueCountdown:Ne,pendingQueueTransition:qe,handleQueueTransition:fe,handleNextEpisode:rt,handleNShortcut:Fe,handlePreviousEpisode:Oe,handlePlaybackFinished:Ke,closeCompleteModal:Be,cancelQueueTransition:ze}=qn({testClipActive:T,selectedSourceType:e.selectedSource?.type,onEnded:x.onEnded,queue:xe,removeFromQueue:Ze.mutate,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,isAutoplayEnabled:e.isAutoplayEnabled,nextEpisode:Ge,previousEpisode:et,navigate:a,invalidateContinueWatching:ft,dispatch:o}),{showNextEpisodePrompt:nt,handleThresholds:Le}=Kn({videoRef:E.videoRef,queue:xe,showId:r,showMetaId:e.showMeta?.id,currentEpisode:e.currentEpisode,selectedSource:e.selectedSource,hasNextEpisode:tt,nextEpisode:Ge,prefetchEpisodeSources:B,matchesQueueItem:Xe}),{checkEnd:De,logDuration:ot}=hr({videoRef:E.videoRef,sourceType:e.selectedSource?.type,resetKey:`${r}:${e.currentEpisode}`,onEnd:Ke}),st=e.showResumeModal,at=W,U=st||at;pr(f,!!e.selectedLink&&!le&&!U);const{fallbackPrompt:ne,isRetryingProvider:he,rememberFallbackChoice:ue,setRememberFallbackChoice:de,fallbackChoice:pe,updateFallbackChoice:ge,dismissFallbackPrompt:je,chooseIframeFallback:We,chooseProviderRetry:ye,handleVideoSourceError:oe,resetFallback:it}=Hn({showId:r,episodeNumber:e.currentEpisode??void 0,currentMode:e.currentMode,selectedProvider:e.selectedProvider,selectedSourceType:e.selectedSource?.type,videoSources:e.videoSources,isAdult:e.showMeta?.isAdult,providerOrder:g,matureProviders:b,setPreferredSource:w,dispatch:o,showControls:x.setShowControls}),{seekToTimeRef:Ue}=Yn({videoRef:E.videoRef,selectedSource:e.selectedSource,selectedLink:e.selectedLink,loadingVideo:e.loadingVideo,testClipActive:T,resumeTime:e.resumeTime,showResumeModal:e.showResumeModal,calibReturnRef:Se,setAvailableSubtitles:x.setAvailableSubtitles,setActiveSubtitleTrack:x.setActiveSubtitleTrack,showControls:x.setShowControls,onFatalError:oe});V(()=>{U&&f.state.isFullscreen&&f.actions.toggleFullscreen()},[U,f.state.isFullscreen,f.actions]),V(()=>{U&&E.videoRef.current&&E.videoRef.current.pause()},[U,E.videoRef]);const{titlePreference:se}=Br(),{lowEndMode:He}=Lr(),{settings:vt,update:Lt}=vr(),Dt=le&&vt.enabled&&!He&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,Pe=Me(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:h,names:Z}=e.showMeta;return se==="name"?h||"Loading...":se==="nativeName"?Z?.native||h||"Loading...":se==="englishName"?Z?.english||h||"Loading...":h||"Loading..."},[e.showMeta,se,e.loadingShowData]);V(()=>{Pe&&Pe!=="Loading..."&&e.currentEpisode&&(document.title=`► ${Pe} Episode ${e.currentEpisode} - dango`)},[Pe,e.currentEpisode]),Gn({onNext:Fe,onToggleTheater:ce,flashControls:f.actions.flashControls});const{setAvailableSubtitles:$t,setActiveSubtitleTrack:It}=x,Et=Me(()=>({fontSize:f.state.subtitleFontSize,position:f.state.subtitlePosition,bgOpacity:f.state.subtitleBgOpacity,bgColor:f.state.subtitleBgColor,textColor:f.state.subtitleTextColor,edge:f.state.subtitleEdge,bold:f.state.subtitleBold}),[f.state.subtitleFontSize,f.state.subtitlePosition,f.state.subtitleBgOpacity,f.state.subtitleBgColor,f.state.subtitleTextColor,f.state.subtitleEdge,f.state.subtitleBold]);Xn({videoRef:E.videoRef,availableSubtitles:f.state.availableSubtitles,activeSubtitleTrack:f.state.activeSubtitleTrack,setAvailableSubtitles:$t,setActiveSubtitleTrack:It});const[Ft,Ot]=ie(0);V(()=>{const h=E.videoRef.current;if(!h)return;const Z=()=>Ot(h.clientHeight||0);Z();const $e=new ResizeObserver(Z);return $e.observe(h),()=>$e.disconnect()},[E.videoRef,e.selectedSource,e.selectedLink]),Jn({videoRef:E.videoRef,videoBoxH:Ft,style:Et,sourceKey:`${e.selectedSource?.sourceName??""}:${e.selectedLink?.link??""}`,activeSubtitleTrack:f.state.activeSubtitleTrack,availableSubtitles:f.state.availableSubtitles}),Zn({videoRef:E.videoRef,overlayRef:I,style:Et,activeSubtitleTrack:f.state.activeSubtitleTrack,delayMs:Ae,enabled:_e}),V(()=>{try{localStorage.setItem("anime4kProfile",L)}catch{}},[L]);const Wt=()=>{E.videoRef.current&&(E.videoRef.current.currentTime=e.resumeTime,E.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Ut=()=>{E.videoRef.current&&(E.videoRef.current.currentTime=0,E.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Vt=Q(()=>{o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o]),Qt=Q(async()=>{try{await p(),Be(),o({type:"SET_STATE",payload:{showResumeModal:!1}}),a("/")}catch{}},[p,Be,o,a]),wt=(h,Z)=>t("div",{className:h,children:[t("button",{className:`${C.episodeNavBtn} ${C.secondary}`,onClick:Oe,disabled:!et,type:"button",children:[t(Y,{name:"chevron-left",size:12}),"Prev EP"]}),t("button",{className:`${C.episodeNavBtn} ${C.primary}`,onClick:rt,disabled:!Ge,type:"button",children:["Next EP",t(Y,{name:"chevron-right",size:12})]}),Z==="mobile"&&X&&t("button",{className:`${C.episodeNavBtn} ${C.episodePickerBtn}`,onClick:()=>j(!0),type:"button",children:[t(Y,{name:"list-ul",size:12}),"Episodes"]})]}),Gt=h=>{o({type:"SET_STATE",payload:{isAutoplayEnabled:h}}),Or(h)},kt=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),qt=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Kt=Q(async()=>{if(!r||!e.currentEpisode||!e.showMeta.name||y)return;const h=E.videoRef.current?.duration,Z=Math.max(h||0,e.resumeDuration||0,Number(e.showMeta.episodeDuration||0)*60,1);await k(e.currentEpisode,Z)},[r,e.currentEpisode,e.showMeta,e.resumeDuration,k,y,E.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return t("p",{className:"error-message",children:["Error: ",e.error]});const Ce=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!i?t("div",{className:be.playerPageLayout,children:t(Wr,{isOpen:!0,onClose:()=>a("/home"),onGrant:s})}):t("div",{className:`${be.playerPageLayout} ${le?be.theaterMode:""}`,onClick:pt,children:[le&&t(gr,{videoRef:E.videoRef,active:Dt,settings:vt}),t(yr,{isOpen:at,onClose:Be,title:"Show Completed!",heading:Pe,message:"Congratulations! You finished all available episodes.",children:[t(ut,{variant:"secondary",onClick:Be,children:"Close"}),t(ut,{onClick:Qt,disabled:v,children:v?"Saving...":"Move to Completed"})]}),t(br,{isOpen:st,onClose:Vt,title:"Resume Playback?",message:t(ct,{children:["You were watching at ",t("strong",{children:f.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Wt,onRestart:Ut}),t(mt,{isOpen:!!ne,onClose:je,title:"Direct stream failed",width:"sm",children:[t(mt.Body,{children:[t("p",{children:[t("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),ne?.retryFailed&&t("p",{children:"No working direct stream was found on the other providers either."}),t("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",t("strong",{children:"ads and pop-ups"}),"."]}),t("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[t("input",{type:"checkbox",checked:ue,onChange:h=>de(h.currentTarget.checked)}),"Remember my choice"]})]}),t(mt.Actions,{children:[t(ut,{variant:"secondary",onClick:We,children:"Continue with iframe"}),t(ut,{onClick:ye,disabled:he,children:he?"Searching…":"Try another provider"})]})]}),t(Dr,{isOpen:!!e.showCookieModal&&e.cookieProvider!=="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{u.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),t(eo,{isOpen:!!e.showCookieModal&&e.cookieProvider==="mkissa",onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{u.invalidateQueries({queryKey:[ae.videoSources,r,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!le&&t("aside",{ref:$,className:be.episodeSidebar,children:e.loadingShowData?t(Sr,{variant:"sidebar"}):t(Er,{episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:h=>a(`/watch/${r}/${h}`)})}),t("div",{className:be.playerMain,children:[t("div",{className:`${C.videoContainer} ${f.state.isFullscreen?"":be.videoPlayerWrapper} ${f.state.isFullscreen?C.fullscreenActive:""}`,style:{...U?{visibility:"hidden"}:{}},onContextMenu:h=>h.preventDefault(),children:t(kn,{player:f,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Gt,fallbackChoice:pe,onFallbackChoiceChange:ge,ambientSettings:vt,onAmbientChange:Lt,showNextEpisodeButton:!U&&nt&&xe.length===0,onNextEpisode:rt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(h,Z)=>{E.videoRef.current&&!isNaN(E.videoRef.current.currentTime)&&(Ue.current=E.videoRef.current.currentTime),w(h.sourceName),o({type:"SET_STATE",payload:{selectedSource:h,selectedLink:Z,showResumeModal:e.showResumeModal&&h.type!=="iframe"}})},loadingVideo:Ce,skipIntervals:e.skipIntervals,animeTitle:Pe,episodeNumber:e.currentEpisode??void 0,isTheaterMode:le,onTheaterModeToggle:ce,anime4kEnabled:te.isEnabled,onAnime4kToggle:te.toggle,anime4kSupported:te.isWebGPUSupported,anime4kProfile:L,onAnime4kProfileChange:A,anime4kInitializing:te.isInitializing,anime4kError:te.error,videoDelayEnabled:O,onVideoDelayToggle:S,videoDelayMs:F,onVideoDelayChange:m,onCalibrateAvSync:J,isInteractingExtra:re||M,className:wr.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:t(ct,{children:[f.state.isSpeedBoostActive&&t("div",{className:C.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(Y,{name:"forward",size:12})]}),Ne!==null&&qe?.nextItem&&t("div",{className:C.queueCountdown,children:["Queue next in ",Ne,"s"]})]}),children:[Ce&&t("div",{className:C.loadingOverlay,children:t("div",{className:C.loadingDots,children:[t("div",{className:C.dot}),t("div",{className:C.dot}),t("div",{className:C.dot})]})}),f.state.isBuffering&&!Ce&&e.selectedSource?.type!=="iframe"&&t("div",{className:C.bufferingOverlay,children:t("div",{className:C.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Ce&&t("iframe",{src:e.selectedLink?.link,className:C.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):t(ct,{children:[!Ce&&e.videoSources.length===0&&t("div",{className:C.errorOverlay,children:[t("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),t("p",{className:C.errorSubtext,children:"Please try selecting a different provider below."}),t("button",{className:C.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Ce&&e.videoSources.length>0&&t("video",{ref:E.videoRef,controls:f.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:x.onPlay,onPause:x.onPause,onEnded:()=>{T||De(!0)},onDurationChange:()=>{x.onDurationChange(),ot()},onSeeked:()=>{T||(Le(),De())},onLoadedMetadata:()=>{x.onLoadedMetadata(),Le(),ot(),T||De()},onTimeUpdate:()=>{T||(x.onTimeUpdate(),Le(),De(),qe&&E.videoRef.current&&E.videoRef.current.currentTime<E.videoRef.current.duration-1&&ze())},onVolumeChange:x.onVolumeChange,onWaiting:x.onWaiting,onPlaying:x.onPlaying,onCanPlay:x.onCanPlay,onError:oe,onContextMenu:h=>h.preventDefault(),className:_e?C.videoElementHidden:""}),te.isWebGPUSupported&&!Ce&&e.videoSources.length>0&&t("canvas",{ref:G,className:`${C.upscalerCanvas} ${z?C.upscalerActive:""}`}),!z&&!Ce&&e.videoSources.length>0&&t("canvas",{ref:Re,className:`${C.upscalerCanvas} ${ke?C.upscalerActive:""}`}),te.isEnabled&&te.isWebGPUSupported&&te.isInitializing&&t("div",{className:C.upscalerStatusBadge,children:"Preparing upscaler…"}),_e&&t("div",{ref:I,className:C.subtitleOverlay}),t(kr,{isOpen:M,ms:F,onChange:m,onApply:K,onClose:H,testClipActive:T,onTestClip:ee})]})]})}),!le&&t(Tr,{}),!le&&t(ct,{children:[Je&&xe.length===0?t(Tn,{count:3}):t(Vr,{title:"Queue",items:xe,currentShowId:r,currentEpisode:e.currentEpisode??void 0,onNextQueue:fe,onRemove:h=>Ze.mutate({showId:h.showId,episodeNumber:h.episodeNumber}),onClear:()=>Qe.mutate(),showClearAll:!0,onReorder:h=>ht.mutate(h.map(Z=>({id:Z.id,showId:Z.showId,episodeNumber:Z.episodeNumber})))}),t("div",{className:C.streamPanel,children:[t(Nn,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:c,onProviderChange:h=>{it(),o({type:"SET_STATE",payload:{selectedProvider:h,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),Bt(h,e.showMeta?.isAdult===!0)}}),wt(`${C.episodeActions} ${C.desktopEpisodeActions}`,"desktop"),Ce?t("div",{className:C.sourceLoader,children:t("div",{className:C.spinner})}):t(An,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:h=>{E.videoRef.current&&!isNaN(E.videoRef.current.currentTime)&&(Ue.current=E.videoRef.current.currentTime);const $e=(h.links||[]).sort((lt,gt)=>(parseInt(gt.resolutionStr)||0)-(parseInt(lt.resolutionStr)||0))[0]||null;w(h.sourceName),o({type:"SET_STATE",payload:{selectedSource:h,selectedLink:$e,showResumeModal:e.showResumeModal&&h.type!=="iframe"}})},onLinkChange:h=>{e.selectedSource&&(w(e.selectedSource.sourceName),o({type:"SET_STATE",payload:{selectedLink:h}}))}})]}),t("div",{className:be.playerInfoContainer,children:[t("div",{className:be.playerInfoHeader,children:[t("div",{className:be.playerAnimeCard,children:t("img",{src:$r(e.showMeta.thumbnail||""),alt:Pe,loading:"lazy",decoding:"async",onError:h=>{h.target.src="/placeholder.svg"}})}),t("div",{className:be.videoTitleSection,children:[t("div",{className:C.titleContainer,children:[t("h1",{children:Pe}),t("div",{className:C.scheduleInfo,children:[e.showMeta.status&&t("span",{className:C.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&t("span",{className:C.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),t("div",{className:C.controls,children:[t("button",{className:`${C.watchlistBtn} ${e.inWatchlist?C.inList:""}`,onClick:R,children:[e.inWatchlist?t(Y,{name:"check",size:14}):t(Y,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),t(Gr,{showId:r,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${C.watchlistBtn} ${C.queueBtn}`,activeClassName:C.queueActive}),qt&&t("button",{className:`${C.watchlistBtn} ${C.markWatchedBtn} ${kt?C.markWatchedDone:""}`,onClick:Kt,disabled:y||!e.currentEpisode,children:[t(Y,{name:"check",size:14}),y?"Saving...":kt?"Watched":"Mark Watched"]}),t("button",{className:`${C.watchlistBtn} ${C.modeToggleBtn} ${e.currentMode==="dub"?C.modeToggleActive:""}`,onClick:()=>{const h=e.currentMode==="dub"?"sub":"dub";it(),o({type:"SET_MODE",payload:h}),localStorage.setItem("preferredMode",h)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),He&&t("button",{className:`${C.watchlistBtn} ${C.modeToggleBtn} ${f.state.useNativeControls?C.modeToggleActive:""}`,onClick:()=>{const h=!f.state.useNativeControls;f.actions.setUseNativeControls(h),localStorage.setItem("playerUseNativeControls",h.toString())},type:"button",children:f.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),wt(`${C.episodeActions} ${C.mobileEpisodeActions}`,"mobile"),t("div",{className:be.infoColumns,children:[t("div",{className:`${C.descriptionSection} ${C.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(zr,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."}),t("button",{className:C.detailsToggleBtn,onClick:P,children:[e.showCombinedDetails?t(Y,{name:"chevron-up"}):t(Y,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]})]}),e.showCombinedDetails&&t(Kr,{showMeta:e.showMeta,styles:C})]})]})]})]}),t(Cr,{isOpen:re,onClose:()=>j(!1),episodes:e.episodes,currentEpisode:e.currentEpisode??void 0,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:h=>{j(!1),a(`/watch/${r}/${h}`)}})]})};export{yo as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-
|
|
1
|
+
import{g as w,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-BSUcso28.js";import{u as re}from"./index-DlcgJVM6.js";import"./usePlaybackEnd-DuEfjKb8.js";import"./vendor-query-BBT5_sHx.js";import"./playbackCompletion-IPHm9fp5.js";const ce="_settingsPanel_1dymm_1",oe="_header_1dymm_33",me="_backBtn_1dymm_56",de="_contentWrapper_1dymm_76",ue="_menuContent_1dymm_82",he="_menuItem_1dymm_89",pe="_selected_1dymm_114",be="_currentValue_1dymm_134",ye="_menuNote_1dymm_141",ge="_menuError_1dymm_150",n={settingsPanel:ce,header:oe,backBtn:me,contentWrapper:de,menuContent:ue,menuItem:he,selected:pe,currentValue:be,menuNote:ye,menuError:ge},ve=($,P)=>{const{isOpen:y,onClose:ke,videoSources:Ce,currentSource:C,currentLink:N,onSourceChange:V,subtitles:O,activeSubtitleTrack:g,onSubtitleChange:E,subtitleSettings:z,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:f,anime4kProfile:r,onAnime4kProfileChange:h,anime4kInitializing:L,anime4kError:S,videoDelayEnabled:_,onVideoDelayToggle:M,videoDelayMs:I,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:m,onAutoSkipChange:W,isAutoplayEnabled:d,onAutoplayChange:G,fallbackChoice:p,onFallbackChoiceChange:j,isTheaterMode:q,ambientSettings:b,onAmbientChange:k}=$,{lowEndMode:F}=re(),[a,i]=ne("main");w.useEffect(()=>{if(!y){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[y]);const Q=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>i("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:N?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:g||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),F&&e("button",{className:`${n.menuItem} ${v?n.selected:""}`,onClick:()=>{const t=!v;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),f&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),f&&u&&e("button",{className:n.menuItem,onClick:()=>i("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>i("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:_?`${I}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[m?"Auto-skip On":null,d?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]}),q&&b&&k&&e("button",{className:n.menuItem,onClick:()=>i("ambient"),children:[e("span",{children:"Ambient Light"}),e("span",{className:n.currentValue,children:b.enabled?"On":"Off"})]})]}),R=()=>{const t=C?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:N?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&V(C,c)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:g==="off"},...O.map(t=>({key:t.label||t.lang,label:t.label,selected:g===(t.label||t.lang)}))],onSelect:t=>E(t)})}),K=()=>e("div",{className:n.menuContent,children:e(se,{classes:{item:n.menuItem,active:n.selected},values:z,onChange:T})}),J=te(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),X=()=>e("div",{className:n.menuContent,children:[L&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),S&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",S]}),!J&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${r==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),r==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),r==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),r==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),r==="denoise"&&e(o,{name:"check",size:12})]})]}),Y=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>W(!m),"aria-pressed":m,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>G(!d),"aria-pressed":d,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>j(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),Z=()=>e("div",{className:n.menuContent,children:e(le,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&k?e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:k})}):null;return y?e(ae,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>i("main"),panelRef:P,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&Q(),a==="quality"&&R(),a==="subtitles"&&H(),a==="subtitle-style"&&K(),a==="upscaler"&&X(),a==="av-sync"&&Z(),a==="playback"&&Y(),a==="ambient"&&ee()]}):null},$e=w.forwardRef(ve);export{$e as default};
|
package/client/dist/assets/{QueueOptionsButton-Cpm6Jovo.js → QueueOptionsButton-B8xuoYlH.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as T}from"./vendor-query-BBT5_sHx.js";import{q as z,t as A,m as J,a1 as W,a2 as X,a3 as Y}from"./index-
|
|
1
|
+
import{b as T}from"./vendor-query-BBT5_sHx.js";import{q as z,t as A,m as J,a1 as W,a2 as X,a3 as Y}from"./index-DlcgJVM6.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-DrybRNxP.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 X}from"./vendor-core-DfaOB3Rn.js";import{I as y}from"./vendor-icons-DrybRNxP.js";import{d as Y,f as L}from"./index-
|
|
1
|
+
import{g as s,u as n,a as X}from"./vendor-core-DfaOB3Rn.js";import{I as y}from"./vendor-icons-DrybRNxP.js";import{d as Y,f as L}from"./index-DlcgJVM6.js";const z="_section_rx9ev_1",F="_header_rx9ev_10",O="_headerToggle_rx9ev_20",j="_headerActions_rx9ev_34",J="_title_rx9ev_40",K="_badge_rx9ev_50",V="_clearBtn_rx9ev_65",W="_nextBtn_rx9ev_83",Z="_list_rx9ev_101",ee="_item_rx9ev_114",ne="_active_rx9ev_134",te="_dragging_rx9ev_142",re="_dragHandle_rx9ev_149",ae="_thumbnail_rx9ev_167",oe="_meta_rx9ev_175",ce="_name_rx9ev_182",se="_episode_rx9ev_204",ie="_iconBtn_rx9ev_210",le="_metaGap_rx9ev_256",r={section:z,header:F,headerToggle:O,headerActions:j,title:J,badge:K,clearBtn:V,nextBtn:W,list:Z,item:ee,active:ne,dragging:te,dragHandle:re,thumbnail:ae,meta:oe,name:ce,episode:se,iconBtn:ie,metaGap:le},ue=({item:a,isActive:x,index:p,onRemove:P,onTouchPointerDown:D,onTouchPointerMove:B,onTouchPointerUp:T,onTouchPointerCancel:w,shouldIgnoreClick:_,onDragStart:R,onDragEnter:f,onDragEnd:c,isDragging:b})=>{const o=X(),{titlePreference:i}=Y(),l=a[i]||a.name||"Unknown show";return n("div",{"data-queue-index":p,className:`${r.item} ${x?r.active:""} ${b?r.dragging:""}`,draggable:!0,onDragStart:R,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:c,onPointerDown:u=>D(p,u),onPointerMove:B,onPointerUp:T,onPointerCancel:w,children:[n("button",{className:r.dragHandle,type:"button","aria-label":"Drag queue item",children:n(y,{name:"bars"})}),n("img",{className:r.thumbnail,src:L(a.thumbnail||"",72,96),alt:l,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:r.meta,children:[n("button",{className:r.name,type:"button",onClick:()=>{_()||o(`/watch/${a.showId}/${a.episodeNumber}`)},children:l}),n("div",{className:r.episode,children:["Episode ",a.episodeNumber]})]}),n("button",{className:r.iconBtn,type:"button",onClick:()=>{_()||P(a)},"aria-label":`Remove ${l} episode ${a.episodeNumber} from queue`,children:n(y,{name:"times"})})]})},ge=({title:a="Queue",eyebrow:x,items:p,currentShowId:P,currentEpisode:D,onRemove:B,onReorder:T,onNextQueue:w,onClear:_,showClearAll:R=!1,defaultExpanded:f=!0})=>{const[c,b]=s.useState([]),[o,i]=s.useState(null),[l,u]=s.useState(f),N=s.useRef(null),v=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{b(p)},[p]),s.useEffect(()=>{u(f)},[f]);const $=e=>{i(e)},k=e=>{if(o===null||o===e)return;const t=[...c],m=t[o];t.splice(o,1),t.splice(e,0,m),i(e),b(t)},A=()=>{o!==null&&T(c.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),i(null)},E=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&h.current&&(T(c.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),C.current=!0,window.setTimeout(()=>{C.current=!1},0)),N.current=null,v.current=null,h.current=!1,i(null)},Q=(e,t)=>{if(t.pointerType==="mouse")return;const m=t.currentTarget,g=t.pointerId;N.current=t.pointerId,v.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{h.current=!0,i(e);try{m.setPointerCapture(g)}catch{}},220)},S=e=>{if(e.pointerType==="mouse"||N.current!==e.pointerId)return;if(!h.current&&v.current){const H=Math.abs(e.clientX-v.current.x),G=Math.abs(e.clientY-v.current.y);(H>8||G>8)&&E(!1);return}if(!h.current)return;e.preventDefault();const m=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),g=m?Number(m.dataset.queueIndex):NaN;if(Number.isNaN(g)||o===null||g===o)return;const I=[...c],U=I[o];I.splice(o,1),I.splice(g,0,U),i(g),b(I)},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:r.section,children:[n("div",{className:r.header,children:[n("button",{className:r.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":l,"aria-label":l?`Collapse ${a}`:`Expand ${a}`,children:[n("span",{className:r.title,children:[n("span",{className:"title-stack",children:[x&&n("div",{className:"section-eyebrow",children:x}),n("span",{children:a})]}),n("span",{className:r.badge,children:c.length})]}),l?n(y,{name:"chevron-up"}):n(y,{name:"chevron-down"})]}),R&&_&&n("div",{className:r.headerActions,children:[w&&c.length>1&&n("button",{className:r.nextBtn,type:"button",onClick:w,children:"Next"}),n("button",{className:r.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),l&&n("div",{className:r.list,children:c.map((e,t)=>n(ue,{item:e,isActive:e.showId===P&&e.episodeNumber===D,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,r 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-
|
|
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-lz7FdOe_.js";import{L as F}from"./LibraryListPage-BT_xDjEq.js";import{u as _,M as z}from"./useMangaPopup-B_wRaMyP.js";import{M as D}from"./MangaResetProgressModal-Br5zqZ-U.js";import{x as G,d as O,o as Q,p as Y,u as q,y as H,z as K,A as V,M as R,m as Z,i as j,b as J,c as W}from"./useMangaLibrary-BacTdrw2.js";import"./vendor-icons-DrybRNxP.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-Beq4JL0b.js";import"./index-DlcgJVM6.js";import"./vendor-query-BBT5_sHx.js";import"./SkeletonGrid-pA-dcLBM.js";import"./ErrorMessage-DAxegITP.js";import"./LibraryListPage.module-r6k9nyT9.js";import"./usePopup-DS9jMzp6.js";import"./ResetProgressModal-0PvvM2XJ.js";import"./libraryInvalidation-DdnIPcOQ.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 Ra(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=G(r?"All":e,g,h),s=O(100),I=Q(),T=Y(),{toggle:L,bookmarkedIds:C}=q(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:M}=_(),f=H(),P=K(),B=V(),S=w(()=>r?(s.data?.data??[]).map(a=>{const o=a.page??0,l=a.pageCount??0;return{key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title||"",altTitle:a.altTitle,cover:a.cover||"",status:a.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]),A=r?s.data?.total??0:n.data?.total??0,$=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...R],entries:S,total:A,isLoading:$,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)=>f.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:J(a.provider,a.cover),chapterBadge:a.chapterLabel??null,isAdult:j(a)},linkTo:a.detailTarget,hoverIcon:"book",progress:a.progressPercent!==void 0&&a.progressLabel?{percent:a.progressPercent,label:a.progressLabel}:void 0,showProgress:r,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:r?()=>u(a):void 0,onOpenDetails:o=>k(o,y(a)),onPopupHoverIntent:o=>o?m():c(),rawThumbnail:!0}),modals:i(E,{children:[t&&t.data.provider&&i(z,{data:t.data,anchorRect:t.rect,bookmarked:C.has(Z(t.data.provider,t.data.mangaId)),onToggleBookmark:()=>L({id:t.data.mangaId,provider:t.data.provider,title:t.data.title,cover:t.data.cover,altTitle:t.data.altTitle??void 0,contentRating:t.data.contentRating}),onMouseEnter:m,onMouseLeave:c,onRequestClose:M}),i(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{Ra as default};
|
package/client/dist/assets/{ResetProgressModal-6X8ciSFl.js → ResetProgressModal-0PvvM2XJ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as f,h as u,u as e}from"./vendor-core-DfaOB3Rn.js";import{M as a,B as c}from"./index-
|
|
1
|
+
import{d as f,h as u,u as e}from"./vendor-core-DfaOB3Rn.js";import{M as a,B as c}from"./index-DlcgJVM6.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 x,p as pe,a as fe,d as o,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{P as ae}from"./MediaCard-
|
|
1
|
+
import{h as x,p as pe,a as fe,d as o,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{P as ae}from"./MediaCard-lz7FdOe_.js";import{A as Ae}from"./AnimeCard-BxhPLWBG.js";import{S as Se}from"./SkeletonGrid-pA-dcLBM.js";import{t as ye,u as be,x as Ne,R as te,B as _,U as Te}from"./index-DlcgJVM6.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{A as Ee}from"./ActiveFilterChips-olGfwxle.js";import{s as t}from"./Search.module-C_qwCdHS.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-Beq4JL0b.js";import"./useAnimeInfoData-tcGkDs2b.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-B8xuoYlH.js";import"./playbackCompletion-IPHm9fp5.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"}],De=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],Pe=[{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 We(){x(()=>{document.title="Search - dango"},[]);const[r,le]=pe(),se=fe(),[m,B]=o(r.get("query")||""),[v,G]=o(parseInt(r.get("page")||"1")),[d,g]=o(r.get("type")||"ALL"),[L,A]=o(r.get("season")||"ALL"),[S,y]=o(r.get("year")||"ALL"),[Y,R]=o(r.get("country")||"ALL"),[k,re]=o(r.get("provider")||"anilist"),[U,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[$,D]=o(r.get("status")||""),[b,ne]=o(!1),[ie,F]=o(null);x(()=>{let e=!1;return ye.data.anilistStatus.query().then(s=>{e||F(s.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:oe}=be(),P=ge(null),{data:ce}=Ne(),M=ce?.genres||[],[N,T]=o(()=>{const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],n=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return s.forEach(l=>l&&(e[l]="include")),n.forEach(l=>l&&(e[l]="exclude")),e}),V=new URLSearchParams(r);V.delete("page");const j=V.toString(),{data:p=[],isLoading:C,isError:ue,error:de}=te(j,v,14),{data:q}=te(j,v+1,14),[O,he]=o(!1),E=Le.useMemo(()=>k==="anilist"&&d==="ADULT"||O?p:p.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[p,O,k,d]);x(()=>{B(r.get("query")||""),g(r.get("type")||"ALL"),A(r.get("season")||"ALL"),y(r.get("year")||"ALL"),R(r.get("country")||"ALL"),re(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),G(parseInt(r.get("page")||"1"));const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],n=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];s.forEach(l=>l&&(e[l]="include")),n.forEach(l=>l&&(e[l]="exclude")),T(e)},[r]);const c=(e=1,s={})=>{Te();const n=s.type??d,l=s.status??$,W=s.season??L,J=s.year??S,K=s.country??Y,Q=s.sort??U,X=s.genreState??N,ve=s.showMature??O,i=new URLSearchParams;m.trim()&&i.set("query",m.trim()),n!=="ALL"&&i.set("type",n),l&&i.set("status",l),W!=="ALL"&&i.set("season",W),J!=="ALL"&&i.set("year",J),K!=="ALL"&&i.set("country",K),Q!=="POPULARITY_DESC"&&i.set("sortBy",Q);const Z=Object.entries(X).filter(([,u])=>u==="include").map(([u])=>u),ee=Object.entries(X).filter(([,u])=>u==="exclude").map(([u])=>u);Z.length>0&&i.set("genres",Z.join(",")),ee.length>0&&i.set("excludeGenres",ee.join(",")),n!=="ADULT"&&!ve&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),le(i),e!==v&&G(e)},z=e=>{if(c(e),P.current){const s=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:s,behavior:"smooth"})}},w=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:w-1980+1},(e,s)=>({value:String(w-s),label:String(w-s)}))],H=p.length>=14&&q&&q.length>0,h=[];d!=="ALL"&&h.push({key:"type",label:`Type: ${d}`,onRemove:()=>{g("ALL"),c(1,{type:"ALL"})}}),L!=="ALL"&&h.push({key:"season",label:`Season: ${L}`,onRemove:()=>{A("ALL"),c(1,{season:"ALL"})}}),S!=="ALL"&&h.push({key:"year",label:`Year: ${S}`,onRemove:()=>{y("ALL"),c(1,{year:"ALL"})}});for(const[e,s]of Object.entries(N))h.push({key:e,label:s==="include"?`+ ${e}`:`-${e}`,tone:s==="include"?"primary":"danger",onRemove:()=>{const n={...N};delete n[e],T(n),c(1,{genreState:n})}});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:m,onInput:e=>B(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(_,{onClick:()=>c(),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:d,onChange:e=>{if(e.currentTarget.value==="ADULT"){se("/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:$,onChange:e=>D(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:Y,onChange:e=>R(e.currentTarget.value),children:De.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:U,onChange:e=>I(e.currentTarget.value),children:Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),M.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:M.map(e=>a("button",{className:`${t.genreButton} ${t[N[e]||""]}`,onClick:()=>{T(s=>{const n=s[e],l={...s};return n==="include"?l[e]="exclude":n==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(_,{variant:"secondary",onClick:()=>{T({}),g("ALL"),A("ALL"),y("ALL"),R("ALL"),I("POPULARITY_DESC"),D(""),he(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(_,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ue&&a(Ce,{message:de?.message||"Error"}),h.length>0&&a(Ee,{chips:h}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:m?`Search Results for "${m}"`:"Discover Anime"}),E.length>0&&a(ae,{page:v,canGoNext:H,onChange:z,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${oe?t.lowEnd:""}`,children:C?a(Se,{}):E.map(e=>a(Ae,{anime:e},e._id))}),!C&&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(ae,{page:v,canGoNext:H,onChange:z,isLoading:C,variant:"labeled"})})]})}export{We as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as s,A as j,h as O,u as e,q as le,S as Ne,T as Te,p as Ie,g as ue,_ as Le}from"./vendor-core-DfaOB3Rn.js";import{d as Re,D as pe,t as b,B as T,M as q,k as fe,i as xe,A as he,H as V,q as $,I as ge,J as Pe,K as De,T as Ae,u as Oe,e as Ge,L as Me,C as ne,V as ze,N as Ue}from"./index-D0DdVatn.js";import{u as ce}from"./vendor-query-BBT5_sHx.js";import{T as K}from"./ToggleSwitch-CN_ppEc9.js";import{I as X}from"./vendor-icons-DrybRNxP.js";const se={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},re=["name","nativeName","englishName"],ie={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ee=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Re(),c=pe(),[l,y]=s(ie[t]),[v,m]=s(!1),a=j(null);O(()=>{o||y(ie[t])},[t,o]);const i=async()=>{if(v)return;m(!0);const p=(re.indexOf(t)+1)%re.length,d=re[p],I=ie[d];a.current&&(a.current.style.transform="translateX(-100%)",a.current.style.opacity="0"),setTimeout(async()=>{y(I),r(d),a.current&&(a.current.style.transition="none",a.current.style.transform="translateX(100%)",a.current.style.opacity="0",a.current.offsetWidth,a.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",a.current.style.transform="translateX(0)",a.current.style.opacity="1");try{await c.mutateAsync({key:"titlePreference",value:d})}catch(h){console.error("Error saving title preference:",h)}finally{m(!1)}},300)};return o?e("p",{children:"Loading title preference..."}):e("div",{className:se["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:i,className:se["toggle-button"],disabled:v,children:e("span",{ref:a,className:se["toggle-label"],children:l})})]})},qe="_settingsHeader_ik3bf_1",Fe="_pageTitle_ik3bf_6",Ke="_pageSubtitle_ik3bf_14",$e="_settingsLayout_ik3bf_20",He="_sidebar_ik3bf_27",We="_sidebarIndicator_ik3bf_35",Be="_sidebarItem_ik3bf_50",Ve="_active_ik3bf_72",je="_mainContent_ik3bf_80",Qe="_tabContent_ik3bf_85",Ye="_settingItem_ik3bf_103",Je="_controls_ik3bf_108",Xe="_status_ik3bf_114",S={settingsHeader:qe,pageTitle:Fe,pageSubtitle:Ke,settingsLayout:$e,sidebar:He,sidebarIndicator:We,sidebarItem:Be,active:Ve,mainContent:je,tabContent:Qe,settingItem:Ye,controls:Je,status:Xe},Ze="_title_tm30b_11",et="_signIn_tm30b_18",tt="_userInfo_tm30b_25",at="_warning_tm30b_47",nt="_formGroup_tm30b_54",st="_label_tm30b_58",rt="_inputWrapper_tm30b_68",it="_input_tm30b_68",ot="_select_tm30b_92",lt="_actions_tm30b_109",ct="_hr_tm30b_117",g={title:Ze,signIn:et,userInfo:tt,warning:at,formGroup:nt,label:st,inputWrapper:rt,input:it,select:ot,actions:lt,hr:ct},dt="_sectionCard_1axuo_1",ut="_dangerCard_1axuo_23",ht="_settingRow_1axuo_31",N={sectionCard:dt,dangerCard:ut,settingRow:ht},gt=()=>{const[t,r]=s(!0),[o,c]=s(!1),[l,y]=s(!1),[v,m]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[d,I]=s(""),[h,k]=s(!1),L=j(null),[R,x]=s({show:!1,message:"",type:"info"}),A=()=>{L.current&&(window.clearInterval(L.current),L.current=null)},w=le(f=>{y(f.authenticated),m(f.user||f.device.user||null),i(f.device),p(!!f.hasCustomClientId)},[]),C=le(async()=>{const f=await b.auth.githubStatus.query();w(f)},[w]),G=async()=>{try{const f=await b.auth.githubPoll.query();i(f),f.status==="success"?(A(),await C(),x({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(A(),x({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{A(),x({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},z=(f=5)=>{A(),L.current=window.setInterval(G,Math.max(f,5)*1e3)};O(()=>(C().catch(()=>{x({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),A),[C]);const _=async()=>{c(!0);try{const f=await b.auth.githubStart.mutate();i(f),z(f.verification?.interval)}catch(f){x({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},D=async()=>{try{await b.auth.githubLogout.mutate(),y(!1),m(null),i({status:"idle"}),x({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{x({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},U=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:d}),I(""),await C(),x({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},W=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),I(""),await C(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"GitHub Cloud Sync"}),e("p",{className:g.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),l&&v?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:v.name||v.login})]}),e(T,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:g.signIn,children:e(T,{onClick:_,disabled:o||a.status==="pending",children:o||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(Ne,{children:[e("hr",{className:g.hr}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Verification URL"}),e("div",{className:g.inputWrapper,children:[e("input",{className:g.input,value:a.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=a.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Device Code"}),e("input",{className:g.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:g.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 ",u?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:d,onChange:f=>I(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:U,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:W,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:R.show,onClose:()=>x(f=>({...f,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:R.message})}),e(q.Actions,{children:e(T,{onClick:()=>x(f=>({...f,show:!1})),children:"OK"})})]})]})},mt=()=>{const[t,r]=s(!0),[o,c]=s(null),[l,y]=s(!1),[v,m]=s(!1),[a,i]=s(""),[u,p]=s(""),[d,I]=s(""),[h,k]=s(!1),[L,R]=s({show:!1,message:"",type:"info"}),x=async()=>{try{const D=await b.auth.user.query();c(D?.email?D:null)}catch{c(null)}},A=async()=>{try{const[_,D]=await Promise.all([b.auth.configStatus.query(),b.auth.googleAuth.query()]);y(!!_.hasConfig),m(!!(D.hasCustomWorkerUrl||D.hasCustomClientId||D.hasClientSecret))}catch(_){console.error("Failed to fetch config status",_)}};O(()=>{(async()=>{r(!0),await Promise.all([x(),A()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await x(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const D=U=>{U.origin===window.location.origin&&typeof U.data=="object"&&U.data!==null&&U.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(U.data.user),window.location.reload())};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[]);const w=async()=>{try{const _=await b.auth.googleLogin.mutate();if(_.authenticated){window.location.reload();return}if(_.url){if(typeof window.DangoBridge<"u"){window.location.href=_.url;return}const U=600,W=700,f=window.innerWidth/2-U/2,Z=window.innerHeight/2-W/2;window.open(_.url,"GoogleAuth",`width=${U},height=${W},top=${Z},left=${f}`)}else throw new Error("Auth URL not available")}catch{R({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await b.auth.logout.mutate(),c(null),R({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(_){console.error("Sign out failed",_),R({show:!0,message:"Failed to sign out.",type:"error"})}},G=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:u,clientSecret:d}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{R({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},z=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{R({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"Google Drive Sync"}),o?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:o.name})," (",o.email,")"]}),e(T,{variant:"danger",onClick:C,children:"Sign Out"})]}):e("div",{className:g.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:w,disabled:!l,children:"Sign in with Google"}),!l&&e("p",{className:g.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 ",v?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Worker URL (optional)"}),e("input",{className:g.input,value:a,onChange:_=>i(_.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:u,onChange:_=>p(_.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:g.input,value:d,onChange:_=>I(_.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:g.actions,children:[e(T,{onClick:G,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:z,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:L.show,onClose:()=>R(_=>({..._,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:L.message})}),e(q.Actions,{children:e(T,{onClick:()=>R(_=>({..._,show:!1})),children:"OK"})})]})]})},pt="_settingItem_3qq0n_1",ft="_modalOverlay_3qq0n_6",yt="_modal_3qq0n_6",vt="_modalActions_3qq0n_41",bt="_modalSecondary_3qq0n_47",wt="_modalPrimary_3qq0n_57",H={settingItem:pt,modalOverlay:ft,modal:yt,modalActions:vt,modalSecondary:bt,modalPrimary:wt},kt={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"]]}},Ct=(t,r)=>{if(t==null)return r;const o=String(t);return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:r},me=(t,r,o)=>{const[c,l]=s(r),[y,v]=s(!1),m=ce();return O(()=>{(async()=>{try{const u=await b.settings.getByKey.query({key:t});l(Ct(u.value,r))}catch(u){console.error("Failed to fetch setting",u)}})()},[t,r]),{value:c,setValue:l,isUpdating:y,toggle:async()=>{if(y)return;v(!0);const i=!c;l(i);try{await b.settings.set.mutate({key:t,value:i});for(const u of o)m.invalidateQueries({queryKey:u})}catch(u){console.error("Error saving setting:",u),l(!i)}finally{v(!1)}}}},St=()=>{const{contentType:t}=fe(),r=kt[t],[o,c]=s(!1),[l,y]=s(!0),[v,m]=s(!1),a=me(r.ignoreKey,!0,r.invalidateKeys),i=me(r.listOnlyKey,!1,r.invalidateKeys),[u,p]=s(null),[d,I]=s(!1),h=ce(),k=xe();O(()=>{y(!0),(async()=>{try{const C=await b.settings.getByKey.query({key:r.skipKey});String(C.value)==="true"||String(C.value)==="1"?c(!0):c(!1)}catch(C){console.error("Failed to fetch setting",C)}finally{y(!1)}})()},[r.skipKey]);const L=async()=>{if(v)return;m(!0);const w=!o;c(w);try{await b.settings.set.mutate({key:r.skipKey,value:w})}catch(C){console.error("Error saving setting:",C),c(!w)}finally{m(!1)}},R=async()=>{if(!a.isUpdating){if(a.value)try{let w;if(t==="anime"?w=(await b.continueWatching.adultCount.query()).count:t==="manga"?w=(await b.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await b.asmrProgress.adultCount.query()).count:w=(await b.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){p(w);return}}catch(w){console.error("Failed to fetch adult count",w)}a.toggle()}},x=()=>{p(null),a.toggle()},A=async()=>{if(!d){I(!0);try{let w;t==="anime"?w=(await b.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await b.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await b.asmrProgress.purgeAdult.mutate()).removed:w=(await b.tvProgress.purgeAdult.mutate()).removed,he.success(r.purgeDoneText(w??0));for(const C of r.invalidateKeys)h.invalidateQueries({queryKey:C});t==="anime"&&h.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&h.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&h.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&h.invalidateQueries(k.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),he.error("Failed to remove adult entries")}finally{I(!1),p(null)}a.toggle()}};return l?e("div",{children:"Loading settings..."}):e("div",{className:N.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(K,{isChecked:o,onChange:L,id:"skip-confirmation-toggle",disabled:v})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(K,{isChecked:a.value,onChange:R,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(K,{isChecked:i.value,onChange:i.toggle,id:"cw-watchlist-only-toggle",disabled:i.isUpdating})]})}),u!==null&&e("div",{className:H.modalOverlay,onClick:()=>p(null),children:e("div",{className:H.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[u," adult ",u===1?"entry":"entries"," not in your"," ",r.listNoun," ",u===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",u===1?"it":"them"," from the database instead of showing ",u===1?"it":"them","."]}),e("div",{className:H.modalActions,children:[e("button",{type:"button",className:H.modalSecondary,onClick:x,disabled:d,children:"Show them"}),e("button",{type:"button",className:H.modalPrimary,onClick:A,disabled:d,children:d?"Purging...":`Purge ${u}`})]})]})})]})},_t="_statsGrid_o4nf0_1",Nt="_statCard_o4nf0_8",Tt="_statLabel_o4nf0_18",It="_statValue_o4nf0_26",Lt="_statMeta_o4nf0_32",Rt="_statusBanner_o4nf0_38",xt="_statusSuccess_o4nf0_49",Pt="_statusUpdating_o4nf0_55",Dt="_statusError_o4nf0_61",At="_sha_o4nf0_67",Ot="_settingItem_o4nf0_74",Gt="_settingTitle_o4nf0_79",Mt="_settingSubtitle_o4nf0_85",zt="_actionsRow_o4nf0_92",P={statsGrid:_t,statCard:Nt,statLabel:Tt,statValue:It,statMeta:Lt,statusBanner:Rt,statusSuccess:xt,statusUpdating:Pt,statusError:Dt,sha:At,settingItem:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:zt},Ut=()=>{const[t,r]=s(null),[o,c]=s(!0),[l,y]=s(!1),[v,m]=s(!1),a=j(null),i=async()=>{try{const h=await b.settings.offlineDbInfo.query();return r(h),h}catch(h){console.error("Failed to fetch offline DB info:",h)}finally{c(!1)}return null};O(()=>(i(),()=>{a.current&&window.clearInterval(a.current)}),[]),O(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const h=await i();h&&!h.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const u=async()=>{if(!t||l)return;const h=!t.autoUpdateEnabled;y(!0),r({...t,autoUpdateEnabled:h});try{await b.settings.setOfflineDbAutoUpdate.mutate({enabled:h})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!h})}finally{y(!1)}},p=async()=>{if(!(t?.isRefreshing||v)){m(!0);try{await b.settings.triggerOfflineDbUpdate.mutate(),r(h=>h?{...h,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(h){console.error("Failed to trigger offline DB update:",h)}finally{m(!1)}}},d=h=>{if(!h)return"Never";try{return new Date(h).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return h}},I=t?.isRefreshing||v;return e("div",{className:N.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:P.statsGrid,children:[e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"MAL Mapped"}),e("span",{className:P.statValue,children:o?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Release"}),e("span",{className:P.statMeta,children:o?"-":t?.releaseTag??"Never"})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Checked"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastCheckedAt??null)})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Updated"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${P.statusBanner} ${t.lastStatus==="failed"?P.statusError:t.lastStatus==="updating"?P.statusUpdating:P.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:P.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:P.settingItem,children:e("div",{className:N.settingRow,children:[e("div",{children:[e("span",{className:P.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:P.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(K,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:u,disabled:o||l})]})}),e("div",{className:P.actionsRow,children:e(T,{onClick:p,disabled:o||I,children:I?"Updating Database...":"Update Offline Database Now"})})]})},Et="_status_1wbo0_1",qt="_warningText_1wbo0_7",Ft="_ackLabel_1wbo0_11",oe={status:Et,warningText:qt,ackLabel:Ft},Kt=()=>{const t=ce(),[r,o]=s(!1),[c,l]=s(!1),[y,v]=s(!1),[m,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{y||(o(!1),l(!1))},p=async()=>{if(!(!c||y)){v(!0),a("");try{const d=await V("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),I=await d.json();if(!d.ok)throw new Error(I.error||"Failed to clear database");const h=I.deleted,k=I.deletedManga,L=I.deletedTv,R=I.deletedAsmr,x=Object.values(h).reduce((G,z)=>G+(z||0),0)+Object.values(k??{}).reduce((G,z)=>G+(z||0),0)+Object.values(L??{}).reduce((G,z)=>G+(z||0),0)+Object.values(R??{}).reduce((G,z)=>G+(z||0),0),A=(k?.manga_library??0)+(k?.manga_progress??0),w=(L?.tv_library??0)+(L?.tv_progress??0),C=(R?.asmr_library??0)+(R?.asmr_progress??0);a(`Library cleared - ${h.watchlist??0} watchlist entries, ${A} manga rows, ${w} TV rows, ${C} ASMR rows and ${x} total rows removed.`),t.invalidateQueries({queryKey:[$.watchlist]}),t.invalidateQueries({queryKey:[$.continueWatching]}),t.invalidateQueries({queryKey:[$.mangaLibrary]}),t.invalidateQueries({queryKey:[$.mangaContinueReading]}),t.invalidateQueries({queryKey:[$.tvLibrary]}),t.invalidateQueries({queryKey:[$.tvContinueWatching]}),t.invalidateQueries({queryKey:[$.asmrLibrary]}),t.invalidateQueries({queryKey:[$.asmrContinueListening]}),o(!1)}catch(d){a(d.message)}finally{v(!1),l(!1)}}};return e("div",{className:`${N.sectionCard} ${N.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(T,{variant:"danger",onClick:i,children:"Clear Library Data"}),m&&e("p",{className:oe.status,children:m}),e(q,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e(q.Body,{children:[e("p",{className:oe.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:oe.ackLabel,children:[e("input",{type:"checkbox",checked:c,onChange:d=>l(d.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(q.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:y,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!c||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},$t=()=>{const[t,r]=s(""),[o,c]=s([]),[l,y]=s(null),[v,m]=s(!0),[a,i]=s({show:!1,message:"",type:"info"}),u=async()=>{try{m(!0);const d=await b.auth.rcloneSettings.query();r(d.remote||""),c(d.availableRemotes||[]),y(d.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{m(!1)}};O(()=>{u()},[]);const p=async()=>{try{await b.auth.saveRclone.mutate({remote:t}),i({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),u()}catch{i({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return v?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"Rclone Cloud Sync"}),e("p",{className:g.signIn,children:"Configure which Rclone remote to use for database synchronization."}),l?e("div",{className:g.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:l})]})}):e("p",{className:g.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Remote Name"}),e("div",{className:g.inputWrapper,children:e("select",{className:g.select,value:t,onChange:d=>r(d.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),o.map(d=>e("option",{value:d,children:d},d)),t&&!o.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:g.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:g.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e(q,{isOpen:a.show,onClose:()=>i(d=>({...d,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:a.message})}),e(q.Actions,{children:e(T,{onClick:()=>i(d=>({...d,show:!1})),children:"OK"})})]})]})},Ht=()=>{const[t,r]=s(null),[o,c]=s(!0),l=async()=>{try{const a=await b.auth.syncSettings.query();r(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{c(!1)}};O(()=>{l()},[]);const y=async a=>{const i=a.currentTarget.value;try{const u=await b.auth.saveSyncProvider.mutate({provider:i});r(p=>p?{...p,activeProvider:u.activeProvider}:null),await l(),ge.success(`Sync provider updated to ${i==="default"?"Default Order":i}`)}catch{ge.error("Failed to update sync provider")}};if(o||!t)return null;const v=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&v.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&v.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&v.push({value:"rclone",label:"Rclone"}),v.push({value:"none",label:"None (Local Only)"});const m=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:N.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:m(t.actualActiveProvider)})]}),e("div",{className:N.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:y,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:v.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function Wt(){return"javascript:"+encodeURIComponent(`(function(){
|
|
1
|
+
import{d as s,A as j,h as O,u as e,q as le,S as Ne,T as Te,p as Ie,g as ue,_ as Le}from"./vendor-core-DfaOB3Rn.js";import{d as Re,D as pe,t as b,B as T,M as q,k as fe,i as xe,A as he,H as V,q as $,I as ge,J as Pe,K as De,T as Ae,u as Oe,e as Ge,L as Me,C as ne,V as ze,N as Ue}from"./index-DlcgJVM6.js";import{u as ce}from"./vendor-query-BBT5_sHx.js";import{T as K}from"./ToggleSwitch-CN_ppEc9.js";import{I as X}from"./vendor-icons-DrybRNxP.js";const se={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},re=["name","nativeName","englishName"],ie={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ee=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Re(),c=pe(),[l,y]=s(ie[t]),[v,m]=s(!1),a=j(null);O(()=>{o||y(ie[t])},[t,o]);const i=async()=>{if(v)return;m(!0);const p=(re.indexOf(t)+1)%re.length,d=re[p],I=ie[d];a.current&&(a.current.style.transform="translateX(-100%)",a.current.style.opacity="0"),setTimeout(async()=>{y(I),r(d),a.current&&(a.current.style.transition="none",a.current.style.transform="translateX(100%)",a.current.style.opacity="0",a.current.offsetWidth,a.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",a.current.style.transform="translateX(0)",a.current.style.opacity="1");try{await c.mutateAsync({key:"titlePreference",value:d})}catch(h){console.error("Error saving title preference:",h)}finally{m(!1)}},300)};return o?e("p",{children:"Loading title preference..."}):e("div",{className:se["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:i,className:se["toggle-button"],disabled:v,children:e("span",{ref:a,className:se["toggle-label"],children:l})})]})},qe="_settingsHeader_ik3bf_1",Fe="_pageTitle_ik3bf_6",Ke="_pageSubtitle_ik3bf_14",$e="_settingsLayout_ik3bf_20",He="_sidebar_ik3bf_27",We="_sidebarIndicator_ik3bf_35",Be="_sidebarItem_ik3bf_50",Ve="_active_ik3bf_72",je="_mainContent_ik3bf_80",Qe="_tabContent_ik3bf_85",Ye="_settingItem_ik3bf_103",Je="_controls_ik3bf_108",Xe="_status_ik3bf_114",S={settingsHeader:qe,pageTitle:Fe,pageSubtitle:Ke,settingsLayout:$e,sidebar:He,sidebarIndicator:We,sidebarItem:Be,active:Ve,mainContent:je,tabContent:Qe,settingItem:Ye,controls:Je,status:Xe},Ze="_title_tm30b_11",et="_signIn_tm30b_18",tt="_userInfo_tm30b_25",at="_warning_tm30b_47",nt="_formGroup_tm30b_54",st="_label_tm30b_58",rt="_inputWrapper_tm30b_68",it="_input_tm30b_68",ot="_select_tm30b_92",lt="_actions_tm30b_109",ct="_hr_tm30b_117",g={title:Ze,signIn:et,userInfo:tt,warning:at,formGroup:nt,label:st,inputWrapper:rt,input:it,select:ot,actions:lt,hr:ct},dt="_sectionCard_1axuo_1",ut="_dangerCard_1axuo_23",ht="_settingRow_1axuo_31",N={sectionCard:dt,dangerCard:ut,settingRow:ht},gt=()=>{const[t,r]=s(!0),[o,c]=s(!1),[l,y]=s(!1),[v,m]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[d,I]=s(""),[h,k]=s(!1),L=j(null),[R,x]=s({show:!1,message:"",type:"info"}),A=()=>{L.current&&(window.clearInterval(L.current),L.current=null)},w=le(f=>{y(f.authenticated),m(f.user||f.device.user||null),i(f.device),p(!!f.hasCustomClientId)},[]),C=le(async()=>{const f=await b.auth.githubStatus.query();w(f)},[w]),G=async()=>{try{const f=await b.auth.githubPoll.query();i(f),f.status==="success"?(A(),await C(),x({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(A(),x({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{A(),x({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},z=(f=5)=>{A(),L.current=window.setInterval(G,Math.max(f,5)*1e3)};O(()=>(C().catch(()=>{x({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),A),[C]);const _=async()=>{c(!0);try{const f=await b.auth.githubStart.mutate();i(f),z(f.verification?.interval)}catch(f){x({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},D=async()=>{try{await b.auth.githubLogout.mutate(),y(!1),m(null),i({status:"idle"}),x({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{x({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},U=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:d}),I(""),await C(),x({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},W=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),I(""),await C(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"GitHub Cloud Sync"}),e("p",{className:g.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),l&&v?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:v.name||v.login})]}),e(T,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:g.signIn,children:e(T,{onClick:_,disabled:o||a.status==="pending",children:o||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(Ne,{children:[e("hr",{className:g.hr}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Verification URL"}),e("div",{className:g.inputWrapper,children:[e("input",{className:g.input,value:a.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=a.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Device Code"}),e("input",{className:g.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:g.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 ",u?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:d,onChange:f=>I(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:U,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:W,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:R.show,onClose:()=>x(f=>({...f,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:R.message})}),e(q.Actions,{children:e(T,{onClick:()=>x(f=>({...f,show:!1})),children:"OK"})})]})]})},mt=()=>{const[t,r]=s(!0),[o,c]=s(null),[l,y]=s(!1),[v,m]=s(!1),[a,i]=s(""),[u,p]=s(""),[d,I]=s(""),[h,k]=s(!1),[L,R]=s({show:!1,message:"",type:"info"}),x=async()=>{try{const D=await b.auth.user.query();c(D?.email?D:null)}catch{c(null)}},A=async()=>{try{const[_,D]=await Promise.all([b.auth.configStatus.query(),b.auth.googleAuth.query()]);y(!!_.hasConfig),m(!!(D.hasCustomWorkerUrl||D.hasCustomClientId||D.hasClientSecret))}catch(_){console.error("Failed to fetch config status",_)}};O(()=>{(async()=>{r(!0),await Promise.all([x(),A()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await x(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const D=U=>{U.origin===window.location.origin&&typeof U.data=="object"&&U.data!==null&&U.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(U.data.user),window.location.reload())};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[]);const w=async()=>{try{const _=await b.auth.googleLogin.mutate();if(_.authenticated){window.location.reload();return}if(_.url){if(typeof window.DangoBridge<"u"){window.location.href=_.url;return}const U=600,W=700,f=window.innerWidth/2-U/2,Z=window.innerHeight/2-W/2;window.open(_.url,"GoogleAuth",`width=${U},height=${W},top=${Z},left=${f}`)}else throw new Error("Auth URL not available")}catch{R({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await b.auth.logout.mutate(),c(null),R({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(_){console.error("Sign out failed",_),R({show:!0,message:"Failed to sign out.",type:"error"})}},G=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:u,clientSecret:d}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{R({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},z=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),I(""),await A(),R({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{R({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"Google Drive Sync"}),o?e("div",{className:g.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:o.name})," (",o.email,")"]}),e(T,{variant:"danger",onClick:C,children:"Sign Out"})]}):e("div",{className:g.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:w,disabled:!l,children:"Sign in with Google"}),!l&&e("p",{className:g.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 ",v?"(override active)":""]}),e("div",{className:g.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:g.label,children:"Worker URL (optional)"}),e("input",{className:g.input,value:a,onChange:_=>i(_.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client ID (optional)"}),e("input",{className:g.input,value:u,onChange:_=>p(_.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:g.input,value:d,onChange:_=>I(_.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:g.actions,children:[e(T,{onClick:G,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:z,disabled:h,children:"Use dango defaults"})]})]}),e(q,{isOpen:L.show,onClose:()=>R(_=>({..._,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:L.message})}),e(q.Actions,{children:e(T,{onClick:()=>R(_=>({..._,show:!1})),children:"OK"})})]})]})},pt="_settingItem_3qq0n_1",ft="_modalOverlay_3qq0n_6",yt="_modal_3qq0n_6",vt="_modalActions_3qq0n_41",bt="_modalSecondary_3qq0n_47",wt="_modalPrimary_3qq0n_57",H={settingItem:pt,modalOverlay:ft,modal:yt,modalActions:vt,modalSecondary:bt,modalPrimary:wt},kt={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"]]}},Ct=(t,r)=>{if(t==null)return r;const o=String(t);return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:r},me=(t,r,o)=>{const[c,l]=s(r),[y,v]=s(!1),m=ce();return O(()=>{(async()=>{try{const u=await b.settings.getByKey.query({key:t});l(Ct(u.value,r))}catch(u){console.error("Failed to fetch setting",u)}})()},[t,r]),{value:c,setValue:l,isUpdating:y,toggle:async()=>{if(y)return;v(!0);const i=!c;l(i);try{await b.settings.set.mutate({key:t,value:i});for(const u of o)m.invalidateQueries({queryKey:u})}catch(u){console.error("Error saving setting:",u),l(!i)}finally{v(!1)}}}},St=()=>{const{contentType:t}=fe(),r=kt[t],[o,c]=s(!1),[l,y]=s(!0),[v,m]=s(!1),a=me(r.ignoreKey,!0,r.invalidateKeys),i=me(r.listOnlyKey,!1,r.invalidateKeys),[u,p]=s(null),[d,I]=s(!1),h=ce(),k=xe();O(()=>{y(!0),(async()=>{try{const C=await b.settings.getByKey.query({key:r.skipKey});String(C.value)==="true"||String(C.value)==="1"?c(!0):c(!1)}catch(C){console.error("Failed to fetch setting",C)}finally{y(!1)}})()},[r.skipKey]);const L=async()=>{if(v)return;m(!0);const w=!o;c(w);try{await b.settings.set.mutate({key:r.skipKey,value:w})}catch(C){console.error("Error saving setting:",C),c(!w)}finally{m(!1)}},R=async()=>{if(!a.isUpdating){if(a.value)try{let w;if(t==="anime"?w=(await b.continueWatching.adultCount.query()).count:t==="manga"?w=(await b.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await b.asmrProgress.adultCount.query()).count:w=(await b.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){p(w);return}}catch(w){console.error("Failed to fetch adult count",w)}a.toggle()}},x=()=>{p(null),a.toggle()},A=async()=>{if(!d){I(!0);try{let w;t==="anime"?w=(await b.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await b.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await b.asmrProgress.purgeAdult.mutate()).removed:w=(await b.tvProgress.purgeAdult.mutate()).removed,he.success(r.purgeDoneText(w??0));for(const C of r.invalidateKeys)h.invalidateQueries({queryKey:C});t==="anime"&&h.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&h.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&h.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&h.invalidateQueries(k.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),he.error("Failed to remove adult entries")}finally{I(!1),p(null)}a.toggle()}};return l?e("div",{children:"Loading settings..."}):e("div",{className:N.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(K,{isChecked:o,onChange:L,id:"skip-confirmation-toggle",disabled:v})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(K,{isChecked:a.value,onChange:R,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:H.settingItem,children:e("div",{className:N.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(K,{isChecked:i.value,onChange:i.toggle,id:"cw-watchlist-only-toggle",disabled:i.isUpdating})]})}),u!==null&&e("div",{className:H.modalOverlay,onClick:()=>p(null),children:e("div",{className:H.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[u," adult ",u===1?"entry":"entries"," not in your"," ",r.listNoun," ",u===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",u===1?"it":"them"," from the database instead of showing ",u===1?"it":"them","."]}),e("div",{className:H.modalActions,children:[e("button",{type:"button",className:H.modalSecondary,onClick:x,disabled:d,children:"Show them"}),e("button",{type:"button",className:H.modalPrimary,onClick:A,disabled:d,children:d?"Purging...":`Purge ${u}`})]})]})})]})},_t="_statsGrid_o4nf0_1",Nt="_statCard_o4nf0_8",Tt="_statLabel_o4nf0_18",It="_statValue_o4nf0_26",Lt="_statMeta_o4nf0_32",Rt="_statusBanner_o4nf0_38",xt="_statusSuccess_o4nf0_49",Pt="_statusUpdating_o4nf0_55",Dt="_statusError_o4nf0_61",At="_sha_o4nf0_67",Ot="_settingItem_o4nf0_74",Gt="_settingTitle_o4nf0_79",Mt="_settingSubtitle_o4nf0_85",zt="_actionsRow_o4nf0_92",P={statsGrid:_t,statCard:Nt,statLabel:Tt,statValue:It,statMeta:Lt,statusBanner:Rt,statusSuccess:xt,statusUpdating:Pt,statusError:Dt,sha:At,settingItem:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:zt},Ut=()=>{const[t,r]=s(null),[o,c]=s(!0),[l,y]=s(!1),[v,m]=s(!1),a=j(null),i=async()=>{try{const h=await b.settings.offlineDbInfo.query();return r(h),h}catch(h){console.error("Failed to fetch offline DB info:",h)}finally{c(!1)}return null};O(()=>(i(),()=>{a.current&&window.clearInterval(a.current)}),[]),O(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const h=await i();h&&!h.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const u=async()=>{if(!t||l)return;const h=!t.autoUpdateEnabled;y(!0),r({...t,autoUpdateEnabled:h});try{await b.settings.setOfflineDbAutoUpdate.mutate({enabled:h})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!h})}finally{y(!1)}},p=async()=>{if(!(t?.isRefreshing||v)){m(!0);try{await b.settings.triggerOfflineDbUpdate.mutate(),r(h=>h?{...h,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(h){console.error("Failed to trigger offline DB update:",h)}finally{m(!1)}}},d=h=>{if(!h)return"Never";try{return new Date(h).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return h}},I=t?.isRefreshing||v;return e("div",{className:N.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:P.statsGrid,children:[e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"MAL Mapped"}),e("span",{className:P.statValue,children:o?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Release"}),e("span",{className:P.statMeta,children:o?"-":t?.releaseTag??"Never"})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Checked"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastCheckedAt??null)})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Updated"}),e("span",{className:P.statMeta,children:o?"-":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${P.statusBanner} ${t.lastStatus==="failed"?P.statusError:t.lastStatus==="updating"?P.statusUpdating:P.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:P.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:P.settingItem,children:e("div",{className:N.settingRow,children:[e("div",{children:[e("span",{className:P.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:P.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(K,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:u,disabled:o||l})]})}),e("div",{className:P.actionsRow,children:e(T,{onClick:p,disabled:o||I,children:I?"Updating Database...":"Update Offline Database Now"})})]})},Et="_status_1wbo0_1",qt="_warningText_1wbo0_7",Ft="_ackLabel_1wbo0_11",oe={status:Et,warningText:qt,ackLabel:Ft},Kt=()=>{const t=ce(),[r,o]=s(!1),[c,l]=s(!1),[y,v]=s(!1),[m,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{y||(o(!1),l(!1))},p=async()=>{if(!(!c||y)){v(!0),a("");try{const d=await V("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),I=await d.json();if(!d.ok)throw new Error(I.error||"Failed to clear database");const h=I.deleted,k=I.deletedManga,L=I.deletedTv,R=I.deletedAsmr,x=Object.values(h).reduce((G,z)=>G+(z||0),0)+Object.values(k??{}).reduce((G,z)=>G+(z||0),0)+Object.values(L??{}).reduce((G,z)=>G+(z||0),0)+Object.values(R??{}).reduce((G,z)=>G+(z||0),0),A=(k?.manga_library??0)+(k?.manga_progress??0),w=(L?.tv_library??0)+(L?.tv_progress??0),C=(R?.asmr_library??0)+(R?.asmr_progress??0);a(`Library cleared - ${h.watchlist??0} watchlist entries, ${A} manga rows, ${w} TV rows, ${C} ASMR rows and ${x} total rows removed.`),t.invalidateQueries({queryKey:[$.watchlist]}),t.invalidateQueries({queryKey:[$.continueWatching]}),t.invalidateQueries({queryKey:[$.mangaLibrary]}),t.invalidateQueries({queryKey:[$.mangaContinueReading]}),t.invalidateQueries({queryKey:[$.tvLibrary]}),t.invalidateQueries({queryKey:[$.tvContinueWatching]}),t.invalidateQueries({queryKey:[$.asmrLibrary]}),t.invalidateQueries({queryKey:[$.asmrContinueListening]}),o(!1)}catch(d){a(d.message)}finally{v(!1),l(!1)}}};return e("div",{className:`${N.sectionCard} ${N.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(T,{variant:"danger",onClick:i,children:"Clear Library Data"}),m&&e("p",{className:oe.status,children:m}),e(q,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e(q.Body,{children:[e("p",{className:oe.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:oe.ackLabel,children:[e("input",{type:"checkbox",checked:c,onChange:d=>l(d.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(q.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:y,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!c||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},$t=()=>{const[t,r]=s(""),[o,c]=s([]),[l,y]=s(null),[v,m]=s(!0),[a,i]=s({show:!1,message:"",type:"info"}),u=async()=>{try{m(!0);const d=await b.auth.rcloneSettings.query();r(d.remote||""),c(d.availableRemotes||[]),y(d.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{m(!1)}};O(()=>{u()},[]);const p=async()=>{try{await b.auth.saveRclone.mutate({remote:t}),i({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),u()}catch{i({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return v?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:N.sectionCard,children:[e("h3",{className:g.title,children:"Rclone Cloud Sync"}),e("p",{className:g.signIn,children:"Configure which Rclone remote to use for database synchronization."}),l?e("div",{className:g.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:l})]})}):e("p",{className:g.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:g.formGroup,children:[e("label",{className:g.label,children:"Remote Name"}),e("div",{className:g.inputWrapper,children:e("select",{className:g.select,value:t,onChange:d=>r(d.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),o.map(d=>e("option",{value:d,children:d},d)),t&&!o.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:g.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:g.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e(q,{isOpen:a.show,onClose:()=>i(d=>({...d,show:!1})),width:"sm",children:[e(q.Body,{children:e("p",{children:a.message})}),e(q.Actions,{children:e(T,{onClick:()=>i(d=>({...d,show:!1})),children:"OK"})})]})]})},Ht=()=>{const[t,r]=s(null),[o,c]=s(!0),l=async()=>{try{const a=await b.auth.syncSettings.query();r(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{c(!1)}};O(()=>{l()},[]);const y=async a=>{const i=a.currentTarget.value;try{const u=await b.auth.saveSyncProvider.mutate({provider:i});r(p=>p?{...p,activeProvider:u.activeProvider}:null),await l(),ge.success(`Sync provider updated to ${i==="default"?"Default Order":i}`)}catch{ge.error("Failed to update sync provider")}};if(o||!t)return null;const v=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&v.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&v.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&v.push({value:"rclone",label:"Rclone"}),v.push({value:"none",label:"None (Local Only)"});const m=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:N.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:m(t.actualActiveProvider)})]}),e("div",{className:N.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:y,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:v.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function Wt(){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{
|