@serifpersia/dango 3.5.8 → 3.6.0

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 (57) hide show
  1. package/README.md +10 -2
  2. package/client/dist/assets/{AnimeCard-Vxac3CKU.js → AnimeCard-CEDL_2lC.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-z1nSbaco.js → AnimeInfo-mVGUoF9q.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-Brb3TFXh.js → AnimeInfoPage-a1-1F_la.js} +2 -2
  5. package/client/dist/assets/{Asmr-BvM8UKQ3.js → Asmr-CCMuiaoR.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-CndzdTHo.js → AsmrResetProgressModal-CiwgOhH2.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-XH4E6Sfp.js → AvSyncCalibrator-PqA6B5Ey.js} +1 -1
  8. package/client/dist/assets/{Home-CW24x23t.js → Home-BmTp0Dx7.js} +1 -1
  9. package/client/dist/assets/{Insights-DLqUhamB.js → Insights-C89oz_3z.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-BcHi-OIb.js → LibraryListPage-DOSPLTiR.js} +1 -1
  11. package/client/dist/assets/{ListeningList-gNfL7dv7.js → ListeningList-IHSyufXX.js} +1 -1
  12. package/client/dist/assets/{Manga-B26xL6Dq.js → Manga-H4hG-3K8.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-CFI4_GgJ.js → MangaInfoPage-Bjz2NwLc.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-CL2TKQc8.js → MangaReadPage-DZakUml0.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-yIv7jY4h.js → MangaResetProgressModal-kbpad7Vl.js} +1 -1
  16. package/client/dist/assets/{Mature-q8lBiSsb.js → Mature-DfODnRR8.js} +1 -1
  17. package/client/dist/assets/{MediaCard-DM2d5vjg.js → MediaCard-fN3GQyTJ.js} +1 -1
  18. package/client/dist/assets/{Music-Dbswx5jU.js → Music-CFVwJyIo.js} +1 -1
  19. package/client/dist/assets/{OptionListMenu-BQnYYHpM.js → OptionListMenu-BjoortST.js} +1 -1
  20. package/client/dist/assets/{Player-lSQC6rcr.js → Player-DMeWl-5s.js} +2 -2
  21. package/client/dist/assets/{PlayerSettings-Bns1A0RY.js → PlayerSettings-DaG98x1K.js} +1 -1
  22. package/client/dist/assets/{QueueOptionsButton-CGQAqTtM.js → QueueOptionsButton-MpSKva6y.js} +1 -1
  23. package/client/dist/assets/{QueueRail-ByOPjeHY.js → QueueRail-CtLxXvR_.js} +1 -1
  24. package/client/dist/assets/{Radio-C7BD7L1o.js → Radio-D1zoU38z.js} +1 -1
  25. package/client/dist/assets/{ReadingList-L0kcgqzm.js → ReadingList-C_oRyOHJ.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-aeUUSFYc.js → ResetProgressModal-CpbOV9Sk.js} +1 -1
  27. package/client/dist/assets/{Search-DP0QouO-.js → Search-Cs8U1ZGO.js} +1 -1
  28. package/client/dist/assets/{Settings-C7iOaCMq.js → Settings-BgcOeTlE.js} +1 -1
  29. package/client/dist/assets/{SkeletonGrid-DyG9u20F.js → SkeletonGrid-gCly-9x7.js} +1 -1
  30. package/client/dist/assets/{Trackers-COKJmOew.js → Trackers-DoHHWI2D.js} +1 -1
  31. package/client/dist/assets/{Tv-QYoBwOlH.js → Tv-DhLdh3WF.js} +1 -1
  32. package/client/dist/assets/{TvInfo-DS9pbimS.js → TvInfo-CfYJPE-C.js} +1 -1
  33. package/client/dist/assets/{TvPopup-C9Xhv1dW.js → TvPopup-BBIe0fHF.js} +1 -1
  34. package/client/dist/assets/{TvSearch-BjyAFYCg.js → TvSearch-Bfp_r265.js} +1 -1
  35. package/client/dist/assets/{TvWatchlist-CAuCk-AT.js → TvWatchlist-DNcVUBXZ.js} +1 -1
  36. package/client/dist/assets/{Watchlist-hgU-RPay.js → Watchlist-DnC7uDc4.js} +1 -1
  37. package/client/dist/assets/{hls-E2REEW_P.js → hls-B9wsDt6U.js} +1 -1
  38. package/client/dist/assets/index-C6HMOCqo.css +1 -0
  39. package/client/dist/assets/index-CfgPGaUO.js +178 -0
  40. package/client/dist/assets/{useAnimeInfoData-CgmVQOsk.js → useAnimeInfoData-Dpkjj68s.js} +1 -1
  41. package/client/dist/assets/{useAsmr-BxU_JBAI.js → useAsmr-QqLyjBbR.js} +1 -1
  42. package/client/dist/assets/{useAsmrPopup-BYMMk2rG.js → useAsmrPopup-CnYAAhDj.js} +1 -1
  43. package/client/dist/assets/{useMangaLibrary-BrKhv-sI.js → useMangaLibrary-CxRsa2lr.js} +1 -1
  44. package/client/dist/assets/{useMangaPopup-BQe7Ug-A.js → useMangaPopup-CXnu2h4Y.js} +1 -1
  45. package/client/dist/assets/{useProviders-swR4Flu5.js → useProviders-DDPMV3HX.js} +1 -1
  46. package/client/dist/assets/{useTv-mq8TkTZl.js → useTv-BkZAFGaD.js} +1 -1
  47. package/client/dist/assets/{useTvLibrary-BuMreQuF.js → useTvLibrary-CL3kMD_c.js} +1 -1
  48. package/client/dist/favicon.svg +11 -0
  49. package/client/dist/index.html +3 -3
  50. package/client/dist/repo_logo.svg +53 -78
  51. package/package.json +2 -2
  52. package/server/package.json +1 -1
  53. package/client/dist/assets/index-Ck-R0JKv.css +0 -1
  54. package/client/dist/assets/index-_iy8RyKU.js +0 -178
  55. package/client/dist/favicon.ico +0 -0
  56. package/client/dist/logo-mochi.png +0 -0
  57. package/client/dist/logo-sakura.png +0 -0
@@ -1,4 +1,4 @@
1
- import{d as s,A as H,h as A,u as e,q as ie,S as ke,T as Ce,p as _e,g as ce,_ as Se}from"./vendor-core-DfaOB3Rn.js";import{d as Ne,t as _,B as T,M as E,j as he,h as Te,z as de,F as te,G as Ie,T as Re,u as xe,e as Le,H as De,y as ae,A as Pe,V as Ae,I as Oe}from"./index-_iy8RyKU.js";import{u as oe}from"./vendor-query-BBT5_sHx.js";import{T as q}from"./ToggleSwitch-CN_ppEc9.js";import{I as Y}from"./vendor-icons-DrybRNxP.js";const ne={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},se=["name","nativeName","englishName"],re={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ge=()=>{const{titlePreference:t,setTitlePreference:r,loading:i}=Ne(),[l,o]=s(re[t]),[v,b]=s(!1),h=H(null);A(()=>{i||o(re[t])},[t,i]);const n=async()=>{if(v)return;b(!0);const g=(se.indexOf(t)+1)%se.length,p=se[g],d=re[p];h.current&&(h.current.style.transform="translateX(-100%)",h.current.style.opacity="0"),setTimeout(async()=>{o(d),r(p),h.current&&(h.current.style.transition="none",h.current.style.transform="translateX(100%)",h.current.style.opacity="0",h.current.offsetWidth,h.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",h.current.style.transform="translateX(0)",h.current.style.opacity="1");try{await _.settings.set.mutate({key:"titlePreference",value:p})}catch(S){console.error("Error saving title preference:",S)}finally{b(!1)}},300)};return i?e("p",{children:"Loading title preference..."}):e("div",{className:ne["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:n,className:ne["toggle-button"],disabled:v,children:e("span",{ref:h,className:ne["toggle-label"],children:l})})]})},Me="_settingsHeader_14a5d_1",Ue="_pageTitle_14a5d_6",ze="_pageSubtitle_14a5d_14",Ee="_settingsLayout_14a5d_20",$e="_sidebar_14a5d_27",qe="_sidebarIndicator_14a5d_35",Fe="_sidebarItem_14a5d_50",Ke="_active_14a5d_72",je="_mainContent_14a5d_80",He="_tabContent_14a5d_85",We="_sectionCard_14a5d_103",Be="_settingItem_14a5d_127",Ve="_settingRow_14a5d_132",Qe="_controls_14a5d_145",Ye="_status_14a5d_151",m={settingsHeader:Me,pageTitle:Ue,pageSubtitle:ze,settingsLayout:Ee,sidebar:$e,sidebarIndicator:qe,sidebarItem:Fe,active:Ke,mainContent:je,tabContent:He,sectionCard:We,settingItem:Be,settingRow:Ve,controls:Qe,status:Ye},Je="_sectionCard_wt900_12",Xe="_title_wt900_22",Ze="_signIn_wt900_29",et="_userInfo_wt900_36",tt="_warning_wt900_58",at="_formGroup_wt900_65",nt="_label_wt900_69",st="_inputWrapper_wt900_79",rt="_input_wt900_79",it="_select_wt900_103",ot="_actions_wt900_140",lt="_hr_wt900_148",u={sectionCard:Je,title:Xe,signIn:Ze,userInfo:et,warning:tt,formGroup:at,label:nt,inputWrapper:st,input:rt,select:it,actions:ot,hr:lt},ct=()=>{const[t,r]=s(!0),[i,l]=s(!1),[o,v]=s(!1),[b,h]=s(null),[n,c]=s({status:"idle"}),[g,p]=s(!1),[d,S]=s(""),[y,k]=s(!1),R=H(null),[x,L]=s({show:!1,message:"",type:"info"}),D=()=>{R.current&&(window.clearInterval(R.current),R.current=null)},w=ie(f=>{v(f.authenticated),h(f.user||f.device.user||null),c(f.device),p(!!f.hasCustomClientId)},[]),C=ie(async()=>{const f=await _.auth.githubStatus.query();w(f)},[w]),P=async()=>{try{const f=await _.auth.githubPoll.query();c(f),f.status==="success"?(D(),await C(),L({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(D(),L({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{D(),L({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},M=(f=5)=>{D(),R.current=window.setInterval(P,Math.max(f,5)*1e3)};A(()=>(C().catch(()=>{L({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),D),[C]);const N=async()=>{l(!0);try{const f=await _.auth.githubStart.mutate();c(f),M(f.verification?.interval)}catch(f){L({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{l(!1)}},O=async()=>{try{await _.auth.githubLogout.mutate(),v(!1),h(null),c({status:"idle"}),L({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{L({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},U=async()=>{k(!0);try{await _.auth.saveGithubAuth.mutate({clientId:d}),S(""),await C(),L({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},K=async()=>{k(!0);try{await _.auth.saveGithubAuth.mutate({clientId:""}),S(""),await C(),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:u.sectionCard,children:[e("h3",{className:u.title,children:"GitHub Cloud Sync"}),e("p",{className:u.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),o&&b?e("div",{className:u.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:b.name||b.login})]}),e(T,{variant:"danger",onClick:O,children:"Sign Out"})]}):e("div",{className:u.signIn,children:e(T,{onClick:N,disabled:i||n.status==="pending",children:i||n.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),n.status==="pending"&&n.verification&&e(ke,{children:[e("hr",{className:u.hr}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Verification URL"}),e("div",{className:u.inputWrapper,children:[e("input",{className:u.input,value:n.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=n.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Device Code"}),e("input",{className:u.input,value:n.verification.user_code,readOnly:!0})]})]}),n.status==="error"&&e("p",{className:u.warning,children:n.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 ",g?"(override active)":""]}),e("div",{className:u.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:u.label,children:"Client ID (optional)"}),e("input",{className:u.input,value:d,onChange:f=>S(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:u.actions,children:[e(T,{onClick:U,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:K,disabled:y,children:"Use dango defaults"})]})]}),e(E,{isOpen:x.show,onClose:()=>L(f=>({...f,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:x.message})}),e(E.Actions,{children:e(T,{onClick:()=>L(f=>({...f,show:!1})),children:"OK"})})]})]})},dt=()=>{const[t,r]=s(!0),[i,l]=s(null),[o,v]=s(!1),[b,h]=s(!1),[n,c]=s(""),[g,p]=s(""),[d,S]=s(""),[y,k]=s(!1),[R,x]=s({show:!1,message:"",type:"info"}),L=async()=>{try{const N=await _.auth.user.query();l(N?.email?N:null)}catch{l(null)}},D=async()=>{try{const[N,O]=await Promise.all([_.auth.configStatus.query(),_.auth.googleAuth.query()]);v(!!N.hasConfig),h(!!(O.hasCustomWorkerUrl||O.hasCustomClientId||O.hasClientSecret))}catch(N){console.error("Failed to fetch config status",N)}};A(()=>{(async()=>{r(!0),await Promise.all([L(),D()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await L(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const O=U=>{U.origin===window.location.origin&&typeof U.data=="object"&&U.data!==null&&U.data.type==="GOOGLE_AUTH_SUCCESS"&&(l(U.data.user),window.location.reload())};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[]);const w=async()=>{try{const N=await _.auth.googleLogin.mutate();if(N.authenticated){window.location.reload();return}if(N.url){if(typeof window.DangoBridge<"u"){window.location.href=N.url;return}const U=600,K=700,f=window.innerWidth/2-U/2,J=window.innerHeight/2-K/2;window.open(N.url,"GoogleAuth",`width=${U},height=${K},top=${J},left=${f}`)}else throw new Error("Auth URL not available")}catch{x({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await _.auth.logout.mutate(),l(null),x({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(N){console.error("Sign out failed",N),x({show:!0,message:"Failed to sign out.",type:"error"})}},P=async()=>{k(!0);try{await _.auth.saveGoogleAuth.mutate({workerUrl:n,clientId:g,clientSecret:d}),c(""),p(""),S(""),await D(),x({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},M=async()=>{k(!0);try{await _.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),c(""),p(""),S(""),await D(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:u.sectionCard,children:[e("h3",{className:u.title,children:"Google Drive Sync"}),i?e("div",{className:u.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:i.name})," (",i.email,")"]}),e(T,{variant:"danger",onClick:C,children:"Sign Out"})]}):e("div",{className:u.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:w,disabled:!o,children:"Sign in with Google"}),!o&&e("p",{className:u.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 ",b?"(override active)":""]}),e("div",{className:u.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:u.label,children:"Worker URL (optional)"}),e("input",{className:u.input,value:n,onChange:N=>c(N.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Client ID (optional)"}),e("input",{className:u.input,value:g,onChange:N=>p(N.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:u.input,value:d,onChange:N=>S(N.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:u.actions,children:[e(T,{onClick:P,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:M,disabled:y,children:"Use dango defaults"})]})]}),e(E,{isOpen:R.show,onClose:()=>x(N=>({...N,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:R.message})}),e(E.Actions,{children:e(T,{onClick:()=>x(N=>({...N,show:!1})),children:"OK"})})]})]})},ut="_sectionCard_1pqo4_1",ht="_settingItem_1pqo4_26",gt="_settingRow_1pqo4_31",mt="_modalOverlay_1pqo4_38",pt="_modal_1pqo4_38",yt="_modalActions_1pqo4_73",ft="_modalSecondary_1pqo4_79",vt="_modalPrimary_1pqo4_89",z={sectionCard:ut,settingItem:ht,settingRow:gt,modalOverlay:mt,modal:pt,modalActions:yt,modalSecondary:ft,modalPrimary:vt},wt={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"]]}},bt=(t,r)=>{if(t==null)return r;const i=String(t);return i==="true"||i==="1"?!0:i==="false"||i==="0"?!1:r},ue=(t,r,i)=>{const[l,o]=s(r),[v,b]=s(!1),h=oe();return A(()=>{(async()=>{try{const g=await _.settings.getByKey.query({key:t});o(bt(g.value,r))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,r]),{value:l,setValue:o,isUpdating:v,toggle:async()=>{if(v)return;b(!0);const c=!l;o(c);try{await _.settings.set.mutate({key:t,value:c});for(const g of i)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),o(!c)}finally{b(!1)}}}},kt=()=>{const{contentType:t}=he(),r=wt[t],[i,l]=s(!1),[o,v]=s(!0),[b,h]=s(!1),n=ue(r.ignoreKey,!0,r.invalidateKeys),c=ue(r.listOnlyKey,!1,r.invalidateKeys),[g,p]=s(null),[d,S]=s(!1),y=oe(),k=Te();A(()=>{v(!0),(async()=>{try{const C=await _.settings.getByKey.query({key:r.skipKey});String(C.value)==="true"||String(C.value)==="1"?l(!0):l(!1)}catch(C){console.error("Failed to fetch setting",C)}finally{v(!1)}})()},[r.skipKey]);const R=async()=>{if(b)return;h(!0);const w=!i;l(w);try{await _.settings.set.mutate({key:r.skipKey,value:w})}catch(C){console.error("Error saving setting:",C),l(!w)}finally{h(!1)}},x=async()=>{if(!n.isUpdating){if(n.value)try{let w;if(t==="anime"?w=(await _.continueWatching.adultCount.query()).count:t==="manga"?w=(await _.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await _.asmrProgress.adultCount.query()).count:w=(await _.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){p(w);return}}catch(w){console.error("Failed to fetch adult count",w)}n.toggle()}},L=()=>{p(null),n.toggle()},D=async()=>{if(!d){S(!0);try{let w;t==="anime"?w=(await _.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await _.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await _.asmrProgress.purgeAdult.mutate()).removed:w=(await _.tvProgress.purgeAdult.mutate()).removed,de.success(r.purgeDoneText(w??0));for(const C of r.invalidateKeys)y.invalidateQueries({queryKey:C});t==="anime"&&y.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&y.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&y.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&y.invalidateQueries(k.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),de.error("Failed to remove adult entries")}finally{S(!1),p(null)}n.toggle()}};return o?e("div",{children:"Loading settings..."}):e("div",{className:z.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(q,{isChecked:i,onChange:R,id:"skip-confirmation-toggle",disabled:b})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(q,{isChecked:n.value,onChange:x,id:"ignore-adult-toggle",disabled:n.isUpdating})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(q,{isChecked:c.value,onChange:c.toggle,id:"cw-watchlist-only-toggle",disabled:c.isUpdating})]})}),g!==null&&e("div",{className:z.modalOverlay,onClick:()=>p(null),children:e("div",{className:z.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",r.listNoun," ",g===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:z.modalActions,children:[e("button",{type:"button",className:z.modalSecondary,onClick:L,disabled:d,children:"Show them"}),e("button",{type:"button",className:z.modalPrimary,onClick:D,disabled:d,children:d?"Purging...":`Purge ${g}`})]})]})})]})},Ct="_sectionCard_jkggs_1",_t="_statsGrid_jkggs_26",St="_statCard_jkggs_33",Nt="_statLabel_jkggs_43",Tt="_statValue_jkggs_51",It="_statMeta_jkggs_57",Rt="_statusBanner_jkggs_63",xt="_statusSuccess_jkggs_74",Lt="_statusUpdating_jkggs_80",Dt="_statusError_jkggs_86",Pt="_sha_jkggs_92",At="_settingItem_jkggs_99",Ot="_settingRow_jkggs_104",Gt="_settingTitle_jkggs_111",Mt="_settingSubtitle_jkggs_117",Ut="_actionsRow_jkggs_124",I={sectionCard:Ct,statsGrid:_t,statCard:St,statLabel:Nt,statValue:Tt,statMeta:It,statusBanner:Rt,statusSuccess:xt,statusUpdating:Lt,statusError:Dt,sha:Pt,settingItem:At,settingRow:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:Ut},zt=()=>{const[t,r]=s(null),[i,l]=s(!0),[o,v]=s(!1),[b,h]=s(!1),n=H(null),c=async()=>{try{const y=await _.settings.offlineDbInfo.query();return r(y),y}catch(y){console.error("Failed to fetch offline DB info:",y)}finally{l(!1)}return null};A(()=>(c(),()=>{n.current&&window.clearInterval(n.current)}),[]),A(()=>{t?.isRefreshing?n.current||(n.current=window.setInterval(async()=>{const y=await c();y&&!y.isRefreshing&&n.current&&(window.clearInterval(n.current),n.current=null)},2e3)):n.current&&(window.clearInterval(n.current),n.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||o)return;const y=!t.autoUpdateEnabled;v(!0),r({...t,autoUpdateEnabled:y});try{await _.settings.setOfflineDbAutoUpdate.mutate({enabled:y})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!y})}finally{v(!1)}},p=async()=>{if(!(t?.isRefreshing||b)){h(!0);try{await _.settings.triggerOfflineDbUpdate.mutate(),r(y=>y?{...y,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(y){console.error("Failed to trigger offline DB update:",y)}finally{h(!1)}}},d=y=>{if(!y)return"Never";try{return new Date(y).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return y}},S=t?.isRefreshing||b;return e("div",{className:I.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:I.statsGrid,children:[e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"MAL Mapped"}),e("span",{className:I.statValue,children:i?"—":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Release"}),e("span",{className:I.statMeta,children:i?"—":t?.releaseTag??"Never"})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Checked"}),e("span",{className:I.statMeta,children:i?"—":d(t?.lastCheckedAt??null)})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Updated"}),e("span",{className:I.statMeta,children:i?"—":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${I.statusBanner} ${t.lastStatus==="failed"?I.statusError:t.lastStatus==="updating"?I.statusUpdating:I.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:I.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:I.settingItem,children:e("div",{className:I.settingRow,children:[e("div",{children:[e("span",{className:I.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:I.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(q,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:i||o})]})}),e("div",{className:I.actionsRow,children:e(T,{onClick:p,disabled:i||S,children:S?"Updating Database...":"Update Offline Database Now"})})]})},Et="_sectionCard_1g4qx_1",$t="_dangerCard_1g4qx_26",qt="_status_1g4qx_34",Ft="_warningText_1g4qx_40",Kt="_ackLabel_1g4qx_44",Q={sectionCard:Et,dangerCard:$t,status:qt,warningText:Ft,ackLabel:Kt},jt=()=>{const t=oe(),[r,i]=s(!1),[l,o]=s(!1),[v,b]=s(!1),[h,n]=s(""),c=()=>{o(!1),n(""),i(!0)},g=()=>{v||(i(!1),o(!1))},p=async()=>{if(!(!l||v)){b(!0),n("");try{const d=await fetch("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),S=await d.json();if(!d.ok)throw new Error(S.error||"Failed to clear database");const y=S.deleted,k=S.deletedManga,R=S.deletedTv,x=S.deletedAsmr,L=Object.values(y).reduce((P,M)=>P+(M||0),0)+Object.values(k??{}).reduce((P,M)=>P+(M||0),0)+Object.values(R??{}).reduce((P,M)=>P+(M||0),0)+Object.values(x??{}).reduce((P,M)=>P+(M||0),0),D=(k?.manga_library??0)+(k?.manga_progress??0),w=(R?.tv_library??0)+(R?.tv_progress??0),C=(x?.asmr_library??0)+(x?.asmr_progress??0);n(`Library cleared — ${y.watchlist??0} watchlist entries, ${D} manga rows, ${w} TV rows, ${C} ASMR rows and ${L} total rows removed.`),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]}),t.invalidateQueries({queryKey:["manga-library"]}),t.invalidateQueries({queryKey:["manga-continue-reading"]}),t.invalidateQueries({queryKey:["tv-library"]}),t.invalidateQueries({queryKey:["tv-continue-watching"]}),t.invalidateQueries({queryKey:["asmr-library"]}),t.invalidateQueries({queryKey:["asmr-continue-listening"]}),i(!1)}catch(d){n(d.message)}finally{b(!1),o(!1)}}};return e("div",{className:`${Q.sectionCard} ${Q.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:c,children:"Clear Library Data"}),h&&e("p",{className:Q.status,children:h}),e(E,{isOpen:r,onClose:g,title:"Clear library data?",width:"sm",children:[e(E.Body,{children:[e("p",{className:Q.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:Q.ackLabel,children:[e("input",{type:"checkbox",checked:l,onChange:d=>o(d.target.checked),disabled:v}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(E.Actions,{children:[e(T,{variant:"secondary",onClick:g,disabled:v,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!l||v,children:v?"Clearing...":"Yes, delete everything"})]})]})]})},Ht=()=>{const[t,r]=s(""),[i,l]=s([]),[o,v]=s(null),[b,h]=s(!0),[n,c]=s({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const S=await(await fetch("/api/auth/settings/rclone")).json();r(S.remote||""),l(S.availableRemotes||[]),v(S.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{h(!1)}};A(()=>{g()},[]);const p=async()=>{try{if((await fetch("/api/auth/settings/rclone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:t})})).ok)c({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g();else throw new Error("Failed to save")}catch{c({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return b?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:u.sectionCard,children:[e("h3",{className:u.title,children:"Rclone Cloud Sync"}),e("p",{className:u.signIn,children:"Configure which Rclone remote to use for database synchronization."}),o?e("div",{className:u.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:o})]})}):e("p",{className:u.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Remote Name"}),e("div",{className:u.inputWrapper,children:e("select",{className:u.select,value:t,onChange:d=>r(d.target.value),children:[e("option",{value:"",children:"(Disabled / None)"}),i.map(d=>e("option",{value:d,children:d},d)),t&&!i.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:u.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:u.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e(E,{isOpen:n.show,onClose:()=>c(d=>({...d,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:n.message})}),e(E.Actions,{children:e(T,{onClick:()=>c(d=>({...d,show:!1})),children:"OK"})})]})]})},Wt=()=>{const[t,r]=s(null),[i,l]=s(!0),o=async()=>{try{const c=await(await fetch("/api/auth/settings/sync")).json();r(c)}catch(n){console.error("Failed to fetch sync settings",n)}finally{l(!1)}};A(()=>{o()},[]);const v=async n=>{const c=n.target.value;try{const g=await fetch("/api/auth/settings/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c})});if(g.ok){const p=await g.json();r(d=>d?{...d,activeProvider:p.activeProvider}:null),await o(),te.success(`Sync provider updated to ${c==="default"?"Default Order":c}`)}else te.error("Failed to update sync provider")}catch{te.error("Error updating sync provider")}};if(i||!t)return null;const b=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&b.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&b.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&b.push({value:"rclone",label:"Rclone"}),b.push({value:"none",label:"None (Local Only)"});const h=n=>n==="none"?"Local Only (No Sync)":n==="google"?"Google Drive":n==="github"?"GitHub":n==="rclone"?"Rclone":n;return e("div",{className:m.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:h(t.actualActiveProvider)})]}),e("div",{className:m.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:v,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:b.map(n=>e("option",{value:n.value,children:n.label},n.value))})]})]})};function Bt(){return"javascript:"+encodeURIComponent(`(function(){
1
+ import{d as s,A as H,h as A,u as e,q as ie,S as ke,T as Ce,p as _e,g as ce,_ as Se}from"./vendor-core-DfaOB3Rn.js";import{d as Ne,t as _,B as T,M as E,j as he,h as Te,z as de,F as te,G as Ie,T as Re,u as xe,e as Le,H as De,y as ae,A as Pe,V as Ae,I as Oe}from"./index-CfgPGaUO.js";import{u as oe}from"./vendor-query-BBT5_sHx.js";import{T as q}from"./ToggleSwitch-CN_ppEc9.js";import{I as Y}from"./vendor-icons-DrybRNxP.js";const ne={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},se=["name","nativeName","englishName"],re={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ge=()=>{const{titlePreference:t,setTitlePreference:r,loading:i}=Ne(),[l,o]=s(re[t]),[v,b]=s(!1),h=H(null);A(()=>{i||o(re[t])},[t,i]);const n=async()=>{if(v)return;b(!0);const g=(se.indexOf(t)+1)%se.length,p=se[g],d=re[p];h.current&&(h.current.style.transform="translateX(-100%)",h.current.style.opacity="0"),setTimeout(async()=>{o(d),r(p),h.current&&(h.current.style.transition="none",h.current.style.transform="translateX(100%)",h.current.style.opacity="0",h.current.offsetWidth,h.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",h.current.style.transform="translateX(0)",h.current.style.opacity="1");try{await _.settings.set.mutate({key:"titlePreference",value:p})}catch(S){console.error("Error saving title preference:",S)}finally{b(!1)}},300)};return i?e("p",{children:"Loading title preference..."}):e("div",{className:ne["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:n,className:ne["toggle-button"],disabled:v,children:e("span",{ref:h,className:ne["toggle-label"],children:l})})]})},Me="_settingsHeader_14a5d_1",Ue="_pageTitle_14a5d_6",ze="_pageSubtitle_14a5d_14",Ee="_settingsLayout_14a5d_20",$e="_sidebar_14a5d_27",qe="_sidebarIndicator_14a5d_35",Fe="_sidebarItem_14a5d_50",Ke="_active_14a5d_72",je="_mainContent_14a5d_80",He="_tabContent_14a5d_85",We="_sectionCard_14a5d_103",Be="_settingItem_14a5d_127",Ve="_settingRow_14a5d_132",Qe="_controls_14a5d_145",Ye="_status_14a5d_151",m={settingsHeader:Me,pageTitle:Ue,pageSubtitle:ze,settingsLayout:Ee,sidebar:$e,sidebarIndicator:qe,sidebarItem:Fe,active:Ke,mainContent:je,tabContent:He,sectionCard:We,settingItem:Be,settingRow:Ve,controls:Qe,status:Ye},Je="_sectionCard_wt900_12",Xe="_title_wt900_22",Ze="_signIn_wt900_29",et="_userInfo_wt900_36",tt="_warning_wt900_58",at="_formGroup_wt900_65",nt="_label_wt900_69",st="_inputWrapper_wt900_79",rt="_input_wt900_79",it="_select_wt900_103",ot="_actions_wt900_140",lt="_hr_wt900_148",u={sectionCard:Je,title:Xe,signIn:Ze,userInfo:et,warning:tt,formGroup:at,label:nt,inputWrapper:st,input:rt,select:it,actions:ot,hr:lt},ct=()=>{const[t,r]=s(!0),[i,l]=s(!1),[o,v]=s(!1),[b,h]=s(null),[n,c]=s({status:"idle"}),[g,p]=s(!1),[d,S]=s(""),[y,k]=s(!1),R=H(null),[x,L]=s({show:!1,message:"",type:"info"}),D=()=>{R.current&&(window.clearInterval(R.current),R.current=null)},w=ie(f=>{v(f.authenticated),h(f.user||f.device.user||null),c(f.device),p(!!f.hasCustomClientId)},[]),C=ie(async()=>{const f=await _.auth.githubStatus.query();w(f)},[w]),P=async()=>{try{const f=await _.auth.githubPoll.query();c(f),f.status==="success"?(D(),await C(),L({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):f.status==="error"&&(D(),L({show:!0,message:f.error||"GitHub authentication failed.",type:"error"}))}catch{D(),L({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},M=(f=5)=>{D(),R.current=window.setInterval(P,Math.max(f,5)*1e3)};A(()=>(C().catch(()=>{L({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>r(!1)),D),[C]);const N=async()=>{l(!0);try{const f=await _.auth.githubStart.mutate();c(f),M(f.verification?.interval)}catch(f){L({show:!0,message:f instanceof Error?f.message:"Failed to start GitHub authentication.",type:"error"})}finally{l(!1)}},O=async()=>{try{await _.auth.githubLogout.mutate(),v(!1),h(null),c({status:"idle"}),L({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{L({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},U=async()=>{k(!0);try{await _.auth.saveGithubAuth.mutate({clientId:d}),S(""),await C(),L({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},K=async()=>{k(!0);try{await _.auth.saveGithubAuth.mutate({clientId:""}),S(""),await C(),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:u.sectionCard,children:[e("h3",{className:u.title,children:"GitHub Cloud Sync"}),e("p",{className:u.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),o&&b?e("div",{className:u.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:b.name||b.login})]}),e(T,{variant:"danger",onClick:O,children:"Sign Out"})]}):e("div",{className:u.signIn,children:e(T,{onClick:N,disabled:i||n.status==="pending",children:i||n.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),n.status==="pending"&&n.verification&&e(ke,{children:[e("hr",{className:u.hr}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Verification URL"}),e("div",{className:u.inputWrapper,children:[e("input",{className:u.input,value:n.verification.verification_uri,readOnly:!0}),e(T,{onClick:()=>{const f=n.verification?.verification_uri;f&&/^https?:\/\//i.test(f)&&window.open(f,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Device Code"}),e("input",{className:u.input,value:n.verification.user_code,readOnly:!0})]})]}),n.status==="error"&&e("p",{className:u.warning,children:n.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 ",g?"(override active)":""]}),e("div",{className:u.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:u.label,children:"Client ID (optional)"}),e("input",{className:u.input,value:d,onChange:f=>S(f.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:u.actions,children:[e(T,{onClick:U,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:K,disabled:y,children:"Use dango defaults"})]})]}),e(E,{isOpen:x.show,onClose:()=>L(f=>({...f,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:x.message})}),e(E.Actions,{children:e(T,{onClick:()=>L(f=>({...f,show:!1})),children:"OK"})})]})]})},dt=()=>{const[t,r]=s(!0),[i,l]=s(null),[o,v]=s(!1),[b,h]=s(!1),[n,c]=s(""),[g,p]=s(""),[d,S]=s(""),[y,k]=s(!1),[R,x]=s({show:!1,message:"",type:"info"}),L=async()=>{try{const N=await _.auth.user.query();l(N?.email?N:null)}catch{l(null)}},D=async()=>{try{const[N,O]=await Promise.all([_.auth.configStatus.query(),_.auth.googleAuth.query()]);v(!!N.hasConfig),h(!!(O.hasCustomWorkerUrl||O.hasCustomClientId||O.hasClientSecret))}catch(N){console.error("Failed to fetch config status",N)}};A(()=>{(async()=>{r(!0),await Promise.all([L(),D()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await L(),window.history.replaceState(null,"",window.location.pathname))}catch{}r(!1)})();const O=U=>{U.origin===window.location.origin&&typeof U.data=="object"&&U.data!==null&&U.data.type==="GOOGLE_AUTH_SUCCESS"&&(l(U.data.user),window.location.reload())};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[]);const w=async()=>{try{const N=await _.auth.googleLogin.mutate();if(N.authenticated){window.location.reload();return}if(N.url){if(typeof window.DangoBridge<"u"){window.location.href=N.url;return}const U=600,K=700,f=window.innerWidth/2-U/2,J=window.innerHeight/2-K/2;window.open(N.url,"GoogleAuth",`width=${U},height=${K},top=${J},left=${f}`)}else throw new Error("Auth URL not available")}catch{x({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},C=async()=>{try{await _.auth.logout.mutate(),l(null),x({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(N){console.error("Sign out failed",N),x({show:!0,message:"Failed to sign out.",type:"error"})}},P=async()=>{k(!0);try{await _.auth.saveGoogleAuth.mutate({workerUrl:n,clientId:g,clientSecret:d}),c(""),p(""),S(""),await D(),x({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{x({show:!0,message:"Failed to save override.",type:"error"})}finally{k(!1)}},M=async()=>{k(!0);try{await _.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),c(""),p(""),S(""),await D(),x({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{x({show:!0,message:"Failed to clear override.",type:"error"})}finally{k(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:u.sectionCard,children:[e("h3",{className:u.title,children:"Google Drive Sync"}),i?e("div",{className:u.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:i.name})," (",i.email,")"]}),e(T,{variant:"danger",onClick:C,children:"Sign Out"})]}):e("div",{className:u.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(T,{onClick:w,disabled:!o,children:"Sign in with Google"}),!o&&e("p",{className:u.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 ",b?"(override active)":""]}),e("div",{className:u.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:u.label,children:"Worker URL (optional)"}),e("input",{className:u.input,value:n,onChange:N=>c(N.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Client ID (optional)"}),e("input",{className:u.input,value:g,onChange:N=>p(N.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:u.input,value:d,onChange:N=>S(N.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:u.actions,children:[e(T,{onClick:P,disabled:y,children:"Save override"}),e(T,{variant:"secondary",onClick:M,disabled:y,children:"Use dango defaults"})]})]}),e(E,{isOpen:R.show,onClose:()=>x(N=>({...N,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:R.message})}),e(E.Actions,{children:e(T,{onClick:()=>x(N=>({...N,show:!1})),children:"OK"})})]})]})},ut="_sectionCard_1pqo4_1",ht="_settingItem_1pqo4_26",gt="_settingRow_1pqo4_31",mt="_modalOverlay_1pqo4_38",pt="_modal_1pqo4_38",yt="_modalActions_1pqo4_73",ft="_modalSecondary_1pqo4_79",vt="_modalPrimary_1pqo4_89",z={sectionCard:ut,settingItem:ht,settingRow:gt,modalOverlay:mt,modal:pt,modalActions:yt,modalSecondary:ft,modalPrimary:vt},wt={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"]]}},bt=(t,r)=>{if(t==null)return r;const i=String(t);return i==="true"||i==="1"?!0:i==="false"||i==="0"?!1:r},ue=(t,r,i)=>{const[l,o]=s(r),[v,b]=s(!1),h=oe();return A(()=>{(async()=>{try{const g=await _.settings.getByKey.query({key:t});o(bt(g.value,r))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,r]),{value:l,setValue:o,isUpdating:v,toggle:async()=>{if(v)return;b(!0);const c=!l;o(c);try{await _.settings.set.mutate({key:t,value:c});for(const g of i)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),o(!c)}finally{b(!1)}}}},kt=()=>{const{contentType:t}=he(),r=wt[t],[i,l]=s(!1),[o,v]=s(!0),[b,h]=s(!1),n=ue(r.ignoreKey,!0,r.invalidateKeys),c=ue(r.listOnlyKey,!1,r.invalidateKeys),[g,p]=s(null),[d,S]=s(!1),y=oe(),k=Te();A(()=>{v(!0),(async()=>{try{const C=await _.settings.getByKey.query({key:r.skipKey});String(C.value)==="true"||String(C.value)==="1"?l(!0):l(!1)}catch(C){console.error("Failed to fetch setting",C)}finally{v(!1)}})()},[r.skipKey]);const R=async()=>{if(b)return;h(!0);const w=!i;l(w);try{await _.settings.set.mutate({key:r.skipKey,value:w})}catch(C){console.error("Error saving setting:",C),l(!w)}finally{h(!1)}},x=async()=>{if(!n.isUpdating){if(n.value)try{let w;if(t==="anime"?w=(await _.continueWatching.adultCount.query()).count:t==="manga"?w=(await _.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await _.asmrProgress.adultCount.query()).count:w=(await _.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){p(w);return}}catch(w){console.error("Failed to fetch adult count",w)}n.toggle()}},L=()=>{p(null),n.toggle()},D=async()=>{if(!d){S(!0);try{let w;t==="anime"?w=(await _.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await _.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await _.asmrProgress.purgeAdult.mutate()).removed:w=(await _.tvProgress.purgeAdult.mutate()).removed,de.success(r.purgeDoneText(w??0));for(const C of r.invalidateKeys)y.invalidateQueries({queryKey:C});t==="anime"&&y.invalidateQueries(k.continueWatching.pathFilter()),t==="manga"&&y.invalidateQueries(k.mangaProgress.pathFilter()),t==="asmr"&&y.invalidateQueries(k.asmrProgress.pathFilter()),t==="tv"&&y.invalidateQueries(k.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),de.error("Failed to remove adult entries")}finally{S(!1),p(null)}n.toggle()}};return o?e("div",{children:"Loading settings..."}):e("div",{className:z.sectionCard,children:[e("h3",{children:r.heading}),e("p",{children:r.blurb}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:r.skipLabel}),e(q,{isChecked:i,onChange:R,id:"skip-confirmation-toggle",disabled:b})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:r.ignoreLabel}),e(q,{isChecked:n.value,onChange:x,id:"ignore-adult-toggle",disabled:n.isUpdating})]})}),e("div",{className:z.settingItem,children:e("div",{className:z.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:r.listOnlyLabel}),e(q,{isChecked:c.value,onChange:c.toggle,id:"cw-watchlist-only-toggle",disabled:c.isUpdating})]})}),g!==null&&e("div",{className:z.modalOverlay,onClick:()=>p(null),children:e("div",{className:z.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",r.listNoun," ",g===1?"is":"are"," currently hidden from"," ",r.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:z.modalActions,children:[e("button",{type:"button",className:z.modalSecondary,onClick:L,disabled:d,children:"Show them"}),e("button",{type:"button",className:z.modalPrimary,onClick:D,disabled:d,children:d?"Purging...":`Purge ${g}`})]})]})})]})},Ct="_sectionCard_jkggs_1",_t="_statsGrid_jkggs_26",St="_statCard_jkggs_33",Nt="_statLabel_jkggs_43",Tt="_statValue_jkggs_51",It="_statMeta_jkggs_57",Rt="_statusBanner_jkggs_63",xt="_statusSuccess_jkggs_74",Lt="_statusUpdating_jkggs_80",Dt="_statusError_jkggs_86",Pt="_sha_jkggs_92",At="_settingItem_jkggs_99",Ot="_settingRow_jkggs_104",Gt="_settingTitle_jkggs_111",Mt="_settingSubtitle_jkggs_117",Ut="_actionsRow_jkggs_124",I={sectionCard:Ct,statsGrid:_t,statCard:St,statLabel:Nt,statValue:Tt,statMeta:It,statusBanner:Rt,statusSuccess:xt,statusUpdating:Lt,statusError:Dt,sha:Pt,settingItem:At,settingRow:Ot,settingTitle:Gt,settingSubtitle:Mt,actionsRow:Ut},zt=()=>{const[t,r]=s(null),[i,l]=s(!0),[o,v]=s(!1),[b,h]=s(!1),n=H(null),c=async()=>{try{const y=await _.settings.offlineDbInfo.query();return r(y),y}catch(y){console.error("Failed to fetch offline DB info:",y)}finally{l(!1)}return null};A(()=>(c(),()=>{n.current&&window.clearInterval(n.current)}),[]),A(()=>{t?.isRefreshing?n.current||(n.current=window.setInterval(async()=>{const y=await c();y&&!y.isRefreshing&&n.current&&(window.clearInterval(n.current),n.current=null)},2e3)):n.current&&(window.clearInterval(n.current),n.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||o)return;const y=!t.autoUpdateEnabled;v(!0),r({...t,autoUpdateEnabled:y});try{await _.settings.setOfflineDbAutoUpdate.mutate({enabled:y})}catch(k){console.error("Failed to update auto update setting:",k),r({...t,autoUpdateEnabled:!y})}finally{v(!1)}},p=async()=>{if(!(t?.isRefreshing||b)){h(!0);try{await _.settings.triggerOfflineDbUpdate.mutate(),r(y=>y?{...y,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(y){console.error("Failed to trigger offline DB update:",y)}finally{h(!1)}}},d=y=>{if(!y)return"Never";try{return new Date(y).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return y}},S=t?.isRefreshing||b;return e("div",{className:I.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:I.statsGrid,children:[e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"MAL Mapped"}),e("span",{className:I.statValue,children:i?"—":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Release"}),e("span",{className:I.statMeta,children:i?"—":t?.releaseTag??"Never"})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Checked"}),e("span",{className:I.statMeta,children:i?"—":d(t?.lastCheckedAt??null)})]}),e("div",{className:I.statCard,children:[e("span",{className:I.statLabel,children:"Last Updated"}),e("span",{className:I.statMeta,children:i?"—":d(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${I.statusBanner} ${t.lastStatus==="failed"?I.statusError:t.lastStatus==="updating"?I.statusUpdating:I.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:I.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:I.settingItem,children:e("div",{className:I.settingRow,children:[e("div",{children:[e("span",{className:I.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:I.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(q,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:i||o})]})}),e("div",{className:I.actionsRow,children:e(T,{onClick:p,disabled:i||S,children:S?"Updating Database...":"Update Offline Database Now"})})]})},Et="_sectionCard_1g4qx_1",$t="_dangerCard_1g4qx_26",qt="_status_1g4qx_34",Ft="_warningText_1g4qx_40",Kt="_ackLabel_1g4qx_44",Q={sectionCard:Et,dangerCard:$t,status:qt,warningText:Ft,ackLabel:Kt},jt=()=>{const t=oe(),[r,i]=s(!1),[l,o]=s(!1),[v,b]=s(!1),[h,n]=s(""),c=()=>{o(!1),n(""),i(!0)},g=()=>{v||(i(!1),o(!1))},p=async()=>{if(!(!l||v)){b(!0),n("");try{const d=await fetch("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),S=await d.json();if(!d.ok)throw new Error(S.error||"Failed to clear database");const y=S.deleted,k=S.deletedManga,R=S.deletedTv,x=S.deletedAsmr,L=Object.values(y).reduce((P,M)=>P+(M||0),0)+Object.values(k??{}).reduce((P,M)=>P+(M||0),0)+Object.values(R??{}).reduce((P,M)=>P+(M||0),0)+Object.values(x??{}).reduce((P,M)=>P+(M||0),0),D=(k?.manga_library??0)+(k?.manga_progress??0),w=(R?.tv_library??0)+(R?.tv_progress??0),C=(x?.asmr_library??0)+(x?.asmr_progress??0);n(`Library cleared — ${y.watchlist??0} watchlist entries, ${D} manga rows, ${w} TV rows, ${C} ASMR rows and ${L} total rows removed.`),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]}),t.invalidateQueries({queryKey:["manga-library"]}),t.invalidateQueries({queryKey:["manga-continue-reading"]}),t.invalidateQueries({queryKey:["tv-library"]}),t.invalidateQueries({queryKey:["tv-continue-watching"]}),t.invalidateQueries({queryKey:["asmr-library"]}),t.invalidateQueries({queryKey:["asmr-continue-listening"]}),i(!1)}catch(d){n(d.message)}finally{b(!1),o(!1)}}};return e("div",{className:`${Q.sectionCard} ${Q.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:c,children:"Clear Library Data"}),h&&e("p",{className:Q.status,children:h}),e(E,{isOpen:r,onClose:g,title:"Clear library data?",width:"sm",children:[e(E.Body,{children:[e("p",{className:Q.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:Q.ackLabel,children:[e("input",{type:"checkbox",checked:l,onChange:d=>o(d.target.checked),disabled:v}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(E.Actions,{children:[e(T,{variant:"secondary",onClick:g,disabled:v,children:"Cancel"}),e(T,{variant:"danger",onClick:p,disabled:!l||v,children:v?"Clearing...":"Yes, delete everything"})]})]})]})},Ht=()=>{const[t,r]=s(""),[i,l]=s([]),[o,v]=s(null),[b,h]=s(!0),[n,c]=s({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const S=await(await fetch("/api/auth/settings/rclone")).json();r(S.remote||""),l(S.availableRemotes||[]),v(S.activeRemote||null)}catch(d){console.error("Failed to fetch Rclone settings",d)}finally{h(!1)}};A(()=>{g()},[]);const p=async()=>{try{if((await fetch("/api/auth/settings/rclone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:t})})).ok)c({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g();else throw new Error("Failed to save")}catch{c({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return b?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:u.sectionCard,children:[e("h3",{className:u.title,children:"Rclone Cloud Sync"}),e("p",{className:u.signIn,children:"Configure which Rclone remote to use for database synchronization."}),o?e("div",{className:u.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:o})]})}):e("p",{className:u.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:u.formGroup,children:[e("label",{className:u.label,children:"Remote Name"}),e("div",{className:u.inputWrapper,children:e("select",{className:u.select,value:t,onChange:d=>r(d.target.value),children:[e("option",{value:"",children:"(Disabled / None)"}),i.map(d=>e("option",{value:d,children:d},d)),t&&!i.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:u.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:u.actions,children:e(T,{onClick:p,children:"Save Rclone Settings"})}),e(E,{isOpen:n.show,onClose:()=>c(d=>({...d,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:n.message})}),e(E.Actions,{children:e(T,{onClick:()=>c(d=>({...d,show:!1})),children:"OK"})})]})]})},Wt=()=>{const[t,r]=s(null),[i,l]=s(!0),o=async()=>{try{const c=await(await fetch("/api/auth/settings/sync")).json();r(c)}catch(n){console.error("Failed to fetch sync settings",n)}finally{l(!1)}};A(()=>{o()},[]);const v=async n=>{const c=n.target.value;try{const g=await fetch("/api/auth/settings/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c})});if(g.ok){const p=await g.json();r(d=>d?{...d,activeProvider:p.activeProvider}:null),await o(),te.success(`Sync provider updated to ${c==="default"?"Default Order":c}`)}else te.error("Failed to update sync provider")}catch{te.error("Error updating sync provider")}};if(i||!t)return null;const b=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&b.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&b.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&b.push({value:"rclone",label:"Rclone"}),b.push({value:"none",label:"None (Local Only)"});const h=n=>n==="none"?"Local Only (No Sync)":n==="google"?"Google Drive":n==="github"?"GitHub":n==="rclone"?"Rclone":n;return e("div",{className:m.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:h(t.actualActiveProvider)})]}),e("div",{className:m.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:v,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:b.map(n=>e("option",{value:n.value,children:n.label},n.value))})]})]})};function Bt(){return"javascript:"+encodeURIComponent(`(function(){
2
2
  if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
3
  var t=null;
4
4
  try{
@@ -1 +1 @@
1
- import{d as _,A as v,h as E,T as R,u as e,g as A}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{u as L}from"./index-_iy8RyKU.js";const x="_pagination_zelsc_1",M="_pageBtn_zelsc_7",S="_pageInfo_zelsc_38",G="_pagePicker_zelsc_48",F="_dropdown_zelsc_52",K="_flipDown_zelsc_68",T="_jumpRow_zelsc_73",W="_jumpInput_zelsc_79",q="_jumpGo_zelsc_90",J="_optionList_zelsc_105",O="_optionBtn_zelsc_113",H="_current_zelsc_132",s={pagination:x,pageBtn:M,pageInfo:S,pagePicker:G,dropdown:F,flipDown:K,jumpRow:T,jumpInput:W,jumpGo:q,optionList:J,optionBtn:O,current:H},cn=({page:t,totalPages:d,canGoNext:m,onChange:p,isLoading:f=!1,variant:g="compact"})=>{const[l,u]=_(!1),[b,h]=_(""),[k,N]=_(0),[$,z]=_(!1),w=v(null),y=v(null),j=v(null);E(()=>{if(!l)return;const n=o=>{w.current&&!w.current.contains(o.target)&&u(!1)},r=o=>{o.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",r)}},[l]),E(()=>{if(!l)return;N(0),z(!1);const n=requestAnimationFrame(()=>{const r=j.current?.getBoundingClientRect(),o=y.current?.getBoundingClientRect();if(!r)return;let c=0;r.right>window.innerWidth-8?c=window.innerWidth-8-r.right:r.left<8&&(c=8-r.left),N(Math.round(c)),o&&o.top<r.height+24&&z(!0)});return()=>cancelAnimationFrame(n)},[l]);const i=d,C=R(()=>{if(i!==void 0){if(i<=100)return Array.from({length:i},(o,c)=>c+1);const r=new Set([1,i]);for(let o=t-10;o<=t+10;o++)o>=1&&o<=i&&r.add(o);return[...r].sort((o,c)=>o-c)}const n=m?t+1:t;return Array.from({length:n},(r,o)=>o+1)},[i,t,m]),B=n=>{const r=i!==void 0?Math.min(Math.max(1,n),i):Math.max(1,n);u(!1),h(""),r!==t&&p(r)},D=()=>{const n=parseInt(b,10);Number.isNaN(n)||B(n)},I=f||(i!==void 0?t>=i:!m);return e("div",{className:s.pagination,ref:w,children:[e("button",{className:s.pageBtn,onClick:()=>p(t-1),disabled:t<=1||f,"aria-label":"Previous page",children:[e(P,{name:"chevron-left",size:14}),g==="labeled"&&e("span",{children:"Previous"})]}),e("div",{className:s.pagePicker,ref:y,children:[e("button",{className:s.pageBtn,onClick:()=>{h(""),u(n=>!n)},disabled:f,"aria-label":"Jump to page","aria-expanded":l,children:e("span",{className:s.pageInfo,children:["Page ",e("strong",{children:t}),i!==void 0&&` of ${i}`]})}),l&&e("div",{ref:j,className:`${s.dropdown} ${$?s.flipDown:""}`,style:k!==0?{marginLeft:k}:void 0,children:[e("div",{className:s.jumpRow,children:[e("input",{className:s.jumpInput,type:"number",inputMode:"numeric",min:1,max:i,value:b,placeholder:"Page #",onChange:n=>h(n.currentTarget.value),onKeyDown:n=>{n.key==="Enter"&&D()}}),e("button",{className:s.jumpGo,onClick:D,children:"Go"})]}),e("div",{className:s.optionList,children:C.map(n=>e("button",{className:`${s.optionBtn} ${n===t?s.current:""}`,onClick:()=>B(n),disabled:n===t,children:n},n))})]})]}),e("button",{className:s.pageBtn,onClick:()=>p(t+1),disabled:I,"aria-label":"Next page",children:[g==="labeled"&&e("span",{children:"Next"}),e(P,{name:"chevron-right",size:14})]})]})},Q="_skeletonCard_1b0hr_1",U="_poster_1b0hr_11",V="_line_1b0hr_20",X="_info_1b0hr_38",Y="_short_1b0hr_54",Z="_horizontal_1b0hr_60",nn="_vertical_1b0hr_78",en="_lowEnd_1b0hr_97",a={skeletonCard:Q,poster:U,line:V,"skeleton-wave":"_skeleton-wave_1b0hr_1",info:X,short:Y,horizontal:Z,vertical:nn,lowEnd:en},tn=({layout:t="vertical"})=>{const{lowEndMode:d}=L();return e("div",{className:`${a.skeletonCard} ${a[t]} ${d?a.lowEnd:""}`,children:[e("div",{className:a.poster}),e("div",{className:a.info,children:[e("div",{className:a.line}),e("div",{className:`${a.line} ${a.short}`})]})]})},on=({count:t=14,layout:d="vertical"})=>e("div",{className:"grid-container",children:Array.from({length:t}).map((m,p)=>e(tn,{layout:d},p))}),ln=A.memo(on);export{tn as A,cn as P,ln as S};
1
+ import{d as _,A as v,h as E,T as R,u as e,g as A}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{u as L}from"./index-CfgPGaUO.js";const x="_pagination_zelsc_1",M="_pageBtn_zelsc_7",S="_pageInfo_zelsc_38",G="_pagePicker_zelsc_48",F="_dropdown_zelsc_52",K="_flipDown_zelsc_68",T="_jumpRow_zelsc_73",W="_jumpInput_zelsc_79",q="_jumpGo_zelsc_90",J="_optionList_zelsc_105",O="_optionBtn_zelsc_113",H="_current_zelsc_132",s={pagination:x,pageBtn:M,pageInfo:S,pagePicker:G,dropdown:F,flipDown:K,jumpRow:T,jumpInput:W,jumpGo:q,optionList:J,optionBtn:O,current:H},cn=({page:t,totalPages:d,canGoNext:m,onChange:p,isLoading:f=!1,variant:g="compact"})=>{const[l,u]=_(!1),[b,h]=_(""),[k,N]=_(0),[$,z]=_(!1),w=v(null),y=v(null),j=v(null);E(()=>{if(!l)return;const n=o=>{w.current&&!w.current.contains(o.target)&&u(!1)},r=o=>{o.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",r)}},[l]),E(()=>{if(!l)return;N(0),z(!1);const n=requestAnimationFrame(()=>{const r=j.current?.getBoundingClientRect(),o=y.current?.getBoundingClientRect();if(!r)return;let c=0;r.right>window.innerWidth-8?c=window.innerWidth-8-r.right:r.left<8&&(c=8-r.left),N(Math.round(c)),o&&o.top<r.height+24&&z(!0)});return()=>cancelAnimationFrame(n)},[l]);const i=d,C=R(()=>{if(i!==void 0){if(i<=100)return Array.from({length:i},(o,c)=>c+1);const r=new Set([1,i]);for(let o=t-10;o<=t+10;o++)o>=1&&o<=i&&r.add(o);return[...r].sort((o,c)=>o-c)}const n=m?t+1:t;return Array.from({length:n},(r,o)=>o+1)},[i,t,m]),B=n=>{const r=i!==void 0?Math.min(Math.max(1,n),i):Math.max(1,n);u(!1),h(""),r!==t&&p(r)},D=()=>{const n=parseInt(b,10);Number.isNaN(n)||B(n)},I=f||(i!==void 0?t>=i:!m);return e("div",{className:s.pagination,ref:w,children:[e("button",{className:s.pageBtn,onClick:()=>p(t-1),disabled:t<=1||f,"aria-label":"Previous page",children:[e(P,{name:"chevron-left",size:14}),g==="labeled"&&e("span",{children:"Previous"})]}),e("div",{className:s.pagePicker,ref:y,children:[e("button",{className:s.pageBtn,onClick:()=>{h(""),u(n=>!n)},disabled:f,"aria-label":"Jump to page","aria-expanded":l,children:e("span",{className:s.pageInfo,children:["Page ",e("strong",{children:t}),i!==void 0&&` of ${i}`]})}),l&&e("div",{ref:j,className:`${s.dropdown} ${$?s.flipDown:""}`,style:k!==0?{marginLeft:k}:void 0,children:[e("div",{className:s.jumpRow,children:[e("input",{className:s.jumpInput,type:"number",inputMode:"numeric",min:1,max:i,value:b,placeholder:"Page #",onChange:n=>h(n.currentTarget.value),onKeyDown:n=>{n.key==="Enter"&&D()}}),e("button",{className:s.jumpGo,onClick:D,children:"Go"})]}),e("div",{className:s.optionList,children:C.map(n=>e("button",{className:`${s.optionBtn} ${n===t?s.current:""}`,onClick:()=>B(n),disabled:n===t,children:n},n))})]})]}),e("button",{className:s.pageBtn,onClick:()=>p(t+1),disabled:I,"aria-label":"Next page",children:[g==="labeled"&&e("span",{children:"Next"}),e(P,{name:"chevron-right",size:14})]})]})},Q="_skeletonCard_1b0hr_1",U="_poster_1b0hr_11",V="_line_1b0hr_20",X="_info_1b0hr_38",Y="_short_1b0hr_54",Z="_horizontal_1b0hr_60",nn="_vertical_1b0hr_78",en="_lowEnd_1b0hr_97",a={skeletonCard:Q,poster:U,line:V,"skeleton-wave":"_skeleton-wave_1b0hr_1",info:X,short:Y,horizontal:Z,vertical:nn,lowEnd:en},tn=({layout:t="vertical"})=>{const{lowEndMode:d}=L();return e("div",{className:`${a.skeletonCard} ${a[t]} ${d?a.lowEnd:""}`,children:[e("div",{className:a.poster}),e("div",{className:a.info,children:[e("div",{className:a.line}),e("div",{className:`${a.line} ${a.short}`})]})]})},on=({count:t=14,layout:d="vertical"})=>e("div",{className:"grid-container",children:Array.from({length:t}).map((m,p)=>e(tn,{layout:d},p))}),ln=A.memo(on);export{tn as A,cn as P,ln as S};
@@ -1,2 +1,2 @@
1
- import{d as t,h as Re,g as Be,A as De,q as $e,u as e,S as d}from"./vendor-core-DfaOB3Rn.js";import{u as qe,b as Fe,a as I}from"./vendor-query-BBT5_sHx.js";import{z as i,t as h,W as nn,j as an,B as le}from"./index-_iy8RyKU.js";import{I as l}from"./vendor-icons-DrybRNxP.js";function tn(){const K=qe(),[Y,k]=t(!1);return Re(()=>{const s=new URLSearchParams(window.location.search),b=s.get("anilist");if(b){const m=s.get("user"),_=s.get("reason");window.history.replaceState(null,"",window.location.pathname),b==="success"?(i.success(m?`Connected to AniList as ${decodeURIComponent(m)}`:"Connected to AniList"),K.invalidateQueries({queryKey:["trackerStatus"]})):i.error(_?decodeURIComponent(_):"AniList authentication failed");return}const j=new URLSearchParams(window.location.hash.substring(1)),y=j.get("access_token"),x=s.get("code");if(!y&&!x){const m=j.get("error");m&&(i.error(`AniList error: ${m}`),window.history.replaceState(null,"",window.location.pathname));return}const g=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),k(!0),i("Connecting to AniList..."),h.tracker.anilistAuth.mutate(y?{token:y}:{code:x,redirectUri:g}).then(async m=>{const _=m.user;i.success(`Connected to AniList as ${_?.name??"AniList user"}`),K.invalidateQueries({queryKey:["trackerStatus"]})}).catch(m=>{i.error(m instanceof Error?m.message:"Failed to authenticate with AniList")}).finally(()=>{k(!1)})},[K]),Y}const sn="_header_j1lbh_1",rn="_fadeIn_j1lbh_1",ln="_pageTitle_j1lbh_6",on="_pageSubtitle_j1lbh_14",cn="_importCard_j1lbh_20",dn="_slideUpIn_j1lbh_1",mn="_cardHeader_j1lbh_37",pn="_uploadArea_j1lbh_55",hn="_fileInputWrapper_j1lbh_59",un="_fileInput_j1lbh_59",gn="_fileDisplay_j1lbh_87",yn="_fileIcon_j1lbh_95",bn="_fileName_j1lbh_100",_n="_browseButton_j1lbh_109",fn="_optionsArea_j1lbh_120",Nn="_checkboxLabel_j1lbh_128",kn="_checkbox_j1lbh_128",wn="_checkboxCustom_j1lbh_141",vn="_optionText_j1lbh_169",In="_optionTitle_j1lbh_175",xn="_optionDesc_j1lbh_181",Mn="_actions_j1lbh_187",Cn="_importBtn_j1lbh_195",Ln="_cancelBtn_j1lbh_201",Sn="_statusMessage_j1lbh_215",Tn="_success_j1lbh_225",An="_error_j1lbh_231",jn="_progressSection_j1lbh_237",Pn="_progressBar_j1lbh_242",En="_progressFill_j1lbh_250",Bn="_progressInfo_j1lbh_257",Dn="_progressCount_j1lbh_264",$n="_progressTitle_j1lbh_271",Fn="_sourceBadge_j1lbh_289",Un="_anilist_j1lbh_301",Rn="_kitsu_j1lbh_307",qn="_offline_j1lbh_313",Kn="_skipped_j1lbh_319",On="_cardTitleRow_j1lbh_324",Qn="_anilistIcon_j1lbh_334",Gn="_malIcon_j1lbh_340",Hn="_badgeOnline_j1lbh_346",Wn="_badgeOffline_j1lbh_358",zn="_connectedProfile_j1lbh_370",Xn="_avatar_j1lbh_379",Jn="_connectedInfo_j1lbh_386",Yn="_connectedName_j1lbh_394",Vn="_connectedHint_j1lbh_400",Zn="_loginPrompt_j1lbh_405",ea="_loginSection_j1lbh_413",na="_fieldLabel_j1lbh_419",aa="_helpText_j1lbh_438",ta="_loginText_j1lbh_455",sa="_primaryBtn_j1lbh_464",ia="_secondaryBtn_j1lbh_465",ra="_syncBtn_j1lbh_466",la="_divider_j1lbh_518",oa="_actionSection_j1lbh_524",ca="_inputGroup_j1lbh_538",da="_input_j1lbh_538",ma="_syncSummary_j1lbh_559",pa="_syncErrors_j1lbh_565",ha="_spin_j1lbh_569",ua="_radioGroup_j1lbh_598",ga="_radioLabel_j1lbh_604",ya="_syncHint_j1lbh_642",ba="_importLoading_j1lbh_649",n={header:sn,fadeIn:rn,pageTitle:ln,pageSubtitle:on,importCard:cn,slideUpIn:dn,cardHeader:mn,uploadArea:pn,fileInputWrapper:hn,fileInput:un,fileDisplay:gn,fileIcon:yn,fileName:bn,browseButton:_n,optionsArea:fn,checkboxLabel:Nn,checkbox:kn,checkboxCustom:wn,optionText:vn,optionTitle:In,optionDesc:xn,actions:Mn,importBtn:Cn,cancelBtn:Ln,statusMessage:Sn,success:Tn,error:An,progressSection:jn,progressBar:Pn,progressFill:En,progressInfo:Bn,progressCount:Dn,progressTitle:$n,sourceBadge:Fn,anilist:Un,kitsu:Rn,offline:qn,skipped:Kn,cardTitleRow:On,anilistIcon:Qn,malIcon:Gn,badgeOnline:Hn,badgeOffline:Wn,connectedProfile:zn,avatar:Xn,connectedInfo:Jn,connectedName:Yn,connectedHint:Vn,loginPrompt:Zn,loginSection:ea,fieldLabel:na,helpText:aa,loginText:ta,primaryBtn:sa,secondaryBtn:ia,syncBtn:ra,divider:la,actionSection:oa,inputGroup:ca,input:da,syncSummary:ma,syncErrors:pa,spin:ha,radioGroup:ua,radioLabel:ga,syncHint:ya,importLoading:ba},oe="tracker_anilist_client_id",Ue="49887".trim(),wa=()=>{const{setIsOpen:K}=nn(),{contentType:Y}=an(),k=Y==="manga",s=qe();Be.useEffect(()=>{document.title="Trackers - dango"},[]);const[b,j]=t(""),[y,x]=t("username"),[g,m]=t(null),[_,ce]=t(""),[M,de]=t(!1),Ke=tn(),{data:me,isLoading:pe}=Fe({queryKey:["trackerStatus"],queryFn:async()=>await h.tracker.status.query()}),{data:C}=Fe({queryKey:["anilistClientId"],queryFn:async()=>(await h.settings.getByKey.query({key:oe})).value||""}),he=De(!1);Be.useEffect(()=>{he.current||C!==void 0&&(C&&ce(C),he.current=!0)},[C]);const w=me?.anilist?.connected??!1;Re(()=>{w&&x("sync")},[w]);const O=me?.anilist?.user??null,V=!!Ue,Oe=(C||"").trim(),Qe=async()=>{const a=_.trim(),r=a||Ue;if(!r){i.error("Enter your AniList client ID first");return}const N=async(A,se)=>{await h.settings.set.mutate({key:A,value:se})};try{a?a!==C&&await N(oe,a):V&&Oe&&await N(oe,""),s.invalidateQueries({queryKey:["anilistClientId"]})}catch(A){i.error(A.message);return}const o=window.location.origin+window.location.pathname,U=encodeURIComponent(o);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(r)}&response_type=token&state=${U}`},ue=I({mutationFn:async()=>h.tracker.anilistDisconnect.mutate(),onSuccess:()=>{s.invalidateQueries({queryKey:["trackerStatus"]}),i.success("Disconnected from AniList")},onError:a=>i.error(a.message)}),Q=I({mutationFn:async()=>(await h.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),m(a),i.success(`Sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}`,{duration:6e3})},onError:a=>i.error(a.message)}),[P,ge]=t(""),[G,ye]=t("sync"),[Z,be]=t("two-way"),[c,Ge]=t(null),H=I({mutationFn:async()=>(await h.tracker.mangaSync.mutate({direction:Z})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),Ge(a);const r=(a.warnings?.length??0)>0?`, ${a.warnings.length} warning(s)`:"";i.success(`Manga sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}${r}`,{duration:6e3})},onError:a=>i.error(a.message)}),L=I({mutationFn:async()=>{if(!P.trim())throw new Error("Please enter a username");return(await h.tracker.mangaImport.mutate({username:P.trim(),erase:M})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from AniList`),ge("")},onError:a=>i.error(a.message)}),[E,_e]=t(""),[W,fe]=t("username"),[ee,Ne]=t(null),[z,ke]=t(!1),[we,ne]=t(""),[ve,He]=t(""),f=I({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a MAL username");const a=await h.tracker.mangaMalImport.mutate({username:E.trim(),erase:M});return{imported:a.imported??0,skipped:a.skipped??0}},onSuccess:({imported:a,skipped:r})=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from MAL${r>0?`, skipped ${r}`:""}`),_e("")},onError:a=>i.error(a.message)}),We=$e(async()=>{const a=document.getElementById("malMangaFile");if(!a.files||a.files.length===0){ne("Please select a file first.");return}ke(!0),ne(""),Ne(null);try{const r=new FormData;r.append("xmlfile",a.files[0]),r.append("erase",String(M));const N=await fetch("/api/import/mal-xml-manga",{method:"POST",body:r}),o=await N.json().catch(()=>({}));if(!N.ok)throw new Error(o.error||"Import failed");Ne({imported:o.imported??0,skipped:o.skipped??0}),s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]})}catch(r){ne(r.message)}finally{ke(!1)}},[M,s]),S=I({mutationFn:async()=>{if(!b.trim())throw new Error("Please enter a username");return(await h.tracker.anilistImport.mutate({username:b.trim(),erase:v})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from AniList`),j("")},onError:a=>i.error(a.message)}),[B,Ie]=t(""),u=I({mutationFn:async a=>{if(!B.trim())throw new Error("Please enter a MAL username");return(await h.tracker.malImport.mutate({username:B.trim(),erase:a.erase,useOfflineDb:a.useOfflineDb,skipFallback:a.skipFallback})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from MAL`),Ie("")},onError:a=>i.error(a.message)}),[v,xe]=t(!1),[D,ze]=t(!0),[$,Xe]=t(!1),[Me,Ce]=t(""),[T,Le]=t(!1),[p,Se]=t(null),[ae,Te]=t(null),[Ae,X]=t(""),te=De(null),Je=a=>{a.target.files&&a.target.files.length>0?Ce(a.target.files[0].name):Ce("")},Ye=$e(async()=>{const a=document.getElementById("malFile");if(!a.files||a.files.length===0){X("Please select a file first.");return}const r=a.files[0];Le(!0),Se(null),Te(null),X("");const N=new AbortController;te.current=N;try{const o=new FormData;o.append("xmlfile",r),o.append("erase",String(v)),o.append("useOfflineDb",String(D)),o.append("skipFallback",String($));const U=await fetch("/api/import/mal-xml",{method:"POST",body:o,signal:N.signal});if(!U.ok){const re=await U.text();let R="Failed to import";try{R=JSON.parse(re).error||R}catch{}throw new Error(R)}const A=U.body?.getReader();if(!A)throw new Error("No response stream");const se=new TextDecoder;let ie="",J="";for(;;){const{done:re,value:R}=await A.read();if(re)break;ie+=se.decode(R,{stream:!0});const Pe=ie.split(`
1
+ import{d as t,h as Re,g as Be,A as De,q as $e,u as e,S as d}from"./vendor-core-DfaOB3Rn.js";import{u as qe,b as Fe,a as I}from"./vendor-query-BBT5_sHx.js";import{z as i,t as h,W as nn,j as an,B as le}from"./index-CfgPGaUO.js";import{I as l}from"./vendor-icons-DrybRNxP.js";function tn(){const K=qe(),[Y,k]=t(!1);return Re(()=>{const s=new URLSearchParams(window.location.search),b=s.get("anilist");if(b){const m=s.get("user"),_=s.get("reason");window.history.replaceState(null,"",window.location.pathname),b==="success"?(i.success(m?`Connected to AniList as ${decodeURIComponent(m)}`:"Connected to AniList"),K.invalidateQueries({queryKey:["trackerStatus"]})):i.error(_?decodeURIComponent(_):"AniList authentication failed");return}const j=new URLSearchParams(window.location.hash.substring(1)),y=j.get("access_token"),x=s.get("code");if(!y&&!x){const m=j.get("error");m&&(i.error(`AniList error: ${m}`),window.history.replaceState(null,"",window.location.pathname));return}const g=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),k(!0),i("Connecting to AniList..."),h.tracker.anilistAuth.mutate(y?{token:y}:{code:x,redirectUri:g}).then(async m=>{const _=m.user;i.success(`Connected to AniList as ${_?.name??"AniList user"}`),K.invalidateQueries({queryKey:["trackerStatus"]})}).catch(m=>{i.error(m instanceof Error?m.message:"Failed to authenticate with AniList")}).finally(()=>{k(!1)})},[K]),Y}const sn="_header_j1lbh_1",rn="_fadeIn_j1lbh_1",ln="_pageTitle_j1lbh_6",on="_pageSubtitle_j1lbh_14",cn="_importCard_j1lbh_20",dn="_slideUpIn_j1lbh_1",mn="_cardHeader_j1lbh_37",pn="_uploadArea_j1lbh_55",hn="_fileInputWrapper_j1lbh_59",un="_fileInput_j1lbh_59",gn="_fileDisplay_j1lbh_87",yn="_fileIcon_j1lbh_95",bn="_fileName_j1lbh_100",_n="_browseButton_j1lbh_109",fn="_optionsArea_j1lbh_120",Nn="_checkboxLabel_j1lbh_128",kn="_checkbox_j1lbh_128",wn="_checkboxCustom_j1lbh_141",vn="_optionText_j1lbh_169",In="_optionTitle_j1lbh_175",xn="_optionDesc_j1lbh_181",Mn="_actions_j1lbh_187",Cn="_importBtn_j1lbh_195",Ln="_cancelBtn_j1lbh_201",Sn="_statusMessage_j1lbh_215",Tn="_success_j1lbh_225",An="_error_j1lbh_231",jn="_progressSection_j1lbh_237",Pn="_progressBar_j1lbh_242",En="_progressFill_j1lbh_250",Bn="_progressInfo_j1lbh_257",Dn="_progressCount_j1lbh_264",$n="_progressTitle_j1lbh_271",Fn="_sourceBadge_j1lbh_289",Un="_anilist_j1lbh_301",Rn="_kitsu_j1lbh_307",qn="_offline_j1lbh_313",Kn="_skipped_j1lbh_319",On="_cardTitleRow_j1lbh_324",Qn="_anilistIcon_j1lbh_334",Gn="_malIcon_j1lbh_340",Hn="_badgeOnline_j1lbh_346",Wn="_badgeOffline_j1lbh_358",zn="_connectedProfile_j1lbh_370",Xn="_avatar_j1lbh_379",Jn="_connectedInfo_j1lbh_386",Yn="_connectedName_j1lbh_394",Vn="_connectedHint_j1lbh_400",Zn="_loginPrompt_j1lbh_405",ea="_loginSection_j1lbh_413",na="_fieldLabel_j1lbh_419",aa="_helpText_j1lbh_438",ta="_loginText_j1lbh_455",sa="_primaryBtn_j1lbh_464",ia="_secondaryBtn_j1lbh_465",ra="_syncBtn_j1lbh_466",la="_divider_j1lbh_518",oa="_actionSection_j1lbh_524",ca="_inputGroup_j1lbh_538",da="_input_j1lbh_538",ma="_syncSummary_j1lbh_559",pa="_syncErrors_j1lbh_565",ha="_spin_j1lbh_569",ua="_radioGroup_j1lbh_598",ga="_radioLabel_j1lbh_604",ya="_syncHint_j1lbh_642",ba="_importLoading_j1lbh_649",n={header:sn,fadeIn:rn,pageTitle:ln,pageSubtitle:on,importCard:cn,slideUpIn:dn,cardHeader:mn,uploadArea:pn,fileInputWrapper:hn,fileInput:un,fileDisplay:gn,fileIcon:yn,fileName:bn,browseButton:_n,optionsArea:fn,checkboxLabel:Nn,checkbox:kn,checkboxCustom:wn,optionText:vn,optionTitle:In,optionDesc:xn,actions:Mn,importBtn:Cn,cancelBtn:Ln,statusMessage:Sn,success:Tn,error:An,progressSection:jn,progressBar:Pn,progressFill:En,progressInfo:Bn,progressCount:Dn,progressTitle:$n,sourceBadge:Fn,anilist:Un,kitsu:Rn,offline:qn,skipped:Kn,cardTitleRow:On,anilistIcon:Qn,malIcon:Gn,badgeOnline:Hn,badgeOffline:Wn,connectedProfile:zn,avatar:Xn,connectedInfo:Jn,connectedName:Yn,connectedHint:Vn,loginPrompt:Zn,loginSection:ea,fieldLabel:na,helpText:aa,loginText:ta,primaryBtn:sa,secondaryBtn:ia,syncBtn:ra,divider:la,actionSection:oa,inputGroup:ca,input:da,syncSummary:ma,syncErrors:pa,spin:ha,radioGroup:ua,radioLabel:ga,syncHint:ya,importLoading:ba},oe="tracker_anilist_client_id",Ue="49887".trim(),wa=()=>{const{setIsOpen:K}=nn(),{contentType:Y}=an(),k=Y==="manga",s=qe();Be.useEffect(()=>{document.title="Trackers - dango"},[]);const[b,j]=t(""),[y,x]=t("username"),[g,m]=t(null),[_,ce]=t(""),[M,de]=t(!1),Ke=tn(),{data:me,isLoading:pe}=Fe({queryKey:["trackerStatus"],queryFn:async()=>await h.tracker.status.query()}),{data:C}=Fe({queryKey:["anilistClientId"],queryFn:async()=>(await h.settings.getByKey.query({key:oe})).value||""}),he=De(!1);Be.useEffect(()=>{he.current||C!==void 0&&(C&&ce(C),he.current=!0)},[C]);const w=me?.anilist?.connected??!1;Re(()=>{w&&x("sync")},[w]);const O=me?.anilist?.user??null,V=!!Ue,Oe=(C||"").trim(),Qe=async()=>{const a=_.trim(),r=a||Ue;if(!r){i.error("Enter your AniList client ID first");return}const N=async(A,se)=>{await h.settings.set.mutate({key:A,value:se})};try{a?a!==C&&await N(oe,a):V&&Oe&&await N(oe,""),s.invalidateQueries({queryKey:["anilistClientId"]})}catch(A){i.error(A.message);return}const o=window.location.origin+window.location.pathname,U=encodeURIComponent(o);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(r)}&response_type=token&state=${U}`},ue=I({mutationFn:async()=>h.tracker.anilistDisconnect.mutate(),onSuccess:()=>{s.invalidateQueries({queryKey:["trackerStatus"]}),i.success("Disconnected from AniList")},onError:a=>i.error(a.message)}),Q=I({mutationFn:async()=>(await h.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),m(a),i.success(`Sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}`,{duration:6e3})},onError:a=>i.error(a.message)}),[P,ge]=t(""),[G,ye]=t("sync"),[Z,be]=t("two-way"),[c,Ge]=t(null),H=I({mutationFn:async()=>(await h.tracker.mangaSync.mutate({direction:Z})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),Ge(a);const r=(a.warnings?.length??0)>0?`, ${a.warnings.length} warning(s)`:"";i.success(`Manga sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}${r}`,{duration:6e3})},onError:a=>i.error(a.message)}),L=I({mutationFn:async()=>{if(!P.trim())throw new Error("Please enter a username");return(await h.tracker.mangaImport.mutate({username:P.trim(),erase:M})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from AniList`),ge("")},onError:a=>i.error(a.message)}),[E,_e]=t(""),[W,fe]=t("username"),[ee,Ne]=t(null),[z,ke]=t(!1),[we,ne]=t(""),[ve,He]=t(""),f=I({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a MAL username");const a=await h.tracker.mangaMalImport.mutate({username:E.trim(),erase:M});return{imported:a.imported??0,skipped:a.skipped??0}},onSuccess:({imported:a,skipped:r})=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from MAL${r>0?`, skipped ${r}`:""}`),_e("")},onError:a=>i.error(a.message)}),We=$e(async()=>{const a=document.getElementById("malMangaFile");if(!a.files||a.files.length===0){ne("Please select a file first.");return}ke(!0),ne(""),Ne(null);try{const r=new FormData;r.append("xmlfile",a.files[0]),r.append("erase",String(M));const N=await fetch("/api/import/mal-xml-manga",{method:"POST",body:r}),o=await N.json().catch(()=>({}));if(!N.ok)throw new Error(o.error||"Import failed");Ne({imported:o.imported??0,skipped:o.skipped??0}),s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]})}catch(r){ne(r.message)}finally{ke(!1)}},[M,s]),S=I({mutationFn:async()=>{if(!b.trim())throw new Error("Please enter a username");return(await h.tracker.anilistImport.mutate({username:b.trim(),erase:v})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from AniList`),j("")},onError:a=>i.error(a.message)}),[B,Ie]=t(""),u=I({mutationFn:async a=>{if(!B.trim())throw new Error("Please enter a MAL username");return(await h.tracker.malImport.mutate({username:B.trim(),erase:a.erase,useOfflineDb:a.useOfflineDb,skipFallback:a.skipFallback})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from MAL`),Ie("")},onError:a=>i.error(a.message)}),[v,xe]=t(!1),[D,ze]=t(!0),[$,Xe]=t(!1),[Me,Ce]=t(""),[T,Le]=t(!1),[p,Se]=t(null),[ae,Te]=t(null),[Ae,X]=t(""),te=De(null),Je=a=>{a.target.files&&a.target.files.length>0?Ce(a.target.files[0].name):Ce("")},Ye=$e(async()=>{const a=document.getElementById("malFile");if(!a.files||a.files.length===0){X("Please select a file first.");return}const r=a.files[0];Le(!0),Se(null),Te(null),X("");const N=new AbortController;te.current=N;try{const o=new FormData;o.append("xmlfile",r),o.append("erase",String(v)),o.append("useOfflineDb",String(D)),o.append("skipFallback",String($));const U=await fetch("/api/import/mal-xml",{method:"POST",body:o,signal:N.signal});if(!U.ok){const re=await U.text();let R="Failed to import";try{R=JSON.parse(re).error||R}catch{}throw new Error(R)}const A=U.body?.getReader();if(!A)throw new Error("No response stream");const se=new TextDecoder;let ie="",J="";for(;;){const{done:re,value:R}=await A.read();if(re)break;ie+=se.decode(R,{stream:!0});const Pe=ie.split(`
2
2
  `);ie=Pe.pop()||"";for(const q of Pe)if(q.startsWith("event: "))J=q.slice(7).trim();else if(q.startsWith("data: ")){const en=q.slice(6);try{const Ee=JSON.parse(en);J==="progress"?Se(Ee):J==="complete"&&Te(Ee)}catch{}}else q===""&&(J="")}s.invalidateQueries({queryKey:["watchlist"]})}catch(o){o instanceof DOMException&&o.name==="AbortError"?X("Import cancelled."):X(o.message)}finally{Le(!1),te.current=null}},[v,D,$,s]),Ve=()=>{te.current?.abort(),h.settings.malImportCancel.mutate().catch(()=>{})},Ze=p?Math.round(p.current/p.total*100):0,[F,je]=t("username");return e("div",{className:"page-container",children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:"Trackers"}),e("p",{className:n.pageSubtitle,children:"Import & sync your anime watchlists and manga reading lists with tracking services"})]}),e("div",{style:{marginBottom:"16px",padding:"10px 14px",borderRadius:"8px",fontSize:"0.85rem",background:"color-mix(in srgb, var(--color-warning) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-warning) 25%, transparent)",color:"var(--text-secondary)"},children:"⚠ Syncing writes directly to your AniList entries, and dango may not always handle anime/manga lists correctly — always keep a backup of your lists before syncing."}),!k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList"}),pe?null:w?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),w&&O?e("div",{className:n.connectedProfile,children:[O.avatar&&e("img",{src:O.avatar,alt:"Avatar",className:n.avatar,loading:"lazy",decoding:"async"}),e("div",{className:n.connectedInfo,children:[e("span",{className:n.connectedName,children:O.name}),e("span",{className:n.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:n.secondaryBtn,onClick:()=>ue.mutate(),disabled:ue.isPending,children:[e(l,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:n.loginSection,children:[e("p",{className:n.loginText,children:["Log in with AniList to enable bidirectional progress & status synchronization.",Ke&&e("span",{style:{marginLeft:8,color:"var(--accent)"},children:"Finishing login…"})]}),e("div",{className:n.fieldLabel,children:["AniList client ID — defaults to Dango's app"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(l,{name:"external-link-alt",size:9})]})]}),e("div",{className:n.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:_,onChange:a=>ce(a.target.value),className:n.input}),e("button",{className:n.primaryBtn,onClick:Qe,disabled:!(_.trim()||V),children:[e(l,{name:"external-link-alt"})," Connect"]})]}),e("p",{className:n.helpText,children:V?e(d,{children:["By default uses Dango's client. To use your own AniList app: create it at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:window.location.port==="5173"?`${window.location.protocol}//${window.location.hostname}:3000/api/tracker/anilist/callback`:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste only the ",e("strong",{children:"Client ID"})," above (leave empty to use Dango's)."]}):e(d,{children:["No shipped client in this build — create your own app at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:window.location.port==="5173"?`${window.location.protocol}//${window.location.hostname}:3000/api/tracker/anilist/callback`:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste the ",e("strong",{children:"Client ID"})," above."]})})]}),w&&e(d,{children:[e("hr",{className:n.divider}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"username",checked:y==="username",onChange:()=>x("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:y==="sync",onChange:()=>x("sync")}),e("span",{children:"Two-way Sync"})]})]}),y==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:b,onChange:a=>j(a.target.value),className:n.input,disabled:S.isPending,onKeyDown:a=>{a.key==="Enter"&&b.trim()&&S.mutate()}})}):e("p",{className:n.syncHint,children:"Merges progress non-destructively: pushes shows and episodes you watched on dango to AniList, and pulls anything you updated on AniList into dango."}),y==="username"&&e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:v,onChange:a=>xe(a.target.checked),className:n.checkbox,disabled:S.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]})}),y==="username"?e("button",{className:n.syncBtn,onClick:()=>S.mutate(),disabled:!b.trim()||S.isPending,children:[e(l,{name:"download"}),S.isPending?"Importing...":"Start Import"]}):e(d,{children:[e("button",{className:n.syncBtn,onClick:()=>Q.mutate(),disabled:Q.isPending,children:[e(l,{name:"sync-alt",className:Q.isPending?n.spin:""}),Q.isPending?"Syncing...":"Start Sync"]}),g&&e("div",{className:n.syncSummary,children:["Pushed: ",g.pushed," · Pulled: ",g.pulled," · Merged:"," ",g.merged," · Unchanged: ",g.unchanged,g.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",g.errors.length," error",g.errors.length>1?"s":""]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rewatching (REPEATING)"})," is not tracked — entries with this status are ignored."]})]})]})}),k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList Manga"}),pe?null:w?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),w?e(d,{children:[e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"username",checked:G==="username",onChange:()=>ye("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"sync",checked:G==="sync",onChange:()=>ye("sync")}),e("span",{children:"Two-way Sync"})]})]}),G==="username"?e(d,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:P,onChange:a=>ge(a.target.value),className:n.input,disabled:L.isPending,onKeyDown:a=>{a.key==="Enter"&&P.trim()&&L.mutate()}})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:M,onChange:a=>de(a.target.checked),className:n.checkbox,disabled:L.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:n.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})})]}):e(d,{children:[e("p",{className:n.syncHint,children:"Merges chapter progress non-destructively: pushes manga and chapters you read on dango to AniList, and pulls anything you updated on AniList into dango. Local titles are linked only on exact title matches, and bookmarks with no chapters read are never pushed."}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"two-way",checked:Z==="two-way",onChange:()=>be("two-way")}),e("span",{children:"Two-way"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"pull-only",checked:Z==="pull-only",onChange:()=>be("pull-only")}),e("span",{children:"Pull only (never writes to AniList)"})]})]})]}),G==="username"?e("button",{className:n.syncBtn,onClick:()=>L.mutate(),disabled:!P.trim()||L.isPending,children:[e(l,{name:"download"}),L.isPending?"Importing...":"Start Import"]}):e(d,{children:[e("button",{className:n.syncBtn,onClick:()=>H.mutate(),disabled:H.isPending,children:[e(l,{name:"sync-alt",className:H.isPending?n.spin:""}),H.isPending?"Syncing...":"Start Manga Sync"]}),c&&e(d,{children:[e("div",{className:n.syncSummary,children:["Pushed: ",c.pushed," · Pulled: ",c.pulled," · Merged: ",c.merged," · Unchanged:"," ",c.unchanged,(c.skipped??0)>0&&e("span",{children:[" · Skipped: ",c.skipped]}),c.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",c.errors.length," error",c.errors.length>1?"s":""]})]}),(c.warnings?.length??0)>0&&e("div",{className:n.syncErrors,style:{marginTop:"8px"},children:[(c.warnings??[]).slice(0,5).map((a,r)=>e("div",{children:["⚠ ",a]},r)),(c.warnings?.length??0)>5&&e("div",{children:["+",(c.warnings?.length??0)-5," more warning(s)"]})]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rereading (REPEATING)"})," is not tracked — entries with this status are ignored."]})]}):e("p",{className:n.loginText,children:"Connect your AniList account above to sync your manga reading list."})]})}),!k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:F==="username",onChange:()=>je("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:F==="xml",onChange:()=>je("xml")}),e("span",{children:"XML File"})]})]}),F==="username"?e(d,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:B,onChange:a=>Ie(a.target.value),className:n.input,disabled:u.isPending,onKeyDown:a=>{a.key==="Enter"&&B.trim()&&u.mutate({erase:v,useOfflineDb:D,skipFallback:$})}})}),u.isPending&&e("div",{className:n.importLoading,children:[e(l,{name:"sync-alt",className:n.spin}),e("span",{children:"Importing from MAL..."})]})]}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malFile",accept:".xml,application/xml",className:n.fileInput,onChange:Je,disabled:T}),e("div",{className:n.fileDisplay,children:[e(l,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:Me||"Choose XML file..."})]}),e("label",{htmlFor:"malFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:[e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:v,onChange:a=>xe(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:D,onChange:a=>ze(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Use offline database (fast)"}),e("span",{className:n.optionDesc,children:"Match by MAL ID locally first — instant and avoids AniList rate limits."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:$,onChange:a=>Xe(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Skip online fallback"}),e("span",{className:n.optionDesc,children:"Only import offline matches. Unmatched titles are skipped without API calls."})]})]})]}),F==="username"?e("button",{className:n.syncBtn,onClick:()=>u.mutate({erase:v,useOfflineDb:D,skipFallback:$}),disabled:!B.trim()||u.isPending,children:[e(l,{name:"download"}),u.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:T?e(le,{onClick:Ve,className:n.cancelBtn,children:"Cancel Import"}):e(le,{onClick:Ye,className:n.importBtn,disabled:!Me,children:[e(l,{name:"upload"})," Start Import"]})}),F==="username"&&u.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:u.error.message}),T&&p&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressBar,children:e("div",{className:n.progressFill,style:{width:`${Ze}%`}})}),e("div",{className:n.progressInfo,children:[e("span",{className:n.progressCount,children:[p.current," / ",p.total]}),e("span",{className:n.progressTitle,children:p.found?e(d,{children:[p.matchedTitle,e("span",{className:`${n.sourceBadge} ${n[p.source||"anilist"]}`,children:p.source==="kitsu"?"Kitsu":p.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:n.skipped,children:["Skipped: ",p.title]})})]})]}),ae&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",ae.imported,", Skipped: ",ae.skipped,"."]}),Ae&&e("div",{className:`${n.statusMessage} ${n.error}`,children:Ae})]})}),k&&e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList Manga"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"username",checked:W==="username",onChange:()=>fe("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"xml",checked:W==="xml",onChange:()=>fe("xml")}),e("span",{children:"XML File"})]})]}),W==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:E,onChange:a=>_e(a.target.value),className:n.input,disabled:f.isPending,onKeyDown:a=>{a.key==="Enter"&&E.trim()&&f.mutate()}})}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malMangaFile",accept:".xml,application/xml",className:n.fileInput,onChange:a=>He(a.target.files?.[0]?.name??""),disabled:z}),e("div",{className:n.fileDisplay,children:[e(l,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:ve||"Choose XML file..."})]}),e("label",{htmlFor:"malMangaFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:M,onChange:a=>de(a.target.checked),className:n.checkbox,disabled:f.isPending||z}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:n.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})}),W==="username"?e("button",{className:n.syncBtn,onClick:()=>f.mutate(),disabled:!E.trim()||f.isPending,children:[e(l,{name:"download"}),f.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:e(le,{onClick:We,className:n.importBtn,disabled:z||!ve,children:[e(l,{name:"upload"})," ",z?"Importing...":"Start Import"]})}),f.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:f.error.message}),we&&e("div",{className:`${n.statusMessage} ${n.error}`,children:we}),ee&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",ee.imported,", Skipped:"," ",ee.skipped,"."]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:"MAL manga is matched to AniList by MAL ID with a title fallback. Unmatched titles are skipped. Imports land as AniList-linked entries alongside your provider bookmarks."})]})]})};export{wa as default};
@@ -1,4 +1,4 @@
1
- import{u as t,d as _,A,h as v,S as Le,g as Yr,o as Gr,p as Qr,a as Xr,T as Ee,q as S}from"./vendor-core-DfaOB3Rn.js";import{u as Zr}from"./vendor-query-BBT5_sHx.js";import{g as an,e as Jr,t as _t,z as es,O as ts,M as Mn,B as We}from"./index-_iy8RyKU.js";import{I as V}from"./vendor-icons-DrybRNxP.js";import{S as ns,U as rs,p as Dn,M as ss,D as fr,m as On,k as os,C as as,a as is,b as ls,c as sn,u as cs,d as ds,e as us,j as ms,f as hs,h as fs,l as gs,B as ps,i as Ln,F as bs,G as vs,H as ur,s as Pn,n as ys,o as _s,q as Ss,r as Ts,t as Ze,A as Cs,v as ks,E as Es,y as xs,P as Ns,w as Se,z as Is,R as Bs}from"./AvSyncCalibrator-XH4E6Sfp.js";import{S as ws,O as Rn,a as As,A as Ms,b as Ls}from"./OptionListMenu-BQnYYHpM.js";import{u as Ps}from"./useProviders-swR4Flu5.js";import{d as Rs,g as $s,h as Ds,f as Os,e as Fs,j as Vs,k as js}from"./useTvLibrary-BuMreQuF.js";import{l as Us,c as Ws}from"./hls-E2REEW_P.js";import{u as zs}from"./useIsMobile-Dvx1uJ82.js";import{S as Hs}from"./SynopsisText-B3Sa5pRv.js";const Ks="_fullscreenFlat_1xij1_1",qs="_timeDisplay_1xij1_15",Ys="_bottomControls_1xij1_19",Gs="_leftControls_1xij1_23",Qs="_rightControls_1xij1_24",Xs="_controlBtn_1xij1_28",Zs="_controlsOverlay_1xij1_47",Js="_hidden_1xij1_67",eo="_topControls_1xij1_73",to="_backBtn_1xij1_93",no="_videoTitleInfo_1xij1_113",ro="_animeTitle_1xij1_119",so="_episodeLabel_1xij1_127",oo="_speedBoostBadge_1xij1_134",ao="_progressBarContainer_1xij1_180",io="_progressBar_1xij1_180",lo="_thumb_1xij1_199",co="_bufferedBar_1xij1_217",uo="_watchedBar_1xij1_227",mo="_scrubbing_1xij1_252",ho="_timeBubble_1xij1_256",fo="_bottomControlsRow_1xij1_270",go="_nextEpisodeBtn_1xij1_293",po="_active_1xij1_346",bo="_settingsPanel_1xij1_421",vo="_settingsHeader_1xij1_440",yo="_settingsBackBtn_1xij1_448",_o="_settingsTitle_1xij1_466",So="_settingsContent_1xij1_477",To="_currentValue_1xij1_486",Co="_menuItem_1xij1_501",ko="_menuNote_1xij1_534",Eo="_loadingOverlay_1xij1_547",xo="_loadingDots_1xij1_558",No="_dot_1xij1_563",Io="_bufferingOverlay_1xij1_592",Bo="_bufferingSpinner_1xij1_601",a={fullscreenFlat:Ks,timeDisplay:qs,bottomControls:Ys,leftControls:Gs,rightControls:Qs,controlBtn:Xs,controlsOverlay:Zs,hidden:Js,topControls:eo,backBtn:to,videoTitleInfo:no,animeTitle:ro,episodeLabel:so,speedBoostBadge:oo,progressBarContainer:ao,progressBar:io,thumb:lo,bufferedBar:co,watchedBar:uo,scrubbing:mo,timeBubble:ho,bottomControlsRow:fo,nextEpisodeBtn:go,active:po,settingsPanel:bo,settingsHeader:vo,settingsBackBtn:yo,settingsTitle:_o,settingsContent:So,currentValue:To,menuItem:Co,menuNote:ko,loadingOverlay:Eo,loadingDots:xo,dot:No,bufferingOverlay:Io,bufferingSpinner:Bo},wo=({player:o,visible:b,settingsOpen:W,onOpenSettings:F,onCloseSettings:G,hasSubtitles:R,isSubtitleActive:r,subtitles:B,onSubtitleChange:i,showNextEpisodeButton:te,onNextEpisode:Q,isTheaterMode:$,onTheaterModeToggle:f,timeLabelRef:K})=>{const{state:h,refs:ze,actions:D}=o,X=ze.videoRef,Pe=T=>{const ne=X.current;!ne||isNaN(h.duration)||h.duration===0||(ne.currentTime=T*h.duration)},Re=()=>{X.current&&(D.setIsScrubbing(!0),D.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},He=T=>{const ne=X.current;ne&&h.duration&&(ne.currentTime=T*h.duration)},Ke=()=>{D.setIsScrubbing(!1),D.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Je=T=>{const ne=X.current;ne&&(ne.volume=T,ne.muted=T===0)},ae=()=>{if(r){i(-1);return}let T=null;try{T=localStorage.getItem("tvLastSubtitle")}catch{}i(Dn(B,{lastKey:T,enabled:!0}))},q=h.isMuted?t(V,{name:"volume-mute"}):h.volume<.5?t(V,{name:"volume-down"}):t(V,{name:"volume-up"});return t("div",{className:`${a.controlsOverlay} ${b?"":a.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:a.bottomControls,onClick:T=>T.stopPropagation(),children:[t(ns,{classes:{container:a.progressBarContainer,scrubbing:a.scrubbing,timeBubble:a.timeBubble,bar:a.progressBar,buffered:a.bufferedBar,watched:a.watchedBar,thumb:a.thumb},videoRef:X,duration:h.duration,formatTime:an,isScrubbing:h.isScrubbing,buffered:"full",onSeek:Pe,onScrubStart:Re,onScrubMove:He,onScrubEnd:Ke,timeLabelRef:K}),t("div",{className:a.bottomControlsRow,children:[t("div",{className:a.leftControls,children:[t("button",{className:a.controlBtn,onClick:D.togglePlay,"aria-label":h.isPlaying?"Pause":"Play",children:h.isPlaying?t(V,{name:"pause"}):t(V,{name:"play"})}),t(rs,{muted:h.isMuted,volume:h.volume,volumeIcon:q,buttonClassName:a.controlBtn,onToggleMute:D.toggleMute,onVolumeChange:Je,onExpandedChange:T=>D.setShowVolumeSlider(T)}),t("span",{className:a.timeDisplay,ref:K,children:[an(0)," / ",an(h.duration)]})]}),t("div",{className:a.rightControls,children:[te&&t("button",{className:a.nextEpisodeBtn,onClick:Q,title:"Play next episode",children:"Next EP"}),R&&t("button",{className:`${a.controlBtn} ${r?a.active:""}`,onClick:ae,"aria-label":r?"Turn subtitles off":"Turn subtitles on",children:t(V,{name:"closed-captioning"})}),t("button",{className:`${a.controlBtn} ${W?a.active:""}`,onClick:()=>W?G():F(),"aria-label":"Settings",children:t(V,{name:"cog"})}),t("button",{className:`${a.controlBtn} ${$?a.active:""}`,onClick:T=>{T.stopPropagation(),f()},title:$?"Exit Theater Mode":"Theater Mode","aria-label":$?"Exit Theater Mode":"Theater Mode",children:t(V,{name:"tv"})}),t("button",{className:a.controlBtn,onClick:D.toggleFullscreen,"aria-label":h.isFullscreen?"Exit Fullscreen":"Fullscreen",children:h.isFullscreen?t(V,{name:"compress"}):t(V,{name:"expand"})})]})]})]})})},on=-6e4,$n=6e4,mr=500,Ao=({classes:o,delayMs:b,onDelayChange:W})=>{const[F,G]=_(null),R=F??b,r=A(W);r.current=W;const B=A(b);B.current=b;const i=A(null);i.current=F,v(()=>{G(null)},[b]),v(()=>()=>{const $=i.current;$!==null&&$!==B.current&&r.current($)},[]);const te=$=>{B.current=$,i.current=null,r.current($),G(null)},Q=$=>{const f=i.current??B.current,K=Math.max(on,Math.min($n,f+$));te(K)};return t(Le,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:o.item,onClick:()=>Q(-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:o.item,onClick:()=>Q(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:o.item,onClick:()=>te(0),disabled:R===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(ss,{label:"Subtitle timing",display:fr(R),min:on,max:$n,step:100,value:R,percent:(R-on)/($n-on)*100,onChange:$=>{const f=Math.round($);i.current=f,G(f)},onCommit:()=>{const $=i.current;$!==null&&te($)}}),t("div",{className:o.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},Mo=({view:o,onSelectView:b,onClose:W,player:F,onSubtitleStyleChange:G,streams:R,resolutionIdx:r,onResolutionChange:B,hasSubtitles:i,subtitles:te,selectedSubtitle:Q,isSubtitleActive:$,onSubtitleChange:f,audioTracks:K,selectedAudioTrack:h,onAudioTrackChange:ze,videoDelayEnabled:D,onVideoDelayToggle:X,videoDelayMs:Pe,onVideoDelayChange:Re,onCalibrate:He,subtitleDelayMs:Ke,onSubtitleDelayChange:Je,ambientSettings:ae,onAmbientChange:q})=>{const{state:T}=F,ne=()=>t(Le,{children:[R.length>1&&t("button",{className:a.menuItem,onClick:()=>b("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:a.currentValue,children:R[r]?.quality||"Auto"})]}),i&&t("button",{className:a.menuItem,onClick:()=>b("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:a.currentValue,children:$?te[Q]?.label||te[Q]?.language:"Off"})]}),i&&t("button",{className:a.menuItem,onClick:()=>b("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:a.currentValue,children:[T.subtitleFontSize.toFixed(1),"x · ",T.subtitlePosition]})]}),i&&t("button",{className:a.menuItem,onClick:()=>b("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:a.currentValue,children:fr(Ke)})]}),K.length>0&&t("button",{className:a.menuItem,onClick:()=>b("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:a.currentValue,children:K[h]?.label||K[h]?.language})]}),t("button",{className:a.menuItem,onClick:()=>b("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:a.currentValue,children:D?`${Pe}ms`:"Off"})]}),ae&&q&&t("button",{className:a.menuItem,onClick:()=>b("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:a.currentValue,children:ae.enabled?"On":"Off"})]})]}),Te=()=>t(Rn,{classes:{item:a.menuItem,active:a.active},options:R.map((C,z)=>({key:String(z),label:C.quality,selected:z===r})),onSelect:C=>B(Number(C))}),Y=()=>t(Rn,{classes:{item:a.menuItem,active:a.active},options:[{key:"off",label:"Off",selected:!$},...te.map((C,z)=>({key:String(z),label:C.label||C.language,selected:z===Q}))],onSelect:C=>f(C==="off"?-1:Number(C))}),Ce=()=>t(As,{classes:{item:a.menuItem,active:a.active},values:{fontSize:T.subtitleFontSize,position:T.subtitlePosition,bgOpacity:T.subtitleBgOpacity,bgColor:T.subtitleBgColor,textColor:T.subtitleTextColor,edge:T.subtitleEdge,bold:T.subtitleBold},onChange:G}),M=()=>t(Ao,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},delayMs:Ke,onDelayChange:C=>Je?.(C)}),$e=()=>t(Rn,{classes:{item:a.menuItem,active:a.active},options:K.map((C,z)=>({key:String(z),label:C.label||C.language,selected:z===h})),onSelect:C=>ze(Number(C))}),qe=()=>t(Ms,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},enabled:D,delayMs:Pe,onToggle:C=>X?.(C),onDelayChange:C=>Re?.(C),onCalibrate:He}),pe=()=>ae&&q?t(Ls,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},values:ae,onChange:q}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:C=>C.stopPropagation(),children:t(ws,{classes:{panel:a.settingsPanel,header:a.settingsHeader,backBtn:a.settingsBackBtn,title:a.settingsTitle,content:a.settingsContent},title:o==="main"?"Settings":o==="subtitle-style"?"Subtitle Style":o==="subtitle-timing"?"Subtitle Timing":o==="audio"?"Audio Track":o==="resolution"?"Resolution":o==="av-sync"?"A/V Sync":o==="ambient"?"Ambient Light":o.charAt(0).toUpperCase()+o.slice(1),onBack:()=>o==="main"?W():b("main"),children:[o==="main"&&ne(),o==="resolution"&&Te(),o==="subtitles"&&Y(),o==="subtitle-style"&&Ce(),o==="subtitle-timing"&&M(),o==="audio"&&$e(),o==="av-sync"&&qe(),o==="ambient"&&pe()]})})},Lo=({player:o,title:b,episodeLabel:W,audioTracks:F,selectedAudioTrack:G,onAudioTrackChange:R,subtitles:r,selectedSubtitle:B,onSubtitleChange:i,streams:te,resolutionIdx:Q,onResolutionChange:$,onBack:f,children:K,videoDelayEnabled:h=!1,onVideoDelayToggle:ze,videoDelayMs:D=0,onVideoDelayChange:X,onCalibrateAvSync:Pe,subtitleDelayMs:Re=0,onSubtitleDelayChange:He,showNextEpisodeButton:Ke=!1,onNextEpisode:Je,isLoading:ae=!1,isTheaterMode:q,onTheaterModeToggle:T,ambientSettings:ne,onAmbientChange:Te})=>{const{state:Y,refs:Ce,actions:M}=o,$e=Ce.videoRef,{subtitleFontSize:qe,subtitlePosition:pe,subtitleBgOpacity:C,subtitleBgColor:z,subtitleTextColor:it,subtitleEdge:ie,subtitleBold:De}=Y,[xe,Oe]=_(null),lt=A(null),[Vt,St]=_(0);v(()=>{const le=$e.current;if(!le)return;const u=()=>St(le.clientHeight||0);u();const ut=new ResizeObserver(u);return ut.observe(le),()=>ut.disconnect()},[$e]);const ue=(le,u)=>{try{localStorage.setItem(le,String(u))}catch{}},be=(le,u)=>{switch(le){case"fontSize":typeof u=="number"&&(M.setSubtitleFontSize(u),ue("subtitleFontSize",u));break;case"position":typeof u=="number"&&(M.setSubtitlePosition(u),ue("subtitlePosition",u));break;case"bgOpacity":typeof u=="number"&&(M.setSubtitleBgOpacity(u),ue("subtitleBgOpacity",u));break;case"bgColor":typeof u=="string"&&(M.setSubtitleBgColor(u),ue("subtitleBgColor",u));break;case"textColor":typeof u=="string"&&(M.setSubtitleTextColor(u),ue("subtitleTextColor",u));break;case"edge":(u==="shadow"||u==="outline"||u==="none")&&(M.setSubtitleEdge(u),ue("subtitleEdge",u));break;case"bold":typeof u=="boolean"&&(M.setSubtitleBold(u),ue("subtitleBold",u));break}};v(()=>{const le="tv-player-subtitle-style";let u=document.getElementById(le);u||(u=document.createElement("style"),u.id=le,document.head.appendChild(u));const ut={fontSize:qe,position:pe,bgOpacity:C,bgColor:z,textColor:it,edge:ie,bold:De},Z=$e.current,Et=On(qe,Vt||Z?.clientHeight||720);if(u.textContent=os({...ut,fontSize:Et}),Z){const xt=()=>{const w=Number(pe);return isNaN(w)?0:Math.max(0,Math.min(100,w))},mt=(w,J)=>{try{const de=w;de.snapToLines=!1,de.line=J}catch{}},Nt=()=>{const w=Et*16,J=Z.videoHeight||Z.clientHeight||720,de=Z.videoWidth||Z.clientWidth||1280;return{step:w*1.3/J*100,chars:Math.max(20,Math.floor(de/(w*.55)))}},y=w=>{const J=Math.max(0,Math.min(100,100-xt())),de=Array.from(w.activeCues??[]);if(de.length<=1){de.forEach(Ve=>mt(Ve,J));return}const{step:wt,chars:cn}=Nt();let ke=J;for(let Ve=de.length-1;Ve>=0;Ve--){const dn=String(de[Ve].text??"").replace(/<[^>]*>/g,"").split(`
1
+ import{u as t,d as _,A,h as v,S as Le,g as Yr,o as Gr,p as Qr,a as Xr,T as Ee,q as S}from"./vendor-core-DfaOB3Rn.js";import{u as Zr}from"./vendor-query-BBT5_sHx.js";import{g as an,e as Jr,t as _t,z as es,O as ts,M as Mn,B as We}from"./index-CfgPGaUO.js";import{I as V}from"./vendor-icons-DrybRNxP.js";import{S as ns,U as rs,p as Dn,M as ss,D as fr,m as On,k as os,C as as,a as is,b as ls,c as sn,u as cs,d as ds,e as us,j as ms,f as hs,h as fs,l as gs,B as ps,i as Ln,F as bs,G as vs,H as ur,s as Pn,n as ys,o as _s,q as Ss,r as Ts,t as Ze,A as Cs,v as ks,E as Es,y as xs,P as Ns,w as Se,z as Is,R as Bs}from"./AvSyncCalibrator-PqA6B5Ey.js";import{S as ws,O as Rn,a as As,A as Ms,b as Ls}from"./OptionListMenu-BjoortST.js";import{u as Ps}from"./useProviders-DDPMV3HX.js";import{d as Rs,g as $s,h as Ds,f as Os,e as Fs,j as Vs,k as js}from"./useTvLibrary-CL3kMD_c.js";import{l as Us,c as Ws}from"./hls-B9wsDt6U.js";import{u as zs}from"./useIsMobile-Dvx1uJ82.js";import{S as Hs}from"./SynopsisText-B3Sa5pRv.js";const Ks="_fullscreenFlat_1xij1_1",qs="_timeDisplay_1xij1_15",Ys="_bottomControls_1xij1_19",Gs="_leftControls_1xij1_23",Qs="_rightControls_1xij1_24",Xs="_controlBtn_1xij1_28",Zs="_controlsOverlay_1xij1_47",Js="_hidden_1xij1_67",eo="_topControls_1xij1_73",to="_backBtn_1xij1_93",no="_videoTitleInfo_1xij1_113",ro="_animeTitle_1xij1_119",so="_episodeLabel_1xij1_127",oo="_speedBoostBadge_1xij1_134",ao="_progressBarContainer_1xij1_180",io="_progressBar_1xij1_180",lo="_thumb_1xij1_199",co="_bufferedBar_1xij1_217",uo="_watchedBar_1xij1_227",mo="_scrubbing_1xij1_252",ho="_timeBubble_1xij1_256",fo="_bottomControlsRow_1xij1_270",go="_nextEpisodeBtn_1xij1_293",po="_active_1xij1_346",bo="_settingsPanel_1xij1_421",vo="_settingsHeader_1xij1_440",yo="_settingsBackBtn_1xij1_448",_o="_settingsTitle_1xij1_466",So="_settingsContent_1xij1_477",To="_currentValue_1xij1_486",Co="_menuItem_1xij1_501",ko="_menuNote_1xij1_534",Eo="_loadingOverlay_1xij1_547",xo="_loadingDots_1xij1_558",No="_dot_1xij1_563",Io="_bufferingOverlay_1xij1_592",Bo="_bufferingSpinner_1xij1_601",a={fullscreenFlat:Ks,timeDisplay:qs,bottomControls:Ys,leftControls:Gs,rightControls:Qs,controlBtn:Xs,controlsOverlay:Zs,hidden:Js,topControls:eo,backBtn:to,videoTitleInfo:no,animeTitle:ro,episodeLabel:so,speedBoostBadge:oo,progressBarContainer:ao,progressBar:io,thumb:lo,bufferedBar:co,watchedBar:uo,scrubbing:mo,timeBubble:ho,bottomControlsRow:fo,nextEpisodeBtn:go,active:po,settingsPanel:bo,settingsHeader:vo,settingsBackBtn:yo,settingsTitle:_o,settingsContent:So,currentValue:To,menuItem:Co,menuNote:ko,loadingOverlay:Eo,loadingDots:xo,dot:No,bufferingOverlay:Io,bufferingSpinner:Bo},wo=({player:o,visible:b,settingsOpen:W,onOpenSettings:F,onCloseSettings:G,hasSubtitles:R,isSubtitleActive:r,subtitles:B,onSubtitleChange:i,showNextEpisodeButton:te,onNextEpisode:Q,isTheaterMode:$,onTheaterModeToggle:f,timeLabelRef:K})=>{const{state:h,refs:ze,actions:D}=o,X=ze.videoRef,Pe=T=>{const ne=X.current;!ne||isNaN(h.duration)||h.duration===0||(ne.currentTime=T*h.duration)},Re=()=>{X.current&&(D.setIsScrubbing(!0),D.wasPlayingBeforeScrub.current=!X.current.paused,X.current.pause())},He=T=>{const ne=X.current;ne&&h.duration&&(ne.currentTime=T*h.duration)},Ke=()=>{D.setIsScrubbing(!1),D.wasPlayingBeforeScrub.current&&X.current?.play().catch(()=>{})},Je=T=>{const ne=X.current;ne&&(ne.volume=T,ne.muted=T===0)},ae=()=>{if(r){i(-1);return}let T=null;try{T=localStorage.getItem("tvLastSubtitle")}catch{}i(Dn(B,{lastKey:T,enabled:!0}))},q=h.isMuted?t(V,{name:"volume-mute"}):h.volume<.5?t(V,{name:"volume-down"}):t(V,{name:"volume-up"});return t("div",{className:`${a.controlsOverlay} ${b?"":a.hidden}`,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:t("div",{className:a.bottomControls,onClick:T=>T.stopPropagation(),children:[t(ns,{classes:{container:a.progressBarContainer,scrubbing:a.scrubbing,timeBubble:a.timeBubble,bar:a.progressBar,buffered:a.bufferedBar,watched:a.watchedBar,thumb:a.thumb},videoRef:X,duration:h.duration,formatTime:an,isScrubbing:h.isScrubbing,buffered:"full",onSeek:Pe,onScrubStart:Re,onScrubMove:He,onScrubEnd:Ke,timeLabelRef:K}),t("div",{className:a.bottomControlsRow,children:[t("div",{className:a.leftControls,children:[t("button",{className:a.controlBtn,onClick:D.togglePlay,"aria-label":h.isPlaying?"Pause":"Play",children:h.isPlaying?t(V,{name:"pause"}):t(V,{name:"play"})}),t(rs,{muted:h.isMuted,volume:h.volume,volumeIcon:q,buttonClassName:a.controlBtn,onToggleMute:D.toggleMute,onVolumeChange:Je,onExpandedChange:T=>D.setShowVolumeSlider(T)}),t("span",{className:a.timeDisplay,ref:K,children:[an(0)," / ",an(h.duration)]})]}),t("div",{className:a.rightControls,children:[te&&t("button",{className:a.nextEpisodeBtn,onClick:Q,title:"Play next episode",children:"Next EP"}),R&&t("button",{className:`${a.controlBtn} ${r?a.active:""}`,onClick:ae,"aria-label":r?"Turn subtitles off":"Turn subtitles on",children:t(V,{name:"closed-captioning"})}),t("button",{className:`${a.controlBtn} ${W?a.active:""}`,onClick:()=>W?G():F(),"aria-label":"Settings",children:t(V,{name:"cog"})}),t("button",{className:`${a.controlBtn} ${$?a.active:""}`,onClick:T=>{T.stopPropagation(),f()},title:$?"Exit Theater Mode":"Theater Mode","aria-label":$?"Exit Theater Mode":"Theater Mode",children:t(V,{name:"tv"})}),t("button",{className:a.controlBtn,onClick:D.toggleFullscreen,"aria-label":h.isFullscreen?"Exit Fullscreen":"Fullscreen",children:h.isFullscreen?t(V,{name:"compress"}):t(V,{name:"expand"})})]})]})]})})},on=-6e4,$n=6e4,mr=500,Ao=({classes:o,delayMs:b,onDelayChange:W})=>{const[F,G]=_(null),R=F??b,r=A(W);r.current=W;const B=A(b);B.current=b;const i=A(null);i.current=F,v(()=>{G(null)},[b]),v(()=>()=>{const $=i.current;$!==null&&$!==B.current&&r.current($)},[]);const te=$=>{B.current=$,i.current=null,r.current($),G(null)},Q=$=>{const f=i.current??B.current,K=Math.max(on,Math.min($n,f+$));te(K)};return t(Le,{children:[t("div",{style:{display:"flex",gap:6,padding:"0.5rem 0.75rem 0.25rem"},children:[t("button",{type:"button",className:o.item,onClick:()=>Q(-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:o.item,onClick:()=>Q(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:o.item,onClick:()=>te(0),disabled:R===0,"aria-label":"Reset subtitle timing",style:{flex:1,justifyContent:"center"},children:t("span",{children:"Reset"})})]}),t(ss,{label:"Subtitle timing",display:fr(R),min:on,max:$n,step:100,value:R,percent:(R-on)/($n-on)*100,onChange:$=>{const f=Math.round($);i.current=f,G(f)},onCommit:()=>{const $=i.current;$!==null&&te($)}}),t("div",{className:o.note,children:"Positive delays subtitles (show later). Negative shows them earlier. 0.0s is default."})]})},Mo=({view:o,onSelectView:b,onClose:W,player:F,onSubtitleStyleChange:G,streams:R,resolutionIdx:r,onResolutionChange:B,hasSubtitles:i,subtitles:te,selectedSubtitle:Q,isSubtitleActive:$,onSubtitleChange:f,audioTracks:K,selectedAudioTrack:h,onAudioTrackChange:ze,videoDelayEnabled:D,onVideoDelayToggle:X,videoDelayMs:Pe,onVideoDelayChange:Re,onCalibrate:He,subtitleDelayMs:Ke,onSubtitleDelayChange:Je,ambientSettings:ae,onAmbientChange:q})=>{const{state:T}=F,ne=()=>t(Le,{children:[R.length>1&&t("button",{className:a.menuItem,onClick:()=>b("resolution"),children:[t("span",{children:"Resolution"}),t("span",{className:a.currentValue,children:R[r]?.quality||"Auto"})]}),i&&t("button",{className:a.menuItem,onClick:()=>b("subtitles"),children:[t("span",{children:"Subtitles"}),t("span",{className:a.currentValue,children:$?te[Q]?.label||te[Q]?.language:"Off"})]}),i&&t("button",{className:a.menuItem,onClick:()=>b("subtitle-style"),children:[t("span",{children:"Subtitle Style"}),t("span",{className:a.currentValue,children:[T.subtitleFontSize.toFixed(1),"x · ",T.subtitlePosition]})]}),i&&t("button",{className:a.menuItem,onClick:()=>b("subtitle-timing"),children:[t("span",{children:"Subtitle Timing"}),t("span",{className:a.currentValue,children:fr(Ke)})]}),K.length>0&&t("button",{className:a.menuItem,onClick:()=>b("audio"),children:[t("span",{children:"Audio Track"}),t("span",{className:a.currentValue,children:K[h]?.label||K[h]?.language})]}),t("button",{className:a.menuItem,onClick:()=>b("av-sync"),children:[t("span",{children:"A/V Sync"}),t("span",{className:a.currentValue,children:D?`${Pe}ms`:"Off"})]}),ae&&q&&t("button",{className:a.menuItem,onClick:()=>b("ambient"),children:[t("span",{children:"Ambient Light"}),t("span",{className:a.currentValue,children:ae.enabled?"On":"Off"})]})]}),Te=()=>t(Rn,{classes:{item:a.menuItem,active:a.active},options:R.map((C,z)=>({key:String(z),label:C.quality,selected:z===r})),onSelect:C=>B(Number(C))}),Y=()=>t(Rn,{classes:{item:a.menuItem,active:a.active},options:[{key:"off",label:"Off",selected:!$},...te.map((C,z)=>({key:String(z),label:C.label||C.language,selected:z===Q}))],onSelect:C=>f(C==="off"?-1:Number(C))}),Ce=()=>t(As,{classes:{item:a.menuItem,active:a.active},values:{fontSize:T.subtitleFontSize,position:T.subtitlePosition,bgOpacity:T.subtitleBgOpacity,bgColor:T.subtitleBgColor,textColor:T.subtitleTextColor,edge:T.subtitleEdge,bold:T.subtitleBold},onChange:G}),M=()=>t(Ao,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},delayMs:Ke,onDelayChange:C=>Je?.(C)}),$e=()=>t(Rn,{classes:{item:a.menuItem,active:a.active},options:K.map((C,z)=>({key:String(z),label:C.label||C.language,selected:z===h})),onSelect:C=>ze(Number(C))}),qe=()=>t(Ms,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},enabled:D,delayMs:Pe,onToggle:C=>X?.(C),onDelayChange:C=>Re?.(C),onCalibrate:He}),pe=()=>ae&&q?t(Ls,{classes:{item:a.menuItem,active:a.active,note:a.menuNote},values:ae,onChange:q}):null;return t("div",{"data-speed-boost-ignore":"true",onClick:C=>C.stopPropagation(),children:t(ws,{classes:{panel:a.settingsPanel,header:a.settingsHeader,backBtn:a.settingsBackBtn,title:a.settingsTitle,content:a.settingsContent},title:o==="main"?"Settings":o==="subtitle-style"?"Subtitle Style":o==="subtitle-timing"?"Subtitle Timing":o==="audio"?"Audio Track":o==="resolution"?"Resolution":o==="av-sync"?"A/V Sync":o==="ambient"?"Ambient Light":o.charAt(0).toUpperCase()+o.slice(1),onBack:()=>o==="main"?W():b("main"),children:[o==="main"&&ne(),o==="resolution"&&Te(),o==="subtitles"&&Y(),o==="subtitle-style"&&Ce(),o==="subtitle-timing"&&M(),o==="audio"&&$e(),o==="av-sync"&&qe(),o==="ambient"&&pe()]})})},Lo=({player:o,title:b,episodeLabel:W,audioTracks:F,selectedAudioTrack:G,onAudioTrackChange:R,subtitles:r,selectedSubtitle:B,onSubtitleChange:i,streams:te,resolutionIdx:Q,onResolutionChange:$,onBack:f,children:K,videoDelayEnabled:h=!1,onVideoDelayToggle:ze,videoDelayMs:D=0,onVideoDelayChange:X,onCalibrateAvSync:Pe,subtitleDelayMs:Re=0,onSubtitleDelayChange:He,showNextEpisodeButton:Ke=!1,onNextEpisode:Je,isLoading:ae=!1,isTheaterMode:q,onTheaterModeToggle:T,ambientSettings:ne,onAmbientChange:Te})=>{const{state:Y,refs:Ce,actions:M}=o,$e=Ce.videoRef,{subtitleFontSize:qe,subtitlePosition:pe,subtitleBgOpacity:C,subtitleBgColor:z,subtitleTextColor:it,subtitleEdge:ie,subtitleBold:De}=Y,[xe,Oe]=_(null),lt=A(null),[Vt,St]=_(0);v(()=>{const le=$e.current;if(!le)return;const u=()=>St(le.clientHeight||0);u();const ut=new ResizeObserver(u);return ut.observe(le),()=>ut.disconnect()},[$e]);const ue=(le,u)=>{try{localStorage.setItem(le,String(u))}catch{}},be=(le,u)=>{switch(le){case"fontSize":typeof u=="number"&&(M.setSubtitleFontSize(u),ue("subtitleFontSize",u));break;case"position":typeof u=="number"&&(M.setSubtitlePosition(u),ue("subtitlePosition",u));break;case"bgOpacity":typeof u=="number"&&(M.setSubtitleBgOpacity(u),ue("subtitleBgOpacity",u));break;case"bgColor":typeof u=="string"&&(M.setSubtitleBgColor(u),ue("subtitleBgColor",u));break;case"textColor":typeof u=="string"&&(M.setSubtitleTextColor(u),ue("subtitleTextColor",u));break;case"edge":(u==="shadow"||u==="outline"||u==="none")&&(M.setSubtitleEdge(u),ue("subtitleEdge",u));break;case"bold":typeof u=="boolean"&&(M.setSubtitleBold(u),ue("subtitleBold",u));break}};v(()=>{const le="tv-player-subtitle-style";let u=document.getElementById(le);u||(u=document.createElement("style"),u.id=le,document.head.appendChild(u));const ut={fontSize:qe,position:pe,bgOpacity:C,bgColor:z,textColor:it,edge:ie,bold:De},Z=$e.current,Et=On(qe,Vt||Z?.clientHeight||720);if(u.textContent=os({...ut,fontSize:Et}),Z){const xt=()=>{const w=Number(pe);return isNaN(w)?0:Math.max(0,Math.min(100,w))},mt=(w,J)=>{try{const de=w;de.snapToLines=!1,de.line=J}catch{}},Nt=()=>{const w=Et*16,J=Z.videoHeight||Z.clientHeight||720,de=Z.videoWidth||Z.clientWidth||1280;return{step:w*1.3/J*100,chars:Math.max(20,Math.floor(de/(w*.55)))}},y=w=>{const J=Math.max(0,Math.min(100,100-xt())),de=Array.from(w.activeCues??[]);if(de.length<=1){de.forEach(Ve=>mt(Ve,J));return}const{step:wt,chars:cn}=Nt();let ke=J;for(let Ve=de.length-1;Ve>=0;Ve--){const dn=String(de[Ve].text??"").replace(/<[^>]*>/g,"").split(`
2
2
  `).reduce((un,ve)=>un+Math.max(1,Math.ceil(ve.length/cn)),0),Wt=ke-dn*wt;mt(de[Ve],Math.max(0,Wt)),ke=Wt-wt*.4}},c=()=>{const w=Math.max(0,Math.min(100,100-xt()));Array.from(Z.textTracks).forEach(J=>{J.cues&&(Array.from(J.cues).forEach(de=>mt(de,w)),J.mode==="showing"&&y(J))})};c();const re=w=>{const J=w.target;J.mode==="showing"&&y(J)},ce=()=>{Array.from(Z.textTracks).forEach(w=>{w.removeEventListener("cuechange",re),w.addEventListener("cuechange",re)}),c()};Array.from(Z.textTracks).forEach(w=>{w.addEventListener("cuechange",re)}),Z.textTracks.addEventListener("addtrack",ce);const It=Array.from(Z.querySelectorAll("track")),Bt=()=>c();return It.forEach(w=>w.addEventListener("load",Bt)),()=>{Array.from(Z.textTracks).forEach(w=>{w.removeEventListener("cuechange",re)}),Z.textTracks.removeEventListener("addtrack",ce),It.forEach(w=>w.removeEventListener("load",Bt))}}},[qe,pe,C,z,it,ie,De,B,r,$e,Vt]);const Tt=r.length>0,ct=B>=0,L=()=>{Oe("main"),M.setShowControls(!0)},dt=()=>{Oe(null)},Ct=Y.showControls||!!xe,Fe=t(ls,{visible:Ct,title:b,episode:W,onBack:f,classes:{overlay:a.controlsOverlay,hidden:a.hidden,top:a.topControls,backBtn:a.backBtn,titleInfo:a.videoTitleInfo,title:a.animeTitle,episode:a.episodeLabel}}),jt=!ae&&!Y.isBuffering&&Y.duration>0?t(as,{isPlaying:Y.isPlaying,onTogglePlay:M.togglePlay,onSkipBack:()=>M.seek(-10),onSkipForward:()=>M.seek(10)}):null,ln=t(wo,{player:o,visible:Ct,settingsOpen:!!xe,onOpenSettings:L,onCloseSettings:dt,hasSubtitles:Tt,isSubtitleActive:ct,subtitles:r,onSubtitleChange:i,showNextEpisodeButton:Ke,onNextEpisode:Je,isTheaterMode:q,onTheaterModeToggle:T,timeLabelRef:lt}),kt=xe?t(Mo,{view:xe,onSelectView:Oe,onClose:dt,player:o,onSubtitleStyleChange:be,streams:te,resolutionIdx:Q,onResolutionChange:$,hasSubtitles:Tt,subtitles:r,selectedSubtitle:B,isSubtitleActive:ct,onSubtitleChange:i,audioTracks:F,selectedAudioTrack:G,onAudioTrackChange:R,videoDelayEnabled:h,onVideoDelayToggle:ze,videoDelayMs:D,onVideoDelayChange:X,onCalibrate:()=>{Oe(null),Pe?.()},subtitleDelayMs:Re,onSubtitleDelayChange:He,ambientSettings:ne,onAmbientChange:Te}):null,Ut=t(Le,{children:[ae&&t("div",{className:a.loadingOverlay,"aria-hidden":"true",children:t("div",{className:a.loadingDots,children:[t("div",{className:a.dot}),t("div",{className:a.dot}),t("div",{className:a.dot})]})}),Y.isBuffering&&!ae&&t("div",{className:a.bufferingOverlay,"aria-hidden":"true",children:t("div",{className:a.bufferingSpinner})}),Y.isSpeedBoostActive&&t("div",{className:a.speedBoostBadge,"aria-hidden":"true",children:[t("span",{children:"2x"}),t(V,{name:"forward",size:12})]})]});return t(is,{player:o,topBar:Fe,centerControls:jt,bottomBar:!ae&&Y.duration>0?ln:null,settingsPanel:kt,overlays:Ut,isInteracting:!!xe,className:Y.isFullscreen?a.fullscreenFlat:"",children:K})},Po=({servers:o,selectedServer:b,onServerSelect:W})=>o.length===0?null:t("div",{className:sn.sourceSelectionContainer,children:[t("h4",{children:"Source"}),t("div",{className:sn.sourceButtons,children:o.map(F=>t("button",{className:`${sn.sourceButton} ${b===F?sn.active:""}`,onClick:()=>W(F),children:F},F))})]}),Ro=Yr.memo(Po);function $o(o,b,W){const F=()=>{const R=Array.isArray(o.audioTracks)?o.audioTracks.length:0,r=W.getWant(),B=R>0?Math.min(Math.max(0,r),R-1):r;o.audioTrack=B,B!==r&&W.onResolve(B)},G=(R,r)=>{const B=W.getWant(),i=Array.isArray(o.audioTracks)?o.audioTracks.length:0;if(r.id!==B&&B>=0&&B<i){o.audioTrack!==B&&(o.audioTrack=B);return}W.onResolve(r.id)};return o.on(b.MANIFEST_PARSED,F),o.on(b.AUDIO_TRACK_SWITCHED,G),()=>{o.off(b.MANIFEST_PARSED,F),o.off(b.AUDIO_TRACK_SWITCHED,G)}}const Do=/\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 Oo(){try{if(Do.test(navigator.userAgent||""))return!0;const o=navigator.deviceMemory;if(typeof o=="number"&&o>0&&o<2)return!0}catch{}return!1}const Fo="_page_y9mr4_1",Vo="_header_y9mr4_7",jo="_pageTitle_y9mr4_11",Uo="_searchForm_y9mr4_21",Wo="_searchInput_y9mr4_27",zo="_searchBtn_y9mr4_42",Ho="_suggestions_y9mr4_58",Ko="_suggestionPill_y9mr4_65",qo="_statusMsg_y9mr4_81",Yo="_error_y9mr4_87",Go="_textOnly_y9mr4_91",Qo="_spinner_y9mr4_96",Xo="_spin_y9mr4_96",Zo="_sourceLoader_y9mr4_101",Jo="_ringSpinner_y9mr4_107",ea="_grid_y9mr4_125",ta="_skeletonCard_y9mr4_131",na="_skeletonThumb_y9mr4_136",ra="_skeletonLine_y9mr4_142",sa="_shimmer_y9mr4_149",oa="_backBtn_y9mr4_169",aa="_meta_y9mr4_187",ia="_headerActions_y9mr4_195",la="_watchlistBtn_y9mr4_202",ca="_active_y9mr4_220",da="_year_y9mr4_230",ua="_rating_y9mr4_235",ma="_typeBadge_y9mr4_244",ha="_tv_y9mr4_252",fa="_movie_y9mr4_257",ga="_tvSeries_y9mr4_262",pa="_tvMiniSeries_y9mr4_267",ba="_overview_y9mr4_272",va="_controls_y9mr4_279",ya="_controlLabel_y9mr4_287",_a="_select_y9mr4_297",Sa="_playerSection_y9mr4_308",Ta="_video_y9mr4_312",Ca="_videoHidden_y9mr4_334",ka="_delayCanvas_y9mr4_339",Ea="_delayCanvasActive_y9mr4_352",xa="_subtitleOverlay_y9mr4_356",Na="_videoIframe_y9mr4_375",Ia="_retryButton_y9mr4_383",Ba="_sidebarSeason_y9mr4_398",wa="_mobileSeasonRow_y9mr4_414",Aa="_sidebarPosterCard_y9mr4_428",Ma="_sidebarPosterMeta_y9mr4_443",La="_providerSelectWrap_y9mr4_460",Pa="_genreRow_y9mr4_472",Ra="_genreChip_y9mr4_479",$a="_metaRow_y9mr4_489",Da="_detailGrid_y9mr4_498",Oa="_detailItem_y9mr4_505",Fa="_imdbLink_y9mr4_527",p={page:Fo,header:Vo,pageTitle:jo,searchForm:Uo,searchInput:Wo,searchBtn:zo,suggestions:Ho,suggestionPill:Ko,statusMsg:qo,error:Yo,textOnly:Go,spinner:Qo,spin:Xo,sourceLoader:Zo,ringSpinner:Jo,grid:ea,skeletonCard:ta,skeletonThumb:na,skeletonLine:ra,shimmer:sa,backBtn:oa,meta:aa,headerActions:ia,watchlistBtn:la,active:ca,year:da,rating:ua,typeBadge:ma,tv:ha,movie:fa,tvSeries:ga,tvMiniSeries:pa,overview:ba,controls:va,controlLabel:ya,select:_a,playerSection:Sa,video:Ta,videoHidden:Ca,delayCanvas:ka,delayCanvasActive:Ea,subtitleOverlay:xa,videoIframe:Na,retryButton:Ia,sidebarSeason:Ba,mobileSeasonRow:wa,sidebarPosterCard:Aa,sidebarPosterMeta:Ma,providerSelectWrap:La,genreRow:Pa,genreChip:Ra,metaRow:$a,detailGrid:Da,detailItem:Oa,imdbLink:Fa},Va=[],ja=[];function hr({error:o,onRetry:b}){return t("div",{className:`${p.statusMsg} ${p.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:o}),t("button",{className:p.retryButton,onClick:b,children:"Retry"})]})})}const ei=()=>{const{id:o}=Gr(),[b]=Qr(),W=A(b);W.current=b;const F=Xr(),G=Zr(),R=b.get("type"),[r,B]=_(null),[i,te]=_(()=>parseInt(b.get("s")||"1",10)||1),[Q,$]=_([]),[f,K]=_(()=>parseInt(b.get("e")||"1",10)||1),[h,ze]=_(()=>{try{return localStorage.getItem("tvProvider")||""}catch{return""}}),[D,X]=_([]),[Pe,Re]=_(""),{options:He,isFallback:Ke,isLoading:Je}=Ps(),ae=Ee(()=>He.filter(e=>(e.kind??"tv")==="tv").map(e=>({id:e.value,label:e.label,tier:e.tier==="embed"?"embed":"direct",servers:e.servers})),[He]),q=Ke||ae.length===0?Va:ae,T=q.filter(e=>e.tier==="direct"),ne=q.filter(e=>e.tier==="embed"),[Te,Y]=_(!1),[Ce,M]=_(""),[$e,qe]=_([]),[pe,C]=_(0),[z,it]=_([]),[ie,De]=_(-1),[xe,Oe]=_(0),[lt,Vt]=_(""),[St,ue]=_(""),[be,Tt]=_(()=>{try{return localStorage.getItem("tvServer")||""}catch{return""}}),ct=Ee(()=>q.find(e=>e.id===h),[q,h]),L=ct?.tier==="embed",[dt,Ct]=_([]),[Fe,jt]=_(""),[ln,kt]=_(""),[Ut,le]=_(!1),u=Ee(()=>dt.length>0?dt:ct?.servers??[],[dt,ct]),ut=Ee(()=>Fe?["Embed",...u]:u,[u,Fe]),Z=Ut&&!!Fe,Et=Z?ln||Fe:"";v(()=>{if(!Fe){kt("");return}let e=!1;return fetch(`/api/resolve?url=${encodeURIComponent(Fe)}`).then(n=>n.json()).then(n=>{!e&&n.finalUrl&&kt(n.finalUrl)}).catch(()=>{}),()=>{e=!0}},[Fe]);const xt=A([]);v(()=>{xt.current=D},[D]);const mt=A(pe);v(()=>{mt.current=pe},[pe]);const Nt=A(ie);v(()=>{Nt.current=ie},[ie]);const y=cs({skipIntervals:ja}),c=y.refs.videoRef,re=A(null),ce=A([]),It=A(null),Bt=A(null),{videoDelayMs:w,videoDelayEnabled:J,setDelayEnabled:de,handleVideoDelayChange:wt,isCalibrating:cn,testClipActive:ke,stopCalibration:Ve,openAvSyncCalibrator:Fn,cancelAvSyncCalibrator:dn,applyAvSyncCalibrator:Wt,toggleTestClip:un,calibReturnRef:ve,effectiveVideoDelayMs:mn}=ds(c),[ht,gr]=_(()=>{try{const e=Number(localStorage.getItem("tvSubtitleDelayMs"));if(Number.isFinite(e)&&e>=-6e4&&e<=6e4)return Math.round(e)}catch{}return 0}),hn=A(ht);hn.current=ht;const pr=S(e=>{const n=Math.max(-6e4,Math.min(6e4,Math.round(e)));if(hn.current!==n){hn.current=n,gr(n);try{localStorage.setItem("tvSubtitleDelayMs",String(n))}catch{}}},[]);us({videoRef:c,canvasRef:It,delayMs:mn,enabled:J});const fn=J,ye=fn||ht!==0,{settings:gn,update:br}=ms(),pn=A(ye);pn.current=ye;const bn=S(()=>{if(!pn.current)return;const e=c.current;e&&Array.from(e.textTracks).forEach(n=>{n.mode!=="hidden"&&(n.mode="hidden")})},[c]),{hasConsent:At,grant:vr}=Jr(),Mt=A("");Mt.current||(Mt.current=`tv-${Date.now()}-${Math.random().toString(36).slice(2)}`);const g=R==="movie",zt=o?Rs(R||"tv",o):"",j=zt,Vn=$s(),Ht=Ds(),{toggle:jn,bookmarkedIds:yr,pending:_r}=Os(),{data:Un}=Fs(r?zt:void 0),Kt=Un?!!Un.inLibrary:zt?yr.has(zt):!1,Sr=S(()=>{!r||!o||jn({tmdbId:Number(o),mediaType:R||"tv",title:r.title,poster:r.poster,year:r.year,adult:r.adult})},[r,o,R,jn]),{data:et,isFetched:Wn,isPending:zn}=Vs(j||void 0,i,f),qt=Ee(()=>Q.map(e=>e.episode_number).sort((e,n)=>e-n),[Q]),tt=qt.indexOf(f),vn=tt>0?qt[tt-1]:null,x=tt>=0&&tt<qt.length-1?qt[tt+1]:null,Yt=Ee(()=>(r?.seasons??[]).map(e=>e.season_number).filter(e=>Number.isFinite(e)).sort((e,n)=>e-n),[r]),_e=Ee(()=>{if(g||x!=null)return null;const e=Yt.indexOf(i);return e>=0&&e<Yt.length-1?Yt[e+1]:(r?.number_of_seasons??0)>i?i+1:null},[g,x,Yt,i,r?.number_of_seasons]),Hn=et?.currentTime??0,Kn=et?.duration??0,yn=et?.completed===!0||et?.completed===1||Ln(Hn,Kn),[Ne,je]=_(!1),Ie=A(!1),_n=A(null),Lt=A(null);v(()=>{Ie.current=!1,Lt.current=null,je(!1)},[j,i,f]);const[Be,Gt]=_(!1),[ft,qn]=_(0),[nt,Yn]=_(!1),[Ye,rt]=_(!1),[Tr,Sn]=_(!1),[Cr,Gn]=_(""),[Qt,kr]=_(!1),[Er,Tn]=_(!1),{isTheaterMode:we,toggleTheaterMode:Cn,handleLayoutClick:xr}=hs();v(()=>{const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="t"&&Cn()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[Cn]),fs(y,(D.length>0||St!=="")&&!we&&!Be&&!Ne&&!Ye);const Nr=zs(),[gt,Ir]=_(gs),Br=S(e=>{Ir(e),ps(e)},[]),me=A(!1),st=A(null),kn=A(0),Qn=A(!1),Xn=A(0),se=A(null),Pt=A(""),wr=ur(Hn,Kn),Rt=!me.current&&!Ie.current&&(Be||Ne||Ye||yn||wr),pt=A(Rt);pt.current=Rt;const bt=A(!1);v(()=>{bt.current=nt},[nt]);const Ge=S((e,n)=>{if(!j||!n||n<30)return;const s=Ln(e,n),l=s?n:e;Math.abs(l-kn.current)<10&&!s||(kn.current=l,Vn.mutate({mediaId:j,season:i,episode:f,currentTime:Math.floor(l),duration:Math.floor(n),completed:s,title:r?.title??null,poster:r?.poster??null,backdrop:r?.backdrop??null,year:r?.year??null,overview:r?.overview??null,tmdbId:r?.id??null,mediaType:R||"tv",adult:r?.adult?1:0}))},[j,i,f,Vn,r,R]),Ae=S((e,n)=>{Ve();const s=new URLSearchParams(b);s.set("type",b.get("type")||"tv"),s.set("s",String(e)),s.set("e",String(n)),F(`${window.location.pathname}?${s.toString()}`)},[b,F,Ve]),$t=S(()=>{const e=c.current;if(!e||g||x==null){Sn(!1);return}const n=e.duration||0,s=e.currentTime||0;Sn(n>0&&s/n>=.8)},[g,x,c]),Xt=S((e,n)=>["tv-sources",h,g?"movie":"tv",o,e,n,be],[h,g,o,be]),Zt=S(async(e,n)=>{if(!r||!o||!h)return{valid:!1,sources:[]};const s=g?"movie":"tv",l=await _t.tv.sources.query({provider:h,type:s,tmdbId:String(o),season:e,episode:n,title:r.title||"",year:r.year||"",totalSeasons:String(r.number_of_seasons||1),imdbId:r.imdb_id||"",...u.length>0&&be?{server:be}:{}});return{valid:"valid"in l?l.valid:!1,error:"error"in l?l.error:void 0,sources:l.sources,referer:"referer"in l?l.referer:void 0,audioTracks:l.audioTracks,subtitles:"subtitles"in l?l.subtitles:void 0,servers:"servers"in l?l.servers:void 0,embedUrl:"embedUrl"in l?l.embedUrl:void 0}},[r,o,h,g,u,be]),Zn=S(()=>{if(g||!r||!o||!h||L||x==null)return;const e=Xt(i,x);G.getQueryState(e)?.status!=="success"&&G.prefetchQuery({queryKey:e,queryFn:()=>Zt(i,x),staleTime:300*1e3,gcTime:1800*1e3})},[g,r,o,h,L,x,i,G,Xt,Zt]),Ar=S(()=>{if(ke)return;$t();const e=c.current;!e||e.paused||e.ended||(e.duration>0&&e.duration-e.currentTime<=60&&Zn(),st.current&&clearTimeout(st.current),st.current=setTimeout(()=>{Ge(e.currentTime,e.duration||0)},5e3))},[Ge,c,ke,$t,Zn]),Mr=S(()=>{const e=c.current;if(!e||!r)return;st.current&&clearTimeout(st.current),Ge(e.currentTime,e.duration||0),Qn.current=!0;const n=bs({seekInduced:Date.now()-Xn.current<vs,autoplayEnabled:gt,hasNext:!g&&x!=null,isFinal:g||x==null});n==="advance"&&x!=null?(K(x),Ae(i,x)):n==="prompt-next"?(Ie.current=!1,me.current=!0,je(!0)):n==="prompt-complete"&&(Gn(g?r.title:`${r.title} — Season ${i}`),rt(!0),Ie.current=!0,me.current=!0)},[g,r,i,x,gt,Ge,Ae,c]),Lr=S(()=>{Qn.current=!1,y.actions.onPlay()},[y.actions]),Pr=S(()=>{y.actions.onPause();const e=c.current;e&&!e.ended&&Ge(e.currentTime,e.duration||0)},[y.actions,Ge,c]),Rr=S(()=>{y.actions.onLoadedMetadata();const e=c.current;if(e){try{const n=parseFloat(localStorage.getItem("playerVolume")||"");isNaN(n)||(e.volume=Math.max(0,Math.min(1,n))),e.muted=localStorage.getItem("playerMuted")==="true"}catch{}if(se.current!=null&&se.current>0){try{e.currentTime=se.current}catch{}se.current=null}$t()}},[y.actions,c,$t]),vt=S(()=>{const e=c.current;if(e&&se.current!=null&&se.current>0){try{e.currentTime=se.current}catch{}se.current=null}},[c]),$r=S(()=>{ft>0&&(se.current=ft);const e=c.current;if(e&&ft>0){try{e.currentTime=ft,se.current=null}catch{}e.play().catch(()=>{})}Gt(!1),me.current=!0},[ft,c]),Jn=S(()=>{se.current=null;const e=c.current;e&&(e.currentTime=0,e.play().catch(()=>{})),Gt(!1),me.current=!0},[c]),Dr=S(()=>{Ie.current=!0,je(!1),me.current=!0},[]),Or=S(()=>{Ie.current=!0,je(!1),me.current=!0,se.current=null;const e=c.current;if(e){try{e.currentTime=0}catch{}e.play().catch(()=>{})}},[c]),er=S(()=>{x!=null&&(Ie.current=!0,je(!1),me.current=!0,K(x),Ae(i,x))},[x,i,Ae]),tr=S(()=>{_e!=null&&(Ie.current=!0,je(!1),rt(!1),me.current=!0,te(_e),K(1),Ae(_e,1))},[_e,Ae]),Fr=S(async()=>{if(j)try{await Ht.mutateAsync({id:j,status:"Completed"}),rt(!1),je(!1),F("/")}catch{}},[j,Ht,F]);v(()=>{me.current=!1,_n.current=null,Gt(!1),Sn(!1),qn(0),Yn(!1),bt.current=!1,se.current=null,Pt.current=`${j}:${i}:${f}`,kn.current=0},[j,i,f]),v(()=>{Wn&&(Yn(!0),bt.current=!0)},[Wn,j,i,f]),v(()=>{if(!et||me.current)return;const e=`${j}:${i}:${f}`;if(_n.current===e)return;_n.current=e;const n=et,s=n.currentTime??0,l=n.duration??0;ur(s,l)&&(qn(s),Gt(!0))},[et,j,i,f]),v(()=>{if(!nt||me.current||Ie.current||Be||Ye||Ne)return;const e=`${j}:${i}:${f}`;if(Lt.current!==e){if(!yn){zn||(Lt.current=e);return}if(g){Lt.current=e,je(!0);return}if(!(!r||tt<0||Q.length===0)){if(Lt.current=e,x==null&&_e==null){r&&Q.length>0&&(Gn(`${r.title} — Season ${i}`),rt(!0),Ie.current=!0,me.current=!0);return}je(!0)}}},[nt,yn,zn,Be,Ye,Ne,g,x,_e,r,tt,Q.length,j,i,f]),v(()=>{(Be||Ne)&&c.current&&c.current.pause()},[Be,Ne,c]),v(()=>{const e=c.current;return()=>{st.current&&clearTimeout(st.current),e&&!e.ended&&Ge(e.currentTime,e.duration||0)}},[Ge,c]);const En=S(e=>{let n=null,s=!0;try{n=localStorage.getItem("tvLastSubtitle"),s=localStorage.getItem("tvSubtitlesEnabled")!=="false"}catch{}return Dn(e,{lastKey:n,enabled:s})},[]),xn=S(e=>{if(!(e<0))try{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e))}catch{}},[]),nr=S(e=>{if(e.length===0)return 0;let n=null;try{n=localStorage.getItem("tvLastAudio")}catch{}if(n){const s=e.findIndex(H=>Pn(H)===n);if(s>=0)return s;const l=n.indexOf("|||"),m=l>=0?n.slice(0,l):n,N=l>=0?n.slice(l+3):n,d=e.findIndex(H=>H.language===m||H.label===N);if(d>=0)return d}return Dn(e,{lastKey:null,enabled:!0})},[]),{data:rr}=js(j||void 0),sr=Ee(()=>(rr?.progress??[]).filter(n=>n.season===i&&(n.completed===!0||n.completed===1||Ln(n.currentTime,n.duration))).map(n=>String(n.episode)),[rr,i]),or=Ee(()=>Q.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})),[Q]),ar=Ee(()=>(r?.genres??[]).map(e=>e.name).slice(0,5),[r]),Nn=Ee(()=>[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(q.length!==0&&!q.some(e=>e.id===h)){const e=q.find(n=>n.tier==="direct")?.id??q[0].id;ze(e);try{localStorage.setItem("tvProvider",e)}catch{}}},[q,h]),v(()=>{Ct([]),jt(""),kt(""),le(!1)},[h]),v(()=>{if(u.length!==0&&!u.includes(be)){Tt(u[0]);try{localStorage.setItem("tvServer",u[0])}catch{}}},[u,be]),v(()=>{if(!o){B(null),X([]),Re(""),M(""),ue("");return}const e=Number(o),n=R||"tv";B(null),X([]),Re(""),M(""),ue("");const s=parseInt(W.current.get("s")||"",10),l=parseInt(W.current.get("e")||"",10);te(isNaN(s)?1:s),K(isNaN(l)?1:l),Oe(0),_t.tv.details.query({type:n,id:String(e)}).then(m=>{const N={id:m.id,title:m.title||"",overview:m.overview||"",vote_average:m.vote_average,year:m.year,poster:m.poster,backdrop:m.backdrop,imdb_id:m.imdb_id||void 0,adult:m.adult,seasons:m.seasons,number_of_seasons:m.number_of_seasons};B(N),N.seasons&&N.seasons.length>0&&isNaN(s)&&te(N.seasons[0].season_number)}).catch(()=>{})},[o,R]),v(()=>{if(!r||!o)return;if(!(r.seasons!==void 0||r.number_of_seasons!==void 0)){$([]);return}const n=parseInt(b.get("e")||"",10);_t.tv.episodes.query({id:String(o),season:String(i)}).then(s=>{const l=(s.episodes||[]).map(m=>({episode_number:m.episode_number,name:m.name||"",vote_average:m.vote_average,overview:m.overview||"",still_path:m.still_path||""}));$(l),l.length!==0&&K(m=>!isNaN(n)&&l.some(N=>N.episode_number===n)?n:l.some(N=>N.episode_number===m)?m:l[0].episode_number)}).catch(()=>{})},[r,o,i,b]),v(()=>{if(!L||!r||!o)return;fetch(`/api/tv/embed/${h}/${g?"movie":"tv"}/${o}?season=${i}&episode=${f}`).then(n=>n.json()).then(n=>{if(n.url)return ue(n.url),fetch(`/api/resolve?url=${encodeURIComponent(n.url)}`).then(s=>s.json()).then(s=>{s.finalUrl&&ue(s.finalUrl)})}).catch(()=>{})},[h,r,o,i,f,g,L]);const Jt=S(async()=>{if(!r||!o||!h||L||r.adult&&!At)return;const e=`${j}:${i}:${f}`;Y(!0),M(""),xt.current.length===0&&(X([]),Oe(0),qe([]),it([]));try{const n=await G.fetchQuery({queryKey:Xt(i,f),queryFn:()=>Zt(i,f),staleTime:3e5,gcTime:18e5});if(Pt.current!==e){Y(!1);return}if(Y(!1),!n.valid||!n.sources?.length){M(n.error?`${n.error}`:u.length>0?`No streams from ${be}. Try another server.`:"No streams available.");return}X(n.sources),Re(e),n.servers?.length&&Ct(n.servers),n.embedUrl&&jt(n.embedUrl),Oe(0),n.referer&&Vt(n.referer);const s=n.audioTracks||[];qe(s),C(s.length>0?nr(s):0);const l=n.subtitles||[];if(it(l),l.length>0){const d=En(l);De(d),xn(d)}else De(-1);const m=g?"movie":"tv",N=o;_t.tv.subtitles.query({type:m,tmdbId:String(N),season:String(i),episode:String(f)}).then(d=>{if(Pt.current!==e)return;const H=Array.isArray(d.subtitles)?d.subtitles:[];H.length!==0&&it(oe=>{const k=[...oe,...H.filter(ee=>!oe.some(he=>he.url===ee.url))];if(oe.length===0){const ee=En(k);De(ee),xn(ee)}return k})}).catch(()=>{}),M("")}catch{if(Pt.current!==e)return;Y(!1),M("Failed to load streams.")}},[r,o,h,i,f,g,L,At,u,be,En,xn,nr,j,G,Xt,Zt]),Vr=S(e=>{if(e==="Embed"){le(!0);return}le(!1),Tt(e);try{localStorage.setItem("tvServer",e)}catch{}M("")},[]),jr=S(e=>{ze(e);try{localStorage.setItem("tvProvider",e)}catch{}},[]);v(()=>{h&&r&&!L&&Jt()},[h,r,Jt,L]),v(()=>{if(!c.current)return;if(re.current&&(re.current.destroy(),re.current=null),L||Z){const d=c.current;d&&(d.pause(),d.removeAttribute("src"),d.load());return}let e=!1;if(ke){const d=c.current;return d&&(d.pause(),d.removeAttribute("src"),d.load(),d.src="/av-sync-test.mp4",pt.current||d.play().catch(()=>{})),()=>{e=!0}}if(Pt.current===`${j}:${i}:${f}`&&se.current==null&&!pt.current)try{const d=c.current;d&&!d.ended&&d.currentTime>1&&(se.current=d.currentTime)}catch{}const s=!Te&&Pe===`${j}:${i}:${f}`?Z?"":D[xe]?.url||"":"";if(!s){try{c.current?.pause(),c.current?.removeAttribute("src"),c.current?.load()}catch{}return}const l=c.current;l.pause(),l.removeAttribute("src"),l.load(),y.actions.resetMediaState();const m=`/api/tv/stream-proxy?url=${encodeURIComponent(s)}&referer=${encodeURIComponent(lt)}`;D[xe]?.type==="hls"?(async()=>{const d=await Us();if(!e)if(d&&d.isSupported()){const H=Oo()||document.body.classList.contains("low-end"),oe=H?60:180,k=new d({enableWorker:!0,lowLatencyMode:!1,maxBufferLength:oe,maxMaxBufferLength:oe+(H?30:60),backBufferLength:H?30:60,maxBufferSize:(H?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}}}});re.current=k,k.on(d.Events.ERROR,(I,E)=>{E.fatal&&(M(`Stream failed (${E.details}). Try another source or reload.`),Y(!1),k.destroy(),re.current=null)}),k.loadSource(m),k.attachMedia(l);const ee=()=>{let I=!1,E=0;try{I=localStorage.getItem("tvSubtitlesEnabled")==="true";const P=parseInt(localStorage.getItem("tvSelectedSubtitle")||"0",10);!isNaN(P)&&P>=0&&(E=P)}catch{}return{enabled:I,index:E}},he=()=>{if(typeof k.subtitleTrack!="number")return;if(ce.current.length>0){k.subtitleTrack=-1;return}const I=Array.isArray(k.subtitleTracks)?k.subtitleTracks:[];if(I.length===0){k.subtitleTrack=-1;return}const E=ee();if(E.enabled){const P=E.index<I.length?E.index:0;k.subtitleTrack=P,De(P),bn()}else k.subtitleTrack=-1};$o(k,d.Events,{getWant:()=>mt.current,onResolve:I=>C(I)}),k.on(d.Events.MANIFEST_PARSED,()=>{he(),ve.current!=null&&(l.currentTime=ve.current,ve.current=null),vt(),!pt.current&&bt.current&&l.play().catch(()=>{})}),k.on(d.Events.SUBTITLE_TRACKS_UPDATED,()=>{he()}),k.on(d.Events.SUBTITLE_TRACK_SWITCH,(I,E)=>{if(ce.current.length>0){if(E.id!==-1)try{k.subtitleTrack=-1}catch{}return}const P=Array.isArray(k.subtitleTracks)?k.subtitleTracks:[];if(P.length!==0){if(E.id===-1){const O=ee();if(O.enabled){const Ue=O.index<P.length?O.index:0;k.subtitleTrack=Ue;return}}De(E.id),bn()}})}else Ws(l)&&(l.src=m,ve.current!=null&&(l.currentTime=ve.current,ve.current=null),vt(),!pt.current&&bt.current&&l.play().catch(()=>{M("Failed to play stream. Try another source.")}))})():(l.src=m,ve.current!=null&&(l.currentTime=ve.current,ve.current=null),vt(),!pt.current&&bt.current&&l.play().catch(()=>{M("Failed to play stream. Try another source.")}));const N=()=>{const oe=l.error?.code===4?"Video source not supported or not found":"Failed to load video stream";M(`${oe}. The source may be invalid or expired. Try switching source or reloading.`),Y(!1)};return l.addEventListener("error",N),()=>{e=!0,l.removeEventListener("error",N)}},[D,Pe,Te,xe,h,lt,L,Z,c,ve,ke,j,i,f,vt,bn,y.actions]),v(()=>{if(!nt||Be||Ne||Ye||Rt||L||ke)return;const e=c.current;!e||!e.paused||e.ended||e.readyState<1||(vt(),e.play().catch(()=>{}))},[nt,Be,Ne,Ye,Rt,L,ke,vt,c]),v(()=>{const e=re.current;!e||typeof e.audioTrack!="number"||(e.audioTrack=pe)},[pe]),v(()=>{const e=re.current;!e||typeof e.subtitleTrack!="number"||!Array.isArray(e.subtitleTracks)||e.subtitleTracks.length===0||ce.current.length>0||(ie>=0?e.subtitleTrack=ie:e.subtitleTrack=-1)},[ie]),v(()=>{const e=c.current;if(!(!e||L)&&(e.querySelectorAll("track").forEach(n=>n.remove()),ce.current=[],z.length!==0&&(z.forEach(n=>{const s=document.createElement("track");s.kind="subtitles",s.label=n.label||n.language||"Unknown",s.srclang=n.language||n.label||"en";const l=`/api/subtitle-proxy?url=${encodeURIComponent(n.url)}&referer=${encodeURIComponent(lt)}`;s.src=l,s.addEventListener("load",()=>{const m=ce.current.indexOf(s),N=s.track;if(N&&m>=0){const d=m===Nt.current;N.mode=d&&!pn.current?"showing":"hidden"}}),e.appendChild(s),ce.current.push(s)}),z.length>0)))try{const n=re.current;n&&typeof n.subtitleTrack=="number"&&n.subtitleTrack!==-1&&(n.subtitleTrack=-1)}catch{}},[z,lt,L,h,c]),v(()=>{const e=c.current;if(!e||L)return;const n=re.current;ce.current.length>0&&n&&typeof n.subtitleTrack=="number"&&Array.isArray(n.subtitleTracks)&&n.subtitleTracks.length>0&&(n.subtitleTrack=-1);const s=()=>{const N=On(y.state.subtitleFontSize,e.clientHeight||720),d=Math.max(0,Math.min(100,100-y.state.subtitlePosition)),H=()=>{const I=N*16,E=e.videoHeight||e.clientHeight||720,P=e.videoWidth||e.clientWidth||1280;return{step:I*1.3/E*100,chars:Math.max(20,Math.floor(P/(I*.55)))}},oe=(I,E)=>{const P=I;P.snapToLines=!1,P.line=E},k=I=>{if(!I.cues)return;Array.from(I.cues).forEach(fe=>oe(fe,d));const E=Array.from(I.activeCues??[]);if(E.length<=1){E.forEach(fe=>oe(fe,d));return}const{step:P,chars:O}=H();let Ue=d;for(let fe=E.length-1;fe>=0;fe--){const Qe=String(E[fe].text??"").replace(/<[^>]*>/g,"").split(`
3
3
  `).reduce((nn,Ot)=>nn+Math.max(1,Math.ceil(Ot.length/O)),0);Ue=Math.max(0,Ue-Qe*P),oe(E[fe],Ue),Ue-=P*.4}},ee=ce.current;if(ee.length>0){ee.forEach((I,E)=>{const P=I.track;if(!P)return;const O=E===ie;P.mode=O&&!ye?"showing":"hidden",O&&!ye&&k(P)});return}const he=Array.from(e.textTracks);he.length!==0&&he.forEach((I,E)=>{const P=E===ie;I.mode=P&&!ye?"showing":"hidden",P&&!ye&&k(I)})};s();const l=()=>s();e.textTracks.addEventListener("addtrack",l),e.addEventListener("loadedmetadata",s,{once:!0});const m=window.setTimeout(s,600);return()=>{e.textTracks.removeEventListener("addtrack",l),e.removeEventListener("loadedmetadata",s),window.clearTimeout(m)}},[ie,z,L,h,c,ye,y.state.subtitleFontSize,y.state.subtitlePosition]),v(()=>{if(!ye)return;const e=c.current,n=Bt.current;if(!e||!n)return;const s=ht/1e3,l=mn/1e3,m=new Set;let N=[],d=-1,H=-1,oe=-1,k=-1,ee=0,he=0,I=!1;const E=()=>{const U=Nt.current;if(U<0)return null;const Xe=ce.current;return Xe.length>0?Xe[U]?.track??null:Array.from(e.textTracks)[U]??null},P=(U,Xe)=>{const ge=U.cues;if(!ge||ge.length===0)return Array.from(U.activeCues??[]);let ot=0,at=ge.length;for(;ot<at;){const Me=ot+at>>>1;ge[Me].endTime+s<Xe?ot=Me+1:at=Me}const Ft=[];for(let Me=ot;Me<ge.length;Me++){const rn=ge[Me];if(rn.startTime+s>Xe)break;rn.endTime+s>=Xe&&Ft.push(rn)}return Ft},O=()=>{const U=E(),Xe=e.currentTime-l,ge=U?P(U,Xe):[],ot=e.clientWidth,at=e.clientHeight,Ft=e.videoWidth,Me=e.videoHeight;if(ge.length===N.length&&ge.every((Bn,wn)=>Bn===N[wn])&&ot===d&&at===H&&Ft===oe&&Me===k||(N=ge,d=ot,H=at,oe=Ft,k=Me,n.textContent="",ge.length===0))return;const cr={fontSize:On(y.state.subtitleFontSize,at),position:y.state.subtitlePosition,bgOpacity:y.state.subtitleBgOpacity,bgColor:y.state.subtitleBgColor,textColor:y.state.subtitleTextColor,edge:y.state.subtitleEdge,bold:y.state.subtitleBold},Hr=ys(cr),Kr=_s(e,cr.position);ge.forEach((Bn,wn)=>{const dr=String(Bn.text??"");if(!Ss(dr).trim())return;const An=document.createElement("div"),qr=(ge.length-1-wn)*1.7;An.style.cssText=`${Hr}
4
4
  bottom: calc(${Kr}px + ${qr}em);`,An.innerHTML=Ts(dr),n.appendChild(An)})},Ue=()=>{Array.from(e.textTracks).forEach(U=>{m.has(U)||(m.add(U),U.addEventListener("cuechange",O))})},fe=()=>{Ue(),O()},In=()=>{if(I||he)return;const U=()=>{he=0,!(I||e.paused||e.ended)&&(O(),In())};he=window.requestAnimationFrame(U)},Qe=e,nn=()=>{ee=0,O(),!I&&Qe.requestVideoFrameCallback&&(ee=Qe.requestVideoFrameCallback(nn))},Ot=()=>{O(),Qe.requestVideoFrameCallback?ee||(ee=Qe.requestVideoFrameCallback(nn)):In()};Ue(),e.textTracks.addEventListener("addtrack",fe),e.textTracks.addEventListener("removetrack",fe),e.addEventListener("timeupdate",O),e.addEventListener("seeked",O),e.addEventListener("loadedmetadata",O),e.addEventListener("play",Ot);const ir=Array.from(e.querySelectorAll("track"));ir.forEach(U=>U.addEventListener("load",O));const lr=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>O());return lr?.observe(e),O(),Ot(),()=>{I=!0,m.forEach(U=>U.removeEventListener("cuechange",O)),e.textTracks.removeEventListener("addtrack",fe),e.textTracks.removeEventListener("removetrack",fe),e.removeEventListener("timeupdate",O),e.removeEventListener("seeked",O),e.removeEventListener("loadedmetadata",O),e.removeEventListener("play",Ot),ir.forEach(U=>U.removeEventListener("load",O)),lr?.disconnect(),he&&window.cancelAnimationFrame(he),ee&&Qe.cancelVideoFrameCallback&&Qe.cancelVideoFrameCallback(ee),n.textContent=""}},[ye,ht,ie,z,mn,c,y.state.subtitleFontSize,y.state.subtitlePosition,y.state.subtitleBgOpacity,y.state.subtitleBgColor,y.state.subtitleTextColor,y.state.subtitleEdge,y.state.subtitleBold]);const en=()=>{B(null),X([]),ue(""),F(-1)},Ur=S(e=>{te(e),K(1),Ae(e,1)},[Ae]),tn=!g&&r?.seasons&&r.seasons.length>1?t("label",{className:p.sidebarSeason,children:[t("span",{children:"Season"}),t("select",{value:i,onChange:e=>Ur(parseInt(e.target.value,10)||1),className:p.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,yt=S(e=>{const n=parseInt(e,10);if(!isNaN(n)){try{c.current?.pause()}catch{}K(n),Ae(i,n)}Tn(!1)},[i,Ae,c]);v(()=>{if(g)return;const e=n=>{n.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||n.key.toLowerCase()==="n"&&(x!=null?yt(String(x)):es.error("No next episode available"))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[g,x,yt]);const Wr=e=>{C(e);try{const s=$e[e];s&&localStorage.setItem("tvLastAudio",Pn(s))}catch{}const n=re.current;n&&n.audioTrack!==void 0&&(n.audioTrack=e)},zr=e=>{De(e);try{if(e===-1)localStorage.setItem("tvSubtitlesEnabled","false");else{localStorage.setItem("tvSubtitlesEnabled","true"),localStorage.setItem("tvSelectedSubtitle",String(e));const m=z[e];m&&localStorage.setItem("tvLastSubtitle",Pn(m))}}catch{}const n=c.current,s=re.current;if(s&&typeof s.subtitleTrack=="number"&&Array.isArray(s.subtitleTracks)&&s.subtitleTracks.length>0&&(s.subtitleTrack=ce.current.length>0||e<0?-1:e),!n)return;const l=ce.current;if(l.length>0){l.forEach((m,N)=>{const d=m.track;if(!d)return;const H=N===e;d.mode=H&&!ye?"showing":"hidden"});return}Array.from(n.textTracks).forEach((m,N)=>{const d=N===e;m.mode=d&&!ye?"showing":"hidden"})},Dt=S(()=>{if(!r)return;const e=c.current,n=g?"":`S${String(i).padStart(2,"0")}E${String(f).padStart(2,"0")}`;_t.discord.tvPresence.mutate({title:r.title,episodeLabel:n,isPlaying:e?!e.paused&&!e.ended:!0,thumbnail:r.poster,currentTime:e?e.currentTime:0,duration:e&&e.duration||0,isAdult:r.adult===!0,sessionId:Mt.current}).catch(()=>{}),_t.discord.heartbeat.mutate({sessionId:Mt.current}).catch(()=>{})},[r,g,i,f,c]);return v(()=>{if(!r)return;Dt();const e=window.setInterval(()=>{const n=c.current;(!n||!n.paused)&&Dt()},15e3);return()=>window.clearInterval(e)},[Dt,r,c]),v(()=>{if(!r||L||Te||Ce||D.length===0)return;const e=c.current;if(!e)return;const n=()=>Dt();return e.addEventListener("play",n),e.addEventListener("pause",n),e.addEventListener("seeked",n),()=>{e.removeEventListener("play",n),e.removeEventListener("pause",n),e.removeEventListener("seeked",n)}},[r,L,Te,Ce,D,Dt,c]),v(()=>{const e=Mt.current,n=()=>ts(e),s=()=>n();return window.addEventListener("pagehide",s),window.addEventListener("beforeunload",s),()=>{window.removeEventListener("pagehide",s),window.removeEventListener("beforeunload",s),n()}},[]),v(()=>{if(!r){document.title="TV & Movies - dango";return}document.title=g?`${r.title} - dango`:`${r.title} - Season ${i} Episode ${f} - dango`},[r,g,i,f]),v(()=>{if(!r||g)return;const e=new URLSearchParams(b),n=e.get("s"),s=e.get("e"),l=String(i),m=String(f);n===l&&s===m||(e.set("type",b.get("type")||"tv"),e.set("s",l),e.set("e",m),F(`${window.location.pathname}?${e.toString()}`,{replace:!0}))},[r,g,i,f,b,F]),t("div",{className:`${Ze.playerPageLayout} ${we?Ze.theaterMode:""}`,onClick:xr,children:[we&&t(Cs,{videoRef:c,active:gn.enabled&&!L&&D.length>0&&!Ce&&!(r?.adult&&!At),settings:gn}),!we&&t("aside",{className:Ze.episodeSidebar,children:r?g?t("div",{className:p.sidebarPosterCard,children:[r.poster&&t("img",{src:`https://image.tmdb.org/t/p/w342${r.poster}`,alt:r.title,loading:"lazy",decoding:"async"}),t("div",{className:p.sidebarPosterMeta,children:[t("strong",{children:r.title}),t("span",{children:r.year})]})]}):t(ks,{episodes:or,currentEpisode:String(f),watchedEpisodes:sr,onEpisodeClick:yt,header:tn}):g?t("div",{className:p.statusMsg,children:[t(V,{name:"spinner",className:p.spinner})," Loading..."]}):t(Es,{variant:"sidebar"})}),t("div",{className:Ze.playerMain,children:[r&&t("div",{className:p.playerSection,onContextMenu:e=>e.preventDefault(),style:r.adult&&!At?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:L&&St?t("iframe",{src:St,className:p.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!L&&Et?t("iframe",{src:Et,className:p.videoIframe,allow:"autoplay; fullscreen",allowFullScreen:!0}):!L&&(D.length>0||Te)?t(Le,{children:[Ce&&t(hr,{error:Ce,onRetry:Jt}),t(Lo,{player:y,title:r.title,episodeLabel:g?void 0:`S${i} E${f}`,audioTracks:$e,selectedAudioTrack:pe,onAudioTrackChange:Wr,subtitles:z,selectedSubtitle:ie,onSubtitleChange:zr,streams:D,resolutionIdx:xe,onResolutionChange:Oe,onBack:en,videoDelayEnabled:J,onVideoDelayToggle:de,videoDelayMs:w,onVideoDelayChange:wt,onCalibrateAvSync:Fn,subtitleDelayMs:ht,onSubtitleDelayChange:pr,showNextEpisodeButton:Tr&&!Be&&!Ne&&!Ye,onNextEpisode:er,isLoading:Te,isTheaterMode:we,onTheaterModeToggle:Cn,ambientSettings:gn,onAmbientChange:br,children:[t("video",{ref:c,autoPlay:nt&&!Rt,playsInline:!0,disablePictureInPicture:!0,className:`${p.video} ${fn?p.videoHidden:""}`,onTimeUpdate:Ar,onEnded:()=>{ke||Mr()},onPlay:Lr,onPause:Pr,onSeeked:()=>{Xn.current=Date.now(),$t()},onLoadedMetadata:Rr,onVolumeChange:y.actions.onVolumeChange,onWaiting:y.actions.onWaiting,onPlaying:y.actions.onPlaying,onCanPlay:y.actions.onCanPlay,onContextMenu:e=>e.preventDefault(),onError:()=>{M("Video failed to load. Try another server or reload."),Y(!1)}}),t("canvas",{ref:It,className:`${p.delayCanvas} ${fn?p.delayCanvasActive:""}`}),ye&&t("div",{ref:Bt,className:p.subtitleOverlay}),t(xs,{isOpen:cn,ms:w,onChange:wt,onApply:Wt,onClose:dn,testClipActive:ke,onTestClip:un})]})]}):Ce&&!L?t(hr,{error:Ce,onRetry:Jt}):null}),!we&&r&&t(Ns,{}),!we&&tn&&t("div",{className:p.mobileSeasonRow,children:tn}),!we&&r&&t("div",{className:p.providerSelectWrap,children:t("label",{className:p.controlLabel,children:["Source",t("select",{value:h,onChange:e=>jr(e.target.value),className:p.select,disabled:q.length===0,children:Je?t("option",{value:"",children:"Loading..."}):q.length===0?t("option",{value:"",children:"No providers available"}):t(Le,{children:[T.length>0&&t("optgroup",{label:"Direct HLS",children:T.map(e=>t("option",{value:e.id,children:e.label},e.id))}),ne.length>0&&t("optgroup",{label:"Embeds",children:ne.map(e=>t("option",{value:e.id,children:e.label},e.id))})]})})]})}),!we&&r&&!L&&(Te?t("div",{className:p.sourceLoader,children:t("div",{className:p.ringSpinner})}):t(Ro,{servers:ut,selectedServer:Ut?"Embed":be,onServerSelect:Vr})),!we&&r&&t("div",{className:Ze.playerInfoContainer,children:[t("div",{className:Ze.playerInfoHeader,children:[t("div",{className:Ze.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:Ze.videoTitleSection,children:[t("div",{className:Se.titleContainer,children:[t("h1",{children:r.title}),t("div",{className:p.meta,children:[t("span",{className:p.year,children:r.year}),r.vote_average!=null&&r.vote_average>0&&t("span",{className:p.rating,children:[t(V,{name:"star",size:12}),Number(r.vote_average).toFixed(1)]}),t("span",{className:`${p.typeBadge} ${p[g?"movie":"tv"]}`,children:g?"Movie":"TV Show"})]}),ar.length>0&&t("div",{className:p.genreRow,children:ar.map(e=>t("span",{className:p.genreChip,children:e},e))}),Nn.length>0&&t("div",{className:p.metaRow,children:Nn.map((e,n)=>t("span",{children:[e,n<Nn.length-1?" · ":""]},`${e}-${n}`))})]}),t("div",{className:Se.controls,children:[t("button",{className:`${Se.watchlistBtn} ${Kt?Se.inList:""}`,onClick:Sr,disabled:_r,type:"button",children:[Kt?t(V,{name:"check",size:14}):t(V,{name:"plus",size:14}),Kt?"In Watchlist":"Add to Watchlist"]}),!g&&t(Le,{children:[t("button",{className:`${Se.watchlistBtn}`,onClick:()=>vn!=null&&yt(String(vn)),disabled:vn==null,type:"button",children:[t(V,{name:"chevron-left",size:14}),"Prev EP"]}),t("button",{className:`${Se.watchlistBtn}`,onClick:()=>x!=null&&yt(String(x)),disabled:x==null,type:"button",children:["Next EP",t(V,{name:"chevron-right",size:14})]}),!g&&t("button",{className:`${Se.watchlistBtn} ${Se.modeToggleBtn} ${gt?Se.modeToggleActive:""}`,onClick:()=>Br(!gt),type:"button","aria-pressed":gt,children:gt?"AUTOPLAY: ON":"AUTOPLAY: OFF"}),Nr&&t("button",{className:`${Se.watchlistBtn}`,onClick:()=>Tn(!0),type:"button",children:[t(V,{name:"list-ul",size:14}),"Episodes"]})]})]})]})]}),t("div",{className:Se.descriptionSection,children:[t("h3",{children:"Synopsis"}),t(Hs,{text:r.overview,emptyText:"No description available."})]}),t("button",{className:Se.detailsToggleBtn,onClick:()=>kr(!Qt),type:"button",children:[Qt?t(V,{name:"chevron-up"}):t(V,{name:"chevron-down"}),Qt?"Hide Details":"Show Details"]}),Qt&&t("div",{className:p.detailGrid,children:[r.first_air_date&&t("div",{className:p.detailItem,children:[t("strong",{children:g?"Release Date":"First Air Date"}),t("span",{children:r.first_air_date})]}),r.last_air_date&&t("div",{className:p.detailItem,children:[t("strong",{children:"Last Air Date"}),t("span",{children:r.last_air_date})]}),r.networks&&r.networks.length>0&&t("div",{className:p.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:p.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:p.detailItem,children:[t("strong",{children:"Episode Runtime"}),t("span",{children:[r.episode_run_time[0]," min"]})]}),r.imdb_id&&t("div",{className:p.detailItem,children:[t("strong",{children:"IMDb"}),t("a",{href:`https://www.imdb.com/title/${r.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:p.imdbLink,children:"View on IMDb"})]})]})]}),!g&&t(Is,{isOpen:Er,onClose:()=>Tn(!1),episodes:or,currentEpisode:String(f),watchedEpisodes:sr,onEpisodeClick:yt,header:tn}),r?.adult&&!At&&t(Mn,{isOpen:!0,title:"Content Warning",onClose:en,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(We,{variant:"secondary",onClick:en,children:"Go Back"}),t(We,{onClick:vr,children:"I'm 18+, Continue"})]})]})}),t(Bs,{isOpen:Be,onClose:Jn,title:"Resume Watching",message:t(Le,{children:["You were at ",t("strong",{children:an(ft)})]}),restartLabel:"Start from Beginning",onResume:$r,onRestart:Jn}),t(Mn,{isOpen:Ne,onClose:Dr,title:g?"Movie Completed":"Episode Completed",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:g?t(Le,{children:"You've already watched this movie."}):t(Le,{children:["You've already watched"," ",t("strong",{children:["Season ",i," Episode ",f]}),". Would you like to continue?"]})}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(We,{variant:"secondary",onClick:Or,children:"Replay"}),x!=null?t(We,{onClick:er,children:["Watch EP ",x]}):_e!=null?t(We,{onClick:tr,children:["Start Season ",_e]}):null]})]})}),t(Mn,{isOpen:Ye,onClose:()=>rt(!1),title:g?"Movie Completed!":_e!=null?"Season Complete!":"Show Completed!",children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t(V,{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:g?"You finished this movie!":_e!=null?`You finished Season ${i}.`:"Congratulations! You finished all available episodes."}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center",flexWrap:"wrap"},children:[t(We,{variant:"secondary",onClick:()=>rt(!1),children:"Close"}),_e!=null?t(We,{onClick:tr,children:["Start Season ",_e]}):t(Le,{children:[t(We,{onClick:()=>{rt(!1),en()},children:"Back to Details"}),Kt&&t(We,{onClick:Fr,disabled:Ht.isPending,children:Ht.isPending?"Saving...":"Move to Completed"})]})]})]})}),!r&&t("div",{className:p.statusMsg,children:[t(V,{name:"spinner",className:p.spinner})," Loading..."]})]})]})};export{ei as default};
@@ -1 +1 @@
1
- import{o as R,a as q,p as E,d as l,h as C,T,u as e,g as F}from"./vendor-core-DfaOB3Rn.js";import{I as a}from"./vendor-icons-DrybRNxP.js";import{e as j,t as U,B as w}from"./index-_iy8RyKU.js";import{n as H,d as J,e as K,f as Q,t as I}from"./useTvLibrary-BuMreQuF.js";import"./vendor-query-BBT5_sHx.js";const X="_container_198yg_1",Y="_heroSection_198yg_11",Z="_bannerContainer_198yg_17",ee="_banner_198yg_17",ne="_bannerOverlay_198yg_37",te="_heroContent_198yg_49",se="_posterContainer_198yg_62",ae="_poster_198yg_62",oe="_infoGlass_198yg_86",ie="_title_198yg_100",re="_quickMeta_198yg_110",le="_metaItem_198yg_118",ce="_iconStar_198yg_126",de="_iconTv_198yg_130",me="_iconType_198yg_134",_e="_genres_198yg_139",he="_genre_198yg_139",ge="_metaRow_198yg_156",ve="_metaValue_198yg_164",pe="_metaDivider_198yg_168",ye="_synopsisSection_198yg_173",ue="_sectionTitleSmall_198yg_179",ke="_synopsis_198yg_173",be="_actions_198yg_196",Ne="_watchBtn_198yg_202",Se="_watchlistBtn_198yg_226",fe="_active_198yg_250",Ce="_seasonPickerLabel_198yg_256",Te="_seasonSelect_198yg_267",we="_detailsToggleBtn_198yg_286",Ie="_expandedContent_198yg_304",Be="_detailGrid_198yg_309",De="_detailItem_198yg_315",Me="_imdbLink_198yg_333",Le="_heroSkeleton_198yg_343",Pe="_skeletonBanner_198yg_347",$e="_skeletonContent_198yg_354",Ge="_skeletonPoster_198yg_365",xe="_skeletonInfo_198yg_373",Oe="_skeletonTitle_198yg_380",Ae="_skeletonMeta_198yg_388",Ve="_skeletonDesc_198yg_396",We="_skeletonActions_198yg_404",ze="_errorState_198yg_413",Re="_matureOverlay_198yg_434",qe="_matureContent_198yg_444",n={container:X,heroSection:Y,bannerContainer:Z,banner:ee,bannerOverlay:ne,heroContent:te,posterContainer:se,poster:ae,infoGlass:oe,title:ie,quickMeta:re,metaItem:le,iconStar:ce,iconTv:de,iconType:me,genres:_e,genre:he,metaRow:ge,metaValue:ve,metaDivider:pe,synopsisSection:ye,sectionTitleSmall:ue,synopsis:ke,actions:be,watchBtn:Ne,watchlistBtn:Se,active:fe,seasonPickerLabel:Ce,seasonSelect:Te,detailsToggleBtn:we,expandedContent:Ie,detailGrid:Be,detailItem:De,imdbLink:Me,heroSkeleton:Le,skeletonBanner:Pe,skeletonContent:$e,skeletonPoster:Ge,skeletonInfo:xe,skeletonTitle:Oe,skeletonMeta:Ae,skeletonDesc:Ve,skeletonActions:We,errorState:ze,matureOverlay:Re,matureContent:qe};function Je(){const{id:o}=R(),c=q(),[B]=E(),i=H(B.get("type")),{hasConsent:D}=j(),[t,M]=l(null),[L,_]=l(!0),[y,u]=l(""),[d,P]=l(!1),[h,$]=l(1),G=J(i,o),x=Number(o),{data:O}=K(t?G:void 0),g=!!O?.inLibrary,{toggle:A}=Q();C(()=>{o&&(_(!0),u(""),U.tv.details.query({type:i,id:String(o)}).then(s=>{const m={id:s.id,title:s.title||"",overview:s.overview||"",vote_average:s.vote_average,year:s.year,poster:s.poster,backdrop:s.backdrop,imdb_id:s.imdb_id||void 0,adult:s.adult,seasons:s.seasons?.map(z=>({...z,name:""})),number_of_seasons:s.number_of_seasons};M(m),_(!1)}).catch(s=>{u(s.message),_(!1)}))},[o,i]),C(()=>{document.title=t?.title?`${t.title} - dango`:"TV & Movies - dango"},[t?.title]);const V=()=>{!o||!t||c(r?I(i,o):I(i,o,h,1))},W=()=>{t&&A({tmdbId:x,mediaType:i,title:t.title,poster:t.poster,year:t.year,adult:t.adult})},r=i==="movie",v=!r,k=t?.backdrop?`https://image.tmdb.org/t/p/w1280${t.backdrop}`:"",b=t?.poster?`https://image.tmdb.org/t/p/w500${t.poster}`:"",N=T(()=>t?.genres?t.genres.map(s=>s.name).slice(0,5):[],[t?.genres]),S=T(()=>t?.seasons?t.seasons.filter(s=>s.season_number>0):[],[t?.seasons]),p=[t?.year,t?.status,v&&t?.number_of_seasons?`${t.number_of_seasons} Season${t.number_of_seasons>1?"s":""}`:null,v&&t?.number_of_episodes?`${t.number_of_episodes} Episodes`:null].filter(Boolean);if(L)return e("div",{className:n.container,children:e("div",{className:n.heroSkeleton,children:[e("div",{className:n.skeletonBanner}),e("div",{className:n.skeletonContent,children:[e("div",{className:n.skeletonPoster}),e("div",{className:n.skeletonInfo,children:[e("div",{className:n.skeletonTitle}),e("div",{className:n.skeletonMeta}),e("div",{className:n.skeletonDesc}),e("div",{className:n.skeletonActions})]})]})]})});if(y||!t)return e("div",{className:n.container,children:e("div",{className:n.errorState,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Failed to load details"}),e("p",{children:y||"Something went wrong"}),e(w,{onClick:()=>c(-1),children:"Go Back"})]})});const f=t.adult&&!D;return e("div",{className:n.container,style:f?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:[e("div",{className:n.heroSection,children:[e("div",{className:n.bannerContainer,children:[k&&e("div",{className:n.banner,style:{backgroundImage:`url(${k})`}}),e("div",{className:n.bannerOverlay})]}),e("div",{className:n.heroContent,children:[e("div",{className:n.posterContainer,children:b&&e("img",{src:b,alt:t.title,className:n.poster,decoding:"async"})}),e("div",{className:n.infoGlass,children:[e("div",{className:n.topInfo,children:[e("h1",{className:n.title,children:t.title}),e("div",{className:n.quickMeta,children:[t.vote_average!=null&&t.vote_average>0&&e("div",{className:n.metaItem,children:[e(a,{name:"star",className:n.iconStar}),e("span",{children:Number(t.vote_average).toFixed(1)})]}),e("div",{className:n.metaItem,children:[e(a,{name:"tv",className:n.iconTv}),e("span",{children:r?"Movie":"TV Show"})]}),t.vote_count!=null&&e("div",{className:n.metaItem,children:[e(a,{name:"users",className:n.iconType}),e("span",{children:[t.vote_count.toLocaleString()," votes"]})]})]}),N.length>0&&e("div",{className:n.genres,children:N.map(s=>e("span",{className:n.genre,children:s},s))})]}),p.length>0&&e("div",{className:n.metaRow,children:p.map((s,m)=>e(F.Fragment,{children:[e("span",{className:n.metaValue,children:s}),m<p.length-1&&e("span",{className:n.metaDivider,children:"·"})]},m))}),t.overview&&e("div",{className:n.synopsisSection,children:[e("h2",{className:n.sectionTitleSmall,children:"Synopsis"}),e("p",{className:n.synopsis,children:t.overview})]}),e("div",{className:n.actions,children:[e("button",{className:n.watchBtn,onClick:V,children:[e(a,{name:"play",size:14}),r?"Watch Now":`Start S${h}`]}),e("button",{className:`${n.watchlistBtn} ${g?n.active:""}`,onClick:W,children:[g?e(a,{name:"check",size:14}):e(a,{name:"plus",size:14}),g?"In Watchlist":"Add to Watchlist"]})]}),v&&S.length>1&&e("label",{className:n.seasonPickerLabel,children:[e("span",{children:"Season"}),e("select",{value:h,onChange:s=>$(parseInt(s.target.value,10)||1),className:n.seasonSelect,children:S.map(s=>e("option",{value:s.season_number,children:["Season ",s.season_number," (",s.episode_count," Episodes)"]},s.season_number))})]}),e("button",{className:n.detailsToggleBtn,onClick:()=>P(!d),children:[d?e(a,{name:"chevron-up"}):e(a,{name:"chevron-down"}),d?"Hide Details":"Show Details"]}),d&&e("div",{className:n.expandedContent,children:e("div",{className:n.detailGrid,children:[t.first_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:r?"Release Date":"First Air Date"}),e("span",{children:t.first_air_date})]}),t.last_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:"Last Air Date"}),e("span",{children:t.last_air_date})]}),t.networks&&t.networks.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Networks"}),e("span",{children:t.networks.map(s=>s.name).join(", ")})]}),t.created_by&&t.created_by.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Created By"}),e("span",{children:t.created_by.map(s=>s.name).join(", ")})]}),t.episode_run_time&&t.episode_run_time.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Episode Runtime"}),e("span",{children:[t.episode_run_time[0]," min"]})]}),t.imdb_id&&e("div",{className:n.detailItem,children:[e("strong",{children:"IMDb"}),e("a",{href:`https://www.imdb.com/title/${t.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:n.imdbLink,children:"View on IMDb"})]})]})})]})]})]}),f&&e("div",{className:n.matureOverlay,children:e("div",{className:n.matureContent,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Content Warning"}),e("p",{children:"This content may contain mature themes."}),e(w,{onClick:()=>c("/"),children:"Go Back"})]})})]})}export{Je as default};
1
+ import{o as R,a as q,p as E,d as l,h as C,T,u as e,g as F}from"./vendor-core-DfaOB3Rn.js";import{I as a}from"./vendor-icons-DrybRNxP.js";import{e as j,t as U,B as w}from"./index-CfgPGaUO.js";import{n as H,d as J,e as K,f as Q,t as I}from"./useTvLibrary-CL3kMD_c.js";import"./vendor-query-BBT5_sHx.js";const X="_container_198yg_1",Y="_heroSection_198yg_11",Z="_bannerContainer_198yg_17",ee="_banner_198yg_17",ne="_bannerOverlay_198yg_37",te="_heroContent_198yg_49",se="_posterContainer_198yg_62",ae="_poster_198yg_62",oe="_infoGlass_198yg_86",ie="_title_198yg_100",re="_quickMeta_198yg_110",le="_metaItem_198yg_118",ce="_iconStar_198yg_126",de="_iconTv_198yg_130",me="_iconType_198yg_134",_e="_genres_198yg_139",he="_genre_198yg_139",ge="_metaRow_198yg_156",ve="_metaValue_198yg_164",pe="_metaDivider_198yg_168",ye="_synopsisSection_198yg_173",ue="_sectionTitleSmall_198yg_179",ke="_synopsis_198yg_173",be="_actions_198yg_196",Ne="_watchBtn_198yg_202",Se="_watchlistBtn_198yg_226",fe="_active_198yg_250",Ce="_seasonPickerLabel_198yg_256",Te="_seasonSelect_198yg_267",we="_detailsToggleBtn_198yg_286",Ie="_expandedContent_198yg_304",Be="_detailGrid_198yg_309",De="_detailItem_198yg_315",Me="_imdbLink_198yg_333",Le="_heroSkeleton_198yg_343",Pe="_skeletonBanner_198yg_347",$e="_skeletonContent_198yg_354",Ge="_skeletonPoster_198yg_365",xe="_skeletonInfo_198yg_373",Oe="_skeletonTitle_198yg_380",Ae="_skeletonMeta_198yg_388",Ve="_skeletonDesc_198yg_396",We="_skeletonActions_198yg_404",ze="_errorState_198yg_413",Re="_matureOverlay_198yg_434",qe="_matureContent_198yg_444",n={container:X,heroSection:Y,bannerContainer:Z,banner:ee,bannerOverlay:ne,heroContent:te,posterContainer:se,poster:ae,infoGlass:oe,title:ie,quickMeta:re,metaItem:le,iconStar:ce,iconTv:de,iconType:me,genres:_e,genre:he,metaRow:ge,metaValue:ve,metaDivider:pe,synopsisSection:ye,sectionTitleSmall:ue,synopsis:ke,actions:be,watchBtn:Ne,watchlistBtn:Se,active:fe,seasonPickerLabel:Ce,seasonSelect:Te,detailsToggleBtn:we,expandedContent:Ie,detailGrid:Be,detailItem:De,imdbLink:Me,heroSkeleton:Le,skeletonBanner:Pe,skeletonContent:$e,skeletonPoster:Ge,skeletonInfo:xe,skeletonTitle:Oe,skeletonMeta:Ae,skeletonDesc:Ve,skeletonActions:We,errorState:ze,matureOverlay:Re,matureContent:qe};function Je(){const{id:o}=R(),c=q(),[B]=E(),i=H(B.get("type")),{hasConsent:D}=j(),[t,M]=l(null),[L,_]=l(!0),[y,u]=l(""),[d,P]=l(!1),[h,$]=l(1),G=J(i,o),x=Number(o),{data:O}=K(t?G:void 0),g=!!O?.inLibrary,{toggle:A}=Q();C(()=>{o&&(_(!0),u(""),U.tv.details.query({type:i,id:String(o)}).then(s=>{const m={id:s.id,title:s.title||"",overview:s.overview||"",vote_average:s.vote_average,year:s.year,poster:s.poster,backdrop:s.backdrop,imdb_id:s.imdb_id||void 0,adult:s.adult,seasons:s.seasons?.map(z=>({...z,name:""})),number_of_seasons:s.number_of_seasons};M(m),_(!1)}).catch(s=>{u(s.message),_(!1)}))},[o,i]),C(()=>{document.title=t?.title?`${t.title} - dango`:"TV & Movies - dango"},[t?.title]);const V=()=>{!o||!t||c(r?I(i,o):I(i,o,h,1))},W=()=>{t&&A({tmdbId:x,mediaType:i,title:t.title,poster:t.poster,year:t.year,adult:t.adult})},r=i==="movie",v=!r,k=t?.backdrop?`https://image.tmdb.org/t/p/w1280${t.backdrop}`:"",b=t?.poster?`https://image.tmdb.org/t/p/w500${t.poster}`:"",N=T(()=>t?.genres?t.genres.map(s=>s.name).slice(0,5):[],[t?.genres]),S=T(()=>t?.seasons?t.seasons.filter(s=>s.season_number>0):[],[t?.seasons]),p=[t?.year,t?.status,v&&t?.number_of_seasons?`${t.number_of_seasons} Season${t.number_of_seasons>1?"s":""}`:null,v&&t?.number_of_episodes?`${t.number_of_episodes} Episodes`:null].filter(Boolean);if(L)return e("div",{className:n.container,children:e("div",{className:n.heroSkeleton,children:[e("div",{className:n.skeletonBanner}),e("div",{className:n.skeletonContent,children:[e("div",{className:n.skeletonPoster}),e("div",{className:n.skeletonInfo,children:[e("div",{className:n.skeletonTitle}),e("div",{className:n.skeletonMeta}),e("div",{className:n.skeletonDesc}),e("div",{className:n.skeletonActions})]})]})]})});if(y||!t)return e("div",{className:n.container,children:e("div",{className:n.errorState,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Failed to load details"}),e("p",{children:y||"Something went wrong"}),e(w,{onClick:()=>c(-1),children:"Go Back"})]})});const f=t.adult&&!D;return e("div",{className:n.container,style:f?{filter:"blur(14px)",pointerEvents:"none",userSelect:"none"}:void 0,children:[e("div",{className:n.heroSection,children:[e("div",{className:n.bannerContainer,children:[k&&e("div",{className:n.banner,style:{backgroundImage:`url(${k})`}}),e("div",{className:n.bannerOverlay})]}),e("div",{className:n.heroContent,children:[e("div",{className:n.posterContainer,children:b&&e("img",{src:b,alt:t.title,className:n.poster,decoding:"async"})}),e("div",{className:n.infoGlass,children:[e("div",{className:n.topInfo,children:[e("h1",{className:n.title,children:t.title}),e("div",{className:n.quickMeta,children:[t.vote_average!=null&&t.vote_average>0&&e("div",{className:n.metaItem,children:[e(a,{name:"star",className:n.iconStar}),e("span",{children:Number(t.vote_average).toFixed(1)})]}),e("div",{className:n.metaItem,children:[e(a,{name:"tv",className:n.iconTv}),e("span",{children:r?"Movie":"TV Show"})]}),t.vote_count!=null&&e("div",{className:n.metaItem,children:[e(a,{name:"users",className:n.iconType}),e("span",{children:[t.vote_count.toLocaleString()," votes"]})]})]}),N.length>0&&e("div",{className:n.genres,children:N.map(s=>e("span",{className:n.genre,children:s},s))})]}),p.length>0&&e("div",{className:n.metaRow,children:p.map((s,m)=>e(F.Fragment,{children:[e("span",{className:n.metaValue,children:s}),m<p.length-1&&e("span",{className:n.metaDivider,children:"·"})]},m))}),t.overview&&e("div",{className:n.synopsisSection,children:[e("h2",{className:n.sectionTitleSmall,children:"Synopsis"}),e("p",{className:n.synopsis,children:t.overview})]}),e("div",{className:n.actions,children:[e("button",{className:n.watchBtn,onClick:V,children:[e(a,{name:"play",size:14}),r?"Watch Now":`Start S${h}`]}),e("button",{className:`${n.watchlistBtn} ${g?n.active:""}`,onClick:W,children:[g?e(a,{name:"check",size:14}):e(a,{name:"plus",size:14}),g?"In Watchlist":"Add to Watchlist"]})]}),v&&S.length>1&&e("label",{className:n.seasonPickerLabel,children:[e("span",{children:"Season"}),e("select",{value:h,onChange:s=>$(parseInt(s.target.value,10)||1),className:n.seasonSelect,children:S.map(s=>e("option",{value:s.season_number,children:["Season ",s.season_number," (",s.episode_count," Episodes)"]},s.season_number))})]}),e("button",{className:n.detailsToggleBtn,onClick:()=>P(!d),children:[d?e(a,{name:"chevron-up"}):e(a,{name:"chevron-down"}),d?"Hide Details":"Show Details"]}),d&&e("div",{className:n.expandedContent,children:e("div",{className:n.detailGrid,children:[t.first_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:r?"Release Date":"First Air Date"}),e("span",{children:t.first_air_date})]}),t.last_air_date&&e("div",{className:n.detailItem,children:[e("strong",{children:"Last Air Date"}),e("span",{children:t.last_air_date})]}),t.networks&&t.networks.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Networks"}),e("span",{children:t.networks.map(s=>s.name).join(", ")})]}),t.created_by&&t.created_by.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Created By"}),e("span",{children:t.created_by.map(s=>s.name).join(", ")})]}),t.episode_run_time&&t.episode_run_time.length>0&&e("div",{className:n.detailItem,children:[e("strong",{children:"Episode Runtime"}),e("span",{children:[t.episode_run_time[0]," min"]})]}),t.imdb_id&&e("div",{className:n.detailItem,children:[e("strong",{children:"IMDb"}),e("a",{href:`https://www.imdb.com/title/${t.imdb_id}`,target:"_blank",rel:"noopener noreferrer",className:n.imdbLink,children:"View on IMDb"})]})]})})]})]})]}),f&&e("div",{className:n.matureOverlay,children:e("div",{className:n.matureContent,children:[e(a,{name:"exclamation-triangle",size:48}),e("h2",{children:"Content Warning"}),e("p",{children:"This content may contain mature themes."}),e(w,{onClick:()=>c("/"),children:"Go Back"})]})})]})}export{Je as default};
@@ -1 +1 @@
1
- import{A as b,d as v,h as P,T as z,u as e,S,L as p}from"./vendor-core-DfaOB3Rn.js";import{I as i}from"./vendor-icons-DrybRNxP.js";import{f as W,d as B,c as D,t as L}from"./useTvLibrary-BuMreQuF.js";import{t as M}from"./index-_iy8RyKU.js";import{p as a,a as A}from"./MediaCard-DM2d5vjg.js";const R=({item:s,anchorRect:m,onMouseEnter:u,onMouseLeave:g,onRequestClose:r})=>{const d=b(!1),[n,N]=v(null),[f,l]=v(!0),{toggle:y,bookmarkedIds:w}=W(),I=B(s.type,s.id),c=w.has(I);P(()=>{let t=!1;return l(!0),M.tv.details.query({type:s.type,id:String(s.id)}).then(o=>{t||(N({overview:o.overview,vote_average:o.vote_average,number_of_seasons:o.number_of_seasons}),l(!1))}).catch(()=>{t||l(!1)}),()=>{t=!0}},[s.id,s.type]);const h=z(()=>n?.genres?n.genres.slice(0,4).map(t=>t.name):[],[n?.genres]),k=D(s.type,s.id),T=L(s.type,s.id),_=t=>{t.preventDefault(),t.stopPropagation(),y({tmdbId:s.id,mediaType:s.type,title:s.title,poster:s.image,year:s.year})};return e(A,{anchorRect:m,onMouseEnter:()=>{d.current=!0,u()},onMouseLeave:()=>{d.current=!1,g()},onRequestClose:r,children:[e("div",{className:a.header,children:e("div",{className:a.title,children:s.title})}),e("div",{className:a.body,children:f?e("div",{className:a.loading,children:[e("div",{className:a.spinner}),e("span",{children:"Fetching details..."})]}):e(S,{children:[e("div",{className:a.metaRow,children:[n?.vote_average!=null&&n.vote_average>0&&e("div",{className:a.metaItem,children:[e(i,{name:"star",className:a.scoreIcon,size:14}),e("span",{children:Number(n.vote_average).toFixed(1)})]}),e("div",{className:a.metaItem,children:[e(i,{name:"tv",size:14}),e("span",{children:s.type==="tv"?"TV Show":"Movie"})]}),s.year&&e("div",{className:a.metaItem,children:e("span",{children:s.year})}),n?.status&&e("div",{className:a.metaItem,children:e("span",{children:n.status})})]}),h.length>0&&e("div",{className:a.genres,children:h.map(t=>e("span",{className:a.genre,children:t},t))}),n?.overview&&e("div",{className:a.synopsis,children:n.overview.length>200?n.overview.slice(0,200)+"...":n.overview})]})}),e("div",{className:a.footer,children:[e("div",{className:a.primaryAction,children:e(p,{to:T,className:a.watchBtn,onClick:r,children:[e(i,{name:"play",size:14}),"Watch now"]})}),e("div",{className:a.secondaryActions,children:[e("button",{className:`${a.watchlistBtn} ${c?a.active:""}`,onClick:_,children:[c?e(i,{name:"check",size:12}):e(i,{name:"plus",size:12}),e("span",{children:c?"Remove":"Watchlist"})]}),e(p,{to:k,className:a.detailsBtn,onClick:r,children:[e(i,{name:"info-circle",size:12}),e("span",{children:"Details"})]})]})]})]})};export{R as T};
1
+ import{A as b,d as v,h as P,T as z,u as e,S,L as p}from"./vendor-core-DfaOB3Rn.js";import{I as i}from"./vendor-icons-DrybRNxP.js";import{f as W,d as B,c as D,t as L}from"./useTvLibrary-CL3kMD_c.js";import{t as M}from"./index-CfgPGaUO.js";import{p as a,a as A}from"./MediaCard-fN3GQyTJ.js";const R=({item:s,anchorRect:m,onMouseEnter:u,onMouseLeave:g,onRequestClose:r})=>{const d=b(!1),[n,N]=v(null),[f,l]=v(!0),{toggle:y,bookmarkedIds:w}=W(),I=B(s.type,s.id),c=w.has(I);P(()=>{let t=!1;return l(!0),M.tv.details.query({type:s.type,id:String(s.id)}).then(o=>{t||(N({overview:o.overview,vote_average:o.vote_average,number_of_seasons:o.number_of_seasons}),l(!1))}).catch(()=>{t||l(!1)}),()=>{t=!0}},[s.id,s.type]);const h=z(()=>n?.genres?n.genres.slice(0,4).map(t=>t.name):[],[n?.genres]),k=D(s.type,s.id),T=L(s.type,s.id),_=t=>{t.preventDefault(),t.stopPropagation(),y({tmdbId:s.id,mediaType:s.type,title:s.title,poster:s.image,year:s.year})};return e(A,{anchorRect:m,onMouseEnter:()=>{d.current=!0,u()},onMouseLeave:()=>{d.current=!1,g()},onRequestClose:r,children:[e("div",{className:a.header,children:e("div",{className:a.title,children:s.title})}),e("div",{className:a.body,children:f?e("div",{className:a.loading,children:[e("div",{className:a.spinner}),e("span",{children:"Fetching details..."})]}):e(S,{children:[e("div",{className:a.metaRow,children:[n?.vote_average!=null&&n.vote_average>0&&e("div",{className:a.metaItem,children:[e(i,{name:"star",className:a.scoreIcon,size:14}),e("span",{children:Number(n.vote_average).toFixed(1)})]}),e("div",{className:a.metaItem,children:[e(i,{name:"tv",size:14}),e("span",{children:s.type==="tv"?"TV Show":"Movie"})]}),s.year&&e("div",{className:a.metaItem,children:e("span",{children:s.year})}),n?.status&&e("div",{className:a.metaItem,children:e("span",{children:n.status})})]}),h.length>0&&e("div",{className:a.genres,children:h.map(t=>e("span",{className:a.genre,children:t},t))}),n?.overview&&e("div",{className:a.synopsis,children:n.overview.length>200?n.overview.slice(0,200)+"...":n.overview})]})}),e("div",{className:a.footer,children:[e("div",{className:a.primaryAction,children:e(p,{to:T,className:a.watchBtn,onClick:r,children:[e(i,{name:"play",size:14}),"Watch now"]})}),e("div",{className:a.secondaryActions,children:[e("button",{className:`${a.watchlistBtn} ${c?a.active:""}`,onClick:_,children:[c?e(i,{name:"check",size:12}):e(i,{name:"plus",size:12}),e("span",{children:c?"Remove":"Watchlist"})]}),e(p,{to:k,className:a.detailsBtn,onClick:r,children:[e(i,{name:"info-circle",size:12}),e("span",{children:"Details"})]})]})]})]})};export{R as T};