@serifpersia/dango 3.4.5 → 3.4.6

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 (64) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-I3S6qw9d.js → AnimeCard-BVdH0EeW.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-CLU2NSBR.js → AnimeInfo-Dw2Nop6Q.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-4Mw9ArDy.js → AnimeInfoPage-Cw-Tq3YX.js} +2 -2
  5. package/client/dist/assets/{Asmr-DN9XBc5Y.js → Asmr-BrjzzyOi.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-DyU1Z2Gw.js → AsmrResetProgressModal-CYjpcYpb.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-DxL0mr_4.js → AvSyncCalibrator-BuHurVgo.js} +3 -3
  8. package/client/dist/assets/AvSyncCalibrator-D0FYSwiz.css +1 -0
  9. package/client/dist/assets/{Home-CeTeJ-gM.js → Home-KdnP7sNM.js} +1 -1
  10. package/client/dist/assets/{Insights-i34-qV4C.js → Insights-DDWry-t1.js} +1 -1
  11. package/client/dist/assets/{LibraryListPage-DE-ASOX2.js → LibraryListPage-CV8Z9JlO.js} +1 -1
  12. package/client/dist/assets/{ListeningList-DrNce5ll.js → ListeningList-DSMbMZT7.js} +1 -1
  13. package/client/dist/assets/{Manga-DOrf7Fk6.js → Manga-J6XoqEKq.js} +1 -1
  14. package/client/dist/assets/{MangaInfoPage-CAZMLMGw.js → MangaInfoPage-N7TxsN5u.js} +1 -1
  15. package/client/dist/assets/{MangaReadPage-DQVEo8_F.js → MangaReadPage-D_VzSNWq.js} +1 -1
  16. package/client/dist/assets/{MangaResetProgressModal-DOjpLAMp.js → MangaResetProgressModal-DyhQYBDy.js} +1 -1
  17. package/client/dist/assets/{Mature-D2xb9EGB.js → Mature-Db53R-LR.js} +1 -1
  18. package/client/dist/assets/{MediaCard-CKUEcFTd.js → MediaCard-BcLjlpfR.js} +1 -1
  19. package/client/dist/assets/{Music-w_a34r7r.js → Music-DjxQjJOl.js} +1 -1
  20. package/client/dist/assets/{OptionListMenu-DxZHBMIZ.js → OptionListMenu-DngTgHxH.js} +1 -1
  21. package/client/dist/assets/Player-Be_7Ne5p.js +56 -0
  22. package/client/dist/assets/{PlayerSettings-Ddlg-MvW.js → PlayerSettings-D47ItGDR.js} +1 -1
  23. package/client/dist/assets/{QueueOptionsButton-BMvAC6Ut.js → QueueOptionsButton-ClVTpH8J.js} +1 -1
  24. package/client/dist/assets/{QueueRail-CAoGJvHP.js → QueueRail-DeJKVRs5.js} +1 -1
  25. package/client/dist/assets/{Radio-6O7rAUv1.js → Radio-DU0ma3GA.js} +1 -1
  26. package/client/dist/assets/{ReadingList-k3g8oHvs.js → ReadingList-qXW7Dk5z.js} +1 -1
  27. package/client/dist/assets/{ResetProgressModal-vFC6N-Qw.js → ResetProgressModal-C6ukct_c.js} +1 -1
  28. package/client/dist/assets/{Search-Bh9Y6nIJ.js → Search-DjjKA_Wu.js} +1 -1
  29. package/client/dist/assets/{Settings-DRumujfh.js → Settings-DQt_S5Qw.js} +1 -1
  30. package/client/dist/assets/{SkeletonGrid-BtzUnQE0.js → SkeletonGrid-nx2HEi4P.js} +1 -1
  31. package/client/dist/assets/{Trackers-D0nqy8wu.js → Trackers-BcGzeqj2.js} +1 -1
  32. package/client/dist/assets/Tv-COvyHdeJ.js +4 -0
  33. package/client/dist/assets/{TvInfo-BkECbOKN.js → TvInfo-CUd1agFy.js} +1 -1
  34. package/client/dist/assets/{TvPopup-D8WWY6o4.js → TvPopup-CJeu3tgc.js} +1 -1
  35. package/client/dist/assets/{TvSearch-kWPep3gL.js → TvSearch-BIypjbU3.js} +1 -1
  36. package/client/dist/assets/{TvWatchlist-dD4emIHx.js → TvWatchlist-DZrBdiqZ.js} +1 -1
  37. package/client/dist/assets/{Watchlist-cWxw38nU.js → Watchlist-Dw8cPe0n.js} +1 -1
  38. package/client/dist/assets/{hls-uG_Y3i5s.js → hls-B3_1VuDP.js} +1 -1
  39. package/client/dist/assets/{index-BWIWE3Qy.js → index-gMxawd-E.js} +2 -2
  40. package/client/dist/assets/{useAnimeInfoData-DjPBg24u.js → useAnimeInfoData-_iOLEAa8.js} +1 -1
  41. package/client/dist/assets/{useAsmr-DQyobNQX.js → useAsmr-Blk4v41t.js} +1 -1
  42. package/client/dist/assets/{useAsmrPopup-CDoroMBD.js → useAsmrPopup-D9SQIgZa.js} +1 -1
  43. package/client/dist/assets/{useMangaLibrary-C6L8mrnS.js → useMangaLibrary-B60at6ni.js} +1 -1
  44. package/client/dist/assets/{useMangaPopup-BSuMa_vA.js → useMangaPopup-DEfGjWSu.js} +1 -1
  45. package/client/dist/assets/{useProviders-XIdvDof6.js → useProviders-Ca0bZWt7.js} +1 -1
  46. package/client/dist/assets/{useTv-DzSYasru.js → useTv-WJCDL5_5.js} +1 -1
  47. package/client/dist/assets/{useTvLibrary-BnbHS-gg.js → useTvLibrary-Fgn5i9rJ.js} +1 -1
  48. package/client/dist/index.html +1 -1
  49. package/package.json +2 -2
  50. package/server/dist/hono/proxy.js +102 -75
  51. package/server/dist/hono/tv.js +2 -2
  52. package/server/dist/hono/watchlist.js +2 -291
  53. package/server/dist/lib/anilist.js +0 -3
  54. package/server/dist/lib/mal.js +0 -38
  55. package/server/dist/lib/offline-db.js +0 -6
  56. package/server/dist/providers/remote-loader.js +15 -26
  57. package/server/dist/providers/title-matching.js +5 -5
  58. package/server/dist/repositories/manga.repository.js +0 -1
  59. package/server/dist/repositories/watched-episodes.repository.js +0 -2
  60. package/server/dist/utils/megaplay.utils.js +1 -2
  61. package/server/package.json +1 -1
  62. package/client/dist/assets/AvSyncCalibrator-C2wu1ydI.css +0 -1
  63. package/client/dist/assets/Player-B8YHeATv.js +0 -56
  64. package/client/dist/assets/Tv-DVebLMNS.js +0 -4
@@ -1 +1 @@
1
- import{g as s,u as n,a as Y}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{d as L,f as z}from"./index-BWIWE3Qy.js";const F="_section_1pwqc_1",O="_header_1pwqc_10",j="_headerToggle_1pwqc_20",G="_headerActions_1pwqc_34",J="_title_1pwqc_40",K="_badge_1pwqc_50",V="_clearBtn_1pwqc_65",W="_nextBtn_1pwqc_83",Z="_list_1pwqc_101",ee="_item_1pwqc_114",ne="_active_1pwqc_134",te="_dragging_1pwqc_142",re="_dragHandle_1pwqc_149",ce="_thumbnail_1pwqc_167",ae="_meta_1pwqc_175",oe="_name_1pwqc_182",se="_episode_1pwqc_204",ie="_iconBtn_1pwqc_210",r={section:F,header:O,headerToggle:j,headerActions:G,title:J,badge:K,clearBtn:V,nextBtn:W,list:Z,item:ee,active:ne,dragging:te,dragHandle:re,thumbnail:ce,meta:ae,name:oe,episode:se,iconBtn:ie},le=({item:c,isActive:T,index:m,onRemove:D,onTouchPointerDown:v,onTouchPointerMove:x,onTouchPointerUp:q,onTouchPointerCancel:I,shouldIgnoreClick:_,onDragStart:B,onDragEnter:f,onDragEnd:o,isDragging:w})=>{const a=Y(),{titlePreference:i}=L(),l=c[i]||c.name||"Unknown show";return n("div",{"data-queue-index":m,className:`${r.item} ${T?r.active:""} ${w?r.dragging:""}`,draggable:!0,onDragStart:B,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:o,onPointerDown:u=>v(m,u),onPointerMove:x,onPointerUp:q,onPointerCancel:I,children:[n("button",{className:r.dragHandle,type:"button","aria-label":"Drag queue item",children:n(P,{name:"bars"})}),n("img",{className:r.thumbnail,src:z(c.thumbnail||"",72,96),alt:l,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:r.meta,children:[n("button",{className:r.name,type:"button",onClick:()=>{_()||a(`/watch/${c.showId}/${c.episodeNumber}`)},children:l}),n("div",{className:r.episode,children:["Episode ",c.episodeNumber]})]}),n("button",{className:r.iconBtn,type:"button",onClick:()=>{_()||D(c)},"aria-label":`Remove ${l} episode ${c.episodeNumber} from queue`,children:n(P,{name:"times"})})]})},he=({title:c="Queue",eyebrow:T,items:m,currentShowId:D,currentEpisode:v,onRemove:x,onReorder:q,onNextQueue:I,onClear:_,showClearAll:B=!1,defaultExpanded:f=!0})=>{const[o,w]=s.useState([]),[a,i]=s.useState(null),[l,u]=s.useState(f),b=s.useRef(null),N=s.useRef(null),d=s.useRef(null),p=s.useRef(!1),R=s.useRef(!1);s.useEffect(()=>{w(m)},[m]),s.useEffect(()=>{u(f)},[f]);const E=e=>{i(e)},$=e=>{if(a===null||a===e)return;const t=[...o],h=t[a];t.splice(a,1),t.splice(e,0,h),i(e),w(t)},k=()=>{a!==null&&q(o.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),i(null)},C=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&p.current&&(q(o.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),R.current=!0,window.setTimeout(()=>{R.current=!1},0)),b.current=null,N.current=null,p.current=!1,i(null)},A=(e,t)=>{if(t.pointerType==="mouse")return;const h=t.currentTarget,g=t.pointerId;b.current=t.pointerId,N.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{p.current=!0,i(e);try{h.setPointerCapture(g)}catch{}},220)},Q=e=>{if(e.pointerType==="mouse"||b.current!==e.pointerId)return;if(!p.current&&N.current){const H=Math.abs(e.clientX-N.current.x),X=Math.abs(e.clientY-N.current.y);(H>8||X>8)&&C(!1);return}if(!p.current)return;e.preventDefault();const h=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),g=h?Number(h.dataset.queueIndex):NaN;if(Number.isNaN(g)||a===null||g===a)return;const y=[...o],U=y[a];y.splice(a,1),y.splice(g,0,U),i(g),w(y)},S=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(p.current)},M=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(!1)};return o.length===0?null:n("section",{className:r.section,children:[n("div",{className:r.header,children:[n("button",{className:r.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":l,"aria-label":l?`Collapse ${c}`:`Expand ${c}`,children:[n("span",{className:r.title,children:[n("span",{className:"title-stack",children:[T&&n("div",{className:"section-eyebrow",children:T}),n("span",{children:c})]}),n("span",{className:r.badge,children:o.length})]}),l?n(P,{name:"chevron-up"}):n(P,{name:"chevron-down"})]}),B&&_&&n("div",{className:r.headerActions,children:[I&&o.length>1&&n("button",{className:r.nextBtn,type:"button",onClick:I,children:"Next"}),n("button",{className:r.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),l&&n("div",{className:r.list,children:o.map((e,t)=>n(le,{item:e,isActive:e.showId===D&&e.episodeNumber===v,index:t,onRemove:x,onTouchPointerDown:A,onTouchPointerMove:Q,onTouchPointerUp:S,onTouchPointerCancel:M,shouldIgnoreClick:()=>R.current,onDragStart:()=>E(t),onDragEnter:()=>$(t),onDragEnd:k,isDragging:a===t},e.id))})]})};export{he as Q,r as s};
1
+ import{g as s,u as n,a as Y}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{d as L,f as z}from"./index-gMxawd-E.js";const F="_section_1pwqc_1",O="_header_1pwqc_10",j="_headerToggle_1pwqc_20",G="_headerActions_1pwqc_34",J="_title_1pwqc_40",K="_badge_1pwqc_50",V="_clearBtn_1pwqc_65",W="_nextBtn_1pwqc_83",Z="_list_1pwqc_101",ee="_item_1pwqc_114",ne="_active_1pwqc_134",te="_dragging_1pwqc_142",re="_dragHandle_1pwqc_149",ce="_thumbnail_1pwqc_167",ae="_meta_1pwqc_175",oe="_name_1pwqc_182",se="_episode_1pwqc_204",ie="_iconBtn_1pwqc_210",r={section:F,header:O,headerToggle:j,headerActions:G,title:J,badge:K,clearBtn:V,nextBtn:W,list:Z,item:ee,active:ne,dragging:te,dragHandle:re,thumbnail:ce,meta:ae,name:oe,episode:se,iconBtn:ie},le=({item:c,isActive:T,index:m,onRemove:D,onTouchPointerDown:v,onTouchPointerMove:x,onTouchPointerUp:q,onTouchPointerCancel:I,shouldIgnoreClick:_,onDragStart:B,onDragEnter:f,onDragEnd:o,isDragging:w})=>{const a=Y(),{titlePreference:i}=L(),l=c[i]||c.name||"Unknown show";return n("div",{"data-queue-index":m,className:`${r.item} ${T?r.active:""} ${w?r.dragging:""}`,draggable:!0,onDragStart:B,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:o,onPointerDown:u=>v(m,u),onPointerMove:x,onPointerUp:q,onPointerCancel:I,children:[n("button",{className:r.dragHandle,type:"button","aria-label":"Drag queue item",children:n(P,{name:"bars"})}),n("img",{className:r.thumbnail,src:z(c.thumbnail||"",72,96),alt:l,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:r.meta,children:[n("button",{className:r.name,type:"button",onClick:()=>{_()||a(`/watch/${c.showId}/${c.episodeNumber}`)},children:l}),n("div",{className:r.episode,children:["Episode ",c.episodeNumber]})]}),n("button",{className:r.iconBtn,type:"button",onClick:()=>{_()||D(c)},"aria-label":`Remove ${l} episode ${c.episodeNumber} from queue`,children:n(P,{name:"times"})})]})},he=({title:c="Queue",eyebrow:T,items:m,currentShowId:D,currentEpisode:v,onRemove:x,onReorder:q,onNextQueue:I,onClear:_,showClearAll:B=!1,defaultExpanded:f=!0})=>{const[o,w]=s.useState([]),[a,i]=s.useState(null),[l,u]=s.useState(f),b=s.useRef(null),N=s.useRef(null),d=s.useRef(null),p=s.useRef(!1),R=s.useRef(!1);s.useEffect(()=>{w(m)},[m]),s.useEffect(()=>{u(f)},[f]);const E=e=>{i(e)},$=e=>{if(a===null||a===e)return;const t=[...o],h=t[a];t.splice(a,1),t.splice(e,0,h),i(e),w(t)},k=()=>{a!==null&&q(o.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),i(null)},C=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&p.current&&(q(o.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),R.current=!0,window.setTimeout(()=>{R.current=!1},0)),b.current=null,N.current=null,p.current=!1,i(null)},A=(e,t)=>{if(t.pointerType==="mouse")return;const h=t.currentTarget,g=t.pointerId;b.current=t.pointerId,N.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{p.current=!0,i(e);try{h.setPointerCapture(g)}catch{}},220)},Q=e=>{if(e.pointerType==="mouse"||b.current!==e.pointerId)return;if(!p.current&&N.current){const H=Math.abs(e.clientX-N.current.x),X=Math.abs(e.clientY-N.current.y);(H>8||X>8)&&C(!1);return}if(!p.current)return;e.preventDefault();const h=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),g=h?Number(h.dataset.queueIndex):NaN;if(Number.isNaN(g)||a===null||g===a)return;const y=[...o],U=y[a];y.splice(a,1),y.splice(g,0,U),i(g),w(y)},S=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(p.current)},M=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(!1)};return o.length===0?null:n("section",{className:r.section,children:[n("div",{className:r.header,children:[n("button",{className:r.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":l,"aria-label":l?`Collapse ${c}`:`Expand ${c}`,children:[n("span",{className:r.title,children:[n("span",{className:"title-stack",children:[T&&n("div",{className:"section-eyebrow",children:T}),n("span",{children:c})]}),n("span",{className:r.badge,children:o.length})]}),l?n(P,{name:"chevron-up"}):n(P,{name:"chevron-down"})]}),B&&_&&n("div",{className:r.headerActions,children:[I&&o.length>1&&n("button",{className:r.nextBtn,type:"button",onClick:I,children:"Next"}),n("button",{className:r.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),l&&n("div",{className:r.list,children:o.map((e,t)=>n(le,{item:e,isActive:e.showId===D&&e.episodeNumber===v,index:t,onRemove:x,onTouchPointerDown:A,onTouchPointerMove:Q,onTouchPointerUp:S,onTouchPointerCancel:M,shouldIgnoreClick:()=>R.current,onDragStart:()=>E(t),onDragEnter:()=>$(t),onDragEnd:k,isDragging:a===t},e.id))})]})};export{he as Q,r as s};
@@ -1 +1 @@
1
- import{d as h,A as O,h as y,g as ne,u as e,S as L,$ as _,T as J}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{b as Y}from"./vendor-query-BBT5_sHx.js";import{h as Z,t as K,W as se}from"./index-BWIWE3Qy.js";import{a}from"./Asmr.module-ChUXDZKx.js";import{r as i}from"./Radio.module-DGSZLpKM.js";const x=300*1e3,re="https://cdn.listen.moe/covers/";function W(n){return n?n.startsWith("http")?n:`${re}${n}`:null}function le(n){return n?W(n.albums[0]?.image)||W(n.artists[0]?.image)||W(n.sources[0]?.image):null}function F(n){return n?n.artists.map(s=>s.nameRomaji||s.name).join(", "):""}const oe=()=>{const n=Z();return Y({...n.radio.stations.queryOptions(),staleTime:x})},ie=n=>{const s=Z();return Y({...s.radio.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:x})},G={song:null,lastPlayed:[],listeners:0,startTime:null},ce=n=>{const[s,p]=h(G),[l,c]=h(!1),d=O(null);return y(()=>{if(p(G),c(!1),!n)return;let m=null,f=!1;try{m=new WebSocket(n)}catch{return}return m.onopen=()=>{f||c(!0)},m.onmessage=v=>{try{const u=JSON.parse(v.data);if(u.op===0){const N=u.d?.heartbeat||35e3;d.current&&window.clearInterval(d.current),d.current=window.setInterval(()=>{m&&m.readyState===WebSocket.OPEN&&m.send(JSON.stringify({op:9}))},N)}else u.op===1&&p({song:u.d?.song||null,lastPlayed:u.d?.lastPlayed||[],listeners:u.d?.listeners||0,startTime:u.d?.startTime||null})}catch{}},m.onclose=()=>{f||c(!1)},()=>{f=!0,d.current&&window.clearInterval(d.current),d.current=null,m&&m.close()}},[n]),{nowPlaying:s,connected:l}};function X(n){if(!n)return"";const s=Math.max(0,Math.floor((Date.now()-new Date(n).getTime())/1e3)),p=Math.floor(s/60),l=s%60;return`${p}:${String(l).padStart(2,"0")}`}const de=({station:n,nowPlaying:s,connected:p,expanded:l,onStationStep:c,onExpandedChange:d,onClose:m})=>{const f=O(null),[v,u]=h(!1),[N,U]=h(!0),[S,I]=h(!1),[P,k]=h(!0),[M,T]=h(""),[b,A]=h(()=>{const t=parseFloat(localStorage.getItem("radioVolume")||"");return Number.isFinite(t)?t:1}),r=O(""),g=O(b);g.current=b,r.current||(r.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`radio-${Date.now()}-${Math.random().toString(36).slice(2)}`);const w=s.song,C=le(w)||n.favicon||null,[E,q]=h(!1);y(()=>{q(!1)},[C]);const B=E?null:C,V=!!B,R=w?`${F(w)} — ${w.title}`:n.name;y(()=>{const t=f.current;if(t)return u(!1),t.src=n.streamUrl,t.load(),t.volume=g.current,t.play().catch(()=>u(!1)),()=>{t.removeAttribute("src")}},[n.id,n.streamUrl]),y(()=>{const t=f.current;t&&(t.volume=b)},[b]),y(()=>{if(l)return document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")},[l]),y(()=>{l&&k(!0)},[l]);const ee=t=>t?Math.max(0,Math.floor((Date.now()-new Date(t).getTime())/1e3)):0,D=ne.useCallback(t=>{n&&(K.discord.radioPresence.mutate({title:R,stationLabel:n.name,isPlaying:t,thumbnail:B||"",currentTime:ee(s.startTime),sessionId:r.current}).catch(()=>{}),K.discord.heartbeat.mutate({sessionId:r.current}).catch(()=>{}))},[n,R,B,s.startTime]);y(()=>{D(v)},[D,v,n.id,R,l]),y(()=>{if(!v)return;const t=window.setInterval(()=>D(!0),15e3);return()=>window.clearInterval(t)},[v,D]),y(()=>{const t=r.current,$=()=>se(t),H=()=>$(),Q=()=>{document.visibilityState==="hidden"&&$()};return window.addEventListener("pagehide",H),window.addEventListener("beforeunload",H),document.addEventListener("visibilitychange",Q),()=>{window.removeEventListener("pagehide",H),window.removeEventListener("beforeunload",H),document.removeEventListener("visibilitychange",Q),$()}},[]),y(()=>{if(!s.startTime){T("");return}T(X(s.startTime));const t=window.setInterval(()=>T(X(s.startTime)),1e3);return()=>window.clearInterval(t)},[s.startTime,s.song?.id]),y(()=>{if(!l)return;const t=$=>{$.key==="Escape"&&(S?I(!1):d(!1))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[l,S,d]);const te=()=>{const t=f.current;t&&(t.paused?(t.load(),t.play().catch(()=>{})):t.pause())},ae=e(L,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>c(-1),"aria-label":"Previous station",children:e(o,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:te,"aria-label":v?"Pause":"Play",children:v?e(o,{name:"pause"}):e(o,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>c(1),"aria-label":"Next station",children:e(o,{name:"step-forward"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:i.liveBadge,children:[e(o,{name:"broadcast-tower",size:10})," LIVE"]}),M&&e("span",{className:a.timeLabel,children:M}),p&&s.listeners>0&&e("span",{className:a.timeLabel,children:[s.listeners," listening"]}),!p&&n.source==="listen.moe"&&e("span",{className:a.timeLabel,children:"connecting…"})]})]}),z=e(L,{children:[e("button",{className:`${a.playerBtn} ${a.playerToggle}`,onClick:()=>d(!l),"aria-label":l?"Minimize player":"Expand player",title:l?"Minimize to browse":"Expand",children:l?e(o,{name:"chevron-down"}):e(o,{name:"chevron-up"})}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:R,children:R}),e("p",{className:a.playerTrack,children:n.name})]}),e("div",{className:a.playerControls,children:ae}),e("div",{className:a.playerRight,children:[b===0?e(o,{name:"volume-mute",className:a.volumeIcon}):b<.5?e(o,{name:"volume-down",className:a.volumeIcon}):e(o,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:b,onChange:t=>{const $=parseFloat(t.target.value);A($),localStorage.setItem("radioVolume",String($))},style:{"--volume-percent":`${b*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[l&&V&&e("button",{className:a.playerBtn,onClick:()=>U(t=>!t),"aria-label":N?"Hide art":"Show art",title:N?"Hide art":"Show art",children:N?e(o,{name:"eye-slash"}):e(o,{name:"image"})}),l&&s.lastPlayed.length>0&&e("button",{className:`${a.playerBtn} ${S?a.playerBtnActive:""}`,onClick:()=>I(t=>!t),"aria-label":S?"Hide history":"Show history",title:"Recently played",children:e(o,{name:"list-ol"})}),e("button",{className:a.playerBtn,onClick:m,"aria-label":"Close player",children:e(o,{name:"times"})})]})]}),j=e("audio",{ref:f,preload:"none",onPlay:()=>u(!0),onPause:()=>u(!1)});return l?_(e(L,{children:[j,e("div",{className:`${a.npOverlay} ${P?"":a.npOverlayControlsHidden}`,children:[e("div",{className:`${a.npStage} ${!N||!V?a.npStageBlank:""}`,onClick:()=>k(t=>!t),children:N&&V&&B&&e("div",{className:i.coverWrap,children:e("img",{src:B,alt:R,loading:"lazy",decoding:"async",draggable:!1,className:i.cover,onError:()=>q(!0)})})}),e("div",{className:`${a.playerBar} ${a.playerBarDocked} ${P?"":a.playerBarDockedHidden}`,onClick:t=>t.stopPropagation(),children:[z,S&&e(L,{children:[e("div",{className:a.npBackdrop,onClick:()=>I(!1)}),e("div",{className:a.chapterPanel,children:s.lastPlayed.map(t=>e("div",{className:a.chapterRow,children:e("span",{className:a.chapterRowLabel,title:`${F(t)} — ${t.title}`,children:[F(t)," — ",t.title]})},t.id))})]})]})]})]}),document.body):_(e(L,{children:[j,e("div",{className:a.playerBar,children:z})]}),document.body)},ve=()=>{y(()=>{document.title="Radio - dango"},[]);const[n,s]=h(""),[p,l]=h(""),[c,d]=h(null),[m,f]=h(!0),{data:v,isLoading:u}=oe(),{data:N,isLoading:U}=ie(p),S=J(()=>v?.stations||[],[v]),I=J(()=>N?.stations||[],[N]),P=p?I:S,{nowPlaying:k,connected:M}=ce(c?.gateway),T=r=>{d(r),f(!0)},b=r=>{const g=P.length>0?P:S;if(g.length===0||!c)return;const w=g.findIndex(E=>E.id===c.id),C=g[(w<0?0:w+r+g.length)%g.length];d(C)},A=r=>{const g=c?.id===r.id,w=g&&k.song?`${F(k.song)} — ${k.song.title}`:null,C=[r.codec,r.bitrate?`${r.bitrate}k`:"",r.tags].filter(Boolean).join(" · ");return e("button",{className:`${i.stationRow} ${g?i.stationRowActive:""}`,onClick:()=>T(r),children:[r.favicon?e("img",{src:r.favicon,alt:"",className:i.stationThumb,loading:"lazy",decoding:"async",onError:E=>{E.target.style.display="none"}}):e("span",{className:i.stationThumbPlaceholder,children:e(o,{name:"broadcast-tower"})}),e("span",{className:i.stationMeta,children:[e("span",{className:i.stationName,children:r.name}),C&&e("span",{className:i.stationSub,children:C})]}),w&&e("span",{className:i.stationNowPlaying,children:w})]},r.id)};return e("div",{className:`${a.page} ${c?a.pageWithPlayer:""}`,children:[e("div",{className:a.header,children:[e("h1",{className:a.pageTitle,children:[e(o,{name:"broadcast-tower"})," Radio"]}),e("form",{className:a.searchForm,onSubmit:r=>{r.preventDefault(),l(n)},children:[e("input",{className:a.searchInput,value:n,onChange:r=>s(r.target.value),placeholder:"Search stations (anime, j-pop, k-pop…)","aria-label":"Search radio stations"}),e("button",{className:a.searchBtn,type:"submit","aria-label":"Search",children:e(o,{name:"search"})})]})]}),p?e(L,{children:[e("h2",{className:i.sectionTitle,children:["Results for “",p,"”"]}),U?e("p",{className:a.statusMsg,children:"Searching…"}):I.length===0?e("p",{className:a.statusMsg,children:"No stations found."}):e("div",{className:i.stationList,children:I.map(A)})]}):e(L,{children:[e("h2",{className:i.sectionTitle,children:"Featured"}),u?e("p",{className:a.statusMsg,children:"Loading…"}):e("div",{className:i.stationList,children:S.map(A)})]}),c&&e(de,{station:c,nowPlaying:k,connected:M,expanded:m,onStationStep:b,onExpandedChange:f,onClose:()=>d(null)})]})};export{ve as default};
1
+ import{d as h,A as O,h as y,g as ne,u as e,S as L,$ as _,T as J}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{b as Y}from"./vendor-query-BBT5_sHx.js";import{h as Z,t as K,W as se}from"./index-gMxawd-E.js";import{a}from"./Asmr.module-ChUXDZKx.js";import{r as i}from"./Radio.module-DGSZLpKM.js";const x=300*1e3,re="https://cdn.listen.moe/covers/";function W(n){return n?n.startsWith("http")?n:`${re}${n}`:null}function le(n){return n?W(n.albums[0]?.image)||W(n.artists[0]?.image)||W(n.sources[0]?.image):null}function F(n){return n?n.artists.map(s=>s.nameRomaji||s.name).join(", "):""}const oe=()=>{const n=Z();return Y({...n.radio.stations.queryOptions(),staleTime:x})},ie=n=>{const s=Z();return Y({...s.radio.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:x})},G={song:null,lastPlayed:[],listeners:0,startTime:null},ce=n=>{const[s,p]=h(G),[l,c]=h(!1),d=O(null);return y(()=>{if(p(G),c(!1),!n)return;let m=null,f=!1;try{m=new WebSocket(n)}catch{return}return m.onopen=()=>{f||c(!0)},m.onmessage=v=>{try{const u=JSON.parse(v.data);if(u.op===0){const N=u.d?.heartbeat||35e3;d.current&&window.clearInterval(d.current),d.current=window.setInterval(()=>{m&&m.readyState===WebSocket.OPEN&&m.send(JSON.stringify({op:9}))},N)}else u.op===1&&p({song:u.d?.song||null,lastPlayed:u.d?.lastPlayed||[],listeners:u.d?.listeners||0,startTime:u.d?.startTime||null})}catch{}},m.onclose=()=>{f||c(!1)},()=>{f=!0,d.current&&window.clearInterval(d.current),d.current=null,m&&m.close()}},[n]),{nowPlaying:s,connected:l}};function X(n){if(!n)return"";const s=Math.max(0,Math.floor((Date.now()-new Date(n).getTime())/1e3)),p=Math.floor(s/60),l=s%60;return`${p}:${String(l).padStart(2,"0")}`}const de=({station:n,nowPlaying:s,connected:p,expanded:l,onStationStep:c,onExpandedChange:d,onClose:m})=>{const f=O(null),[v,u]=h(!1),[N,U]=h(!0),[S,I]=h(!1),[P,k]=h(!0),[M,T]=h(""),[b,A]=h(()=>{const t=parseFloat(localStorage.getItem("radioVolume")||"");return Number.isFinite(t)?t:1}),r=O(""),g=O(b);g.current=b,r.current||(r.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`radio-${Date.now()}-${Math.random().toString(36).slice(2)}`);const w=s.song,C=le(w)||n.favicon||null,[E,q]=h(!1);y(()=>{q(!1)},[C]);const B=E?null:C,V=!!B,R=w?`${F(w)} — ${w.title}`:n.name;y(()=>{const t=f.current;if(t)return u(!1),t.src=n.streamUrl,t.load(),t.volume=g.current,t.play().catch(()=>u(!1)),()=>{t.removeAttribute("src")}},[n.id,n.streamUrl]),y(()=>{const t=f.current;t&&(t.volume=b)},[b]),y(()=>{if(l)return document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")},[l]),y(()=>{l&&k(!0)},[l]);const ee=t=>t?Math.max(0,Math.floor((Date.now()-new Date(t).getTime())/1e3)):0,D=ne.useCallback(t=>{n&&(K.discord.radioPresence.mutate({title:R,stationLabel:n.name,isPlaying:t,thumbnail:B||"",currentTime:ee(s.startTime),sessionId:r.current}).catch(()=>{}),K.discord.heartbeat.mutate({sessionId:r.current}).catch(()=>{}))},[n,R,B,s.startTime]);y(()=>{D(v)},[D,v,n.id,R,l]),y(()=>{if(!v)return;const t=window.setInterval(()=>D(!0),15e3);return()=>window.clearInterval(t)},[v,D]),y(()=>{const t=r.current,$=()=>se(t),H=()=>$(),Q=()=>{document.visibilityState==="hidden"&&$()};return window.addEventListener("pagehide",H),window.addEventListener("beforeunload",H),document.addEventListener("visibilitychange",Q),()=>{window.removeEventListener("pagehide",H),window.removeEventListener("beforeunload",H),document.removeEventListener("visibilitychange",Q),$()}},[]),y(()=>{if(!s.startTime){T("");return}T(X(s.startTime));const t=window.setInterval(()=>T(X(s.startTime)),1e3);return()=>window.clearInterval(t)},[s.startTime,s.song?.id]),y(()=>{if(!l)return;const t=$=>{$.key==="Escape"&&(S?I(!1):d(!1))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[l,S,d]);const te=()=>{const t=f.current;t&&(t.paused?(t.load(),t.play().catch(()=>{})):t.pause())},ae=e(L,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>c(-1),"aria-label":"Previous station",children:e(o,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:te,"aria-label":v?"Pause":"Play",children:v?e(o,{name:"pause"}):e(o,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>c(1),"aria-label":"Next station",children:e(o,{name:"step-forward"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:i.liveBadge,children:[e(o,{name:"broadcast-tower",size:10})," LIVE"]}),M&&e("span",{className:a.timeLabel,children:M}),p&&s.listeners>0&&e("span",{className:a.timeLabel,children:[s.listeners," listening"]}),!p&&n.source==="listen.moe"&&e("span",{className:a.timeLabel,children:"connecting…"})]})]}),z=e(L,{children:[e("button",{className:`${a.playerBtn} ${a.playerToggle}`,onClick:()=>d(!l),"aria-label":l?"Minimize player":"Expand player",title:l?"Minimize to browse":"Expand",children:l?e(o,{name:"chevron-down"}):e(o,{name:"chevron-up"})}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:R,children:R}),e("p",{className:a.playerTrack,children:n.name})]}),e("div",{className:a.playerControls,children:ae}),e("div",{className:a.playerRight,children:[b===0?e(o,{name:"volume-mute",className:a.volumeIcon}):b<.5?e(o,{name:"volume-down",className:a.volumeIcon}):e(o,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:b,onChange:t=>{const $=parseFloat(t.target.value);A($),localStorage.setItem("radioVolume",String($))},style:{"--volume-percent":`${b*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[l&&V&&e("button",{className:a.playerBtn,onClick:()=>U(t=>!t),"aria-label":N?"Hide art":"Show art",title:N?"Hide art":"Show art",children:N?e(o,{name:"eye-slash"}):e(o,{name:"image"})}),l&&s.lastPlayed.length>0&&e("button",{className:`${a.playerBtn} ${S?a.playerBtnActive:""}`,onClick:()=>I(t=>!t),"aria-label":S?"Hide history":"Show history",title:"Recently played",children:e(o,{name:"list-ol"})}),e("button",{className:a.playerBtn,onClick:m,"aria-label":"Close player",children:e(o,{name:"times"})})]})]}),j=e("audio",{ref:f,preload:"none",onPlay:()=>u(!0),onPause:()=>u(!1)});return l?_(e(L,{children:[j,e("div",{className:`${a.npOverlay} ${P?"":a.npOverlayControlsHidden}`,children:[e("div",{className:`${a.npStage} ${!N||!V?a.npStageBlank:""}`,onClick:()=>k(t=>!t),children:N&&V&&B&&e("div",{className:i.coverWrap,children:e("img",{src:B,alt:R,loading:"lazy",decoding:"async",draggable:!1,className:i.cover,onError:()=>q(!0)})})}),e("div",{className:`${a.playerBar} ${a.playerBarDocked} ${P?"":a.playerBarDockedHidden}`,onClick:t=>t.stopPropagation(),children:[z,S&&e(L,{children:[e("div",{className:a.npBackdrop,onClick:()=>I(!1)}),e("div",{className:a.chapterPanel,children:s.lastPlayed.map(t=>e("div",{className:a.chapterRow,children:e("span",{className:a.chapterRowLabel,title:`${F(t)} — ${t.title}`,children:[F(t)," — ",t.title]})},t.id))})]})]})]})]}),document.body):_(e(L,{children:[j,e("div",{className:a.playerBar,children:z})]}),document.body)},ve=()=>{y(()=>{document.title="Radio - dango"},[]);const[n,s]=h(""),[p,l]=h(""),[c,d]=h(null),[m,f]=h(!0),{data:v,isLoading:u}=oe(),{data:N,isLoading:U}=ie(p),S=J(()=>v?.stations||[],[v]),I=J(()=>N?.stations||[],[N]),P=p?I:S,{nowPlaying:k,connected:M}=ce(c?.gateway),T=r=>{d(r),f(!0)},b=r=>{const g=P.length>0?P:S;if(g.length===0||!c)return;const w=g.findIndex(E=>E.id===c.id),C=g[(w<0?0:w+r+g.length)%g.length];d(C)},A=r=>{const g=c?.id===r.id,w=g&&k.song?`${F(k.song)} — ${k.song.title}`:null,C=[r.codec,r.bitrate?`${r.bitrate}k`:"",r.tags].filter(Boolean).join(" · ");return e("button",{className:`${i.stationRow} ${g?i.stationRowActive:""}`,onClick:()=>T(r),children:[r.favicon?e("img",{src:r.favicon,alt:"",className:i.stationThumb,loading:"lazy",decoding:"async",onError:E=>{E.target.style.display="none"}}):e("span",{className:i.stationThumbPlaceholder,children:e(o,{name:"broadcast-tower"})}),e("span",{className:i.stationMeta,children:[e("span",{className:i.stationName,children:r.name}),C&&e("span",{className:i.stationSub,children:C})]}),w&&e("span",{className:i.stationNowPlaying,children:w})]},r.id)};return e("div",{className:`${a.page} ${c?a.pageWithPlayer:""}`,children:[e("div",{className:a.header,children:[e("h1",{className:a.pageTitle,children:[e(o,{name:"broadcast-tower"})," Radio"]}),e("form",{className:a.searchForm,onSubmit:r=>{r.preventDefault(),l(n)},children:[e("input",{className:a.searchInput,value:n,onChange:r=>s(r.target.value),placeholder:"Search stations (anime, j-pop, k-pop…)","aria-label":"Search radio stations"}),e("button",{className:a.searchBtn,type:"submit","aria-label":"Search",children:e(o,{name:"search"})})]})]}),p?e(L,{children:[e("h2",{className:i.sectionTitle,children:["Results for “",p,"”"]}),U?e("p",{className:a.statusMsg,children:"Searching…"}):I.length===0?e("p",{className:a.statusMsg,children:"No stations found."}):e("div",{className:i.stationList,children:I.map(A)})]}):e(L,{children:[e("h2",{className:i.sectionTitle,children:"Featured"}),u?e("p",{className:a.statusMsg,children:"Loading…"}):e("div",{className:i.stationList,children:S.map(A)})]}),c&&e(de,{station:c,nowPlaying:k,connected:M,expanded:m,onStationStep:b,onExpandedChange:f,onClose:()=>d(null)})]})};export{ve as default};
@@ -1 +1 @@
1
- import{o as U,d as v,h as b,T as w,u as i,S as E}from"./vendor-core-DfaOB3Rn.js";import{M as x}from"./MediaCard-CKUEcFTd.js";import{L as F}from"./LibraryListPage-DE-ASOX2.js";import{u as _,M as z}from"./useMangaPopup-BSuMa_vA.js";import{M as D}from"./MangaResetProgressModal-DOjpLAMp.js";import{x as G,d as O,o as Q,p as Y,u as q,y as H,z as K,A as V,M as h,m as Z,i as j,b as J,c as W}from"./useMangaLibrary-C6L8mrnS.js";import"./vendor-ui-3qrARCPr.js";import"./vendor-icons-DrybRNxP.js";import"./index-BWIWE3Qy.js";import"./vendor-query-BBT5_sHx.js";import"./useIsMobile-Dvx1uJ82.js";import"./SkeletonGrid-BtzUnQE0.js";import"./ErrorMessage-DAxegITP.js";import"./Watchlist.module-XGtVQr1d.js";import"./ResetProgressModal-vFC6N-Qw.js";const X=["All","Continue Reading",...h],R=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 va(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=G(r?"All":e,g,R),s=O(100),I=Q(),T=Y(),{toggle:L,bookmarkedIds:C}=q(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:M}=_(),f=H(),P=K(),B=V(),S=w(()=>r?(s.data?.data??[]).map(a=>{const o=a.page??0,l=a.pageCount??0;return{key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title,altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.chapterNumber?`Ch. ${a.chapterNumber}`:void 0,progressPercent:l>0?o/l*100:0,progressLabel:a.chapterNumber&&l>0?`Ch. ${a.chapterNumber} · p. ${o}/${l}`:void 0,detailTarget:a.chapterId&&a.provider&&a.mangaId?`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}/read?chapter=${encodeURIComponent(a.chapterId)}`:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`}}):(n.data?.data??[]).map(a=>({key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title,altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.lastChapterNumber?`Ch. ${a.lastChapterNumber}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`})),[r,s.data,n.data]),A=r?s.data?.total??0:n.data?.total??0,$=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...h],entries:S,total:A,isLoading:$,error:N,page:g,pageSize:R,onPageChange:p,emptyTitle:"Your reading list is looking a bit lonely",emptyFilteredText:"No titles match this filter.",emptyAllText:"Let's find something to read!",browseLabel:"Browse Manga",browseTarget:"/manga",removeListLabel:"Remove from Reading List",listNoun:"reading list",skipConfirmKey:"mangaSkipRemoveConfirmation",onBulkStatus:(a,o)=>f.mutate({ids:a,status:o}),onBulkRemove:a=>{r?B.mutate(a):P.mutate(a)},onStatusChange:(a,o)=>T.mutate({id:a,status:o}),onRemoveItem:a=>I.mutate(a),renderCard:a=>i(x,{item:{id:a.libId,title:a.title,...W({title:a.title,altTitle:a.altTitle}),thumbnail:J(a.provider,a.cover),chapterBadge:a.chapterLabel??null,isAdult:j(a)},linkTo:a.detailTarget,hoverIcon:"book",progress:a.progressPercent!==void 0&&a.progressLabel?{percent:a.progressPercent,label:a.progressLabel}:void 0,showProgress:r,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:r?()=>u(a):void 0,onOpenDetails:o=>k(o,y(a)),onPopupHoverIntent:o=>o?m():c(),rawThumbnail:!0}),modals:i(E,{children:[t&&t.data.provider&&i(z,{data:t.data,anchorRect:t.rect,bookmarked:C.has(Z(t.data.provider,t.data.mangaId)),onToggleBookmark:()=>L({id:t.data.mangaId,provider:t.data.provider,title:t.data.title,cover:t.data.cover,altTitle:t.data.altTitle??void 0,contentRating:t.data.contentRating}),onMouseEnter:m,onMouseLeave:c,onRequestClose:M}),i(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{va as default};
1
+ import{o as U,d as v,h as b,T as w,u as i,S as E}from"./vendor-core-DfaOB3Rn.js";import{M as x}from"./MediaCard-BcLjlpfR.js";import{L as F}from"./LibraryListPage-CV8Z9JlO.js";import{u as _,M as z}from"./useMangaPopup-DEfGjWSu.js";import{M as D}from"./MangaResetProgressModal-DyhQYBDy.js";import{x as G,d as O,o as Q,p as Y,u as q,y as H,z as K,A as V,M as h,m as Z,i as j,b as J,c as W}from"./useMangaLibrary-B60at6ni.js";import"./vendor-ui-3qrARCPr.js";import"./vendor-icons-DrybRNxP.js";import"./index-gMxawd-E.js";import"./vendor-query-BBT5_sHx.js";import"./useIsMobile-Dvx1uJ82.js";import"./SkeletonGrid-nx2HEi4P.js";import"./ErrorMessage-DAxegITP.js";import"./Watchlist.module-XGtVQr1d.js";import"./ResetProgressModal-C6ukct_c.js";const X=["All","Continue Reading",...h],R=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 va(){const{filter:e="All"}=U(),[g,p]=v(1),[d,u]=v(null);b(()=>{document.title="Reading List - dango"},[]),b(()=>{p(1)},[e]);const r=e==="Continue Reading",n=G(r?"All":e,g,R),s=O(100),I=Q(),T=Y(),{toggle:L,bookmarkedIds:C}=q(),{popup:t,openPopup:k,scheduleClose:c,cancelClose:m,closePopup:M}=_(),f=H(),P=K(),B=V(),S=w(()=>r?(s.data?.data??[]).map(a=>{const o=a.page??0,l=a.pageCount??0;return{key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title,altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.chapterNumber?`Ch. ${a.chapterNumber}`:void 0,progressPercent:l>0?o/l*100:0,progressLabel:a.chapterNumber&&l>0?`Ch. ${a.chapterNumber} · p. ${o}/${l}`:void 0,detailTarget:a.chapterId&&a.provider&&a.mangaId?`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}/read?chapter=${encodeURIComponent(a.chapterId)}`:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`}}):(n.data?.data??[]).map(a=>({key:a.id,libId:a.id,provider:a.provider,mangaId:a.mangaId,title:a.title,altTitle:a.altTitle,cover:a.cover||"",status:a.status,contentRating:a.contentRating||void 0,chapterLabel:a.lastChapterNumber?`Ch. ${a.lastChapterNumber}`:void 0,progressPercent:void 0,progressLabel:void 0,detailTarget:`/manga/${a.provider}/${encodeURIComponent(a.mangaId)}`})),[r,s.data,n.data]),A=r?s.data?.total??0:n.data?.total??0,$=r?s.isLoading:n.isLoading,N=r?s.error:n.error;return i(F,{headerTitle:"My Reading List",headerSubtitle:"Track and manage your manga collection",filters:X,filterBy:e,filterBasePath:"/reading-list",continueFilter:"Continue Reading",statusOptions:[...h],entries:S,total:A,isLoading:$,error:N,page:g,pageSize:R,onPageChange:p,emptyTitle:"Your reading list is looking a bit lonely",emptyFilteredText:"No titles match this filter.",emptyAllText:"Let's find something to read!",browseLabel:"Browse Manga",browseTarget:"/manga",removeListLabel:"Remove from Reading List",listNoun:"reading list",skipConfirmKey:"mangaSkipRemoveConfirmation",onBulkStatus:(a,o)=>f.mutate({ids:a,status:o}),onBulkRemove:a=>{r?B.mutate(a):P.mutate(a)},onStatusChange:(a,o)=>T.mutate({id:a,status:o}),onRemoveItem:a=>I.mutate(a),renderCard:a=>i(x,{item:{id:a.libId,title:a.title,...W({title:a.title,altTitle:a.altTitle}),thumbnail:J(a.provider,a.cover),chapterBadge:a.chapterLabel??null,isAdult:j(a)},linkTo:a.detailTarget,hoverIcon:"book",progress:a.progressPercent!==void 0&&a.progressLabel?{percent:a.progressPercent,label:a.progressLabel}:void 0,showProgress:r,display:{elements:{poster:{typeBadge:!1,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!1}}},onRemove:r?()=>u(a):void 0,onOpenDetails:o=>k(o,y(a)),onPopupHoverIntent:o=>o?m():c(),rawThumbnail:!0}),modals:i(E,{children:[t&&t.data.provider&&i(z,{data:t.data,anchorRect:t.rect,bookmarked:C.has(Z(t.data.provider,t.data.mangaId)),onToggleBookmark:()=>L({id:t.data.mangaId,provider:t.data.provider,title:t.data.title,cover:t.data.cover,altTitle:t.data.altTitle??void 0,contentRating:t.data.contentRating}),onMouseEnter:m,onMouseLeave:c,onRequestClose:M}),i(D,{mangaId:d?d.libId:null,title:d?.title,onClose:()=>u(null)})]})})}export{va as default};
@@ -1 +1 @@
1
- import{u as e}from"./vendor-core-DfaOB3Rn.js";import{M as r,B as n}from"./index-BWIWE3Qy.js";const p=({isOpen:t,itemName:c,progressKind:i,listLabel:s,alsoRemove:a,onAlsoRemoveChange:d,onClose:o,onConfirm:l})=>e(r,{isOpen:t,onClose:o,title:"Reset Progress",children:[e(r.Body,{children:[e("p",{children:["Are you sure you want to remove your ",i,' progress for "',c,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:a,onChange:h=>d(h.target.checked)}),"Also remove from ",s]})]}),e(r.Actions,{children:[e(n,{variant:"secondary",onClick:o,children:"No"}),e(n,{variant:"danger",onClick:l,children:"Yes"})]})]});export{p as R};
1
+ import{u as e}from"./vendor-core-DfaOB3Rn.js";import{M as r,B as n}from"./index-gMxawd-E.js";const p=({isOpen:t,itemName:c,progressKind:i,listLabel:s,alsoRemove:a,onAlsoRemoveChange:d,onClose:o,onConfirm:l})=>e(r,{isOpen:t,onClose:o,title:"Reset Progress",children:[e(r.Body,{children:[e("p",{children:["Are you sure you want to remove your ",i,' progress for "',c,'"?']}),e("label",{children:[e("input",{type:"checkbox",checked:a,onChange:h=>d(h.target.checked)}),"Also remove from ",s]})]}),e(r.Actions,{children:[e(n,{variant:"secondary",onClick:o,children:"No"}),e(n,{variant:"danger",onClick:l,children:"Yes"})]})]});export{p as R};
@@ -1 +1 @@
1
- import{h as O,p as me,a as ge,d as o,A as ve,g as fe,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as L}from"./vendor-icons-DrybRNxP.js";import{P as ee,S as Le}from"./SkeletonGrid-BtzUnQE0.js";import{A as Ae}from"./AnimeCard-I3S6qw9d.js";import{t as be,u as ye,v as Se,R as ae,B as w,U as Ne}from"./index-BWIWE3Qy.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{s as t}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-DjPBg24u.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-BMvAC6Ut.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-CKUEcFTd.js";import"./useIsMobile-Dvx1uJ82.js";const Te=[{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"}],Ee=[{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"}],Pe=[{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 Ve(){O(()=>{document.title="Search - dango"},[]);const[r,te]=me(),le=ge(),[h,k]=o(r.get("query")||""),[p,_]=o(parseInt(r.get("page")||"1")),[u,A]=o(r.get("type")||"ALL"),[m,b]=o(r.get("season")||"ALL"),[g,y]=o(r.get("year")||"ALL"),[B,E]=o(r.get("country")||"ALL"),[G,ne]=o(r.get("provider")||"anilist"),[Y,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[U,D]=o(r.get("status")||""),[S,re]=o(!1),[se,F]=o(null);O(()=>{let e=!1;return be.data.anilistStatus.query().then(n=>{e||F(n.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:ie}=ye(),P=ve(null),{data:oe}=Se(),M=oe?.genres||[],[v,N]=o(()=>{const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),e}),$=new URLSearchParams(r);$.delete("page");const V=$.toString(),{data:f=[],isLoading:C,isError:ce,error:ue}=ae(V,p,14),{data:j}=ae(V,p+1,14),[x,de]=o(!1),T=fe.useMemo(()=>G==="anilist"&&u==="ADULT"||x?f:f.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[f,x,G,u]);O(()=>{k(r.get("query")||""),A(r.get("type")||"ALL"),b(r.get("season")||"ALL"),y(r.get("year")||"ALL"),E(r.get("country")||"ALL"),ne(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),_(parseInt(r.get("page")||"1"));const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const c=(e=1,n={})=>{Ne();const s=n.type??u,l=n.status??U,q=n.season??m,H=n.year??g,J=n.country??B,K=n.sort??Y,Q=n.genreState??v,pe=n.showMature??x,i=new URLSearchParams;h.trim()&&i.set("query",h.trim()),s!=="ALL"&&i.set("type",s),l&&i.set("status",l),q!=="ALL"&&i.set("season",q),H!=="ALL"&&i.set("year",H),J!=="ALL"&&i.set("country",J),K!=="POPULARITY_DESC"&&i.set("sortBy",K);const X=Object.entries(Q).filter(([,d])=>d==="include").map(([d])=>d),Z=Object.entries(Q).filter(([,d])=>d==="exclude").map(([d])=>d);X.length>0&&i.set("genres",X.join(",")),Z.length>0&&i.set("excludeGenres",Z.join(",")),s!=="ADULT"&&!pe&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),te(i),e!==p&&_(e)},W=e=>{if(c(e),P.current){const n=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},R=new Date().getFullYear(),he=[{value:"ALL",label:"All Years"},...Array.from({length:R-1980+1},(e,n)=>({value:String(R-n),label:String(R-n)}))],z=f.length>=14&&j&&j.length>0;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(L,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:h,onInput:e=>k(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(w,{onClick:()=>c(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${S?t.active:""}`,onClick:()=>re(!S),children:[a(L,{name:"filter",size:14}),a("span",{children:"Filters"}),S?a(L,{name:"chevron-up",size:12}):a(L,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${S?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:u,onChange:e=>{if(e.currentTarget.value==="ADULT"){le("/mature?provider=mal");return}A(e.currentTarget.value)},children:Te.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:U,onChange:e=>D(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Pe.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:m,onChange:e=>b(e.currentTarget.value),children:Ee.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:g,onChange:e=>y(e.currentTarget.value),children:he.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",se===!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:B,onChange:e=>E(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:Y,onChange:e=>I(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),M.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:M.map(e=>a("button",{className:`${t.genreButton} ${t[v[e]||""]}`,onClick:()=>{N(n=>{const s=n[e],l={...n};return s==="include"?l[e]="exclude":s==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(w,{variant:"secondary",onClick:()=>{N({}),A("ALL"),b("ALL"),y("ALL"),E("ALL"),I("POPULARITY_DESC"),D(""),de(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(w,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ce&&a(Ce,{message:ue?.message||"Error"}),(u!=="ALL"||m!=="ALL"||g!=="ALL"||Object.keys(v).length>0)&&a("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",marginBottom:"1.5rem"},children:[a("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),u!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Type: ",u,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),A("ALL"),c(1,{type:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),m!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Season: ",m,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),b("ALL"),c(1,{season:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),g!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Year: ",g,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),y("ALL"),c(1,{year:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),Object.entries(v).map(([e,n])=>a("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${e}`:`- ${e}`,a("button",{onClick:s=>{s.stopPropagation(),s.preventDefault();const l={...v};delete l[e],N(l),c(1,{genreState:l})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e))]}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:h?`Search Results for "${h}"`:"Discover Anime"}),T.length>0&&a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${ie?t.lowEnd:""}`,children:C?a(Le,{}):T.map(e=>a(Ae,{anime:e},e._id))}),!C&&T.length===0&&a("div",{className:t.noResults,children:[a(L,{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."})]}),T.length>0&&a("div",{className:t.bottomPagination,children:a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C,variant:"labeled"})})]})}export{Ve as default};
1
+ import{h as O,p as me,a as ge,d as o,A as ve,g as fe,u as a}from"./vendor-core-DfaOB3Rn.js";import{I as L}from"./vendor-icons-DrybRNxP.js";import{P as ee,S as Le}from"./SkeletonGrid-nx2HEi4P.js";import{A as Ae}from"./AnimeCard-BVdH0EeW.js";import{t as be,u as ye,v as Se,R as ae,B as w,U as Ne}from"./index-gMxawd-E.js";import{E as Ce}from"./ErrorMessage-DAxegITP.js";import{s as t}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-_iOLEAa8.js";import"./vendor-query-BBT5_sHx.js";import"./QueueOptionsButton-ClVTpH8J.js";import"./vendor-ui-3qrARCPr.js";import"./MediaCard-BcLjlpfR.js";import"./useIsMobile-Dvx1uJ82.js";const Te=[{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"}],Ee=[{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"}],Pe=[{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 Ve(){O(()=>{document.title="Search - dango"},[]);const[r,te]=me(),le=ge(),[h,k]=o(r.get("query")||""),[p,_]=o(parseInt(r.get("page")||"1")),[u,A]=o(r.get("type")||"ALL"),[m,b]=o(r.get("season")||"ALL"),[g,y]=o(r.get("year")||"ALL"),[B,E]=o(r.get("country")||"ALL"),[G,ne]=o(r.get("provider")||"anilist"),[Y,I]=o(r.get("sortBy")||"POPULARITY_DESC"),[U,D]=o(r.get("status")||""),[S,re]=o(!1),[se,F]=o(null);O(()=>{let e=!1;return be.data.anilistStatus.query().then(n=>{e||F(n.available)}).catch(()=>{e||F(!0)}),()=>{e=!0}},[]);const{lowEndMode:ie}=ye(),P=ve(null),{data:oe}=Se(),M=oe?.genres||[],[v,N]=o(()=>{const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];return n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),e}),$=new URLSearchParams(r);$.delete("page");const V=$.toString(),{data:f=[],isLoading:C,isError:ce,error:ue}=ae(V,p,14),{data:j}=ae(V,p+1,14),[x,de]=o(!1),T=fe.useMemo(()=>G==="anilist"&&u==="ADULT"||x?f:f.filter(e=>!(e.isAdult||e.rating==="R+"||e.rating==="Rx"||e.rating?.includes("17+"))),[f,x,G,u]);O(()=>{k(r.get("query")||""),A(r.get("type")||"ALL"),b(r.get("season")||"ALL"),y(r.get("year")||"ALL"),E(r.get("country")||"ALL"),ne(r.get("provider")||"anilist"),I(r.get("sortBy")||"POPULARITY_DESC"),D(r.get("status")||""),_(parseInt(r.get("page")||"1"));const e={},n=r.get("genres")?.split(",").map(l=>l.trim()).filter(Boolean)||[],s=r.get("excludeGenres")?.split(",").map(l=>l.trim()).filter(Boolean)||[];n.forEach(l=>l&&(e[l]="include")),s.forEach(l=>l&&(e[l]="exclude")),N(e)},[r]);const c=(e=1,n={})=>{Ne();const s=n.type??u,l=n.status??U,q=n.season??m,H=n.year??g,J=n.country??B,K=n.sort??Y,Q=n.genreState??v,pe=n.showMature??x,i=new URLSearchParams;h.trim()&&i.set("query",h.trim()),s!=="ALL"&&i.set("type",s),l&&i.set("status",l),q!=="ALL"&&i.set("season",q),H!=="ALL"&&i.set("year",H),J!=="ALL"&&i.set("country",J),K!=="POPULARITY_DESC"&&i.set("sortBy",K);const X=Object.entries(Q).filter(([,d])=>d==="include").map(([d])=>d),Z=Object.entries(Q).filter(([,d])=>d==="exclude").map(([d])=>d);X.length>0&&i.set("genres",X.join(",")),Z.length>0&&i.set("excludeGenres",Z.join(",")),s!=="ADULT"&&!pe&&i.set("adult","false"),i.set("provider","anilist"),e>1&&i.set("page",e.toString()),te(i),e!==p&&_(e)},W=e=>{if(c(e),P.current){const n=P.current.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:n,behavior:"smooth"})}},R=new Date().getFullYear(),he=[{value:"ALL",label:"All Years"},...Array.from({length:R-1980+1},(e,n)=>({value:String(R-n),label:String(R-n)}))],z=f.length>=14&&j&&j.length>0;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(L,{name:"search",className:t.searchIcon}),a("input",{type:"text","data-virtual-keyboard":"true",className:t.searchInput,placeholder:"Search by title, character, or studio...",value:h,onInput:e=>k(e.currentTarget.value),onKeyDown:e=>e.key==="Enter"&&c()})]}),a("div",{className:t.searchActions,children:[a(w,{onClick:()=>c(),className:t.searchBtn,children:"Search"}),a("button",{className:`${t.filterToggleBtn} ${S?t.active:""}`,onClick:()=>re(!S),children:[a(L,{name:"filter",size:14}),a("span",{children:"Filters"}),S?a(L,{name:"chevron-up",size:12}):a(L,{name:"chevron-down",size:12})]})]})]}),a("div",{className:`${t.advancedFilters} ${S?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:u,onChange:e=>{if(e.currentTarget.value==="ADULT"){le("/mature?provider=mal");return}A(e.currentTarget.value)},children:Te.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:U,onChange:e=>D(e.currentTarget.value),children:[a("option",{value:"",children:"All Status"}),Pe.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:m,onChange:e=>b(e.currentTarget.value),children:Ee.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:g,onChange:e=>y(e.currentTarget.value),children:he.map(e=>a("option",{value:e.value,children:e.label},e.value))})]}),a("div",{className:t.filterItem,children:[a("label",{children:["Country",se===!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:B,onChange:e=>E(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:Y,onChange:e=>I(e.currentTarget.value),children:De.map(e=>a("option",{value:e.value,children:e.label},e.value))})]})]}),M.length>0&&a("div",{className:t.genreSection,children:[a("label",{className:t.genreLabel,children:"Genres"}),a("div",{className:t.genreContainer,children:M.map(e=>a("button",{className:`${t.genreButton} ${t[v[e]||""]}`,onClick:()=>{N(n=>{const s=n[e],l={...n};return s==="include"?l[e]="exclude":s==="exclude"?delete l[e]:l[e]="include",l})},children:e},e))})]}),a("div",{className:t.filterActions,children:[a(w,{variant:"secondary",onClick:()=>{N({}),A("ALL"),b("ALL"),y("ALL"),E("ALL"),I("POPULARITY_DESC"),D(""),de(!1),c(1,{type:"ALL",status:"",season:"ALL",year:"ALL",country:"ALL",sort:"POPULARITY_DESC",genreState:{},showMature:!1})},children:"Reset All"}),a(w,{onClick:()=>c(),className:t.applyBtn,children:"Apply Filters"})]})]})]}),ce&&a(Ce,{message:ue?.message||"Error"}),(u!=="ALL"||m!=="ALL"||g!=="ALL"||Object.keys(v).length>0)&&a("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",marginBottom:"1.5rem"},children:[a("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:600},children:"Active Filters:"}),u!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Type: ",u,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),A("ALL"),c(1,{type:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),m!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Season: ",m,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),b("ALL"),c(1,{season:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),g!=="ALL"&&a("span",{className:"badge badge-secondary",style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:["Year: ",g,a("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),y("ALL"),c(1,{year:"ALL"})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]}),Object.entries(v).map(([e,n])=>a("span",{className:`badge ${n==="include"?"badge-primary":"badge-danger"}`,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[n==="include"?`+ ${e}`:`- ${e}`,a("button",{onClick:s=>{s.stopPropagation(),s.preventDefault();const l={...v};delete l[e],N(l),c(1,{genreState:l})},style:{background:"none",border:"none",color:"inherit",cursor:"pointer"},children:"✕"})]},e))]}),a("div",{className:t.resultsHeader,ref:P,children:[a("h2",{className:t.resultsTitle,children:h?`Search Results for "${h}"`:"Discover Anime"}),T.length>0&&a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C})]}),a("div",{className:`${t.resultsGrid} ${ie?t.lowEnd:""}`,children:C?a(Le,{}):T.map(e=>a(Ae,{anime:e},e._id))}),!C&&T.length===0&&a("div",{className:t.noResults,children:[a(L,{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."})]}),T.length>0&&a("div",{className:t.bottomPagination,children:a(ee,{page:p,canGoNext:z,onChange:W,isLoading:C,variant:"labeled"})})]})}export{Ve as default};
@@ -1,4 +1,4 @@
1
- import{d as r,A as V,h as A,u as e,q as ae,S as te,T as Le,p as xe,a as Pe,g as pe,_ as Ae}from"./vendor-core-DfaOB3Rn.js";import{d as Oe,t as b,B as I,M as F,j as ve,h as Ue,T as H,z as ye,F as oe,G as Me,H as Ee,u as $e,e as Ge,I as Fe,y as fe,A as Ke,J as He,K as Be,V as ze,L as qe,N as je,O as We}from"./index-BWIWE3Qy.js";import{u as ue}from"./vendor-query-BBT5_sHx.js";import{I as W}from"./vendor-icons-DrybRNxP.js";const ce={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},le=["name","nativeName","englishName"],de={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ve=()=>{const{titlePreference:t,setTitlePreference:s,loading:i}=Oe(),[c,h]=r(de[t]),[d,_]=r(!1),m=V(null);A(()=>{i||h(de[t])},[t,i]);const a=async()=>{if(d)return;_(!0);const f=(le.indexOf(t)+1)%le.length,p=le[f],l=de[p];m.current&&(m.current.style.transform="translateX(-100%)",m.current.style.opacity="0"),setTimeout(async()=>{h(l),s(p),m.current&&(m.current.style.transition="none",m.current.style.transform="translateX(100%)",m.current.style.opacity="0",m.current.offsetWidth,m.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",m.current.style.transform="translateX(0)",m.current.style.opacity="1");try{await b.settings.set.mutate({key:"titlePreference",value:p})}catch(T){console.error("Error saving title preference:",T)}finally{_(!1)}},300)};return i?e("p",{children:"Loading title preference..."}):e("div",{className:ce["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ce["toggle-button"],disabled:d,children:e("span",{ref:m,className:ce["toggle-label"],children:c})})]})},Ye="_settingsHeader_14a5d_1",Je="_pageTitle_14a5d_6",Qe="_pageSubtitle_14a5d_14",Xe="_settingsLayout_14a5d_20",Ze="_sidebar_14a5d_27",et="_sidebarIndicator_14a5d_35",tt="_sidebarItem_14a5d_50",at="_active_14a5d_72",nt="_mainContent_14a5d_80",st="_tabContent_14a5d_85",rt="_sectionCard_14a5d_103",it="_settingItem_14a5d_127",ot="_settingRow_14a5d_132",ct="_controls_14a5d_145",lt="_status_14a5d_151",g={settingsHeader:Ye,pageTitle:Je,pageSubtitle:Qe,settingsLayout:Xe,sidebar:Ze,sidebarIndicator:et,sidebarItem:tt,active:at,mainContent:nt,tabContent:st,sectionCard:rt,settingItem:it,settingRow:ot,controls:ct,status:lt},dt="_sectionCard_wt900_12",ut="_title_wt900_22",ht="_signIn_wt900_29",gt="_userInfo_wt900_36",mt="_warning_wt900_58",pt="_formGroup_wt900_65",yt="_label_wt900_69",ft="_inputWrapper_wt900_79",wt="_input_wt900_79",vt="_select_wt900_103",bt="_actions_wt900_140",_t="_hr_wt900_148",y={sectionCard:dt,title:ut,signIn:ht,userInfo:gt,warning:mt,formGroup:pt,label:yt,inputWrapper:ft,input:wt,select:vt,actions:bt,hr:_t},kt=()=>{const[t,s]=r(!0),[i,c]=r(!1),[h,d]=r(!1),[_,m]=r(null),[a,u]=r({status:"idle"}),[f,p]=r(!1),[l,T]=r(""),[w,C]=r(!1),x=V(null),[L,D]=r({show:!1,message:"",type:"info"}),O=()=>{x.current&&(window.clearInterval(x.current),x.current=null)},N=ae(S=>{d(S.authenticated),m(S.user||S.device.user||null),u(S.device),p(!!S.hasCustomClientId)},[]),R=ae(async()=>{const S=await b.auth.githubStatus.query();N(S)},[N]),M=async()=>{try{const S=await b.auth.githubPoll.query();u(S),S.status==="success"?(O(),await R(),D({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):S.status==="error"&&(O(),D({show:!0,message:S.error||"GitHub authentication failed.",type:"error"}))}catch{O(),D({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},v=(S=5)=>{O(),x.current=window.setInterval(M,Math.max(S,5)*1e3)};A(()=>(R().catch(()=>{D({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>s(!1)),O),[R]);const k=async()=>{c(!0);try{const S=await b.auth.githubStart.mutate();u(S),v(S.verification?.interval)}catch(S){D({show:!0,message:S instanceof Error?S.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},U=async()=>{try{await b.auth.githubLogout.mutate(),d(!1),m(null),u({status:"idle"}),D({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{D({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},E=async()=>{C(!0);try{await b.auth.saveGithubAuth.mutate({clientId:l}),T(""),await R(),D({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{D({show:!0,message:"Failed to save override.",type:"error"})}finally{C(!1)}},z=async()=>{C(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),T(""),await R(),D({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{D({show:!0,message:"Failed to clear override.",type:"error"})}finally{C(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:y.sectionCard,children:[e("h3",{className:y.title,children:"GitHub Cloud Sync"}),e("p",{className:y.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),h&&_?e("div",{className:y.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:_.name||_.login})]}),e(I,{variant:"danger",onClick:U,children:"Sign Out"})]}):e("div",{className:y.signIn,children:e(I,{onClick:k,disabled:i||a.status==="pending",children:i||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(te,{children:[e("hr",{className:y.hr}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Verification URL"}),e("div",{className:y.inputWrapper,children:[e("input",{className:y.input,value:a.verification.verification_uri,readOnly:!0}),e(I,{onClick:()=>{const S=a.verification?.verification_uri;S&&/^https?:\/\//i.test(S)&&window.open(S,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Device Code"}),e("input",{className:y.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:y.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 ",f?"(override active)":""]}),e("div",{className:y.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:y.label,children:"Client ID (optional)"}),e("input",{className:y.input,value:l,onChange:S=>T(S.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:y.actions,children:[e(I,{onClick:E,disabled:w,children:"Save override"}),e(I,{variant:"secondary",onClick:z,disabled:w,children:"Use dango defaults"})]})]}),e(F,{isOpen:L.show,onClose:()=>D(S=>({...S,show:!1})),width:"sm",children:[e(F.Body,{children:e("p",{children:L.message})}),e(F.Actions,{children:e(I,{onClick:()=>D(S=>({...S,show:!1})),children:"OK"})})]})]})},St=()=>{const[t,s]=r(!0),[i,c]=r(null),[h,d]=r(!1),[_,m]=r(!1),[a,u]=r(""),[f,p]=r(""),[l,T]=r(""),[w,C]=r(!1),[x,L]=r({show:!1,message:"",type:"info"}),D=async()=>{try{const k=await b.auth.user.query();c(k?.email?k:null)}catch{c(null)}},O=async()=>{try{const[k,U]=await Promise.all([b.auth.configStatus.query(),b.auth.googleAuth.query()]);d(!!k.hasConfig),m(!!(U.hasCustomWorkerUrl||U.hasCustomClientId||U.hasClientSecret))}catch(k){console.error("Failed to fetch config status",k)}};A(()=>{(async()=>{s(!0),await Promise.all([D(),O()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await D(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const U=E=>{E.origin===window.location.origin&&typeof E.data=="object"&&E.data!==null&&E.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(E.data.user),window.location.reload())};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[]);const N=async()=>{try{const k=await b.auth.googleLogin.mutate();if(k.authenticated){window.location.reload();return}if(k.url){if(typeof window.DangoBridge<"u"){window.location.href=k.url;return}const E=600,z=700,S=window.innerWidth/2-E/2,ne=window.innerHeight/2-z/2;window.open(k.url,"GoogleAuth",`width=${E},height=${z},top=${ne},left=${S}`)}else throw new Error("Auth URL not available")}catch{L({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},R=async()=>{try{await b.auth.logout.mutate(),c(null),L({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(k){console.error("Sign out failed",k),L({show:!0,message:"Failed to sign out.",type:"error"})}},M=async()=>{C(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:f,clientSecret:l}),u(""),p(""),T(""),await O(),L({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{C(!1)}},v=async()=>{C(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),u(""),p(""),T(""),await O(),L({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{L({show:!0,message:"Failed to clear override.",type:"error"})}finally{C(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:y.sectionCard,children:[e("h3",{className:y.title,children:"Google Drive Sync"}),i?e("div",{className:y.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:i.name})," (",i.email,")"]}),e(I,{variant:"danger",onClick:R,children:"Sign Out"})]}):e("div",{className:y.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(I,{onClick:N,disabled:!h,children:"Sign in with Google"}),!h&&e("p",{className:y.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 ",_?"(override active)":""]}),e("div",{className:y.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:y.label,children:"Worker URL (optional)"}),e("input",{className:y.input,value:a,onChange:k=>u(k.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Client ID (optional)"}),e("input",{className:y.input,value:f,onChange:k=>p(k.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:y.input,value:l,onChange:k=>T(k.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:y.actions,children:[e(I,{onClick:M,disabled:w,children:"Save override"}),e(I,{variant:"secondary",onClick:v,disabled:w,children:"Use dango defaults"})]})]}),e(F,{isOpen:x.show,onClose:()=>L(k=>({...k,show:!1})),width:"sm",children:[e(F.Body,{children:e("p",{children:x.message})}),e(F.Actions,{children:e(I,{onClick:()=>L(k=>({...k,show:!1})),children:"OK"})})]})]})},Ct="_sectionCard_1pqo4_1",Nt="_settingItem_1pqo4_26",Tt="_settingRow_1pqo4_31",Rt="_modalOverlay_1pqo4_38",Dt="_modal_1pqo4_38",It="_modalActions_1pqo4_73",Lt="_modalSecondary_1pqo4_79",xt="_modalPrimary_1pqo4_89",G={sectionCard:Ct,settingItem:Nt,settingRow:Tt,modalOverlay:Rt,modal:Dt,modalActions:It,modalSecondary:Lt,modalPrimary:xt},Pt={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"]]}},At=(t,s)=>{if(t==null)return s;const i=String(t);return i==="true"||i==="1"?!0:i==="false"||i==="0"?!1:s},we=(t,s,i)=>{const[c,h]=r(s),[d,_]=r(!1),m=ue();return A(()=>{(async()=>{try{const f=await b.settings.getByKey.query({key:t});h(At(f.value,s))}catch(f){console.error("Failed to fetch setting",f)}})()},[t,s]),{value:c,setValue:h,isUpdating:d,toggle:async()=>{if(d)return;_(!0);const u=!c;h(u);try{await b.settings.set.mutate({key:t,value:u});for(const f of i)m.invalidateQueries({queryKey:f})}catch(f){console.error("Error saving setting:",f),h(!u)}finally{_(!1)}}}},Ot=()=>{const{contentType:t}=ve(),s=Pt[t],[i,c]=r(!1),[h,d]=r(!0),[_,m]=r(!1),a=we(s.ignoreKey,!0,s.invalidateKeys),u=we(s.listOnlyKey,!1,s.invalidateKeys),[f,p]=r(null),[l,T]=r(!1),w=ue(),C=Ue();A(()=>{d(!0),(async()=>{try{const R=await b.settings.getByKey.query({key:s.skipKey});String(R.value)==="true"||String(R.value)==="1"?c(!0):c(!1)}catch(R){console.error("Failed to fetch setting",R)}finally{d(!1)}})()},[s.skipKey]);const x=async()=>{if(_)return;m(!0);const N=!i;c(N);try{await b.settings.set.mutate({key:s.skipKey,value:N})}catch(R){console.error("Error saving setting:",R),c(!N)}finally{m(!1)}},L=async()=>{if(!a.isUpdating){if(a.value)try{let N;if(t==="anime"?N=(await b.continueWatching.adultCount.query()).count:t==="manga"?N=(await b.mangaProgress.adultCount.query()).count:t==="asmr"?N=(await b.asmrProgress.adultCount.query()).count:N=(await b.tvProgress.adultCount.query()).count,typeof N=="number"&&N>0){p(N);return}}catch(N){console.error("Failed to fetch adult count",N)}a.toggle()}},D=()=>{p(null),a.toggle()},O=async()=>{if(!l){T(!0);try{let N;t==="anime"?N=(await b.continueWatching.purgeAdult.mutate()).removed:t==="manga"?N=(await b.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?N=(await b.asmrProgress.purgeAdult.mutate()).removed:N=(await b.tvProgress.purgeAdult.mutate()).removed,ye.success(s.purgeDoneText(N??0));for(const R of s.invalidateKeys)w.invalidateQueries({queryKey:R});t==="anime"&&w.invalidateQueries(C.continueWatching.pathFilter()),t==="manga"&&w.invalidateQueries(C.mangaProgress.pathFilter()),t==="asmr"&&w.invalidateQueries(C.asmrProgress.pathFilter()),t==="tv"&&w.invalidateQueries(C.tvProgress.pathFilter())}catch(N){console.error("Failed to purge adult entries",N),ye.error("Failed to remove adult entries")}finally{T(!1),p(null)}a.toggle()}};return h?e("div",{children:"Loading settings..."}):e("div",{className:G.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:G.settingItem,children:e("div",{className:G.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(H,{isChecked:i,onChange:x,id:"skip-confirmation-toggle",disabled:_})]})}),e("div",{className:G.settingItem,children:e("div",{className:G.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(H,{isChecked:a.value,onChange:L,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:G.settingItem,children:e("div",{className:G.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(H,{isChecked:u.value,onChange:u.toggle,id:"cw-watchlist-only-toggle",disabled:u.isUpdating})]})}),f!==null&&e("div",{className:G.modalOverlay,onClick:()=>p(null),children:e("div",{className:G.modal,onClick:N=>N.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[f," adult ",f===1?"entry":"entries"," not in your"," ",s.listNoun," ",f===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",f===1?"it":"them"," from the database instead of showing ",f===1?"it":"them","."]}),e("div",{className:G.modalActions,children:[e("button",{type:"button",className:G.modalSecondary,onClick:D,disabled:l,children:"Show them"}),e("button",{type:"button",className:G.modalPrimary,onClick:O,disabled:l,children:l?"Purging...":`Purge ${f}`})]})]})})]})},Ut="_sectionCard_jkggs_1",Mt="_statsGrid_jkggs_26",Et="_statCard_jkggs_33",$t="_statLabel_jkggs_43",Gt="_statValue_jkggs_51",Ft="_statMeta_jkggs_57",Kt="_statusBanner_jkggs_63",Ht="_statusSuccess_jkggs_74",Bt="_statusUpdating_jkggs_80",zt="_statusError_jkggs_86",qt="_sha_jkggs_92",jt="_settingItem_jkggs_99",Wt="_settingRow_jkggs_104",Vt="_settingTitle_jkggs_111",Yt="_settingSubtitle_jkggs_117",Jt="_actionsRow_jkggs_124",P={sectionCard:Ut,statsGrid:Mt,statCard:Et,statLabel:$t,statValue:Gt,statMeta:Ft,statusBanner:Kt,statusSuccess:Ht,statusUpdating:Bt,statusError:zt,sha:qt,settingItem:jt,settingRow:Wt,settingTitle:Vt,settingSubtitle:Yt,actionsRow:Jt},Qt=()=>{const[t,s]=r(null),[i,c]=r(!0),[h,d]=r(!1),[_,m]=r(!1),a=V(null),u=async()=>{try{const w=await b.settings.offlineDbInfo.query();return s(w),w}catch(w){console.error("Failed to fetch offline DB info:",w)}finally{c(!1)}return null};A(()=>(u(),()=>{a.current&&window.clearInterval(a.current)}),[]),A(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const w=await u();w&&!w.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const f=async()=>{if(!t||h)return;const w=!t.autoUpdateEnabled;d(!0),s({...t,autoUpdateEnabled:w});try{await b.settings.setOfflineDbAutoUpdate.mutate({enabled:w})}catch(C){console.error("Failed to update auto update setting:",C),s({...t,autoUpdateEnabled:!w})}finally{d(!1)}},p=async()=>{if(!(t?.isRefreshing||_)){m(!0);try{await b.settings.triggerOfflineDbUpdate.mutate(),s(w=>w?{...w,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(w){console.error("Failed to trigger offline DB update:",w)}finally{m(!1)}}},l=w=>{if(!w)return"Never";try{return new Date(w).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return w}},T=t?.isRefreshing||_;return e("div",{className:P.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:P.statsGrid,children:[e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"MAL Mapped"}),e("span",{className:P.statValue,children:i?"—":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Release"}),e("span",{className:P.statMeta,children:i?"—":t?.releaseTag??"Never"})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Checked"}),e("span",{className:P.statMeta,children:i?"—":l(t?.lastCheckedAt??null)})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Updated"}),e("span",{className:P.statMeta,children:i?"—":l(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${P.statusBanner} ${t.lastStatus==="failed"?P.statusError:t.lastStatus==="updating"?P.statusUpdating:P.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:P.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:P.settingItem,children:e("div",{className:P.settingRow,children:[e("div",{children:[e("span",{className:P.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:P.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(H,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:f,disabled:i||h})]})}),e("div",{className:P.actionsRow,children:e(I,{onClick:p,disabled:i||T,children:T?"Updating Database...":"Update Offline Database Now"})})]})},Xt="_sectionCard_1g4qx_1",Zt="_dangerCard_1g4qx_26",ea="_status_1g4qx_34",ta="_warningText_1g4qx_40",aa="_ackLabel_1g4qx_44",ee={sectionCard:Xt,dangerCard:Zt,status:ea,warningText:ta,ackLabel:aa},na=()=>{const t=ue(),[s,i]=r(!1),[c,h]=r(!1),[d,_]=r(!1),[m,a]=r(""),u=()=>{h(!1),a(""),i(!0)},f=()=>{d||(i(!1),h(!1))},p=async()=>{if(!(!c||d)){_(!0),a("");try{const l=await fetch("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),T=await l.json();if(!l.ok)throw new Error(T.error||"Failed to clear database");const w=T.deleted,C=T.deletedManga,x=T.deletedTv,L=T.deletedAsmr,D=Object.values(w).reduce((M,v)=>M+(v||0),0)+Object.values(C??{}).reduce((M,v)=>M+(v||0),0)+Object.values(x??{}).reduce((M,v)=>M+(v||0),0)+Object.values(L??{}).reduce((M,v)=>M+(v||0),0),O=(C?.manga_library??0)+(C?.manga_progress??0),N=(x?.tv_library??0)+(x?.tv_progress??0),R=(L?.asmr_library??0)+(L?.asmr_progress??0);a(`Library cleared — ${w.watchlist??0} watchlist entries, ${O} manga rows, ${N} TV rows, ${R} ASMR rows and ${D} total rows removed.`),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]}),t.invalidateQueries({queryKey:["manga-library"]}),t.invalidateQueries({queryKey:["manga-continue-reading"]}),t.invalidateQueries({queryKey:["tv-library"]}),t.invalidateQueries({queryKey:["tv-continue-watching"]}),t.invalidateQueries({queryKey:["asmr-library"]}),t.invalidateQueries({queryKey:["asmr-continue-listening"]}),i(!1)}catch(l){a(l.message)}finally{_(!1),h(!1)}}};return e("div",{className:`${ee.sectionCard} ${ee.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(I,{variant:"danger",onClick:u,children:"Clear Library Data"}),m&&e("p",{className:ee.status,children:m}),e(F,{isOpen:s,onClose:f,title:"Clear library data?",width:"sm",children:[e(F.Body,{children:[e("p",{className:ee.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:ee.ackLabel,children:[e("input",{type:"checkbox",checked:c,onChange:l=>h(l.target.checked),disabled:d}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(F.Actions,{children:[e(I,{variant:"secondary",onClick:f,disabled:d,children:"Cancel"}),e(I,{variant:"danger",onClick:p,disabled:!c||d,children:d?"Clearing...":"Yes, delete everything"})]})]})]})},sa=()=>{const[t,s]=r(""),[i,c]=r([]),[h,d]=r(null),[_,m]=r(!0),[a,u]=r({show:!1,message:"",type:"info"}),f=async()=>{try{m(!0);const T=await(await fetch("/api/auth/settings/rclone")).json();s(T.remote||""),c(T.availableRemotes||[]),d(T.activeRemote||null)}catch(l){console.error("Failed to fetch Rclone settings",l)}finally{m(!1)}};A(()=>{f()},[]);const p=async()=>{try{if((await fetch("/api/auth/settings/rclone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:t})})).ok)u({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),f();else throw new Error("Failed to save")}catch{u({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return _?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:y.sectionCard,children:[e("h3",{className:y.title,children:"Rclone Cloud Sync"}),e("p",{className:y.signIn,children:"Configure which Rclone remote to use for database synchronization."}),h?e("div",{className:y.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:h})]})}):e("p",{className:y.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Remote Name"}),e("div",{className:y.inputWrapper,children:e("select",{className:y.select,value:t,onChange:l=>s(l.target.value),children:[e("option",{value:"",children:"(Disabled / None)"}),i.map(l=>e("option",{value:l,children:l},l)),t&&!i.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:y.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:y.actions,children:e(I,{onClick:p,children:"Save Rclone Settings"})}),e(F,{isOpen:a.show,onClose:()=>u(l=>({...l,show:!1})),width:"sm",children:[e(F.Body,{children:e("p",{children:a.message})}),e(F.Actions,{children:e(I,{onClick:()=>u(l=>({...l,show:!1})),children:"OK"})})]})]})},ra=()=>{const[t,s]=r(null),[i,c]=r(!0),h=async()=>{try{const u=await(await fetch("/api/auth/settings/sync")).json();s(u)}catch(a){console.error("Failed to fetch sync settings",a)}finally{c(!1)}};A(()=>{h()},[]);const d=async a=>{const u=a.target.value;try{const f=await fetch("/api/auth/settings/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u})});if(f.ok){const p=await f.json();s(l=>l?{...l,activeProvider:p.activeProvider}:null),await h(),oe.success(`Sync provider updated to ${u==="default"?"Default Order":u}`)}else oe.error("Failed to update sync provider")}catch{oe.error("Error updating sync provider")}};if(i||!t)return null;const _=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&_.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&_.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&_.push({value:"rclone",label:"Rclone"}),_.push({value:"none",label:"None (Local Only)"});const m=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:g.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:m(t.actualActiveProvider)})]}),e("div",{className:g.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:d,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:_.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ia(){return"javascript:"+encodeURIComponent(`(function(){
1
+ import{d as r,A as V,h as A,u as e,q as ae,S as te,T as Le,p as xe,a as Pe,g as pe,_ as Ae}from"./vendor-core-DfaOB3Rn.js";import{d as Oe,t as b,B as I,M as F,j as ve,h as Ue,T as H,z as ye,F as oe,G as Me,H as Ee,u as $e,e as Ge,I as Fe,y as fe,A as Ke,J as He,K as Be,V as ze,L as qe,N as je,O as We}from"./index-gMxawd-E.js";import{u as ue}from"./vendor-query-BBT5_sHx.js";import{I as W}from"./vendor-icons-DrybRNxP.js";const ce={"title-preference-container":"_title-preference-container_sdqgs_1","toggle-button":"_toggle-button_sdqgs_21","toggle-label":"_toggle-label_sdqgs_51"},le=["name","nativeName","englishName"],de={name:"Default (Romaji)",nativeName:"Native",englishName:"English"},Ve=()=>{const{titlePreference:t,setTitlePreference:s,loading:i}=Oe(),[c,h]=r(de[t]),[d,_]=r(!1),m=V(null);A(()=>{i||h(de[t])},[t,i]);const a=async()=>{if(d)return;_(!0);const f=(le.indexOf(t)+1)%le.length,p=le[f],l=de[p];m.current&&(m.current.style.transform="translateX(-100%)",m.current.style.opacity="0"),setTimeout(async()=>{h(l),s(p),m.current&&(m.current.style.transition="none",m.current.style.transform="translateX(100%)",m.current.style.opacity="0",m.current.offsetWidth,m.current.style.transition="transform 0.3s ease-out, opacity 0.3s ease-out",m.current.style.transform="translateX(0)",m.current.style.opacity="1");try{await b.settings.set.mutate({key:"titlePreference",value:p})}catch(T){console.error("Error saving title preference:",T)}finally{_(!1)}},300)};return i?e("p",{children:"Loading title preference..."}):e("div",{className:ce["title-preference-container"],children:[e("h4",{children:"Anime Title Display Preference"}),e("button",{onClick:a,className:ce["toggle-button"],disabled:d,children:e("span",{ref:m,className:ce["toggle-label"],children:c})})]})},Ye="_settingsHeader_14a5d_1",Je="_pageTitle_14a5d_6",Qe="_pageSubtitle_14a5d_14",Xe="_settingsLayout_14a5d_20",Ze="_sidebar_14a5d_27",et="_sidebarIndicator_14a5d_35",tt="_sidebarItem_14a5d_50",at="_active_14a5d_72",nt="_mainContent_14a5d_80",st="_tabContent_14a5d_85",rt="_sectionCard_14a5d_103",it="_settingItem_14a5d_127",ot="_settingRow_14a5d_132",ct="_controls_14a5d_145",lt="_status_14a5d_151",g={settingsHeader:Ye,pageTitle:Je,pageSubtitle:Qe,settingsLayout:Xe,sidebar:Ze,sidebarIndicator:et,sidebarItem:tt,active:at,mainContent:nt,tabContent:st,sectionCard:rt,settingItem:it,settingRow:ot,controls:ct,status:lt},dt="_sectionCard_wt900_12",ut="_title_wt900_22",ht="_signIn_wt900_29",gt="_userInfo_wt900_36",mt="_warning_wt900_58",pt="_formGroup_wt900_65",yt="_label_wt900_69",ft="_inputWrapper_wt900_79",wt="_input_wt900_79",vt="_select_wt900_103",bt="_actions_wt900_140",_t="_hr_wt900_148",y={sectionCard:dt,title:ut,signIn:ht,userInfo:gt,warning:mt,formGroup:pt,label:yt,inputWrapper:ft,input:wt,select:vt,actions:bt,hr:_t},kt=()=>{const[t,s]=r(!0),[i,c]=r(!1),[h,d]=r(!1),[_,m]=r(null),[a,u]=r({status:"idle"}),[f,p]=r(!1),[l,T]=r(""),[w,C]=r(!1),x=V(null),[L,D]=r({show:!1,message:"",type:"info"}),O=()=>{x.current&&(window.clearInterval(x.current),x.current=null)},N=ae(S=>{d(S.authenticated),m(S.user||S.device.user||null),u(S.device),p(!!S.hasCustomClientId)},[]),R=ae(async()=>{const S=await b.auth.githubStatus.query();N(S)},[N]),M=async()=>{try{const S=await b.auth.githubPoll.query();u(S),S.status==="success"?(O(),await R(),D({show:!0,message:"GitHub authentication complete. Sync has been initialized.",type:"success"})):S.status==="error"&&(O(),D({show:!0,message:S.error||"GitHub authentication failed.",type:"error"}))}catch{O(),D({show:!0,message:"Failed to poll GitHub authentication status.",type:"error"})}},v=(S=5)=>{O(),x.current=window.setInterval(M,Math.max(S,5)*1e3)};A(()=>(R().catch(()=>{D({show:!0,message:"Failed to load GitHub sync status.",type:"error"})}).finally(()=>s(!1)),O),[R]);const k=async()=>{c(!0);try{const S=await b.auth.githubStart.mutate();u(S),v(S.verification?.interval)}catch(S){D({show:!0,message:S instanceof Error?S.message:"Failed to start GitHub authentication.",type:"error"})}finally{c(!1)}},U=async()=>{try{await b.auth.githubLogout.mutate(),d(!1),m(null),u({status:"idle"}),D({show:!0,message:"Signed out of GitHub sync.",type:"success"})}catch{D({show:!0,message:"Failed to sign out of GitHub.",type:"error"})}},E=async()=>{C(!0);try{await b.auth.saveGithubAuth.mutate({clientId:l}),T(""),await R(),D({show:!0,message:"Custom GitHub auth saved.",type:"success"})}catch{D({show:!0,message:"Failed to save override.",type:"error"})}finally{C(!1)}},z=async()=>{C(!0);try{await b.auth.saveGithubAuth.mutate({clientId:""}),T(""),await R(),D({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{D({show:!0,message:"Failed to clear override.",type:"error"})}finally{C(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:y.sectionCard,children:[e("h3",{className:y.title,children:"GitHub Cloud Sync"}),e("p",{className:y.signIn,children:"Sync local data through a private GitHub repository named dango-sync-data."}),h&&_?e("div",{className:y.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:_.name||_.login})]}),e(I,{variant:"danger",onClick:U,children:"Sign Out"})]}):e("div",{className:y.signIn,children:e(I,{onClick:k,disabled:i||a.status==="pending",children:i||a.status==="pending"?"Waiting for GitHub...":"Sign in with GitHub"})}),a.status==="pending"&&a.verification&&e(te,{children:[e("hr",{className:y.hr}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Verification URL"}),e("div",{className:y.inputWrapper,children:[e("input",{className:y.input,value:a.verification.verification_uri,readOnly:!0}),e(I,{onClick:()=>{const S=a.verification?.verification_uri;S&&/^https?:\/\//i.test(S)&&window.open(S,"_blank","noopener,noreferrer")},children:"Open"})]})]}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Device Code"}),e("input",{className:y.input,value:a.verification.user_code,readOnly:!0})]})]}),a.status==="error"&&e("p",{className:y.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 ",f?"(override active)":""]}),e("div",{className:y.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:y.label,children:"Client ID (optional)"}),e("input",{className:y.input,value:l,onChange:S=>T(S.currentTarget.value),placeholder:"Your GitHub OAuth app ID"})]}),e("div",{className:y.actions,children:[e(I,{onClick:E,disabled:w,children:"Save override"}),e(I,{variant:"secondary",onClick:z,disabled:w,children:"Use dango defaults"})]})]}),e(F,{isOpen:L.show,onClose:()=>D(S=>({...S,show:!1})),width:"sm",children:[e(F.Body,{children:e("p",{children:L.message})}),e(F.Actions,{children:e(I,{onClick:()=>D(S=>({...S,show:!1})),children:"OK"})})]})]})},St=()=>{const[t,s]=r(!0),[i,c]=r(null),[h,d]=r(!1),[_,m]=r(!1),[a,u]=r(""),[f,p]=r(""),[l,T]=r(""),[w,C]=r(!1),[x,L]=r({show:!1,message:"",type:"info"}),D=async()=>{try{const k=await b.auth.user.query();c(k?.email?k:null)}catch{c(null)}},O=async()=>{try{const[k,U]=await Promise.all([b.auth.configStatus.query(),b.auth.googleAuth.query()]);d(!!k.hasConfig),m(!!(U.hasCustomWorkerUrl||U.hasCustomClientId||U.hasClientSecret))}catch(k){console.error("Failed to fetch config status",k)}};A(()=>{(async()=>{s(!0),await Promise.all([D(),O()]);try{new URLSearchParams(window.location.search).get("google_auth")==="success"&&(await D(),window.history.replaceState(null,"",window.location.pathname))}catch{}s(!1)})();const U=E=>{E.origin===window.location.origin&&typeof E.data=="object"&&E.data!==null&&E.data.type==="GOOGLE_AUTH_SUCCESS"&&(c(E.data.user),window.location.reload())};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[]);const N=async()=>{try{const k=await b.auth.googleLogin.mutate();if(k.authenticated){window.location.reload();return}if(k.url){if(typeof window.DangoBridge<"u"){window.location.href=k.url;return}const E=600,z=700,S=window.innerWidth/2-E/2,ne=window.innerHeight/2-z/2;window.open(k.url,"GoogleAuth",`width=${E},height=${z},top=${ne},left=${S}`)}else throw new Error("Auth URL not available")}catch{L({show:!0,message:"Authentication failed. Ensure server is configured correctly.",type:"error"})}},R=async()=>{try{await b.auth.logout.mutate(),c(null),L({show:!0,message:"Successfully signed out.",type:"success"}),window.location.reload()}catch(k){console.error("Sign out failed",k),L({show:!0,message:"Failed to sign out.",type:"error"})}},M=async()=>{C(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:a,clientId:f,clientSecret:l}),u(""),p(""),T(""),await O(),L({show:!0,message:"Custom auth saved. Restart may be required.",type:"success"})}catch{L({show:!0,message:"Failed to save override.",type:"error"})}finally{C(!1)}},v=async()=>{C(!0);try{await b.auth.saveGoogleAuth.mutate({workerUrl:"",clientId:"",clientSecret:""}),u(""),p(""),T(""),await O(),L({show:!0,message:"Custom auth cleared. Using dango defaults.",type:"success"})}catch{L({show:!0,message:"Failed to clear override.",type:"error"})}finally{C(!1)}};return t?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:y.sectionCard,children:[e("h3",{className:y.title,children:"Google Drive Sync"}),i?e("div",{className:y.userInfo,children:[e("p",{children:["Signed in as: ",e("strong",{children:i.name})," (",i.email,")"]}),e(I,{variant:"danger",onClick:R,children:"Sign Out"})]}):e("div",{className:y.signIn,children:[e("p",{children:"Sign in with your Google account to enable synchronization features."}),e(I,{onClick:N,disabled:!h,children:"Sign in with Google"}),!h&&e("p",{className:y.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 ",_?"(override active)":""]}),e("div",{className:y.formGroup,style:{marginTop:"0.75rem"},children:[e("label",{className:y.label,children:"Worker URL (optional)"}),e("input",{className:y.input,value:a,onChange:k=>u(k.currentTarget.value),placeholder:"https://your-worker.workers.dev"})]}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Client ID (optional)"}),e("input",{className:y.input,value:f,onChange:k=>p(k.currentTarget.value),placeholder:"Your Google OAuth client ID"})]}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Client Secret (optional)"}),e("input",{type:"password",className:y.input,value:l,onChange:k=>T(k.currentTarget.value),placeholder:"Your Google OAuth secret"})]}),e("div",{className:y.actions,children:[e(I,{onClick:M,disabled:w,children:"Save override"}),e(I,{variant:"secondary",onClick:v,disabled:w,children:"Use dango defaults"})]})]}),e(F,{isOpen:x.show,onClose:()=>L(k=>({...k,show:!1})),width:"sm",children:[e(F.Body,{children:e("p",{children:x.message})}),e(F.Actions,{children:e(I,{onClick:()=>L(k=>({...k,show:!1})),children:"OK"})})]})]})},Ct="_sectionCard_1pqo4_1",Nt="_settingItem_1pqo4_26",Tt="_settingRow_1pqo4_31",Rt="_modalOverlay_1pqo4_38",Dt="_modal_1pqo4_38",It="_modalActions_1pqo4_73",Lt="_modalSecondary_1pqo4_79",xt="_modalPrimary_1pqo4_89",G={sectionCard:Ct,settingItem:Nt,settingRow:Tt,modalOverlay:Rt,modal:Dt,modalActions:It,modalSecondary:Lt,modalPrimary:xt},Pt={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"]]}},At=(t,s)=>{if(t==null)return s;const i=String(t);return i==="true"||i==="1"?!0:i==="false"||i==="0"?!1:s},we=(t,s,i)=>{const[c,h]=r(s),[d,_]=r(!1),m=ue();return A(()=>{(async()=>{try{const f=await b.settings.getByKey.query({key:t});h(At(f.value,s))}catch(f){console.error("Failed to fetch setting",f)}})()},[t,s]),{value:c,setValue:h,isUpdating:d,toggle:async()=>{if(d)return;_(!0);const u=!c;h(u);try{await b.settings.set.mutate({key:t,value:u});for(const f of i)m.invalidateQueries({queryKey:f})}catch(f){console.error("Error saving setting:",f),h(!u)}finally{_(!1)}}}},Ot=()=>{const{contentType:t}=ve(),s=Pt[t],[i,c]=r(!1),[h,d]=r(!0),[_,m]=r(!1),a=we(s.ignoreKey,!0,s.invalidateKeys),u=we(s.listOnlyKey,!1,s.invalidateKeys),[f,p]=r(null),[l,T]=r(!1),w=ue(),C=Ue();A(()=>{d(!0),(async()=>{try{const R=await b.settings.getByKey.query({key:s.skipKey});String(R.value)==="true"||String(R.value)==="1"?c(!0):c(!1)}catch(R){console.error("Failed to fetch setting",R)}finally{d(!1)}})()},[s.skipKey]);const x=async()=>{if(_)return;m(!0);const N=!i;c(N);try{await b.settings.set.mutate({key:s.skipKey,value:N})}catch(R){console.error("Error saving setting:",R),c(!N)}finally{m(!1)}},L=async()=>{if(!a.isUpdating){if(a.value)try{let N;if(t==="anime"?N=(await b.continueWatching.adultCount.query()).count:t==="manga"?N=(await b.mangaProgress.adultCount.query()).count:t==="asmr"?N=(await b.asmrProgress.adultCount.query()).count:N=(await b.tvProgress.adultCount.query()).count,typeof N=="number"&&N>0){p(N);return}}catch(N){console.error("Failed to fetch adult count",N)}a.toggle()}},D=()=>{p(null),a.toggle()},O=async()=>{if(!l){T(!0);try{let N;t==="anime"?N=(await b.continueWatching.purgeAdult.mutate()).removed:t==="manga"?N=(await b.mangaProgress.purgeAdult.mutate()).removed:t==="asmr"?N=(await b.asmrProgress.purgeAdult.mutate()).removed:N=(await b.tvProgress.purgeAdult.mutate()).removed,ye.success(s.purgeDoneText(N??0));for(const R of s.invalidateKeys)w.invalidateQueries({queryKey:R});t==="anime"&&w.invalidateQueries(C.continueWatching.pathFilter()),t==="manga"&&w.invalidateQueries(C.mangaProgress.pathFilter()),t==="asmr"&&w.invalidateQueries(C.asmrProgress.pathFilter()),t==="tv"&&w.invalidateQueries(C.tvProgress.pathFilter())}catch(N){console.error("Failed to purge adult entries",N),ye.error("Failed to remove adult entries")}finally{T(!1),p(null)}a.toggle()}};return h?e("div",{children:"Loading settings..."}):e("div",{className:G.sectionCard,children:[e("h3",{children:s.heading}),e("p",{children:s.blurb}),e("div",{className:G.settingItem,children:e("div",{className:G.settingRow,children:[e("label",{htmlFor:"skip-confirmation-toggle",children:s.skipLabel}),e(H,{isChecked:i,onChange:x,id:"skip-confirmation-toggle",disabled:_})]})}),e("div",{className:G.settingItem,children:e("div",{className:G.settingRow,children:[e("label",{htmlFor:"ignore-adult-toggle",children:s.ignoreLabel}),e(H,{isChecked:a.value,onChange:L,id:"ignore-adult-toggle",disabled:a.isUpdating})]})}),e("div",{className:G.settingItem,children:e("div",{className:G.settingRow,children:[e("label",{htmlFor:"cw-watchlist-only-toggle",children:s.listOnlyLabel}),e(H,{isChecked:u.value,onChange:u.toggle,id:"cw-watchlist-only-toggle",disabled:u.isUpdating})]})}),f!==null&&e("div",{className:G.modalOverlay,onClick:()=>p(null),children:e("div",{className:G.modal,onClick:N=>N.stopPropagation(),children:[e("h4",{children:"Show adult entries?"}),e("p",{children:[f," adult ",f===1?"entry":"entries"," not in your"," ",s.listNoun," ",f===1?"is":"are"," currently hidden from"," ",s.continueNoun,". You can purge ",f===1?"it":"them"," from the database instead of showing ",f===1?"it":"them","."]}),e("div",{className:G.modalActions,children:[e("button",{type:"button",className:G.modalSecondary,onClick:D,disabled:l,children:"Show them"}),e("button",{type:"button",className:G.modalPrimary,onClick:O,disabled:l,children:l?"Purging...":`Purge ${f}`})]})]})})]})},Ut="_sectionCard_jkggs_1",Mt="_statsGrid_jkggs_26",Et="_statCard_jkggs_33",$t="_statLabel_jkggs_43",Gt="_statValue_jkggs_51",Ft="_statMeta_jkggs_57",Kt="_statusBanner_jkggs_63",Ht="_statusSuccess_jkggs_74",Bt="_statusUpdating_jkggs_80",zt="_statusError_jkggs_86",qt="_sha_jkggs_92",jt="_settingItem_jkggs_99",Wt="_settingRow_jkggs_104",Vt="_settingTitle_jkggs_111",Yt="_settingSubtitle_jkggs_117",Jt="_actionsRow_jkggs_124",P={sectionCard:Ut,statsGrid:Mt,statCard:Et,statLabel:$t,statValue:Gt,statMeta:Ft,statusBanner:Kt,statusSuccess:Ht,statusUpdating:Bt,statusError:zt,sha:qt,settingItem:jt,settingRow:Wt,settingTitle:Vt,settingSubtitle:Yt,actionsRow:Jt},Qt=()=>{const[t,s]=r(null),[i,c]=r(!0),[h,d]=r(!1),[_,m]=r(!1),a=V(null),u=async()=>{try{const w=await b.settings.offlineDbInfo.query();return s(w),w}catch(w){console.error("Failed to fetch offline DB info:",w)}finally{c(!1)}return null};A(()=>(u(),()=>{a.current&&window.clearInterval(a.current)}),[]),A(()=>{t?.isRefreshing?a.current||(a.current=window.setInterval(async()=>{const w=await u();w&&!w.isRefreshing&&a.current&&(window.clearInterval(a.current),a.current=null)},2e3)):a.current&&(window.clearInterval(a.current),a.current=null)},[t?.isRefreshing]);const f=async()=>{if(!t||h)return;const w=!t.autoUpdateEnabled;d(!0),s({...t,autoUpdateEnabled:w});try{await b.settings.setOfflineDbAutoUpdate.mutate({enabled:w})}catch(C){console.error("Failed to update auto update setting:",C),s({...t,autoUpdateEnabled:!w})}finally{d(!1)}},p=async()=>{if(!(t?.isRefreshing||_)){m(!0);try{await b.settings.triggerOfflineDbUpdate.mutate(),s(w=>w?{...w,isRefreshing:!0,lastStatus:"updating",lastMessage:"Downloading database..."}:null)}catch(w){console.error("Failed to trigger offline DB update:",w)}finally{m(!1)}}},l=w=>{if(!w)return"Never";try{return new Date(w).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch{return w}},T=t?.isRefreshing||_;return e("div",{className:P.sectionCard,children:[e("h3",{children:"Offline Metadata Database"}),e("p",{children:"Local MAL to AniList ID map used for instant imports and metadata enrichment without hitting rate-limited APIs. Updates automatically every Saturday in the background."}),e("div",{className:P.statsGrid,children:[e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"MAL Mapped"}),e("span",{className:P.statValue,children:i?"—":(t?.totalMalMapped??0).toLocaleString()})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Release"}),e("span",{className:P.statMeta,children:i?"—":t?.releaseTag??"Never"})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Checked"}),e("span",{className:P.statMeta,children:i?"—":l(t?.lastCheckedAt??null)})]}),e("div",{className:P.statCard,children:[e("span",{className:P.statLabel,children:"Last Updated"}),e("span",{className:P.statMeta,children:i?"—":l(t?.lastUpdatedAt??null)})]})]}),t?.lastMessage&&e("div",{className:`${P.statusBanner} ${t.lastStatus==="failed"?P.statusError:t.lastStatus==="updating"?P.statusUpdating:P.statusSuccess}`,children:[e("span",{children:t.lastMessage}),t.contentSha256&&e("span",{className:P.sha,children:["sha:",t.contentSha256.slice(0,12)]})]}),e("div",{className:P.settingItem,children:e("div",{className:P.settingRow,children:[e("div",{children:[e("span",{className:P.settingTitle,children:"Weekly Automatic Updates (Saturdays)"}),e("div",{className:P.settingSubtitle,children:"Download and index new database releases in the background. Catches up on startup if the server was offline."})]}),e(H,{id:"offline-db-auto-update-toggle",isChecked:t?t.autoUpdateEnabled:!0,onChange:f,disabled:i||h})]})}),e("div",{className:P.actionsRow,children:e(I,{onClick:p,disabled:i||T,children:T?"Updating Database...":"Update Offline Database Now"})})]})},Xt="_sectionCard_1g4qx_1",Zt="_dangerCard_1g4qx_26",ea="_status_1g4qx_34",ta="_warningText_1g4qx_40",aa="_ackLabel_1g4qx_44",ee={sectionCard:Xt,dangerCard:Zt,status:ea,warningText:ta,ackLabel:aa},na=()=>{const t=ue(),[s,i]=r(!1),[c,h]=r(!1),[d,_]=r(!1),[m,a]=r(""),u=()=>{h(!1),a(""),i(!0)},f=()=>{d||(i(!1),h(!1))},p=async()=>{if(!(!c||d)){_(!0),a("");try{const l=await fetch("/api/database/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0})}),T=await l.json();if(!l.ok)throw new Error(T.error||"Failed to clear database");const w=T.deleted,C=T.deletedManga,x=T.deletedTv,L=T.deletedAsmr,D=Object.values(w).reduce((M,v)=>M+(v||0),0)+Object.values(C??{}).reduce((M,v)=>M+(v||0),0)+Object.values(x??{}).reduce((M,v)=>M+(v||0),0)+Object.values(L??{}).reduce((M,v)=>M+(v||0),0),O=(C?.manga_library??0)+(C?.manga_progress??0),N=(x?.tv_library??0)+(x?.tv_progress??0),R=(L?.asmr_library??0)+(L?.asmr_progress??0);a(`Library cleared — ${w.watchlist??0} watchlist entries, ${O} manga rows, ${N} TV rows, ${R} ASMR rows and ${D} total rows removed.`),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]}),t.invalidateQueries({queryKey:["manga-library"]}),t.invalidateQueries({queryKey:["manga-continue-reading"]}),t.invalidateQueries({queryKey:["tv-library"]}),t.invalidateQueries({queryKey:["tv-continue-watching"]}),t.invalidateQueries({queryKey:["asmr-library"]}),t.invalidateQueries({queryKey:["asmr-continue-listening"]}),i(!1)}catch(l){a(l.message)}finally{_(!1),h(!1)}}};return e("div",{className:`${ee.sectionCard} ${ee.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(I,{variant:"danger",onClick:u,children:"Clear Library Data"}),m&&e("p",{className:ee.status,children:m}),e(F,{isOpen:s,onClose:f,title:"Clear library data?",width:"sm",children:[e(F.Body,{children:[e("p",{className:ee.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:ee.ackLabel,children:[e("input",{type:"checkbox",checked:c,onChange:l=>h(l.target.checked),disabled:d}),e("span",{children:"I understand this permanently deletes my library"})]})]}),e(F.Actions,{children:[e(I,{variant:"secondary",onClick:f,disabled:d,children:"Cancel"}),e(I,{variant:"danger",onClick:p,disabled:!c||d,children:d?"Clearing...":"Yes, delete everything"})]})]})]})},sa=()=>{const[t,s]=r(""),[i,c]=r([]),[h,d]=r(null),[_,m]=r(!0),[a,u]=r({show:!1,message:"",type:"info"}),f=async()=>{try{m(!0);const T=await(await fetch("/api/auth/settings/rclone")).json();s(T.remote||""),c(T.availableRemotes||[]),d(T.activeRemote||null)}catch(l){console.error("Failed to fetch Rclone settings",l)}finally{m(!1)}};A(()=>{f()},[]);const p=async()=>{try{if((await fetch("/api/auth/settings/rclone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:t})})).ok)u({show:!0,message:"Rclone configuration saved successfully. You must restart the server for these changes to take effect.",type:"success"}),f();else throw new Error("Failed to save")}catch{u({show:!0,message:"Failed to save Rclone configuration.",type:"error"})}};return _?e("div",{style:{color:"var(--text-secondary)",padding:"1.5rem"},children:"Loading..."}):e("div",{className:y.sectionCard,children:[e("h3",{className:y.title,children:"Rclone Cloud Sync"}),e("p",{className:y.signIn,children:"Configure which Rclone remote to use for database synchronization."}),h?e("div",{className:y.userInfo,children:e("p",{children:["Current Active Remote: ",e("strong",{children:h})]})}):e("p",{className:y.warning,style:{marginBottom:"1.5rem"},children:"Rclone sync is not currently active. Ensure rclone is installed and a remote is configured."}),e("div",{className:y.formGroup,children:[e("label",{className:y.label,children:"Remote Name"}),e("div",{className:y.inputWrapper,children:e("select",{className:y.select,value:t,onChange:l=>s(l.target.value),children:[e("option",{value:"",children:"(Disabled / None)"}),i.map(l=>e("option",{value:l,children:l},l)),t&&!i.includes(t)&&e("option",{value:t,children:[t," (Manual)"]})]})}),e("p",{className:y.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:y.actions,children:e(I,{onClick:p,children:"Save Rclone Settings"})}),e(F,{isOpen:a.show,onClose:()=>u(l=>({...l,show:!1})),width:"sm",children:[e(F.Body,{children:e("p",{children:a.message})}),e(F.Actions,{children:e(I,{onClick:()=>u(l=>({...l,show:!1})),children:"OK"})})]})]})},ra=()=>{const[t,s]=r(null),[i,c]=r(!0),h=async()=>{try{const u=await(await fetch("/api/auth/settings/sync")).json();s(u)}catch(a){console.error("Failed to fetch sync settings",a)}finally{c(!1)}};A(()=>{h()},[]);const d=async a=>{const u=a.target.value;try{const f=await fetch("/api/auth/settings/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u})});if(f.ok){const p=await f.json();s(l=>l?{...l,activeProvider:p.activeProvider}:null),await h(),oe.success(`Sync provider updated to ${u==="default"?"Default Order":u}`)}else oe.error("Failed to update sync provider")}catch{oe.error("Error updating sync provider")}};if(i||!t)return null;const _=[{value:"default",label:"Default (Priority Based)"}];t.authenticatedProviders.github&&_.push({value:"github",label:"GitHub"}),t.authenticatedProviders.google&&_.push({value:"google",label:"Google Drive"}),t.authenticatedProviders.rclone&&_.push({value:"rclone",label:"Rclone"}),_.push({value:"none",label:"None (Local Only)"});const m=a=>a==="none"?"Local Only (No Sync)":a==="google"?"Google Drive":a==="github"?"GitHub":a==="rclone"?"Rclone":a;return e("div",{className:g.sectionCard,children:[e("h3",{children:"Active Sync Provider"}),e("p",{children:'Choose which provider to use for synchronization. "Default" uses the first available provider you are logged into.'}),e("div",{style:{marginBottom:"1.5rem",padding:"0.75rem",background:"rgba(255, 255, 255, 0.03)",borderRadius:"var(--radius-md)",borderLeft:"4px solid var(--accent)",fontSize:"var(--font-size-sm)"},children:["Current Status:"," ",e("strong",{style:{color:"var(--accent-light)",textTransform:"capitalize"},children:m(t.actualActiveProvider)})]}),e("div",{className:g.settingRow,children:[e("label",{htmlFor:"sync-provider-select",children:"Selected Preference"}),e("select",{id:"sync-provider-select",value:t.activeProvider,onChange:d,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:_.map(a=>e("option",{value:a.value,children:a.label},a.value))})]})]})};function ia(){return"javascript:"+encodeURIComponent(`(function(){
2
2
  if(!/(^|\\.)discord\\.com$/.test(location.hostname)){alert('Dango: use this bookmarklet while on discord.com');return}
3
3
  var t=null;
4
4
  try{
@@ -1 +1 @@
1
- import{d as _,A as v,h as E,T as R,u as e,g as A}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{u as L}from"./index-BWIWE3Qy.js";const x="_pagination_zelsc_1",M="_pageBtn_zelsc_7",S="_pageInfo_zelsc_38",G="_pagePicker_zelsc_48",F="_dropdown_zelsc_52",K="_flipDown_zelsc_68",T="_jumpRow_zelsc_73",W="_jumpInput_zelsc_79",q="_jumpGo_zelsc_90",J="_optionList_zelsc_105",O="_optionBtn_zelsc_113",H="_current_zelsc_132",s={pagination:x,pageBtn:M,pageInfo:S,pagePicker:G,dropdown:F,flipDown:K,jumpRow:T,jumpInput:W,jumpGo:q,optionList:J,optionBtn:O,current:H},cn=({page:t,totalPages:d,canGoNext:m,onChange:p,isLoading:f=!1,variant:g="compact"})=>{const[l,u]=_(!1),[b,h]=_(""),[k,N]=_(0),[$,z]=_(!1),w=v(null),y=v(null),j=v(null);E(()=>{if(!l)return;const n=o=>{w.current&&!w.current.contains(o.target)&&u(!1)},r=o=>{o.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",r)}},[l]),E(()=>{if(!l)return;N(0),z(!1);const n=requestAnimationFrame(()=>{const r=j.current?.getBoundingClientRect(),o=y.current?.getBoundingClientRect();if(!r)return;let c=0;r.right>window.innerWidth-8?c=window.innerWidth-8-r.right:r.left<8&&(c=8-r.left),N(Math.round(c)),o&&o.top<r.height+24&&z(!0)});return()=>cancelAnimationFrame(n)},[l]);const i=d,C=R(()=>{if(i!==void 0){if(i<=100)return Array.from({length:i},(o,c)=>c+1);const r=new Set([1,i]);for(let o=t-10;o<=t+10;o++)o>=1&&o<=i&&r.add(o);return[...r].sort((o,c)=>o-c)}const n=m?t+1:t;return Array.from({length:n},(r,o)=>o+1)},[i,t,m]),B=n=>{const r=i!==void 0?Math.min(Math.max(1,n),i):Math.max(1,n);u(!1),h(""),r!==t&&p(r)},D=()=>{const n=parseInt(b,10);Number.isNaN(n)||B(n)},I=f||(i!==void 0?t>=i:!m);return e("div",{className:s.pagination,ref:w,children:[e("button",{className:s.pageBtn,onClick:()=>p(t-1),disabled:t<=1||f,"aria-label":"Previous page",children:[e(P,{name:"chevron-left",size:14}),g==="labeled"&&e("span",{children:"Previous"})]}),e("div",{className:s.pagePicker,ref:y,children:[e("button",{className:s.pageBtn,onClick:()=>{h(""),u(n=>!n)},disabled:f,"aria-label":"Jump to page","aria-expanded":l,children:e("span",{className:s.pageInfo,children:["Page ",e("strong",{children:t}),i!==void 0&&` of ${i}`]})}),l&&e("div",{ref:j,className:`${s.dropdown} ${$?s.flipDown:""}`,style:k!==0?{marginLeft:k}:void 0,children:[e("div",{className:s.jumpRow,children:[e("input",{className:s.jumpInput,type:"number",inputMode:"numeric",min:1,max:i,value:b,placeholder:"Page #",onChange:n=>h(n.currentTarget.value),onKeyDown:n=>{n.key==="Enter"&&D()}}),e("button",{className:s.jumpGo,onClick:D,children:"Go"})]}),e("div",{className:s.optionList,children:C.map(n=>e("button",{className:`${s.optionBtn} ${n===t?s.current:""}`,onClick:()=>B(n),disabled:n===t,children:n},n))})]})]}),e("button",{className:s.pageBtn,onClick:()=>p(t+1),disabled:I,"aria-label":"Next page",children:[g==="labeled"&&e("span",{children:"Next"}),e(P,{name:"chevron-right",size:14})]})]})},Q="_skeletonCard_1b0hr_1",U="_poster_1b0hr_11",V="_line_1b0hr_20",X="_info_1b0hr_38",Y="_short_1b0hr_54",Z="_horizontal_1b0hr_60",nn="_vertical_1b0hr_78",en="_lowEnd_1b0hr_97",a={skeletonCard:Q,poster:U,line:V,"skeleton-wave":"_skeleton-wave_1b0hr_1",info:X,short:Y,horizontal:Z,vertical:nn,lowEnd:en},tn=({layout:t="vertical"})=>{const{lowEndMode:d}=L();return e("div",{className:`${a.skeletonCard} ${a[t]} ${d?a.lowEnd:""}`,children:[e("div",{className:a.poster}),e("div",{className:a.info,children:[e("div",{className:a.line}),e("div",{className:`${a.line} ${a.short}`})]})]})},on=({count:t=14,layout:d="vertical"})=>e("div",{className:"grid-container",children:Array.from({length:t}).map((m,p)=>e(tn,{layout:d},p))}),ln=A.memo(on);export{tn as A,cn as P,ln as S};
1
+ import{d as _,A as v,h as E,T as R,u as e,g as A}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{u as L}from"./index-gMxawd-E.js";const x="_pagination_zelsc_1",M="_pageBtn_zelsc_7",S="_pageInfo_zelsc_38",G="_pagePicker_zelsc_48",F="_dropdown_zelsc_52",K="_flipDown_zelsc_68",T="_jumpRow_zelsc_73",W="_jumpInput_zelsc_79",q="_jumpGo_zelsc_90",J="_optionList_zelsc_105",O="_optionBtn_zelsc_113",H="_current_zelsc_132",s={pagination:x,pageBtn:M,pageInfo:S,pagePicker:G,dropdown:F,flipDown:K,jumpRow:T,jumpInput:W,jumpGo:q,optionList:J,optionBtn:O,current:H},cn=({page:t,totalPages:d,canGoNext:m,onChange:p,isLoading:f=!1,variant:g="compact"})=>{const[l,u]=_(!1),[b,h]=_(""),[k,N]=_(0),[$,z]=_(!1),w=v(null),y=v(null),j=v(null);E(()=>{if(!l)return;const n=o=>{w.current&&!w.current.contains(o.target)&&u(!1)},r=o=>{o.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",r)}},[l]),E(()=>{if(!l)return;N(0),z(!1);const n=requestAnimationFrame(()=>{const r=j.current?.getBoundingClientRect(),o=y.current?.getBoundingClientRect();if(!r)return;let c=0;r.right>window.innerWidth-8?c=window.innerWidth-8-r.right:r.left<8&&(c=8-r.left),N(Math.round(c)),o&&o.top<r.height+24&&z(!0)});return()=>cancelAnimationFrame(n)},[l]);const i=d,C=R(()=>{if(i!==void 0){if(i<=100)return Array.from({length:i},(o,c)=>c+1);const r=new Set([1,i]);for(let o=t-10;o<=t+10;o++)o>=1&&o<=i&&r.add(o);return[...r].sort((o,c)=>o-c)}const n=m?t+1:t;return Array.from({length:n},(r,o)=>o+1)},[i,t,m]),B=n=>{const r=i!==void 0?Math.min(Math.max(1,n),i):Math.max(1,n);u(!1),h(""),r!==t&&p(r)},D=()=>{const n=parseInt(b,10);Number.isNaN(n)||B(n)},I=f||(i!==void 0?t>=i:!m);return e("div",{className:s.pagination,ref:w,children:[e("button",{className:s.pageBtn,onClick:()=>p(t-1),disabled:t<=1||f,"aria-label":"Previous page",children:[e(P,{name:"chevron-left",size:14}),g==="labeled"&&e("span",{children:"Previous"})]}),e("div",{className:s.pagePicker,ref:y,children:[e("button",{className:s.pageBtn,onClick:()=>{h(""),u(n=>!n)},disabled:f,"aria-label":"Jump to page","aria-expanded":l,children:e("span",{className:s.pageInfo,children:["Page ",e("strong",{children:t}),i!==void 0&&` of ${i}`]})}),l&&e("div",{ref:j,className:`${s.dropdown} ${$?s.flipDown:""}`,style:k!==0?{marginLeft:k}:void 0,children:[e("div",{className:s.jumpRow,children:[e("input",{className:s.jumpInput,type:"number",inputMode:"numeric",min:1,max:i,value:b,placeholder:"Page #",onChange:n=>h(n.currentTarget.value),onKeyDown:n=>{n.key==="Enter"&&D()}}),e("button",{className:s.jumpGo,onClick:D,children:"Go"})]}),e("div",{className:s.optionList,children:C.map(n=>e("button",{className:`${s.optionBtn} ${n===t?s.current:""}`,onClick:()=>B(n),disabled:n===t,children:n},n))})]})]}),e("button",{className:s.pageBtn,onClick:()=>p(t+1),disabled:I,"aria-label":"Next page",children:[g==="labeled"&&e("span",{children:"Next"}),e(P,{name:"chevron-right",size:14})]})]})},Q="_skeletonCard_1b0hr_1",U="_poster_1b0hr_11",V="_line_1b0hr_20",X="_info_1b0hr_38",Y="_short_1b0hr_54",Z="_horizontal_1b0hr_60",nn="_vertical_1b0hr_78",en="_lowEnd_1b0hr_97",a={skeletonCard:Q,poster:U,line:V,"skeleton-wave":"_skeleton-wave_1b0hr_1",info:X,short:Y,horizontal:Z,vertical:nn,lowEnd:en},tn=({layout:t="vertical"})=>{const{lowEndMode:d}=L();return e("div",{className:`${a.skeletonCard} ${a[t]} ${d?a.lowEnd:""}`,children:[e("div",{className:a.poster}),e("div",{className:a.info,children:[e("div",{className:a.line}),e("div",{className:`${a.line} ${a.short}`})]})]})},on=({count:t=14,layout:d="vertical"})=>e("div",{className:"grid-container",children:Array.from({length:t}).map((m,p)=>e(tn,{layout:d},p))}),ln=A.memo(on);export{tn as A,cn as P,ln as S};
@@ -1,2 +1,2 @@
1
- import{d as t,h as Re,g as Be,A as De,q as $e,u as e,S as d}from"./vendor-core-DfaOB3Rn.js";import{u as qe,b as Fe,a as I}from"./vendor-query-BBT5_sHx.js";import{z as i,t as h,a0 as nn,j as an,B as le}from"./index-BWIWE3Qy.js";import{I as l}from"./vendor-icons-DrybRNxP.js";function tn(){const K=qe(),[Y,k]=t(!1);return Re(()=>{const s=new URLSearchParams(window.location.search),b=s.get("anilist");if(b){const m=s.get("user"),_=s.get("reason");window.history.replaceState(null,"",window.location.pathname),b==="success"?(i.success(m?`Connected to AniList as ${decodeURIComponent(m)}`:"Connected to AniList"),K.invalidateQueries({queryKey:["trackerStatus"]})):i.error(_?decodeURIComponent(_):"AniList authentication failed");return}const j=new URLSearchParams(window.location.hash.substring(1)),y=j.get("access_token"),x=s.get("code");if(!y&&!x){const m=j.get("error");m&&(i.error(`AniList error: ${m}`),window.history.replaceState(null,"",window.location.pathname));return}const g=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),k(!0),i("Connecting to AniList..."),h.tracker.anilistAuth.mutate(y?{token:y}:{code:x,redirectUri:g}).then(async m=>{const _=m.user;i.success(`Connected to AniList as ${_?.name??"AniList user"}`),K.invalidateQueries({queryKey:["trackerStatus"]})}).catch(m=>{i.error(m instanceof Error?m.message:"Failed to authenticate with AniList")}).finally(()=>{k(!1)})},[K]),Y}const sn="_header_j1lbh_1",rn="_fadeIn_j1lbh_1",ln="_pageTitle_j1lbh_6",on="_pageSubtitle_j1lbh_14",cn="_importCard_j1lbh_20",dn="_slideUpIn_j1lbh_1",mn="_cardHeader_j1lbh_37",pn="_uploadArea_j1lbh_55",hn="_fileInputWrapper_j1lbh_59",un="_fileInput_j1lbh_59",gn="_fileDisplay_j1lbh_87",yn="_fileIcon_j1lbh_95",bn="_fileName_j1lbh_100",_n="_browseButton_j1lbh_109",fn="_optionsArea_j1lbh_120",Nn="_checkboxLabel_j1lbh_128",kn="_checkbox_j1lbh_128",wn="_checkboxCustom_j1lbh_141",vn="_optionText_j1lbh_169",In="_optionTitle_j1lbh_175",xn="_optionDesc_j1lbh_181",Mn="_actions_j1lbh_187",Cn="_importBtn_j1lbh_195",Ln="_cancelBtn_j1lbh_201",Sn="_statusMessage_j1lbh_215",Tn="_success_j1lbh_225",An="_error_j1lbh_231",jn="_progressSection_j1lbh_237",Pn="_progressBar_j1lbh_242",En="_progressFill_j1lbh_250",Bn="_progressInfo_j1lbh_257",Dn="_progressCount_j1lbh_264",$n="_progressTitle_j1lbh_271",Fn="_sourceBadge_j1lbh_289",Un="_anilist_j1lbh_301",Rn="_kitsu_j1lbh_307",qn="_offline_j1lbh_313",Kn="_skipped_j1lbh_319",On="_cardTitleRow_j1lbh_324",Qn="_anilistIcon_j1lbh_334",Gn="_malIcon_j1lbh_340",Hn="_badgeOnline_j1lbh_346",Wn="_badgeOffline_j1lbh_358",zn="_connectedProfile_j1lbh_370",Xn="_avatar_j1lbh_379",Jn="_connectedInfo_j1lbh_386",Yn="_connectedName_j1lbh_394",Vn="_connectedHint_j1lbh_400",Zn="_loginPrompt_j1lbh_405",ea="_loginSection_j1lbh_413",na="_fieldLabel_j1lbh_419",aa="_helpText_j1lbh_438",ta="_loginText_j1lbh_455",sa="_primaryBtn_j1lbh_464",ia="_secondaryBtn_j1lbh_465",ra="_syncBtn_j1lbh_466",la="_divider_j1lbh_518",oa="_actionSection_j1lbh_524",ca="_inputGroup_j1lbh_538",da="_input_j1lbh_538",ma="_syncSummary_j1lbh_559",pa="_syncErrors_j1lbh_565",ha="_spin_j1lbh_569",ua="_radioGroup_j1lbh_598",ga="_radioLabel_j1lbh_604",ya="_syncHint_j1lbh_642",ba="_importLoading_j1lbh_649",n={header:sn,fadeIn:rn,pageTitle:ln,pageSubtitle:on,importCard:cn,slideUpIn:dn,cardHeader:mn,uploadArea:pn,fileInputWrapper:hn,fileInput:un,fileDisplay:gn,fileIcon:yn,fileName:bn,browseButton:_n,optionsArea:fn,checkboxLabel:Nn,checkbox:kn,checkboxCustom:wn,optionText:vn,optionTitle:In,optionDesc:xn,actions:Mn,importBtn:Cn,cancelBtn:Ln,statusMessage:Sn,success:Tn,error:An,progressSection:jn,progressBar:Pn,progressFill:En,progressInfo:Bn,progressCount:Dn,progressTitle:$n,sourceBadge:Fn,anilist:Un,kitsu:Rn,offline:qn,skipped:Kn,cardTitleRow:On,anilistIcon:Qn,malIcon:Gn,badgeOnline:Hn,badgeOffline:Wn,connectedProfile:zn,avatar:Xn,connectedInfo:Jn,connectedName:Yn,connectedHint:Vn,loginPrompt:Zn,loginSection:ea,fieldLabel:na,helpText:aa,loginText:ta,primaryBtn:sa,secondaryBtn:ia,syncBtn:ra,divider:la,actionSection:oa,inputGroup:ca,input:da,syncSummary:ma,syncErrors:pa,spin:ha,radioGroup:ua,radioLabel:ga,syncHint:ya,importLoading:ba},oe="tracker_anilist_client_id",Ue="49887".trim(),wa=()=>{const{setIsOpen:K}=nn(),{contentType:Y}=an(),k=Y==="manga",s=qe();Be.useEffect(()=>{document.title="Trackers - dango"},[]);const[b,j]=t(""),[y,x]=t("username"),[g,m]=t(null),[_,ce]=t(""),[M,de]=t(!1),Ke=tn(),{data:me,isLoading:pe}=Fe({queryKey:["trackerStatus"],queryFn:async()=>await h.tracker.status.query()}),{data:C}=Fe({queryKey:["anilistClientId"],queryFn:async()=>(await h.settings.getByKey.query({key:oe})).value||""}),he=De(!1);Be.useEffect(()=>{he.current||C!==void 0&&(C&&ce(C),he.current=!0)},[C]);const w=me?.anilist?.connected??!1;Re(()=>{w&&x("sync")},[w]);const O=me?.anilist?.user??null,V=!!Ue,Oe=(C||"").trim(),Qe=async()=>{const a=_.trim(),r=a||Ue;if(!r){i.error("Enter your AniList client ID first");return}const N=async(A,se)=>{await h.settings.set.mutate({key:A,value:se})};try{a?a!==C&&await N(oe,a):V&&Oe&&await N(oe,""),s.invalidateQueries({queryKey:["anilistClientId"]})}catch(A){i.error(A.message);return}const o=window.location.origin+window.location.pathname,U=encodeURIComponent(o);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(r)}&response_type=token&state=${U}`},ue=I({mutationFn:async()=>h.tracker.anilistDisconnect.mutate(),onSuccess:()=>{s.invalidateQueries({queryKey:["trackerStatus"]}),i.success("Disconnected from AniList")},onError:a=>i.error(a.message)}),Q=I({mutationFn:async()=>(await h.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),m(a),i.success(`Sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}`,{duration:6e3})},onError:a=>i.error(a.message)}),[P,ge]=t(""),[G,ye]=t("sync"),[Z,be]=t("two-way"),[c,Ge]=t(null),H=I({mutationFn:async()=>(await h.tracker.mangaSync.mutate({direction:Z})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),Ge(a);const r=(a.warnings?.length??0)>0?`, ${a.warnings.length} warning(s)`:"";i.success(`Manga sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}${r}`,{duration:6e3})},onError:a=>i.error(a.message)}),L=I({mutationFn:async()=>{if(!P.trim())throw new Error("Please enter a username");return(await h.tracker.mangaImport.mutate({username:P.trim(),erase:M})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from AniList`),ge("")},onError:a=>i.error(a.message)}),[E,_e]=t(""),[W,fe]=t("username"),[ee,Ne]=t(null),[z,ke]=t(!1),[we,ne]=t(""),[ve,He]=t(""),f=I({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a MAL username");const a=await h.tracker.mangaMalImport.mutate({username:E.trim(),erase:M});return{imported:a.imported??0,skipped:a.skipped??0}},onSuccess:({imported:a,skipped:r})=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from MAL${r>0?`, skipped ${r}`:""}`),_e("")},onError:a=>i.error(a.message)}),We=$e(async()=>{const a=document.getElementById("malMangaFile");if(!a.files||a.files.length===0){ne("Please select a file first.");return}ke(!0),ne(""),Ne(null);try{const r=new FormData;r.append("xmlfile",a.files[0]),r.append("erase",String(M));const N=await fetch("/api/import/mal-xml-manga",{method:"POST",body:r}),o=await N.json().catch(()=>({}));if(!N.ok)throw new Error(o.error||"Import failed");Ne({imported:o.imported??0,skipped:o.skipped??0}),s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]})}catch(r){ne(r.message)}finally{ke(!1)}},[M,s]),S=I({mutationFn:async()=>{if(!b.trim())throw new Error("Please enter a username");return(await h.tracker.anilistImport.mutate({username:b.trim(),erase:v})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from AniList`),j("")},onError:a=>i.error(a.message)}),[B,Ie]=t(""),u=I({mutationFn:async a=>{if(!B.trim())throw new Error("Please enter a MAL username");return(await h.tracker.malImport.mutate({username:B.trim(),erase:a.erase,useOfflineDb:a.useOfflineDb,skipFallback:a.skipFallback})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from MAL`),Ie("")},onError:a=>i.error(a.message)}),[v,xe]=t(!1),[D,ze]=t(!0),[$,Xe]=t(!1),[Me,Ce]=t(""),[T,Le]=t(!1),[p,Se]=t(null),[ae,Te]=t(null),[Ae,X]=t(""),te=De(null),Je=a=>{a.target.files&&a.target.files.length>0?Ce(a.target.files[0].name):Ce("")},Ye=$e(async()=>{const a=document.getElementById("malFile");if(!a.files||a.files.length===0){X("Please select a file first.");return}const r=a.files[0];Le(!0),Se(null),Te(null),X("");const N=new AbortController;te.current=N;try{const o=new FormData;o.append("xmlfile",r),o.append("erase",String(v)),o.append("useOfflineDb",String(D)),o.append("skipFallback",String($));const U=await fetch("/api/import/mal-xml",{method:"POST",body:o,signal:N.signal});if(!U.ok){const re=await U.text();let R="Failed to import";try{R=JSON.parse(re).error||R}catch{}throw new Error(R)}const A=U.body?.getReader();if(!A)throw new Error("No response stream");const se=new TextDecoder;let ie="",J="";for(;;){const{done:re,value:R}=await A.read();if(re)break;ie+=se.decode(R,{stream:!0});const Pe=ie.split(`
1
+ import{d as t,h as Re,g as Be,A as De,q as $e,u as e,S as d}from"./vendor-core-DfaOB3Rn.js";import{u as qe,b as Fe,a as I}from"./vendor-query-BBT5_sHx.js";import{z as i,t as h,a0 as nn,j as an,B as le}from"./index-gMxawd-E.js";import{I as l}from"./vendor-icons-DrybRNxP.js";function tn(){const K=qe(),[Y,k]=t(!1);return Re(()=>{const s=new URLSearchParams(window.location.search),b=s.get("anilist");if(b){const m=s.get("user"),_=s.get("reason");window.history.replaceState(null,"",window.location.pathname),b==="success"?(i.success(m?`Connected to AniList as ${decodeURIComponent(m)}`:"Connected to AniList"),K.invalidateQueries({queryKey:["trackerStatus"]})):i.error(_?decodeURIComponent(_):"AniList authentication failed");return}const j=new URLSearchParams(window.location.hash.substring(1)),y=j.get("access_token"),x=s.get("code");if(!y&&!x){const m=j.get("error");m&&(i.error(`AniList error: ${m}`),window.history.replaceState(null,"",window.location.pathname));return}const g=window.location.origin+window.location.pathname;window.history.replaceState(null,"",window.location.pathname),k(!0),i("Connecting to AniList..."),h.tracker.anilistAuth.mutate(y?{token:y}:{code:x,redirectUri:g}).then(async m=>{const _=m.user;i.success(`Connected to AniList as ${_?.name??"AniList user"}`),K.invalidateQueries({queryKey:["trackerStatus"]})}).catch(m=>{i.error(m instanceof Error?m.message:"Failed to authenticate with AniList")}).finally(()=>{k(!1)})},[K]),Y}const sn="_header_j1lbh_1",rn="_fadeIn_j1lbh_1",ln="_pageTitle_j1lbh_6",on="_pageSubtitle_j1lbh_14",cn="_importCard_j1lbh_20",dn="_slideUpIn_j1lbh_1",mn="_cardHeader_j1lbh_37",pn="_uploadArea_j1lbh_55",hn="_fileInputWrapper_j1lbh_59",un="_fileInput_j1lbh_59",gn="_fileDisplay_j1lbh_87",yn="_fileIcon_j1lbh_95",bn="_fileName_j1lbh_100",_n="_browseButton_j1lbh_109",fn="_optionsArea_j1lbh_120",Nn="_checkboxLabel_j1lbh_128",kn="_checkbox_j1lbh_128",wn="_checkboxCustom_j1lbh_141",vn="_optionText_j1lbh_169",In="_optionTitle_j1lbh_175",xn="_optionDesc_j1lbh_181",Mn="_actions_j1lbh_187",Cn="_importBtn_j1lbh_195",Ln="_cancelBtn_j1lbh_201",Sn="_statusMessage_j1lbh_215",Tn="_success_j1lbh_225",An="_error_j1lbh_231",jn="_progressSection_j1lbh_237",Pn="_progressBar_j1lbh_242",En="_progressFill_j1lbh_250",Bn="_progressInfo_j1lbh_257",Dn="_progressCount_j1lbh_264",$n="_progressTitle_j1lbh_271",Fn="_sourceBadge_j1lbh_289",Un="_anilist_j1lbh_301",Rn="_kitsu_j1lbh_307",qn="_offline_j1lbh_313",Kn="_skipped_j1lbh_319",On="_cardTitleRow_j1lbh_324",Qn="_anilistIcon_j1lbh_334",Gn="_malIcon_j1lbh_340",Hn="_badgeOnline_j1lbh_346",Wn="_badgeOffline_j1lbh_358",zn="_connectedProfile_j1lbh_370",Xn="_avatar_j1lbh_379",Jn="_connectedInfo_j1lbh_386",Yn="_connectedName_j1lbh_394",Vn="_connectedHint_j1lbh_400",Zn="_loginPrompt_j1lbh_405",ea="_loginSection_j1lbh_413",na="_fieldLabel_j1lbh_419",aa="_helpText_j1lbh_438",ta="_loginText_j1lbh_455",sa="_primaryBtn_j1lbh_464",ia="_secondaryBtn_j1lbh_465",ra="_syncBtn_j1lbh_466",la="_divider_j1lbh_518",oa="_actionSection_j1lbh_524",ca="_inputGroup_j1lbh_538",da="_input_j1lbh_538",ma="_syncSummary_j1lbh_559",pa="_syncErrors_j1lbh_565",ha="_spin_j1lbh_569",ua="_radioGroup_j1lbh_598",ga="_radioLabel_j1lbh_604",ya="_syncHint_j1lbh_642",ba="_importLoading_j1lbh_649",n={header:sn,fadeIn:rn,pageTitle:ln,pageSubtitle:on,importCard:cn,slideUpIn:dn,cardHeader:mn,uploadArea:pn,fileInputWrapper:hn,fileInput:un,fileDisplay:gn,fileIcon:yn,fileName:bn,browseButton:_n,optionsArea:fn,checkboxLabel:Nn,checkbox:kn,checkboxCustom:wn,optionText:vn,optionTitle:In,optionDesc:xn,actions:Mn,importBtn:Cn,cancelBtn:Ln,statusMessage:Sn,success:Tn,error:An,progressSection:jn,progressBar:Pn,progressFill:En,progressInfo:Bn,progressCount:Dn,progressTitle:$n,sourceBadge:Fn,anilist:Un,kitsu:Rn,offline:qn,skipped:Kn,cardTitleRow:On,anilistIcon:Qn,malIcon:Gn,badgeOnline:Hn,badgeOffline:Wn,connectedProfile:zn,avatar:Xn,connectedInfo:Jn,connectedName:Yn,connectedHint:Vn,loginPrompt:Zn,loginSection:ea,fieldLabel:na,helpText:aa,loginText:ta,primaryBtn:sa,secondaryBtn:ia,syncBtn:ra,divider:la,actionSection:oa,inputGroup:ca,input:da,syncSummary:ma,syncErrors:pa,spin:ha,radioGroup:ua,radioLabel:ga,syncHint:ya,importLoading:ba},oe="tracker_anilist_client_id",Ue="49887".trim(),wa=()=>{const{setIsOpen:K}=nn(),{contentType:Y}=an(),k=Y==="manga",s=qe();Be.useEffect(()=>{document.title="Trackers - dango"},[]);const[b,j]=t(""),[y,x]=t("username"),[g,m]=t(null),[_,ce]=t(""),[M,de]=t(!1),Ke=tn(),{data:me,isLoading:pe}=Fe({queryKey:["trackerStatus"],queryFn:async()=>await h.tracker.status.query()}),{data:C}=Fe({queryKey:["anilistClientId"],queryFn:async()=>(await h.settings.getByKey.query({key:oe})).value||""}),he=De(!1);Be.useEffect(()=>{he.current||C!==void 0&&(C&&ce(C),he.current=!0)},[C]);const w=me?.anilist?.connected??!1;Re(()=>{w&&x("sync")},[w]);const O=me?.anilist?.user??null,V=!!Ue,Oe=(C||"").trim(),Qe=async()=>{const a=_.trim(),r=a||Ue;if(!r){i.error("Enter your AniList client ID first");return}const N=async(A,se)=>{await h.settings.set.mutate({key:A,value:se})};try{a?a!==C&&await N(oe,a):V&&Oe&&await N(oe,""),s.invalidateQueries({queryKey:["anilistClientId"]})}catch(A){i.error(A.message);return}const o=window.location.origin+window.location.pathname,U=encodeURIComponent(o);window.location.href=`https://anilist.co/api/v2/oauth/authorize?client_id=${encodeURIComponent(r)}&response_type=token&state=${U}`},ue=I({mutationFn:async()=>h.tracker.anilistDisconnect.mutate(),onSuccess:()=>{s.invalidateQueries({queryKey:["trackerStatus"]}),i.success("Disconnected from AniList")},onError:a=>i.error(a.message)}),Q=I({mutationFn:async()=>(await h.tracker.sync.mutate({provider:"anilist"})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),m(a),i.success(`Sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}`,{duration:6e3})},onError:a=>i.error(a.message)}),[P,ge]=t(""),[G,ye]=t("sync"),[Z,be]=t("two-way"),[c,Ge]=t(null),H=I({mutationFn:async()=>(await h.tracker.mangaSync.mutate({direction:Z})).summary,onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),Ge(a);const r=(a.warnings?.length??0)>0?`, ${a.warnings.length} warning(s)`:"";i.success(`Manga sync complete — pushed ${a.pushed}, pulled ${a.pulled}, merged ${a.merged}, unchanged ${a.unchanged}${r}`,{duration:6e3})},onError:a=>i.error(a.message)}),L=I({mutationFn:async()=>{if(!P.trim())throw new Error("Please enter a username");return(await h.tracker.mangaImport.mutate({username:P.trim(),erase:M})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from AniList`),ge("")},onError:a=>i.error(a.message)}),[E,_e]=t(""),[W,fe]=t("username"),[ee,Ne]=t(null),[z,ke]=t(!1),[we,ne]=t(""),[ve,He]=t(""),f=I({mutationFn:async()=>{if(!E.trim())throw new Error("Please enter a MAL username");const a=await h.tracker.mangaMalImport.mutate({username:E.trim(),erase:M});return{imported:a.imported??0,skipped:a.skipped??0}},onSuccess:({imported:a,skipped:r})=>{s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]}),i.success(`Imported ${a} manga entries from MAL${r>0?`, skipped ${r}`:""}`),_e("")},onError:a=>i.error(a.message)}),We=$e(async()=>{const a=document.getElementById("malMangaFile");if(!a.files||a.files.length===0){ne("Please select a file first.");return}ke(!0),ne(""),Ne(null);try{const r=new FormData;r.append("xmlfile",a.files[0]),r.append("erase",String(M));const N=await fetch("/api/import/mal-xml-manga",{method:"POST",body:r}),o=await N.json().catch(()=>({}));if(!N.ok)throw new Error(o.error||"Import failed");Ne({imported:o.imported??0,skipped:o.skipped??0}),s.invalidateQueries({queryKey:["manga-library"]}),s.invalidateQueries({queryKey:["manga-continue-reading"]})}catch(r){ne(r.message)}finally{ke(!1)}},[M,s]),S=I({mutationFn:async()=>{if(!b.trim())throw new Error("Please enter a username");return(await h.tracker.anilistImport.mutate({username:b.trim(),erase:v})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from AniList`),j("")},onError:a=>i.error(a.message)}),[B,Ie]=t(""),u=I({mutationFn:async a=>{if(!B.trim())throw new Error("Please enter a MAL username");return(await h.tracker.malImport.mutate({username:B.trim(),erase:a.erase,useOfflineDb:a.useOfflineDb,skipFallback:a.skipFallback})).count},onSuccess:a=>{s.invalidateQueries({queryKey:["watchlist"]}),s.invalidateQueries({queryKey:["allContinueWatching"]}),i.success(`Imported ${a} anime entries from MAL`),Ie("")},onError:a=>i.error(a.message)}),[v,xe]=t(!1),[D,ze]=t(!0),[$,Xe]=t(!1),[Me,Ce]=t(""),[T,Le]=t(!1),[p,Se]=t(null),[ae,Te]=t(null),[Ae,X]=t(""),te=De(null),Je=a=>{a.target.files&&a.target.files.length>0?Ce(a.target.files[0].name):Ce("")},Ye=$e(async()=>{const a=document.getElementById("malFile");if(!a.files||a.files.length===0){X("Please select a file first.");return}const r=a.files[0];Le(!0),Se(null),Te(null),X("");const N=new AbortController;te.current=N;try{const o=new FormData;o.append("xmlfile",r),o.append("erase",String(v)),o.append("useOfflineDb",String(D)),o.append("skipFallback",String($));const U=await fetch("/api/import/mal-xml",{method:"POST",body:o,signal:N.signal});if(!U.ok){const re=await U.text();let R="Failed to import";try{R=JSON.parse(re).error||R}catch{}throw new Error(R)}const A=U.body?.getReader();if(!A)throw new Error("No response stream");const se=new TextDecoder;let ie="",J="";for(;;){const{done:re,value:R}=await A.read();if(re)break;ie+=se.decode(R,{stream:!0});const Pe=ie.split(`
2
2
  `);ie=Pe.pop()||"";for(const q of Pe)if(q.startsWith("event: "))J=q.slice(7).trim();else if(q.startsWith("data: ")){const en=q.slice(6);try{const Ee=JSON.parse(en);J==="progress"?Se(Ee):J==="complete"&&Te(Ee)}catch{}}else q===""&&(J="")}s.invalidateQueries({queryKey:["watchlist"]})}catch(o){o instanceof DOMException&&o.name==="AbortError"?X("Import cancelled."):X(o.message)}finally{Le(!1),te.current=null}},[v,D,$,s]),Ve=()=>{te.current?.abort(),h.settings.malImportCancel.mutate().catch(()=>{})},Ze=p?Math.round(p.current/p.total*100):0,[F,je]=t("username");return e("div",{className:"page-container",children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:"Trackers"}),e("p",{className:n.pageSubtitle,children:"Import & sync your anime watchlists and manga reading lists with tracking services"})]}),e("div",{style:{marginBottom:"16px",padding:"10px 14px",borderRadius:"8px",fontSize:"0.85rem",background:"color-mix(in srgb, var(--color-warning) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-warning) 25%, transparent)",color:"var(--text-secondary)"},children:"⚠ Syncing writes directly to your AniList entries, and dango may not always handle anime/manga lists correctly — always keep a backup of your lists before syncing."}),!k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList"}),pe?null:w?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),w&&O?e("div",{className:n.connectedProfile,children:[O.avatar&&e("img",{src:O.avatar,alt:"Avatar",className:n.avatar,loading:"lazy",decoding:"async"}),e("div",{className:n.connectedInfo,children:[e("span",{className:n.connectedName,children:O.name}),e("span",{className:n.connectedHint,children:"2-way sync is ready"})]}),e("button",{className:n.secondaryBtn,onClick:()=>ue.mutate(),disabled:ue.isPending,children:[e(l,{name:"sign-out-alt"})," Disconnect"]})]}):e("div",{className:n.loginSection,children:[e("p",{className:n.loginText,children:["Log in with AniList to enable bidirectional progress & status synchronization.",Ke&&e("span",{style:{marginLeft:8,color:"var(--accent)"},children:"Finishing login…"})]}),e("div",{className:n.fieldLabel,children:["AniList client ID — defaults to Dango's app"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:["create your own app ",e(l,{name:"external-link-alt",size:9})]})]}),e("div",{className:n.inputGroup,children:[e("input",{type:"text",placeholder:"Client ID",value:_,onChange:a=>ce(a.target.value),className:n.input}),e("button",{className:n.primaryBtn,onClick:Qe,disabled:!(_.trim()||V),children:[e(l,{name:"external-link-alt"})," Connect"]})]}),e("p",{className:n.helpText,children:V?e(d,{children:["By default uses Dango's client. To use your own AniList app: create it at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set its ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:window.location.port==="5173"?`${window.location.protocol}//${window.location.hostname}:3000/api/tracker/anilist/callback`:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste only the ",e("strong",{children:"Client ID"})," above (leave empty to use Dango's)."]}):e(d,{children:["No shipped client in this build — create your own app at"," ",e("a",{href:"https://anilist.co/settings/developer",target:"_blank",rel:"noopener noreferrer",children:"anilist.co/settings/developer"}),", set ",e("strong",{children:"Redirect URL"})," to"," ",e("code",{children:window.location.port==="5173"?`${window.location.protocol}//${window.location.hostname}:3000/api/tracker/anilist/callback`:`${window.location.origin}/api/tracker/anilist/callback`}),", then paste the ",e("strong",{children:"Client ID"})," above."]})})]}),w&&e(d,{children:[e("hr",{className:n.divider}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"username",checked:y==="username",onChange:()=>x("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"anilistMode",value:"sync",checked:y==="sync",onChange:()=>x("sync")}),e("span",{children:"Two-way Sync"})]})]}),y==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:b,onChange:a=>j(a.target.value),className:n.input,disabled:S.isPending,onKeyDown:a=>{a.key==="Enter"&&b.trim()&&S.mutate()}})}):e("p",{className:n.syncHint,children:"Merges progress non-destructively: pushes shows and episodes you watched on dango to AniList, and pulls anything you updated on AniList into dango."}),y==="username"&&e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:v,onChange:a=>xe(a.target.checked),className:n.checkbox,disabled:S.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]})}),y==="username"?e("button",{className:n.syncBtn,onClick:()=>S.mutate(),disabled:!b.trim()||S.isPending,children:[e(l,{name:"download"}),S.isPending?"Importing...":"Start Import"]}):e(d,{children:[e("button",{className:n.syncBtn,onClick:()=>Q.mutate(),disabled:Q.isPending,children:[e(l,{name:"sync-alt",className:Q.isPending?n.spin:""}),Q.isPending?"Syncing...":"Start Sync"]}),g&&e("div",{className:n.syncSummary,children:["Pushed: ",g.pushed," · Pulled: ",g.pulled," · Merged:"," ",g.merged," · Unchanged: ",g.unchanged,g.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",g.errors.length," error",g.errors.length>1?"s":""]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rewatching (REPEATING)"})," is not tracked — entries with this status are ignored."]})]})]})}),k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"anilist",className:n.anilistIcon}),e("h3",{children:"AniList Manga"}),pe?null:w?e("span",{className:n.badgeOnline,children:"Connected"}):e("span",{className:n.badgeOffline,children:"Not connected"})]})}),w?e(d,{children:[e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"username",checked:G==="username",onChange:()=>ye("username")}),e("span",{children:"Quick Import"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaMode",value:"sync",checked:G==="sync",onChange:()=>ye("sync")}),e("span",{children:"Two-way Sync"})]})]}),G==="username"?e(d,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter AniList username",value:P,onChange:a=>ge(a.target.value),className:n.input,disabled:L.isPending,onKeyDown:a=>{a.key==="Enter"&&P.trim()&&L.mutate()}})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:M,onChange:a=>de(a.target.checked),className:n.checkbox,disabled:L.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:n.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})})]}):e(d,{children:[e("p",{className:n.syncHint,children:"Merges chapter progress non-destructively: pushes manga and chapters you read on dango to AniList, and pulls anything you updated on AniList into dango. Local titles are linked only on exact title matches, and bookmarks with no chapters read are never pushed."}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"two-way",checked:Z==="two-way",onChange:()=>be("two-way")}),e("span",{children:"Two-way"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"mangaDirection",value:"pull-only",checked:Z==="pull-only",onChange:()=>be("pull-only")}),e("span",{children:"Pull only (never writes to AniList)"})]})]})]}),G==="username"?e("button",{className:n.syncBtn,onClick:()=>L.mutate(),disabled:!P.trim()||L.isPending,children:[e(l,{name:"download"}),L.isPending?"Importing...":"Start Import"]}):e(d,{children:[e("button",{className:n.syncBtn,onClick:()=>H.mutate(),disabled:H.isPending,children:[e(l,{name:"sync-alt",className:H.isPending?n.spin:""}),H.isPending?"Syncing...":"Start Manga Sync"]}),c&&e(d,{children:[e("div",{className:n.syncSummary,children:["Pushed: ",c.pushed," · Pulled: ",c.pulled," · Merged: ",c.merged," · Unchanged:"," ",c.unchanged,(c.skipped??0)>0&&e("span",{children:[" · Skipped: ",c.skipped]}),c.errors.length>0&&e("span",{className:n.syncErrors,children:[" ","· ",c.errors.length," error",c.errors.length>1?"s":""]})]}),(c.warnings?.length??0)>0&&e("div",{className:n.syncErrors,style:{marginTop:"8px"},children:[(c.warnings??[]).slice(0,5).map((a,r)=>e("div",{children:["⚠ ",a]},r)),(c.warnings?.length??0)>5&&e("div",{children:["+",(c.warnings?.length??0)-5," more warning(s)"]})]})]})]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:["AniList ",e("code",{children:"Rereading (REPEATING)"})," is not tracked — entries with this status are ignored."]})]}):e("p",{className:n.loginText,children:"Connect your AniList account above to sync your manga reading list."})]})}),!k&&e(d,{children:e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"username",checked:F==="username",onChange:()=>je("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMode",value:"xml",checked:F==="xml",onChange:()=>je("xml")}),e("span",{children:"XML File"})]})]}),F==="username"?e(d,{children:[e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:B,onChange:a=>Ie(a.target.value),className:n.input,disabled:u.isPending,onKeyDown:a=>{a.key==="Enter"&&B.trim()&&u.mutate({erase:v,useOfflineDb:D,skipFallback:$})}})}),u.isPending&&e("div",{className:n.importLoading,children:[e(l,{name:"sync-alt",className:n.spin}),e("span",{children:"Importing from MAL..."})]})]}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malFile",accept:".xml,application/xml",className:n.fileInput,onChange:Je,disabled:T}),e("div",{className:n.fileDisplay,children:[e(l,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:Me||"Choose XML file..."})]}),e("label",{htmlFor:"malFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:[e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:v,onChange:a=>xe(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Erase current watchlist"}),e("span",{className:n.optionDesc,children:"Delete existing watchlist before importing."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:D,onChange:a=>ze(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Use offline database (fast)"}),e("span",{className:n.optionDesc,children:"Match by MAL ID locally first — instant and avoids AniList rate limits."})]})]}),e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:$,onChange:a=>Xe(a.target.checked),className:n.checkbox,disabled:T||u.isPending}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Skip online fallback"}),e("span",{className:n.optionDesc,children:"Only import offline matches. Unmatched titles are skipped without API calls."})]})]})]}),F==="username"?e("button",{className:n.syncBtn,onClick:()=>u.mutate({erase:v,useOfflineDb:D,skipFallback:$}),disabled:!B.trim()||u.isPending,children:[e(l,{name:"download"}),u.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:T?e(le,{onClick:Ve,className:n.cancelBtn,children:"Cancel Import"}):e(le,{onClick:Ye,className:n.importBtn,disabled:!Me,children:[e(l,{name:"upload"})," Start Import"]})}),F==="username"&&u.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:u.error.message}),T&&p&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressBar,children:e("div",{className:n.progressFill,style:{width:`${Ze}%`}})}),e("div",{className:n.progressInfo,children:[e("span",{className:n.progressCount,children:[p.current," / ",p.total]}),e("span",{className:n.progressTitle,children:p.found?e(d,{children:[p.matchedTitle,e("span",{className:`${n.sourceBadge} ${n[p.source||"anilist"]}`,children:p.source==="kitsu"?"Kitsu":p.source==="offline"?"Offline DB":"AniList"})]}):e("span",{className:n.skipped,children:["Skipped: ",p.title]})})]})]}),ae&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",ae.imported,", Skipped: ",ae.skipped,"."]}),Ae&&e("div",{className:`${n.statusMessage} ${n.error}`,children:Ae})]})}),k&&e("div",{className:n.importCard,children:[e("div",{className:n.cardHeader,children:e("div",{className:n.cardTitleRow,children:[e(l,{name:"myanimelist",className:n.malIcon}),e("h3",{children:"MyAnimeList Manga"})]})}),e("div",{className:n.radioGroup,children:[e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"username",checked:W==="username",onChange:()=>fe("username")}),e("span",{children:"Username"})]}),e("label",{className:n.radioLabel,children:[e("input",{type:"radio",name:"malMangaMode",value:"xml",checked:W==="xml",onChange:()=>fe("xml")}),e("span",{children:"XML File"})]})]}),W==="username"?e("div",{className:n.inputGroup,children:e("input",{type:"text",placeholder:"Enter MAL username",value:E,onChange:a=>_e(a.target.value),className:n.input,disabled:f.isPending,onKeyDown:a=>{a.key==="Enter"&&E.trim()&&f.mutate()}})}):e("div",{className:n.uploadArea,children:e("div",{className:n.fileInputWrapper,children:[e("input",{type:"file",id:"malMangaFile",accept:".xml,application/xml",className:n.fileInput,onChange:a=>He(a.target.files?.[0]?.name??""),disabled:z}),e("div",{className:n.fileDisplay,children:[e(l,{name:"file-alt",className:n.fileIcon}),e("span",{className:n.fileName,children:ve||"Choose XML file..."})]}),e("label",{htmlFor:"malMangaFile",className:n.browseButton,children:"Browse"})]})}),e("div",{className:n.optionsArea,children:e("label",{className:n.checkboxLabel,children:[e("input",{type:"checkbox",checked:M,onChange:a=>de(a.target.checked),className:n.checkbox,disabled:f.isPending||z}),e("span",{className:n.checkboxCustom}),e("div",{className:n.optionText,children:[e("span",{className:n.optionTitle,children:"Replace AniList-linked manga"}),e("span",{className:n.optionDesc,children:"Clears previously imported (anilist:) entries before importing. Your provider bookmarks are never touched."})]})]})}),W==="username"?e("button",{className:n.syncBtn,onClick:()=>f.mutate(),disabled:!E.trim()||f.isPending,children:[e(l,{name:"download"}),f.isPending?"Importing...":"Start Import"]}):e("div",{className:n.actions,children:e(le,{onClick:We,className:n.importBtn,disabled:z||!ve,children:[e(l,{name:"upload"})," ",z?"Importing...":"Start Import"]})}),f.isError&&e("div",{className:`${n.statusMessage} ${n.error}`,children:f.error.message}),we&&e("div",{className:`${n.statusMessage} ${n.error}`,children:we}),ee&&e("div",{className:`${n.statusMessage} ${n.success}`,children:["Import complete! Imported: ",ee.imported,", Skipped:"," ",ee.skipped,"."]}),e("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"8px"},children:"MAL manga is matched to AniList by MAL ID with a title fallback. Unmatched titles are skipped. Imports land as AniList-linked entries alongside your provider bookmarks."})]})]})};export{wa as default};