@serifpersia/dango 3.7.2 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-CoPx634q.js → AnimeCard-CBxkRKU-.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-COVCRujg.js → AnimeInfo-D3LmqzJo.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-BwlKpRXY.js → AnimeInfoPage-CeJHVkQ0.js} +2 -2
  5. package/client/dist/assets/{Asmr-nOUcDsWe.js → Asmr-CrHIKmJ4.js} +2 -2
  6. package/client/dist/assets/Asmr-Do89pEHG.css +1 -0
  7. package/client/dist/assets/{AsmrResetProgressModal-Mj1PYE2c.js → AsmrResetProgressModal-C13uw5lH.js} +1 -1
  8. package/client/dist/assets/{Home-wi0a_BDQ.js → Home-CC9XyO9O.js} +1 -1
  9. package/client/dist/assets/{Insights-MLCDyTnY.js → Insights-BZGAhYrz.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-CRqv737t.js → LibraryListPage-DosBFeR_.js} +1 -1
  11. package/client/dist/assets/{ListeningList-8dzhiDeb.js → ListeningList-nq279J8O.js} +1 -1
  12. package/client/dist/assets/{Manga-dkD-uWJk.js → Manga-DiCcXa9I.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-nCeWZNcO.js → MangaInfoPage-sZn0qDxf.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-NdDNCyLg.js → MangaReadPage-ChgW4VO8.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-C28AiLJl.js → MangaResetProgressModal-BkNHdClw.js} +1 -1
  16. package/client/dist/assets/{Mature-D5WSkhIJ.js → Mature-D7bJH6LQ.js} +1 -1
  17. package/client/dist/assets/{MatureConsentModal-BsdpNeXA.js → MatureConsentModal-B3u3RgAE.js} +1 -1
  18. package/client/dist/assets/MediaCard-B1llLoho.js +1 -0
  19. package/client/dist/assets/{MediaCard-B0PJStxp.css → MediaCard-CoyScn-7.css} +1 -1
  20. package/client/dist/assets/OptionListMenu-1QikgQ8d.js +1 -0
  21. package/client/dist/assets/Player-hVrgi0J1.js +56 -0
  22. package/client/dist/assets/PlayerSettings-CWc5Tf-B.js +1 -0
  23. package/client/dist/assets/{QueueOptionsButton-DNzKPzPw.js → QueueOptionsButton-Cpm6Jovo.js} +1 -1
  24. package/client/dist/assets/{QueueRail-BWcDVSHd.js → QueueRail-DpUQ2Ba2.js} +1 -1
  25. package/client/dist/assets/{ReadingList-zkFp3wpF.js → ReadingList-DMxkudSM.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-BYNYqwwl.js → ResetProgressModal-6X8ciSFl.js} +1 -1
  27. package/client/dist/assets/{Search-yDP_wGJ1.js → Search-CbXvziWY.js} +1 -1
  28. package/client/dist/assets/Settings-BEZZSWsj.js +21 -0
  29. package/client/dist/assets/Settings-DYjRBgpE.css +1 -0
  30. package/client/dist/assets/{SkeletonGrid-CYJeh04P.js → SkeletonGrid-BDR-fKs1.js} +1 -1
  31. package/client/dist/assets/{Trackers-D2KUt71k.js → Trackers-DO0mA01O.js} +1 -1
  32. package/client/dist/assets/Tv-DP4rcV9T.js +4 -0
  33. package/client/dist/assets/{TvInfo-D_4QdgV4.js → TvInfo-WNJynk-5.js} +1 -1
  34. package/client/dist/assets/{TvPopup-DHXB5ZSF.js → TvPopup-Q9_MFJdx.js} +1 -1
  35. package/client/dist/assets/{TvSearch-COwVoGru.js → TvSearch-C-RBZ1iq.js} +1 -1
  36. package/client/dist/assets/{TvWatchlist-CU3r-NO5.js → TvWatchlist-BXE6yUS0.js} +1 -1
  37. package/client/dist/assets/{Watchlist-DHyuTLJG.js → Watchlist-7x__Rf-s.js} +1 -1
  38. package/client/dist/assets/{hls-DOAVt6Ry.js → hls-DIyfUbGZ.js} +1 -1
  39. package/client/dist/assets/{index-BLh_CXtu.js → index-D0DdVatn.js} +2 -2
  40. package/client/dist/assets/{libraryInvalidation-AzFLnbjH.js → libraryInvalidation-BFqNv8Cx.js} +1 -1
  41. package/client/dist/assets/playbackCompletion-IPHm9fp5.js +1 -0
  42. package/client/dist/assets/{useAnimeInfoData-MPNJXLaM.js → useAnimeInfoData-D_qedrui.js} +1 -1
  43. package/client/dist/assets/{useAsmr-2dFEmQD_.js → useAsmr-CrshwDPO.js} +1 -1
  44. package/client/dist/assets/{useAsmrPopup-N2vUf3Pw.js → useAsmrPopup-HwNC-ZRo.js} +1 -1
  45. package/client/dist/assets/{useMangaLibrary-B3Ni34a7.js → useMangaLibrary-BPSi9vcc.js} +1 -1
  46. package/client/dist/assets/{useMangaPopup-h8NHEPUk.js → useMangaPopup-DdueqAi5.js} +1 -1
  47. package/client/dist/assets/usePlaybackEnd-DLFOYx3Q.css +1 -0
  48. package/client/dist/assets/usePlaybackEnd-DjZq1szR.js +10 -0
  49. package/client/dist/assets/{useProviders-z8L8GKy0.js → useProviders-_ilIsyde.js} +1 -1
  50. package/client/dist/assets/{useTv-D4zQ1BsQ.js → useTv-C558DPdT.js} +1 -1
  51. package/client/dist/assets/{useTvLibrary-B4vcRzQc.js → useTvLibrary-CNQcDI7O.js} +1 -1
  52. package/client/dist/index.html +1 -1
  53. package/package.json +2 -2
  54. package/server/dist/server.js +2 -2
  55. package/server/package.json +1 -1
  56. package/client/dist/assets/Asmr-Dl1EZqaI.css +0 -1
  57. package/client/dist/assets/AvSyncCalibrator-BtUHM1mW.css +0 -1
  58. package/client/dist/assets/AvSyncCalibrator-C5GxpyPE.js +0 -10
  59. package/client/dist/assets/MediaCard-C1jNesfK.js +0 -1
  60. package/client/dist/assets/OptionListMenu-CIvW5WmO.js +0 -1
  61. package/client/dist/assets/Player-PGj8YYO8.js +0 -56
  62. package/client/dist/assets/PlayerSettings-CAYfF0sA.js +0 -1
  63. package/client/dist/assets/Settings-BEHII_8K.css +0 -1
  64. package/client/dist/assets/Settings-BpKwWesn.js +0 -21
  65. package/client/dist/assets/Tv-Ul3jFq-x.js +0 -4
  66. package/client/dist/assets/playbackCompletion-DuUs8u-8.js +0 -1
@@ -1,21 +0,0 @@
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 xe,g as ue,_ as Ie}from"./vendor-core-DfaOB3Rn.js";import{d as Le,D as pe,t as b,B as T,M as E,k as ye,i as Re,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 qe,C as ne,V as Me,N as ze}from"./index-BLh_CXtu.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"},Ue=()=>{const{titlePreference:t,setTitlePreference:r,loading:o}=Le(),c=pe(),[l,f]=s(ie[t]),[v,m]=s(!1),a=j(null);O(()=>{o||f(ie[t])},[t,o]);const i=async()=>{if(v)return;m(!0);const p=(re.indexOf(t)+1)%re.length,d=re[p],x=ie[d];a.current&&(a.current.style.transform="translateX(-100%)",a.current.style.opacity="0"),setTimeout(async()=>{f(x),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})})]})},Ee="_settingsHeader_1p8qx_1",Fe="_pageTitle_1p8qx_6",Ke="_pageSubtitle_1p8qx_14",$e="_settingsLayout_1p8qx_20",He="_sidebar_1p8qx_27",We="_sidebarIndicator_1p8qx_35",Be="_sidebarItem_1p8qx_50",Ve="_active_1p8qx_72",je="_mainContent_1p8qx_80",Qe="_tabContent_1p8qx_85",Ye="_settingItem_1p8qx_95",Je="_controls_1p8qx_100",Xe="_status_1p8qx_106",S={settingsHeader:Ee,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,f]=s(!1),[v,m]=s(null),[a,i]=s({status:"idle"}),[u,p]=s(!1),[d,x]=s(""),[h,k]=s(!1),I=j(null),[L,R]=s({show:!1,message:"",type:"info"}),A=()=>{I.current&&(window.clearInterval(I.current),I.current=null)},w=le(y=>{f(y.authenticated),m(y.user||y.device.user||null),i(y.device),p(!!y.hasCustomClientId)},[]),C=le(async()=>{const y=await b.auth.githubStatus.query();w(y)},[w]),G=async()=>{try{const y=await b.auth.githubPoll.query();i(y),y.status==="success"?(A(),await C(),R({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):y.status==="error"&&(A(),R({show:!0,message:y.error||"GitHub authentication failed.",type:"error"}))}catch{A(),R({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},M=(y=5)=>{A(),I.current=window.setInterval(G,Math.max(y,5)*1e3)};O(()=>(C().catch(()=>{R({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),A),[C]);const _=async()=>{c(!0);try{const y=await b.auth.githubStart.mutate();i(y),M(y.verification?.interval)}catch(y){R({show:!0,message:y instanceof Error?y.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},D=async()=>{try{await b.auth.githubLogout.mutate(),f(!1),m(null),i({status:"idle"}),R({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{R({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},z=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:d}),x(""),await C(),R({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{R({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},W=async()=>{k(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),x(""),await C(),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:"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 y=a.verification?.verification_uri;y&&/^https?:\/\//i.test(y)&&window.open(y,"_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:y=>x(y.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:g.actions,children:[e(T,{onClick:z,disabled:h,children:"Save override"}),e(T,{variant:"secondary",onClick:W,disabled:h,children:"Use dango defaults"})]})]}),e(E,{isOpen:L.show,onClose:()=>R(y=>({...y,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:L.message})}),e(E.Actions,{children:e(T,{onClick:()=>R(y=>({...y,show:!1})),children:"OK"})})]})]})},mt=()=>{const[t,r]=s(!0),[o,c]=s(null),[l,f]=s(!1),[v,m]=s(!1),[a,i]=s(""),[u,p]=s(""),[d,x]=s(""),[h,k]=s(!1),[I,L]=s({show:!1,message:"",type:"info"}),R=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()]);f(!!_.hasConfig),m(!!(D.hasCustomWorkerUrl||D.hasCustomClientId||D.hasClientSecret))}catch(_){console.error("Failed to fetch config status",_)}};O(()=>{(async()=>{r(!0),await Promise.all([R(),A()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await R(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const D=z=>{z.origin===window.location.origin&&typeof z.data=="object"&&z.data!==null&&z.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(z.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 z=600,W=700,y=window.innerWidth/2-z/2,Z=window.innerHeight/2-W/2;window.open(_.url,"GoogleAuth",`width=${z},height=${W},top=${Z},left=${y}`)}else throw new Error("Auth URL not available")}catch{L({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await b.auth.logout.mutate(),c(null),L({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(_){console.error("Sign out failed",_),L({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(""),x(""),await A(),L({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},M=async()=>{k(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),i(""),p(""),x(""),await A(),L({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{L({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:_=>x(_.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:M,disabled:h,children:"Use dango defaults"})]})]}),e(E,{isOpen:I.show,onClose:()=>L(_=>({..._,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:I.message})}),e(E.Actions,{children:e(T,{onClick:()=>L(_=>({..._,show:!1})),children:"OK"})})]})]})},pt="_settingItem_3qq0n_1",yt="_modalOverlay_3qq0n_6",ft="_modal_3qq0n_6",vt="_modalActions_3qq0n_41",bt="_modalSecondary_3qq0n_47",wt="_modalPrimary_3qq0n_57",H={settingItem:pt,modalOverlay:yt,modal:ft,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),[f,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:f,toggle:async()=>{if(f)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}=ye(),r=kt[t],[o,c]=s(!1),[l,f]=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,x]=s(!1),h=ce(),k=Re();O(()=>{f(!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{f(!1)}})()},[r.skipKey]);const I=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)}},L=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()}},R=()=>{p(null),a.toggle()},A=async()=>{if(!d){x(!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{x(!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:I,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:L,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:R,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",xt="_statValue_o4nf0_26",It="_statMeta_o4nf0_32",Lt="_statusBanner_o4nf0_38",Rt="_statusSuccess_o4nf0_49",Pt="_statusUpdating_o4nf0_55",Dt="_statusError_o4nf0_61",At="_sha_o4nf0_67",Ot="_settingItem_o4nf0_74",Gt="_settingTitle_o4nf0_79",qt="_settingSubtitle_o4nf0_85",Mt="_actionsRow_o4nf0_92",P={statsGrid:_t,statCard:Nt,statLabel:Tt,statValue:xt,statMeta:It,statusBanner:Lt,statusSuccess:Rt,statusUpdating:Pt,statusError:Dt,sha:At,settingItem:Ot,settingTitle:Gt,settingSubtitle:qt,actionsRow:Mt},zt=()=>{const[t,r]=s(null),[o,c]=s(!0),[l,f]=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;f(!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{f(!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}},x=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||x,children:x?"Updating Database...":"Update Offline Database Now"})})]})},Ut="_status_1wbo0_1",Et="_warningText_1wbo0_7",Ft="_ackLabel_1wbo0_11",oe={status:Ut,warningText:Et,ackLabel:Ft},Kt=()=>{const t=ce(),[r,o]=s(!1),[c,l]=s(!1),[f,v]=s(!1),[m,a]=s(""),i=()=>{l(!1),a(""),o(!0)},u=()=>{f||(o(!1),l(!1))},p=async()=>{if(!(!c||f)){v(!0),a("");try{const d=await V("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),x=await d.json();if(!d.ok)throw new Error(x.error||"Failed to clear database");const h=x.deleted,k=x.deletedManga,I=x.deletedTv,L=x.deletedAsmr,R=Object.values(h).reduce((G,M)=>G+(M||0),0)+Object.values(k??{}).reduce((G,M)=>G+(M||0),0)+Object.values(I??{}).reduce((G,M)=>G+(M||0),0)+Object.values(L??{}).reduce((G,M)=>G+(M||0),0),A=(k?.manga_library??0)+(k?.manga_progress??0),w=(I?.tv_library??0)+(I?.tv_progress??0),C=(L?.asmr_library??0)+(L?.asmr_progress??0);a(`Library cleared - ${h.watchlist??0} watchlist entries, ${A} manga rows, ${w} TV rows, ${C} ASMR rows and ${R} 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(E,{isOpen:r,onClose:u,title:"Clear library data?",width:"sm",children:[e(E.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:f}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(E.Actions,{children:[e(T,{variant:"secondary",onClick:u,disabled:f,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!c||f,children:f?"Clearing...":"Yes, delete everything"})]})]})]})},$t=()=>{const[t,r]=s(""),[o,c]=s([]),[l,f]=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||[]),f(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(E,{isOpen:a.show,onClose:()=>i(d=>({...d,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:a.message})}),e(E.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 f=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:f,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
- if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
- var t=null;
4
- try{
5
- window.webpackChunkdiscord_app.push([[Symbol()],{},function(req){
6
- if(!req.c)return;
7
- var ms=Object.values(req.c);
8
- for(var i=0;i<ms.length;i++){var m=ms[i];
9
- try{
10
- if(!m.exports||m.exports===window)continue;
11
- if(typeof m.exports.getToken==='function'){var x=m.exports.getToken();if(x){t=x;return}}
12
- for(var k in m.exports){try{var ex=m.exports[k];if(ex&&typeof ex.getToken==='function'&&ex[Symbol.toStringTag]!=='IntlMessagesProxy'){var y=ex.getToken();if(y){t=y;return}}}catch(e1){}}
13
- }catch(e2){}}
14
- }]);
15
- window.webpackChunkdiscord_app.pop();
16
- }catch(e3){}
17
- if(!t){alert('Dango: could not grab your token. Make sure you are logged in to Discord in this tab, then run the bookmarklet again.');return}
18
- function copyFallback(){var a=document.createElement('textarea');a.value=t;a.style.position='fixed';a.style.opacity='0';document.body.appendChild(a);a.select();try{document.execCommand('copy')}catch(e4){}document.body.removeChild(a)}
19
- var done=function(){window.close();setTimeout(function(){if(!window.closed){alert('Dango: token copied to clipboard! Could not close this tab, so just close it, go back to Dango Settings, paste the token and press Save.')}},250)};
20
- if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(t).then(done,function(){copyFallback();done()})}else{copyFallback();done()}
21
- })()`)}const Bt=()=>{const t=Te(Wt,[]);return e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Grab the token automatically (bookmarklet)"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Set this up once and you never have to dig through DevTools: the bookmarklet copies your Discord token to the clipboard and closes the Discord tab - then you just paste it above and press Save."}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Drag the ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," ","button below onto your bookmarks bar (press ",e("kbd",{children:"Ctrl"}),"+",e("kbd",{children:"Shift"}),"+",e("kbd",{children:"B"})," ","first if the bar is hidden)."]}),e("li",{children:["Click ",e("strong",{style:{color:"var(--text-primary)"},children:"Open Discord"})," and log in (skip this if you are already logged in)."]}),e("li",{children:["On the Discord tab, click the"," ",e("strong",{style:{color:"var(--text-primary)"},children:"Dango Token Grabber"})," bookmark. The token lands in your clipboard and the tab closes on its own - come back here, paste it above and press ",e("strong",{children:"Save"}),"."]})]}),e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("a",{href:t,onClick:c=>{c.preventDefault(),alert("Drag this button onto your bookmarks bar instead of clicking it, then click it while you are on discord.com.")},title:"Drag me to your bookmarks bar",draggable:!0,style:{display:"inline-flex",alignItems:"center",padding:"0.4rem 0.8rem",borderRadius:"999px",border:"1px dashed var(--accent)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"0.85rem",textDecoration:"none",cursor:"grab",userSelect:"none"},children:[e(X,{name:"bookmark",style:{marginRight:"0.45rem",color:"var(--accent)"}}),"Dango Token Grabber"]}),e("a",{className:"btn btn-secondary btn-sm",href:"https://discord.com/channels/@me",target:"_blank",rel:"noopener noreferrer",children:"Open Discord"}),e(T,{variant:"ghost",size:"sm",onClick:async()=>{try{await navigator.clipboard.writeText(t),alert('Bookmarklet code copied. Create a new bookmark on your bookmarks bar, name it "Dango Token" and paste the code as its URL.')}catch{alert(`Could not copy automatically. Right-click the "Dango Token Grabber" button and choose "Copy link address" instead, then paste that into a new bookmark's URL.`)}},children:"Copy code"})]}),e("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:`"Copy code" is a fallback for browsers that won't drag bookmarklets: create any bookmark, then paste the copied code as its URL.`})]})},Vt="_settingItem_68mz3_1",jt="_field_68mz3_6",Qt="_input_68mz3_19",Yt="_actions_68mz3_39",Jt="_status_68mz3_45",U={settingItem:Vt,field:jt,input:Qt,actions:Yt,status:Jt},Xt=()=>{const[t,r]=s(!1),[o,c]=s(""),[l,f]=s(""),[v,m]=s(!0),[a,i]=s(!1),[u,p]=s("");O(()=>{(async()=>{try{const L=await(await V("/api/auth/app-status")).json();r(L.hasPassword)}catch{console.error("Failed to fetch LAN auth status")}finally{m(!1)}})()},[]);const d=async()=>{if(p(""),o!==l){p("Passwords do not match");return}if(o.length<4){p("Password must be at least 4 characters");return}i(!0);try{const k=await V("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})}),I=await k.json();if(!k.ok){p(I.error||"Failed to update password");return}r(I.hasPassword),c(""),f(""),p(I.hasPassword?"Password set successfully":"Password removed")}catch{p("Network error")}finally{i(!1)}},x=async()=>{i(!0);try{const k=await V("/api/auth/app-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:""})}),I=await k.json();if(!k.ok){p(I.error||"Failed to remove password");return}r(!1),c(""),f(""),p("Password removed")}catch{p("Network error")}finally{i(!1)}},h=async()=>{i(!0);try{await V("/api/auth/app-logout",{method:"POST"}),p("Logged out"),window.location.reload()}catch{p("Logout failed")}finally{i(!1)}};return v?e("div",{className:N.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:N.sectionCard,children:[e("h3",{children:"LAN Lock"}),e("p",{children:"Require a password to access this instance from any device, including this one. Sessions persist across server restarts until logout or password change."}),e("div",{className:U.settingItem,children:[e("div",{className:U.field,children:[e("label",{htmlFor:"lan-password",children:"New Password"}),e("input",{id:"lan-password",type:"password",value:o,onChange:k=>c(k.currentTarget.value),placeholder:t?"Leave empty to keep current password":"Enter a password...",className:U.input})]}),e("div",{className:U.field,children:[e("label",{htmlFor:"lan-confirm-password",children:"Confirm Password"}),e("input",{id:"lan-confirm-password",type:"password",value:l,onChange:k=>f(k.currentTarget.value),placeholder:"Confirm password...",className:U.input})]}),e("div",{className:U.actions,children:[e(T,{variant:"primary",onClick:d,loading:a,disabled:a,children:t?"Update Password":"Set Password"}),t&&e(T,{variant:"danger",onClick:h,loading:a,disabled:a,children:"Logout"}),t&&e(T,{variant:"secondary",onClick:x,loading:a,disabled:a,children:"Remove Password"})]}),u&&e("p",{className:U.status,children:u})]})]})},Zt=()=>{const[t,r]=s(""),[o,c]=s(!0),[l,f]=s(!1),[v,m]=s("");O(()=>{Pe("/api/auth/app-status").then(i=>r(String(i.port??3e3))).catch(()=>m("Failed to load current port")).finally(()=>c(!1))},[]);const a=async()=>{const i=Number(t);if(!Number.isInteger(i)||i<1||i>65535){m("Enter a port between 1 and 65535");return}f(!0),m("");try{await b.auth.setServerPort.mutate({port:i}),m(`Saved. Restart dango, then open http://localhost:${i} - this overrides the PORT environment variable.`)}catch(u){m(u.message)}finally{f(!1)}};return o?e("div",{className:N.sectionCard,children:e("p",{children:"Loading..."})}):e("div",{className:N.sectionCard,children:[e("h3",{children:"Server Port"}),e("p",{children:"Port the backend listens on. Takes effect after a restart. Google and AniList sign-in need the matching redirect URI registered with the provider."}),e("div",{className:U.settingItem,children:[e("div",{className:U.field,children:[e("label",{htmlFor:"server-port",children:"Port"}),e("input",{id:"server-port",type:"number",min:1,max:65535,value:t,onChange:i=>r(i.currentTarget.value),className:U.input})]}),e("div",{className:U.actions,children:e(T,{variant:"primary",onClick:a,loading:l,disabled:l,children:"Save Port"})}),v&&e("p",{className:U.status,children:v})]})]})},ea=()=>{const{theme:t,setTheme:r,loading:o}=De();return e("div",{children:[e("h4",{style:{margin:"0 0 0.25rem",fontSize:"1rem"},children:"Palette"}),e("p",{style:{margin:"0 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Taro is the default. Pick a palette that suits you."}),e("div",{role:"radiogroup","aria-label":"Palette",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"0.6rem"},children:Ae.map(c=>{const l=t===c.id;return e("button",{role:"radio","aria-checked":l,disabled:o,onClick:()=>r(c.id),style:{display:"flex",gap:"0.6rem",alignItems:"center",textAlign:"left",padding:"0.65rem 0.75rem",borderRadius:"10px",cursor:"pointer",background:l?"var(--accent-subtle)":"var(--bg-tertiary)",border:l?"1px solid var(--accent)":"1px solid var(--border-primary)",color:"var(--text-primary)"},children:[e("span",{"aria-hidden":!0,style:{width:26,height:26,borderRadius:"50%",flex:"none",background:c.swatch,border:"1px solid rgba(0,0,0,0.35)"}}),e("span",{style:{minWidth:0},children:[e("span",{style:{display:"block",fontSize:"0.85rem",fontWeight:700},children:c.label}),e("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.blurb})]})]},c.id)})})]})};function ta({variant:t="info",children:r,className:o=""}){return e("div",{className:`alert alert-${t} ${o}`,children:r})}const aa={anime:"Watchlist",manga:"Reading List",tv:"TV Watchlist",asmr:"Listening List"},la=()=>{const[t,r]=xe(),{contentType:o}=ye(),c=t.get("tab"),[l,f]=s(c&&["general","sync","watchlist","database"].includes(c)?c:"general"),[v,m]=s(""),a=j(null),i=j(null),u=j(new Map),[p,d]=s({top:0,height:0,left:0,width:0}),{lowEndMode:x,setLowEndMode:h}=Oe(),{hasConsent:k,revoke:I}=Ge(),[L,R]=s(qe),[A,w]=s(!0),{data:C}=ne("discordRPCEnabled"),G=pe(),[M,_]=s(!0),{data:D}=ne("dangoGaze"),[z,W]=s(!0),{data:y}=ne("discordRPCHideMature"),[Z,ee]=s(""),[Q,ae]=s(null);O(()=>{b.discord.gatewayStatus.query().then(n=>{ae(n),n.masked&&n.masked!=="none"&&ee(n.masked)}).catch(()=>{})},[]),O(()=>{C!==void 0&&w(C==="true"||C===!0||C===null)},[C]),O(()=>{y!==void 0&&W(y==="true"||y===!0||y===null)},[y]);const fe=n=>{w(n),G.mutate({key:"discordRPCEnabled",value:String(n)})};O(()=>{D!==void 0&&_(D!=="false"&&D!==!1)},[D]);const ve=n=>{_(n),G.mutate({key:"dangoGaze",value:String(n)})},be=n=>{W(n),G.mutate({key:"discordRPCHideMature",value:String(n)})},we=n=>{R(n),localStorage.setItem(Me,String(n)),window.dispatchEvent(new CustomEvent(ze))};ue.useEffect(()=>{document.title="Settings - dango"},[]),ue.useEffect(()=>{const n=t.get("tab");n&&["general","sync","watchlist","database"].includes(n)&&f(n)},[t]);const te=n=>{f(n),r(n==="general"?{}:{tab:n})},Y=le(()=>{const n=u.current.get(l),q=i.current;if(n&&q){const B=q.getBoundingClientRect(),F=n.getBoundingClientRect(),J=window.matchMedia("(max-width: 900px)").matches;d(J?{top:F.top-B.top,height:F.height,left:F.left-B.left,width:F.width}:{top:F.top-B.top,height:F.height,left:0,width:0})}},[l]);Ie(()=>{Y()},[l,Y]),O(()=>{const n=()=>Y();window.addEventListener("resize",n);let q=!1;return document.fonts?.ready&&document.fonts.ready.then(()=>{q||Y()}),()=>{q=!0,window.removeEventListener("resize",n)}},[l,Y]);const ke=()=>{m("Exporting databases...");const n=window.DangoBridge;if(n?.downloadFile){n.downloadFile("/api/backup-db","dango-backup.json"),setTimeout(()=>{m("Databases exported successfully!")},1500);return}const q=document.createElement("a");q.href="/api/backup-db",q.download="dango-backup.json",document.body.appendChild(q),q.click(),q.remove(),setTimeout(()=>{m("Databases exported successfully!")},1500)},Ce=async n=>{const q=n.currentTarget.files?.[0];if(!q)return;m("Importing databases...");const B=new FormData;B.append("dbfile",q);try{const F=await V("/api/restore-db",{method:"POST",body:B}),J=await F.json();if(F.ok){const de=Array.isArray(J.restored)?J.restored.join(", "):null;m(de?`Databases imported successfully (${de})!`:"Database imported successfully!"),setTimeout(()=>window.location.reload(),2e3)}else m(`Import failed: ${J.error}`)}catch{m("Import failed: An unexpected error occurred.")}finally{n.currentTarget.value=""}},Se=()=>{a.current?.click()},_e=()=>{switch(l){case"general":return e("div",{className:S.tabContent,children:e("div",{className:N.sectionCard,children:[e("h3",{children:"Appearance & Preferences"}),e("p",{children:"Configure how titles are displayed and other general preferences."}),e("div",{className:S.settingItem,children:e(Ue,{})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e(ea,{})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Low End Mode"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Disables animations and heavy visual effects for better performance on older hardware."})]}),e(K,{isChecked:x,onChange:n=>h(n.currentTarget.checked),id:"low-end-mode"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Dango Animations"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Lets the dango logo look around, blink and react when you pet it. Always off in Low End Mode."})]}),e(K,{isChecked:M,onChange:n=>ve(n.currentTarget.checked),id:"dango-gaze"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Virtual Keyboard"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Shows an on-screen keyboard when text search fields are focused."})]}),e(K,{isChecked:L,onChange:n=>we(n.currentTarget.checked),id:"virtual-keyboard-enabled"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Rich Presence"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Show your current anime and watch progress on your Discord profile status."})]}),e(K,{isChecked:A,onChange:n=>fe(n.currentTarget.checked),id:"discord-rpc-enabled"})]})}),e("div",{style:{marginTop:"2rem"},children:e(Xt,{})}),e("div",{style:{marginTop:"2rem"},children:e(Zt,{})}),A&&e("div",{className:S.settingItem,style:{marginTop:"1rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Hide Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Hide mature content (18+) from Discord Rich Presence."})]}),e(K,{isChecked:z,onChange:n=>be(n.currentTarget.checked),id:"discord-hide-mature"})]})}),e("div",{className:S.settingItem,style:{marginTop:"1.5rem",background:"var(--bg-tertiary)",padding:"1rem",borderRadius:"8px",border:"1px solid var(--border-color)"},children:[e("div",{className:N.settingRow,children:e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Discord Mobile Presence (Gateway)"}),e("p",{style:{margin:"0.25rem 0 0.75rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Paste your Discord authentication token to enable presence on mobile devices. If no token is saved, the default desktop Rich Presence is used. The token is stored locally in your configuration and never shared."})]})}),e(ta,{variant:"warning",style:{marginTop:"1.25rem",paddingTop:"1.25rem"},children:[e("strong",{children:"Use at your own risk."})," This feature uses the Discord Gateway API with your user token, which violates Discord's Terms of Service. Discord may detect this usage and take action against your account, including phone number locks, temporary suspensions, or permanent bans. While the risk is generally low, it is not zero. Only use this if you understand and accept the risks."]}),e("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem",alignItems:"center",flexWrap:"wrap"},children:[e("input",{type:"password",value:Z,onChange:n=>ee(n.currentTarget.value),placeholder:"Paste Discord token here...",style:{flex:"1 1 200px",padding:"0.5rem",borderRadius:"4px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)",fontFamily:"monospace",minWidth:0}}),e(T,{variant:"primary",size:"sm",onClick:async()=>{try{const n=await b.discord.gatewaySave.mutate({token:Z});ae({hasToken:!0,masked:n.masked,enabled:!0}),ee(n.masked)}catch(n){alert(n instanceof Error?n.message:"Failed to save token")}},children:"Save"}),e(T,{variant:"secondary",size:"sm",onClick:async()=>{await b.discord.gatewayRemove.mutate().catch(()=>{}),ee(""),ae({hasToken:!1,masked:null,enabled:!1})},children:"Remove"})]}),Q&&e("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",color:Q.hasToken?"green":"var(--text-secondary)"},children:["Status:"," ",Q.hasToken?`Token saved (${Q.masked})`:"No token saved",Q.enabled?" - Gateway active":""]}),e(Bt,{})]}),k&&e("div",{className:S.settingItem,style:{marginTop:"1.5rem"},children:e("div",{className:N.settingRow,children:[e("div",{style:{minWidth:0},children:[e("h4",{style:{margin:0,fontSize:"1rem"},children:"Mature Content"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"You have previously agreed to view 18+ content. Toggle this off to re-enable the blur gate and filtering."})]}),e(K,{isChecked:!0,onChange:n=>{n.currentTarget.checked||(I(),window.location.reload())},id:"mature-content-enabled"})]})})]})});case"sync":return e("div",{className:S.tabContent,children:[e(Ht,{}),e(gt,{}),e(mt,{}),e($t,{})]});case"watchlist":return e("div",{className:S.tabContent,children:e(St,{})});case"database":return e("div",{className:S.tabContent,children:[e("div",{className:N.sectionCard,children:[e("h3",{children:"Database Management"}),e("p",{children:"Download a backup of all databases (anime, manga, TV and ASMR) or restore from a backup file. Legacy single-file anime (.db) backups can still be restored."}),e("div",{className:S.controls,children:[e(T,{onClick:ke,children:"Backup Database"}),e(T,{variant:"secondary",onClick:Se,children:"Restore Database"})]}),e("input",{type:"file",ref:a,onChange:Ce,style:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"},accept:".json,.db,application/octet-stream"}),v&&e("p",{className:S.status,children:v})]}),e(zt,{}),e(Kt,{})]});default:return null}};return e("div",{className:"page-container",children:[e("div",{className:S.settingsHeader,children:[e("h1",{className:S.pageTitle,children:"Settings"}),e("p",{className:S.pageSubtitle,children:"Manage your preferences and data synchronization"})]}),e("div",{className:S.settingsLayout,children:[e("aside",{className:S.sidebar,ref:i,children:[e("div",{className:S.sidebarIndicator,style:{top:p.top,height:p.height,left:p.left,...p.width?{width:p.width}:{}}}),e("button",{ref:n=>{n&&u.current.set("general",n)},className:`${S.sidebarItem} ${l==="general"?S.active:""}`,onClick:()=>te("general"),children:[e(X,{name:"cog"})," ",e("span",{children:"General"})]}),e("button",{ref:n=>{n&&u.current.set("sync",n)},className:`${S.sidebarItem} ${l==="sync"?S.active:""}`,onClick:()=>te("sync"),children:[e(X,{name:"cloud"})," ",e("span",{children:"Synchronization"})]}),e("button",{ref:n=>{n&&u.current.set("watchlist",n)},className:`${S.sidebarItem} ${l==="watchlist"?S.active:""}`,onClick:()=>te("watchlist"),children:[e(X,{name:"list"})," ",e("span",{children:aa[o]})]}),e("button",{ref:n=>{n&&u.current.set("database",n)},className:`${S.sidebarItem} ${l==="database"?S.active:""}`,onClick:()=>te("database"),children:[e(X,{name:"database"})," ",e("span",{children:"Database"})]})]}),e("main",{className:S.mainContent,children:e("div",{className:S.tabContent,children:_e()},l)})]})]})};export{la as default};
@@ -1,4 +0,0 @@
1
- import{u as t,d as S,A as P,h as v,S as Le,g as jr,q as T,o as Gr,p as Qr,a as Xr,T as Te}from"./vendor-core-DfaOB3Rn.js";import{u as Jr}from"./vendor-query-BBT5_sHx.js";import{g as nn,t as vt,W as Zr,J as Ln,e as es,A as ts,M as ur,B as ot}from"./index-BLh_CXtu.js";import{I as H}from"./vendor-icons-DrybRNxP.js";import{S as ns,U as rs,p as $n,M as ss,x as br,f as Dn,d as as,C as os,a as is,b as ls,c as en,u as cs,i as us,j as ds,m as ms,k as hs,l as bs,s as Bn,e as fs,g as ps,h as gs,r as vs,n as Me,A as ys,o as Ss,E as _s,v as Ts,P as Cs,q as de,w as ks,R as Es}from"./AvSyncCalibrator-C5GxpyPE.js";import{S as Ns,O as Pn,a as xs,A as Is,b as As}from"./OptionListMenu-CIvW5WmO.js";import{M as ws}from"./MatureConsentModal-BsdpNeXA.js";import{u as Ms}from"./useProviders-z8L8GKy0.js";import{d as Ls,g as Bs,h as Ps,f as Rs,e as zs,j as $s,k as Ds}from"./useTvLibrary-B4vcRzQc.js";import{l as Os,s as Vs,a as Rn,d as Fs,S as qs,h as dr}from"./playbackCompletion-DuUs8u-8.js";import{l as Us,c as Ws}from"./hls-DOAVt6Ry.js";import{u as Hs}from"./useIsMobile-Dvx1uJ82.js";import{S as Ks}from"./SynopsisText-B3Sa5pRv.js";import"./libraryInvalidation-AzFLnbjH.js";const Ys="_fullscreenFlat_10bzs_1",js="_timeDisplay_10bzs_12",Gs="_bottomControls_10bzs_16",Qs="_leftControls_10bzs_20",Xs="_rightControls_10bzs_21",Js="_controlBtn_10bzs_25",Zs="_controlsOverlay_10bzs_32",ea="_hidden_10bzs_52",ta="_topControls_10bzs_58",na="_backBtn_10bzs_78",ra="_videoTitleInfo_10bzs_98",sa="_animeTitle_10bzs_104",aa="_episodeLabel_10bzs_112",oa="_speedBoostBadge_10bzs_119",ia="_progressBarContainer_10bzs_165",la="_progressBar_10bzs_165",ca="_thumb_10bzs_184",ua="_bufferedBar_10bzs_202",da="_watchedBar_10bzs_212",ma="_scrubbing_10bzs_237",ha="_timeBubble_10bzs_241",ba="_bottomControlsRow_10bzs_255",fa="_nextEpisodeBtn_10bzs_278",pa="_active_10bzs_340",ga="_settingsPanel_10bzs_352",va="_settingsHeader_10bzs_371",ya="_settingsBackBtn_10bzs_379",Sa="_settingsTitle_10bzs_397",_a="_settingsContent_10bzs_408",Ta="_currentValue_10bzs_417",Ca="_menuItem_10bzs_423",ka="_menuNote_10bzs_456",Ea="_loadingOverlay_10bzs_465",Na="_loadingDots_10bzs_476",xa="_dot_10bzs_481",Ia="_bufferingOverlay_10bzs_510",Aa="_bufferingSpinner_10bzs_519",o={fullscreenFlat:Ys,timeDisplay:js,bottomControls:Gs,leftControls:Qs,rightControls:Xs,controlBtn:Js,controlsOverlay:Zs,hidden:ea,topControls:ta,backBtn:na,videoTitleInfo:ra,animeTitle:sa,episodeLabel:aa,speedBoostBadge:oa,progressBarContainer:ia,progressBar:la,thumb:ca,bufferedBar:ua,watchedBar:da,scrubbing:ma,timeBubble:ha,bottomControlsRow:ba,nextEpisodeBtn:fa,active:pa,settingsPanel:ga,settingsHeader:va,settingsBackBtn:ya,settingsTitle:Sa,settingsContent:_a,currentValue:Ta,menuItem:Ca,menuNote:ka,loadingOverlay:Ea,loadingDots:Na,dot:xa,bufferingOverlay:Ia,bufferingSpinner:Aa},wa=({player:a,visible:m,settingsOpen:V,onOpenSettings:M,onCloseSettings:R,hasSubtitles:A,isSubtitleActive:r,subtitles:_,onSubtitleChange:s,showNextEpisodeButton:C,onNextEpisode:F,isTheaterMode:z,onTheaterModeToggle:h,timeLabelRef:j})=>{const{state:d,refs:qe,actions:O}=a,X=qe.videoRef,Be=E=>{const te=X.current;!te||isNaN(d.duration)||d.duration===0||(te.currentTime=E*d.duration)},Pe=()=>{X.current&&(O.setIsScrubbing(!0),O.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},Ue=E=>{const te=X.current;te&&d.duration&&(te.currentTime=E*d.duration)},We=()=>{O.setIsScrubbing(!1),O.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Qe=E=>{const te=X.current;te&&(te.volume=E,te.muted=E===0)},ie=()=>{if(r){s(-1);return}let E=null;try{E=localStorage.getItem("tvLastSubtitle")}catch{}s($n(_,{lastKey:E,enabled:!0}))},G=d.isMuted?t(H,{name:"volume-mute"}):d.volume<.5?t(H,{name:"volume-down"}):t(H,{name:"volume-up"});return t("div",{className:`${o.controlsOverlay} ${m?"":o.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:o.bottomControls,onClick:E=>E.stopPropagation(),children:[t(ns,{classes:{container:o.progressBarContainer,scrubbing:o.scrubbing,timeBubble:o.timeBubble,bar:o.progressBar,buffered:o.bufferedBar,watched:o.watchedBar,thumb:o.thumb},videoRef:X,duration:d.duration,formatTime:nn,isScrubbing:d.isScrubbing,buffered:"full",onSeek:Be,onScrubStart:Pe,onScrubMove:Ue,onScrubEnd:We,timeLabelRef:j}),t("div",{className:o.bottomControlsRow,children:[t("div",{className:o.leftControls,children:[t("button",{className:o.controlBtn,onClick:O.togglePlay,"aria-label":d.isPlaying?"Pause":"Play",children:d.isPlaying?t(H,{name:"pause"}):t(H,{name:"play"})}),t(rs,{muted:d.isMuted,volume:d.volume,volumeIcon:G,buttonClassName:o.controlBtn,onToggleMute:O.toggleMute,onVolumeChange:Qe,onExpandedChange:E=>O.setShowVolumeSlider(E)}),t("span",{className:o.timeDisplay,ref:j,children:[nn(0)," / ",nn(d.duration)]})]}),t("div",{className:o.rightControls,children:[C&&t("button",{className:o.nextEpisodeBtn,onClick:F,title:"Play next episode",children:"Next EP"}),A&&t("button",{className:`${o.controlBtn} ${r?o.active:""}`,onClick:ie,"aria-label":r?"Turn subtitles off":"Turn subtitles on",children:t(H,{name:"closed-captioning"})}),t("button",{className:`${o.controlBtn} ${V?o.active:""}`,onClick:()=>V?R():M(),"aria-label":"Settings",children:t(H,{name:"cog"})}),t("button",{className:`${o.controlBtn} ${z?o.active:""}`,onClick:E=>{E.stopPropagation(),h()},title:z?"Exit Theater Mode":"Theater Mode","aria-label":z?"Exit Theater Mode":"Theater Mode",children:t(H,{name:"tv"})}),t("button",{className:o.controlBtn,onClick:O.toggleFullscreen,"aria-label":d.isFullscreen?"Exit Fullscreen":"Fullscreen",children:d.isFullscreen?t(H,{name:"compress"}):t(H,{name:"expand"})})]})]})]})})},tn=-6e4,zn=6e4,mr=500,Ma=({classes:a,delayMs:m,onDelayChange:V})=>{const[M,R]=S(null),A=M??m,r=P(V);r.current=V;const _=P(m);_.current=m;const s=P(null);s.current=M,v(()=>{R(null)},[m]),v(()=>()=>{const z=s.current;z!==null&&z!==_.current&&r.current(z)},[]);const C=z=>{_.current=z,s.current=null,r.current(z),R(null)},F=z=>{const h=s.current??_.current,j=Math.max(tn,Math.min(zn,h+z));C(j)};return t(Le,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:a.item,onClick:()=>F(-mr),"aria-label":"Show subtitles 0.5 seconds earlier",style:{flex:1,justifyContent:"center"},children:t("span",{children:"-0.5s"})}),t("button",{type:"button",className:a.item,onClick:()=>F(mr),"aria-label":"Show subtitles 0.5 seconds later",style:{flex:1,justifyContent:"center"},children:t("span",{children:"+0.5s"})}),t("button",{type:"button",className:a.item,onClick:()=>C(0),disabled:A===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(ss,{label:"Subtitle timing",display:br(A),min:tn,max:zn,step:100,value:A,percent:(A-tn)/(zn-tn)*100,onChange:z=>{const h=Math.round(z);s.current=h,R(h)},onCommit:()=>{const z=s.current;z!==null&&C(z)}}),t("div",{className:a.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},La=({view:a,onSelectView:m,onClose:V,player:M,onSubtitleStyleChange:R,streams:A,resolutionIdx:r,onResolutionChange:_,hasSubtitles:s,subtitles:C,selectedSubtitle:F,isSubtitleActive:z,onSubtitleChange:h,audioTracks:j,selectedAudioTrack:d,onAudioTrackChange:qe,videoDelayEnabled:O,onVideoDelayToggle:X,videoDelayMs:Be,onVideoDelayChange:Pe,onCalibrate:Ue,subtitleDelayMs:We,onSubtitleDelayChange:Qe,ambientSettings:ie,onAmbientChange:G})=>{const{state:E}=M,te=()=>t(Le,{children:[A.length>1&&t("button",{className:o.menuItem,onClick:()=>m("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:o.currentValue,children:A[r]?.quality||"Auto"})]}),s&&t("button",{className:o.menuItem,onClick:()=>m("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:o.currentValue,children:z?C[F]?.label||C[F]?.language:"Off"})]}),s&&t("button",{className:o.menuItem,onClick:()=>m("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:o.currentValue,children:[E.subtitleFontSize.toFixed(1),"x · ",E.subtitlePosition]})]}),s&&t("button",{className:o.menuItem,onClick:()=>m("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:o.currentValue,children:br(We)})]}),j.length>0&&t("button",{className:o.menuItem,onClick:()=>m("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:o.currentValue,children:j[d]?.label||j[d]?.language})]}),t("button",{className:o.menuItem,onClick:()=>m("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:o.currentValue,children:O?`${Be}ms`:"Off"})]}),ie&&G&&t("button",{className:o.menuItem,onClick:()=>m("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:o.currentValue,children:ie.enabled?"On":"Off"})]})]}),Ce=()=>t(Pn,{classes:{item:o.menuItem,active:o.active},options:A.map((x,Y)=>({key:String(Y),label:x.quality,selected:Y===r})),onSelect:x=>_(Number(x))}),Q=()=>t(Pn,{classes:{item:o.menuItem,active:o.active},options:[{key:"off",label:"Off",selected:!z},...C.map((x,Y)=>({key:String(Y),label:x.label||x.language,selected:Y===F}))],onSelect:x=>h(x==="off"?-1:Number(x))}),ke=()=>t(xs,{classes:{item:o.menuItem,active:o.active},values:{fontSize:E.subtitleFontSize,position:E.subtitlePosition,bgOpacity:E.subtitleBgOpacity,bgColor:E.subtitleBgColor,textColor:E.subtitleTextColor,edge:E.subtitleEdge,bold:E.subtitleBold},onChange:R}),K=()=>t(Ma,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},delayMs:We,onDelayChange:x=>Qe?.(x)}),Re=()=>t(Pn,{classes:{item:o.menuItem,active:o.active},options:j.map((x,Y)=>({key:String(Y),label:x.label||x.language,selected:Y===d})),onSelect:x=>qe(Number(x))}),He=()=>t(Is,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},enabled:O,delayMs:Be,onToggle:x=>X?.(x),onDelayChange:x=>Pe?.(x),onCalibrate:Ue}),ge=()=>ie&&G?t(As,{classes:{item:o.menuItem,active:o.active,note:o.menuNote},values:ie,onChange:G}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:x=>x.stopPropagation(),children:t(Ns,{classes:{panel:o.settingsPanel,header:o.settingsHeader,backBtn:o.settingsBackBtn,title:o.settingsTitle,content:o.settingsContent},title:a==="main"?"Settings":a==="subtitle-style"?"Subtitle Style":a==="subtitle-timing"?"Subtitle Timing":a==="audio"?"Audio Track":a==="resolution"?"Resolution":a==="av-sync"?"A/V Sync":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1),onBack:()=>a==="main"?V():m("main"),children:[a==="main"&&te(),a==="resolution"&&Ce(),a==="subtitles"&&Q(),a==="subtitle-style"&&ke(),a==="subtitle-timing"&&K(),a==="audio"&&Re(),a==="av-sync"&&He(),a==="ambient"&&ge()]})})},Ba=({player:a,title:m,episodeLabel:V,audioTracks:M,selectedAudioTrack:R,onAudioTrackChange:A,subtitles:r,selectedSubtitle:_,onSubtitleChange:s,streams:C,resolutionIdx:F,onResolutionChange:z,onBack:h,children:j,videoDelayEnabled:d=!1,onVideoDelayToggle:qe,videoDelayMs:O=0,onVideoDelayChange:X,onCalibrateAvSync:Be,subtitleDelayMs:Pe=0,onSubtitleDelayChange:Ue,showNextEpisodeButton:We=!1,onNextEpisode:Qe,isLoading:ie=!1,isTheaterMode:G,onTheaterModeToggle:E,ambientSettings:te,onAmbientChange:Ce})=>{const{state:Q,refs:ke,actions:K}=a,Re=ke.videoRef,{subtitleFontSize:He,subtitlePosition:ge,subtitleBgOpacity:x,subtitleBgColor:Y,subtitleTextColor:it,subtitleEdge:le,subtitleBold:ze}=Q,[Ee,$e]=S(null),lt=P(null),[Lt,yt]=S(0);v(()=>{const Oe=Re.current;if(!Oe)return;const ve=()=>yt(Oe.clientHeight||0);ve();const Z=new ResizeObserver(ve);return Z.observe(Oe),()=>Z.disconnect()},[Re]);const Xe=K.setSubtitleStyle;v(()=>{const Oe="tv-player-subtitle-style";let ve=document.getElementById(Oe);ve||(ve=document.createElement("style"),ve.id=Oe,document.head.appendChild(ve));const Z={fontSize:He,position:ge,bgOpacity:x,bgColor:Y,textColor:it,edge:le,bold:ze},se=Re.current,Je=Dn(He,Lt||se?.clientHeight||720);if(ve.textContent=as({...Z,fontSize:Je}),se){const Ct=()=>{const B=Number(ge);return isNaN(B)?0:Math.max(0,Math.min(100,B))},ut=(B,ee)=>{try{const ne=B;ne.snapToLines=!1,ne.line=ee}catch{}},Rt=()=>{const B=Je*16,ee=se.videoHeight||se.clientHeight||720,ne=se.videoWidth||se.clientWidth||1280;return{step:B*1.3/ee*100,chars:Math.max(20,Math.floor(ne/(B*.55)))}},dt=B=>{const ee=Math.max(0,Math.min(100,100-Ct())),ne=Array.from(B.activeCues??[]);if(ne.length<=1){ne.forEach(ae=>ut(ae,ee));return}const{step:zt,chars:$t}=Rt();let Dt=ee;for(let ae=ne.length-1;ae>=0;ae--){const an=String(ne[ae].text??"").replace(/<[^>]*>/g,"").split(`
2
- `).reduce((on,ln)=>on+Math.max(1,Math.ceil(ln.length/$t)),0),Ot=Dt-an*zt;ut(ne[ae],Math.max(0,Ot)),Dt=Ot-zt*.4}},p=()=>{const B=Math.max(0,Math.min(100,100-Ct()));Array.from(se.textTracks).forEach(ee=>{ee.cues&&(Array.from(ee.cues).forEach(ne=>ut(ne,B)),ee.mode==="showing"&&dt(ee))})};p();const l=B=>{const ee=B.target;ee.mode==="showing"&&dt(ee)},ce=()=>{Array.from(se.textTracks).forEach(B=>{B.removeEventListener("cuechange",l),B.addEventListener("cuechange",l)}),p()};Array.from(se.textTracks).forEach(B=>{B.addEventListener("cuechange",l)}),se.textTracks.addEventListener("addtrack",ce);const ue=Array.from(se.querySelectorAll("track")),kt=()=>p();return ue.forEach(B=>B.addEventListener("load",kt)),()=>{Array.from(se.textTracks).forEach(B=>{B.removeEventListener("cuechange",l)}),se.textTracks.removeEventListener("addtrack",ce),ue.forEach(B=>B.removeEventListener("load",kt))}}},[He,ge,x,Y,it,le,ze,_,r,Re,Lt]);const me=r.length>0,St=_>=0,_t=()=>{$e("main"),K.setShowControls(!0)},L=()=>{$e(null)},ct=Q.showControls||!!Ee,Bt=t(ls,{visible:ct,title:m,episode:V,onBack:h,classes:{overlay:o.controlsOverlay,hidden:o.hidden,top:o.topControls,backBtn:o.backBtn,titleInfo:o.videoTitleInfo,title:o.animeTitle,episode:o.episodeLabel}}),De=!ie&&!Q.isBuffering&&Q.duration>0?t(os,{isPlaying:Q.isPlaying,onTogglePlay:K.togglePlay,onSkipBack:()=>K.seek(-10),onSkipForward:()=>K.seek(10)}):null,Pt=t(wa,{player:a,visible:ct,settingsOpen:!!Ee,onOpenSettings:_t,onCloseSettings:L,hasSubtitles:me,isSubtitleActive:St,subtitles:r,onSubtitleChange:s,showNextEpisodeButton:We,onNextEpisode:Qe,isTheaterMode:G,onTheaterModeToggle:E,timeLabelRef:lt}),rn=Ee?t(La,{view:Ee,onSelectView:$e,onClose:L,player:a,onSubtitleStyleChange:Xe,streams:C,resolutionIdx:F,onResolutionChange:z,hasSubtitles:me,subtitles:r,selectedSubtitle:_,isSubtitleActive:St,onSubtitleChange:s,audioTracks:M,selectedAudioTrack:R,onAudioTrackChange:A,videoDelayEnabled:d,onVideoDelayToggle:qe,videoDelayMs:O,onVideoDelayChange:X,onCalibrate:()=>{$e(null),Be?.()},subtitleDelayMs:Pe,onSubtitleDelayChange:Ue,ambientSettings:te,onAmbientChange:Ce}):null,Tt=t(Le,{children:[ie&&t("div",{className:o.loadingOverlay,"aria-hidden":"true",children:t("div",{className:o.loadingDots,children:[t("div",{className:o.dot}),t("div",{className:o.dot}),t("div",{className:o.dot})]})}),Q.isBuffering&&!ie&&t("div",{className:o.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:o.bufferingSpinner})}),Q.isSpeedBoostActive&&t("div",{className:o.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(H,{name:"forward",size:12})]})]});return t(is,{player:a,topBar:Bt,centerControls:De,bottomBar:!ie&&Q.duration>0?Pt:null,settingsPanel:rn,overlays:Tt,isInteracting:!!Ee,onStageClick:L,className:Q.isFullscreen?o.fullscreenFlat:"",children:j})},Pa=({servers:a,selectedServer:m,onServerSelect:V})=>a.length===0?null:t("div",{className:en.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:en.sourceButtons,children:a.map(M=>t("button",{className:`${en.sourceButton} ${m===M?en.active:""}`,onClick:()=>V(M),children:M},M))})]}),Ra=jr.memo(Pa);function za({details:a,isMovie:m,season:V,episode:M,videoRef:R,active:A}){const r=P("");r.current||(r.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const _=T(()=>{if(!a)return;const s=R.current,C=m?"":`S${String(V).padStart(2,"0")}E${String(M).padStart(2,"0")}`;vt.discord.tvPresence.mutate({title:a.title,episodeLabel:C,isPlaying:s?!s.paused&&!s.ended:!0,thumbnail:a.poster,currentTime:s?s.currentTime:0,duration:s&&s.duration||0,isAdult:a.adult===!0,sessionId:r.current}).catch(()=>{}),vt.discord.heartbeat.mutate({sessionId:r.current}).catch(()=>{})},[a,m,V,M,R]);return v(()=>{if(!a)return;_();const s=window.setInterval(()=>{const C=R.current;(!C||!C.paused)&&_()},15e3);return()=>window.clearInterval(s)},[_,a,R]),v(()=>{if(!a||!A)return;const s=R.current;if(!s)return;const C=()=>_();return s.addEventListener("play",C),s.addEventListener("pause",C),s.addEventListener("seeked",C),()=>{s.removeEventListener("play",C),s.removeEventListener("pause",C),s.removeEventListener("seeked",C)}},[a,A,_,R]),v(()=>{const s=r.current,C=()=>Zr(s),F=()=>C();return window.addEventListener("pagehide",F),window.addEventListener("beforeunload",F),()=>{window.removeEventListener("pagehide",F),window.removeEventListener("beforeunload",F),C()}},[]),{sendPresence:_}}function $a(a,m,V){const M=()=>{const A=Array.isArray(a.audioTracks)?a.audioTracks.length:0,r=V.getWant(),_=A>0?Math.min(Math.max(0,r),A-1):r;a.audioTrack=_,_!==r&&V.onResolve(_)},R=(A,r)=>{const _=V.getWant(),s=Array.isArray(a.audioTracks)?a.audioTracks.length:0;if(r.id!==_&&_>=0&&_<s){a.audioTrack!==_&&(a.audioTrack=_);return}V.onResolve(r.id)};return a.on(m.MANIFEST_PARSED,M),a.on(m.AUDIO_TRACK_SWITCHED,R),()=>{a.off(m.MANIFEST_PARSED,M),a.off(m.AUDIO_TRACK_SWITCHED,R)}}const Da=/\b(SmartTV|SMART-TV|Tizen|Web0S|webOS|NetCast|HbbTV|AppleTV|CrKey|BRAVIA|AFT[A-Za-z]|Fire\s?TV|GoogleTV|Roku|VIDAA|DTV|PlayStation|Xbox|Opera TV|POV_TV)\b/i;function Oa(){try{if(Da.test(navigator.userAgent||""))return!0;const a=navigator.deviceMemory;if(typeof a=="number"&&a>0&&a<2)return!0}catch{}return!1}const Va="_statusMsg_zqb8u_1",Fa="_error_zqb8u_7",qa="_spinner_zqb8u_11",Ua="_spin_zqb8u_11",Wa="_sourceLoader_zqb8u_16",Ha="_ringSpinner_zqb8u_22",Ka="_meta_zqb8u_40",Ya="_year_zqb8u_48",ja="_rating_zqb8u_53",Ga="_typeBadge_zqb8u_62",Qa="_tv_zqb8u_70",Xa="_movie_zqb8u_75",Ja="_controlLabel_zqb8u_80",Za="_select_zqb8u_90",eo="_playerSection_zqb8u_102",to="_video_zqb8u_106",no="_videoHidden_zqb8u_128",ro="_delayCanvas_zqb8u_133",so="_delayCanvasActive_zqb8u_146",ao="_subtitleOverlay_zqb8u_150",oo="_videoIframe_zqb8u_169",io="_retryButton_zqb8u_177",lo="_sidebarSeason_zqb8u_192",co="_mobileSeasonRow_zqb8u_208",uo="_providerSelectWrap_zqb8u_222",mo="_genreRow_zqb8u_230",ho="_genreChip_zqb8u_237",bo="_metaRow_zqb8u_247",fo="_detailGrid_zqb8u_256",po="_detailItem_zqb8u_264",go="_imdbLink_zqb8u_286",g={statusMsg:Va,error:Fa,spinner:qa,spin:Ua,sourceLoader:Wa,ringSpinner:Ha,meta:Ka,year:Ya,rating:ja,typeBadge:Ga,tv:Qa,movie:Xa,controlLabel:Ja,select:Za,playerSection:eo,video:to,videoHidden:no,delayCanvas:ro,delayCanvasActive:so,subtitleOverlay:ao,videoIframe:oo,retryButton:io,sidebarSeason:lo,mobileSeasonRow:co,providerSelectWrap:uo,genreRow:mo,genreChip:ho,metaRow:bo,detailGrid:fo,detailItem:po,imdbLink:go},vo=[],yo=[];function hr({error:a,onRetry:m}){return t("div",{className:`${g.statusMsg} ${g.error}`,style:{flexDirection:"column",alignItems:"stretch",gap:8},children:t("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t("span",{style:{flex:1},children:a}),t("button",{className:g.retryButton,onClick:m,children:"Retry"})]})})}const Ro=()=>{const{id:a}=Gr(),[m]=Qr(),V=P(m);V.current=m;const M=Xr(),R=Jr(),A=m.get("type"),[r,_]=S(null),[s,C]=S(()=>parseInt(m.get("s")||"1",10)||1),[F,z]=S([]),[h,j]=S(()=>parseInt(m.get("e")||"1",10)||1),[d,qe]=S(()=>{try{return localStorage.getItem("tvProvider")||""}catch{return""}}),[O,X]=S([]),[Be,Pe]=S(""),{options:Ue,isFallback:We,isLoading:Qe}=Ms(),ie=Te(()=>Ue.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.id,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[Ue]),G=We||ie.length===0?vo:ie,E=G.filter(e=>e.tier==="direct"),te=G.filter(e=>e.tier==="embed"),[Ce,Q]=S(!1),[ke,K]=S(""),[Re,He]=S([]),[ge,x]=S(0),[Y,it]=S([]),[le,ze]=S(-1),[Ee,$e]=S(0),[lt,Lt]=S(""),[yt,Xe]=S(""),[me,St]=S(()=>{try{return localStorage.getItem("tvServer")||""}catch{return""}}),_t=Te(()=>G.find(e=>e.id===d),[G,d]),L=_t?.tier==="embed",[ct,Bt]=S([]),[De,Pt]=S(""),[rn,Tt]=S(""),[Oe,ve]=S(!1),Z=Te(()=>ct.length>0?ct:_t?.servers??[],[ct,_t]),se=Te(()=>De?["Embed",...Z]:Z,[Z,De]),Je=Oe&&!!De,Ct=Je?rn||De:"";v(()=>{if(!De){Tt("");return}let e=!1;return Ln(`/api/resolve?url=${encodeURIComponent(De)}`).then(n=>{!e&&n.finalUrl&&Tt(n.finalUrl)}).catch(()=>{}),()=>{e=!0}},[De]);const ut=P([]);v(()=>{ut.current=O},[O]);const Rt=P(ge);v(()=>{Rt.current=ge},[ge]);const dt=P(le);v(()=>{dt.current=le},[le]);const p=cs({skipIntervals:yo}),l=p.refs.videoRef,ce=P(null),ue=P([]),kt=P(null),B=P(null),{videoDelayMs:ee,videoDelayEnabled:ne,setDelayEnabled:zt,handleVideoDelayChange:$t,isCalibrating:Dt,testClipActive:ae,stopCalibration:sn,openAvSyncCalibrator:an,cancelAvSyncCalibrator:Ot,applyAvSyncCalibrator:on,toggleTestClip:ln,calibReturnRef:Vt,effectiveVideoDelayMs:cn}=us(l),[mt,fr]=S(()=>{try{const e=Number(localStorage.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),un=P(mt);un.current=mt;const pr=T(e=>{const n=Math.max(-6e4,Math.min(6e4,Math.round(e)));if(un.current!==n){un.current=n,fr(n);try{localStorage.setItem("tvSubtitleDelayMs",String(n))}catch{}}},[]);ds({videoRef:l,canvasRef:kt,delayMs:cn,enabled:ne});const dn=ne,ye=dn||mt!==0,{settings:mn,update:gr}=ms(),hn=P(ye);hn.current=ye;const bn=T(()=>{if(!hn.current)return;const e=l.current;e&&Array.from(e.textTracks).forEach(n=>{n.mode!=="hidden"&&(n.mode="hidden")})},[l]),{hasConsent:Et,grant:vr}=es(),b=A==="movie";za({details:r,isMovie:b,season:s,episode:h,videoRef:l,active:!L&&!Ce&&!ke&&O.length>0});const Ft=a?Ls(A||"tv",a):"",q=Ft,On=Bs(),qt=Ps(),{toggle:Vn,bookmarkedIds:yr,pending:Sr}=Rs(),{data:Fn}=zs(r?Ft:void 0),Ut=Fn?!!Fn.inLibrary:Ft?yr.has(Ft):!1,_r=T(()=>{!r||!a||Vn({tmdbId:Number(a),mediaType:A||"tv",title:r.title,poster:r.poster,year:r.year,adult:r.adult})},[r,a,A,Vn]),{data:Ze,isFetched:qn,isPending:Un}=$s(q||void 0,s,h),Wt=Te(()=>F.map(e=>e.episode_number).sort((e,n)=>e-n),[F]),et=Wt.indexOf(h),fn=et>0?Wt[et-1]:null,w=et>=0&&et<Wt.length-1?Wt[et+1]:null,Ht=Te(()=>(r?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,n)=>e-n),[r]),Se=Te(()=>{if(b||w!=null)return null;const e=Ht.indexOf(s);return e>=0&&e<Ht.length-1?Ht[e+1]:(r?.number_of_seasons??0)>s?s+1:null},[b,w,Ht,s,r?.number_of_seasons]),Wn=Ze?.currentTime??0,Hn=Ze?.duration??0,pn=Ze?.completed===!0||Ze?.completed===1||Rn(Wn,Hn),[Ne,Ve]=S(!1),xe=P(!1),gn=P(null),Nt=P(null);v(()=>{xe.current=!1,Nt.current=null,Ve(!1)},[q,s,h]);const[Ie,Kt]=S(!1),[ht,Kn]=S(0),[tt,Yn]=S(!1),[Ke,nt]=S(!1),[Tr,vn]=S(!1),[Cr,jn]=S(""),[Yt,kr]=S(!1),[Er,yn]=S(!1),{isTheaterMode:Fe,toggleTheaterMode:Sn,handleLayoutClick:Nr}=hs();v(()=>{const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="t"&&Sn()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Sn]),bs(p,(O.length>0||yt!=="")&&!Fe&&!Ie&&!Ne&&!Ke);const xr=Hs(),[bt,Ir]=S(Os),Ar=T(e=>{Ir(e),Vs(e)},[]),he=P(!1),rt=P(null),_n=P(0),Gn=P(!1),Qn=P(0),J=P(null),xt=P(""),wr=dr(Wn,Hn),It=!he.current&&!xe.current&&(Ie||Ne||Ke||pn||wr),ft=P(It);ft.current=It;const pt=P(!1);v(()=>{pt.current=tt},[tt]);const Ye=T((e,n)=>{if(!q||!n||n<30)return;const i=Rn(e,n),u=i?n:e;Math.abs(u-_n.current)<10&&!i||(_n.current=u,On.mutate({mediaId:q,season:s,episode:h,currentTime:Math.floor(u),duration:Math.floor(n),completed:i,title:r?.title??null,poster:r?.poster??null,backdrop:r?.backdrop??null,year:r?.year??null,overview:r?.overview??null,tmdbId:r?.id??null,mediaType:A||"tv",adult:r?.adult?1:0}))},[q,s,h,On,r,A]),Ae=T((e,n)=>{sn();const i=new URLSearchParams(m);i.set("type",m.get("type")||"tv"),i.set("s",String(e)),i.set("e",String(n)),M(`${window.location.pathname}?${i.toString()}`)},[m,M,sn]),At=T(()=>{const e=l.current;if(!e||b||w==null){vn(!1);return}const n=e.duration||0,i=e.currentTime||0;vn(n>0&&i/n>=.8)},[b,w,l]),jt=T((e,n)=>["tv-sources",d,b?"movie":"tv",a,e,n,me],[d,b,a,me]),Gt=T(async(e,n)=>{if(!r||!a||!d)return{valid:!1,sources:[]};const i=b?"movie":"tv",u=await vt.tv.sources.query({provider:d,type:i,tmdbId:String(a),season:e,episode:n,title:r.title||"",year:r.year||"",totalSeasons:String(r.number_of_seasons||1),imdbId:r.imdb_id||"",...Z.length>0&&me?{server:me}:{}});return{valid:"valid"in u?u.valid:!1,error:"error"in u?u.error:void 0,sources:u.sources,referer:"referer"in u?u.referer:void 0,audioTracks:u.audioTracks,subtitles:"subtitles"in u?u.subtitles:void 0,servers:"servers"in u?u.servers:void 0,embedUrl:"embedUrl"in u?u.embedUrl:void 0}},[r,a,d,b,Z,me]),Xn=T(()=>{if(b||!r||!a||!d||L||w==null)return;const e=jt(s,w);R.getQueryState(e)?.status!=="success"&&R.prefetchQuery({queryKey:e,queryFn:()=>Gt(s,w),staleTime:300*1e3,gcTime:1800*1e3})},[b,r,a,d,L,w,s,R,jt,Gt]),Mr=T(()=>{if(ae)return;At();const e=l.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&Xn(),rt.current&&clearTimeout(rt.current),rt.current=setTimeout(()=>{Ye(e.currentTime,e.duration||0)},5e3))},[Ye,l,ae,At,Xn]),Lr=T(()=>{const e=l.current;if(!e||!r)return;rt.current&&clearTimeout(rt.current),Ye(e.currentTime,e.duration||0),Gn.current=!0;const n=Fs({seekInduced:Date.now()-Qn.current<qs,autoplayEnabled:bt,hasNext:!b&&w!=null,isFinal:b||w==null});n==="advance"&&w!=null?(j(w),Ae(s,w)):n==="prompt-next"?(xe.current=!1,he.current=!0,Ve(!0)):n==="prompt-complete"&&(jn(b?r.title:`${r.title} - Season ${s}`),nt(!0),xe.current=!0,he.current=!0)},[b,r,s,w,bt,Ye,Ae,l]),Br=T(()=>{Gn.current=!1,p.actions.onPlay()},[p.actions]),Pr=T(()=>{p.actions.onPause();const e=l.current;e&&!e.ended&&Ye(e.currentTime,e.duration||0)},[p.actions,Ye,l]),Rr=T(()=>{p.actions.onLoadedMetadata();const e=l.current;if(e){try{const n=parseFloat(localStorage.getItem("playerVolume")||"");isNaN(n)||(e.volume=Math.max(0,Math.min(1,n))),e.muted=localStorage.getItem("playerMuted")==="true"}catch{}if(J.current!=null&&J.current>0){try{e.currentTime=J.current}catch{}J.current=null}At()}},[p.actions,l,At]),Tn=T(()=>{const e=l.current;if(e&&J.current!=null&&J.current>0){try{e.currentTime=J.current}catch{}J.current=null}},[l]),zr=T(()=>{ht>0&&(J.current=ht);const e=l.current;if(e&&ht>0){try{e.currentTime=ht,J.current=null}catch{}e.play().catch(()=>{})}Kt(!1),he.current=!0},[ht,l]),Jn=T(()=>{J.current=null;const e=l.current;e&&(e.currentTime=0,e.play().catch(()=>{})),Kt(!1),he.current=!0},[l]),$r=T(()=>{xe.current=!0,Ve(!1),he.current=!0},[]),Dr=T(()=>{xe.current=!0,Ve(!1),he.current=!0,J.current=null;const e=l.current;if(e){try{e.currentTime=0}catch{}e.play().catch(()=>{})}},[l]),Zn=T(()=>{w!=null&&(xe.current=!0,Ve(!1),he.current=!0,j(w),Ae(s,w))},[w,s,Ae]),er=T(()=>{Se!=null&&(xe.current=!0,Ve(!1),nt(!1),he.current=!0,C(Se),j(1),Ae(Se,1))},[Se,Ae]),Or=T(async()=>{if(q)try{await qt.mutateAsync({id:q,status:"Completed"}),nt(!1),Ve(!1),M("/")}catch{}},[q,qt,M]);v(()=>{he.current=!1,gn.current=null,Kt(!1),vn(!1),Kn(0),Yn(!1),pt.current=!1,J.current=null,xt.current=`${q}:${s}:${h}`,_n.current=0},[q,s,h]),v(()=>{qn&&(Yn(!0),pt.current=!0)},[qn,q,s,h]),v(()=>{if(!Ze||he.current)return;const e=`${q}:${s}:${h}`;if(gn.current===e)return;gn.current=e;const n=Ze,i=n.currentTime??0,u=n.duration??0;dr(i,u)&&(Kn(i),Kt(!0))},[Ze,q,s,h]),v(()=>{if(!tt||he.current||xe.current||Ie||Ke||Ne)return;const e=`${q}:${s}:${h}`;if(Nt.current!==e){if(!pn){Un||(Nt.current=e);return}if(b){Nt.current=e,Ve(!0);return}if(!(!r||et<0||F.length===0)){if(Nt.current=e,w==null&&Se==null){r&&F.length>0&&(jn(`${r.title} - Season ${s}`),nt(!0),xe.current=!0,he.current=!0);return}Ve(!0)}}},[tt,pn,Un,Ie,Ke,Ne,b,w,Se,r,et,F.length,q,s,h]),v(()=>{(Ie||Ne)&&l.current&&l.current.pause()},[Ie,Ne,l]),v(()=>{const e=l.current;return()=>{rt.current&&clearTimeout(rt.current),e&&!e.ended&&Ye(e.currentTime,e.duration||0)}},[Ye,l]);const Cn=T(e=>{let n=null,i=!0;try{n=localStorage.getItem("tvLastSubtitle"),i=localStorage.getItem("tvSubtitlesEnabled")!=="false"}catch{}return $n(e,{lastKey:n,enabled:i})},[]),kn=T(e=>{if(!(e<0))try{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),tr=T(e=>{if(e.length===0)return 0;let n=null;try{n=localStorage.getItem("tvLastAudio")}catch{}if(n){const i=e.findIndex(f=>Bn(f)===n);if(i>=0)return i;const u=n.indexOf("|||"),c=u>=0?n.slice(0,u):n,I=u>=0?n.slice(u+3):n,$=e.findIndex(f=>f.language===c||f.label===I);if($>=0)return $}return $n(e,{lastKey:null,enabled:!0})},[]),{data:nr}=Ds(q||void 0),rr=Te(()=>(nr?.progress??[]).filter(n=>n.season===s&&(n.completed===1||n.completed===1||Rn(n.currentTime,n.duration))).map(n=>String(n.episode)),[nr,s]),sr=Te(()=>F.map(e=>({id:String(e.episode_number),label:`Episode ${e.episode_number}`,sublabel:e.name||void 0,thumbnail:e.still_path?`https://image.tmdb.org/t/p/w185${e.still_path}`:void 0})),[F]),ar=Te(()=>(r?.genres??[]).map(e=>e.name).slice(0,5),[r]),En=Te(()=>[r?.year,r?.status,r?.number_of_seasons?`${r.number_of_seasons} Season${r.number_of_seasons>1?"s":""}`:null,r?.number_of_episodes?`${r.number_of_episodes} Episodes`:null].filter(Boolean),[r]);v(()=>{if(G.length!==0&&!G.some(e=>e.id===d)){const e=G.find(n=>n.tier==="direct")?.id??G[0].id;qe(e);try{localStorage.setItem("tvProvider",e)}catch{}}},[G,d]),v(()=>{Bt([]),Pt(""),Tt(""),ve(!1)},[d]),v(()=>{if(Z.length!==0&&!Z.includes(me)){St(Z[0]);try{localStorage.setItem("tvServer",Z[0])}catch{}}},[Z,me]),v(()=>{if(!a){_(null),X([]),Pe(""),K(""),Xe("");return}const e=Number(a),n=A||"tv";_(null),X([]),Pe(""),K(""),Xe("");const i=parseInt(V.current.get("s")||"",10),u=parseInt(V.current.get("e")||"",10);C(isNaN(i)?1:i),j(isNaN(u)?1:u),$e(0),vt.tv.details.query({type:n,id:String(e)}).then(c=>{const I={id:c.id,title:c.title||"",overview:c.overview||"",vote_average:c.vote_average,year:c.year,poster:c.poster,backdrop:c.backdrop,imdb_id:c.imdb_id||void 0,adult:c.adult,seasons:c.seasons,number_of_seasons:c.number_of_seasons};_(I),I.seasons&&I.seasons.length>0&&isNaN(i)&&C(I.seasons[0].season_number)}).catch(()=>{})},[a,A]),v(()=>{if(!r||!a)return;if(!(r.seasons!==void 0||r.number_of_seasons!==void 0)){z([]);return}const n=parseInt(m.get("e")||"",10);vt.tv.episodes.query({id:String(a),season:String(s)}).then(i=>{const u=(i.episodes||[]).map(c=>({episode_number:c.episode_number,name:c.name||"",vote_average:c.vote_average,overview:c.overview||"",still_path:c.still_path||""}));z(u),u.length!==0&&j(c=>!isNaN(n)&&u.some(I=>I.episode_number===n)?n:u.some(I=>I.episode_number===c)?c:u[0].episode_number)}).catch(()=>{})},[r,a,s,m]),v(()=>{if(!L||!r||!a)return;Ln(`/api/tv/embed/${d}/${b?"movie":"tv"}/${a}?season=${s}&episode=${h}`).then(n=>{if(n.url)return Xe(n.url),Ln(`/api/resolve?url=${encodeURIComponent(n.url)}`).then(i=>{i.finalUrl&&Xe(i.finalUrl)})}).catch(()=>{})},[d,r,a,s,h,b,L]);const Qt=T(async()=>{if(!r||!a||!d||L||r.adult&&!Et)return;const e=`${q}:${s}:${h}`;Q(!0),K(""),ut.current.length===0&&(X([]),$e(0),He([]),it([]));try{const n=await R.fetchQuery({queryKey:jt(s,h),queryFn:()=>Gt(s,h),staleTime:3e5,gcTime:18e5});if(xt.current!==e){Q(!1);return}if(Q(!1),!n.valid||!n.sources?.length){K(n.error?`${n.error}`:Z.length>0?`No streams from ${me}. Try another server.`:"No streams available.");return}X(n.sources),Pe(e),n.servers?.length&&Bt(n.servers),n.embedUrl&&Pt(n.embedUrl),$e(0),n.referer&&Lt(n.referer);const i=n.audioTracks||[];He(i),x(i.length>0?tr(i):0);const u=n.subtitles||[];if(it(u),u.length>0){const $=Cn(u);ze($),kn($)}else ze(-1);const c=b?"movie":"tv",I=a;vt.tv.subtitles.query({type:c,tmdbId:String(I),season:String(s),episode:String(h)}).then($=>{if(xt.current!==e)return;const f=Array.isArray($.subtitles)?$.subtitles:[];f.length!==0&&it(re=>{const be=[...re,...f.filter(y=>!re.some(fe=>fe.url===y.url))];if(re.length===0){const y=Cn(be);ze(y),kn(y)}return be})}).catch(()=>{}),K("")}catch(n){if(xt.current!==e)return;Q(!1),K(n instanceof Error?n.message:"Failed to load streams.")}},[r,a,d,s,h,b,L,Et,Z,me,Cn,kn,tr,q,R,jt,Gt]),Nn=T(()=>{const e=l.current;e&&!isNaN(e.currentTime)&&(J.current=e.currentTime)},[l]),Vr=T(e=>{if(e==="Embed"){ve(!0);return}Nn(),ve(!1),St(e);try{localStorage.setItem("tvServer",e)}catch{}K("")},[Nn]),Fr=T(e=>{qe(e);try{localStorage.setItem("tvProvider",e)}catch{}},[]);v(()=>{d&&r&&!L&&Qt()},[d,r,Qt,L]),v(()=>{if(!l.current)return;if(ce.current&&(ce.current.destroy(),ce.current=null),L||Je){const f=l.current;f&&(f.pause(),f.removeAttribute("src"),f.load());return}let e=!1;if(ae){const f=l.current;return f&&(f.pause(),f.removeAttribute("src"),f.load(),f.src="/av-sync-test.mp4",ft.current||f.play().catch(()=>{})),()=>{e=!0}}if(Vt.current!=null&&(J.current=Vt.current,Vt.current=null),xt.current===`${q}:${s}:${h}`&&J.current==null&&!ft.current)try{const f=l.current;f&&!f.ended&&f.currentTime>1&&(J.current=f.currentTime)}catch{}const i=J.current??0,u=!Ce&&Be===`${q}:${s}:${h}`?Je?"":O[Ee]?.url||"":"";if(!u){try{l.current?.pause(),l.current?.removeAttribute("src"),l.current?.load()}catch{}return}const c=l.current;c.pause(),c.removeAttribute("src"),c.load(),p.actions.resetMediaState();const I=`/api/tv/stream-proxy?url=${encodeURIComponent(u)}&referer=${encodeURIComponent(lt)}&provider=${encodeURIComponent(d)}`;O[Ee]?.type==="hls"?(async()=>{const f=await Us();if(!e)if(f&&f.isSupported()){const re=Oa()||document.body.classList.contains("low-end"),be=re?60:180,y=new f({enableWorker:!0,lowLatencyMode:!1,startPosition:i>0?i:-1,maxBufferLength:be,maxMaxBufferLength:be+(re?30:60),backBufferLength:re?30:60,maxBufferSize:(re?120:360)*1e3*1e3,fragLoadPolicy:{default:{maxTimeToFirstByteMs:15e3,maxLoadTimeMs:45e3,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:3,retryDelayMs:800,maxRetryDelayMs:6e3}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:25e3,timeoutRetry:{maxNumRetry:1,retryDelayMs:500,maxRetryDelayMs:2e3},errorRetry:{maxNumRetry:2,retryDelayMs:800,maxRetryDelayMs:4e3}}}});ce.current=y,y.on(f.Events.ERROR,(D,N)=>{N.fatal&&(K(`Stream failed (${N.details}). Try another source or reload.`),Q(!1),y.destroy(),ce.current=null)}),y.loadSource(I),y.attachMedia(c);const fe=()=>{let D=!1,N=0;try{D=localStorage.getItem("tvSubtitlesEnabled")==="true";const k=parseInt(localStorage.getItem("tvSelectedSubtitle")||"0",10);!isNaN(k)&&k>=0&&(N=k)}catch{}return{enabled:D,index:N}},U=()=>{if(typeof y.subtitleTrack!="number")return;if(ue.current.length>0){y.subtitleTrack=-1;return}const D=Array.isArray(y.subtitleTracks)?y.subtitleTracks:[];if(D.length===0){y.subtitleTrack=-1;return}const N=fe();if(N.enabled){const k=N.index<D.length?N.index:0;y.subtitleTrack=k,ze(k),bn()}else y.subtitleTrack=-1};$a(y,f.Events,{getWant:()=>Rt.current,onResolve:D=>x(D)}),y.on(f.Events.MANIFEST_PARSED,()=>{U(),(i>0||!ft.current&&pt.current)&&c.play().catch(()=>p.actions.setShowControls(!0))}),y.on(f.Events.SUBTITLE_TRACKS_UPDATED,()=>{U()}),y.on(f.Events.SUBTITLE_TRACK_SWITCH,(D,N)=>{if(ue.current.length>0){if(N.id!==-1)try{y.subtitleTrack=-1}catch{}return}const k=Array.isArray(y.subtitleTracks)?y.subtitleTracks:[];if(k.length!==0){if(N.id===-1){const _e=fe();if(_e.enabled){const oe=_e.index<k.length?_e.index:0;y.subtitleTrack=oe;return}}ze(N.id),bn()}})}else Ws(c)&&(c.src=I,(i>0||!ft.current&&pt.current)&&c.play().catch(()=>{K("Failed to play stream. Try another source.")}))})():(c.src=I,(i>0||!ft.current&&pt.current)&&c.play().catch(()=>{K("Failed to play stream. Try another source.")}));const $=()=>{const be=c.error?.code===4?"Video source not supported or not found":"Failed to load video stream";K(`${be}. The source may be invalid or expired. Try switching source or reloading.`),Q(!1)};return c.addEventListener("error",$),()=>{e=!0,c.removeEventListener("error",$)}},[O,Be,Ce,Ee,d,lt,L,Je,l,Vt,ae,q,s,h,Tn,bn,p.actions]),v(()=>{if(!tt||Ie||Ne||Ke||It||L||ae)return;const e=l.current;!e||!e.paused||e.ended||e.readyState<1||(Tn(),e.play().catch(()=>{}))},[tt,Ie,Ne,Ke,It,L,ae,Tn,l]),v(()=>{const e=ce.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=ge)},[ge]),v(()=>{const e=ce.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||ue.current.length>0||(le>=0?e.subtitleTrack=le:e.subtitleTrack=-1)},[le]),v(()=>{const e=l.current;if(!(!e||L)&&(e.querySelectorAll("track").forEach(n=>n.remove()),ue.current=[],Y.length!==0&&(Y.forEach(n=>{const i=document.createElement("track");i.kind="subtitles",i.label=n.label||n.language||"Unknown",i.srclang=n.language||n.label||"en";const u=`/api/subtitle-proxy?url=${encodeURIComponent(n.url)}&referer=${encodeURIComponent(lt)}`;i.src=u,i.addEventListener("load",()=>{const c=ue.current.indexOf(i),I=i.track;if(I&&c>=0){const $=c===dt.current;I.mode=$&&!hn.current?"showing":"hidden"}}),e.appendChild(i),ue.current.push(i)}),Y.length>0)))try{const n=ce.current;n&&typeof n.subtitleTrack=="number"&&n.subtitleTrack!==-1&&(n.subtitleTrack=-1)}catch{}},[Y,lt,L,d,l]),v(()=>{const e=l.current;if(!e||L)return;const n=ce.current;ue.current.length>0&&n&&typeof n.subtitleTrack=="number"&&Array.isArray(n.subtitleTracks)&&n.subtitleTracks.length>0&&(n.subtitleTrack=-1);const i=()=>{const I=Dn(p.state.subtitleFontSize,e.clientHeight||720),$=Math.max(0,Math.min(100,100-p.state.subtitlePosition)),f=()=>{const U=I*16,D=e.videoHeight||e.clientHeight||720,N=e.videoWidth||e.clientWidth||1280;return{step:U*1.3/D*100,chars:Math.max(20,Math.floor(N/(U*.55)))}},re=(U,D)=>{const N=U;N.snapToLines=!1,N.line=D},be=U=>{if(!U.cues)return;Array.from(U.cues).forEach(oe=>re(oe,$));const D=Array.from(U.activeCues??[]);if(D.length<=1){D.forEach(oe=>re(oe,$));return}const{step:N,chars:k}=f();let _e=$;for(let oe=D.length-1;oe>=0;oe--){const je=String(D[oe].text??"").replace(/<[^>]*>/g,"").split(`
3
- `).reduce((Jt,wt)=>Jt+Math.max(1,Math.ceil(wt.length/k)),0);_e=Math.max(0,_e-je*N),re(D[oe],_e),_e-=N*.4}},y=ue.current;if(y.length>0){y.forEach((U,D)=>{const N=U.track;if(!N)return;const k=D===le;N.mode=k&&!ye?"showing":"hidden",k&&!ye&&be(N)});return}const fe=Array.from(e.textTracks);fe.length!==0&&fe.forEach((U,D)=>{const N=D===le;U.mode=N&&!ye?"showing":"hidden",N&&!ye&&be(U)})};i();const u=()=>i();e.textTracks.addEventListener("addtrack",u),e.addEventListener("loadedmetadata",i,{once:!0});const c=window.setTimeout(i,600);return()=>{e.textTracks.removeEventListener("addtrack",u),e.removeEventListener("loadedmetadata",i),window.clearTimeout(c)}},[le,Y,L,d,l,ye,p.state.subtitleFontSize,p.state.subtitlePosition]),v(()=>{if(!ye)return;const e=l.current,n=B.current;if(!e||!n)return;const i=mt/1e3,u=cn/1e3,c=new Set;let I=[],$=-1,f=-1,re=-1,be=-1,y=0,fe=0,U=!1;const D=()=>{const W=dt.current;if(W<0)return null;const Ge=ue.current;return Ge.length>0?Ge[W]?.track??null:Array.from(e.textTracks)[W]??null},N=(W,Ge)=>{const pe=W.cues;if(!pe||pe.length===0)return Array.from(W.activeCues??[]);let st=0,at=pe.length;for(;st<at;){const we=st+at>>>1;pe[we].endTime+i<Ge?st=we+1:at=we}const Mt=[];for(let we=st;we<pe.length;we++){const Zt=pe[we];if(Zt.startTime+i>Ge)break;Zt.endTime+i>=Ge&&Mt.push(Zt)}return Mt},k=()=>{const W=D(),Ge=e.currentTime-u,pe=W?N(W,Ge):[],st=e.clientWidth,at=e.clientHeight,Mt=e.videoWidth,we=e.videoHeight;if(pe.length===I.length&&pe.every((An,wn)=>An===I[wn])&&st===$&&at===f&&Mt===re&&we===be||(I=pe,$=st,f=at,re=Mt,be=we,n.textContent="",pe.length===0))return;const lr={fontSize:Dn(p.state.subtitleFontSize,at),position:p.state.subtitlePosition,bgOpacity:p.state.subtitleBgOpacity,bgColor:p.state.subtitleBgColor,textColor:p.state.subtitleTextColor,edge:p.state.subtitleEdge,bold:p.state.subtitleBold},Hr=fs(lr),Kr=ps(e,lr.position);pe.forEach((An,wn)=>{const cr=String(An.text??"");if(!gs(cr).trim())return;const Mn=document.createElement("div"),Yr=(pe.length-1-wn)*1.7;Mn.style.cssText=`${Hr}
4
- bottom: calc(${Kr}px + ${Yr}em);`,Mn.innerHTML=vs(cr),n.appendChild(Mn)})},_e=()=>{Array.from(e.textTracks).forEach(W=>{c.has(W)||(c.add(W),W.addEventListener("cuechange",k))})},oe=()=>{_e(),k()},In=()=>{if(U||fe)return;const W=()=>{fe=0,!(U||e.paused||e.ended)&&(k(),In())};fe=window.requestAnimationFrame(W)},je=e,Jt=()=>{y=0,k(),!U&&je.requestVideoFrameCallback&&(y=je.requestVideoFrameCallback(Jt))},wt=()=>{k(),je.requestVideoFrameCallback?y||(y=je.requestVideoFrameCallback(Jt)):In()};_e(),e.textTracks.addEventListener("addtrack",oe),e.textTracks.addEventListener("removetrack",oe),e.addEventListener("timeupdate",k),e.addEventListener("seeked",k),e.addEventListener("loadedmetadata",k),e.addEventListener("play",wt);const or=Array.from(e.querySelectorAll("track"));or.forEach(W=>W.addEventListener("load",k));const ir=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>k());return ir?.observe(e),k(),wt(),()=>{U=!0,c.forEach(W=>W.removeEventListener("cuechange",k)),e.textTracks.removeEventListener("addtrack",oe),e.textTracks.removeEventListener("removetrack",oe),e.removeEventListener("timeupdate",k),e.removeEventListener("seeked",k),e.removeEventListener("loadedmetadata",k),e.removeEventListener("play",wt),or.forEach(W=>W.removeEventListener("load",k)),ir?.disconnect(),fe&&window.cancelAnimationFrame(fe),y&&je.cancelVideoFrameCallback&&je.cancelVideoFrameCallback(y),n.textContent=""}},[ye,mt,le,Y,cn,l,p.state.subtitleFontSize,p.state.subtitlePosition,p.state.subtitleBgOpacity,p.state.subtitleBgColor,p.state.subtitleTextColor,p.state.subtitleEdge,p.state.subtitleBold]);const xn=()=>{_(null),X([]),Xe(""),M(-1)},qr=T(e=>{C(e),j(1),Ae(e,1)},[Ae]),Xt=!b&&r?.seasons&&r.seasons.length>1?t("label",{className:g.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{value:s,onChange:e=>qr(parseInt(e.currentTarget.value,10)||1),className:g.select,children:r.seasons.map(e=>t("option",{value:e.season_number,children:["Season ",e.season_number," (",e.episode_count," ep)"]},e.season_number))})]}):null,gt=T(e=>{const n=parseInt(e,10);if(!isNaN(n)){try{l.current?.pause()}catch{}j(n),Ae(s,n)}yn(!1)},[s,Ae,l]);v(()=>{if(b)return;const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="n"&&(w!=null?gt(String(w)):ts.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[b,w,gt]);const Ur=e=>{x(e);try{const i=Re[e];i&&localStorage.setItem("tvLastAudio",Bn(i))}catch{}const n=ce.current;n&&n.audioTrack!==void 0&&(n.audioTrack=e)},Wr=e=>{ze(e);try{if(e===-1)localStorage.setItem("tvSubtitlesEnabled","false");else{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e));const c=Y[e];c&&localStorage.setItem("tvLastSubtitle",Bn(c))}}catch{}const n=l.current,i=ce.current;if(i&&typeof i.subtitleTrack=="number"&&Array.isArray(i.subtitleTracks)&&i.subtitleTracks.length>0&&(i.subtitleTrack=ue.current.length>0||e<0?-1:e),!n)return;const u=ue.current;if(u.length>0){u.forEach((c,I)=>{const $=c.track;if(!$)return;const f=I===e;$.mode=f&&!ye?"showing":"hidden"});return}Array.from(n.textTracks).forEach((c,I)=>{const $=I===e;c.mode=$&&!ye?"showing":"hidden"})};return v(()=>{if(!r){document.title="TV & Movies - dango";return}document.title=b?`${r.title} - dango`:`${r.title} - Season ${s} Episode ${h} - dango`},[r,b,s,h]),v(()=>{if(!r||b)return;const e=new URLSearchParams(m),n=e.get("s"),i=e.get("e"),u=String(s),c=String(h);n===u&&i===c||(e.set("type",m.get("type")||"tv"),e.set("s",u),e.set("e",c),M(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[r,b,s,h,m,M]),t("div",{className:`${Me.playerPageLayout} ${Fe?Me.theaterMode:""} ${b?Me.noSidebar:""}`,onClick:Nr,children:[Fe&&t(ys,{videoRef:l,active:mn.enabled&&!L&&O.length>0&&!ke&&!(r?.adult&&!Et),settings:mn}),!Fe&&!b&&t("aside",{className:Me.episodeSidebar,children:r?t(Ss,{episodes:sr,currentEpisode:String(h),watchedEpisodes:rr,onEpisodeClick:gt,header:Xt}):t(_s,{variant:"sidebar"})}),t("div",{className:Me.playerMain,children:[r&&t("div",{className:g.playerSection,onContextMenu:e=>e.preventDefault(),style:r.adult&&!Et?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:L&&yt?t("iframe",{src:yt,className:g.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!L&&Ct?t("iframe",{src:Ct,className:g.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!L&&(O.length>0||Ce)?t(Le,{children:[ke&&t(hr,{error:ke,onRetry:Qt}),t(Ba,{player:p,title:r.title,episodeLabel:b?void 0:`S${s} E${h}`,audioTracks:Re,selectedAudioTrack:ge,onAudioTrackChange:Ur,subtitles:Y,selectedSubtitle:le,onSubtitleChange:Wr,streams:O,resolutionIdx:Ee,onResolutionChange:e=>{Nn(),$e(e)},onBack:xn,videoDelayEnabled:ne,onVideoDelayToggle:zt,videoDelayMs:ee,onVideoDelayChange:$t,onCalibrateAvSync:an,subtitleDelayMs:mt,onSubtitleDelayChange:pr,showNextEpisodeButton:Tr&&!Ie&&!Ne&&!Ke,onNextEpisode:Zn,isLoading:Ce,isTheaterMode:Fe,onTheaterModeToggle:Sn,ambientSettings:mn,onAmbientChange:gr,children:[t("video",{ref:l,autoPlay:tt&&!It,playsInline:!0,disablePictureInPicture:!0,className:`${g.video} ${dn?g.videoHidden:""}`,onTimeUpdate:Mr,onEnded:()=>{ae||Lr()},onPlay:Br,onPause:Pr,onSeeked:()=>{Qn.current=Date.now(),At()},onLoadedMetadata:Rr,onVolumeChange:p.actions.onVolumeChange,onWaiting:p.actions.onWaiting,onPlaying:p.actions.onPlaying,onCanPlay:p.actions.onCanPlay,onContextMenu:e=>e.preventDefault(),onError:()=>{K("Video failed to load. Try another server or reload."),Q(!1)}}),t("canvas",{ref:kt,className:`${g.delayCanvas} ${dn?g.delayCanvasActive:""}`}),ye&&t("div",{ref:B,className:g.subtitleOverlay}),t(Ts,{isOpen:Dt,ms:ee,onChange:$t,onApply:on,onClose:Ot,testClipActive:ae,onTestClip:ln})]})]}):ke&&!L?t(hr,{error:ke,onRetry:Qt}):null}),!Fe&&r&&t(Cs,{}),!Fe&&Xt&&t("div",{className:g.mobileSeasonRow,children:Xt}),!Fe&&r&&t("div",{className:de.streamPanel,children:[t("div",{className:g.providerSelectWrap,children:t("label",{className:g.controlLabel,children:["Provider",t("select",{value:d,onChange:e=>Fr(e.currentTarget.value),className:g.select,disabled:G.length===0,children:Qe?t("option",{value:"",children:"Loading..."}):G.length===0?t("option",{value:"",children:"No providers available"}):t(Le,{children:[E.length>0&&t("optgroup",{label:"Direct HLS",children:E.map(e=>t("option",{value:e.id,children:e.label},e.id))}),te.length>0&&t("optgroup",{label:"Embeds",children:te.map(e=>t("option",{value:e.id,children:e.label},e.id))})]})})]})}),!L&&(Ce?t("div",{className:g.sourceLoader,children:t("div",{className:g.ringSpinner})}):t(Ra,{servers:se,selectedServer:Oe?"Embed":me,onServerSelect:Vr}))]}),!Fe&&r&&t("div",{className:Me.playerInfoContainer,children:[t("div",{className:Me.playerInfoHeader,children:[t("div",{className:Me.playerAnimeCard,children:r.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"})}),t("div",{className:Me.videoTitleSection,children:[t("div",{className:de.titleContainer,children:[t("h1",{children:r.title}),t("div",{className:g.meta,children:[t("span",{className:g.year,children:r.year}),r.vote_average!=null&&r.vote_average>0&&t("span",{className:g.rating,children:[t(H,{name:"star",size:12}),Number(r.vote_average).toFixed(1)]}),t("span",{className:`${g.typeBadge} ${g[b?"movie":"tv"]}`,children:b?"Movie":"TV Show"})]}),ar.length>0&&t("div",{className:g.genreRow,children:ar.map(e=>t("span",{className:g.genreChip,children:e},e))}),En.length>0&&t("div",{className:g.metaRow,children:En.map((e,n)=>t("span",{children:[e,n<En.length-1?" · ":""]},`${e}-${n}`))})]}),t("div",{className:de.controls,children:[t("button",{className:`${de.watchlistBtn} ${Ut?de.inList:""}`,onClick:_r,disabled:Sr,type:"button",children:[Ut?t(H,{name:"check",size:14}):t(H,{name:"plus",size:14}),Ut?"In Watchlist":"Add to Watchlist"]}),!b&&t(Le,{children:[t("button",{className:`${de.watchlistBtn}`,onClick:()=>fn!=null&&gt(String(fn)),disabled:fn==null,type:"button",children:[t(H,{name:"chevron-left",size:14}),"Prev EP"]}),t("button",{className:`${de.watchlistBtn}`,onClick:()=>w!=null&&gt(String(w)),disabled:w==null,type:"button",children:["Next EP",t(H,{name:"chevron-right",size:14})]}),!b&&t("button",{className:`${de.watchlistBtn} ${de.modeToggleBtn} ${bt?de.modeToggleActive:""}`,onClick:()=>Ar(!bt),type:"button","aria-pressed":bt,children:bt?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),xr&&t("button",{className:`${de.watchlistBtn}`,onClick:()=>yn(!0),type:"button",children:[t(H,{name:"list-ul",size:14}),"Episodes"]})]})]})]})]}),t("div",{className:Me.infoColumns,children:[t("div",{className:`${de.descriptionSection} ${de.synopsisFlat}`,children:[t("h3",{children:"Synopsis"}),t(Ks,{text:r.overview,emptyText:"No description available."}),t("button",{className:de.detailsToggleBtn,onClick:()=>kr(!Yt),type:"button",children:[Yt?t(H,{name:"chevron-up"}):t(H,{name:"chevron-down"}),Yt?"Hide Details":"Show Details"]})]}),Yt&&t("div",{className:g.detailGrid,children:[r.first_air_date&&t("div",{className:g.detailItem,children:[t("strong",{children:b?"Release Date":"First Air Date"}),t("span",{children:r.first_air_date})]}),r.last_air_date&&t("div",{className:g.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:r.last_air_date})]}),r.networks&&r.networks.length>0&&t("div",{className:g.detailItem,children:[t("strong",{children:"Networks"}),t("span",{children:r.networks.map(e=>e.name).join(", ")})]}),r.created_by&&r.created_by.length>0&&t("div",{className:g.detailItem,children:[t("strong",{children:"Created By"}),t("span",{children:r.created_by.map(e=>e.name).join(", ")})]}),r.episode_run_time&&r.episode_run_time.length>0&&t("div",{className:g.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[r.episode_run_time[0]," min"]})]}),r.imdb_id&&t("div",{className:g.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${r.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:g.imdbLink,children:"View on IMDb"})]})]})]})]}),!b&&t(ks,{isOpen:Er,onClose:()=>yn(!1),episodes:sr,currentEpisode:String(h),watchedEpisodes:rr,onEpisodeClick:gt,header:Xt}),r?.adult&&!Et&&t(ws,{isOpen:!0,onClose:xn,onGrant:vr}),t(Es,{isOpen:Ie,onClose:Jn,title:"Resume Watching",message:t(Le,{children:["You were at ",t("strong",{children:nn(ht)})]}),restartLabel:"Start from Beginning",onResume:zr,onRestart:Jn}),t(ur,{isOpen:Ne,onClose:$r,title:b?"Movie Completed":"Episode Completed",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:b?t(Le,{children:"You've already watched this movie."}):t(Le,{children:["You've already watched"," ",t("strong",{children:["Season ",s," Episode ",h]}),". Would you like to continue?"]})}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(ot,{variant:"secondary",onClick:Dr,children:"Replay"}),w!=null?t(ot,{onClick:Zn,children:["Watch EP ",w]}):Se!=null?t(ot,{onClick:er,children:["Start Season ",Se]}):null]})]})}),t(ur,{isOpen:Ke,onClose:()=>nt(!1),title:b?"Movie Completed!":Se!=null?"Season Complete!":"Show Completed!",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t(H,{name:"check-circle",size:48,style:{color:"var(--accent-lighter)",marginBottom:"0.5rem"}}),t("p",{style:{fontSize:"1.1rem",fontWeight:600},children:Cr}),t("p",{style:{color:"var(--text-secondary)"},children:b?"You finished this movie!":Se!=null?`You finished Season ${s}.`:"Congratulations! You finished all available episodes."}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(ot,{variant:"secondary",onClick:()=>nt(!1),children:"Close"}),Se!=null?t(ot,{onClick:er,children:["Start Season ",Se]}):t(Le,{children:[t(ot,{onClick:()=>{nt(!1),xn()},children:"Back to Details"}),Ut&&t(ot,{onClick:Or,disabled:qt.isPending,children:qt.isPending?"Saving...":"Move to Completed"})]})]})]})}),!r&&t("div",{className:g.statusMsg,children:[t(H,{name:"spinner",className:g.spinner})," Loading..."]})]})]})};export{Ro as default};
@@ -1 +0,0 @@
1
- const o=.8;const c=2e3,a="autoplayEnabled",r=(e,t)=>t>0&&e>=t*.8,E=(e,t)=>e>5&&!r(e,t),S=()=>{try{return localStorage.getItem(a)==="true"}catch{return!1}},d=e=>{try{localStorage.setItem(a,String(e))}catch{}},l=["finished","completed","complete","ended"],u=(e,t,n)=>e.length>0&&!!t&&e[e.length-1]===t&&l.some(s=>String(n||"").trim().toLowerCase().includes(s)),I=e=>e.seekInduced?"none":e.autoplayEnabled&&e.hasNext?"advance":e.hasNext?"prompt-next":e.isFinal?"prompt-complete":"none";export{o as C,c as S,r as a,I as d,E as h,u as i,S as l,d as s};