@serifpersia/dango 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/AnimeCard-Dj2gXZQ_.js +1 -0
  3. package/client/dist/assets/{AnimeInfo-DXoNbSao.js → AnimeInfo-FTnsxEMu.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-CRWoCwXo.js → AnimeInfoPage-DaoQEHyi.js} +2 -2
  5. package/client/dist/assets/{Asmr-z6PNn8Ld.js → Asmr-Dj290riM.js} +2 -2
  6. package/client/dist/assets/{AsmrPopup-Cc-aIYXd.js → AsmrPopup-DCxF-0FD.js} +1 -1
  7. package/client/dist/assets/{AsmrResetProgressModal-D4Mp_-lx.js → AsmrResetProgressModal-BFgtJIjq.js} +1 -1
  8. package/client/dist/assets/Home-BvAHDt_3.js +1 -0
  9. package/client/dist/assets/Insights-Cn3L3buF.css +1 -0
  10. package/client/dist/assets/Insights-xaMU0gDH.js +1 -0
  11. package/client/dist/assets/{LibraryListPage-CNjzasIi.js → LibraryListPage-y1J_sbu3.js} +1 -1
  12. package/client/dist/assets/ListeningList-DxPvvTGs.js +1 -0
  13. package/client/dist/assets/Manga-Dc9QLjTm.js +1 -0
  14. package/client/dist/assets/{MangaInfoPage-DnDwJDWC.js → MangaInfoPage-BHnn83Zv.js} +1 -1
  15. package/client/dist/assets/{MangaReadPage-Cq4NYq31.js → MangaReadPage-CDQJ6lwj.js} +1 -1
  16. package/client/dist/assets/{MangaResetProgressModal-DaZmK9CX.js → MangaResetProgressModal-Cw4txoU9.js} +1 -1
  17. package/client/dist/assets/Mature-DdHf-knG.js +1 -0
  18. package/client/dist/assets/{MatureConsentModal-CEoZ_OA0.js → MatureConsentModal-BuJjdQ5N.js} +1 -1
  19. package/client/dist/assets/MediaCard-Co-j57uA.css +1 -0
  20. package/client/dist/assets/MediaCard-FQr72c16.js +1 -0
  21. package/client/dist/assets/MediaPopupShell-BewMMT93.js +1 -0
  22. package/client/dist/assets/MediaPopupShell-D6Emr-co.css +1 -0
  23. package/client/dist/assets/{OptionListMenu-ArbsAjlv.js → OptionListMenu-CAjFAq0c.js} +1 -1
  24. package/client/dist/assets/{Player-4wh-a_ee.js → Player-DO3lmGMJ.js} +2 -2
  25. package/client/dist/assets/{PlayerProvider-CbamWD19.js → PlayerProvider-1nQxpPbi.js} +1 -1
  26. package/client/dist/assets/{PlayerSettings-DehU56D4.js → PlayerSettings-BxmbpvrQ.js} +1 -1
  27. package/client/dist/assets/{QueueOptionsButton-DqoDQST5.js → QueueOptionsButton-Tsij7x21.js} +1 -1
  28. package/client/dist/assets/{QueueRail-ClrcV9LL.js → QueueRail-DHSBCDXc.js} +1 -1
  29. package/client/dist/assets/ReadingList-Bl-49YU7.js +1 -0
  30. package/client/dist/assets/{ResetProgressModal-BdcBPlC1.js → ResetProgressModal-DIn1j8Qp.js} +1 -1
  31. package/client/dist/assets/Search-uY6VQ4os.js +1 -0
  32. package/client/dist/assets/{Settings-O0oOrEUd.js → Settings-CHkvGAxk.js} +1 -1
  33. package/client/dist/assets/{SkeletonGrid-DqN0laN_.js → SkeletonGrid-xUVpcN5T.js} +1 -1
  34. package/client/dist/assets/{Trackers-DxBWYwss.js → Trackers-DXrxbGg1.js} +1 -1
  35. package/client/dist/assets/Tv-DFrBiMVQ.js +4 -0
  36. package/client/dist/assets/{TvInfo-DjPQ7BZn.js → TvInfo-eLmiGzwb.js} +1 -1
  37. package/client/dist/assets/{TvPopup-CCTQiS84.js → TvPopup-CaXs4L6B.js} +1 -1
  38. package/client/dist/assets/TvSearch-D_IGBBD8.js +1 -0
  39. package/client/dist/assets/TvWatchlist-Ol8QK-C9.js +1 -0
  40. package/client/dist/assets/{VirtualKeyboard-Bf7wvuX3.js → VirtualKeyboard-Bp-M8SVt.js} +1 -1
  41. package/client/dist/assets/{WatchAlong-D9NsqbWz.js → WatchAlong-qJzs9_fD.js} +1 -1
  42. package/client/dist/assets/{WatchAlongPanel-DRsYyjM7.js → WatchAlongPanel-DLuYT4hH.js} +1 -1
  43. package/client/dist/assets/Watchlist-DcAUYWtZ.js +1 -0
  44. package/client/dist/assets/{index-YxVpiwVZ.css → index-BBbcJwUD.css} +1 -1
  45. package/client/dist/assets/index-CkZCduQZ.js +178 -0
  46. package/client/dist/assets/{libraryInvalidation-hcASRQHn.js → libraryInvalidation-Cv-7EfU1.js} +1 -1
  47. package/client/dist/assets/{playbackCompletion-D1Gm0GbH.js → playbackCompletion-BTwrTq5S.js} +1 -1
  48. package/client/dist/assets/{useAnimeInfoData-BsFz9uiF.js → useAnimeInfoData-tmC_S41n.js} +1 -1
  49. package/client/dist/assets/{useMangaLibrary-DbvnlYV9.js → useMangaLibrary-CPluPl_T.js} +1 -1
  50. package/client/dist/assets/{useMangaPopup-2lqmdmS5.js → useMangaPopup-DRDWlEcN.js} +1 -1
  51. package/client/dist/assets/{useProviders-BgAgACS8.js → useProviders-aA8vRBov.js} +1 -1
  52. package/client/dist/assets/{useTv-OX_q_uaI.js → useTv-Dl0TYap6.js} +1 -1
  53. package/client/dist/assets/{useTvLibrary-DaLHYFID.js → useTvLibrary-BCgO-d_K.js} +1 -1
  54. package/client/dist/assets/{useWatchAlongPlayer-B7Yj2s3s.js → useWatchAlongPlayer-DfbkmL7h.js} +1 -1
  55. package/client/dist/index.html +2 -2
  56. package/package.json +2 -2
  57. package/server/dist/server.js +193 -185
  58. package/server/package.json +1 -1
  59. package/client/dist/assets/AnimeCard-B-3qrNhu.js +0 -1
  60. package/client/dist/assets/Home-9ZTaG1WX.js +0 -1
  61. package/client/dist/assets/Insights-Bf92STPA.js +0 -1
  62. package/client/dist/assets/Insights-DEicrokg.css +0 -1
  63. package/client/dist/assets/ListeningList-1mBIfxxH.js +0 -1
  64. package/client/dist/assets/Manga-B3_TdzgY.js +0 -1
  65. package/client/dist/assets/Mature-CbQWqjUS.js +0 -1
  66. package/client/dist/assets/MediaCard-B-TmXdgl.js +0 -1
  67. package/client/dist/assets/MediaCard-BfQaS9n5.css +0 -1
  68. package/client/dist/assets/ReadingList-Cy1BKzJs.js +0 -1
  69. package/client/dist/assets/Search-5PvZ8pAC.js +0 -1
  70. package/client/dist/assets/Tv-Ox6p6iEx.js +0 -4
  71. package/client/dist/assets/TvSearch-Baig87wj.js +0 -1
  72. package/client/dist/assets/TvWatchlist-D-yxvaKC.js +0 -1
  73. package/client/dist/assets/Watchlist-oYAx_dFL.js +0 -1
  74. package/client/dist/assets/index-CPhXtUuw.js +0 -178
@@ -1 +1 @@
1
- import{b as T}from"./vendor-query-BBT5_sHx.js";import{q as z,t as A,x as J,as as W,at as X,au as Y}from"./index-CPhXtUuw.js";import{d as Z,T as R,q as r,u as t,$ as w,S as ee}from"./vendor-core-DfaOB3Rn.js";import{a as te,c as ne,d as se,b as ae,o as oe,f as ie,s as re}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-C1Pj_eSX.js";function Ee(n){return T({queryKey:[z.showMeta,n],queryFn:async()=>n?A.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",pe="_menuTitle_1vova_51",de="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",o={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:pe,menuItem:de,removeItem:ge,menuEmpty:fe},ve=8,Pe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:D="",activeClassName:F="",align:M="right",onMenuOpenChange:d})=>{const{data:q=[]}=J(),E=W(),P=X(),[m,f]=Z(!1),{refs:Q,floatingStyles:x,context:C}=te({open:m,onOpenChange:e=>{e||(f(!1),d?.(!1))},placement:M==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ie({padding:8}),re({padding:8})],whileElementsMounted:ae}),I=ne(C,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:S,getFloatingProps:K}=se([I]),l=R(()=>q.filter(e=>e.showId===n),[q,n]),{data:L}=T({queryKey:[z.suggestedEpisode,n],queryFn:()=>A.watchlist.queueSuggested.query({showId:n}),enabled:!!n}),{data:$,isFetching:N}=Y(n,m),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),d?.(!0)},[d]),c=r(()=>{f(!1),d?.(!1)},[d]),p=l.length>0,a=s.length>0,g=L?.episodeNumber,i=r(e=>{!n||e.length===0||(E.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,E,c]),O=r(()=>{!n||l.length===0||(P.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,P,c]),U=r(()=>{a?i([s[0]]):g&&i([String(g)])},[a,s,g,i]),G=r(()=>{a&&i(s.slice(0,3))},[a,s,i]),V=r(()=>{a&&i([...s])},[a,s,i]),B=s[0],j=s[Math.min(2,s.length-1)],H=t("div",{className:o.trigger,ref:Q.setReference,children:t("span",{className:`${o.triggerBtn} ${D} ${p?F:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":p?"Queued":"Queue",...S(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[p?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),p?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:o.chevron})]})});return t(ee,{children:[H,m&&w(t("div",{ref:Q.setFloating,className:o.menu,style:x,role:"menu",...K(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:o.menuTitle,children:"Queue episodes"}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a&&!g,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+3 — EP ${B}${s.length>1?`-${j}`:""}`:"+3"})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),V()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:o.menuEmpty,children:p?"All episodes are already queued":"No remaining unwatched episodes"}),p&&t("button",{className:`${o.menuItem} ${o.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{Pe as Q,Ee as u};
1
+ import{b as T}from"./vendor-query-BBT5_sHx.js";import{q as z,t as A,x as J,as as W,at as X,au as Y}from"./index-CkZCduQZ.js";import{d as Z,T as R,q as r,u as t,$ as w,S as ee}from"./vendor-core-DfaOB3Rn.js";import{a as te,c as ne,d as se,b as ae,o as oe,f as ie,s as re}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-C1Pj_eSX.js";function Ee(n){return T({queryKey:[z.showMeta,n],queryFn:async()=>n?A.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",pe="_menuTitle_1vova_51",de="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",o={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:pe,menuItem:de,removeItem:ge,menuEmpty:fe},ve=8,Pe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:D="",activeClassName:F="",align:M="right",onMenuOpenChange:d})=>{const{data:q=[]}=J(),E=W(),P=X(),[m,f]=Z(!1),{refs:Q,floatingStyles:x,context:C}=te({open:m,onOpenChange:e=>{e||(f(!1),d?.(!1))},placement:M==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ie({padding:8}),re({padding:8})],whileElementsMounted:ae}),I=ne(C,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:S,getFloatingProps:K}=se([I]),l=R(()=>q.filter(e=>e.showId===n),[q,n]),{data:L}=T({queryKey:[z.suggestedEpisode,n],queryFn:()=>A.watchlist.queueSuggested.query({showId:n}),enabled:!!n}),{data:$,isFetching:N}=Y(n,m),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),d?.(!0)},[d]),c=r(()=>{f(!1),d?.(!1)},[d]),p=l.length>0,a=s.length>0,g=L?.episodeNumber,i=r(e=>{!n||e.length===0||(E.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,E,c]),O=r(()=>{!n||l.length===0||(P.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,P,c]),U=r(()=>{a?i([s[0]]):g&&i([String(g)])},[a,s,g,i]),G=r(()=>{a&&i(s.slice(0,3))},[a,s,i]),V=r(()=>{a&&i([...s])},[a,s,i]),B=s[0],j=s[Math.min(2,s.length-1)],H=t("div",{className:o.trigger,ref:Q.setReference,children:t("span",{className:`${o.triggerBtn} ${D} ${p?F:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":p?"Queued":"Queue",...S(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[p?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),p?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:o.chevron})]})});return t(ee,{children:[H,m&&w(t("div",{ref:Q.setFloating,className:o.menu,style:x,role:"menu",...K(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:o.menuTitle,children:"Queue episodes"}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a&&!g,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+3 — EP ${B}${s.length>1?`-${j}`:""}`:"+3"})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),V()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:o.menuEmpty,children:p?"All episodes are already queued":"No remaining unwatched episodes"}),p&&t("button",{className:`${o.menuItem} ${o.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{Pe as Q,Ee as u};
@@ -1 +1 @@
1
- import{g as s,u as n,a as G}from"./vendor-core-DfaOB3Rn.js";import{I as D}from"./vendor-icons-C1Pj_eSX.js";import{d as X,F as Y,f as L}from"./index-CPhXtUuw.js";const z="_section_5peha_1",O="_header_5peha_10",j="_headerToggle_5peha_20",J="_headerActions_5peha_34",K="_title_5peha_40",V="_badge_5peha_50",W="_clearBtn_5peha_65",Z="_nextBtn_5peha_83",ee="_list_5peha_101",ne="_item_5peha_115",te="_active_5peha_135",ae="_dragging_5peha_143",re="_dragHandle_5peha_150",oe="_thumbnail_5peha_168",ce="_meta_5peha_176",se="_name_5peha_183",le="_episode_5peha_205",ie="_iconBtn_5peha_211",ue="_metaGap_5peha_257",a={section:z,header:O,headerToggle:j,headerActions:J,title:K,badge:V,clearBtn:W,nextBtn:Z,list:ee,item:ne,active:te,dragging:ae,dragHandle:re,thumbnail:oe,meta:ce,name:se,episode:le,iconBtn:ie,metaGap:ue},de=({item:r,isActive:I,index:g,onRemove:v,onTouchPointerDown:x,onTouchPointerMove:B,onTouchPointerUp:w,onTouchPointerCancel:y,shouldIgnoreClick:_,onDragStart:R,onDragEnter:f,onDragEnd:c,isDragging:b})=>{const o=G(),{titlePreference:l}=X(),i=r[l]||r.name||"Unknown show";return n("div",{"data-queue-index":g,className:`${a.item} ${I?a.active:""} ${b?a.dragging:""}`,draggable:!0,onDragStart:R,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:c,onPointerDown:u=>x(g,u),onPointerMove:B,onPointerUp:w,onPointerCancel:y,children:[n("button",{className:a.dragHandle,type:"button","aria-label":"Drag queue item",children:n(D,{name:"bars"})}),n(Y,{className:a.thumbnail,src:L(r.thumbnail||"",72,96),alt:i,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:a.meta,children:[n("button",{className:a.name,type:"button",onClick:()=>{_()||o(`/watch/${r.showId}/${r.episodeNumber}`)},children:i}),n("div",{className:a.episode,children:["Episode ",r.episodeNumber]})]}),n("button",{className:a.iconBtn,type:"button",onClick:()=>{_()||v(r)},"aria-label":`Remove ${i} episode ${r.episodeNumber} from queue`,children:n(D,{name:"times"})})]})},ge=({title:r="Queue",eyebrow:I,items:g,currentShowId:v,currentEpisode:x,onRemove:B,onReorder:w,onNextQueue:y,onClear:_,showClearAll:R=!1,defaultExpanded:f=!0})=>{const[c,b]=s.useState([]),[o,l]=s.useState(null),[i,u]=s.useState(f),N=s.useRef(null),T=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{b(g)},[g]),s.useEffect(()=>{u(f)},[f]);const $=e=>{l(e)},k=e=>{if(o===null||o===e)return;const t=[...c],p=t[o];t.splice(o,1),t.splice(e,0,p),l(e),b(t)},A=()=>{o!==null&&w(c.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),l(null)},E=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&h.current&&(w(c.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),C.current=!0,window.setTimeout(()=>{C.current=!1},0)),N.current=null,T.current=null,h.current=!1,l(null)},Q=(e,t)=>{if(t.pointerType==="mouse")return;const p=t.currentTarget,m=t.pointerId;N.current=t.pointerId,T.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{h.current=!0,l(e);try{p.setPointerCapture(m)}catch{}},220)},S=e=>{if(e.pointerType==="mouse"||N.current!==e.pointerId)return;if(!h.current&&T.current){const H=Math.abs(e.clientX-T.current.x),F=Math.abs(e.clientY-T.current.y);(H>8||F>8)&&E(!1);return}if(!h.current)return;e.preventDefault();const p=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),m=p?Number(p.dataset.queueIndex):NaN;if(Number.isNaN(m)||o===null||m===o)return;const P=[...c],U=P[o];P.splice(o,1),P.splice(m,0,U),l(m),b(P)},q=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(h.current)},M=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(!1)};return c.length===0?null:n("section",{className:a.section,children:[n("div",{className:a.header,children:[n("button",{className:a.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":i,"aria-label":i?`Collapse ${r}`:`Expand ${r}`,children:[n("span",{className:a.title,children:[n("span",{className:"title-stack",children:[I&&n("div",{className:"section-eyebrow",children:I}),n("span",{children:r})]}),n("span",{className:a.badge,children:c.length})]}),i?n(D,{name:"chevron-up"}):n(D,{name:"chevron-down"})]}),R&&_&&n("div",{className:a.headerActions,children:[y&&c.length>1&&n("button",{className:a.nextBtn,type:"button",onClick:y,children:"Next"}),n("button",{className:a.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),i&&n("div",{className:a.list,children:c.map((e,t)=>n(de,{item:e,isActive:e.showId===v&&e.episodeNumber===x,index:t,onRemove:B,onTouchPointerDown:Q,onTouchPointerMove:S,onTouchPointerUp:q,onTouchPointerCancel:M,shouldIgnoreClick:()=>C.current,onDragStart:()=>$(t),onDragEnter:()=>k(t),onDragEnd:A,isDragging:o===t},e.id))})]})};export{ge as Q,a as s};
1
+ import{g as s,u as n,a as G}from"./vendor-core-DfaOB3Rn.js";import{I as D}from"./vendor-icons-C1Pj_eSX.js";import{d as X,F as Y,f as L}from"./index-CkZCduQZ.js";const z="_section_5peha_1",O="_header_5peha_10",j="_headerToggle_5peha_20",J="_headerActions_5peha_34",K="_title_5peha_40",V="_badge_5peha_50",W="_clearBtn_5peha_65",Z="_nextBtn_5peha_83",ee="_list_5peha_101",ne="_item_5peha_115",te="_active_5peha_135",ae="_dragging_5peha_143",re="_dragHandle_5peha_150",oe="_thumbnail_5peha_168",ce="_meta_5peha_176",se="_name_5peha_183",le="_episode_5peha_205",ie="_iconBtn_5peha_211",ue="_metaGap_5peha_257",a={section:z,header:O,headerToggle:j,headerActions:J,title:K,badge:V,clearBtn:W,nextBtn:Z,list:ee,item:ne,active:te,dragging:ae,dragHandle:re,thumbnail:oe,meta:ce,name:se,episode:le,iconBtn:ie,metaGap:ue},de=({item:r,isActive:I,index:g,onRemove:v,onTouchPointerDown:x,onTouchPointerMove:B,onTouchPointerUp:w,onTouchPointerCancel:y,shouldIgnoreClick:_,onDragStart:R,onDragEnter:f,onDragEnd:c,isDragging:b})=>{const o=G(),{titlePreference:l}=X(),i=r[l]||r.name||"Unknown show";return n("div",{"data-queue-index":g,className:`${a.item} ${I?a.active:""} ${b?a.dragging:""}`,draggable:!0,onDragStart:R,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:c,onPointerDown:u=>x(g,u),onPointerMove:B,onPointerUp:w,onPointerCancel:y,children:[n("button",{className:a.dragHandle,type:"button","aria-label":"Drag queue item",children:n(D,{name:"bars"})}),n(Y,{className:a.thumbnail,src:L(r.thumbnail||"",72,96),alt:i,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:a.meta,children:[n("button",{className:a.name,type:"button",onClick:()=>{_()||o(`/watch/${r.showId}/${r.episodeNumber}`)},children:i}),n("div",{className:a.episode,children:["Episode ",r.episodeNumber]})]}),n("button",{className:a.iconBtn,type:"button",onClick:()=>{_()||v(r)},"aria-label":`Remove ${i} episode ${r.episodeNumber} from queue`,children:n(D,{name:"times"})})]})},ge=({title:r="Queue",eyebrow:I,items:g,currentShowId:v,currentEpisode:x,onRemove:B,onReorder:w,onNextQueue:y,onClear:_,showClearAll:R=!1,defaultExpanded:f=!0})=>{const[c,b]=s.useState([]),[o,l]=s.useState(null),[i,u]=s.useState(f),N=s.useRef(null),T=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{b(g)},[g]),s.useEffect(()=>{u(f)},[f]);const $=e=>{l(e)},k=e=>{if(o===null||o===e)return;const t=[...c],p=t[o];t.splice(o,1),t.splice(e,0,p),l(e),b(t)},A=()=>{o!==null&&w(c.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),l(null)},E=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&h.current&&(w(c.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),C.current=!0,window.setTimeout(()=>{C.current=!1},0)),N.current=null,T.current=null,h.current=!1,l(null)},Q=(e,t)=>{if(t.pointerType==="mouse")return;const p=t.currentTarget,m=t.pointerId;N.current=t.pointerId,T.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{h.current=!0,l(e);try{p.setPointerCapture(m)}catch{}},220)},S=e=>{if(e.pointerType==="mouse"||N.current!==e.pointerId)return;if(!h.current&&T.current){const H=Math.abs(e.clientX-T.current.x),F=Math.abs(e.clientY-T.current.y);(H>8||F>8)&&E(!1);return}if(!h.current)return;e.preventDefault();const p=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),m=p?Number(p.dataset.queueIndex):NaN;if(Number.isNaN(m)||o===null||m===o)return;const P=[...c],U=P[o];P.splice(o,1),P.splice(m,0,U),l(m),b(P)},q=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(h.current)},M=e=>{e.pointerType!=="mouse"&&N.current===e.pointerId&&E(!1)};return c.length===0?null:n("section",{className:a.section,children:[n("div",{className:a.header,children:[n("button",{className:a.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":i,"aria-label":i?`Collapse ${r}`:`Expand ${r}`,children:[n("span",{className:a.title,children:[n("span",{className:"title-stack",children:[I&&n("div",{className:"section-eyebrow",children:I}),n("span",{children:r})]}),n("span",{className:a.badge,children:c.length})]}),i?n(D,{name:"chevron-up"}):n(D,{name:"chevron-down"})]}),R&&_&&n("div",{className:a.headerActions,children:[y&&c.length>1&&n("button",{className:a.nextBtn,type:"button",onClick:y,children:"Next"}),n("button",{className:a.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),i&&n("div",{className:a.list,children:c.map((e,t)=>n(de,{item:e,isActive:e.showId===v&&e.episodeNumber===x,index:t,onRemove:B,onTouchPointerDown:Q,onTouchPointerMove:S,onTouchPointerUp:q,onTouchPointerCancel:M,shouldIgnoreClick:()=>C.current,onDragStart:()=>$(t),onDragEnter:()=>k(t),onDragEnd:A,isDragging:o===t},e.id))})]})};export{ge as Q,a as s};
@@ -0,0 +1 @@
1
+ import{o as U,d as v,h as b,T as w,u as i,S as E}from"./vendor-core-DfaOB3Rn.js";import{M as x}from"./MediaCard-FQr72c16.js";import{L as F}from"./LibraryListPage-y1J_sbu3.js";import{u as _,M as q}from"./useMangaPopup-DRDWlEcN.js";import{M as D}from"./MangaResetProgressModal-Cw4txoU9.js";import{m as G}from"./index-CkZCduQZ.js";import{n as O,b as Q,h as Y,j,u as z,o as H,q as K,s as V,M as R,m as Z,i as J,a as W}from"./useMangaLibrary-CPluPl_T.js";import"./vendor-icons-C1Pj_eSX.js";import"./MediaPopupShell-BewMMT93.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-BuJjdQ5N.js";import"./SkeletonGrid-xUVpcN5T.js";import"./ErrorMessage-hMt90aG4.js";import"./LibraryListPage.module-r6k9nyT9.js";import"./usePopup-DS9jMzp6.js";import"./ResetProgressModal-DIn1j8Qp.js";import"./vendor-query-BBT5_sHx.js";import"./libraryInvalidation-Cv-7EfU1.js";const X=["All","Continue Reading",...R],h=24,y=e=>({provider:e.provider,mangaId:e.mangaId,title:e.title,altTitle:e.altTitle,cover:e.cover,contentRating:e.contentRating,readTarget:e.detailTarget,progressLabel:e.progressLabel});function Ia(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=O(r?"All":e,g,h),s=Q(100),I=Y(),T=j(),{toggle:L,bookmarkedIds:C}=z(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:f}=_(),M=H(),P=K(),B=V(),S=w(()=>r?(s.data?.data??[]).map(a=>{const o=a.page??0,l=a.pageCount??0;return{key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title||"",altTitle:a.altTitle,cover:a.cover||"",status:a.watchlistStatus??"",contentRating:a.contentRating||void 0,chapterLabel:a.chapterNumber?`Ch. ${a.chapterNumber}`:void 0,progressPercent:l>0?o/l*100:0,progressLabel:a.chapterNumber&&l>0?`Ch. ${a.chapterNumber} · p. ${o}/${l}`:void 0,detailTarget:a.chapterId&&a.provider&&a.mangaId?`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}/read?chapter=${encodeURIComponent(a.chapterId)}`:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`}}):(n.data?.data??[]).map(a=>({key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title||"",altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.lastChapterNumber?`Ch. ${a.lastChapterNumber}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`})),[r,s.data,n.data]),$=r?s.data?.total??0:n.data?.total??0,A=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...R],entries:S,total:$,isLoading:A,error:N,page:g,pageSize:h,onPageChange:p,emptyTitle:"Your reading list is looking a bit lonely",emptyFilteredText:"No titles match this filter.",emptyAllText:"Let's find something to read!",browseLabel:"Browse Manga",browseTarget:"/manga",removeListLabel:"Remove from Reading List",listNoun:"reading list",skipConfirmKey:"mangaSkipRemoveConfirmation",onBulkStatus:(a,o)=>M.mutate({ids:a,status:o}),onBulkRemove:a=>{r?B.mutate({ids:a}):P.mutate(a)},onStatusChange:(a,o)=>T.mutate({id:a,status:o}),onRemoveItem:a=>I.mutate(a),renderCard:a=>i(x,{item:{id:a.libId,title:a.title,...W({title:a.title,altTitle:a.altTitle}),thumbnail:G(a.provider,a.cover),chapterBadge:a.chapterLabel??null,isAdult:J(a)},linkTo:a.detailTarget,hoverIcon:"book",progress:a.progressPercent!==void 0&&a.progressLabel?{percent:a.progressPercent,label:a.progressLabel}:void 0,showProgress:r,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:r?()=>u(a):void 0,onOpenDetails:o=>k(o,y(a)),onPopupHoverIntent:o=>o?m():c(),rawThumbnail:!0}),modals:i(E,{children:[t&&t.data.provider&&i(q,{data:t.data,anchorRect:t.rect,bookmarked:C.has(Z(t.data.provider,t.data.mangaId)),onToggleBookmark:()=>L({id:t.data.mangaId,provider:t.data.provider,title:t.data.title,cover:t.data.cover,altTitle:t.data.altTitle??void 0,contentRating:t.data.contentRating}),onMouseEnter:m,onMouseLeave:c,onRequestClose:f}),i(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{Ia as default};
@@ -1 +1 @@
1
- import{d as f,h as u,u as e}from"./vendor-core-DfaOB3Rn.js";import{R as a,B as c}from"./index-CPhXtUuw.js";const g=({isOpen:o,itemName:n,progressKind:d,listLabel:i,onClose:s,onConfirm:h})=>{const[l,r]=f(!1);return u(()=>{o&&r(!1)},[o]),e(a,{isOpen:o,onClose:()=>{r(!1),s()},title:"Reset Progress",children:[e(a.Body,{children:[e("p",{children:["Are you sure you want to remove your ",d,' progress for "',n,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:l,onChange:t=>r(t.currentTarget.checked)}),"Also remove from ",i]})]}),e(a.Actions,{children:[e(c,{variant:"secondary",onClick:()=>{r(!1),s()},children:"No"}),e(c,{variant:"danger",onClick:()=>{const t=l;r(!1),h(t),s()},children:"Yes"})]})]})};export{g as R};
1
+ import{d as f,h as u,u as e}from"./vendor-core-DfaOB3Rn.js";import{R as a,B as c}from"./index-CkZCduQZ.js";const g=({isOpen:o,itemName:n,progressKind:d,listLabel:i,onClose:s,onConfirm:h})=>{const[l,r]=f(!1);return u(()=>{o&&r(!1)},[o]),e(a,{isOpen:o,onClose:()=>{r(!1),s()},title:"Reset Progress",children:[e(a.Body,{children:[e("p",{children:["Are you sure you want to remove your ",d,' progress for "',n,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:l,onChange:t=>r(t.currentTarget.checked)}),"Also remove from ",i]})]}),e(a.Actions,{children:[e(c,{variant:"secondary",onClick:()=>{r(!1),s()},children:"No"}),e(c,{variant:"danger",onClick:()=>{const t=l;r(!1),h(t),s()},children:"Yes"})]})]})};export{g as R};
@@ -0,0 +1 @@
1
+ import{h as G,p as pe,a as fe,d as c,A as ge,g as Le,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as f}from"./vendor-icons-C1Pj_eSX.js";import{P as te}from"./MediaCard-FQr72c16.js";import{A as Ae}from"./AnimeCard-Dj2gXZQ_.js";import{S as Se}from"./SkeletonGrid-xUVpcN5T.js";import{t as ye,u as be,H as Ce,a9 as le,B as U,aa as Ne}from"./index-CkZCduQZ.js";import{E as Te}from"./ErrorMessage-hMt90aG4.js";import{A as Ee}from"./ActiveFilterChips-olGfwxle.js";import{s as t}from"./Search.module-C_qwCdHS.js";import"./MediaPopupShell-BewMMT93.js";import"./vendor-ui-3qrARCPr.js";import"./useIsMobile-Dvx1uJ82.js";import"./MatureConsentModal-BuJjdQ5N.js";import"./useAnimeInfoData-tmC_S41n.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-Tsij7x21.js";import"./playbackCompletion-BTwrTq5S.js";const Re=[{value:"ALL",label:"All Types"},{value:"TV",label:"TV Series"},{value:"Movie",label:"Movie"},{value:"OVA",label:"OVA"},{value:"ONA",label:"ONA"},{value:"TV_SHORT",label:"TV Short"},{value:"SPECIAL",label:"Special"},{value:"ADULT",label:"Mature"}],Pe=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],Ie=[{value:"ALL",label:"All Countries"},{value:"JP",label:"Japan"},{value:"CN",label:"China"}],De=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"START_DATE_ASC",label:"Oldest"},{value:"EPISODES_DESC",label:"Most Episodes"},{value:"FAVOURITES_DESC",label:"Favourites"}],Oe=[{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"},{value:"CANCELLED",label:"Cancelled"},{value:"HIATUS",label:"Hiatus"}];function Je(){G(()=>{document.title="Search - dango"},[]);const[r,se]=pe(),k=fe(),[d,$]=c(r.get("query")||""),[v,F]=c(parseInt(r.get("page")||"1")),[h,g]=c(r.get("type")||"ALL"),[L,A]=c(r.get("season")||"ALL"),[S,y]=c(r.get("year")||"ALL"),[M,D]=c(r.get("country")||"ALL"),[V,re]=c(r.get("provider")||"anilist"),[j,O]=c(r.get("sortBy")||"POPULARITY_DESC"),[q,w]=c(r.get("status")||""),[b,ne]=c(!1),[ie,H]=c(null);G(()=>{let e=!1;return ye.data.anilistStatus.query().then(s=>{e||H(s.available)}).catch(()=>{e||H(!0)}),()=>{e=!0}},[]);const{lowEndMode:oe}=be(),_=ge(null),{data:ce}=Ce(),z=ce?.genres||[],[C,N]=c(()=>{const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],i=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return s.forEach(l=>l&&(e[l]="include")),i.forEach(l=>l&&(e[l]="exclude")),e}),W=new URLSearchParams(r);W.delete("page");const J=W.toString(),{data:p=[],isLoading:T,isError:ue,error:de}=le(J,v,14),{data:K}=le(J,v+1,14),[x,he]=c(!1),E=Le.useMemo(()=>V==="anilist"&&h==="ADULT"||x?p:p.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[p,x,V,h]);G(()=>{$(r.get("query")||""),g(r.get("type")||"ALL"),A(r.get("season")||"ALL"),y(r.get("year")||"ALL"),D(r.get("country")||"ALL"),re(r.get("provider")||"anilist"),O(r.get("sortBy")||"POPULARITY_DESC"),w(r.get("status")||""),F(parseInt(r.get("page")||"1"));const e={},s=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],i=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];s.forEach(l=>l&&(e[l]="include")),i.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const u=(e=1,s={})=>{Ne();const i=s.type??h,l=s.status??q,R=s.season??L,P=s.year??S,Z=s.country??M,I=s.sort??j,ee=s.genreState??C,ve=s.showMature??x,o=new URLSearchParams;d.trim()&&o.set("query",d.trim()),i!=="ALL"&&o.set("type",i),l&&o.set("status",l),R!=="ALL"&&o.set("season",R),P!=="ALL"&&o.set("year",P),Z!=="ALL"&&o.set("country",Z),I!=="POPULARITY_DESC"&&o.set("sortBy",I);const Y=Object.entries(ee).filter(([,n])=>n==="include").map(([n])=>n),ae=Object.entries(ee).filter(([,n])=>n==="exclude").map(([n])=>n);if(Y.some(n=>n.toLowerCase()==="hentai")){const n=new URLSearchParams;n.set("provider","anilist"),d.trim()&&n.set("query",d.trim()),l&&n.set("status",l),R!=="ALL"&&n.set("season",R),P!=="ALL"&&n.set("year",P),I!=="POPULARITY_DESC"&&n.set("sortBy",I),k(`/mature?${n.toString()}`);return}Y.length>0&&o.set("genres",Y.join(",")),ae.length>0&&o.set("excludeGenres",ae.join(",")),i!=="ADULT"&&!ve&&o.set("adult","false"),o.set("provider","anilist"),e>1&&o.set("page",e.toString()),se(o),e!==v&&F(e)},Q=e=>{if(u(e),_.current){const s=_.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:s,behavior:"smooth"})}},B=new Date().getFullYear(),me=[{value:"ALL",label:"All Years"},...Array.from({length:B-1980+1},(e,s)=>({value:String(B-s),label:String(B-s)}))],X=p.length>=14&&K&&K.length>0,m=[];h!=="ALL"&&m.push({key:"type",label:`Type: ${h}`,onRemove:()=>{g("ALL"),u(1,{type:"ALL"})}}),L!=="ALL"&&m.push({key:"season",label:`Season: ${L}`,onRemove:()=>{A("ALL"),u(1,{season:"ALL"})}}),S!=="ALL"&&m.push({key:"year",label:`Year: ${S}`,onRemove:()=>{y("ALL"),u(1,{year:"ALL"})}});for(const[e,s]of Object.entries(C))m.push({key:e,label:s==="include"?`+ ${e}`:`-${e}`,tone:s==="include"?"primary":"danger",onRemove:()=>{const i={...C};delete i[e],N(i),u(1,{genreState:i})}});return a("div",{className:"page-container",children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:"Search Anime"}),a("p",{className:t.pageSubtitle,children:"Search through thousands of titles and discover your next favorite"})]}),a("div",{className:t.filterContainer,children:[a("div",{className:t.searchBarWrapper,children:[a("div",{className:t.inputIconWrapper,children:[a(f,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:d,onInput:e=>$(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&u()})]}),a("div",{className:t.searchActions,children:[a(U,{onClick:()=>u(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${b?t.active:""}`,onClick:()=>ne(!b),children:[a(f,{name:"filter",size:14}),a("span",{children:"Filters"}),b?a(f,{name:"chevron-up",size:12}):a(f,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${b?t.show:""}`,children:[a("div",{className:t.filterDivider}),a("div",{className:t.filterGrid,children:[a("div",{className:t.filterItem,children:[a("label",{children:"Type"}),a("select",{value:h,onChange:e=>{if(e.currentTarget.value==="ADULT"){k("/mature?provider=mal");return}g(e.currentTarget.value)},children:Re.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Status"}),a("select",{value:q,onChange:e=>w(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Oe.map(e=>a("option",{value:e.value,children:e.label},e.value))]})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Season"}),a("select",{value:L,onChange:e=>A(e.currentTarget.value),children:Pe.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Year"}),a("select",{value:S,onChange:e=>y(e.currentTarget.value),children:me.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",ie===!1&&a("span",{style:{display:"block",fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:400},children:"AniList only - ignored by fallback providers"})]}),a("select",{value:M,onChange:e=>D(e.currentTarget.value),children:Ie.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:"Sort By"}),a("select",{value:j,onChange:e=>O(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),z.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:z.map(e=>a("button",{className:`${t.genreButton} ${t[C[e]||""]}`,onClick:()=>{N(s=>{const i=s[e],l={...s};return i==="include"?l[e]="exclude":i==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(U,{variant:"secondary",onClick:()=>{N({}),g("ALL"),A("ALL"),y("ALL"),D("ALL"),O("POPULARITY_DESC"),w(""),he(!1),u(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(U,{onClick:()=>u(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ue&&a(Te,{message:de?.message||"Error"}),m.length>0&&a(Ee,{chips:m}),a("div",{className:t.resultsHeader,ref:_,children:[a("h2",{className:t.resultsTitle,children:d?`Search Results for "${d}"`:"Discover Anime"}),E.length>0&&a(te,{page:v,canGoNext:X,onChange:Q,isLoading:T})]}),a("div",{className:`${t.resultsGrid} ${oe?t.lowEnd:""}`,children:T?a(Se,{}):E.map(e=>a(Ae,{anime:e},e._id))}),!T&&E.length===0&&a("div",{className:t.noResults,children:[a(f,{name:"search",size:48,className:t.noResultsIcon}),a("h3",{children:"No results found"}),a("p",{children:"Try adjusting your search or filters to find what you're looking for."})]}),E.length>0&&a("div",{className:t.bottomPagination,children:a(te,{page:v,canGoNext:X,onChange:Q,isLoading:T,variant:"labeled"})})]})}export{Je as default};
@@ -1,4 +1,4 @@
1
- import{d as r,u as e,S as le,A as X,h as z,q as pe,T as qe,p as ze,g as be,_ as Ke}from"./vendor-core-DfaOB3Rn.js";import{b as fe,u as ee}from"./vendor-query-BBT5_sHx.js";import{S as Z,U as Q,V as K,W as Ce,B as C,X as Ue,R as E,d as Ee,N as Te,t as k,v as Fe,o as $e,K as ke,Y as J,q as H,Z as Se,_ as We,$ as He,u as Be,e as je,a0 as Qe,L as de,p as Ve,a1 as Ye,a2 as Je}from"./index-CPhXtUuw.js";import{I as j}from"./vendor-icons-C1Pj_eSX.js";import{T as F}from"./ToggleSwitch-CN_ppEc9.js";import{l as Xe,s as Ze}from"./playbackCompletion-D1Gm0GbH.js";import{M as et}from"./MatureConsentModal-CEoZ_OA0.js";const tt="_sectionCard_1vuib_1",at="_dangerCard_1vuib_20",nt="_settingRow_1vuib_31",_={sectionCard:tt,dangerCard:at,settingRow:nt};function rt(){const{data:t}=fe(Z),{data:s}=fe({queryKey:["profiles"],queryFn:()=>Q("/api/profiles/status"),enabled:!!t?.owner}),c=ee(),[p,d]=r(null),[y,S]=r(""),[h,o]=r(""),[a,g]=r(""),[v,m]=r(""),[x,l]=r(""),[f,T]=r(!1),[I,G]=r(null),[P,w]=r(null),[L,A]=r(""),M=async i=>{T(!0),l("");try{await Q("/api/profiles/update",{method:"POST",body:JSON.stringify(i)}),await c.invalidateQueries({queryKey:Z.queryKey}),S(""),o(""),l("Profile saved")}catch(R){l(R.message)}finally{T(!1)}};return t?e("section",{className:_.sectionCard,children:[e("h3",{children:"Your profile"}),e("p",{children:"Keep using this profile, rename it, or add another person with their own library and connections."}),e("div",{className:K.avatarRow,children:[e(Ce,{image:t.image,name:t.name}),e("label",{className:K.uploadButton,children:[e(j,{name:"upload"}),e("span",{children:"Upload image"}),e("input",{className:K.fileInput,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",disabled:f,onChange:async i=>{const R=i.currentTarget.files?.[0];if(i.currentTarget.value="",!R)return;if(R.size>2*1024*1024){l("Image must be smaller than 2 MB");return}const D=new FileReader;D.onerror=()=>l("Could not read image"),D.onload=()=>{M({avatar:D.result})},D.readAsDataURL(R)}})]}),t.avatar&&e(C,{variant:"secondary",disabled:f,onClick:()=>M({avatar:null}),children:"Clear uploaded image"})]}),e("p",{children:"Your uploaded image takes priority, followed by your active cloud account image, then the default user icon."}),e("form",{className:K.form,onSubmit:i=>{i.preventDefault(),M({name:p??t.name})},children:[e("label",{className:K.field,children:["Profile name",e("input",{value:p??t.name,maxLength:60,required:!0,onChange:i=>d(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save name"})]}),e("form",{className:K.form,onSubmit:i=>{i.preventDefault(),M({password:y,currentPassword:h})},children:[t.protected&&e("label",{className:K.field,children:["Current password",e("input",{type:"password",autoComplete:"current-password",value:h,required:!0,maxLength:256,onChange:i=>o(i.currentTarget.value)})]}),e("label",{className:K.field,children:[t.protected?"New password (empty removes protection)":"Protect this profile",e("input",{type:"password",autoComplete:"new-password",value:y,minLength:8,maxLength:256,onChange:i=>S(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save password"})]}),e(C,{variant:"secondary",disabled:f,onClick:async()=>{T(!0);try{await Q("/api/profiles/logout",{method:"POST"}),Ue()}catch(i){l(i.message),T(!1)}},children:"Switch profile / sign out"}),t.owner&&e("form",{className:K.form,onSubmit:async i=>{i.preventDefault(),T(!0),l("");try{await Q("/api/profiles/create",{method:"POST",body:JSON.stringify({name:a,password:v})}),g(""),m(""),await c.invalidateQueries({queryKey:["profiles"]}),l("Profile created. Sign out to switch to it.")}catch(R){l(R.message)}finally{T(!1)}},children:[e("h3",{children:"Add another profile"}),e("p",{children:"Protect your owner profile first. New profiles start empty and do not inherit your accounts. A profile without a password is accessible to anyone who passes the LAN lock."}),e("label",{className:K.field,children:["Name",e("input",{required:!0,maxLength:60,value:a,onChange:i=>g(i.currentTarget.value)})]}),e("label",{className:K.field,children:["Password (optional)",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,value:v,onChange:i=>m(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f||!t.protected,children:"Create profile"})]}),t.owner&&s?.profiles.some(i=>!i.owner)&&e(le,{children:[e("h3",{children:"Other profiles"}),e("ul",{className:K.profileList,children:s.profiles.filter(i=>!i.owner).map(i=>e("li",{children:[e("span",{className:K.smallAvatar,children:e(Ce,{image:i.avatar??i.cloudAvatar,name:i.name})}),e("span",{className:K.profileName,children:i.name}),e(C,{variant:"secondary",size:"sm",disabled:f,onClick:()=>{l(""),A(""),w(i)},children:"Reset password"}),e(C,{variant:"danger",size:"sm",disabled:f,onClick:()=>{l(""),G(i)},children:"Delete"})]},i.id))})]}),e(E,{isOpen:!!P,onClose:f?void 0:()=>w(null),title:"Reset password",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>w(null),children:"Cancel"}),e(C,{loading:f,onClick:async()=>{if(P){T(!0),l("");try{await Q("/api/profiles/reset-password",{method:"POST",body:JSON.stringify({id:P.id,password:L})}),await c.invalidateQueries({queryKey:["profiles"]}),w(null),A(""),l("Password updated. The profile has been signed out.")}catch(i){l(i.message)}finally{T(!1)}}},children:"Save password"})]}),children:[e("p",{children:["Set a new password for ",e("strong",{children:P?.name}),". They will be signed out and must use the new password next time."]}),e("label",{className:K.field,children:["New password",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,placeholder:"Leave empty to remove their password",value:L,onChange:i=>A(i.currentTarget.value)})]})]}),e(E,{isOpen:!!I,onClose:f?void 0:()=>G(null),title:"Delete profile?",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>G(null),children:"Cancel"}),e(C,{variant:"danger",loading:f,onClick:async()=>{if(I){T(!0);try{await Q("/api/profiles/delete",{method:"POST",body:JSON.stringify({id:I.id,confirm:!0})}),await c.invalidateQueries({queryKey:["profiles"]}),G(null),l("Profile deleted. Local files will be removed when Dango restarts.")}catch(i){l(i.message),G(null)}finally{T(!1)}}},children:"Delete profile"})]}),children:[e("p",{children:["Delete ",e("strong",{children:I?.name}),"? This signs them out immediately. Their local libraries, settings and connections will be removed when Dango next restarts."]}),e("p",{children:"Cloud backups and tracker lists will stay intact. Export any library you want to keep before deleting."})]}),x&&e("p",{role:"status",children:x})]}):null}const ue={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},he=["name","nativeName","englishName"],ge={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},st=()=>{const{titlePreference:t,setTitlePreference:s,loading:c}=Ee(),p=Te(),[d,y]=r(ge[t]),[S,h]=r(!1),o=X(null);z(()=>{c||y(ge[t])},[t,c]);const a=async()=>{if(S)return;h(!0);const v=(he.indexOf(t)+1)%he.length,m=he[v],x=ge[m];o.current&&(o.current.style.transform="translateX(-100%)",o.current.style.opacity="0"),setTimeout(async()=>{y(x),s(m),o.current&&(o.current.style.transition="none",o.current.style.transform="translateX(100%)",o.current.style.opacity="0",o.current.offsetWidth,o.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",o.current.style.transform="translateX(0)",o.current.style.opacity="1");try{await p.mutateAsync({key:"titlePreference",value:m})}catch(l){console.error("Error saving title preference:",l)}finally{h(!1)}},300)};return c?e("p",{children:"Loading title preference..."}):e("div",{className:ue["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ue["toggle-button"],disabled:S,children:e("span",{ref:o,className:ue["toggle-label"],children:d})})]})},it="_settingsHeader_gfwoa_1",ot="_pageTitle_gfwoa_6",lt="_pageSubtitle_gfwoa_14",ct="_settingsLayout_gfwoa_20",dt="_sidebar_gfwoa_27",ut="_sidebarIndicator_gfwoa_35",ht="_sidebarItem_gfwoa_50",gt="_active_gfwoa_72",mt="_mainContent_gfwoa_80",pt="_tabContent_gfwoa_85",ft="_settingItem_gfwoa_103",yt="_shortcutContainer_gfwoa_108",vt="_shortcutGroup_gfwoa_115",wt="_shortcutGroupTitle_gfwoa_121",bt="_shortcutGrid_gfwoa_130",Ct="_shortcutCard_gfwoa_136",kt="_controls_gfwoa_170",St="_status_gfwoa_176",u={settingsHeader:it,pageTitle:ot,pageSubtitle:lt,settingsLayout:ct,sidebar:dt,sidebarIndicator:ut,sidebarItem:ht,active:gt,mainContent:mt,tabContent:pt,settingItem:ft,shortcutContainer:yt,shortcutGroup:vt,shortcutGroupTitle:wt,shortcutGrid:bt,shortcutCard:Ct,controls:kt,status:St},Nt="_title_tm30b_11",_t="_signIn_tm30b_18",Tt="_userInfo_tm30b_25",Pt="_warning_tm30b_47",It="_formGroup_tm30b_54",Lt="_label_tm30b_58",xt="_inputWrapper_tm30b_68",Rt="_input_tm30b_68",Dt="_select_tm30b_92",Ot="_actions_tm30b_109",At="_hr_tm30b_117",b={title:Nt,signIn:_t,userInfo:Tt,warning:Pt,formGroup:It,label:Lt,inputWrapper:xt,input:Rt,select:Dt,actions:Ot,hr:At},Mt=()=>{const t=ee(),[s,c]=r(!0),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(null),[a,g]=r({status:"idle"}),[v,m]=r(!1),[x,l]=r(""),[f,T]=r(!1),I=X(null),[G,P]=r({show:!1,message:"",type:"info"}),w=()=>{I.current&&(window.clearInterval(I.current),I.current=null)},L=pe(N=>{S(N.authenticated),o(N.user||N.device.user||null),g(N.device),m(!!N.hasCustomClientId)},[]),A=pe(async()=>{const N=await k.auth.githubStatus.query();L(N)},[L]),M=async()=>{try{const N=await k.auth.githubPoll.query();g(N),N.status==="success"?(w(),await t.invalidateQueries({queryKey:Z.queryKey}),await A(),P({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):N.status==="error"&&(w(),P({show:!0,message:N.error||"GitHub authentication failed.",type:"error"}))}catch{w(),P({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},i=(N=5)=>{w(),I.current=window.setInterval(M,Math.max(N,5)*1e3)};z(()=>(A().catch(()=>{P({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>c(!1)),w),[A]);const R=async()=>{d(!0);try{const N=await k.auth.githubStart.mutate();g(N),i(N.verification?.interval)}catch(N){P({show:!0,message:N instanceof Error?N.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},D=async()=>{try{await k.auth.githubLogout.mutate(),await t.invalidateQueries({queryKey:Z.queryKey}),S(!1),o(null),g({status:"idle"}),P({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{P({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},W=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:x}),l(""),await A(),P({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{P({show:!0,message:"Failed to save override.",type:"error"})}finally{T(!1)}},te=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:""}),l(""),await A(),P({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{P({show:!0,message:"Failed to clear override.",type:"error"})}finally{T(!1)}};return s?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"GitHub Cloud Sync"}),e("p",{className:b.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),y&&h?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:h.name||h.login})]}),e(C,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:b.signIn,children:e(C,{onClick:R,disabled:p||a.status==="pending",children:p||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(le,{children:[e("hr",{className:b.hr}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Verification URL"}),e("div",{className:b.inputWrapper,children:[e("input",{className:b.input,value:a.verification.verification_uri,readOnly:!0}),e(C,{onClick:()=>{const N=a.verification?.verification_uri;N&&/^https?:\/\//i.test(N)&&window.open(N,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Device Code"}),e("input",{className:b.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:b.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",v?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:x,onChange:N=>l(N.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:b.actions,children:[e(C,{onClick:W,disabled:f,children:"Save override"}),e(C,{variant:"secondary",onClick:te,disabled:f,children:"Use dango defaults"})]})]}),e(E,{isOpen:G.show,onClose:()=>P(N=>({...N,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:G.message})}),e(E.Actions,{children:e(C,{onClick:()=>P(N=>({...N,show:!1})),children:"OK"})})]})]})},Gt=()=>{const[t,s]=r(!0),[c,p]=r(null),[d,y]=r(!1),[S,h]=r(!1),[o,a]=r(""),[g,v]=r(""),[m,x]=r(""),[l,f]=r(!1),[T,I]=r({show:!1,message:"",type:"info"}),G=async()=>{try{const R=await k.auth.user.query();p(R?.email?R:null)}catch{p(null)}},P=async()=>{try{const[i,R]=await Promise.all([k.auth.configStatus.query(),k.auth.googleAuth.query()]);y(!!i.hasConfig),h(!!(R.hasCustomWorkerUrl||R.hasCustomClientId||R.hasClientSecret))}catch(i){console.error("Failed to fetch config status",i)}};z(()=>{(async()=>{s(!0),await Promise.all([G(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await G(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const R=D=>{D.origin===window.location.origin&&typeof D.data=="object"&&D.data!==null&&D.data.type==="GOOGLE_AUTH_SUCCESS"&&(p(D.data.user),window.location.reload())};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[]);const w=async()=>{try{const i=await k.auth.googleLogin.mutate();if(i.authenticated){window.location.reload();return}if(i.url){if(typeof window.DangoBridge<"u"){window.location.href=i.url;return}const D=600,W=700,te=window.innerWidth/2-D/2,N=window.innerHeight/2-W/2;window.open(i.url,"GoogleAuth",`width=${D},height=${W},top=${N},left=${te}`)}else throw new Error("Auth URL not available")}catch{I({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},L=async()=>{try{await k.auth.logout.mutate(),p(null),I({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(i){console.error("Sign out failed",i),I({show:!0,message:"Failed to sign out.",type:"error"})}},A=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:o,clientId:g,clientSecret:m}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{I({show:!0,message:"Failed to save override.",type:"error"})}finally{f(!1)}},M=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{I({show:!0,message:"Failed to clear override.",type:"error"})}finally{f(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Google Drive Sync"}),c?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:c.name})," (",c.email,")"]}),e(C,{variant:"danger",onClick:L,children:"Sign Out"})]}):e("div",{className:b.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(C,{onClick:w,disabled:!d,children:"Sign in with Google"}),!d&&e("p",{className:b.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",S?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Worker URL (optional)"}),e("input",{className:b.input,value:o,onChange:i=>a(i.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:g,onChange:i=>v(i.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:b.input,value:m,onChange:i=>x(i.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:b.actions,children:[e(C,{onClick:A,disabled:l,children:"Save override"}),e(C,{variant:"secondary",onClick:M,disabled:l,children:"Use dango defaults"})]})]}),e(E,{isOpen:T.show,onClose:()=>I(i=>({...i,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:T.message})}),e(E.Actions,{children:e(C,{onClick:()=>I(i=>({...i,show:!1})),children:"OK"})})]})]})},qt="_settingItem_3qq0n_1",zt="_modalOverlay_3qq0n_6",Kt="_modal_3qq0n_6",Ut="_modalActions_3qq0n_41",Et="_modalSecondary_3qq0n_47",Ft="_modalPrimary_3qq0n_57",B={settingItem:qt,modalOverlay:zt,modal:Kt,modalActions:Ut,modalSecondary:Et,modalPrimary:Ft},$t={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},Wt=(t,s)=>{if(t==null)return s;const c=String(t);return c==="true"||c==="1"?!0:c==="false"||c==="0"?!1:s},Ne=(t,s,c)=>{const[p,d]=r(s),[y,S]=r(!1),h=ee();return z(()=>{(async()=>{try{const g=await k.settings.getByKey.query({key:t});d(Wt(g.value,s))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,s]),{value:p,setValue:d,isUpdating:y,toggle:async()=>{if(y)return;S(!0);const a=!p;d(a);try{await k.settings.set.mutate({key:t,value:a});for(const g of c)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),d(!a)}finally{S(!1)}}}},Ht=()=>{const{contentType:t}=Fe(),s=$t[t],[c,p]=r(!1),[d,y]=r(!0),[S,h]=r(!1),o=Ne(s.ignoreKey,!0,s.invalidateKeys),a=Ne(s.listOnlyKey,!1,s.invalidateKeys),[g,v]=r(null),[m,x]=r(!1),l=ee(),f=$e();z(()=>{y(!0),(async()=>{try{const L=await k.settings.getByKey.query({key:s.skipKey});String(L.value)==="true"||String(L.value)==="1"?p(!0):p(!1)}catch(L){console.error("Failed to fetch setting",L)}finally{y(!1)}})()},[s.skipKey]);const T=async()=>{if(S)return;h(!0);const w=!c;p(w);try{await k.settings.set.mutate({key:s.skipKey,value:w})}catch(L){console.error("Error saving setting:",L),p(!w)}finally{h(!1)}},I=async()=>{if(!o.isUpdating){if(o.value)try{let w;if(t==="anime"?w=(await k.continueWatching.adultCount.query()).count:t==="manga"?w=(await k.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await k.asmrProgress.adultCount.query()).count:w=(await k.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){v(w);return}}catch(w){console.error("Failed to fetch adult count",w)}o.toggle()}},G=()=>{v(null),o.toggle()},P=async()=>{if(!m){x(!0);try{let w;t==="anime"?w=(await k.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await k.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await k.asmrProgress.purgeAdult.mutate()).removed:w=(await k.tvProgress.purgeAdult.mutate()).removed,ke.success(s.purgeDoneText(w??0));for(const L of s.invalidateKeys)l.invalidateQueries({queryKey:L});t==="anime"&&l.invalidateQueries(f.continueWatching.pathFilter()),t==="manga"&&l.invalidateQueries(f.mangaProgress.pathFilter()),t==="asmr"&&l.invalidateQueries(f.asmrProgress.pathFilter()),t==="tv"&&l.invalidateQueries(f.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),ke.error("Failed to remove adult entries")}finally{x(!1),v(null)}o.toggle()}};return d?e("div",{children:"Loading settings..."}):e("div",{className:_.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(F,{isChecked:c,onChange:T,id:"skip-confirmation-toggle",disabled:S})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(F,{isChecked:o.value,onChange:I,id:"ignore-adult-toggle",disabled:o.isUpdating})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(F,{isChecked:a.value,onChange:a.toggle,id:"cw-watchlist-only-toggle",disabled:a.isUpdating})]})}),g!==null&&e("div",{className:B.modalOverlay,onClick:()=>v(null),children:e("div",{className:B.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",s.listNoun," ",g===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:B.modalActions,children:[e("button",{type:"button",className:B.modalSecondary,onClick:G,disabled:m,children:"Show them"}),e("button",{type:"button",className:B.modalPrimary,onClick:P,disabled:m,children:m?"Purging...":`Purge ${g}`})]})]})})]})},Bt="_statsGrid_o4nf0_1",jt="_statCard_o4nf0_8",Qt="_statLabel_o4nf0_18",Vt="_statValue_o4nf0_26",Yt="_statMeta_o4nf0_32",Jt="_statusBanner_o4nf0_38",Xt="_statusSuccess_o4nf0_49",Zt="_statusUpdating_o4nf0_55",ea="_statusError_o4nf0_61",ta="_sha_o4nf0_67",aa="_settingItem_o4nf0_74",na="_settingTitle_o4nf0_79",ra="_settingSubtitle_o4nf0_85",sa="_actionsRow_o4nf0_92",O={statsGrid:Bt,statCard:jt,statLabel:Qt,statValue:Vt,statMeta:Yt,statusBanner:Jt,statusSuccess:Xt,statusUpdating:Zt,statusError:ea,sha:ta,settingItem:aa,settingTitle:na,settingSubtitle:ra,actionsRow:sa},ia=()=>{const[t,s]=r(null),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r(!1),o=X(null),a=async()=>{try{const l=await k.settings.offlineDbInfo.query();return s(l),l}catch(l){console.error("Failed to fetch offline DB info:",l)}finally{p(!1)}return null};z(()=>(a(),()=>{o.current&&window.clearInterval(o.current)}),[]),z(()=>{t?.isRefreshing?o.current||(o.current=window.setInterval(async()=>{const l=await a();l&&!l.isRefreshing&&o.current&&(window.clearInterval(o.current),o.current=null)},2e3)):o.current&&(window.clearInterval(o.current),o.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||d)return;const l=!t.autoUpdateEnabled;y(!0),s({...t,autoUpdateEnabled:l});try{await k.settings.setOfflineDbAutoUpdate.mutate({enabled:l})}catch(f){console.error("Failed to update auto update setting:",f),s({...t,autoUpdateEnabled:!l})}finally{y(!1)}},v=async()=>{if(!(t?.isRefreshing||S)){h(!0);try{await k.settings.triggerOfflineDbUpdate.mutate(),s(l=>l?{...l,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(l){console.error("Failed to trigger offline DB update:",l)}finally{h(!1)}}},m=l=>{if(!l)return"Never";try{return new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return l}},x=t?.isRefreshing||S;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:O.statsGrid,children:[e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"MAL Mapped"}),e("span",{className:O.statValue,children:c?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Release"}),e("span",{className:O.statMeta,children:c?"-":t?.releaseTag??"Never"})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Checked"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastCheckedAt??null)})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Updated"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${O.statusBanner} ${t.lastStatus==="failed"?O.statusError:t.lastStatus==="updating"?O.statusUpdating:O.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:O.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:O.settingItem,children:e("div",{className:_.settingRow,children:[e("div",{children:[e("span",{className:O.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:O.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(F,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:c||d})]})}),e("div",{className:O.actionsRow,children:e(C,{onClick:v,disabled:c||x,children:x?"Updating Database...":"Update Offline Database Now"})})]})},oa="_status_1wbo0_1",la="_warningText_1wbo0_7",ca="_ackLabel_1wbo0_11",me={status:oa,warningText:la,ackLabel:ca},da=()=>{const t=ee(),[s,c]=r(!1),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(""),a=()=>{d(!1),o(""),c(!0)},g=()=>{y||(c(!1),d(!1))},v=async()=>{if(!(!p||y)){S(!0),o("");try{const m=await J("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),x=await m.json();if(!m.ok)throw new Error(x.error||"Failed to clear database");const l=x.deleted,f=x.deletedManga,T=x.deletedTv,I=x.deletedAsmr,G=Object.values(l).reduce((A,M)=>A+(M||0),0)+Object.values(f??{}).reduce((A,M)=>A+(M||0),0)+Object.values(T??{}).reduce((A,M)=>A+(M||0),0)+Object.values(I??{}).reduce((A,M)=>A+(M||0),0),P=(f?.manga_library??0)+(f?.manga_progress??0),w=(T?.tv_library??0)+(T?.tv_progress??0),L=(I?.asmr_library??0)+(I?.asmr_progress??0);o(`Library cleared - ${l.watchlist??0} watchlist entries, ${P} manga rows, ${w} TV rows, ${L} ASMR rows and ${G} total rows removed.`),t.invalidateQueries({queryKey:[H.watchlist]}),t.invalidateQueries({queryKey:[H.continueWatching]}),t.invalidateQueries({queryKey:[H.mangaLibrary]}),t.invalidateQueries({queryKey:[H.mangaContinueReading]}),t.invalidateQueries({queryKey:[H.tvLibrary]}),t.invalidateQueries({queryKey:[H.tvContinueWatching]}),t.invalidateQueries({queryKey:[H.asmrLibrary]}),t.invalidateQueries({queryKey:[H.asmrContinueListening]}),c(!1)}catch(m){o(m.message)}finally{S(!1),d(!1)}}};return e("div",{className:`${_.sectionCard} ${_.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(C,{variant:"danger",onClick:a,children:"Clear Library Data"}),h&&e("p",{className:me.status,children:h}),e(E,{isOpen:s,onClose:g,title:"Clear library data?",width:"sm",children:[e(E.Body,{children:[e("p",{className:me.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:me.ackLabel,children:[e("input",{type:"checkbox",checked:p,onChange:m=>d(m.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(E.Actions,{children:[e(C,{variant:"secondary",onClick:g,disabled:y,children:"Cancel"}),e(C,{variant:"danger",onClick:v,disabled:!p||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},ua=()=>{const[t,s]=r(""),[c,p]=r([]),[d,y]=r(null),[S,h]=r(!0),[o,a]=r({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const m=await k.auth.rcloneSettings.query();s(m.remote||""),p(m.availableRemotes||[]),y(m.activeRemote||null)}catch(m){console.error("Failed to fetch Rclone settings",m)}finally{h(!1)}};z(()=>{g()},[]);const v=async()=>{try{await k.auth.saveRclone.mutate({remote:t}),a({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g()}catch{a({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return S?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Rclone Cloud Sync"}),e("p",{className:b.signIn,children:"Configure which Rclone remote to use for database synchronization."}),d?e("div",{className:b.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:d})]})}):e("p",{className:b.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Remote Name"}),e("div",{className:b.inputWrapper,children:e("select",{className:b.select,value:t,onChange:m=>s(m.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),c.map(m=>e("option",{value:m,children:m},m)),t&&!c.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:b.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:b.actions,children:e(C,{onClick:v,children:"Save Rclone Settings"})}),e(E,{isOpen:o.show,onClose:()=>a(m=>({...m,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:o.message})}),e(E.Actions,{children:e(C,{onClick:()=>a(m=>({...m,show:!1})),children:"OK"})})]})]})},ha=()=>{const t=ee(),[s,c]=r(null),[p,d]=r(!0),y=async()=>{try{const a=await k.auth.syncSettings.query();c(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};z(()=>{y()},[]);const S=async a=>{const g=a.currentTarget.value;try{const v=await k.auth.saveSyncProvider.mutate({provider:g});c(m=>m?{...m,activeProvider:v.activeProvider}:null),await y(),await t.invalidateQueries({queryKey:Z.queryKey}),Se.success(`Sync provider updated to ${g==="default"?"Default Order":g}`)}catch{Se.error("Failed to update sync provider")}};if(p||!s)return null;const h=[{value:"default",label:"Default (Priority Based)"}];s.authenticatedProviders.github&&h.push({value:"github",label:"GitHub"}),s.authenticatedProviders.google&&h.push({value:"google",label:"Google Drive"}),s.authenticatedProviders.rclone&&h.push({value:"rclone",label:"Rclone"}),h.push({value:"none",label:"None (Local Only)"});const o=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:o(s.actualActiveProvider)})]}),e("div",{className:_.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:s.activeProvider,onChange:S,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:h.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ga(){return"javascript:"+encodeURIComponent(`(function(){
1
+ import{d as r,u as e,S as le,A as X,h as z,q as pe,T as qe,p as ze,g as be,_ as Ke}from"./vendor-core-DfaOB3Rn.js";import{b as fe,u as ee}from"./vendor-query-BBT5_sHx.js";import{S as Z,U as Q,V as K,W as Ce,B as C,X as Ue,R as E,d as Ee,N as Te,t as k,v as Fe,o as $e,K as ke,Y as J,q as H,Z as Se,_ as We,$ as He,u as Be,e as je,a0 as Qe,L as de,p as Ve,a1 as Ye,a2 as Je}from"./index-CkZCduQZ.js";import{I as j}from"./vendor-icons-C1Pj_eSX.js";import{T as F}from"./ToggleSwitch-CN_ppEc9.js";import{l as Xe,s as Ze}from"./playbackCompletion-BTwrTq5S.js";import{M as et}from"./MatureConsentModal-BuJjdQ5N.js";const tt="_sectionCard_1vuib_1",at="_dangerCard_1vuib_20",nt="_settingRow_1vuib_31",_={sectionCard:tt,dangerCard:at,settingRow:nt};function rt(){const{data:t}=fe(Z),{data:s}=fe({queryKey:["profiles"],queryFn:()=>Q("/api/profiles/status"),enabled:!!t?.owner}),c=ee(),[p,d]=r(null),[y,S]=r(""),[h,o]=r(""),[a,g]=r(""),[v,m]=r(""),[x,l]=r(""),[f,T]=r(!1),[I,G]=r(null),[P,w]=r(null),[L,A]=r(""),M=async i=>{T(!0),l("");try{await Q("/api/profiles/update",{method:"POST",body:JSON.stringify(i)}),await c.invalidateQueries({queryKey:Z.queryKey}),S(""),o(""),l("Profile saved")}catch(R){l(R.message)}finally{T(!1)}};return t?e("section",{className:_.sectionCard,children:[e("h3",{children:"Your profile"}),e("p",{children:"Keep using this profile, rename it, or add another person with their own library and connections."}),e("div",{className:K.avatarRow,children:[e(Ce,{image:t.image,name:t.name}),e("label",{className:K.uploadButton,children:[e(j,{name:"upload"}),e("span",{children:"Upload image"}),e("input",{className:K.fileInput,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",disabled:f,onChange:async i=>{const R=i.currentTarget.files?.[0];if(i.currentTarget.value="",!R)return;if(R.size>2*1024*1024){l("Image must be smaller than 2 MB");return}const D=new FileReader;D.onerror=()=>l("Could not read image"),D.onload=()=>{M({avatar:D.result})},D.readAsDataURL(R)}})]}),t.avatar&&e(C,{variant:"secondary",disabled:f,onClick:()=>M({avatar:null}),children:"Clear uploaded image"})]}),e("p",{children:"Your uploaded image takes priority, followed by your active cloud account image, then the default user icon."}),e("form",{className:K.form,onSubmit:i=>{i.preventDefault(),M({name:p??t.name})},children:[e("label",{className:K.field,children:["Profile name",e("input",{value:p??t.name,maxLength:60,required:!0,onChange:i=>d(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save name"})]}),e("form",{className:K.form,onSubmit:i=>{i.preventDefault(),M({password:y,currentPassword:h})},children:[t.protected&&e("label",{className:K.field,children:["Current password",e("input",{type:"password",autoComplete:"current-password",value:h,required:!0,maxLength:256,onChange:i=>o(i.currentTarget.value)})]}),e("label",{className:K.field,children:[t.protected?"New password (empty removes protection)":"Protect this profile",e("input",{type:"password",autoComplete:"new-password",value:y,minLength:8,maxLength:256,onChange:i=>S(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f,children:"Save password"})]}),e(C,{variant:"secondary",disabled:f,onClick:async()=>{T(!0);try{await Q("/api/profiles/logout",{method:"POST"}),Ue()}catch(i){l(i.message),T(!1)}},children:"Switch profile / sign out"}),t.owner&&e("form",{className:K.form,onSubmit:async i=>{i.preventDefault(),T(!0),l("");try{await Q("/api/profiles/create",{method:"POST",body:JSON.stringify({name:a,password:v})}),g(""),m(""),await c.invalidateQueries({queryKey:["profiles"]}),l("Profile created. Sign out to switch to it.")}catch(R){l(R.message)}finally{T(!1)}},children:[e("h3",{children:"Add another profile"}),e("p",{children:"Protect your owner profile first. New profiles start empty and do not inherit your accounts. A profile without a password is accessible to anyone who passes the LAN lock."}),e("label",{className:K.field,children:["Name",e("input",{required:!0,maxLength:60,value:a,onChange:i=>g(i.currentTarget.value)})]}),e("label",{className:K.field,children:["Password (optional)",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,value:v,onChange:i=>m(i.currentTarget.value)})]}),e(C,{type:"submit",disabled:f||!t.protected,children:"Create profile"})]}),t.owner&&s?.profiles.some(i=>!i.owner)&&e(le,{children:[e("h3",{children:"Other profiles"}),e("ul",{className:K.profileList,children:s.profiles.filter(i=>!i.owner).map(i=>e("li",{children:[e("span",{className:K.smallAvatar,children:e(Ce,{image:i.avatar??i.cloudAvatar,name:i.name})}),e("span",{className:K.profileName,children:i.name}),e(C,{variant:"secondary",size:"sm",disabled:f,onClick:()=>{l(""),A(""),w(i)},children:"Reset password"}),e(C,{variant:"danger",size:"sm",disabled:f,onClick:()=>{l(""),G(i)},children:"Delete"})]},i.id))})]}),e(E,{isOpen:!!P,onClose:f?void 0:()=>w(null),title:"Reset password",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>w(null),children:"Cancel"}),e(C,{loading:f,onClick:async()=>{if(P){T(!0),l("");try{await Q("/api/profiles/reset-password",{method:"POST",body:JSON.stringify({id:P.id,password:L})}),await c.invalidateQueries({queryKey:["profiles"]}),w(null),A(""),l("Password updated. The profile has been signed out.")}catch(i){l(i.message)}finally{T(!1)}}},children:"Save password"})]}),children:[e("p",{children:["Set a new password for ",e("strong",{children:P?.name}),". They will be signed out and must use the new password next time."]}),e("label",{className:K.field,children:["New password",e("input",{type:"password",autoComplete:"new-password",minLength:8,maxLength:256,placeholder:"Leave empty to remove their password",value:L,onChange:i=>A(i.currentTarget.value)})]})]}),e(E,{isOpen:!!I,onClose:f?void 0:()=>G(null),title:"Delete profile?",width:"sm",footer:e(le,{children:[e(C,{variant:"secondary",disabled:f,onClick:()=>G(null),children:"Cancel"}),e(C,{variant:"danger",loading:f,onClick:async()=>{if(I){T(!0);try{await Q("/api/profiles/delete",{method:"POST",body:JSON.stringify({id:I.id,confirm:!0})}),await c.invalidateQueries({queryKey:["profiles"]}),G(null),l("Profile deleted. Local files will be removed when Dango restarts.")}catch(i){l(i.message),G(null)}finally{T(!1)}}},children:"Delete profile"})]}),children:[e("p",{children:["Delete ",e("strong",{children:I?.name}),"? This signs them out immediately. Their local libraries, settings and connections will be removed when Dango next restarts."]}),e("p",{children:"Cloud backups and tracker lists will stay intact. Export any library you want to keep before deleting."})]}),x&&e("p",{role:"status",children:x})]}):null}const ue={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},he=["name","nativeName","englishName"],ge={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},st=()=>{const{titlePreference:t,setTitlePreference:s,loading:c}=Ee(),p=Te(),[d,y]=r(ge[t]),[S,h]=r(!1),o=X(null);z(()=>{c||y(ge[t])},[t,c]);const a=async()=>{if(S)return;h(!0);const v=(he.indexOf(t)+1)%he.length,m=he[v],x=ge[m];o.current&&(o.current.style.transform="translateX(-100%)",o.current.style.opacity="0"),setTimeout(async()=>{y(x),s(m),o.current&&(o.current.style.transition="none",o.current.style.transform="translateX(100%)",o.current.style.opacity="0",o.current.offsetWidth,o.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",o.current.style.transform="translateX(0)",o.current.style.opacity="1");try{await p.mutateAsync({key:"titlePreference",value:m})}catch(l){console.error("Error saving title preference:",l)}finally{h(!1)}},300)};return c?e("p",{children:"Loading title preference..."}):e("div",{className:ue["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ue["toggle-button"],disabled:S,children:e("span",{ref:o,className:ue["toggle-label"],children:d})})]})},it="_settingsHeader_gfwoa_1",ot="_pageTitle_gfwoa_6",lt="_pageSubtitle_gfwoa_14",ct="_settingsLayout_gfwoa_20",dt="_sidebar_gfwoa_27",ut="_sidebarIndicator_gfwoa_35",ht="_sidebarItem_gfwoa_50",gt="_active_gfwoa_72",mt="_mainContent_gfwoa_80",pt="_tabContent_gfwoa_85",ft="_settingItem_gfwoa_103",yt="_shortcutContainer_gfwoa_108",vt="_shortcutGroup_gfwoa_115",wt="_shortcutGroupTitle_gfwoa_121",bt="_shortcutGrid_gfwoa_130",Ct="_shortcutCard_gfwoa_136",kt="_controls_gfwoa_170",St="_status_gfwoa_176",u={settingsHeader:it,pageTitle:ot,pageSubtitle:lt,settingsLayout:ct,sidebar:dt,sidebarIndicator:ut,sidebarItem:ht,active:gt,mainContent:mt,tabContent:pt,settingItem:ft,shortcutContainer:yt,shortcutGroup:vt,shortcutGroupTitle:wt,shortcutGrid:bt,shortcutCard:Ct,controls:kt,status:St},Nt="_title_tm30b_11",_t="_signIn_tm30b_18",Tt="_userInfo_tm30b_25",Pt="_warning_tm30b_47",It="_formGroup_tm30b_54",Lt="_label_tm30b_58",xt="_inputWrapper_tm30b_68",Rt="_input_tm30b_68",Dt="_select_tm30b_92",Ot="_actions_tm30b_109",At="_hr_tm30b_117",b={title:Nt,signIn:_t,userInfo:Tt,warning:Pt,formGroup:It,label:Lt,inputWrapper:xt,input:Rt,select:Dt,actions:Ot,hr:At},Mt=()=>{const t=ee(),[s,c]=r(!0),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(null),[a,g]=r({status:"idle"}),[v,m]=r(!1),[x,l]=r(""),[f,T]=r(!1),I=X(null),[G,P]=r({show:!1,message:"",type:"info"}),w=()=>{I.current&&(window.clearInterval(I.current),I.current=null)},L=pe(N=>{S(N.authenticated),o(N.user||N.device.user||null),g(N.device),m(!!N.hasCustomClientId)},[]),A=pe(async()=>{const N=await k.auth.githubStatus.query();L(N)},[L]),M=async()=>{try{const N=await k.auth.githubPoll.query();g(N),N.status==="success"?(w(),await t.invalidateQueries({queryKey:Z.queryKey}),await A(),P({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):N.status==="error"&&(w(),P({show:!0,message:N.error||"GitHub authentication failed.",type:"error"}))}catch{w(),P({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},i=(N=5)=>{w(),I.current=window.setInterval(M,Math.max(N,5)*1e3)};z(()=>(A().catch(()=>{P({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>c(!1)),w),[A]);const R=async()=>{d(!0);try{const N=await k.auth.githubStart.mutate();g(N),i(N.verification?.interval)}catch(N){P({show:!0,message:N instanceof Error?N.message:"Failed to start GitHub authentication.",type:"error"})}finally{d(!1)}},D=async()=>{try{await k.auth.githubLogout.mutate(),await t.invalidateQueries({queryKey:Z.queryKey}),S(!1),o(null),g({status:"idle"}),P({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{P({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},W=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:x}),l(""),await A(),P({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{P({show:!0,message:"Failed to save override.",type:"error"})}finally{T(!1)}},te=async()=>{T(!0);try{await k.auth.saveGithubAuth.mutate({clientId:""}),l(""),await A(),P({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{P({show:!0,message:"Failed to clear override.",type:"error"})}finally{T(!1)}};return s?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"GitHub Cloud Sync"}),e("p",{className:b.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),y&&h?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:h.name||h.login})]}),e(C,{variant:"danger",onClick:D,children:"Sign Out"})]}):e("div",{className:b.signIn,children:e(C,{onClick:R,disabled:p||a.status==="pending",children:p||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(le,{children:[e("hr",{className:b.hr}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Verification URL"}),e("div",{className:b.inputWrapper,children:[e("input",{className:b.input,value:a.verification.verification_uri,readOnly:!0}),e(C,{onClick:()=>{const N=a.verification?.verification_uri;N&&/^https?:\/\//i.test(N)&&window.open(N,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Device Code"}),e("input",{className:b.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:b.warning,children:a.error}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",v?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:x,onChange:N=>l(N.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:b.actions,children:[e(C,{onClick:W,disabled:f,children:"Save override"}),e(C,{variant:"secondary",onClick:te,disabled:f,children:"Use dango defaults"})]})]}),e(E,{isOpen:G.show,onClose:()=>P(N=>({...N,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:G.message})}),e(E.Actions,{children:e(C,{onClick:()=>P(N=>({...N,show:!1})),children:"OK"})})]})]})},Gt=()=>{const[t,s]=r(!0),[c,p]=r(null),[d,y]=r(!1),[S,h]=r(!1),[o,a]=r(""),[g,v]=r(""),[m,x]=r(""),[l,f]=r(!1),[T,I]=r({show:!1,message:"",type:"info"}),G=async()=>{try{const R=await k.auth.user.query();p(R?.email?R:null)}catch{p(null)}},P=async()=>{try{const[i,R]=await Promise.all([k.auth.configStatus.query(),k.auth.googleAuth.query()]);y(!!i.hasConfig),h(!!(R.hasCustomWorkerUrl||R.hasCustomClientId||R.hasClientSecret))}catch(i){console.error("Failed to fetch config status",i)}};z(()=>{(async()=>{s(!0),await Promise.all([G(),P()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await G(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const R=D=>{D.origin===window.location.origin&&typeof D.data=="object"&&D.data!==null&&D.data.type==="GOOGLE_AUTH_SUCCESS"&&(p(D.data.user),window.location.reload())};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[]);const w=async()=>{try{const i=await k.auth.googleLogin.mutate();if(i.authenticated){window.location.reload();return}if(i.url){if(typeof window.DangoBridge<"u"){window.location.href=i.url;return}const D=600,W=700,te=window.innerWidth/2-D/2,N=window.innerHeight/2-W/2;window.open(i.url,"GoogleAuth",`width=${D},height=${W},top=${N},left=${te}`)}else throw new Error("Auth URL not available")}catch{I({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},L=async()=>{try{await k.auth.logout.mutate(),p(null),I({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(i){console.error("Sign out failed",i),I({show:!0,message:"Failed to sign out.",type:"error"})}},A=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:o,clientId:g,clientSecret:m}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{I({show:!0,message:"Failed to save override.",type:"error"})}finally{f(!1)}},M=async()=>{f(!0);try{await k.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),a(""),v(""),x(""),await P(),I({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{I({show:!0,message:"Failed to clear override.",type:"error"})}finally{f(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Google Drive Sync"}),c?e("div",{className:b.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:c.name})," (",c.email,")"]}),e(C,{variant:"danger",onClick:L,children:"Sign Out"})]}):e("div",{className:b.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(C,{onClick:w,disabled:!d,children:"Sign in with Google"}),!d&&e("p",{className:b.warning,children:"Google sync is not configured on the server."})]}),e("details",{style:{marginTop:"1rem",fontSize:"var(--font-size-sm)"},children:[e("summary",{style:{cursor:"pointer",color:"var(--text-secondary)"},children:["Advanced: use your own auth ",S?"(override active)":""]}),e("div",{className:b.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:b.label,children:"Worker URL (optional)"}),e("input",{className:b.input,value:o,onChange:i=>a(i.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client ID (optional)"}),e("input",{className:b.input,value:g,onChange:i=>v(i.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:b.input,value:m,onChange:i=>x(i.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:b.actions,children:[e(C,{onClick:A,disabled:l,children:"Save override"}),e(C,{variant:"secondary",onClick:M,disabled:l,children:"Use dango defaults"})]})]}),e(E,{isOpen:T.show,onClose:()=>I(i=>({...i,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:T.message})}),e(E.Actions,{children:e(C,{onClick:()=>I(i=>({...i,show:!1})),children:"OK"})})]})]})},qt="_settingItem_3qq0n_1",zt="_modalOverlay_3qq0n_6",Kt="_modal_3qq0n_6",Ut="_modalActions_3qq0n_41",Et="_modalSecondary_3qq0n_47",Ft="_modalPrimary_3qq0n_57",B={settingItem:qt,modalOverlay:zt,modal:Kt,modalActions:Ut,modalSecondary:Et,modalPrimary:Ft},$t={anime:{heading:"Watchlist Preferences",blurb:"Customize your experience when managing your watchlist and series entries.",skipKey:"skipRemoveConfirmation",ignoreKey:"ignoreAdultContent",listOnlyKey:"cwWatchlistOnly",skipLabel:"Skip confirmation when removing from watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in watchlist",listNoun:"watchlist",continueNoun:"continue watching",adultCountUrl:"/api/continue-watching/adult-count",purgeUrl:"/api/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["allContinueWatching"]]},manga:{heading:"Reading List Preferences",blurb:"Customize your experience when managing your reading list and manga entries.",skipKey:"mangaSkipRemoveConfirmation",ignoreKey:"mangaIgnoreAdultContent",listOnlyKey:"mangaCwWatchlistOnly",skipLabel:"Skip confirmation when removing from reading list",ignoreLabel:"Hide adult content from continue reading",listOnlyLabel:"Only show continue reading for manga in reading list",listNoun:"reading list",continueNoun:"continue reading",adultCountUrl:"/api/manga/continue-reading/adult-count",purgeUrl:"/api/manga/continue-reading/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue reading`,invalidateKeys:[["manga-continue-reading"]]},tv:{heading:"TV Watchlist Preferences",blurb:"Customize your experience when managing your TV watchlist and series entries.",skipKey:"tvSkipRemoveConfirmation",ignoreKey:"tvIgnoreAdultContent",listOnlyKey:"tvCwWatchlistOnly",skipLabel:"Skip confirmation when removing from TV watchlist",ignoreLabel:"Hide adult content from continue watching",listOnlyLabel:"Only show continue watching for shows in TV watchlist",listNoun:"TV watchlist",continueNoun:"continue watching",adultCountUrl:"/api/tv/continue-watching/adult-count",purgeUrl:"/api/tv/continue-watching/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue watching`,invalidateKeys:[["tv-continue-watching"]]},asmr:{heading:"Listening List Preferences",blurb:"Customize your experience when managing your listening list and work entries.",skipKey:"asmrSkipRemoveConfirmation",ignoreKey:"asmrIgnoreAdultContent",listOnlyKey:"asmrCwWatchlistOnly",skipLabel:"Skip confirmation when removing from listening list",ignoreLabel:"Hide adult content from continue listening",listOnlyLabel:"Only show continue listening for works in listening list",listNoun:"listening list",continueNoun:"continue listening",adultCountUrl:"/api/asmr/continue-listening/adult-count",purgeUrl:"/api/asmr/continue-listening/purge-adult",purgeDoneText:t=>`Removed ${t??0} entries from continue listening`,invalidateKeys:[["asmr-continue-listening"]]}},Wt=(t,s)=>{if(t==null)return s;const c=String(t);return c==="true"||c==="1"?!0:c==="false"||c==="0"?!1:s},Ne=(t,s,c)=>{const[p,d]=r(s),[y,S]=r(!1),h=ee();return z(()=>{(async()=>{try{const g=await k.settings.getByKey.query({key:t});d(Wt(g.value,s))}catch(g){console.error("Failed to fetch setting",g)}})()},[t,s]),{value:p,setValue:d,isUpdating:y,toggle:async()=>{if(y)return;S(!0);const a=!p;d(a);try{await k.settings.set.mutate({key:t,value:a});for(const g of c)h.invalidateQueries({queryKey:g})}catch(g){console.error("Error saving setting:",g),d(!a)}finally{S(!1)}}}},Ht=()=>{const{contentType:t}=Fe(),s=$t[t],[c,p]=r(!1),[d,y]=r(!0),[S,h]=r(!1),o=Ne(s.ignoreKey,!0,s.invalidateKeys),a=Ne(s.listOnlyKey,!1,s.invalidateKeys),[g,v]=r(null),[m,x]=r(!1),l=ee(),f=$e();z(()=>{y(!0),(async()=>{try{const L=await k.settings.getByKey.query({key:s.skipKey});String(L.value)==="true"||String(L.value)==="1"?p(!0):p(!1)}catch(L){console.error("Failed to fetch setting",L)}finally{y(!1)}})()},[s.skipKey]);const T=async()=>{if(S)return;h(!0);const w=!c;p(w);try{await k.settings.set.mutate({key:s.skipKey,value:w})}catch(L){console.error("Error saving setting:",L),p(!w)}finally{h(!1)}},I=async()=>{if(!o.isUpdating){if(o.value)try{let w;if(t==="anime"?w=(await k.continueWatching.adultCount.query()).count:t==="manga"?w=(await k.mangaProgress.adultCount.query()).count:t==="asmr"?w=(await k.asmrProgress.adultCount.query()).count:w=(await k.tvProgress.adultCount.query()).count,typeof w=="number"&&w>0){v(w);return}}catch(w){console.error("Failed to fetch adult count",w)}o.toggle()}},G=()=>{v(null),o.toggle()},P=async()=>{if(!m){x(!0);try{let w;t==="anime"?w=(await k.continueWatching.purgeAdult.mutate()).removed:t==="manga"?w=(await k.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?w=(await k.asmrProgress.purgeAdult.mutate()).removed:w=(await k.tvProgress.purgeAdult.mutate()).removed,ke.success(s.purgeDoneText(w??0));for(const L of s.invalidateKeys)l.invalidateQueries({queryKey:L});t==="anime"&&l.invalidateQueries(f.continueWatching.pathFilter()),t==="manga"&&l.invalidateQueries(f.mangaProgress.pathFilter()),t==="asmr"&&l.invalidateQueries(f.asmrProgress.pathFilter()),t==="tv"&&l.invalidateQueries(f.tvProgress.pathFilter())}catch(w){console.error("Failed to purge adult entries",w),ke.error("Failed to remove adult entries")}finally{x(!1),v(null)}o.toggle()}};return d?e("div",{children:"Loading settings..."}):e("div",{className:_.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(F,{isChecked:c,onChange:T,id:"skip-confirmation-toggle",disabled:S})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(F,{isChecked:o.value,onChange:I,id:"ignore-adult-toggle",disabled:o.isUpdating})]})}),e("div",{className:B.settingItem,children:e("div",{className:_.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(F,{isChecked:a.value,onChange:a.toggle,id:"cw-watchlist-only-toggle",disabled:a.isUpdating})]})}),g!==null&&e("div",{className:B.modalOverlay,onClick:()=>v(null),children:e("div",{className:B.modal,onClick:w=>w.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[g," adult ",g===1?"entry":"entries"," not in your"," ",s.listNoun," ",g===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",g===1?"it":"them"," from the database instead of showing ",g===1?"it":"them","."]}),e("div",{className:B.modalActions,children:[e("button",{type:"button",className:B.modalSecondary,onClick:G,disabled:m,children:"Show them"}),e("button",{type:"button",className:B.modalPrimary,onClick:P,disabled:m,children:m?"Purging...":`Purge ${g}`})]})]})})]})},Bt="_statsGrid_o4nf0_1",jt="_statCard_o4nf0_8",Qt="_statLabel_o4nf0_18",Vt="_statValue_o4nf0_26",Yt="_statMeta_o4nf0_32",Jt="_statusBanner_o4nf0_38",Xt="_statusSuccess_o4nf0_49",Zt="_statusUpdating_o4nf0_55",ea="_statusError_o4nf0_61",ta="_sha_o4nf0_67",aa="_settingItem_o4nf0_74",na="_settingTitle_o4nf0_79",ra="_settingSubtitle_o4nf0_85",sa="_actionsRow_o4nf0_92",O={statsGrid:Bt,statCard:jt,statLabel:Qt,statValue:Vt,statMeta:Yt,statusBanner:Jt,statusSuccess:Xt,statusUpdating:Zt,statusError:ea,sha:ta,settingItem:aa,settingTitle:na,settingSubtitle:ra,actionsRow:sa},ia=()=>{const[t,s]=r(null),[c,p]=r(!0),[d,y]=r(!1),[S,h]=r(!1),o=X(null),a=async()=>{try{const l=await k.settings.offlineDbInfo.query();return s(l),l}catch(l){console.error("Failed to fetch offline DB info:",l)}finally{p(!1)}return null};z(()=>(a(),()=>{o.current&&window.clearInterval(o.current)}),[]),z(()=>{t?.isRefreshing?o.current||(o.current=window.setInterval(async()=>{const l=await a();l&&!l.isRefreshing&&o.current&&(window.clearInterval(o.current),o.current=null)},2e3)):o.current&&(window.clearInterval(o.current),o.current=null)},[t?.isRefreshing]);const g=async()=>{if(!t||d)return;const l=!t.autoUpdateEnabled;y(!0),s({...t,autoUpdateEnabled:l});try{await k.settings.setOfflineDbAutoUpdate.mutate({enabled:l})}catch(f){console.error("Failed to update auto update setting:",f),s({...t,autoUpdateEnabled:!l})}finally{y(!1)}},v=async()=>{if(!(t?.isRefreshing||S)){h(!0);try{await k.settings.triggerOfflineDbUpdate.mutate(),s(l=>l?{...l,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(l){console.error("Failed to trigger offline DB update:",l)}finally{h(!1)}}},m=l=>{if(!l)return"Never";try{return new Date(l).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return l}},x=t?.isRefreshing||S;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:O.statsGrid,children:[e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"MAL Mapped"}),e("span",{className:O.statValue,children:c?"-":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Release"}),e("span",{className:O.statMeta,children:c?"-":t?.releaseTag??"Never"})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Checked"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastCheckedAt??null)})]}),e("div",{className:O.statCard,children:[e("span",{className:O.statLabel,children:"Last Updated"}),e("span",{className:O.statMeta,children:c?"-":m(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${O.statusBanner} ${t.lastStatus==="failed"?O.statusError:t.lastStatus==="updating"?O.statusUpdating:O.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:O.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:O.settingItem,children:e("div",{className:_.settingRow,children:[e("div",{children:[e("span",{className:O.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:O.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(F,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:g,disabled:c||d})]})}),e("div",{className:O.actionsRow,children:e(C,{onClick:v,disabled:c||x,children:x?"Updating Database...":"Update Offline Database Now"})})]})},oa="_status_1wbo0_1",la="_warningText_1wbo0_7",ca="_ackLabel_1wbo0_11",me={status:oa,warningText:la,ackLabel:ca},da=()=>{const t=ee(),[s,c]=r(!1),[p,d]=r(!1),[y,S]=r(!1),[h,o]=r(""),a=()=>{d(!1),o(""),c(!0)},g=()=>{y||(c(!1),d(!1))},v=async()=>{if(!(!p||y)){S(!0),o("");try{const m=await J("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),x=await m.json();if(!m.ok)throw new Error(x.error||"Failed to clear database");const l=x.deleted,f=x.deletedManga,T=x.deletedTv,I=x.deletedAsmr,G=Object.values(l).reduce((A,M)=>A+(M||0),0)+Object.values(f??{}).reduce((A,M)=>A+(M||0),0)+Object.values(T??{}).reduce((A,M)=>A+(M||0),0)+Object.values(I??{}).reduce((A,M)=>A+(M||0),0),P=(f?.manga_library??0)+(f?.manga_progress??0),w=(T?.tv_library??0)+(T?.tv_progress??0),L=(I?.asmr_library??0)+(I?.asmr_progress??0);o(`Library cleared - ${l.watchlist??0} watchlist entries, ${P} manga rows, ${w} TV rows, ${L} ASMR rows and ${G} total rows removed.`),t.invalidateQueries({queryKey:[H.watchlist]}),t.invalidateQueries({queryKey:[H.continueWatching]}),t.invalidateQueries({queryKey:[H.mangaLibrary]}),t.invalidateQueries({queryKey:[H.mangaContinueReading]}),t.invalidateQueries({queryKey:[H.tvLibrary]}),t.invalidateQueries({queryKey:[H.tvContinueWatching]}),t.invalidateQueries({queryKey:[H.asmrLibrary]}),t.invalidateQueries({queryKey:[H.asmrContinueListening]}),c(!1)}catch(m){o(m.message)}finally{S(!1),d(!1)}}};return e("div",{className:`${_.sectionCard} ${_.dangerCard}`,children:[e("h3",{children:"Danger Zone"}),e("p",{children:"Permanently delete your library (watchlist, watched episodes, queue, cached show metadata, manga reading list and reading progress, TV watchlist and watch progress, ASMR listening list and listening progress) to start fresh. Your settings, sync state and the offline metadata cache are preserved."}),e(C,{variant:"danger",onClick:a,children:"Clear Library Data"}),h&&e("p",{className:me.status,children:h}),e(E,{isOpen:s,onClose:g,title:"Clear library data?",width:"sm",children:[e(E.Body,{children:[e("p",{className:me.warningText,children:"This permanently deletes everything in your library. It acts on the active database (dev or prod, per server config) and cannot be undone. Settings, sync state and the offline metadata cache are kept."}),e("label",{className:me.ackLabel,children:[e("input",{type:"checkbox",checked:p,onChange:m=>d(m.currentTarget.checked),disabled:y}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(E.Actions,{children:[e(C,{variant:"secondary",onClick:g,disabled:y,children:"Cancel"}),e(C,{variant:"danger",onClick:v,disabled:!p||y,children:y?"Clearing...":"Yes, delete everything"})]})]})]})},ua=()=>{const[t,s]=r(""),[c,p]=r([]),[d,y]=r(null),[S,h]=r(!0),[o,a]=r({show:!1,message:"",type:"info"}),g=async()=>{try{h(!0);const m=await k.auth.rcloneSettings.query();s(m.remote||""),p(m.availableRemotes||[]),y(m.activeRemote||null)}catch(m){console.error("Failed to fetch Rclone settings",m)}finally{h(!1)}};z(()=>{g()},[]);const v=async()=>{try{await k.auth.saveRclone.mutate({remote:t}),a({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),g()}catch{a({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return S?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:_.sectionCard,children:[e("h3",{className:b.title,children:"Rclone Cloud Sync"}),e("p",{className:b.signIn,children:"Configure which Rclone remote to use for database synchronization."}),d?e("div",{className:b.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:d})]})}):e("p",{className:b.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:b.formGroup,children:[e("label",{className:b.label,children:"Remote Name"}),e("div",{className:b.inputWrapper,children:e("select",{className:b.select,value:t,onChange:m=>s(m.currentTarget.value),children:[e("option",{value:"",children:"(Disabled / None)"}),c.map(m=>e("option",{value:m,children:m},m)),t&&!c.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:b.warning,style:{marginTop:"12px"},children:[e("strong",{children:"Note:"})," You can choose which provider is active using the selector at the top of the page."]})]}),e("div",{className:b.actions,children:e(C,{onClick:v,children:"Save Rclone Settings"})}),e(E,{isOpen:o.show,onClose:()=>a(m=>({...m,show:!1})),width:"sm",children:[e(E.Body,{children:e("p",{children:o.message})}),e(E.Actions,{children:e(C,{onClick:()=>a(m=>({...m,show:!1})),children:"OK"})})]})]})},ha=()=>{const t=ee(),[s,c]=r(null),[p,d]=r(!0),y=async()=>{try{const a=await k.auth.syncSettings.query();c(a)}catch(a){console.error("Failed to fetch sync settings",a)}finally{d(!1)}};z(()=>{y()},[]);const S=async a=>{const g=a.currentTarget.value;try{const v=await k.auth.saveSyncProvider.mutate({provider:g});c(m=>m?{...m,activeProvider:v.activeProvider}:null),await y(),await t.invalidateQueries({queryKey:Z.queryKey}),Se.success(`Sync provider updated to ${g==="default"?"Default Order":g}`)}catch{Se.error("Failed to update sync provider")}};if(p||!s)return null;const h=[{value:"default",label:"Default (Priority Based)"}];s.authenticatedProviders.github&&h.push({value:"github",label:"GitHub"}),s.authenticatedProviders.google&&h.push({value:"google",label:"Google Drive"}),s.authenticatedProviders.rclone&&h.push({value:"rclone",label:"Rclone"}),h.push({value:"none",label:"None (Local Only)"});const o=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:_.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:o(s.actualActiveProvider)})]}),e("div",{className:_.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:s.activeProvider,onChange:S,style:{padding:"0.5rem",borderRadius:"var(--radius-md)",background:"rgba(255, 255, 255, 0.05)",color:"var(--text-primary)",border:"1px solid var(--glass-border)",fontSize:"var(--font-size-sm)",minWidth:"220px",outline:"none",cursor:"pointer"},children:h.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ga(){return"javascript:"+encodeURIComponent(`(function(){
2
2
  if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
3
  var t=null;
4
4
  try{
@@ -1 +1 @@
1
- import{u as o,g as r}from"./vendor-core-DfaOB3Rn.js";import{u as l}from"./index-CPhXtUuw.js";const a="_skeletonCard_qtypb_1",i="_poster_qtypb_11",d="_line_qtypb_20",c="_info_qtypb_38",_="_short_qtypb_54",m="_lowEnd_qtypb_69",e={skeletonCard:a,poster:i,line:d,"skeleton-wave":"_skeleton-wave_qtypb_1",info:c,short:_,lowEnd:m},p=({layout:n="vertical"})=>{const{lowEndMode:t}=l();return o("div",{className:`${e.skeletonCard} ${e[n]} ${t?e.lowEnd:""}`,children:[o("div",{className:e.poster}),o("div",{className:e.info,children:[o("div",{className:e.line}),o("div",{className:`${e.line} ${e.short}`})]})]})},v=({count:n=14,layout:t="vertical"})=>o("div",{className:"grid-container",children:Array.from({length:n}).map((k,s)=>o(p,{layout:t},s))}),w=r.memo(v);export{p as A,w as S};
1
+ import{u as o,g as r}from"./vendor-core-DfaOB3Rn.js";import{u as l}from"./index-CkZCduQZ.js";const a="_skeletonCard_qtypb_1",i="_poster_qtypb_11",d="_line_qtypb_20",c="_info_qtypb_38",_="_short_qtypb_54",m="_lowEnd_qtypb_69",e={skeletonCard:a,poster:i,line:d,"skeleton-wave":"_skeleton-wave_qtypb_1",info:c,short:_,lowEnd:m},p=({layout:n="vertical"})=>{const{lowEndMode:t}=l();return o("div",{className:`${e.skeletonCard} ${e[n]} ${t?e.lowEnd:""}`,children:[o("div",{className:e.poster}),o("div",{className:e.info,children:[o("div",{className:e.line}),o("div",{className:`${e.line} ${e.short}`})]})]})},v=({count:n=14,layout:t="vertical"})=>o("div",{className:"grid-container",children:Array.from({length:n}).map((k,s)=>o(p,{layout:t},s))}),w=r.memo(v);export{p as A,w as S};
@@ -1,2 +1,2 @@
1
- import{h as J,d as i,A as ye,u as e,S as g,g as ea,q as De}from"./vendor-core-DfaOB3Rn.js";import{u as V,b as R,a as S}from"./vendor-query-BBT5_sHx.js";import{K as r,q as s,t as c,ap as aa,v as na,Y as qe,B as ge}from"./index-CPhXtUuw.js";import{I as m}from"./vendor-icons-C1Pj_eSX.js";function ta(){const N=V();J(()=>{const C=new URLSearchParams(window.location.search),h=C.get("mal");if(!h)return;const t=C.get("user"),y=C.get("reason");window.history.replaceState(null,"",window.location.pathname),h==="success"?(r.success(t?`Connected to MyAnimeList as ${decodeURIComponent(t)}`:"Connected to MyAnimeList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(y?decodeURIComponent(y):"MyAnimeList authentication failed")},[N])}function sa(){const N=V(),[C,h]=i(!1);return J(()=>{const t=new URLSearchParams(window.location.search),y=t.get("anilist");if(y){const k=t.get("user"),u=t.get("reason");window.history.replaceState(null,"",window.location.pathname),y==="success"?(r.success(k?`Connected to AniList as ${decodeURIComponent(k)}`:"Connected to AniList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(u?decodeURIComponent(u):"AniList authentication failed");return}const b=new URLSearchParams(window.location.hash.substring(1)),l=b.get("access_token"),L=t.get("code");if(!l&&!L){const k=b.get("error");k&&(r.error(`AniList error: ${k}`),window.history.replaceState(null,"",window.location.pathname));return}const d=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),h(!0),r("Connecting to AniList..."),c.tracker.anilistAuth.mutate(l?{token:l}:{code:L,redirectUri:d}).then(async k=>{const u=k.user;r.success(`Connected to AniList as ${u?.name??"AniList user"}`),N.invalidateQueries({queryKey:[s.trackerStatus]})}).catch(k=>{r.error(k instanceof Error?k.message:"Failed to authenticate with AniList")}).finally(()=>{h(!1)})},[N]),C}const ia="_header_azjok_1",ra="_fadeIn_azjok_1",ca="_pageTitle_azjok_6",oa="_pageSubtitle_azjok_14",la="_importCard_azjok_20",da="_cardHeader_azjok_31",ma="_uploadArea_azjok_49",ua="_fileInputWrapper_azjok_53",pa="_fileInput_azjok_53",ha="_fileDisplay_azjok_71",ga="_fileIcon_azjok_79",ya="_fileName_azjok_84",ka="_browseButton_azjok_93",fa="_optionsArea_azjok_104",_a="_checkboxLabel_azjok_112",ba="_checkbox_azjok_112",va="_checkboxCustom_azjok_125",Na="_optionText_azjok_153",wa="_optionTitle_azjok_159",Ca="_optionDesc_azjok_165",Ia="_actions_azjok_171",Sa="_importBtn_azjok_179",La="_cancelBtn_azjok_185",Ma="_statusMessage_azjok_199",xa="_success_azjok_209",Ta="_error_azjok_215",Aa="_progressSection_azjok_221",za="_progressBar_azjok_226",Pa="_progressFill_azjok_234",ja="_progressInfo_azjok_241",Ba="_progressCount_azjok_248",Ea="_progressTitle_azjok_255",Fa="_sourceBadge_azjok_273",Da="_anilist_azjok_285",qa="_kitsu_azjok_291",$a="_offline_azjok_297",Ka="_skipped_azjok_303",Ra="_cardTitleRow_azjok_308",Ua="_anilistIcon_azjok_318",Qa="_malIcon_azjok_324",Oa="_badgeOnline_azjok_330",Ha="_badgeOffline_azjok_342",Ga="_connectedProfile_azjok_354",Wa="_avatar_azjok_361",Xa="_connectedInfo_azjok_368",Ya="_connectedName_azjok_376",Ja="_connectedHint_azjok_382",Va="_loginPrompt_azjok_387",Za="_loginSection_azjok_395",en="_primaryBtn_azjok_401",an="_fieldLabel_azjok_405",nn="_helpText_azjok_424",tn="_resetBtn_azjok_431",sn="_loginText_azjok_461",rn="_secondaryBtn_azjok_471",cn="_syncBtn_azjok_472",on="_divider_azjok_525",ln="_actionSection_azjok_531",dn="_inputGroup_azjok_545",mn="_credentialFields_azjok_551",un="_credentialField_azjok_551",pn="_input_azjok_545",hn="_syncSummary_azjok_587",gn="_syncErrors_azjok_593",yn="_spin_azjok_597",kn="_radioGroup_azjok_616",fn="_radioLabel_azjok_623",_n="_syncHint_azjok_661",bn="_importLoading_azjok_668",a={header:ia,fadeIn:ra,pageTitle:ca,pageSubtitle:oa,importCard:la,cardHeader:da,uploadArea:ma,fileInputWrapper:ua,fileInput:pa,fileDisplay:ha,fileIcon:ga,fileName:ya,browseButton:ka,optionsArea:fa,checkboxLabel:_a,checkbox:ba,checkboxCustom:va,optionText:Na,optionTitle:wa,optionDesc:Ca,actions:Ia,importBtn:Sa,cancelBtn:La,statusMessage:Ma,success:xa,error:Ta,progressSection:Aa,progressBar:za,progressFill:Pa,progressInfo:ja,progressCount:Ba,progressTitle:Ea,sourceBadge:Fa,anilist:Da,kitsu:qa,offline:$a,skipped:Ka,cardTitleRow:Ra,anilistIcon:Ua,malIcon:Qa,badgeOnline:Oa,badgeOffline:Ha,connectedProfile:Ga,avatar:Wa,connectedInfo:Xa,connectedName:Ya,connectedHint:Ja,loginPrompt:Va,loginSection:Za,primaryBtn:en,fieldLabel:an,helpText:nn,resetBtn:tn,loginText:sn,secondaryBtn:rn,syncBtn:cn,divider:on,actionSection:ln,inputGroup:dn,credentialFields:mn,credentialField:un,input:pn,syncSummary:hn,syncErrors:gn,spin:yn,radioGroup:kn,radioLabel:fn,syncHint:_n,importLoading:bn},ie="tracker_anilist_client_id",Re="49887".trim(),re=!!Re;function $e(){const N=V(),[C,h]=i(""),t=ye(!1),y=sa(),{data:b}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query()}),{data:l}=R({queryKey:[s.anilistClientId],queryFn:async()=>(await c.settings.getByKey.query({key:ie})).value||""});J(()=>{t.current||l===void 0||(l&&h(l),t.current=!0)},[l]);const L=S({mutationFn:()=>c.tracker.anilistDisconnect.mutate(),onSuccess:()=>{N.invalidateQueries({queryKey:[s.trackerStatus]}),r.success("Disconnected from AniList")},onError:_=>r.error(_.message)}),d=S({mutationFn:()=>c.settings.set.mutate({key:ie,value:""}),onSuccess:()=>{h(""),N.invalidateQueries({queryKey:[s.anilistClientId]}),r.success("Switched to dango's AniList app")},onError:_=>r.error(_.message)}),k=async()=>{const _=C.trim(),o=_||Re;if(!o){r.error("Enter your AniList client ID first");return}const P=(l||"").trim();try{_?_!==l&&await c.settings.set.mutate({key:ie,value:_}):re&&P&&await c.settings.set.mutate({key:ie,value:""}),N.invalidateQueries({queryKey:[s.anilistClientId]})}catch(M){r.error(M.message);return}const p=encodeURIComponent(window.location.origin+window.location.pathname);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(o)}&response_type=token&state=${p}`},u=b?.anilist?.user??null;return b?.anilist?.connected&&u?e("div",{className:a.connectedProfile,children:[u.avatar&&e("img",{src:u.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:u.name}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>L.mutate(),disabled:L.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.loginText,children:["Log in with AniList to enable bidirectional progress & status synchronization.",y&&e("span",{style:{marginLeft:8,color:"var(--accent)"},children:"Finishing login…"})]}),e("div",{className:a.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(m,{name:"external-link-alt",size:9})]})]}),e("div",{className:a.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:C,onChange:_=>h(_.currentTarget.value),className:a.input}),e("button",{className:a.primaryBtn,onClick:k,disabled:!(C.trim()||re),children:[e(m,{name:"external-link-alt"})," Connect"]})]}),re&&l&&e("button",{className:a.resetBtn,onClick:()=>d.mutate(),disabled:d.isPending,children:"Use dango's app instead"}),e("p",{className:a.helpText,children:re?e(g,{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.origin}/api/tracker/anilist/callback`}),", then paste only the ",e("strong",{children:"Client ID"})," above (leave empty to use dango's)."]}):e(g,{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.origin}/api/tracker/anilist/callback`}),", then paste the"," ",e("strong",{children:"Client ID"})," above."]})})]})}function Ke({kind:N="anime",active:C=!0}){const h=V(),[t,y]=i(""),[b,l]=i(""),[L,d]=i(""),[k,u]=i(""),_=ye(!1),{data:o}=R({queryKey:[s.malClientConfig],queryFn:()=>c.tracker.malConfig.query()}),{data:P}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query(),refetchInterval:15e3});J(()=>{o&&!_.current&&(y(o.clientId),_.current=!0)},[o]);const p=S({mutationFn:async()=>{d(""),(b.trim()||t.trim()&&t.trim()!==o?.clientId)&&await c.tracker.malSaveConfig.mutate({clientId:t.trim(),clientSecret:b.trim()||void 0}),l("");const f=await c.tracker.malLogin.mutate({redirectUri:`${window.location.origin}/api/tracker/mal/callback`});window.location.assign(f.url)},onError:f=>d(f.message)}),M=S({mutationFn:()=>c.tracker.malDisconnect.mutate(),onSuccess:()=>{h.invalidateQueries({queryKey:[s.trackerStatus]}),u(""),d(""),r.success("Disconnected from MyAnimeList")},onError:f=>d(f.message)}),B=S({mutationFn:()=>c.tracker.malClearConfig.mutate(),onSuccess:()=>{y(""),l(""),u(""),d(""),h.invalidateQueries({queryKey:[s.trackerStatus]}),h.invalidateQueries({queryKey:[s.malClientConfig]}),r.success("Switched to dango's MyAnimeList app - reconnect to finish")},onError:f=>d(f.message)}),D=S({mutationFn:()=>N==="manga"?c.tracker.mangaMalSync.mutate():c.tracker.sync.mutate({provider:"mal"}),onSuccess:f=>{const T=f.summary;u(`Pushed: ${T.pushed} · Pulled: ${T.pulled} · Merged: ${T.merged} · Unchanged: ${T.unchanged}`+(T.errors.length>0?` · ${T.errors.length} error${T.errors.length>1?"s":""}`:""));for(const E of N==="manga"?[[s.trackerStatus],[s.mangaLibrary],[s.mangaContinueReading]]:[[s.trackerStatus],[s.watchlist],[s.continueWatching]])h.invalidateQueries({queryKey:E})},onError:f=>d(f.message)}),x=P?.mal;return e("div",{children:[x?.connected?e(g,{children:[e("div",{className:a.connectedProfile,children:[x.user?.avatar&&e("img",{src:x.user.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:x.user?.name||"MyAnimeList user"}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>M.mutate(),disabled:M.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}),C?e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>D.mutate(),disabled:D.isPending,children:[e(m,{name:"sync-alt",className:D.isPending?a.spin:""}),D.isPending?"Syncing...":"Start Sync"]}),k&&e("div",{className:a.syncSummary,children:k})]}):e("p",{className:a.connectedHint,style:{color:"var(--color-warning)"},children:"Not the active tracker - sync disabled."})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.loginText,children:"Log in with MyAnimeList to enable bidirectional progress & status synchronization."}),e("div",{className:a.credentialFields,children:[e("label",{className:`${a.fieldLabel} ${a.credentialField}`,children:[e("span",{children:["Client ID"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(m,{name:"external-link-alt",size:9})]}),o?.mode==="worker"&&e("span",{className:a.helpText,children:" — defaults to dango's app"})]}),e("input",{className:a.input,placeholder:o?.mode==="worker"?"dango's app (leave empty)":"Client ID",value:t,onChange:f=>y(f.currentTarget.value),autoComplete:"off"})]}),e("label",{className:`${a.fieldLabel} ${a.credentialField}`,children:[e("span",{children:["Client secret"," ",o?.hasSecret&&!b&&e("span",{className:a.helpText,children:"— saved"})]}),e("input",{className:a.input,type:"password",value:b,onChange:f=>l(f.currentTarget.value),placeholder:o?.mode==="worker"?"dango's app (leave empty)":o?.hasSecret?"Saved — leave blank to keep":"Client secret",autoComplete:"new-password"})]})]}),o?.hasCustomId&&o?.hasWorker&&e("button",{className:a.resetBtn,onClick:()=>B.mutate(),disabled:B.isPending,children:"Use dango's app instead"}),e("p",{className:a.helpText,children:o?.mode==="worker"?e(g,{children:["By default uses dango's client. To use your own MyAnimeList app: create it at"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:"myanimelist.net/apiconfig"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:[window.location.origin,"/api/tracker/mal/callback"]}),", then paste its"," ",e("strong",{children:"Client ID"})," and ",e("strong",{children:"Client secret"})," above (leave both empty to use dango's)."]}):e(g,{children:["No shipped client in this build - create your own app at"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:"myanimelist.net/apiconfig"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:[window.location.origin,"/api/tracker/mal/callback"]}),", then paste the"," ",e("strong",{children:"Client ID"})," and ",e("strong",{children:"Client secret"})," above. MAL requires the secret even for PKCE apps; it stays on your dango server and is never returned to the browser."]})}),e("button",{className:a.primaryBtn,onClick:()=>p.mutate(),disabled:!(t.trim()&&b.trim()||o?.clientId&&t.trim()===o.clientId&&o.hasSecret||!t.trim()&&!b.trim()&&o?.mode==="worker")||p.isPending,children:p.isPending?"Connecting...":"Connect to MyAnimeList"})]}),L&&e("p",{className:`${a.helpText} ${a.syncErrors}`,role:"alert",children:L}),e("hr",{className:a.divider}),e("p",{className:a.syncHint,children:"You can also import a public list or XML file without connecting an account:"})]})}const In=()=>{const{setIsOpen:N}=aa(),{contentType:C}=na(),h=C==="manga",t=V();ea.useEffect(()=>{document.title="Trackers - dango"},[]);const[y,b]=i(""),[l,L]=i("username"),[d,k]=i(null),[u,_]=i(!1);ta();const{data:o,isLoading:P}=R({queryKey:[s.trackerStatus],queryFn:async()=>await c.tracker.status.query()}),p=o?.anilist?.connected??!1,M=o?.mal?.connected??!1,{data:B}=R({queryKey:["activeTrackerProvider"],queryFn:async()=>(await c.settings.getByKey.query({key:"active_tracker_provider"}))?.value||""}),D=S({mutationFn:async n=>(await c.settings.set.mutate({key:"active_tracker_provider",value:n}),n),onSuccess:n=>{t.invalidateQueries({queryKey:["activeTrackerProvider"]}),r.success(`Active tracker set to ${n==="mal"?"MyAnimeList":"AniList"}`)},onError:()=>r.error("Failed to update active tracker")}),x=B&&(B==="anilist"&&p||B==="mal"&&M)?B:p&&!M?"anilist":M&&!p?"mal":p?"anilist":"",f=p||M;J(()=>{p&&L("sync")},[p]);const T=S({mutationFn:async()=>(await c.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),k(n),r.success(`Sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}`,{duration:6e3})},onError:n=>r.error(n.message)}),[E,ke]=i(""),[Z,fe]=i("sync"),[ce,_e]=i("two-way"),[w,Ue]=i(null),ee=S({mutationFn:async()=>(await c.tracker.mangaSync.mutate({direction:ce})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),Ue(n);const v=(n.warnings?.length??0)>0?`, ${n.warnings.length} warning(s)`:"";r.success(`Manga sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}${v}`,{duration:6e3})},onError:n=>r.error(n.message)}),q=S({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a username");return(await c.tracker.mangaImport.mutate({username:E.trim(),erase:u})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from AniList`),ke("")},onError:n=>r.error(n.message)}),[U,be]=i(""),[ae,ve]=i("username"),[oe,Ne]=i(null),[ne,we]=i(!1),[Ce,le]=i(""),[Ie,Qe]=i(""),j=S({mutationFn:async()=>{if(!U.trim())throw new Error("Please enter a MAL username");const n=await c.tracker.mangaMalImport.mutate({username:U.trim(),erase:u});return{imported:n.imported??0,skipped:n.skipped??0}},onSuccess:({imported:n,skipped:v})=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from MAL${v>0?`, skipped ${v}`:""}`),be("")},onError:n=>r.error(n.message)}),Oe=De(async()=>{const n=document.getElementById("malMangaFile");if(!n.files||n.files.length===0){le("Please select a file first.");return}we(!0),le(""),Ne(null);try{const v=new FormData;v.append("xmlfile",n.files[0]),v.append("erase",String(u));const W=await qe("/api/import/mal-xml-manga",{method:"POST",body:v}),I=await W.json().catch(()=>({}));if(!W.ok)throw new Error(I.error||"Import failed");Ne({imported:I.imported??0,skipped:I.skipped??0}),t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]})}catch(v){le(v.message)}finally{we(!1)}},[u,t]),$=S({mutationFn:async()=>{if(!y.trim())throw new Error("Please enter a username");return(await c.tracker.anilistImport.mutate({username:y.trim(),erase:F})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from AniList`),b("")},onError:n=>r.error(n.message)}),[Q,Se]=i(""),z=S({mutationFn:async n=>{if(!Q.trim())throw new Error("Please enter a MAL username");return(await c.tracker.malImport.mutate({username:Q.trim(),erase:n.erase,useOfflineDb:n.useOfflineDb,skipFallback:n.skipFallback})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from MAL`),Se("")},onError:n=>r.error(n.message)}),[F,Le]=i(!1),[O,He]=i(!0),[H,Ge]=i(!1),[Me,xe]=i(""),[K,Te]=i(!1),[A,Ae]=i(null),[de,ze]=i(null),[Pe,te]=i(""),me=ye(null),We=n=>{n.currentTarget.files&&n.currentTarget.files.length>0?xe(n.currentTarget.files[0].name):xe("")},Xe=De(async()=>{const n=document.getElementById("malFile");if(!n.files||n.files.length===0){te("Please select a file first.");return}const v=n.files[0];Te(!0),Ae(null),ze(null),te("");const W=new AbortController;me.current=W;try{const I=new FormData;I.append("xmlfile",v),I.append("erase",String(F)),I.append("useOfflineDb",String(O)),I.append("skipFallback",String(H));const ue=await qe("/api/import/mal-xml",{method:"POST",body:I,signal:W.signal});if(!ue.ok){const he=await ue.text();let X="Failed to import";try{X=JSON.parse(he).error||X}catch{}throw new Error(X)}const Be=ue.body?.getReader();if(!Be)throw new Error("No response stream");const Ve=new TextDecoder;let pe="",se="";for(;;){const{done:he,value:X}=await Be.read();if(he)break;pe+=Ve.decode(X,{stream:!0});const Ee=pe.split(`
1
+ import{h as J,d as i,A as ye,u as e,S as g,g as ea,q as De}from"./vendor-core-DfaOB3Rn.js";import{u as V,b as R,a as S}from"./vendor-query-BBT5_sHx.js";import{K as r,q as s,t as c,ap as aa,v as na,Y as qe,B as ge}from"./index-CkZCduQZ.js";import{I as m}from"./vendor-icons-C1Pj_eSX.js";function ta(){const N=V();J(()=>{const C=new URLSearchParams(window.location.search),h=C.get("mal");if(!h)return;const t=C.get("user"),y=C.get("reason");window.history.replaceState(null,"",window.location.pathname),h==="success"?(r.success(t?`Connected to MyAnimeList as ${decodeURIComponent(t)}`:"Connected to MyAnimeList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(y?decodeURIComponent(y):"MyAnimeList authentication failed")},[N])}function sa(){const N=V(),[C,h]=i(!1);return J(()=>{const t=new URLSearchParams(window.location.search),y=t.get("anilist");if(y){const k=t.get("user"),u=t.get("reason");window.history.replaceState(null,"",window.location.pathname),y==="success"?(r.success(k?`Connected to AniList as ${decodeURIComponent(k)}`:"Connected to AniList"),N.invalidateQueries({queryKey:[s.trackerStatus]})):r.error(u?decodeURIComponent(u):"AniList authentication failed");return}const b=new URLSearchParams(window.location.hash.substring(1)),l=b.get("access_token"),L=t.get("code");if(!l&&!L){const k=b.get("error");k&&(r.error(`AniList error: ${k}`),window.history.replaceState(null,"",window.location.pathname));return}const d=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),h(!0),r("Connecting to AniList..."),c.tracker.anilistAuth.mutate(l?{token:l}:{code:L,redirectUri:d}).then(async k=>{const u=k.user;r.success(`Connected to AniList as ${u?.name??"AniList user"}`),N.invalidateQueries({queryKey:[s.trackerStatus]})}).catch(k=>{r.error(k instanceof Error?k.message:"Failed to authenticate with AniList")}).finally(()=>{h(!1)})},[N]),C}const ia="_header_azjok_1",ra="_fadeIn_azjok_1",ca="_pageTitle_azjok_6",oa="_pageSubtitle_azjok_14",la="_importCard_azjok_20",da="_cardHeader_azjok_31",ma="_uploadArea_azjok_49",ua="_fileInputWrapper_azjok_53",pa="_fileInput_azjok_53",ha="_fileDisplay_azjok_71",ga="_fileIcon_azjok_79",ya="_fileName_azjok_84",ka="_browseButton_azjok_93",fa="_optionsArea_azjok_104",_a="_checkboxLabel_azjok_112",ba="_checkbox_azjok_112",va="_checkboxCustom_azjok_125",Na="_optionText_azjok_153",wa="_optionTitle_azjok_159",Ca="_optionDesc_azjok_165",Ia="_actions_azjok_171",Sa="_importBtn_azjok_179",La="_cancelBtn_azjok_185",Ma="_statusMessage_azjok_199",xa="_success_azjok_209",Ta="_error_azjok_215",Aa="_progressSection_azjok_221",za="_progressBar_azjok_226",Pa="_progressFill_azjok_234",ja="_progressInfo_azjok_241",Ba="_progressCount_azjok_248",Ea="_progressTitle_azjok_255",Fa="_sourceBadge_azjok_273",Da="_anilist_azjok_285",qa="_kitsu_azjok_291",$a="_offline_azjok_297",Ka="_skipped_azjok_303",Ra="_cardTitleRow_azjok_308",Ua="_anilistIcon_azjok_318",Qa="_malIcon_azjok_324",Oa="_badgeOnline_azjok_330",Ha="_badgeOffline_azjok_342",Ga="_connectedProfile_azjok_354",Wa="_avatar_azjok_361",Xa="_connectedInfo_azjok_368",Ya="_connectedName_azjok_376",Ja="_connectedHint_azjok_382",Va="_loginPrompt_azjok_387",Za="_loginSection_azjok_395",en="_primaryBtn_azjok_401",an="_fieldLabel_azjok_405",nn="_helpText_azjok_424",tn="_resetBtn_azjok_431",sn="_loginText_azjok_461",rn="_secondaryBtn_azjok_471",cn="_syncBtn_azjok_472",on="_divider_azjok_525",ln="_actionSection_azjok_531",dn="_inputGroup_azjok_545",mn="_credentialFields_azjok_551",un="_credentialField_azjok_551",pn="_input_azjok_545",hn="_syncSummary_azjok_587",gn="_syncErrors_azjok_593",yn="_spin_azjok_597",kn="_radioGroup_azjok_616",fn="_radioLabel_azjok_623",_n="_syncHint_azjok_661",bn="_importLoading_azjok_668",a={header:ia,fadeIn:ra,pageTitle:ca,pageSubtitle:oa,importCard:la,cardHeader:da,uploadArea:ma,fileInputWrapper:ua,fileInput:pa,fileDisplay:ha,fileIcon:ga,fileName:ya,browseButton:ka,optionsArea:fa,checkboxLabel:_a,checkbox:ba,checkboxCustom:va,optionText:Na,optionTitle:wa,optionDesc:Ca,actions:Ia,importBtn:Sa,cancelBtn:La,statusMessage:Ma,success:xa,error:Ta,progressSection:Aa,progressBar:za,progressFill:Pa,progressInfo:ja,progressCount:Ba,progressTitle:Ea,sourceBadge:Fa,anilist:Da,kitsu:qa,offline:$a,skipped:Ka,cardTitleRow:Ra,anilistIcon:Ua,malIcon:Qa,badgeOnline:Oa,badgeOffline:Ha,connectedProfile:Ga,avatar:Wa,connectedInfo:Xa,connectedName:Ya,connectedHint:Ja,loginPrompt:Va,loginSection:Za,primaryBtn:en,fieldLabel:an,helpText:nn,resetBtn:tn,loginText:sn,secondaryBtn:rn,syncBtn:cn,divider:on,actionSection:ln,inputGroup:dn,credentialFields:mn,credentialField:un,input:pn,syncSummary:hn,syncErrors:gn,spin:yn,radioGroup:kn,radioLabel:fn,syncHint:_n,importLoading:bn},ie="tracker_anilist_client_id",Re="49887".trim(),re=!!Re;function $e(){const N=V(),[C,h]=i(""),t=ye(!1),y=sa(),{data:b}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query()}),{data:l}=R({queryKey:[s.anilistClientId],queryFn:async()=>(await c.settings.getByKey.query({key:ie})).value||""});J(()=>{t.current||l===void 0||(l&&h(l),t.current=!0)},[l]);const L=S({mutationFn:()=>c.tracker.anilistDisconnect.mutate(),onSuccess:()=>{N.invalidateQueries({queryKey:[s.trackerStatus]}),r.success("Disconnected from AniList")},onError:_=>r.error(_.message)}),d=S({mutationFn:()=>c.settings.set.mutate({key:ie,value:""}),onSuccess:()=>{h(""),N.invalidateQueries({queryKey:[s.anilistClientId]}),r.success("Switched to dango's AniList app")},onError:_=>r.error(_.message)}),k=async()=>{const _=C.trim(),o=_||Re;if(!o){r.error("Enter your AniList client ID first");return}const P=(l||"").trim();try{_?_!==l&&await c.settings.set.mutate({key:ie,value:_}):re&&P&&await c.settings.set.mutate({key:ie,value:""}),N.invalidateQueries({queryKey:[s.anilistClientId]})}catch(M){r.error(M.message);return}const p=encodeURIComponent(window.location.origin+window.location.pathname);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(o)}&response_type=token&state=${p}`},u=b?.anilist?.user??null;return b?.anilist?.connected&&u?e("div",{className:a.connectedProfile,children:[u.avatar&&e("img",{src:u.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:u.name}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>L.mutate(),disabled:L.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.loginText,children:["Log in with AniList to enable bidirectional progress & status synchronization.",y&&e("span",{style:{marginLeft:8,color:"var(--accent)"},children:"Finishing login…"})]}),e("div",{className:a.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(m,{name:"external-link-alt",size:9})]})]}),e("div",{className:a.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:C,onChange:_=>h(_.currentTarget.value),className:a.input}),e("button",{className:a.primaryBtn,onClick:k,disabled:!(C.trim()||re),children:[e(m,{name:"external-link-alt"})," Connect"]})]}),re&&l&&e("button",{className:a.resetBtn,onClick:()=>d.mutate(),disabled:d.isPending,children:"Use dango's app instead"}),e("p",{className:a.helpText,children:re?e(g,{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.origin}/api/tracker/anilist/callback`}),", then paste only the ",e("strong",{children:"Client ID"})," above (leave empty to use dango's)."]}):e(g,{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.origin}/api/tracker/anilist/callback`}),", then paste the"," ",e("strong",{children:"Client ID"})," above."]})})]})}function Ke({kind:N="anime",active:C=!0}){const h=V(),[t,y]=i(""),[b,l]=i(""),[L,d]=i(""),[k,u]=i(""),_=ye(!1),{data:o}=R({queryKey:[s.malClientConfig],queryFn:()=>c.tracker.malConfig.query()}),{data:P}=R({queryKey:[s.trackerStatus],queryFn:()=>c.tracker.status.query(),refetchInterval:15e3});J(()=>{o&&!_.current&&(y(o.clientId),_.current=!0)},[o]);const p=S({mutationFn:async()=>{d(""),(b.trim()||t.trim()&&t.trim()!==o?.clientId)&&await c.tracker.malSaveConfig.mutate({clientId:t.trim(),clientSecret:b.trim()||void 0}),l("");const f=await c.tracker.malLogin.mutate({redirectUri:`${window.location.origin}/api/tracker/mal/callback`});window.location.assign(f.url)},onError:f=>d(f.message)}),M=S({mutationFn:()=>c.tracker.malDisconnect.mutate(),onSuccess:()=>{h.invalidateQueries({queryKey:[s.trackerStatus]}),u(""),d(""),r.success("Disconnected from MyAnimeList")},onError:f=>d(f.message)}),B=S({mutationFn:()=>c.tracker.malClearConfig.mutate(),onSuccess:()=>{y(""),l(""),u(""),d(""),h.invalidateQueries({queryKey:[s.trackerStatus]}),h.invalidateQueries({queryKey:[s.malClientConfig]}),r.success("Switched to dango's MyAnimeList app - reconnect to finish")},onError:f=>d(f.message)}),D=S({mutationFn:()=>N==="manga"?c.tracker.mangaMalSync.mutate():c.tracker.sync.mutate({provider:"mal"}),onSuccess:f=>{const T=f.summary;u(`Pushed: ${T.pushed} · Pulled: ${T.pulled} · Merged: ${T.merged} · Unchanged: ${T.unchanged}`+(T.errors.length>0?` · ${T.errors.length} error${T.errors.length>1?"s":""}`:""));for(const E of N==="manga"?[[s.trackerStatus],[s.mangaLibrary],[s.mangaContinueReading]]:[[s.trackerStatus],[s.watchlist],[s.continueWatching]])h.invalidateQueries({queryKey:E})},onError:f=>d(f.message)}),x=P?.mal;return e("div",{children:[x?.connected?e(g,{children:[e("div",{className:a.connectedProfile,children:[x.user?.avatar&&e("img",{src:x.user.avatar,alt:"Avatar",className:a.avatar,loading:"lazy",decoding:"async"}),e("div",{className:a.connectedInfo,children:[e("span",{className:a.connectedName,children:x.user?.name||"MyAnimeList user"}),e("span",{className:a.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:a.secondaryBtn,onClick:()=>M.mutate(),disabled:M.isPending,children:[e(m,{name:"sign-out-alt"})," Disconnect"]})]}),C?e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>D.mutate(),disabled:D.isPending,children:[e(m,{name:"sync-alt",className:D.isPending?a.spin:""}),D.isPending?"Syncing...":"Start Sync"]}),k&&e("div",{className:a.syncSummary,children:k})]}):e("p",{className:a.connectedHint,style:{color:"var(--color-warning)"},children:"Not the active tracker - sync disabled."})]}):e("div",{className:a.loginSection,children:[e("p",{className:a.loginText,children:"Log in with MyAnimeList to enable bidirectional progress & status synchronization."}),e("div",{className:a.credentialFields,children:[e("label",{className:`${a.fieldLabel} ${a.credentialField}`,children:[e("span",{children:["Client ID"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(m,{name:"external-link-alt",size:9})]}),o?.mode==="worker"&&e("span",{className:a.helpText,children:" — defaults to dango's app"})]}),e("input",{className:a.input,placeholder:o?.mode==="worker"?"dango's app (leave empty)":"Client ID",value:t,onChange:f=>y(f.currentTarget.value),autoComplete:"off"})]}),e("label",{className:`${a.fieldLabel} ${a.credentialField}`,children:[e("span",{children:["Client secret"," ",o?.hasSecret&&!b&&e("span",{className:a.helpText,children:"— saved"})]}),e("input",{className:a.input,type:"password",value:b,onChange:f=>l(f.currentTarget.value),placeholder:o?.mode==="worker"?"dango's app (leave empty)":o?.hasSecret?"Saved — leave blank to keep":"Client secret",autoComplete:"new-password"})]})]}),o?.hasCustomId&&o?.hasWorker&&e("button",{className:a.resetBtn,onClick:()=>B.mutate(),disabled:B.isPending,children:"Use dango's app instead"}),e("p",{className:a.helpText,children:o?.mode==="worker"?e(g,{children:["By default uses dango's client. To use your own MyAnimeList app: create it at"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:"myanimelist.net/apiconfig"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:[window.location.origin,"/api/tracker/mal/callback"]}),", then paste its"," ",e("strong",{children:"Client ID"})," and ",e("strong",{children:"Client secret"})," above (leave both empty to use dango's)."]}):e(g,{children:["No shipped client in this build - create your own app at"," ",e("a",{href:"https://myanimelist.net/apiconfig",target:"_blank",rel:"noopener noreferrer",children:"myanimelist.net/apiconfig"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:[window.location.origin,"/api/tracker/mal/callback"]}),", then paste the"," ",e("strong",{children:"Client ID"})," and ",e("strong",{children:"Client secret"})," above. MAL requires the secret even for PKCE apps; it stays on your dango server and is never returned to the browser."]})}),e("button",{className:a.primaryBtn,onClick:()=>p.mutate(),disabled:!(t.trim()&&b.trim()||o?.clientId&&t.trim()===o.clientId&&o.hasSecret||!t.trim()&&!b.trim()&&o?.mode==="worker")||p.isPending,children:p.isPending?"Connecting...":"Connect to MyAnimeList"})]}),L&&e("p",{className:`${a.helpText} ${a.syncErrors}`,role:"alert",children:L}),e("hr",{className:a.divider}),e("p",{className:a.syncHint,children:"You can also import a public list or XML file without connecting an account:"})]})}const In=()=>{const{setIsOpen:N}=aa(),{contentType:C}=na(),h=C==="manga",t=V();ea.useEffect(()=>{document.title="Trackers - dango"},[]);const[y,b]=i(""),[l,L]=i("username"),[d,k]=i(null),[u,_]=i(!1);ta();const{data:o,isLoading:P}=R({queryKey:[s.trackerStatus],queryFn:async()=>await c.tracker.status.query()}),p=o?.anilist?.connected??!1,M=o?.mal?.connected??!1,{data:B}=R({queryKey:["activeTrackerProvider"],queryFn:async()=>(await c.settings.getByKey.query({key:"active_tracker_provider"}))?.value||""}),D=S({mutationFn:async n=>(await c.settings.set.mutate({key:"active_tracker_provider",value:n}),n),onSuccess:n=>{t.invalidateQueries({queryKey:["activeTrackerProvider"]}),r.success(`Active tracker set to ${n==="mal"?"MyAnimeList":"AniList"}`)},onError:()=>r.error("Failed to update active tracker")}),x=B&&(B==="anilist"&&p||B==="mal"&&M)?B:p&&!M?"anilist":M&&!p?"mal":p?"anilist":"",f=p||M;J(()=>{p&&L("sync")},[p]);const T=S({mutationFn:async()=>(await c.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),k(n),r.success(`Sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}`,{duration:6e3})},onError:n=>r.error(n.message)}),[E,ke]=i(""),[Z,fe]=i("sync"),[ce,_e]=i("two-way"),[w,Ue]=i(null),ee=S({mutationFn:async()=>(await c.tracker.mangaSync.mutate({direction:ce})).summary,onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),Ue(n);const v=(n.warnings?.length??0)>0?`, ${n.warnings.length} warning(s)`:"";r.success(`Manga sync complete - pushed ${n.pushed}, pulled ${n.pulled}, merged ${n.merged}, unchanged ${n.unchanged}${v}`,{duration:6e3})},onError:n=>r.error(n.message)}),q=S({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a username");return(await c.tracker.mangaImport.mutate({username:E.trim(),erase:u})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from AniList`),ke("")},onError:n=>r.error(n.message)}),[U,be]=i(""),[ae,ve]=i("username"),[oe,Ne]=i(null),[ne,we]=i(!1),[Ce,le]=i(""),[Ie,Qe]=i(""),j=S({mutationFn:async()=>{if(!U.trim())throw new Error("Please enter a MAL username");const n=await c.tracker.mangaMalImport.mutate({username:U.trim(),erase:u});return{imported:n.imported??0,skipped:n.skipped??0}},onSuccess:({imported:n,skipped:v})=>{t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]}),r.success(`Imported ${n} manga entries from MAL${v>0?`, skipped ${v}`:""}`),be("")},onError:n=>r.error(n.message)}),Oe=De(async()=>{const n=document.getElementById("malMangaFile");if(!n.files||n.files.length===0){le("Please select a file first.");return}we(!0),le(""),Ne(null);try{const v=new FormData;v.append("xmlfile",n.files[0]),v.append("erase",String(u));const W=await qe("/api/import/mal-xml-manga",{method:"POST",body:v}),I=await W.json().catch(()=>({}));if(!W.ok)throw new Error(I.error||"Import failed");Ne({imported:I.imported??0,skipped:I.skipped??0}),t.invalidateQueries({queryKey:[s.mangaLibrary]}),t.invalidateQueries({queryKey:[s.mangaContinueReading]})}catch(v){le(v.message)}finally{we(!1)}},[u,t]),$=S({mutationFn:async()=>{if(!y.trim())throw new Error("Please enter a username");return(await c.tracker.anilistImport.mutate({username:y.trim(),erase:F})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from AniList`),b("")},onError:n=>r.error(n.message)}),[Q,Se]=i(""),z=S({mutationFn:async n=>{if(!Q.trim())throw new Error("Please enter a MAL username");return(await c.tracker.malImport.mutate({username:Q.trim(),erase:n.erase,useOfflineDb:n.useOfflineDb,skipFallback:n.skipFallback})).count},onSuccess:n=>{t.invalidateQueries({queryKey:[s.watchlist]}),t.invalidateQueries({queryKey:[s.continueWatching]}),r.success(`Imported ${n} anime entries from MAL`),Se("")},onError:n=>r.error(n.message)}),[F,Le]=i(!1),[O,He]=i(!0),[H,Ge]=i(!1),[Me,xe]=i(""),[K,Te]=i(!1),[A,Ae]=i(null),[de,ze]=i(null),[Pe,te]=i(""),me=ye(null),We=n=>{n.currentTarget.files&&n.currentTarget.files.length>0?xe(n.currentTarget.files[0].name):xe("")},Xe=De(async()=>{const n=document.getElementById("malFile");if(!n.files||n.files.length===0){te("Please select a file first.");return}const v=n.files[0];Te(!0),Ae(null),ze(null),te("");const W=new AbortController;me.current=W;try{const I=new FormData;I.append("xmlfile",v),I.append("erase",String(F)),I.append("useOfflineDb",String(O)),I.append("skipFallback",String(H));const ue=await qe("/api/import/mal-xml",{method:"POST",body:I,signal:W.signal});if(!ue.ok){const he=await ue.text();let X="Failed to import";try{X=JSON.parse(he).error||X}catch{}throw new Error(X)}const Be=ue.body?.getReader();if(!Be)throw new Error("No response stream");const Ve=new TextDecoder;let pe="",se="";for(;;){const{done:he,value:X}=await Be.read();if(he)break;pe+=Ve.decode(X,{stream:!0});const Ee=pe.split(`
2
2
  `);pe=Ee.pop()||"";for(const Y of Ee)if(Y.startsWith("event: "))se=Y.slice(7).trim();else if(Y.startsWith("data: ")){const Ze=Y.slice(6);try{const Fe=JSON.parse(Ze);se==="progress"?Ae(Fe):se==="complete"&&ze(Fe)}catch{}}else Y===""&&(se="")}t.invalidateQueries({queryKey:[s.watchlist]})}catch(I){I instanceof DOMException&&I.name==="AbortError"?te("Import cancelled."):te(I.message)}finally{Te(!1),me.current=null}},[F,O,H,t]),Ye=()=>{me.current?.abort(),c.settings.malImportCancel.mutate().catch(()=>{})},Je=A?Math.round(A.current/A.total*100):0,[G,je]=i("username");return e("div",{className:"page-container",children:[e("div",{className:a.header,children:[e("h1",{className:a.pageTitle,children:"Trackers"}),e("p",{className:a.pageSubtitle,children:"Import & sync your anime watchlists and manga reading lists with tracking services"})]}),e("div",{style:{marginBottom:"16px",fontSize:"0.8rem",color:"var(--color-warning)",borderBottom:"1px solid var(--border-primary)",paddingBottom:"12px"},children:"⚠ Syncing writes directly to your AniList and MyAnimeList entries, and dango may not always handle anime/manga lists correctly - always keep a backup of your lists before syncing."}),f&&e("div",{style:{marginBottom:"16px",display:"flex",alignItems:"center",gap:"10px",fontSize:"0.85rem"},children:[e("label",{htmlFor:"active-tracker-select",style:{fontWeight:600,color:"var(--text-secondary)"},children:"Active tracker:"}),e("select",{id:"active-tracker-select",value:x,onChange:n=>D.mutate(n.currentTarget.value),style:{padding:"0.3rem 0.5rem",borderRadius:"var(--radius-md)",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",fontSize:"var(--font-size-sm)",cursor:"pointer"},children:[p&&e("option",{value:"anilist",children:"AniList"}),M&&e("option",{value:"mal",children:"MyAnimeList"})]})]}),!h&&e(g,{children:e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"anilist",className:a.anilistIcon}),e("h3",{children:"AniList"}),P?null:p?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e($e,{}),p&&x!=="anilist"&&e("p",{style:{color:"var(--color-warning)",marginTop:"8px",fontSize:"0.85rem"},children:"Not the active tracker - sync disabled."}),p&&x==="anilist"&&e(g,{children:[e("hr",{className:a.divider}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"username",checked:l==="username",onChange:()=>L("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:l==="sync",onChange:()=>L("sync")}),e("span",{children:"Two-way Sync"})]})]}),l==="username"?e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:y,onChange:n=>b(n.currentTarget.value),className:a.input,disabled:$.isPending,onKeyDown:n=>{n.key==="Enter"&&y.trim()&&$.mutate()}})}):e("p",{className:a.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."}),l==="username"&&e("div",{className:a.optionsArea,children:e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:F,onChange:n=>Le(n.currentTarget.checked),className:a.checkbox,disabled:$.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Erase current watchlist"}),e("span",{className:a.optionDesc,children:"Delete existing watchlist before importing."})]})]})}),l==="username"?e("button",{className:a.syncBtn,onClick:()=>$.mutate(),disabled:!y.trim()||$.isPending,children:[e(m,{name:"download"}),$.isPending?"Importing...":"Start Import"]}):e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>T.mutate(),disabled:T.isPending,children:[e(m,{name:"sync-alt",className:T.isPending?a.spin:""}),T.isPending?"Syncing...":"Start Sync"]}),d&&e("div",{className:a.syncSummary,children:["Pushed: ",d.pushed," · Pulled: ",d.pulled," · Merged:"," ",d.merged," · Unchanged: ",d.unchanged,d.errors.length>0&&e("span",{className:a.syncErrors,children:[" ","· ",d.errors.length," error",d.errors.length>1?"s":""]})]})]})]})]})}),h&&e(g,{children:e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"anilist",className:a.anilistIcon}),e("h3",{children:"AniList Manga"}),P?null:p?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e($e,{}),p&&x!=="anilist"&&e("p",{style:{color:"var(--color-warning)",marginTop:"8px",fontSize:"0.85rem"},children:"Not the active tracker - sync disabled."}),p&&x==="anilist"&&e(g,{children:[e("hr",{className:a.divider}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"username",checked:Z==="username",onChange:()=>fe("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"sync",checked:Z==="sync",onChange:()=>fe("sync")}),e("span",{children:"Two-way Sync"})]})]}),Z==="username"?e(g,{children:[e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:E,onChange:n=>ke(n.currentTarget.value),className:a.input,disabled:q.isPending,onKeyDown:n=>{n.key==="Enter"&&E.trim()&&q.mutate()}})}),e("div",{className:a.optionsArea,children:e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:u,onChange:n=>_(n.currentTarget.checked),className:a.checkbox,disabled:q.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:a.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})})]}):e(g,{children:[e("p",{className:a.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:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"two-way",checked:ce==="two-way",onChange:()=>_e("two-way")}),e("span",{children:"Two-way"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"pull-only",checked:ce==="pull-only",onChange:()=>_e("pull-only")}),e("span",{children:"Pull only (never writes to AniList)"})]})]})]}),Z==="username"?e("button",{className:a.syncBtn,onClick:()=>q.mutate(),disabled:!E.trim()||q.isPending,children:[e(m,{name:"download"}),q.isPending?"Importing...":"Start Import"]}):e(g,{children:[e("button",{className:a.syncBtn,onClick:()=>ee.mutate(),disabled:ee.isPending,children:[e(m,{name:"sync-alt",className:ee.isPending?a.spin:""}),ee.isPending?"Syncing...":"Start Manga Sync"]}),w&&e(g,{children:[e("div",{className:a.syncSummary,children:["Pushed: ",w.pushed," · Pulled: ",w.pulled," · Merged: ",w.merged," · Unchanged:"," ",w.unchanged,(w.skipped??0)>0&&e("span",{children:[" · Skipped: ",w.skipped]}),w.errors.length>0&&e("span",{className:a.syncErrors,children:[" ","· ",w.errors.length," error",w.errors.length>1?"s":""]})]}),(w.warnings?.length??0)>0&&e("div",{className:a.syncErrors,style:{marginTop:"8px"},children:[(w.warnings??[]).slice(0,5).map((n,v)=>e("div",{children:["⚠ ",n]},v)),(w.warnings?.length??0)>5&&e("div",{children:["+",(w.warnings?.length??0)-5," more warning(s)"]})]})]})]})]})]})}),!h&&e(g,{children:e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"myanimelist",className:a.malIcon}),e("h3",{children:"MyAnimeList"}),P?null:M?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e(Ke,{active:x==="mal"}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:G==="username",onChange:()=>je("username")}),e("span",{children:"Username"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:G==="xml",onChange:()=>je("xml")}),e("span",{children:"XML File"})]})]}),G==="username"?e(g,{children:[e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:Q,onChange:n=>Se(n.currentTarget.value),className:a.input,disabled:z.isPending,onKeyDown:n=>{n.key==="Enter"&&Q.trim()&&z.mutate({erase:F,useOfflineDb:O,skipFallback:H})}})}),z.isPending&&e("div",{className:a.importLoading,children:[e(m,{name:"sync-alt",className:a.spin}),e("span",{children:"Importing from MAL..."})]})]}):e("div",{className:a.uploadArea,children:e("div",{className:a.fileInputWrapper,children:[e("input",{type:"file",id:"malFile",accept:".xml,application/xml",className:a.fileInput,onChange:We,disabled:K}),e("div",{className:a.fileDisplay,children:[e(m,{name:"file-alt",className:a.fileIcon}),e("span",{className:a.fileName,children:Me||"Choose XML file..."})]}),e("label",{htmlFor:"malFile",className:a.browseButton,children:"Browse"})]})}),e("div",{className:a.optionsArea,children:[e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:F,onChange:n=>Le(n.currentTarget.checked),className:a.checkbox,disabled:K||z.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Erase current watchlist"}),e("span",{className:a.optionDesc,children:"Delete existing watchlist before importing."})]})]}),e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:O,onChange:n=>He(n.currentTarget.checked),className:a.checkbox,disabled:K||z.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Use offline database (fast)"}),e("span",{className:a.optionDesc,children:"Match by MAL ID locally first - instant and avoids AniList rate limits."})]})]}),e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:H,onChange:n=>Ge(n.currentTarget.checked),className:a.checkbox,disabled:K||z.isPending}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Skip online fallback"}),e("span",{className:a.optionDesc,children:"Only import offline matches. Unmatched titles are skipped without API calls."})]})]})]}),G==="username"?e("button",{className:a.syncBtn,onClick:()=>z.mutate({erase:F,useOfflineDb:O,skipFallback:H}),disabled:!Q.trim()||z.isPending,children:[e(m,{name:"download"}),z.isPending?"Importing...":"Start Import"]}):e("div",{className:a.actions,children:K?e(ge,{onClick:Ye,className:a.cancelBtn,children:"Cancel Import"}):e(ge,{onClick:Xe,className:a.importBtn,disabled:!Me,children:[e(m,{name:"upload"})," Start Import"]})}),G==="username"&&z.isError&&e("div",{className:`${a.statusMessage} ${a.error}`,children:z.error.message}),K&&A&&e("div",{className:a.progressSection,children:[e("div",{className:a.progressBar,children:e("div",{className:a.progressFill,style:{width:`${Je}%`}})}),e("div",{className:a.progressInfo,children:[e("span",{className:a.progressCount,children:[A.current," / ",A.total]}),e("span",{className:a.progressTitle,children:A.found?e(g,{children:[A.matchedTitle,e("span",{className:`${a.sourceBadge} ${a[A.source||"anilist"]}`,children:A.source==="kitsu"?"Kitsu":A.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:a.skipped,children:["Skipped: ",A.title]})})]})]}),de&&e("div",{className:`${a.statusMessage} ${a.success}`,children:["Import complete! Imported: ",de.imported,", Skipped: ",de.skipped,"."]}),Pe&&e("div",{className:`${a.statusMessage} ${a.error}`,children:Pe})]})}),h&&e("div",{className:a.importCard,children:[e("div",{className:a.cardHeader,children:e("div",{className:a.cardTitleRow,children:[e(m,{name:"myanimelist",className:a.malIcon}),e("h3",{children:"MyAnimeList Manga"}),P?null:M?e("span",{className:a.badgeOnline,children:"Connected"}):e("span",{className:a.badgeOffline,children:"Not connected"})]})}),e(Ke,{kind:"manga",active:x==="mal"}),e("div",{className:a.radioGroup,children:[e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"username",checked:ae==="username",onChange:()=>ve("username")}),e("span",{children:"Username"})]}),e("label",{className:a.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"xml",checked:ae==="xml",onChange:()=>ve("xml")}),e("span",{children:"XML File"})]})]}),ae==="username"?e("div",{className:a.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:U,onChange:n=>be(n.currentTarget.value),className:a.input,disabled:j.isPending,onKeyDown:n=>{n.key==="Enter"&&U.trim()&&j.mutate()}})}):e("div",{className:a.uploadArea,children:e("div",{className:a.fileInputWrapper,children:[e("input",{type:"file",id:"malMangaFile",accept:".xml,application/xml",className:a.fileInput,onChange:n=>Qe(n.currentTarget.files?.[0]?.name??""),disabled:ne}),e("div",{className:a.fileDisplay,children:[e(m,{name:"file-alt",className:a.fileIcon}),e("span",{className:a.fileName,children:Ie||"Choose XML file..."})]}),e("label",{htmlFor:"malMangaFile",className:a.browseButton,children:"Browse"})]})}),e("div",{className:a.optionsArea,children:e("label",{className:a.checkboxLabel,children:[e("input",{type:"checkbox",checked:u,onChange:n=>_(n.currentTarget.checked),className:a.checkbox,disabled:j.isPending||ne}),e("span",{className:a.checkboxCustom}),e("div",{className:a.optionText,children:[e("span",{className:a.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:a.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})}),ae==="username"?e("button",{className:a.syncBtn,onClick:()=>j.mutate(),disabled:!U.trim()||j.isPending,children:[e(m,{name:"download"}),j.isPending?"Importing...":"Start Import"]}):e("div",{className:a.actions,children:e(ge,{onClick:Oe,className:a.importBtn,disabled:ne||!Ie,children:[e(m,{name:"upload"})," ",ne?"Importing...":"Start Import"]})}),j.isError&&e("div",{className:`${a.statusMessage} ${a.error}`,children:j.error.message}),Ce&&e("div",{className:`${a.statusMessage} ${a.error}`,children:Ce}),oe&&e("div",{className:`${a.statusMessage} ${a.success}`,children:["Import complete! Imported: ",oe.imported,", Skipped:"," ",oe.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{In as default};