@serifpersia/dango 3.4.4 → 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 (96) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-4CEz8Buu.js → AnimeCard-BVdH0EeW.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-DyX9qTwg.js → AnimeInfo-Dw2Nop6Q.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-Dvp_c8vK.js → AnimeInfoPage-Cw-Tq3YX.js} +2 -2
  5. package/client/dist/assets/{Asmr-qg3lMAJn.js → Asmr-BrjzzyOi.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-BpPlg_Vv.js → AsmrResetProgressModal-CYjpcYpb.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-FJllOgOH.js → AvSyncCalibrator-BuHurVgo.js} +3 -3
  8. package/client/dist/assets/AvSyncCalibrator-D0FYSwiz.css +1 -0
  9. package/client/dist/assets/{Home-A7gCeEST.js → Home-KdnP7sNM.js} +1 -1
  10. package/client/dist/assets/{Insights-G9IXepHJ.js → Insights-DDWry-t1.js} +1 -1
  11. package/client/dist/assets/{LibraryListPage-Bh2qCJPh.js → LibraryListPage-CV8Z9JlO.js} +1 -1
  12. package/client/dist/assets/{ListeningList-Czv4cTRl.js → ListeningList-DSMbMZT7.js} +1 -1
  13. package/client/dist/assets/{Manga-qdAAS1z7.js → Manga-J6XoqEKq.js} +1 -1
  14. package/client/dist/assets/{MangaInfoPage-1rTgZzf2.js → MangaInfoPage-N7TxsN5u.js} +1 -1
  15. package/client/dist/assets/{MangaReadPage-CeyxPG6w.js → MangaReadPage-D_VzSNWq.js} +1 -1
  16. package/client/dist/assets/{MangaResetProgressModal-C_ppotmh.js → MangaResetProgressModal-DyhQYBDy.js} +1 -1
  17. package/client/dist/assets/{Mature-Bkhxnr3K.js → Mature-Db53R-LR.js} +1 -1
  18. package/client/dist/assets/{MediaCard-BQZsutEo.js → MediaCard-BcLjlpfR.js} +1 -1
  19. package/client/dist/assets/{Music-C0rGzSbi.js → Music-DjxQjJOl.js} +1 -1
  20. package/client/dist/assets/{OptionListMenu-CyfpCBEy.js → OptionListMenu-DngTgHxH.js} +1 -1
  21. package/client/dist/assets/Player-Be_7Ne5p.js +56 -0
  22. package/client/dist/assets/{PlayerSettings-icy4SfQa.js → PlayerSettings-D47ItGDR.js} +1 -1
  23. package/client/dist/assets/{QueueOptionsButton-5eloKF5J.js → QueueOptionsButton-ClVTpH8J.js} +1 -1
  24. package/client/dist/assets/{QueueRail-DaMjlKL4.js → QueueRail-DeJKVRs5.js} +1 -1
  25. package/client/dist/assets/{Radio-FxGqCxR4.js → Radio-DU0ma3GA.js} +1 -1
  26. package/client/dist/assets/{ReadingList-CCm3IAbt.js → ReadingList-qXW7Dk5z.js} +1 -1
  27. package/client/dist/assets/{ResetProgressModal-CeI4V3Y5.js → ResetProgressModal-C6ukct_c.js} +1 -1
  28. package/client/dist/assets/{Search-qpILaAiQ.js → Search-DjjKA_Wu.js} +1 -1
  29. package/client/dist/assets/{Settings-Bw9M3NGz.js → Settings-DQt_S5Qw.js} +1 -1
  30. package/client/dist/assets/{SkeletonGrid-0dY_xMq3.js → SkeletonGrid-nx2HEi4P.js} +1 -1
  31. package/client/dist/assets/{Trackers-Zy5GOs0P.js → Trackers-BcGzeqj2.js} +1 -1
  32. package/client/dist/assets/Tv-COvyHdeJ.js +4 -0
  33. package/client/dist/assets/{TvInfo-CHIsVzZ0.js → TvInfo-CUd1agFy.js} +1 -1
  34. package/client/dist/assets/{TvPopup-D_tVTyZ2.js → TvPopup-CJeu3tgc.js} +1 -1
  35. package/client/dist/assets/{TvSearch-BVxedBW-.js → TvSearch-BIypjbU3.js} +1 -1
  36. package/client/dist/assets/{TvWatchlist-BEIwq9R9.js → TvWatchlist-DZrBdiqZ.js} +1 -1
  37. package/client/dist/assets/{Watchlist-CSngjqlz.js → Watchlist-Dw8cPe0n.js} +1 -1
  38. package/client/dist/assets/{hls-D48GVTkk.js → hls-B3_1VuDP.js} +1 -1
  39. package/client/dist/assets/{index-CVB5dYhT.js → index-gMxawd-E.js} +2 -2
  40. package/client/dist/assets/{useAnimeInfoData-DxdOg_B7.js → useAnimeInfoData-_iOLEAa8.js} +1 -1
  41. package/client/dist/assets/{useAsmr-ClckxnPe.js → useAsmr-Blk4v41t.js} +1 -1
  42. package/client/dist/assets/{useAsmrPopup-Bbgxefy_.js → useAsmrPopup-D9SQIgZa.js} +1 -1
  43. package/client/dist/assets/{useMangaLibrary-B3_BUKVk.js → useMangaLibrary-B60at6ni.js} +1 -1
  44. package/client/dist/assets/{useMangaPopup-Celk4lzf.js → useMangaPopup-DEfGjWSu.js} +1 -1
  45. package/client/dist/assets/{useProviders-pwxPZPHh.js → useProviders-Ca0bZWt7.js} +1 -1
  46. package/client/dist/assets/{useTv-D9sQrDop.js → useTv-WJCDL5_5.js} +1 -1
  47. package/client/dist/assets/{useTvLibrary-UsQpgBTB.js → useTvLibrary-Fgn5i9rJ.js} +1 -1
  48. package/client/dist/index.html +1 -1
  49. package/package.json +4 -2
  50. package/server/dist/app-hono.js +2 -0
  51. package/server/dist/hono/asmr.js +10 -1
  52. package/server/dist/hono/music.js +122 -332
  53. package/server/dist/hono/proxy.js +105 -99
  54. package/server/dist/hono/tv.js +5 -58
  55. package/server/dist/hono/watchlist.js +2 -291
  56. package/server/dist/lib/anilist.js +0 -3
  57. package/server/dist/lib/mal.js +4 -41
  58. package/server/dist/lib/offline-db.js +0 -6
  59. package/server/dist/lib/potoken.js +135 -0
  60. package/server/dist/lib/tracker/manga-sync.service.js +3 -22
  61. package/server/dist/lib/tracker/sync-state.js +21 -0
  62. package/server/dist/lib/tracker/sync.service.js +3 -22
  63. package/server/dist/lib/ump.js +106 -0
  64. package/server/dist/providers/remote-loader.js +17 -27
  65. package/server/dist/providers/title-matching.js +5 -5
  66. package/server/dist/repositories/asmr.repository.js +4 -53
  67. package/server/dist/repositories/library.repository.js +46 -0
  68. package/server/dist/repositories/manga.repository.js +3 -53
  69. package/server/dist/repositories/settings.repository.js +8 -0
  70. package/server/dist/repositories/tv.repository.js +3 -46
  71. package/server/dist/repositories/watched-episodes.repository.js +0 -2
  72. package/server/dist/server.js +5 -1
  73. package/server/dist/sync.js +3 -5
  74. package/server/dist/trpc/routers/asmr-library.js +2 -12
  75. package/server/dist/trpc/routers/asmr-progress.js +10 -22
  76. package/server/dist/trpc/routers/data.js +17 -36
  77. package/server/dist/trpc/routers/discord.js +1 -8
  78. package/server/dist/trpc/routers/insights.js +15 -16
  79. package/server/dist/trpc/routers/manga-library.js +5 -22
  80. package/server/dist/trpc/routers/manga-progress.js +8 -20
  81. package/server/dist/trpc/routers/music.js +6 -11
  82. package/server/dist/trpc/routers/queue.js +1 -1
  83. package/server/dist/trpc/routers/tracker.js +1 -7
  84. package/server/dist/trpc/routers/tv-library.js +2 -12
  85. package/server/dist/trpc/routers/tv-progress.js +16 -28
  86. package/server/dist/trpc/routers/tv.js +5 -21
  87. package/server/dist/trpc/routers/watchlist.js +1 -8
  88. package/server/dist/trpc/validation.js +35 -0
  89. package/server/dist/utils/db-utils.js +8 -0
  90. package/server/dist/utils/http.utils.js +12 -0
  91. package/server/dist/utils/machine-id.js +1 -2
  92. package/server/dist/utils/megaplay.utils.js +1 -2
  93. package/server/package.json +4 -1
  94. package/client/dist/assets/AvSyncCalibrator-C2wu1ydI.css +0 -1
  95. package/client/dist/assets/Player-yhiTlpYU.js +0 -56
  96. package/client/dist/assets/Tv-DREwc7BX.js +0 -4
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Home-A7gCeEST.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-query-BBT5_sHx.js","assets/SkeletonGrid-0dY_xMq3.js","assets/vendor-icons-DrybRNxP.js","assets/SkeletonGrid-Bge3aRl2.css","assets/AnimeCard-4CEz8Buu.js","assets/useAnimeInfoData-DxdOg_B7.js","assets/QueueOptionsButton-5eloKF5J.js","assets/vendor-ui-3qrARCPr.js","assets/QueueOptionsButton-CM15uQn8.css","assets/MediaCard-BQZsutEo.js","assets/useIsMobile-Dvx1uJ82.js","assets/MediaCard-DB6Yjgky.css","assets/ErrorMessage-DAxegITP.js","assets/ErrorMessage-CXoRbrLN.css","assets/ResetProgressModal-CeI4V3Y5.js","assets/QueueRail-DaMjlKL4.js","assets/QueueRail-BUYEjdaq.css","assets/useMangaPopup-Celk4lzf.js","assets/useMangaLibrary-B3_BUKVk.js","assets/MangaResetProgressModal-C_ppotmh.js","assets/useProviders-pwxPZPHh.js","assets/useTv-D9sQrDop.js","assets/TvPopup-D_tVTyZ2.js","assets/useTvLibrary-UsQpgBTB.js","assets/AsmrResetProgressModal-BpPlg_Vv.js","assets/useAsmr-ClckxnPe.js","assets/Home-B6bte0tw.css","assets/Watchlist-CSngjqlz.js","assets/Watchlist.module-XGtVQr1d.js","assets/Watchlist-BiDEU0iV.css","assets/Settings-Bw9M3NGz.js","assets/Settings-AuFxQcJF.css","assets/Player-yhiTlpYU.js","assets/AvSyncCalibrator-FJllOgOH.js","assets/AvSyncCalibrator-C2wu1ydI.css","assets/hls-D48GVTkk.js","assets/AnimeMetaDetails-BogOi_bM.js","assets/AnimeMetaDetails-BwNQnRCd.css","assets/SynopsisText-B3Sa5pRv.js","assets/SynopsisText-CYv2W3yR.css","assets/Player-B036Ic3m.css","assets/Search-qpILaAiQ.js","assets/Search.module-CMEai-B-.js","assets/Search-Cs45oAwI.css","assets/Mature-Bkhxnr3K.js","assets/Mature-DJmUUtlF.css","assets/Asmr-qg3lMAJn.js","assets/Asmr.module-ChUXDZKx.js","assets/Asmr-Cq2ua6Zk.css","assets/useAsmrPopup-Bbgxefy_.js","assets/Manga-qdAAS1z7.js","assets/Manga.module-BcfOdsNP.js","assets/Manga-Dp_-l1Pw.css","assets/MangaInfoPage-1rTgZzf2.js","assets/MangaReadPage-CeyxPG6w.js","assets/ReadingList-CCm3IAbt.js","assets/LibraryListPage-Bh2qCJPh.js","assets/Radio-FxGqCxR4.js","assets/Radio.module-DGSZLpKM.js","assets/Radio-CCHNFN7R.css","assets/Music-C0rGzSbi.js","assets/Music-BGH_0voi.css","assets/TvSearch-BVxedBW-.js","assets/TvInfo-CHIsVzZ0.js","assets/TvInfo-Bu36xJyO.css","assets/Tv-DREwc7BX.js","assets/OptionListMenu-CyfpCBEy.js","assets/Tv-Bx7tGS57.css","assets/TvWatchlist-BEIwq9R9.js","assets/ListeningList-Czv4cTRl.js","assets/Trackers-Zy5GOs0P.js","assets/Trackers-D5XBOCDp.css","assets/Insights-G9IXepHJ.js","assets/Insights-Dc8xLmsr.css","assets/Map-BtXwpBOC.js","assets/Map-CXFqXmsZ.css","assets/AnimeInfoPage-Dvp_c8vK.js","assets/PlayerRedirect-fv2tzEUu.js","assets/VirtualKeyboard-BmqZPZXR.js","assets/VirtualKeyboard-KIPc5ZGH.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Home-KdnP7sNM.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-query-BBT5_sHx.js","assets/SkeletonGrid-nx2HEi4P.js","assets/vendor-icons-DrybRNxP.js","assets/SkeletonGrid-Bge3aRl2.css","assets/AnimeCard-BVdH0EeW.js","assets/useAnimeInfoData-_iOLEAa8.js","assets/QueueOptionsButton-ClVTpH8J.js","assets/vendor-ui-3qrARCPr.js","assets/QueueOptionsButton-CM15uQn8.css","assets/MediaCard-BcLjlpfR.js","assets/useIsMobile-Dvx1uJ82.js","assets/MediaCard-DB6Yjgky.css","assets/ErrorMessage-DAxegITP.js","assets/ErrorMessage-CXoRbrLN.css","assets/ResetProgressModal-C6ukct_c.js","assets/QueueRail-DeJKVRs5.js","assets/QueueRail-BUYEjdaq.css","assets/useMangaPopup-DEfGjWSu.js","assets/useMangaLibrary-B60at6ni.js","assets/MangaResetProgressModal-DyhQYBDy.js","assets/useProviders-Ca0bZWt7.js","assets/useTv-WJCDL5_5.js","assets/TvPopup-CJeu3tgc.js","assets/useTvLibrary-Fgn5i9rJ.js","assets/AsmrResetProgressModal-CYjpcYpb.js","assets/useAsmr-Blk4v41t.js","assets/Home-B6bte0tw.css","assets/Watchlist-Dw8cPe0n.js","assets/Watchlist.module-XGtVQr1d.js","assets/Watchlist-BiDEU0iV.css","assets/Settings-DQt_S5Qw.js","assets/Settings-AuFxQcJF.css","assets/Player-Be_7Ne5p.js","assets/AvSyncCalibrator-BuHurVgo.js","assets/AvSyncCalibrator-D0FYSwiz.css","assets/hls-B3_1VuDP.js","assets/AnimeMetaDetails-BogOi_bM.js","assets/AnimeMetaDetails-BwNQnRCd.css","assets/SynopsisText-B3Sa5pRv.js","assets/SynopsisText-CYv2W3yR.css","assets/Player-B036Ic3m.css","assets/Search-DjjKA_Wu.js","assets/Search.module-CMEai-B-.js","assets/Search-Cs45oAwI.css","assets/Mature-Db53R-LR.js","assets/Mature-DJmUUtlF.css","assets/Asmr-BrjzzyOi.js","assets/Asmr.module-ChUXDZKx.js","assets/Asmr-Cq2ua6Zk.css","assets/useAsmrPopup-D9SQIgZa.js","assets/Manga-J6XoqEKq.js","assets/Manga.module-BcfOdsNP.js","assets/Manga-Dp_-l1Pw.css","assets/MangaInfoPage-N7TxsN5u.js","assets/MangaReadPage-D_VzSNWq.js","assets/ReadingList-qXW7Dk5z.js","assets/LibraryListPage-CV8Z9JlO.js","assets/Radio-DU0ma3GA.js","assets/Radio.module-DGSZLpKM.js","assets/Radio-CCHNFN7R.css","assets/Music-DjxQjJOl.js","assets/Music-BGH_0voi.css","assets/TvSearch-BIypjbU3.js","assets/TvInfo-CUd1agFy.js","assets/TvInfo-Bu36xJyO.css","assets/Tv-COvyHdeJ.js","assets/OptionListMenu-DngTgHxH.js","assets/Tv-Bx7tGS57.css","assets/TvWatchlist-DZrBdiqZ.js","assets/ListeningList-DSMbMZT7.js","assets/Trackers-BcGzeqj2.js","assets/Trackers-D5XBOCDp.css","assets/Insights-DDWry-t1.js","assets/Insights-Dc8xLmsr.css","assets/Map-BtXwpBOC.js","assets/Map-CXFqXmsZ.css","assets/AnimeInfoPage-Cw-Tq3YX.js","assets/PlayerRedirect-fv2tzEUu.js","assets/VirtualKeyboard-BmqZPZXR.js","assets/VirtualKeyboard-KIPc5ZGH.css"])))=>i.map(i=>d[i]);
2
2
  import{N as wn,k as M,A as B,q as F,h as b,S as G,d as _,X as oe,x as ie,T as pe,g as Je,u as o,L as J,$ as Rt,a as qt,c as Ye,e as Sn,f as kn,D as Pn,i as En,P as at,j as Tn,l as w,m as ct,z as I,n as In,B as xn}from"./vendor-core-DfaOB3Rn.js";import{s as de,i as On,q as Nn,u as z,a as Y,b as Q,c as Ze,Q as Cn,d as An}from"./vendor-query-BBT5_sHx.js";import{I as v}from"./vendor-icons-DrybRNxP.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const Ln="modulepreload",Rn=function(e){return"/"+e},lt={},x=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let l=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");i=l(n.map(u=>{if(u=Rn(u),u in lt)return;lt[u]=!0;const d=u.endsWith(".css"),m=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${m}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":Ln,d||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((h,f)=>{p.addEventListener("load",h),p.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return i.then(a=>{for(const c of a||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})};let qn={data:""},$n=e=>{if(typeof window=="object"){let t=(e?e.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return t.nonce=window.__nonce__,t.parentNode||(e||document.head).appendChild(t),t.firstChild}return e||qn},Dn=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,jn=/\/\*[^]*?\*\/| +/g,ut=/\n+/g,ce=(e,t)=>{let n="",r="",i="";for(let s in e){let a=e[s];s[0]=="@"?s[1]=="i"?n=s+" "+a+";":r+=s[1]=="f"?ce(a,s):s+"{"+ce(a,s[1]=="k"?"":t)+"}":typeof a=="object"?r+=ce(a,t?t.replace(/([^,])+/g,c=>s.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,l=>/&/.test(l)?l.replace(/&/g,c):c?c+" "+l:l)):s):a!=null&&(s=s[1]=="-"?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=ce.p?ce.p(s,a):s+":"+a+";")}return n+(t&&i?t+"{"+i+"}":i)+r},ae={},$t=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+$t(e[n]);return t}return e},Mn=(e,t,n,r,i)=>{let s=$t(e),a=ae[s]||(ae[s]=(l=>{let u=0,d=11;for(;u<l.length;)d=101*d+l.charCodeAt(u++)>>>0;return"go"+d})(s));if(!ae[a]){let l=s!==e?e:(u=>{let d,m,p=[{}];for(;d=Dn.exec(u.replace(jn,""));)d[4]?p.shift():d[3]?(m=d[3].replace(ut," ").trim(),p.unshift(p[0][m]=p[0][m]||{})):p[0][d[1]]=d[2].replace(ut," ").trim();return p[0]})(e);ae[a]=ce(i?{["@keyframes "+a]:l}:l,n?"":"."+a)}let c=n&&ae.g;return n&&(ae.g=ae[a]),((l,u,d,m)=>{m?u.data=u.data.replace(m,l):u.data.indexOf(l)===-1&&(u.data=d?l+u.data:u.data+l)})(ae[a],t,r,c),a},Bn=(e,t,n)=>e.reduce((r,i,s)=>{let a=t[s];if(a&&a.call){let c=a(n),l=c&&c.props&&c.props.className||/^go/.test(c)&&c;a=l?"."+l:c&&typeof c=="object"?c.props?"":ce(c,""):c===!1?"":c}return r+i+(a??"")},"");function Le(e){let t=this||{},n=e.call?e(t.p):e;return Mn(n.unshift?n.raw?Bn(n,[].slice.call(arguments,1),t.p):n.reduce((r,i)=>Object.assign(r,i&&i.call?i(t.p):i),{}):n,$n(t.target),t.g,t.o,t.k)}let Dt,Fe,We;Le.bind({g:1});let se=Le.bind({k:1});function Fn(e,t,n,r){ce.p=t,Dt=e,Fe=n,We=r}function ue(e,t){let n=this||{};return function(){let r=arguments;function i(s,a){let c=Object.assign({},s),l=c.className||i.className;n.p=Object.assign({theme:Fe&&Fe()},c),n.o=/go\d/.test(l),c.className=Le.apply(n,r)+(l?" "+l:"");let u=e;return e[0]&&(u=c.as||e,delete c.as),We&&u[0]&&We(c),Dt(u,c)}return i}}var Wn=e=>typeof e=="function",Ne=(e,t)=>Wn(e)?e(t):e,Kn=(()=>{let e=0;return()=>(++e).toString()})(),jt=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),Un=20,Xe="default",Mt=(e,t)=>{let{toastLimit:n}=e.settings;switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,n)};case 1:return{...e,toasts:e.toasts.map(a=>a.id===t.toast.id?{...a,...t.toast}:a)};case 2:let{toast:r}=t;return Mt(e,{type:e.toasts.find(a=>a.id===r.id)?1:0,toast:r});case 3:let{toastId:i}=t;return{...e,toasts:e.toasts.map(a=>a.id===i||i===void 0?{...a,dismissed:!0,visible:!1}:a)};case 4:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(a=>a.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let s=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(a=>({...a,pauseDuration:a.pauseDuration+s}))}}},Ie=[],Bt={toasts:[],pausedAt:void 0,settings:{toastLimit:Un}},te={},Ft=(e,t=Xe)=>{te[t]=Mt(te[t]||Bt,e),Ie.forEach(([n,r])=>{n===t&&r(te[t])})},Wt=e=>Object.keys(te).forEach(t=>Ft(e,t)),zn=e=>Object.keys(te).find(t=>te[t].toasts.some(n=>n.id===e)),Re=(e=Xe)=>t=>{Ft(t,e)},Qn={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Hn=(e={},t=Xe)=>{let[n,r]=_(te[t]||Bt),i=B(te[t]);b(()=>(i.current!==te[t]&&r(te[t]),Ie.push([t,r]),()=>{let a=Ie.findIndex(([c])=>c===t);a>-1&&Ie.splice(a,1)}),[t]);let s=n.toasts.map(a=>{var c,l,u;return{...e,...e[a.type],...a,removeDelay:a.removeDelay||((c=e[a.type])==null?void 0:c.removeDelay)||e?.removeDelay,duration:a.duration||((l=e[a.type])==null?void 0:l.duration)||e?.duration||Qn[a.type],style:{...e.style,...(u=e[a.type])==null?void 0:u.style,...a.style}}});return{...n,toasts:s}},Vn=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:n?.id||Kn()}),Se=e=>(t,n)=>{let r=Vn(t,e,n);return Re(r.toasterId||zn(r.id))({type:2,toast:r}),r.id},q=(e,t)=>Se("blank")(e,t);q.error=Se("error");q.success=Se("success");q.loading=Se("loading");q.custom=Se("custom");q.dismiss=(e,t)=>{let n={type:3,toastId:e};t?Re(t)(n):Wt(n)};q.dismissAll=e=>q.dismiss(void 0,e);q.remove=(e,t)=>{let n={type:4,toastId:e};t?Re(t)(n):Wt(n)};q.removeAll=e=>q.remove(void 0,e);q.promise=(e,t,n)=>{let r=q.loading(t.loading,{...n,...n?.loading});return typeof e=="function"&&(e=e()),e.then(i=>{let s=t.success?Ne(t.success,i):void 0;return s?q.success(s,{id:r,...n,...n?.success}):q.dismiss(r),i}).catch(i=>{let s=t.error?Ne(t.error,i):void 0;s?q.error(s,{id:r,...n,...n?.error}):q.dismiss(r)}),e};var Gn=1e3,Jn=(e,t="default")=>{let{toasts:n,pausedAt:r}=Hn(e,t),i=B(new Map).current,s=F((m,p=Gn)=>{if(i.has(m))return;let h=setTimeout(()=>{i.delete(m),a({type:4,toastId:m})},p);i.set(m,h)},[]);b(()=>{if(r)return;let m=Date.now(),p=n.map(h=>{if(h.duration===1/0)return;let f=(h.duration||0)+h.pauseDuration-(m-h.createdAt);if(f<0){h.visible&&q.dismiss(h.id);return}return setTimeout(()=>q.dismiss(h.id,t),f)});return()=>{p.forEach(h=>h&&clearTimeout(h))}},[n,r,t]);let a=F(Re(t),[t]),c=F(()=>{a({type:5,time:Date.now()})},[a]),l=F((m,p)=>{a({type:1,toast:{id:m,height:p}})},[a]),u=F(()=>{r&&a({type:6,time:Date.now()})},[r,a]),d=F((m,p)=>{let{reverseOrder:h=!1,gutter:f=8,defaultPosition:O}=p||{},D=n.filter(A=>(A.position||O)===(m.position||O)&&A.height),j=D.findIndex(A=>A.id===m.id),H=D.filter((A,R)=>R<j&&A.visible).length;return D.filter(A=>A.visible).slice(...h?[H+1]:[0,H]).reduce((A,R)=>A+(R.height||0)+f,0)},[n]);return b(()=>{n.forEach(m=>{if(m.dismissed)s(m.id,m.removeDelay);else{let p=i.get(m.id);p&&(clearTimeout(p),i.delete(m.id))}})},[n,s]),{toasts:n,handlers:{updateHeight:l,startPause:c,endPause:u,calculateOffset:d}}},Yn=se`
3
3
  from {
4
4
  transform: scale(0) rotate(45deg);
@@ -175,4 +175,4 @@ to {
175
175
  > * {
176
176
  pointer-events: auto;
177
177
  }
178
- `,Pe=16,Sr=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:i,toasterId:s,containerStyle:a,containerClassName:c})=>{let{toasts:l,handlers:u}=Jn(n,s);return M("div",{"data-rht-toaster":s||"",style:{position:"fixed",zIndex:9999,top:Pe,left:Pe,right:Pe,bottom:Pe,pointerEvents:"none",...a},className:c,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map(d=>{let m=d.position||t,p=u.calculateOffset(d,{reverseOrder:e,gutter:r,defaultPosition:t}),h=_r(m,p);return M(br,{id:d.id,key:d.id,onHeightUpdate:u.updateHeight,className:d.visible?wr:"",style:h},d.type==="custom"?Ne(d.message,d):i?i(d):M(gr,{toast:d,position:m}))}))},g=q;function qe(e){const t={subscribe(n){let r=null,i=!1,s=!1,a=!1;function c(){if(r===null){a=!0;return}s||(s=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=e({next(l){var u;i||(u=n.next)===null||u===void 0||u.call(n,l)},error(l){var u;i||(i=!0,(u=n.error)===null||u===void 0||u.call(n,l),c())},complete(){var l;i||(i=!0,(l=n.complete)===null||l===void 0||l.call(n),c())}}),a&&c(),{unsubscribe:c}},pipe(...n){return n.reduce(kr,t)}};return t}function kr(e,t){return t(e)}function Pr(e){const t=new AbortController;return new Promise((n,r)=>{let i=!1;function s(){i||(i=!0,a.unsubscribe())}t.signal.addEventListener("abort",()=>{r(t.signal.reason)});const a=e.subscribe({next(c){i=!0,n(c),s()},error(c){r(c)},complete(){t.abort(),s()}})})}function Er(e){return t=>{let n=0,r=null;const i=[];function s(){r||(r=t.subscribe({next(c){for(const u of i){var l;(l=u.next)===null||l===void 0||l.call(u,c)}},error(c){for(const u of i){var l;(l=u.error)===null||l===void 0||l.call(u,c)}},complete(){for(const l of i){var c;(c=l.complete)===null||c===void 0||c.call(l)}}}))}function a(){if(n===0&&r){const c=r;r=null,c.unsubscribe()}}return qe(c=>(n++,i.push(c),s(),{unsubscribe(){n--,a();const l=i.findIndex(u=>u===c);l>-1&&i.splice(l,1)}}))}}function Tr(e){let t=e;const n=[],r=a=>{t!==void 0&&a.next(t),n.push(a)},i=a=>{n.splice(n.indexOf(a),1)},s=qe(a=>(r(a),()=>{i(a)}));return s.next=a=>{if(t!==a){t=a;for(const c of n)c.next(a)}},s.get=()=>t,s}function Ir(e){return qe(t=>{function n(r=0,i=e.op){const s=e.links[r];if(!s)throw new Error("No more links to execute - did you forget to add an ending link?");return s({op:i,next(a){return n(r+1,a)}})}return n().subscribe(t)})}function be(e){"@babel/helpers - typeof";return be=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},be(e)}function xr(e,t){if(be(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(be(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Or(e){var t=xr(e,"string");return be(t)=="symbol"?t:t+""}function K(e,t,n){return(t=Or(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dt(Object(n),!0).forEach(function(r){K(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function le(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function Nr(e){return typeof e=="function"}function Cr(){return Object.create(null)}const Ar=typeof Symbol=="function"&&!!Symbol.asyncIterator;function Lr(e){return Ar&&le(e)&&Symbol.asyncIterator in e}const Rr=e=>e(),Kt=()=>{},mt=e=>{Object.freeze&&Object.freeze(e)};function Ut(e,t,n){var r;const i=t.join(".");return(r=n[i])!==null&&r!==void 0||(n[i]=new Proxy(Kt,{get(s,a){if(!(typeof a!="string"||a==="then"))return Ut(e,[...t,a],n)},apply(s,a,c){const l=t[t.length-1];if(l==="valueOf"||l==="toString"||l==="toJSON")return`tRPC.proxy(${t.slice(0,-1).join(".")})`;let u={args:c,path:t};return l==="call"?u={args:c.length>=2?[c[1]]:[],path:t.slice(0,-1)}:l==="apply"&&(u={args:c.length>=2?c[1]:[],path:t.slice(0,-1)}),mt(u.args),mt(u.path),e(u)}})),n[i]}const zt=e=>Ut(e,[],Cr()),qr=e=>new Proxy(Kt,{get(t,n){if(n!=="then")return e(n)}});function _e(e){"@babel/helpers - typeof";return _e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_e(e)}function $r(e,t){if(_e(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(_e(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Dr(e){var t=$r(e,"string");return _e(t)=="symbol"?t:t+""}function Ke(e,t,n){return(t=Dr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ee(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pt(Object(n),!0).forEach(function(r){Ke(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var jr=class extends Error{constructor(e){super(Mr(e)),Object.assign(this,e)}};function Mr(e){if("message"in e)return String(e.message)}function Br(e){if(e instanceof Error)return e;const t=typeof e;if(!(t==="undefined"||t==="function"||e===null)){if(t!=="object")return new Error(String(e));if(le(e))return new jr(e)}}var ht=class extends Error{constructor(e){var t,n,r;const i=Br(e.cause),s=(t=(n=e.message)!==null&&n!==void 0?n:i?.message)!==null&&t!==void 0?t:e.code;super(s,{cause:i}),Ke(this,"cause",void 0),Ke(this,"code",void 0),this.code=e.code,this.name="TRPCError",(r=this.cause)!==null&&r!==void 0||(this.cause=i)}};function Fr(e,t){if("error"in e){const n=t.deserialize(e.error);return{ok:!1,error:Ee(Ee({},e),{},{error:n})}}return{ok:!0,result:Ee(Ee({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var je=class extends Error{constructor(){super("Unable to transform response from server")}};function Wr(e,t){let n;try{n=Fr(e,t)}catch{throw new je}if(!n.ok&&(!le(n.error.error)||typeof n.error.error.code!="number"))throw new je;if(n.ok&&!le(n.result))throw new je;return n}function Kr(e){return typeof e=="function"}async function Ur(e,t){const{_def:n}=e;let r=n.procedures[t];for(;!r;){const i=Object.keys(n.lazy).find(s=>t===s||t.startsWith(s+"."));if(!i)return null;await n.lazy[i].load(),r=n.procedures[t]}return r}async function zr(e){const{type:t,path:n}=e,r=await Ur(e.router,n);if(!r||!Kr(r)||r._def.type!==t&&!e.allowMethodOverride)throw new ht({code:"NOT_FOUND",message:`No "${t}"-procedure on path "${n}"`});if(r._def.type!==t&&e.allowMethodOverride&&r._def.type==="subscription")throw new ht({code:"METHOD_NOT_SUPPORTED",message:"Method override is not supported for subscriptions"});return r(e)}function Qr(e){return e instanceof Ce}function Hr(e){return le(e)&&le(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function Vr(e,t){return typeof e=="string"?e:le(e)&&typeof e.message=="string"?e.message:t}var Ce=class xe extends Error{constructor(t,n){var r,i;const s=n?.cause;super(t,{cause:s}),K(this,"cause",void 0),K(this,"shape",void 0),K(this,"data",void 0),K(this,"meta",void 0),this.meta=n?.meta,this.cause=s,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(i=n.result)===null||i===void 0?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,xe.prototype)}static from(t,n={}){const r=t;return Qr(r)?(n.meta&&(r.meta=$($({},r.meta),n.meta)),r):Hr(r)?new xe(r.error.message,$($({},n),{},{result:r,cause:n.cause})):new xe(Vr(r,"Unknown error"),$($({},n),{},{cause:r}))}};function Gr(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}const ft=e=>typeof e=="function";function Jr(e){if(e)return e;if(typeof window<"u"&&ft(window.fetch))return window.fetch.bind(window);if(typeof globalThis<"u"&&ft(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function Yr(...e){const t=new AbortController,n=e.length;let r=0;const i=()=>{++r===n&&t.abort()};for(const s of e)s?.aborted?i():s?.addEventListener("abort",i,{once:!0});return t.signal}function Zr(...e){const t=new AbortController;for(const n of e)n?.aborted?t.abort():n?.addEventListener("abort",()=>t.abort(),{once:!0});return t.signal}function Xr(e){return{url:e.url.toString(),fetch:e.fetch,transformer:Gr(e.transformer),methodOverride:e.methodOverride}}function eo(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];t[n]=r}return t}const to={query:"GET",mutation:"POST",subscription:"PATCH"};function Qt(e){return"input"in e?e.transformer.input.serialize(e.input):eo(e.inputs.map(t=>e.transformer.input.serialize(t)))}const Ht=e=>{const t=e.url.split("?");let n=t[0].replace(/\/$/,"")+"/"+e.path;const r=[];if(t[1]&&r.push(t[1]),"inputs"in e&&r.push("batch=1"),e.type==="query"||e.type==="subscription"){const i=Qt(e);i!==void 0&&e.methodOverride!=="POST"&&r.push(`input=${encodeURIComponent(JSON.stringify(i))}`)}return r.length&&(n+="?"+r.join("&")),n},no=e=>{if(e.type==="query"&&e.methodOverride!=="POST")return;const t=Qt(e);return t!==void 0?JSON.stringify(t):void 0},ro=e=>ao($($({},e),{},{contentTypeHeader:"application/json",getUrl:Ht,getBody:no}));var oo=class extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}};const io=e=>{var t;if(e?.aborted)throw(t=e.throwIfAborted)===null||t===void 0||t.call(e),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new oo};async function so(e){var t,n;io(e.signal);const r=e.getUrl(e),i=e.getBody(e),s=(t=e.methodOverride)!==null&&t!==void 0?t:to[e.type],a=await(async()=>{const l=await e.headers();return Symbol.iterator in l?Object.fromEntries(l):l})(),c=$($($({},e.contentTypeHeader&&s!=="GET"?{"content-type":e.contentTypeHeader}:{}),e.trpcAcceptHeader?{[(n=e.trpcAcceptHeaderKey)!==null&&n!==void 0?n:"trpc-accept"]:e.trpcAcceptHeader}:void 0),a);return Jr(e.fetch)(r,{method:s,signal:e.signal,body:i,headers:c})}async function ao(e){const t={},n=await so(e);t.response=n;const r=await n.json();return t.responseJSON=r,{json:r,meta:t}}const yt=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function vt(e){let t=null,n=null;const r=()=>{clearTimeout(n),n=null,t=null};function i(c){const l=[[]];let u=0;for(;;){const p=c[u];if(!p)break;const h=l[l.length-1];if(p.aborted){var d;(d=p.reject)===null||d===void 0||d.call(p,new Error("Aborted")),u++;continue}if(e.validate(h.concat(p).map(f=>f.key))){h.push(p),u++;continue}if(h.length===0){var m;(m=p.reject)===null||m===void 0||m.call(p,new Error("Input is too big for a single dispatch")),u++;continue}l.push([])}return l}function s(){const c=i(t);r();for(const l of c){if(!l.length)continue;const u={items:l};for(const d of l)d.batch=u;e.fetch(u.items.map(d=>d.key)).then(async d=>{await Promise.all(d.map(async(p,h)=>{const f=u.items[h];try{var O;const j=await Promise.resolve(p);(O=f.resolve)===null||O===void 0||O.call(f,j)}catch(j){var D;(D=f.reject)===null||D===void 0||D.call(f,j)}f.batch=null,f.reject=null,f.resolve=null}));for(const p of u.items){var m;(m=p.reject)===null||m===void 0||m.call(p,new Error("Missing result")),p.batch=null}}).catch(d=>{for(const p of u.items){var m;(m=p.reject)===null||m===void 0||m.call(p,d),p.batch=null}})}}function a(c){var l;const u={aborted:!1,key:c,batch:null,resolve:yt,reject:yt},d=new Promise((m,p)=>{var h;u.reject=p,u.resolve=m,(h=t)!==null&&h!==void 0||(t=[]),t.push(u)});return(l=n)!==null&&l!==void 0||(n=setTimeout(s)),d}return{load:a}}function co(e){var t,n;const r=Xr(e),i=(t=e.maxURLLength)!==null&&t!==void 0?t:1/0,s=(n=e.maxItems)!==null&&n!==void 0?n:1/0;return()=>{const a=l=>({validate(u){if(i===1/0&&s===1/0)return!0;if(u.length>s)return!1;const d=u.map(p=>p.path).join(","),m=u.map(p=>p.input);return Ht($($({},r),{},{type:l,path:d,inputs:m,signal:null})).length<=i},async fetch(u){const d=u.map(f=>f.path).join(","),m=u.map(f=>f.input),p=Yr(...u.map(f=>f.signal)),h=await ro($($({},r),{},{path:d,inputs:m,type:l,headers(){return e.headers?typeof e.headers=="function"?e.headers({opList:u}):e.headers:{}},signal:p}));return(Array.isArray(h.json)?h.json:u.map(()=>h.json)).map(f=>({meta:h.meta,json:f}))}}),c={query:vt(a("query")),mutation:vt(a("mutation"))};return({op:l})=>qe(u=>{if(l.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const d=new AbortController,m=c[l.type].load($($({},l),{},{signal:Zr(l.signal,d.signal)}));let p=!1,h;return m.then(f=>{p=!0,h=f;const O=Wr(f.json,r.transformer.output);if(!O.ok){u.error(Ce.from(O.error,{meta:f.meta}));return}u.next({context:f.meta,result:O.result}),u.complete()}).catch(f=>{p=!0,u.error(Ce.from(f,{meta:h?.meta}))}),()=>{p||d.abort()}})}}const Vt=(e,...t)=>typeof e=="function"?e(...t):e;function lo(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function uo(e){const t=await Vt(e.url);return e.connectionParams?t+`${t.includes("?")?"&":"?"}connectionParams=1`:t}async function mo(e,t){const n={method:"connectionParams",data:await Vt(e)};return t.encode(n)}function po(e){const{promise:t,resolve:n,reject:r}=lo();return e.addEventListener("open",()=>{e.removeEventListener("error",r),n()}),e.addEventListener("error",r),t}function ho(e,{intervalMs:t,pongTimeoutMs:n}){let r,i;function s(){r=setTimeout(()=>{e.send("PING"),i=setTimeout(()=>{e.close()},n)},t)}function a(){clearTimeout(r),s()}function c(){clearTimeout(i),a()}e.addEventListener("open",s),e.addEventListener("message",({data:l})=>{clearTimeout(r),s(),l==="PONG"&&c()}),e.addEventListener("close",()=>{clearTimeout(r),clearTimeout(i)})}var fo=class Ue{constructor(t){var n;if(K(this,"id",++Ue.connectCount),K(this,"WebSocketPonyfill",void 0),K(this,"urlOptions",void 0),K(this,"keepAliveOpts",void 0),K(this,"encoder",void 0),K(this,"wsObservable",Tr(null)),K(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){if(this.openPromise)return this.openPromise;this.id=++Ue.connectCount;const t=uo(this.urlOptions).then(n=>new this.WebSocketPonyfill(n));this.openPromise=t.then(async n=>{this.ws=n,n.binaryType="arraybuffer",n.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),this.keepAliveOpts.enabled&&ho(n,this.keepAliveOpts),n.addEventListener("close",()=>{this.ws===n&&(this.ws=null)}),await po(n),this.urlOptions.connectionParams&&n.send(await mo(this.urlOptions.connectionParams,this.encoder))});try{await this.openPromise}finally{this.openPromise=null}}async close(){try{await this.openPromise}finally{var t;(t=this.ws)===null||t===void 0||t.close()}}};K(fo,"connectCount",0);var Gt=class{constructor(e){K(this,"links",void 0),K(this,"runtime",void 0),K(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return Ir({links:this.links,op:$($({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(Er())}async requestAsPromise(e){try{const t=this.$request(e);return(await Pr(t)).result.data}catch(t){throw Ce.from(t)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(r){switch(r.result.type){case"state":var i;(i=n.onConnectionStateChange)===null||i===void 0||i.call(n,r.result);break;case"started":var s;(s=n.onStarted)===null||s===void 0||s.call(n,{context:r.context});break;case"stopped":var a;(a=n.onStopped)===null||a===void 0||a.call(n);break;case"data":case void 0:var c;(c=n.onData)===null||c===void 0||c.call(n,r.result.data)}},error(r){var i;(i=n.onError)===null||i===void 0||i.call(n,r)},complete(){var r;(r=n.onComplete)===null||r===void 0||r.call(n)}})}};const Jt=Symbol.for("trpc_untypedClient"),yo={query:"query",mutate:"mutation",subscribe:"subscription"},vo=e=>yo[e];function go(e){const t=zt(({path:n,args:r})=>{const i=[...n],s=vo(i.pop()),a=i.join(".");return e[s](a,...r)});return qr(n=>n===Jt?e:t[n])}function bo(e){return go(new Gt(e))}function _o(e){return e[Jt]}function we(e){"@babel/helpers - typeof";return we=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},we(e)}function wo(e,t){if(we(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(we(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function So(e){var t=wo(e,"string");return we(t)=="symbol"?t:t+""}function ko(e,t,n){return(t=So(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gt(Object(n),!0).forEach(function(r){ko(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Po(e){var t,n,r,i=2;for(typeof Symbol<"u"&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&(t=e[n])!=null)return t.call(e);if(r&&(t=e[r])!=null)return new Oe(t.call(e));n="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function Oe(e){function t(n){if(Object(n)!==n)return Promise.reject(new TypeError(n+" is not an object."));var r=n.done;return Promise.resolve(n.value).then(function(i){return{value:i,done:r}})}return Oe=function(r){this.s=r,this.n=r.next},Oe.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(r){var i=this.s.return;return i===void 0?Promise.resolve({value:r,done:!0}):t(i.apply(this.s,arguments))},throw:function(r){var i=this.s.return;return i===void 0?Promise.reject(r):t(i.apply(this.s,arguments))}},new Oe(e)}function Eo(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function To(e,t){if(e==null)return{};var n,r,i=Eo(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const Io=["cursor","direction"];function $e(e){return{path:e.path.join(".")}}function xo(e){return e.length>=3}function Oo(e){return xo(e)?{type:"prefixed",prefix:e[0],path:e[1],args:e[2]}:{type:"unprefixed",prefix:void 0,path:e[0],args:e[1]}}function et(e,t,n){var r;const i=Oo(e);let s=(r=i.args)===null||r===void 0?void 0:r.input;if(n){var a,c;s=k(k(k({},(a=(c=i.args)===null||c===void 0?void 0:c.input)!==null&&a!==void 0?a:{}),n.pageParam!==void 0?{cursor:n.pageParam}:{}),{},{direction:n.direction})}return[i.path.join("."),s,t?.trpc]}async function No(e,t,n){const r=t.getQueryCache().build(t,{queryKey:n});r.setState({data:[],status:"success"});const i=[];var s=!1,a=!1,c;try{for(var l=Po(e),u;s=!(u=await l.next()).done;s=!1){const d=u.value;i.push(d),r.setState({data:[...i]})}}catch(d){a=!0,c=d}finally{try{s&&l.return!=null&&await l.return()}finally{if(a)throw c}}return i}function re(e){const t=Rr(()=>{const{input:n,type:r}=e,i=e.path.flatMap(s=>s.split("."));if(!n&&r==="any")return i.length?[i]:[];if(r==="infinite"&&le(n)&&("direction"in n||"cursor"in n)){const{cursor:s,direction:a}=n;return[i,{input:To(n,Io),type:"infinite"}]}return[i,k(k({},typeof n<"u"&&n!==de&&{input:n}),r&&r!=="any"&&{type:r})]});return e.prefix&&t.unshift([e.prefix]),t}function Yt(e){const t=[e.path.flatMap(n=>n.split("."))];return e.prefix&&t.unshift([e.prefix]),t}function tt(e){return Nr(e)?e():e}function Co(e){var t;const{input:n,query:r,path:i,queryKey:s,opts:a}=e,c=n===de,l=async u=>{var d;const m=k(k({},a),{},{trpc:k(k({},a?.trpc),!(a==null||(d=a.trpc)===null||d===void 0)&&d.abortOnUnmount?{signal:u.signal}:{signal:null})});return await r(...et(s,m,{direction:u.direction,pageParam:u.pageParam}))};return Object.assign(On(k(k({},a??{}),{},{queryKey:s,queryFn:c?de:l,initialPageParam:(t=a?.initialCursor)!==null&&t!==void 0?t:n?.cursor})),{trpc:$e({path:i})})}function Ao(e){var t,n;const{mutate:r,path:i,prefix:s,opts:a,overrides:c}=e,l=tt(e.queryClient),u=Yt({path:i,prefix:(t=a?.keyPrefix)!==null&&t!==void 0?t:s}),d=l.defaultMutationOptions(l.getMutationDefaults(u)),m=(n=c?.onSuccess)!==null&&n!==void 0?n:(h=>h.originalFn()),p=async h=>await r(...et([...u,{input:h}],a));return k(k({},a),{},{mutationKey:u,mutationFn:p,onSuccess(...h){var f,O;return m({originalFn:()=>{var j,H,A;return(j=a==null||(H=a.onSuccess)===null||H===void 0?void 0:H.call(a,...h))!==null&&j!==void 0?j:d==null||(A=d.onSuccess)===null||A===void 0?void 0:A.call(d,...h)},queryClient:l,meta:(f=(O=a?.meta)!==null&&O!==void 0?O:d?.meta)!==null&&f!==void 0?f:{}})},trpc:$e({path:i})})}function Lo(e){const{input:t,query:n,path:r,queryKey:i,opts:s}=e,a=tt(e.queryClient),c=t===de,l=async u=>{var d;const m=k(k({},s),{},{trpc:k(k({},s?.trpc),!(s==null||(d=s.trpc)===null||d===void 0)&&d.abortOnUnmount?{signal:u.signal}:{signal:null})}),p=u.queryKey,h=await n(...et(p,m));return Lr(h)?No(h,a,p):h};return Object.assign(Nn(k(k({},s),{},{queryKey:i,queryFn:c?de:l})),{trpc:$e({path:r})})}const Ro=e=>{const{subscribe:t,path:n,queryKey:r,input:i,opts:s={}}=e,a="enabled"in s?!!s.enabled:i!==de,c=l=>t(n.join("."),i===de?void 0:i,l);return k(k({},s),{},{enabled:a,subscribe:c,queryKey:r,trpc:$e({path:n})})};function qo(e){const t=e.keyPrefix,n=r=>(i,s,a)=>"router"in e?Promise.resolve(tt(e.ctx)).then(c=>zr({router:e.router,path:i,getRawInput:async()=>s,ctx:c,type:r,signal:void 0,batchIndex:0})):(e.client instanceof Gt?e.client:_o(e.client))[r](i,s,a);return zt(({args:r,path:i})=>{const s=[...i],a=s.pop(),[c,l]=r;return{"~types":void 0,pathKey:()=>re({path:s,type:"any",prefix:t}),pathFilter:()=>k(k({},c),{},{queryKey:re({path:s,type:"any",prefix:t})}),queryOptions:()=>Lo({input:c,opts:l,path:s,queryClient:e.queryClient,queryKey:re({path:s,input:c,type:"query",prefix:t}),query:n("query")}),queryKey:()=>re({path:s,input:c,type:"query",prefix:t}),queryFilter:()=>k(k({},l),{},{queryKey:re({path:s,input:c,type:"query",prefix:t})}),infiniteQueryOptions:()=>Co({input:c,opts:l,path:s,queryKey:re({path:s,input:c,type:"infinite",prefix:t}),query:n("query")}),infiniteQueryKey:()=>re({path:s,input:c,type:"infinite",prefix:t}),infiniteQueryFilter:()=>k(k({},l),{},{queryKey:re({path:s,input:c,type:"infinite",prefix:t})}),mutationOptions:()=>{var u;return Ao({opts:c,path:s,prefix:t,queryClient:e.queryClient,mutate:n("mutation"),overrides:(u=e.overrides)===null||u===void 0?void 0:u.mutations})},mutationKey:()=>Yt({path:s,prefix:t}),subscriptionOptions:()=>Ro({opts:l,path:s,input:c,queryKey:re({path:s,input:c,type:"any",prefix:t}),subscribe:n("subscription")})}[a]()})}function $o(){const e=oe(null),t=oe(null),n=s=>{const a=pe(()=>qo({client:s.trpcClient,queryClient:s.queryClient,keyPrefix:s.keyPrefix}),[s.trpcClient,s.queryClient,s.keyPrefix]);return M(e.Provider,{value:s.trpcClient},M(t.Provider,{value:a},s.children))};n.displayName="TRPCProvider";function r(){const s=ie(t);if(!s)throw new Error("useTRPC() can only be used inside of a <TRPCProvider>");return s}function i(){const s=ie(e);if(!s)throw new Error("useTRPCClient() can only be used inside of a <TRPCProvider>");return s}return{TRPCProvider:n,useTRPC:r,useTRPCClient:i}}const ze={lan:new Set,animepahe:new Set,jasmr:new Set};function Qe(e){for(const t of[...ze[e]])try{t()}catch(n){console.error(`auth-bus listener failed (${e}):`,n)}}function Zt(e,t){return ze[e].add(t),()=>{ze[e].delete(t)}}const Do=e=>new Promise(t=>setTimeout(t,e));async function jo(e,t){const n={"Content-Type":"application/json"},r=typeof e=="string"?e:e.toString();if(r.startsWith("/")||typeof window<"u"&&r.startsWith(window.location.origin)){const a=localStorage.getItem("animepahe_ua"),c=localStorage.getItem("animepahe_cookie"),l=localStorage.getItem("jasmr_ua"),u=localStorage.getItem("jasmr_cookie");a&&(n["x-animepahe-ua"]=a),c&&(n["x-animepahe-cookie"]=c),l&&(n["x-jasmr-ua"]=l),u&&(n["x-jasmr-cookie"]=u)}let s=await fetch(e,{...t,headers:{...n,...t?.headers}});for(let a=0;s.status===503&&a<8;a++)await Do(Math.min(500*2**a,4e3)),s=await fetch(e,{...t,headers:{...n,...t?.headers}});if(s.status===401)try{(await s.clone().json())?.error==="LAN_AUTH_REQUIRED"&&Qe("lan")}catch{}return await Mo(s),s}async function Mo(e){try{if(!e.headers.get("content-type")?.includes("json"))return;const t=await e.clone().json(),n=Array.isArray(t)?t:[t];for(const r of n){const i=r?.error;if(!i||typeof i!="object")continue;const s=i.data?.cause;(i.message==="AUTH_REQUIRED"||s?.code==="AUTH_REQUIRED")&&(s?.provider==="animepahe"||s?.provider==="jasmr")&&Qe(s.provider),(i.message==="LAN_AUTH_REQUIRED"||s?.code==="LAN_AUTH_REQUIRED")&&Qe("lan")}}catch{}}const{TRPCProvider:Bo,useTRPC:P}=$o(),U=bo({links:[co({url:"/api/trpc",fetch:jo})]}),ge=new Map,Fo=500,Wo=(e,t,n)=>{if(!e||e.trim()==="")return"/placeholder.svg";if(e.includes("/api/image-proxy")){let a=e;if(t&&!a.includes("w=")){const c=a.includes("?")?"&":"?";a+=`${c}w=${t}`}if(n&&!a.includes("h=")){const c=a.includes("?")?"&":"?";a+=`${c}h=${n}`}return a}let r=e;r.includes("aln.youtube-anime.com")&&(r=r.replace(/https?:\/\/allanime\.day\/aln\.youtube-anime\.com/,"https://aln.youtube-anime.com"),r.includes("/images/mcovers")&&(r=r.replace("/images/mcovers","/mcovers")),r.includes("/images/images2")&&(r=r.replace("/images/images2","/images2"))),r.includes("allanime.day/s4.anilist.co")&&(r=r.replace(/https?:\/\/allanime\.day\/s4\.anilist\.co/,"https://s4.anilist.co")),r.includes("wp.youtube-anime.com/s4.anilist.co")&&(r=r.replace(/https?:\/\/wp\.youtube-anime\.com\/s4\.anilist\.co/,"https://s4.anilist.co"));const i=`${r}-${t}-${n}`;if(ge.has(i))return ge.get(i);let s;if(r.startsWith("https://s4.anilist.co"))s=r,t&&(s+=`${s.includes("?")?"&":"?"}w=${t}`),n&&(s+=`${s.includes("?")?"&":"?"}h=${n}`);else if(r.includes("animepahe")){s=`/api/image-proxy?url=${encodeURIComponent(r)}`;const a=localStorage.getItem("animepahe_cookie"),c=localStorage.getItem("animepahe_ua");a&&(s+=`&cookie=${encodeURIComponent(a)}`),c&&(s+=`&ua=${encodeURIComponent(c)}`)}else if(r.startsWith("http"))s=`/api/image-proxy?url=${encodeURIComponent(r)}`,t&&(s+=`&w=${t}`),n?s+=`&h=${n}`:t||(s+="&w=300");else{const c=`${r.startsWith("mcovers")||r.startsWith("images2")?"https://aln.youtube-anime.com":"https://aln.youtube-anime.com/images"}/${r}`;s=`/api/image-proxy?url=${encodeURIComponent(c)}`,t&&(s+=`&w=${t}`),n?s+=`&h=${n}`:t||(s+="&w=300")}return ge.size>Fo&&ge.clear(),ge.set(i,s),s},Dc=e=>{if(isNaN(e)||e<=0)return"00:00";const t=new Date(e*1e3).toISOString().slice(11,19);return parseInt(t.slice(0,2),10)>0?t:t.slice(3)};function jc(e){return e?e.replace(/<[^>]*>?/gm,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").trim():""}function Mc(e){return e==null?e:e>10?Number((e/10).toFixed(1)):e}const Xt=oe(void 0),Ko=()=>{const e=ie(Xt);if(e===void 0)throw new Error("useTitlePreference must be used within a TitlePreferenceProvider");return e},Bc=()=>{const e=P();return Q({...e.data.spotlight.queryOptions(),staleTime:1e3*60*5,retry:1})},Fc=(e="TRENDING_DESC",t=10)=>Ze({queryKey:["trendingList",e,t],queryFn:({pageParam:n=1})=>U.data.popularList.query({sort:e,page:n,size:t}),initialPageParam:1,getNextPageParam:(n,r)=>n.length>=t?r.length+1:void 0}),Wc=(e="TV",t=12)=>Ze({queryKey:["latestReleases",e,t],queryFn:({pageParam:n=1})=>U.data.latestReleases.query({format:e,page:n,size:t}),initialPageParam:1,getNextPageParam:(n,r)=>n.length>=t?r.length+1:void 0}),Kc=(e,t="TV",n=!0)=>{const r=P();return Q({...r.data.seasonal.queryOptions({page:e,format:t}),enabled:n,staleTime:1e3*60*5})},Uo=["query","sortBy","type","status","season","year","country","genres","excludeGenres","excludeTags","minScore","minEpisodes","adult"],Uc=(e,t,n=14)=>{const r=P(),i=new URLSearchParams(e),s={page:t,limit:n};for(const a of Uo){const c=i.get(a);c!==null&&(s[a]=c)}return Q({...r.data.search.queryOptions(s),enabled:e!=null})},zc=()=>{const e=P();return Q(e.queue.list.queryOptions())},zo=()=>{const e=P(),t=z();return Y(e.queue.add.mutationOptions({onSuccess:n=>{n.queued?g.success("Added to queue"):g.success("Removed from queue"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]})},onError:n=>{g.error(`Failed to update queue: ${n.message}`)}}))},Qc=()=>{const e=P(),t=z();return Y(e.queue.remove.mutationOptions({onSuccess:()=>{g.success("Removed from queue"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},Hc=(e,t=!0)=>Q({queryKey:["queue-remaining",e],queryFn:()=>U.watchlist.queueRemaining.query({showId:e}),enabled:!!e&&t,staleTime:1e3*60}),Vc=()=>{const e=P(),t=z();return Y(e.queue.addBatch.mutationOptions({onSuccess:(n,r)=>{const i=n.added??r.episodeNumbers.length;g.success(`${i} ${i===1?"episode":"episodes"} added to queue`),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]})},onError:n=>{g.error(`Failed to update queue: ${n.message}`)}}))},Gc=()=>{const e=P(),t=z();return Y(e.queue.removeMany.mutationOptions({onSuccess:()=>{g.success("Removed from queue"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},Jc=()=>{const e=P(),t=z();return Y(e.queue.clear.mutationOptions({onSuccess:()=>{g.success("Queue cleared"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to clear queue: ${n.message}`)}}))},Yc=()=>{const e=P(),t=z(),n=e.queue.list.queryOptions().queryKey;return Y(e.queue.reorder.mutationOptions({onMutate:async r=>{await t.cancelQueries({queryKey:n});const i=t.getQueryData(n);return t.setQueryData(n,s=>{if(!s)return s;const a=new Map(s.map(c=>[c.id,c]));return r.map((c,l)=>{const u=a.get(c.id??-1);return u?{...u,queue_order:l}:void 0}).filter(c=>!!c)}),{previousQueue:i}},onError:(r,i,s)=>{s?.previousQueue&&t.setQueryData(n,s.previousQueue)},onSettled:()=>{t.invalidateQueries(e.queue.pathFilter())}}))},Qo=["status","showMature","query","type","season","year","genres","excludeGenres","sortBy","titlePreference"];function nt(e,t,n){const r=new URLSearchParams(e),i={page:t,limit:n};for(const s of Qo){const a=r.get(s);a!==null&&(i[s]=a)}return i}const Zc=(e,t="",n,r=14)=>Q({queryKey:["watchlist",e,t,n,r],queryFn:async()=>{const i=new URLSearchParams(t);return i.set("status",e),await U.watchlist.list.query(nt(i.toString(),n,r))}}),Xc=(e="")=>Ze({queryKey:["allContinueWatching",e],queryFn:async({pageParam:t=1})=>await U.watchlist.continueWatchingAll.query(nt(e,t,14)),initialPageParam:1,getNextPageParam:t=>{if(!(t.data.length===0||t.page*t.limit>=t.total))return t.page+1},select:t=>({...t,pages:t.pages.flatMap(n=>n.data)})}),el=(e="",t,n=14)=>Q({queryKey:["allContinueWatching",e,t,n],queryFn:async()=>await U.watchlist.continueWatchingAll.query(nt(e,t,n))}),tl=()=>{const e=P(),t=z();return Y(e.watchlist.remove.mutationOptions({onSuccess:()=>{g.success("Removed from watchlist"),t.invalidateQueries(e.watchlist.pathFilter()),t.invalidateQueries({queryKey:["watchlist"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},nl=()=>{const e=P(),t=z();return Y(e.watchlist.batchStatus.mutationOptions({onSuccess:n=>{g.success(`Status updated for ${n.updated??0} items`),t.invalidateQueries(e.watchlist.pathFilter()),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to update statuses: ${n.message}`)}}))},rl=()=>{const e=P(),t=z();return Y(e.watchlist.removeMany.mutationOptions({onSuccess:n=>{const r=n.removed??0;g.success(`Removed ${r} ${r===1?"item":"items"} from watchlist`),t.invalidateQueries(e.watchlist.pathFilter()),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},ol=()=>{const e=P(),t=z();return Y(e.continueWatching.removeMany.mutationOptions({onSuccess:n=>{const r=n.removed??0;g.success(`Removed ${r} ${r===1?"item":"items"} from continue watching`),t.invalidateQueries(e.continueWatching.pathFilter()),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},en=(e=!0)=>{const t=P();return Q({...t.notifications.list.queryOptions(),enabled:e,refetchInterval:3e4})},tn=(e=!0)=>{const t=P();return Q({...t.data.systemNotifications.queryOptions(),enabled:e,refetchInterval:3e4})},nn=(e=!0)=>{const t=P();return Q({...t.discovery.status.queryOptions(),enabled:e,refetchInterval:n=>n.state.data?.running?2e3:!1})},Ho=()=>{const e=P(),t=z(),n=e.discovery.status.queryOptions().queryKey;return Y(e.discovery.refresh.mutationOptions({onSuccess:r=>{t.setQueryData(n,{running:r.running,state:r.state,total:r.total,done:r.done,lastRunAt:r.lastRunAt}),t.invalidateQueries(e.notifications.pathFilter()),t.invalidateQueries({queryKey:["notifications"]})},onError:()=>{t.invalidateQueries({queryKey:n})}}))},Vo=()=>{const e=P(),t=z();return Y(e.notifications.dismiss.mutationOptions({onSuccess:()=>{t.invalidateQueries(e.notifications.pathFilter())}}))},Go=()=>{const e=P(),t=z();return Y(e.notifications.clearAll.mutationOptions({onSuccess:()=>{t.invalidateQueries(e.notifications.pathFilter())}}))},il=()=>{const e=P();return Q({...e.continueWatching.thisWeek.queryOptions(),staleTime:1e3*60*5})},sl=()=>{const e=P();return Q({...e.data.genresAndTags.queryOptions(),staleTime:1e3*60*60})},al=()=>Q({queryKey:["genreCards"],queryFn:()=>U.insights.genreCards.query()}),Jo="_container_z68uz_1",Yo="_bellBtn_z68uz_7",Zo="_badge_z68uz_56",Xo="_dropdown_z68uz_96",ei="_dropdownHeader_z68uz_127",ti="_clearAllBtn_z68uz_141",ni="_discoveryStatusRow_z68uz_156",ri="_statusDot_z68uz_167",oi="_statusDotRunning_z68uz_174",ii="_statusDotOk_z68uz_179",si="_statusDotInfo_z68uz_183",ai="_statusDotError_z68uz_187",ci="_statusDotIdle_z68uz_191",li="_list_z68uz_205",ui="_item_z68uz_219",di="_thumbnail_z68uz_234",mi="_itemInfo_z68uz_243",pi="_itemTitle_z68uz_248",hi="_itemMeta_z68uz_259",fi="_systemItemMeta_z68uz_269",yi="_removeItem_z68uz_286",vi="_queueItem_z68uz_316",gi="_emptyState_z68uz_320",y={container:Jo,bellBtn:Yo,badge:Zo,dropdown:Xo,dropdownHeader:ei,clearAllBtn:ti,discoveryStatusRow:ni,statusDot:ri,statusDotRunning:oi,statusDotOk:ii,statusDotInfo:si,statusDotError:ai,statusDotIdle:ci,list:li,item:ui,thumbnail:di,itemInfo:mi,itemTitle:pi,itemMeta:hi,systemItemMeta:fi,removeItem:yi,queueItem:vi,emptyState:gi},bi=({notification:e})=>{const t=Vo(),n=zo(),[r,i]=Je.useState(!1),s=d=>{d.preventDefault(),d.stopPropagation(),t.mutate({showId:e.showId,episodeNumber:e.episodeNumber})},a=()=>{t.mutate({showId:e.showId,episodeNumber:e.episodeNumber})},c=d=>{d.preventDefault(),d.stopPropagation(),i(!0),n.mutate({showId:e.showId,episodeNumber:e.episodeNumber,showName:e.name,showThumbnail:e.thumbnail,nativeName:e.nativeName,englishName:e.englishName}),t.mutate({showId:e.showId,episodeNumber:e.episodeNumber}),window.setTimeout(()=>i(!1),1e3)},{titlePreference:l}=Ko(),u=l==="nativeName"?e.nativeName||e.name:l==="englishName"&&e.englishName||e.name;return o(J,{to:`/watch/${e.showId}/${e.episodeNumber}`,className:y.item,onClick:a,children:[o("img",{src:Wo(e.thumbnail,48,64),alt:e.name,className:y.thumbnail,loading:"lazy",decoding:"async"}),o("div",{className:y.itemInfo,children:[o("span",{className:y.itemTitle,children:u}),o("span",{className:y.itemMeta,children:["New Episode ",e.episodeNumber]})]}),o("button",{className:`${y.removeItem} ${y.queueItem}`,onClick:c,"aria-label":"Add notification to queue",children:r?o(v,{name:"check"}):o(v,{name:"plus"})}),o("button",{className:y.removeItem,onClick:s,"aria-label":"Remove notification",children:o(v,{name:"times"})})]})};function Me({width:e="100%",height:t="1em",variant:n="rectangular",className:r="",style:i}){return o("div",{className:`skeleton skeleton-${n} ${r}`,style:{width:e,height:t,...i}})}const _i=({count:e=3})=>o(G,{children:Array.from({length:e}).map((t,n)=>o("div",{className:y.item,style:{borderBottom:"1px solid var(--border-primary)",pointerEvents:"none"},children:[o("div",{className:y.thumbnail,style:{overflow:"hidden"},children:o(Me,{width:"100%",height:"100%",variant:"rectangular"})}),o("div",{className:y.itemInfo,children:[o(Me,{width:"80%",height:"1rem",variant:"text",style:{marginBottom:"4px"}}),o(Me,{width:"40%",height:"0.7rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},n))}),wi=()=>{const{data:e=[],isLoading:t}=en(),{data:n=[]}=tn(),{data:r}=nn(),i=Go(),s=z(),[a,c]=_(null);b(()=>{s.invalidateQueries({queryKey:["notifications"]})},[s]);const l=()=>{i.mutate(void 0)},u=n.find(d=>d.id===a)??null;return o("div",{className:y.dropdown,children:[o("div",{className:y.dropdownHeader,children:[o("h4",{children:"Notifications"}),e.length>0&&o("button",{className:y.clearAllBtn,onClick:l,children:"Clear All"})]}),o("div",{className:y.discoveryStatusRow,children:r?.running?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotRunning}`,"aria-hidden":"true"}),o("span",{children:r.total>0?`Checking ${Math.min(r.done,r.total)}/${r.total} shows...`:"Checking for new episodes..."})]}):r?.state==="complete"?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotOk}`,"aria-hidden":"true"}),o("span",{children:["Discovery complete — checked ",r.total," ",r.total===1?"show":"shows"]})]}):r?.state==="empty"?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotInfo}`,"aria-hidden":"true"}),o("span",{children:"No shows set to Watching — nothing to check"})]}):r?.state==="error"?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotError}`,"aria-hidden":"true"}),o("span",{children:"Last check failed — will retry automatically"})]}):o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotIdle}`,"aria-hidden":"true"}),o("span",{children:r?.lastRunAt?`Last checked ${Math.max(1,Math.round((Date.now()-r.lastRunAt)/1e3))}s ago`:"Auto-checks every few minutes"})]})}),o("div",{className:y.list,children:t&&n.length===0?o(_i,{count:4}):o(G,{children:[n.map(d=>o("div",{className:y.item,children:[o("div",{className:y.thumbnail,style:{background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:0,boxShadow:"none"},children:o(v,{name:"info-circle",size:32,color:"#6c9fff"})}),o("div",{className:y.itemInfo,children:[o("span",{className:y.itemTitle,children:d.title}),o("button",{type:"button",className:y.systemItemMeta,onClick:()=>c(d.id),title:"View full status",children:d.message.length>40?d.message.slice(0,40)+"…":d.message})]}),o("button",{className:y.removeItem,disabled:!0,style:{opacity:.3,cursor:"not-allowed"},"aria-hidden":"true",children:o(v,{name:"plus"})}),o("button",{className:y.removeItem,disabled:!0,style:{opacity:.3,cursor:"not-allowed"},"aria-hidden":"true",children:o(v,{name:"times"})})]},d.id)),n.length>0&&e.length>0&&o("div",{className:y.notificationDivider}),e.length>0?e.map(d=>o(bi,{notification:d},d.id)):!t&&n.length===0&&o("div",{className:y.emptyState,children:"No new notifications"})]})}),u&&Rt(o("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem",backdropFilter:"blur(3px)"},onClick:()=>c(null),children:o("div",{style:{backgroundColor:"var(--bg-secondary)",padding:"1.5rem",borderRadius:"var(--radius-lg)",maxWidth:"420px",width:"100%",boxShadow:"var(--shadow-xl)",border:"1px solid var(--border-primary)"},onClick:d=>d.stopPropagation(),children:[o("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem"},children:[o(v,{name:"info-circle",color:"#6c9fff"}),o("span",{style:{color:"#fff",fontWeight:600,fontSize:"1rem"},children:u.title})]}),o("p",{style:{color:"var(--text-secondary)",marginBottom:"1.5rem",lineHeight:1.5},children:u.message}),o("div",{style:{display:"flex",justifyContent:"flex-end"},children:o("button",{type:"button",onClick:()=>c(null),style:{background:"var(--primary-color)",color:"#fff",border:"none",padding:"0.5rem 1rem",borderRadius:"var(--radius-md)",cursor:"pointer",fontWeight:600},children:"OK"})})]})}),document.body)]})},Si=()=>{const[e,t]=_(!1),n=B(null),r=z(),i=P(),s=Ho(),{data:a=[]}=en(),{data:c=[]}=tn(),{data:l}=nn(),u=a.length+c.length,d=u>5?"5+":u,m=B(!1);b(()=>{const h=f=>{n.current&&!n.current.contains(f.target)&&t(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),b(()=>{const h=!!l?.running;m.current&&!h&&(r.invalidateQueries(i.notifications.pathFilter()),r.invalidateQueries(i.discovery.pathFilter())),m.current=h},[l?.running,r,i]);const p=()=>{const h=!e;t(h),h&&s.mutate()};return o("div",{className:y.container,ref:n,children:[o("button",{className:y.bellBtn,onClick:p,"aria-label":"Notifications",children:[o(v,{name:"bell"}),u>0&&o("span",{className:y.badge,children:d})]}),e&&o(wi,{})]})},rn=oe(void 0),on=()=>{const e=ie(rn);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},cl=[{id:"iris",label:"Taro (default)",blurb:"Deep purple",swatch:"#7d6df0"},{id:"mochi",label:"Mochi",blurb:"Monochrome pearl",swatch:"#f0f0f0"},{id:"sakura",label:"Sakura",blurb:"Soft pink",swatch:"#e0b0e0"}],bt={iris:"/logo.png",mochi:"/logo-mochi.png",sakura:"/logo-sakura.png"},sn=({className:e})=>{const{theme:t}=on(),n=bt[t]||bt.iris;return o("img",{src:n,alt:"dango",className:e,decoding:"async",style:{height:"var(--logo-height, 75px)",width:"auto",display:"block",objectFit:"contain"}})},an=oe(void 0),rt=()=>{const e=ie(an);if(e===void 0)throw new Error("useSidebar must be used within a SidebarProvider");return e},cn=oe(void 0),ln=()=>{const e=ie(cn);if(e===void 0)throw new Error("useContentType must be used within a ContentTypeProvider");return e},He="virtual-keyboard:hide",_t="virtual-keyboard:enabled-change",un="virtual_keyboard_enabled",ki=!1;function wt(){const e=localStorage.getItem(un);return e===null?ki:e==="true"}const St=e=>e instanceof HTMLInputElement&&e.type==="text"&&!e.disabled&&!e.readOnly;function Pi(){window.dispatchEvent(new CustomEvent(He))}function Ei(){const[e,t]=_(!1),[n,r]=_(wt),i=B(null);return b(()=>{const s=d=>{n&&St(d.target)&&(i.current=d.target,t(!0))},a=d=>{d.target===i.current&&window.setTimeout(()=>{if(St(document.activeElement)){i.current=document.activeElement,t(!0);return}i.current=null,t(!1)},0)},c=()=>{i.current=null,t(!1)},l=d=>{if(d.key!==un)return;const m=d.newValue==="true";r(m),m||c()},u=()=>{const d=wt();r(d),d||c()};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),window.addEventListener(He,c),window.addEventListener("storage",l),window.addEventListener(_t,u),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a),window.removeEventListener(He,c),window.removeEventListener("storage",l),window.removeEventListener(_t,u)}},[n]),{activeInputRef:i,isVisible:n&&e,hide:()=>t(!1)}}const Ti="_header_1elij_1",Ii="_hidden_1elij_21",xi="_scrolled_1elij_25",Oi="_logo_1elij_31",Ni="_headerInner_1elij_44",Ci="_leftSection_1elij_54",Ai="_desktopNav_1elij_60",Li="_navLink_1elij_67",Ri="_navLinkActive_1elij_83",qi="_rightSection_1elij_102",$i="_searchWrapper_1elij_108",Di="_searchInput_1elij_114",ji="_searchButton_1elij_144",Mi="_searchIcon_1elij_168",Bi="_profileBtn_1elij_178",Fi="_profileImg_1elij_211",Wi="_hamburgerBtn_1elij_217",Ki="_mobileSearchBar_1elij_245",Ui="_mobileSearchBarHidden_1elij_272",zi="_mobileSearchInner_1elij_289",Qi="_mobileSearchIcon_1elij_305",Hi="_mobileSearchInput_1elij_312",S={header:Ti,hidden:Ii,scrolled:xi,logo:Oi,headerInner:Ni,leftSection:Ci,desktopNav:Ai,navLink:Li,navLinkActive:Ri,rightSection:qi,searchWrapper:$i,searchInput:Di,searchButton:ji,searchIcon:Mi,profileBtn:Bi,profileImg:Fi,hamburgerBtn:Wi,mobileSearchBar:Ki,mobileSearchBarHidden:Ui,mobileSearchInner:zi,mobileSearchIcon:Qi,mobileSearchInput:Hi},Vi=async()=>{let e;try{e=await U.auth.syncSettings.query()}catch{return null}const t=e.actualActiveProvider;if(t==="github")try{const n=await U.auth.githubStatus.query();if(n.authenticated&&n.user)return{name:n.user.name||n.user.login,picture:n.user.avatarUrl,provider:"github"}}catch{}if(t==="google")try{const n=await U.auth.user.query();if(n)return{name:n.name,picture:n.picture,email:n.email,provider:"google"}}catch{}return null},Gi=()=>{const{toggleSidebar:e}=rt(),{contentType:t}=ln(),[n,r]=_(""),[i,s]=_(!0),[a,c]=_(!1),[l,u]=_(!0),[d,m]=_(!1),p=qt(),h=Ye(),f=B(null),O=B(!1),D=B(null),j=B(null),H=B(null),A=B(null),{data:R}=Q({queryKey:["sync-profile"],queryFn:Vi,staleTime:3e4});b(()=>{const N=window.visualViewport;if(!N)return;const V=()=>{A.current?.style.setProperty("--vv-top",`${N.offsetTop}px`)};return V(),N.addEventListener("scroll",V),N.addEventListener("resize",V),()=>{N.removeEventListener("scroll",V),N.removeEventListener("resize",V)}},[]),b(()=>{const N=()=>{f.current&&(window.clearTimeout(f.current),f.current=null)},V=()=>{O.current||(O.current=!0,D.current=requestAnimationFrame(()=>{O.current=!1,D.current=null;const ne=window.scrollY<=10;u(ve=>ve===ne?ve:ne),s(ve=>ve||!0),N(),ne||(f.current=window.setTimeout(()=>{s(!1)},2500))}))},st=ne=>{(ne.metaKey||ne.ctrlKey)&&ne.key==="k"?(ne.preventDefault(),E.current?.focus({preventScroll:!0})):ne.key==="Escape"&&document.activeElement===E.current&&E.current?.blur()};return window.addEventListener("scroll",V,{passive:!0}),window.addEventListener("keydown",st),()=>{window.removeEventListener("scroll",V),window.removeEventListener("keydown",st),N(),D.current!==null&&(cancelAnimationFrame(D.current),D.current=null),O.current=!1}},[a]);const E=Je.useRef(null),Z=()=>window.innerWidth<=1024,fe=()=>{Z()?(m(!0),setTimeout(()=>H.current?.focus({preventScroll:!0}),50)):document.activeElement===E.current&&n.trim()?De():E.current?.focus({preventScroll:!0})},X=N=>{j.current?.contains(N.relatedTarget)||m(!1)},ke=t==="manga"?"Search manga...":t==="tv"?"Search TV & movies...":t==="asmr"?"Search ASMR...":"Search anime...",ye=t==="manga"?{to:"/reading-list",label:"Reading List"}:t==="tv"?{to:"/tv-watchlist",label:"TV Watchlist"}:t==="asmr"?{to:"/listening-list",label:"Listening List"}:{to:"/watchlist",label:"Watchlist"},De=N=>{Pi();const V=n.trim();V&&p(t==="manga"?`/manga?q=${encodeURIComponent(V)}`:t==="tv"?`/tv-search?q=${encodeURIComponent(V)}`:t==="asmr"?`/asmr?q=${encodeURIComponent(V)}`:`/search?query=${encodeURIComponent(V)}`)};return o(G,{children:o("header",{ref:A,className:`${S.header} ${i?"":S.hidden} ${l?"":S.scrolled}`,children:[o("div",{className:S.headerInner,children:[o("div",{className:S.leftSection,children:[o("button",{className:S.hamburgerBtn,onClick:e,"aria-label":"Menu",children:o(v,{name:"bars"})}),o(J,{to:"/",className:S.logo,"aria-label":"Ani-Web Home",children:o(sn,{})}),o("nav",{className:S.desktopNav,children:[o(J,{to:"/",className:`${S.navLink} ${h.pathname==="/"?S.navLinkActive:""}`,children:"Home"}),o(J,{to:ye.to,className:`${S.navLink} ${h.pathname.startsWith(ye.to)?S.navLinkActive:""}`,children:ye.label}),t==="anime"&&o(J,{to:"/insights",className:`${S.navLink} ${h.pathname==="/insights"?S.navLinkActive:""}`,children:"Insights"}),o(J,{to:"/settings",className:`${S.navLink} ${h.pathname.startsWith("/settings")?S.navLinkActive:""}`,children:"Settings"})]})]}),o("div",{className:S.rightSection,children:[o("div",{className:S.searchWrapper,children:[o("input",{ref:E,type:"text","data-virtual-keyboard":"true",className:S.searchInput,placeholder:ke,value:n,onChange:N=>r(N.target.value),onFocus:()=>c(!0),onBlur:()=>c(!1),onKeyDown:N=>{N.key==="Enter"&&De()}}),o("button",{type:"button",className:S.searchButton,"aria-label":"Search",onMouseDown:N=>N.preventDefault(),onClick:fe,children:o(v,{name:"search",className:S.searchIcon})})]}),o(Si,{}),o(J,{to:"/settings?tab=sync",className:S.profileBtn,"aria-label":"Sync settings",children:R?.picture?o("img",{src:R.picture,alt:R.name,className:S.profileImg,referrerPolicy:"no-referrer",decoding:"async"}):R?.provider==="github"?o(v,{name:"github"}):o(v,{name:"cloud"})})]})]}),d&&o("div",{className:`${S.mobileSearchBar} ${i?"":S.mobileSearchBarHidden}`,ref:j,onBlur:X,children:o("div",{className:S.mobileSearchInner,children:[o(v,{name:"search",className:S.mobileSearchIcon}),o("input",{ref:H,type:"text","data-virtual-keyboard":"true",className:S.mobileSearchInput,placeholder:ke,value:n,onChange:N=>r(N.target.value),onKeyDown:N=>{N.key==="Enter"?(De(),m(!1)):N.key==="Escape"&&m(!1)}})]})})]})})},Ve="agreedToViewMature";function kt(){try{return localStorage.getItem(Ve)==="true"}catch{return!1}}function Ji(){const[e,t]=_(kt);b(()=>{const i=()=>t(kt());return window.addEventListener("storage",i),window.addEventListener("focus",i),()=>{window.removeEventListener("storage",i),window.removeEventListener("focus",i)}},[]);const n=F(()=>{try{localStorage.setItem(Ve,"true")}catch{}t(!0)},[]),r=F(()=>{try{localStorage.removeItem(Ve)}catch{}t(!1)},[]);return{hasConsent:e,grant:n,revoke:r}}const Yi="_sidebar_153jc_1",Zi="_open_153jc_20",Xi="_sidebarHeader_153jc_25",es="_closeBtn_153jc_33",ts="_logo_153jc_57",ns="_navSection_153jc_69",rs="_navLink_153jc_75",os="_active_153jc_108",is="_overlay_153jc_118",ss="_versionInfo_153jc_138",ee={sidebar:Yi,open:Zi,sidebarHeader:Xi,closeBtn:es,logo:ts,navSection:ns,navLink:rs,active:os,overlay:is,versionInfo:ss},as="dango-client",cs="3.4.4",ls="module",us={node:">=22.12.0"},ds={start:"vite",dev:"vite",build:"tsc && vite build",lint:"eslint .",test:"vitest run",preview:"vite preview","start:prod":"vite preview",format:"prettier --write ."},ms={"@floating-ui/react":"^0.27.20","@tanstack/react-query":"^5.99.2","@trpc/client":"11.19.0","@trpc/tanstack-react-query":"11.19.0","anime4k-webgpu-async":"^2.0.0","embla-carousel-react":"^8.6.0","hls.js":"^1.5.13",preact:"^10.29.1","react-hot-toast":"^2.6.0","react-router":"^8.3.0","react-simple-maps":"^5.0.3"},ps={"@preact/preset-vite":"^2.10.5","@webgpu/types":"^0.1.72","eslint-plugin-react-hooks":"^7.1.1","eslint-plugin-react-refresh":"^0.5.2",vite:"^7.3.1",vitest:"^5.0.0"},ot={name:as,private:!0,version:cs,type:ls,engines:us,scripts:ds,dependencies:ms,devDependencies:ps},hs=()=>{const{isOpen:e,setIsOpen:t}=rt(),{contentType:n}=ln(),{hasConsent:r}=Ji(),i=()=>{t(!1)},s=n==="manga",a=n==="tv",c=n==="asmr",l=[{to:"/",icon:o(v,{name:"home"}),label:"Home"},s?{to:"/manga",icon:o(v,{name:"book"}),label:"Manga"}:a?{to:"/tv-search",icon:o(v,{name:"tv"}),label:"TV and Movies"}:c?{to:"/asmr",icon:o(v,{name:"headphones"}),label:"ASMR"}:{to:"/search",icon:o(v,{name:"search"}),label:"Search"},s?{to:"/reading-list",icon:o(v,{name:"bookmark"}),label:"Reading List"}:a?{to:"/tv-watchlist",icon:o(v,{name:"clock"}),label:"TV Watchlist"}:c?{to:"/listening-list",icon:o(v,{name:"history"}),label:"Listening List"}:{to:"/watchlist",icon:o(v,{name:"clock"}),label:"Watchlist"},...n==="anime"?[{to:"/insights",icon:o(v,{name:"chart-pie"}),label:"Insights"}]:[],{to:"/trackers",icon:o(v,{name:"sync-alt"}),label:"Trackers"},{to:"/radio",icon:o(v,{name:"broadcast-tower"}),label:"Radio"},{to:"/music",icon:o(v,{name:"headphones"}),label:"Music"},...r?[{to:"/mature",icon:o(v,{name:"pepper-hot"}),label:"Mature"}]:[],{to:"/settings",icon:o(v,{name:"cog"}),label:"Settings"}];return o(G,{children:[o("aside",{className:`${ee.sidebar} ${e?ee.open:""} sidebar`,children:[o("div",{className:ee.sidebarHeader,children:[o("button",{className:ee.closeBtn,onClick:()=>t(!1),"aria-label":"Close menu",children:"×"}),o(J,{to:"/",className:ee.logo,onClick:i,children:o(sn,{})})]}),o("nav",{className:ee.navSection,children:l.map(u=>o(Sn,{to:u.to,className:({isActive:d})=>`${ee.navLink} ${d?ee.active:""}`,onClick:i,end:u.to==="/",children:[u.icon,o("span",{children:u.label})]},u.to))}),o("div",{className:ee.versionInfo,children:["v",ot.version]})]}),e&&o("div",{className:ee.overlay,onClick:()=>t(!1),"aria-label":"Close sidebar"})]})},fs="_footer_1p5nb_1",ys="_footerInner_1p5nb_15",vs="_brandSection_1p5nb_27",gs="_logoRow_1p5nb_39",bs="_logoText_1p5nb_59",_s="_brandMeta_1p5nb_65",ws="_brandTagline_1p5nb_74",Ss="_statusPill_1p5nb_81",ks="_statusDot_1p5nb_94",Ps="_linksGrid_1p5nb_102",Es="_linkColumn_1p5nb_110",Ts="_columnTitle_1p5nb_116",Is="_bottomBar_1p5nb_140",xs="_copyright_1p5nb_150",Os="_brand_1p5nb_27",Ns="_heartIcon_1p5nb_166",Cs="_backToTop_1p5nb_171",C={footer:fs,footerInner:ys,brandSection:vs,logoRow:gs,logoText:bs,brandMeta:_s,brandTagline:ws,statusPill:Ss,statusDot:ks,linksGrid:Ps,linkColumn:Es,columnTitle:Ts,bottomBar:Is,copyright:xs,brand:Os,heartIcon:Ns,backToTop:Cs},Pt={iris:"/logo.png",mochi:"/logo-mochi.png",sakura:"/logo-sakura.png"},As=()=>{const{theme:e}=on(),t=Pt[e]||Pt.iris,n=new Date().getFullYear(),r=()=>{window.scrollTo({top:0,behavior:"smooth"})};return o("footer",{className:C.footer,children:[o("div",{className:C.footerInner,children:[o("div",{className:C.brandSection,children:[o("div",{className:C.logoRow,children:o("img",{src:t,className:C.logoText,alt:"dango",loading:"lazy",decoding:"async"})}),o("div",{className:C.brandMeta,children:[o("div",{className:C.statusPill,children:[o("span",{className:C.statusDot}),o("span",{children:["v",ot.version]})]}),o("p",{className:C.brandTagline,children:"Fast, local anime streaming."})]})]}),o("div",{className:C.linksGrid,children:[o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Navigation"}),o(J,{to:"/",children:"Home"}),o(J,{to:"/watchlist",children:"Watchlist"}),o(J,{to:"/settings",children:"Settings"})]}),o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Features"}),o(J,{to:"/search",children:"Search Anime"}),o(J,{to:"/trackers",children:"Trackers"}),o(J,{to:"/insights",children:"Insights"})]}),o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Community"}),o("a",{href:"https://discord.gg/2FTSPXCsvn",target:"_blank",rel:"noopener noreferrer",children:[o(v,{name:"discord",style:{marginRight:"6px"}})," Discord"]}),o("a",{href:"https://github.com/serifpersia/dango",target:"_blank",rel:"noopener noreferrer",children:[o(v,{name:"github",style:{marginRight:"6px"}})," GitHub"]})]}),o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Project"}),o("a",{href:"https://github.com/serifpersia/dango/releases",target:"_blank",rel:"noopener noreferrer",children:"Releases"}),o("a",{href:"https://github.com/serifpersia/dango/issues",target:"_blank",rel:"noopener noreferrer",children:"Feedback"})]})]})]}),o("div",{className:C.bottomBar,children:[o("p",{className:C.copyright,children:["© ",n," ",o("span",{className:C.brand,children:"dango"})," • Crafted with"," ",o(v,{name:"heart",className:C.heartIcon})," by"," ",o("a",{href:"https://github.com/serifpersia",target:"_blank",rel:"noopener noreferrer",children:"serifpersia"})]}),o("button",{className:C.backToTop,onClick:r,"aria-label":"Back to top",children:[o(v,{name:"chevron-up",size:14}),o("span",{children:"Top"})]})]})]})},Ls=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),Ae="https://script.google.com/macros/s/AKfycbxpllCbhqNjqFN02er9WV-0Tv-Y9br13UqXZqGHzSMetAgqKaFX5oFKGHgxji1fxJ6udw/exec",Rs=()=>{const e=navigator.userAgent;let t="Unknown Browser",n="Unknown OS";return e.includes("Firefox")?t="Firefox":e.includes("SamsungBrowser")?t="Samsung Browser":e.includes("Opera")||e.includes("OPR")?t="Opera":e.includes("Trident")?t="Internet Explorer":e.includes("Edge")?t="Edge":e.includes("Chrome")?t="Chrome":e.includes("Safari")&&(t="Safari"),e.includes("Windows")?n="Windows":e.includes("Mac")?n="MacOS":e.includes("Linux")?n="Linux":e.includes("Android")?n="Android":(e.includes("iPhone")||e.includes("iPad")||e.includes("iPod"))&&(n="iOS"),`${t} on ${n}`},qs=async()=>{localStorage.removeItem("last_telemetry_ping");const e=localStorage.getItem("installation_id");if(e&&Ae)try{await fetch(Ae,{method:"POST",mode:"no-cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"delete"})})}catch(t){console.error("Telemetry delete request failed:",t)}};let Be=!1;const $s=async()=>{if(!Be){Be=!0,localStorage.setItem("last_telemetry_ping",Date.now().toString());try{let e=localStorage.getItem("installation_id");if(!e)try{const t=await U.settings.installationId.query();t.id&&(e=t.id,localStorage.setItem("installation_id",e))}catch(t){console.error("Failed to fetch hardware ID:",t)}e||(e=Ls(),localStorage.setItem("installation_id",e)),await fetch(Ae,{method:"POST",mode:"no-cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,version:ot.version,userAgent:Rs(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}catch(e){console.error("Telemetry ping failed:",e)}finally{Be=!1}}},Ds=()=>{const[e,t]=_(!1);return b(()=>{if(!localStorage.getItem("telemetry_notice_v2")){const r=setTimeout(()=>t(!0),3e3);return()=>clearTimeout(r)}},[]),b(()=>{if(!(localStorage.getItem("telemetry_enabled")!=="false")||!Ae)return;const r=localStorage.getItem("last_telemetry_ping"),i=Date.now(),s=1440*60*1e3;r&&i-parseInt(r)<s||$s()},[]),{showTelemetryModal:e,setShowTelemetryModal:t}},js="_overlay_1juub_1",Ms="_fadeIn_1juub_1",Bs="_content_1juub_11",Fs="_modalIn_1juub_1",Ws="_sm_1juub_29",Ks="_md_1juub_33",Us="_lg_1juub_37",zs="_title_1juub_41",Qs="_body_1juub_48",Hs="_footer_1juub_52",me={overlay:js,fadeIn:Ms,content:Bs,modalIn:Fs,sm:Ws,md:Ks,lg:Us,title:zs,body:Qs,footer:Hs};function dn({children:e}){return o("h2",{className:me.title,children:e})}function mn({children:e}){return o("div",{className:me.body,children:e})}function pn({children:e}){return o("div",{className:me.footer,children:e})}function he({isOpen:e,onClose:t,title:n,children:r,footer:i,width:s="md"}){const a=B(null);return b(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&t?.()};document.addEventListener("keydown",c);const l=document.body.style.overflow;return document.body.style.overflow="hidden",a.current?.focus(),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=l}},[e,t]),e?Rt(o("div",{role:"presentation",onMouseDown:c=>c.stopPropagation(),children:[o("div",{className:me.overlay,onClick:()=>t?.(),"aria-hidden":"true"}),o("div",{ref:a,className:`${me.content} ${me[s]}`,role:"dialog","aria-modal":"true","aria-label":n,tabIndex:-1,children:[n&&o(dn,{children:n}),o(mn,{children:r}),i&&o(pn,{children:i})]})]}),document.body):null}he.Header=dn;he.Body=mn;he.Actions=pn;const Vs="_slider_1f1gi_15",Et={switch:"_switch_1f1gi_1",slider:Vs},Gs=({isChecked:e,onChange:t,id:n,disabled:r=!1})=>o("label",{className:Et.switch,htmlFor:n,children:[o("input",{type:"checkbox",id:n,checked:e,onChange:t,disabled:r}),o("span",{className:Et.slider})]}),Js="_container_1hh92_1",Ys="_description_1hh92_8",Zs="_dataList_1hh92_14",Xs="_dataTitle_1hh92_20",ea="_toggleRow_1hh92_39",ta="_toggleLabel_1hh92_46",na="_actions_1hh92_50",ra="_okButton_1hh92_55",oa="_previewToggle_1hh92_71",ia="_chevron_1hh92_89",sa="_chevronOpen_1hh92_94",aa="_previewBox_1hh92_98",ca="_previewItem_1hh92_107",la="_previewKey_1hh92_114",ua="_previewVal_1hh92_118",T={container:Js,description:Ys,dataList:Zs,dataTitle:Xs,toggleRow:ea,toggleLabel:ta,actions:na,okButton:ra,previewToggle:oa,chevron:ia,chevronOpen:sa,previewBox:aa,previewItem:ca,previewKey:la,previewVal:ua},da="3.4.4",ma={version:da},pa=()=>{const e=navigator.userAgent;return e.includes("Firefox")?"Firefox":e.includes("SamsungBrowser")?"Samsung Browser":e.includes("Opera")||e.includes("OPR")?"Opera":e.includes("Edge")?"Edge":e.includes("Chrome")?"Chrome":e.includes("Safari")?"Safari":"Unknown"},ha=()=>{const e=navigator.userAgent;return e.includes("Windows")?"Windows":e.includes("Mac")?"macOS":e.includes("Linux")?"Linux":e.includes("Android")?"Android":e.includes("iPhone")||e.includes("iPad")?"iOS":"Unknown"},fa=({isOpen:e,onClose:t})=>{const[n,r]=_(!0),[i,s]=_(!1),a=()=>{localStorage.setItem("telemetry_enabled",String(n)),localStorage.setItem("telemetry_notice_v2","true"),n||qs(),t()};return o(he,{isOpen:e,onClose:()=>{},title:"Telemetry",children:o("div",{className:T.container,children:[o("p",{className:T.description,children:"Dango collects anonymous usage data to help track how many people use the app. This information is used to measure the project's install base and popularity. Participation is completely optional."}),o("div",{className:T.dataList,children:[o("p",{className:T.dataTitle,children:"What is collected:"}),o("ul",{children:[o("li",{children:"Browser type and operating system"}),o("li",{children:"Your timezone (e.g. Europe/Berlin)"}),o("li",{children:"Anonymous timestamps (first seen / last seen)"})]})]}),o("button",{className:T.previewToggle,onClick:()=>s(!i),children:[o("span",{children:"See exactly what data is sent"}),o(v,{name:"chevron-down",className:`${T.chevron} ${i?T.chevronOpen:""}`})]}),i&&o("div",{className:T.previewBox,children:[o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"Browser:"}),o("span",{className:T.previewVal,children:pa()})]}),o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"OS:"}),o("span",{className:T.previewVal,children:ha()})]}),o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"Timezone:"}),o("span",{className:T.previewVal,children:Intl.DateTimeFormat().resolvedOptions().timeZone})]}),o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"App Version:"}),o("span",{className:T.previewVal,children:ma.version})]})]}),o("div",{className:T.toggleRow,children:[o("span",{className:T.toggleLabel,children:"Send anonymous telemetry"}),o(Gs,{isChecked:n,onChange:c=>r(c.target.checked),id:"telemetry-notice-toggle"})]}),o("div",{className:T.actions,children:o("button",{className:T.okButton,onClick:a,children:"Ok"})})]})})},ya="_promoWrapper_1vfnt_1",va="_visible_1vfnt_11",ga="_panel_1vfnt_16",ba="_closeBtn_1vfnt_29",_a="_header_1vfnt_55",wa="_discordIcon_1vfnt_62",Sa="_headerText_1vfnt_74",ka="_body_1vfnt_89",Pa="_rolePreview_1vfnt_96",Ea="_badge_1vfnt_103",Ta="_badgeRank_1vfnt_111",Ia="_badgeDere_1vfnt_117",xa="_actions_1vfnt_123",Oa="_btnJoin_1vfnt_129",Na="_btnSettings_1vfnt_155",Ca="_skipLink_1vfnt_180",Aa="_hint_1vfnt_200",L={promoWrapper:ya,visible:va,panel:ga,closeBtn:ba,header:_a,discordIcon:wa,headerText:Sa,body:ka,rolePreview:Pa,badge:Ea,badgeRank:Ta,badgeDere:Ia,actions:xa,btnJoin:Oa,btnSettings:Na,skipLink:Ca,hint:Aa},Tt="discord_community_promo_dismissed",La=4500;function Ra({workerUrl:e}){const t=qt(),[n,r]=_(!1),i=B(!1);b(()=>{if(localStorage.getItem(Tt)==="true"||localStorage.getItem("dango_discord_user"))return;const c=setTimeout(()=>r(!0),La);return()=>clearTimeout(c)},[]);const s=()=>{i.current||(i.current=!0,r(!1),localStorage.setItem(Tt,"true"))},a=()=>{s(),t("/settings?tab=community")};return e?o("div",{className:`${L.promoWrapper} ${n?L.visible:""}`,"aria-live":"polite",children:o("div",{className:L.panel,children:[o("button",{className:L.closeBtn,onClick:s,"aria-label":"Dismiss",children:"✕"}),o("div",{className:L.header,children:[o("div",{className:L.discordIcon,children:o("svg",{width:"20",height:"16",viewBox:"0 0 71 55",fill:"white","aria-hidden":"true",children:o("path",{d:"M60.1 4.9A58.5 58.5 0 0 0 45.5.3a.22.22 0 0 0-.23.11 40.8 40.8 0 0 0-1.8 3.7 54 54 0 0 0-16.2 0 37.5 37.5 0 0 0-1.83-3.7.23.23 0 0 0-.23-.11A58.3 58.3 0 0 0 10.9 4.9a.2.2 0 0 0-.1.08C1.58 18.73-1 32.23.31 45.55a.24.24 0 0 0 .09.17 58.8 58.8 0 0 0 17.7 8.95.23.23 0 0 0 .25-.08 42 42 0 0 0 3.61-5.88.22.22 0 0 0-.12-.31 38.7 38.7 0 0 1-5.53-2.64.23.23 0 0 1-.02-.37 29 29 0 0 0 1.1-.86.22.22 0 0 1 .23-.03c11.6 5.3 24.14 5.3 35.6 0a.22.22 0 0 1 .23.03c.36.3.73.58 1.1.86a.23.23 0 0 1-.02.37 36.4 36.4 0 0 1-5.53 2.64.22.22 0 0 0-.12.31 47.1 47.1 0 0 0 3.61 5.88.22.22 0 0 0 .25.08 58.6 58.6 0 0 0 17.72-8.95.23.23 0 0 0 .09-.16c1.47-15.27-2.47-28.65-10.46-40.47a.18.18 0 0 0-.09-.09ZM23.73 37.55c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.82 7.15-6.37 7.15Zm23.54 0c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.79 7.15-6.37 7.15Z"})})}),o("div",{className:L.headerText,children:[o("h4",{children:"Join the Dango Community"}),o("p",{children:"Earn roles based on your watch stats"})]})]}),o("div",{className:L.body,children:[o("p",{style:{margin:"0 0 6px"},children:"Connect your Discord account and earn exclusive server roles based on how much you watch:"}),o("div",{className:L.rolePreview,children:[o("span",{className:`${L.badge} ${L.badgeRank}`,children:"S-Rank"}),o("span",{className:`${L.badge} ${L.badgeRank}`,children:"F–A Rank"}),o("span",{className:`${L.badge} ${L.badgeDere}`,children:"Tsundere"}),o("span",{className:`${L.badge} ${L.badgeDere}`,children:"Kamidere…"})]})]}),o("div",{className:L.actions,children:[o("a",{className:L.btnJoin,href:"https://discord.gg/6yPAZjDzg8",target:"_blank",rel:"noopener noreferrer",children:[o("svg",{width:"16",height:"12",viewBox:"0 0 71 55",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M60.1 4.9A58.5 58.5 0 0 0 45.5.3a.22.22 0 0 0-.23.11 40.8 40.8 0 0 0-1.8 3.7 54 54 0 0 0-16.2 0 37.5 37.5 0 0 0-1.83-3.7.23.23 0 0 0-.23-.11A58.3 58.3 0 0 0 10.9 4.9a.2.2 0 0 0-.1.08C1.58 18.73-1 32.23.31 45.55a.24.24 0 0 0 .09.17 58.8 58.8 0 0 0 17.7 8.95.23.23 0 0 0 .25-.08 42 42 0 0 0 3.61-5.88.22.22 0 0 0-.12-.31 38.7 38.7 0 0 1-5.53-2.64.23.23 0 0 1-.02-.37 29 29 0 0 0 1.1-.86.22.22 0 0 1 .23-.03c11.6 5.3 24.14 5.3 35.6 0a.22.22 0 0 1 .23.03c.36.3.73.58 1.1.86a.23.23 0 0 1-.02.37 36.4 36.4 0 0 1-5.53 2.64.22.22 0 0 0-.12.31 47.1 47.1 0 0 0 3.61 5.88.22.22 0 0 0 .25.08 58.6 58.6 0 0 0 17.72-8.95.23.23 0 0 0 .09-.16c1.47-15.27-2.47-28.65-10.46-40.47a.18.18 0 0 0-.09-.09ZM23.73 37.55c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.82 7.15-6.37 7.15Zm23.54 0c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.79 7.15-6.37 7.15Z"})}),"Join Discord Server"]}),o("button",{className:L.btnSettings,onClick:a,children:[o("span",{children:"⚙"})," Get Roles & Settings"]})]}),o("button",{className:L.skipLink,onClick:s,children:"Skip — don't show again"}),o("p",{className:L.hint,children:"You can always find this in Settings → Community"})]})}):null}const it=e=>{const t=P();return Q({...t.settings.getByKey.queryOptions({key:e}),select:n=>n.value})},hn=()=>{const e=P(),t=z();return Y(e.settings.set.mutationOptions({onSuccess:()=>{g.success("Setting updated!"),t.invalidateQueries(e.settings.pathFilter()),t.invalidateQueries({queryKey:["settings"]})},onError:n=>{g.error(`Failed to update setting: ${n.message}`)}}))};function fn(e){return JSON.stringify({0:e??{}})}function yn(e){return`/api/trpc/${e}?batch=1`}function Ge(e,t){const n=fn(t),r=yn(e);try{if(navigator.sendBeacon){navigator.sendBeacon(r,new Blob([n],{type:"application/json"}));return}}catch{}fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}).catch(()=>{})}async function ll(e,t){await fetch(yn(e),{method:"POST",headers:{"Content-Type":"application/json"},body:fn(t),keepalive:!0})}function ul(e){e&&(Ge("discord.clear",{sessionId:e}),Ge("discord.heartbeat",{sessionId:e,bye:!0}))}function qa(){const e=Ye(),{data:t}=it("discordRPCEnabled"),n=B("");n.current||(n.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`tab-${Date.now()}-${Math.random().toString(36).slice(2)}`),b(()=>{if(t===!1||t==="false")return;const r=n.current,i=()=>U.discord.heartbeat.mutate({sessionId:r}).catch(()=>{});i();const s=setInterval(i,15e3),a=()=>{Ge("discord.heartbeat",{sessionId:r,bye:!0})};return window.addEventListener("pagehide",a),()=>{clearInterval(s),window.removeEventListener("pagehide",a)}},[t]),b(()=>{if(t===!1||t==="false")return;const r=e.pathname;if(r.startsWith("/watch/")||r.startsWith("/player/"))return;let i="home";r.startsWith("/search")||r.startsWith("/mature")?i="search":r.startsWith("/watchlist")?i="watchlist":r.startsWith("/anime/")?i="anime":r.startsWith("/insights")?i="insights":r.startsWith("/settings")?i="settings":r.startsWith("/map")?i="map":r.startsWith("/trackers")?i="trackers":r.startsWith("/asmr")?i="asmr":r.startsWith("/manga")?i="manga":r.startsWith("/radio")?i="radio":r.startsWith("/music")?i="music":r.startsWith("/tv")&&(i="tv"),U.discord.pageStatus.mutate({page:i}).catch(()=>{})},[e.pathname,t])}function vn(e,t){const[n,r]=_(()=>{try{const s=localStorage.getItem(e);if(s===null)return t;if(typeof t=="string")return s;try{return JSON.parse(s)}catch{return s}}catch{return t}});b(()=>{const s=a=>{if(a.key===e)try{if(a.newValue===null){r(t);return}if(typeof t=="string"){r(a.newValue);return}try{r(JSON.parse(a.newValue))}catch{r(a.newValue)}}catch{}};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[e,t]);const i=F(s=>{r(a=>{const c=typeof s=="function"?s(a):s;try{typeof c=="string"?localStorage.setItem(e,c):localStorage.setItem(e,JSON.stringify(c))}catch{}return c})},[e]);return[n,i]}const gn=oe(void 0),$a=()=>{const e=ie(gn);if(!e)throw new Error("useAnimePaheCookie must be used within an AnimePaheCookieProvider");return e},Da="_container_e96gf_1",ja="_field_e96gf_9",Ma="_textarea_e96gf_20",Ba="_input_e96gf_40",Fa="_button_e96gf_58",Wa="_secondaryButton_e96gf_78",Ka="_actions_e96gf_95",Ua="_hint_e96gf_104",za="_link_e96gf_117",W={container:Da,field:ja,textarea:Ma,input:Ba,button:Fa,secondaryButton:Wa,actions:Ka,hint:Ua,link:za},Qa="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Ha=e=>{try{return JSON.parse(e.detail)}catch{return null}},Va=({isOpen:e,onClose:t,onSuccess:n})=>{const[r,i]=_(1),[s,a]=_(navigator.userAgent),[c,l]=_(""),[u,d]=_(!1),m=B(null),p=navigator.userAgent,h=/android/i.test(p),f=/firefox|fxios/i.test(p)&&!h,O=!f&&!h&&/chrome|chromium|edg|brave/i.test(p),D=f||O;b(()=>{e&&(i(1),a(navigator.userAgent),l(""),d(!1))},[e]),b(()=>()=>{m.current&&(window.removeEventListener("dango:pahe-cookie",m.current),m.current=null)},[]);const j=()=>{localStorage.setItem("animepahe_ua",s),window.open("https://animepahe.pw","_blank","noopener,noreferrer"),i(2)},H=()=>{if(u)return;d(!0);const R=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,E=window.setTimeout(()=>{d(!1),m.current&&(window.removeEventListener("dango:pahe-cookie",m.current),m.current=null),g.error("Helper not detected — install it via about:debugging first.")},3e3),Z=fe=>{const X=Ha(fe);if(!(!X||X.requestId!==R))if(window.clearTimeout(E),window.removeEventListener("dango:pahe-cookie",Z),m.current=null,d(!1),X?.ok&&X.cookie)l(X.cookie),g.success("Cookie extracted from helper!");else if(X?.error==="NO_COOKIE"){const ke=X.debug?.stores?.length??0,ye=X.debug?.names??[];g.error(`Helper found no cf_clearance (checked ${ke} stores, saw: ${ye.join(", ")||"none"}) — solve the challenge on the AnimePahe tab first.`)}else g.error("Helper request failed — try again.")};m.current=Z,window.addEventListener("dango:pahe-cookie",Z),window.dispatchEvent(new CustomEvent("dango:get-pahe-cookie",{detail:{requestId:R}}))},A=()=>{const R=c.trim();if(!R){g.error("Please enter the cf_clearance cookie");return}try{localStorage.setItem("animepahe_cookie",R),g.success("Cookie updated successfully! Reloading…"),n?.(),t(),window.setTimeout(()=>window.location.reload(),1e3)}catch{g.error("Failed to save cookie")}};return o(he,{isOpen:e,onClose:t,title:"AnimePahe Verification Required",children:o("div",{className:W.container,children:r===1?o(G,{children:[o("p",{children:"AnimePahe requires a manual verification to bypass Cloudflare/DDoS-Guard protection."}),o("div",{className:W.field,children:[o("label",{children:"Your User-Agent (will be used for requests):"}),o("textarea",{value:s,readOnly:!0,rows:3,className:W.textarea})]}),o("div",{className:W.actions,children:[o("button",{className:W.secondaryButton,onClick:t,children:"Cancel"}),o("button",{className:W.button,onClick:j,children:"Start Verification (Opens AnimePahe)"})]})]}):o(G,{children:[o("p",{children:["1. Solve the challenge on the ",o("strong",{children:"AnimePahe tab"})," (keep that tab open).",o("br",{}),"2. Copy the ",o("strong",{children:"cf_clearance"})," cookie value using one of these:",o("br",{}),o("br",{}),o("strong",{children:"Chrome / Edge — DevTools:"})," press ",o("code",{children:"F12"})," →"," ",o("strong",{children:"Application"})," → ",o("strong",{children:"Cookies"})," →"," ",o("code",{children:"https://animepahe.pw"}),". Find ",o("strong",{children:"cf_clearance"}),", double-click its ",o("strong",{children:"Value"})," to select it, then copy.",o("br",{}),o("br",{}),o("strong",{children:"Firefox — Storage Inspector:"})," press ",o("code",{children:"F12"})," →"," ",o("strong",{children:"Storage"})," → ",o("strong",{children:"Cookies"})," →"," ",o("code",{children:"https://animepahe.pw"}),". Find ",o("strong",{children:"cf_clearance"}),", right-click the value → ",o("strong",{children:"Copy Value"}),".",o("br",{}),o("br",{}),o("strong",{children:"Either browser — extension:"})," open"," ",o("strong",{children:"Cookie Manager"})," while on the AnimePahe tab, find"," ",o("strong",{children:"cf_clearance"}),", and copy its value (or use the extension's export).",o("br",{}),o("br",{}),"3. Paste it below. Copy ",o("strong",{children:"only the value"})," — remove any"," ",o("code",{children:"cf_clearance="})," prefix or quotes if they were included."]}),D&&o("div",{className:W.hint,children:[o("strong",{children:"Dango helper (one-time setup):"})," ",f?o(G,{children:["type ",o("code",{children:"about:debugging"})," in the address bar →"," ",o("strong",{children:"This Firefox"})," → ",o("strong",{children:"Load Temporary Add-on"})," ","→ open the ",o("code",{children:"dango-extension/firefox"})," folder and pick"," ",o("code",{children:"manifest.json"}),". (Temporary helpers unload when Firefox closes — repeat after a restart.)"]}):o(G,{children:["type ",o("code",{children:"chrome://extensions"})," in the address bar → enable"," ",o("strong",{children:"Developer mode"})," → ",o("strong",{children:"Load unpacked"})," → open the ",o("code",{children:"dango-extension/chrome"})," folder. (Unpacked helpers show a developer-mode notice — expected.)"]})," ","Use this link to download the extension and extract it:"," ",o("a",{href:Qa,target:"_blank",rel:"noreferrer",className:W.link,children:"dango-extension.zip"}),". Then click Extract below and the field fills itself.",o("div",{className:W.actions,children:o("button",{className:W.button,onClick:H,disabled:u,type:"button",children:u?"Extracting…":"Extract cookie from helper"})})]}),o("div",{className:W.field,children:[o("label",{children:"cf_clearance cookie value:"}),o("input",{type:"text",value:c,onChange:R=>l(R.target.value),placeholder:"e.g. xxxxxxxx.xxxxxxxx.xxxxxxx-xxxxxxx",className:W.input})]}),o("div",{className:W.actions,children:[o("button",{className:W.secondaryButton,onClick:t,children:"Cancel"}),o("button",{className:W.secondaryButton,onClick:()=>i(1),children:"Back"}),o("button",{className:W.button,onClick:A,children:"Submit"})]})]})})})};function Ga(){const[e,t]=_(!1);return b(()=>{const n=window.setTimeout(()=>t(!0),120);return()=>window.clearTimeout(n)},[]),e?o("div",{className:"top-progress-bar",role:"progressbar","aria-label":"Loading"}):null}class Ja extends kn{state={hasError:!1};static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?o("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100%",backgroundColor:"#1a1b1c",color:"#fff",textAlign:"center",padding:"2rem"},children:[o(v,{name:"exclamation-triangle",style:{fontSize:"4rem",color:"#ff4d4d",marginBottom:"1rem"}}),o("h1",{style:{marginBottom:"1rem"},children:"Something went wrong"}),o("p",{style:{color:"#aaa",marginBottom:"2rem"},children:"The application encountered an unexpected error."}),o("button",{onClick:()=>{this.setState({hasError:!1}),window.location.href="/"},style:{padding:"0.8rem 1.5rem",backgroundColor:"var(--accent, #3d5afe)",color:"#fff",border:"none",borderRadius:"0.5rem",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"1rem",transition:"background-color 0.2s"},onMouseOver:t=>t.currentTarget.style.backgroundColor="#536dfe",onMouseOut:t=>t.currentTarget.style.backgroundColor="var(--accent, #3d5afe)",children:[o(v,{name:"home"}),"Go back Home"]})]}):this.props.children}}const bn=oe(void 0),Ya=({children:e})=>{const[t,n]=_(!1),r=F(()=>n(!0),[]),i=F(()=>n(!1),[]);return b(()=>Zt("lan",r),[r]),o(bn.Provider,{value:{isOpen:t,openModal:r,closeModal:i},children:e})},Za=()=>{const e=ie(bn);if(!e)throw new Error("useLanAuth must be used within a LanAuthProvider");return e},Xa="_container_88bss_1",ec="_field_88bss_8",tc="_input_88bss_19",nc="_actions_88bss_37",Te={container:Xa,field:ec,input:tc,actions:nc},It=Pn(({variant:e="primary",size:t="md",loading:n,children:r,className:i="",disabled:s,...a},c)=>{const l=["btn",`btn-${e}`,t!=="md"&&`btn-${t}`,n&&"btn-loading",i].filter(Boolean).join(" ");return o("button",{className:l,disabled:s||n,ref:c,...a,children:n?o("span",{className:"btn-spinner"}):r})}),rc=({isOpen:e,onClose:t,onSuccess:n})=>{const[r,i]=_(""),[s,a]=_(!1);Je.useEffect(()=>{e&&i("")},[e]);const c=async()=>{if(!r){g.error("Please enter your password");return}a(!0);try{const l=await fetch("/api/auth/app-login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})}),u=await l.json().catch(()=>({}));if(!l.ok){g.error(u.error||"Login failed");return}g.success("Authenticated successfully"),n(),t(),window.location.reload()}catch{g.error("Network error")}finally{a(!1)}};return o(he,{isOpen:e,onClose:t,title:"LAN Authentication Required",children:o("div",{className:Te.container,children:[o("p",{children:"This instance is protected. Enter the password to access from this device."}),o("div",{className:Te.field,children:[o("label",{htmlFor:"lan-password",children:"Password"}),o("input",{id:"lan-password",type:"password",value:r,onChange:l=>i(l.target.value),placeholder:"Enter password...",className:Te.input,onKeyDown:l=>l.key==="Enter"&&c()})]}),o("div",{className:Te.actions,children:[o(It,{variant:"secondary",onClick:t,disabled:s,children:"Cancel"}),o(It,{variant:"primary",onClick:c,loading:s,children:"Unlock"})]})]})})},oc=I(()=>x(()=>import("./Home-A7gCeEST.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]))),ic=I(()=>x(()=>import("./Watchlist-CSngjqlz.js"),__vite__mapDeps([29,1,2,4,6,7,8,9,10,11,12,13,3,5,14,15,30,31]))),sc=I(()=>x(()=>import("./Settings-Bw9M3NGz.js"),__vite__mapDeps([32,1,2,4,33]))),xt=I(()=>x(()=>import("./Player-yhiTlpYU.js"),__vite__mapDeps([34,1,2,35,4,36,37,12,17,18,8,9,10,22,38,39,40,41,42]))),ac=I(()=>x(()=>import("./Search-qpILaAiQ.js"),__vite__mapDeps([43,1,4,3,5,6,7,2,8,9,10,11,12,13,14,15,44,45]))),cc=I(()=>x(()=>import("./Mature-Bkhxnr3K.js"),__vite__mapDeps([46,1,2,4,3,5,6,7,8,9,10,11,12,13,14,15,22,44,45,47]))),Ot=I(()=>x(()=>import("./Asmr-qg3lMAJn.js"),__vite__mapDeps([48,1,4,2,11,9,12,13,27,49,50,51,37]))),lc=I(()=>x(()=>import("./Manga-qdAAS1z7.js"),__vite__mapDeps([52,1,4,14,15,11,9,12,13,19,20,2,22,53,54]))),uc=I(()=>x(()=>import("./MangaInfoPage-1rTgZzf2.js"),__vite__mapDeps([55,1,4,14,15,20,2,53,54]))),dc=I(()=>x(()=>import("./MangaReadPage-CeyxPG6w.js"),__vite__mapDeps([56,1,14,4,15,2,20,53,54]))),mc=I(()=>x(()=>import("./ReadingList-CCm3IAbt.js"),__vite__mapDeps([57,1,11,9,4,12,13,58,3,5,14,15,30,31,19,20,2,21,16]))),pc=I(()=>x(()=>import("./Radio-FxGqCxR4.js"),__vite__mapDeps([59,1,4,2,49,50,60,61]))),hc=I(()=>x(()=>import("./Music-C0rGzSbi.js"),__vite__mapDeps([62,1,4,49,50,60,61,2,63]))),Nt=I(()=>x(()=>import("./TvSearch-BVxedBW-.js"),__vite__mapDeps([64,1,4,3,5,23,11,9,12,13,24,25,2,14,15,44,45]))),fc=I(()=>x(()=>import("./TvInfo-CHIsVzZ0.js"),__vite__mapDeps([65,1,4,25,2,66]))),yc=I(()=>x(()=>import("./Tv-DREwc7BX.js"),__vite__mapDeps([67,1,2,4,35,36,68,22,25,37,12,40,41,69]))),vc=I(()=>x(()=>import("./TvWatchlist-BEIwq9R9.js"),__vite__mapDeps([70,1,11,9,4,12,13,58,3,5,14,15,30,31,16,24,25,2]))),gc=I(()=>x(()=>import("./ListeningList-Czv4cTRl.js"),__vite__mapDeps([71,1,11,9,4,12,13,58,3,5,14,15,30,31,51,27,2,49,50,26,16]))),bc=I(()=>x(()=>import("./Trackers-Zy5GOs0P.js"),__vite__mapDeps([72,1,2,4,73]))),_c=I(()=>x(()=>import("./Insights-G9IXepHJ.js"),__vite__mapDeps([74,1,2,4,75]))),wc=I(()=>x(()=>import("./Map-BtXwpBOC.js"),__vite__mapDeps([76,1,4,77]))),Sc=I(()=>x(()=>import("./AnimeInfoPage-Dvp_c8vK.js"),__vite__mapDeps([78,1,2,4]))),kc=I(()=>x(()=>import("./PlayerRedirect-fv2tzEUu.js"),__vite__mapDeps([79,1]))),Pc=I(()=>x(()=>import("./VirtualKeyboard-BmqZPZXR.js"),__vite__mapDeps([80,1,81])));function Ec(){const{isOpen:e,closeModal:t,onSuccess:n}=$a(),{isOpen:r,setIsOpen:i}=rt(),{isOpen:s,openModal:a,closeModal:c}=Za(),l=Ye(),u=En(),d=B(new Map),m=Ei(),{showTelemetryModal:p,setShowTelemetryModal:h}=Ds();qa();const[f,O]=_("");b(()=>{U.discord.rolesConfig.query().then(E=>{E.workerUrl&&O(E.workerUrl)}).catch(()=>{})},[]);const[D,j]=_(!1);b(()=>{fetch("/api/auth/app-status").then(E=>E.json()).then(E=>{E.hasPassword&&!E.isAuthenticated&&(j(!0),a())}).catch(()=>{})},[a]);const[H,A]=vn("lan_auth_notice_shown","false"),R=B(!1);return b(()=>{if(H==="true"||R.current)return;R.current=!0,A("true");const E=setTimeout(()=>{g("Optional LAN lock is available. Set a password in Settings to protect access from other devices on your network.",{duration:1e4,icon:"🔒"})},3e3);return()=>clearTimeout(E)},[H,A]),b(()=>{try{window.history.scrollRestoration="manual"}catch{}},[]),b(()=>{const E=l.key,Z=d.current;if(u==="POP"){const fe=Z.get(E)??0;window.scrollTo({top:fe,behavior:"instant"})}else window.scrollTo({top:0,behavior:"instant"});return()=>{Z.set(E,window.scrollY)}},[l.key,u]),b(()=>{const E=Z=>{r&&Z.key==="Escape"&&i(!1)};return r?document.body.classList.add("sidebar-open"):document.body.classList.remove("sidebar-open"),window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E),document.body.classList.remove("sidebar-open")}},[r,i]),o("div",{className:"app-container",children:[o(Va,{isOpen:e,onClose:t,onSuccess:n}),o(fa,{isOpen:p,onClose:()=>h(!1)}),o(rc,{isOpen:s,onClose:D?()=>{}:c,onSuccess:()=>{j(!1),c()}}),f&&o(Ra,{workerUrl:f}),o(Sr,{position:"top-center",toastOptions:{style:{background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border-primary)"},success:{style:{background:"var(--accent)",color:"var(--accent-text)"},iconTheme:{primary:"var(--accent-text)",secondary:"var(--accent)"}},error:{style:{background:"rgba(153, 42, 42, 0.95)",color:"#fff"}}}}),o(Gi,{}),o(hs,{}),o("main",{className:"main-content",children:o(Ja,{children:o(at,{fallback:o(Ga,{}),children:o(Tn,{children:[o(w,{path:"/",element:o(oc,{})}),o(w,{path:"/watchlist/:filter?",element:o(ic,{})}),o(w,{path:"/reading-list/:filter?",element:o(mc,{})}),o(w,{path:"/search",element:o(ac,{})}),o(w,{path:"/mature",element:o(cc,{})}),o(w,{path:"/asmr",element:o(Ot,{})}),o(w,{path:"/asmr/:rj",element:o(Ot,{})}),o(w,{path:"/manga",element:o(lc,{})}),o(w,{path:"/manga/:provider/:id",element:o(uc,{})}),o(w,{path:"/manga/:provider/:id/read",element:o(dc,{})}),o(w,{path:"/radio",element:o(pc,{})}),o(w,{path:"/music",element:o(hc,{})}),o(w,{path:"/tv",element:o(Nt,{})}),o(w,{path:"/tv/:id",element:o(fc,{})}),o(w,{path:"/tv/:id/watch",element:o(yc,{})}),o(w,{path:"/tv-search",element:o(Nt,{})}),o(w,{path:"/tv-watchlist/:filter?",element:o(vc,{})}),o(w,{path:"/listening-list/:filter?",element:o(gc,{})}),o(w,{path:"/settings",element:o(sc,{})}),o(w,{path:"/trackers",element:o(bc,{})}),o(w,{path:"/mal",element:o(ct,{to:"/trackers",replace:!0})}),o(w,{path:"/insights",element:o(_c,{})}),o(w,{path:"/map",element:o(wc,{})}),o(w,{path:"/anime/:id",element:o(Sc,{})}),o(w,{path:"/watch/:id",element:o(xt,{})}),o(w,{path:"/watch/:id/:episodeNumber",element:o(xt,{})}),o(w,{path:"/player/:id/:episodeNumber?",element:o(kc,{})}),o(w,{path:"*",element:o(ct,{to:"/",replace:!0})})]})})})}),o(As,{}),m.isVisible&&o(at,{fallback:null,children:o(Pc,{activeInputRef:m.activeInputRef,isVisible:m.isVisible,onClose:m.hide})})]})}function Tc(){return o(Ya,{children:o(Ec,{})})}const Ic=({children:e})=>{const[t,n]=_(!1),r=F(()=>{n(s=>!s)},[]),i=pe(()=>({isOpen:t,setIsOpen:n,toggleSidebar:r}),[t,r]);return o(an.Provider,{value:i,children:e})},xc=({children:e})=>{const[t,n]=vn("dango_content_type","anime"),r=pe(()=>({contentType:t,setContentType:n}),[t,n]);return o(cn.Provider,{value:r,children:e})},Oc=({children:e})=>{const[t,n]=_("englishName"),[r,i]=_(!0);b(()=>{(async()=>{try{const c=await U.settings.getByKey.query({key:"titlePreference"});c.value&&n(c.value)}catch(c){console.error("Error fetching title preference in context:",c)}finally{i(!1)}})()},[]);const s=pe(()=>({titlePreference:t,setTitlePreference:n,loading:r}),[t,r]);return o(Xt.Provider,{value:s,children:e})},_n=oe(void 0),dl=()=>{const e=ie(_n);if(e===void 0)throw new Error("useLowEndMode must be used within a LowEndModeProvider");return e},Nc=({children:e})=>{const{data:t,isLoading:n}=it("lowEndMode"),r=hn(),[i,s]=_(!1);b(()=>{t!==void 0&&s(t==="true"||t===!0)},[t]),b(()=>{i?document.body.classList.add("low-end"):document.body.classList.remove("low-end")},[i]);const a=F(l=>{s(l),r.mutate({key:"lowEndMode",value:String(l)})},[r]),c=pe(()=>({lowEndMode:i,setLowEndMode:a,loading:n}),[i,a,n]);return o(_n.Provider,{value:c,children:e})},Cc=["iris","mochi","sakura"];function Ct(e){e==="iris"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const Ac=({children:e})=>{const{data:t,isLoading:n}=it("theme"),r=hn(),[i,s]=_("iris");b(()=>{typeof t=="string"&&Cc.includes(t)&&s(t)},[t]),b(()=>{Ct(i)},[i]);const a=F(l=>{l!==i&&(s(l),Ct(l),r.mutate({key:"theme",value:l}))},[r,i]),c=pe(()=>({theme:i,setTheme:a,loading:n}),[i,a,n]);return o(rn.Provider,{value:c,children:e})},Lc=({children:e})=>{const[t,n]=_(!1),[r,i]=_(void 0),s=F(c=>{i(()=>c),n(!0)},[]),a=F(()=>{n(!1),i(void 0)},[]);return b(()=>Zt("animepahe",()=>s()),[s]),o(gn.Provider,{value:{isOpen:t,openModal:s,closeModal:a,onSuccess:r},children:e})};try{window.history.scrollRestoration="manual"}catch{}const At=new Cn({defaultOptions:{queries:{staleTime:1e3*60*5,refetchOnWindowFocus:!1,refetchIntervalInBackground:!1,retry:1}}}),Lt=document.getElementById("root");Lt&&In(o(xn,{children:o(Bo,{trpcClient:U,queryClient:At,children:o(An,{client:At,children:o(Lc,{children:o(Ic,{children:o(xc,{children:o(Oc,{children:o(Nc,{children:o(Ac,{children:o(Tc,{})})})})})})})})})}),Lt);export{Qe as $,hn as A,It as B,rl as C,ol as D,nl as E,q as F,on as G,cl as H,wt as I,ma as J,Rs as K,_t as L,he as M,$s as N,qs as O,Mc as P,Va as Q,Uc as R,Me as S,Gs as T,Pi as U,un as V,ul as W,W as X,Zt as Y,ll as Z,x as _,vn as a,rt as a0,al as a1,Ga as a2,Vc as a3,Gc as a4,Hc as a5,Fc as b,Wc as c,Ko as d,Ji as e,Wo as f,Dc as g,P as h,Kc as i,ln as j,tl as k,zc as l,Qc as m,Jc as n,Yc as o,il as p,Xc as q,Bc as r,jc as s,U as t,dl as u,sl as v,el as w,Zc as x,it as y,g as z};
178
+ `,Pe=16,Sr=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:i,toasterId:s,containerStyle:a,containerClassName:c})=>{let{toasts:l,handlers:u}=Jn(n,s);return M("div",{"data-rht-toaster":s||"",style:{position:"fixed",zIndex:9999,top:Pe,left:Pe,right:Pe,bottom:Pe,pointerEvents:"none",...a},className:c,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map(d=>{let m=d.position||t,p=u.calculateOffset(d,{reverseOrder:e,gutter:r,defaultPosition:t}),h=_r(m,p);return M(br,{id:d.id,key:d.id,onHeightUpdate:u.updateHeight,className:d.visible?wr:"",style:h},d.type==="custom"?Ne(d.message,d):i?i(d):M(gr,{toast:d,position:m}))}))},g=q;function qe(e){const t={subscribe(n){let r=null,i=!1,s=!1,a=!1;function c(){if(r===null){a=!0;return}s||(s=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=e({next(l){var u;i||(u=n.next)===null||u===void 0||u.call(n,l)},error(l){var u;i||(i=!0,(u=n.error)===null||u===void 0||u.call(n,l),c())},complete(){var l;i||(i=!0,(l=n.complete)===null||l===void 0||l.call(n),c())}}),a&&c(),{unsubscribe:c}},pipe(...n){return n.reduce(kr,t)}};return t}function kr(e,t){return t(e)}function Pr(e){const t=new AbortController;return new Promise((n,r)=>{let i=!1;function s(){i||(i=!0,a.unsubscribe())}t.signal.addEventListener("abort",()=>{r(t.signal.reason)});const a=e.subscribe({next(c){i=!0,n(c),s()},error(c){r(c)},complete(){t.abort(),s()}})})}function Er(e){return t=>{let n=0,r=null;const i=[];function s(){r||(r=t.subscribe({next(c){for(const u of i){var l;(l=u.next)===null||l===void 0||l.call(u,c)}},error(c){for(const u of i){var l;(l=u.error)===null||l===void 0||l.call(u,c)}},complete(){for(const l of i){var c;(c=l.complete)===null||c===void 0||c.call(l)}}}))}function a(){if(n===0&&r){const c=r;r=null,c.unsubscribe()}}return qe(c=>(n++,i.push(c),s(),{unsubscribe(){n--,a();const l=i.findIndex(u=>u===c);l>-1&&i.splice(l,1)}}))}}function Tr(e){let t=e;const n=[],r=a=>{t!==void 0&&a.next(t),n.push(a)},i=a=>{n.splice(n.indexOf(a),1)},s=qe(a=>(r(a),()=>{i(a)}));return s.next=a=>{if(t!==a){t=a;for(const c of n)c.next(a)}},s.get=()=>t,s}function Ir(e){return qe(t=>{function n(r=0,i=e.op){const s=e.links[r];if(!s)throw new Error("No more links to execute - did you forget to add an ending link?");return s({op:i,next(a){return n(r+1,a)}})}return n().subscribe(t)})}function be(e){"@babel/helpers - typeof";return be=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},be(e)}function xr(e,t){if(be(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(be(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Or(e){var t=xr(e,"string");return be(t)=="symbol"?t:t+""}function K(e,t,n){return(t=Or(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dt(Object(n),!0).forEach(function(r){K(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function le(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function Nr(e){return typeof e=="function"}function Cr(){return Object.create(null)}const Ar=typeof Symbol=="function"&&!!Symbol.asyncIterator;function Lr(e){return Ar&&le(e)&&Symbol.asyncIterator in e}const Rr=e=>e(),Kt=()=>{},mt=e=>{Object.freeze&&Object.freeze(e)};function Ut(e,t,n){var r;const i=t.join(".");return(r=n[i])!==null&&r!==void 0||(n[i]=new Proxy(Kt,{get(s,a){if(!(typeof a!="string"||a==="then"))return Ut(e,[...t,a],n)},apply(s,a,c){const l=t[t.length-1];if(l==="valueOf"||l==="toString"||l==="toJSON")return`tRPC.proxy(${t.slice(0,-1).join(".")})`;let u={args:c,path:t};return l==="call"?u={args:c.length>=2?[c[1]]:[],path:t.slice(0,-1)}:l==="apply"&&(u={args:c.length>=2?c[1]:[],path:t.slice(0,-1)}),mt(u.args),mt(u.path),e(u)}})),n[i]}const zt=e=>Ut(e,[],Cr()),qr=e=>new Proxy(Kt,{get(t,n){if(n!=="then")return e(n)}});function _e(e){"@babel/helpers - typeof";return _e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_e(e)}function $r(e,t){if(_e(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(_e(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Dr(e){var t=$r(e,"string");return _e(t)=="symbol"?t:t+""}function Ke(e,t,n){return(t=Dr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ee(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pt(Object(n),!0).forEach(function(r){Ke(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var jr=class extends Error{constructor(e){super(Mr(e)),Object.assign(this,e)}};function Mr(e){if("message"in e)return String(e.message)}function Br(e){if(e instanceof Error)return e;const t=typeof e;if(!(t==="undefined"||t==="function"||e===null)){if(t!=="object")return new Error(String(e));if(le(e))return new jr(e)}}var ht=class extends Error{constructor(e){var t,n,r;const i=Br(e.cause),s=(t=(n=e.message)!==null&&n!==void 0?n:i?.message)!==null&&t!==void 0?t:e.code;super(s,{cause:i}),Ke(this,"cause",void 0),Ke(this,"code",void 0),this.code=e.code,this.name="TRPCError",(r=this.cause)!==null&&r!==void 0||(this.cause=i)}};function Fr(e,t){if("error"in e){const n=t.deserialize(e.error);return{ok:!1,error:Ee(Ee({},e),{},{error:n})}}return{ok:!0,result:Ee(Ee({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var je=class extends Error{constructor(){super("Unable to transform response from server")}};function Wr(e,t){let n;try{n=Fr(e,t)}catch{throw new je}if(!n.ok&&(!le(n.error.error)||typeof n.error.error.code!="number"))throw new je;if(n.ok&&!le(n.result))throw new je;return n}function Kr(e){return typeof e=="function"}async function Ur(e,t){const{_def:n}=e;let r=n.procedures[t];for(;!r;){const i=Object.keys(n.lazy).find(s=>t===s||t.startsWith(s+"."));if(!i)return null;await n.lazy[i].load(),r=n.procedures[t]}return r}async function zr(e){const{type:t,path:n}=e,r=await Ur(e.router,n);if(!r||!Kr(r)||r._def.type!==t&&!e.allowMethodOverride)throw new ht({code:"NOT_FOUND",message:`No "${t}"-procedure on path "${n}"`});if(r._def.type!==t&&e.allowMethodOverride&&r._def.type==="subscription")throw new ht({code:"METHOD_NOT_SUPPORTED",message:"Method override is not supported for subscriptions"});return r(e)}function Qr(e){return e instanceof Ce}function Hr(e){return le(e)&&le(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function Vr(e,t){return typeof e=="string"?e:le(e)&&typeof e.message=="string"?e.message:t}var Ce=class xe extends Error{constructor(t,n){var r,i;const s=n?.cause;super(t,{cause:s}),K(this,"cause",void 0),K(this,"shape",void 0),K(this,"data",void 0),K(this,"meta",void 0),this.meta=n?.meta,this.cause=s,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(i=n.result)===null||i===void 0?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,xe.prototype)}static from(t,n={}){const r=t;return Qr(r)?(n.meta&&(r.meta=$($({},r.meta),n.meta)),r):Hr(r)?new xe(r.error.message,$($({},n),{},{result:r,cause:n.cause})):new xe(Vr(r,"Unknown error"),$($({},n),{},{cause:r}))}};function Gr(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}const ft=e=>typeof e=="function";function Jr(e){if(e)return e;if(typeof window<"u"&&ft(window.fetch))return window.fetch.bind(window);if(typeof globalThis<"u"&&ft(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function Yr(...e){const t=new AbortController,n=e.length;let r=0;const i=()=>{++r===n&&t.abort()};for(const s of e)s?.aborted?i():s?.addEventListener("abort",i,{once:!0});return t.signal}function Zr(...e){const t=new AbortController;for(const n of e)n?.aborted?t.abort():n?.addEventListener("abort",()=>t.abort(),{once:!0});return t.signal}function Xr(e){return{url:e.url.toString(),fetch:e.fetch,transformer:Gr(e.transformer),methodOverride:e.methodOverride}}function eo(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];t[n]=r}return t}const to={query:"GET",mutation:"POST",subscription:"PATCH"};function Qt(e){return"input"in e?e.transformer.input.serialize(e.input):eo(e.inputs.map(t=>e.transformer.input.serialize(t)))}const Ht=e=>{const t=e.url.split("?");let n=t[0].replace(/\/$/,"")+"/"+e.path;const r=[];if(t[1]&&r.push(t[1]),"inputs"in e&&r.push("batch=1"),e.type==="query"||e.type==="subscription"){const i=Qt(e);i!==void 0&&e.methodOverride!=="POST"&&r.push(`input=${encodeURIComponent(JSON.stringify(i))}`)}return r.length&&(n+="?"+r.join("&")),n},no=e=>{if(e.type==="query"&&e.methodOverride!=="POST")return;const t=Qt(e);return t!==void 0?JSON.stringify(t):void 0},ro=e=>ao($($({},e),{},{contentTypeHeader:"application/json",getUrl:Ht,getBody:no}));var oo=class extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}};const io=e=>{var t;if(e?.aborted)throw(t=e.throwIfAborted)===null||t===void 0||t.call(e),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new oo};async function so(e){var t,n;io(e.signal);const r=e.getUrl(e),i=e.getBody(e),s=(t=e.methodOverride)!==null&&t!==void 0?t:to[e.type],a=await(async()=>{const l=await e.headers();return Symbol.iterator in l?Object.fromEntries(l):l})(),c=$($($({},e.contentTypeHeader&&s!=="GET"?{"content-type":e.contentTypeHeader}:{}),e.trpcAcceptHeader?{[(n=e.trpcAcceptHeaderKey)!==null&&n!==void 0?n:"trpc-accept"]:e.trpcAcceptHeader}:void 0),a);return Jr(e.fetch)(r,{method:s,signal:e.signal,body:i,headers:c})}async function ao(e){const t={},n=await so(e);t.response=n;const r=await n.json();return t.responseJSON=r,{json:r,meta:t}}const yt=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function vt(e){let t=null,n=null;const r=()=>{clearTimeout(n),n=null,t=null};function i(c){const l=[[]];let u=0;for(;;){const p=c[u];if(!p)break;const h=l[l.length-1];if(p.aborted){var d;(d=p.reject)===null||d===void 0||d.call(p,new Error("Aborted")),u++;continue}if(e.validate(h.concat(p).map(f=>f.key))){h.push(p),u++;continue}if(h.length===0){var m;(m=p.reject)===null||m===void 0||m.call(p,new Error("Input is too big for a single dispatch")),u++;continue}l.push([])}return l}function s(){const c=i(t);r();for(const l of c){if(!l.length)continue;const u={items:l};for(const d of l)d.batch=u;e.fetch(u.items.map(d=>d.key)).then(async d=>{await Promise.all(d.map(async(p,h)=>{const f=u.items[h];try{var O;const j=await Promise.resolve(p);(O=f.resolve)===null||O===void 0||O.call(f,j)}catch(j){var D;(D=f.reject)===null||D===void 0||D.call(f,j)}f.batch=null,f.reject=null,f.resolve=null}));for(const p of u.items){var m;(m=p.reject)===null||m===void 0||m.call(p,new Error("Missing result")),p.batch=null}}).catch(d=>{for(const p of u.items){var m;(m=p.reject)===null||m===void 0||m.call(p,d),p.batch=null}})}}function a(c){var l;const u={aborted:!1,key:c,batch:null,resolve:yt,reject:yt},d=new Promise((m,p)=>{var h;u.reject=p,u.resolve=m,(h=t)!==null&&h!==void 0||(t=[]),t.push(u)});return(l=n)!==null&&l!==void 0||(n=setTimeout(s)),d}return{load:a}}function co(e){var t,n;const r=Xr(e),i=(t=e.maxURLLength)!==null&&t!==void 0?t:1/0,s=(n=e.maxItems)!==null&&n!==void 0?n:1/0;return()=>{const a=l=>({validate(u){if(i===1/0&&s===1/0)return!0;if(u.length>s)return!1;const d=u.map(p=>p.path).join(","),m=u.map(p=>p.input);return Ht($($({},r),{},{type:l,path:d,inputs:m,signal:null})).length<=i},async fetch(u){const d=u.map(f=>f.path).join(","),m=u.map(f=>f.input),p=Yr(...u.map(f=>f.signal)),h=await ro($($({},r),{},{path:d,inputs:m,type:l,headers(){return e.headers?typeof e.headers=="function"?e.headers({opList:u}):e.headers:{}},signal:p}));return(Array.isArray(h.json)?h.json:u.map(()=>h.json)).map(f=>({meta:h.meta,json:f}))}}),c={query:vt(a("query")),mutation:vt(a("mutation"))};return({op:l})=>qe(u=>{if(l.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const d=new AbortController,m=c[l.type].load($($({},l),{},{signal:Zr(l.signal,d.signal)}));let p=!1,h;return m.then(f=>{p=!0,h=f;const O=Wr(f.json,r.transformer.output);if(!O.ok){u.error(Ce.from(O.error,{meta:f.meta}));return}u.next({context:f.meta,result:O.result}),u.complete()}).catch(f=>{p=!0,u.error(Ce.from(f,{meta:h?.meta}))}),()=>{p||d.abort()}})}}const Vt=(e,...t)=>typeof e=="function"?e(...t):e;function lo(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function uo(e){const t=await Vt(e.url);return e.connectionParams?t+`${t.includes("?")?"&":"?"}connectionParams=1`:t}async function mo(e,t){const n={method:"connectionParams",data:await Vt(e)};return t.encode(n)}function po(e){const{promise:t,resolve:n,reject:r}=lo();return e.addEventListener("open",()=>{e.removeEventListener("error",r),n()}),e.addEventListener("error",r),t}function ho(e,{intervalMs:t,pongTimeoutMs:n}){let r,i;function s(){r=setTimeout(()=>{e.send("PING"),i=setTimeout(()=>{e.close()},n)},t)}function a(){clearTimeout(r),s()}function c(){clearTimeout(i),a()}e.addEventListener("open",s),e.addEventListener("message",({data:l})=>{clearTimeout(r),s(),l==="PONG"&&c()}),e.addEventListener("close",()=>{clearTimeout(r),clearTimeout(i)})}var fo=class Ue{constructor(t){var n;if(K(this,"id",++Ue.connectCount),K(this,"WebSocketPonyfill",void 0),K(this,"urlOptions",void 0),K(this,"keepAliveOpts",void 0),K(this,"encoder",void 0),K(this,"wsObservable",Tr(null)),K(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){if(this.openPromise)return this.openPromise;this.id=++Ue.connectCount;const t=uo(this.urlOptions).then(n=>new this.WebSocketPonyfill(n));this.openPromise=t.then(async n=>{this.ws=n,n.binaryType="arraybuffer",n.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),this.keepAliveOpts.enabled&&ho(n,this.keepAliveOpts),n.addEventListener("close",()=>{this.ws===n&&(this.ws=null)}),await po(n),this.urlOptions.connectionParams&&n.send(await mo(this.urlOptions.connectionParams,this.encoder))});try{await this.openPromise}finally{this.openPromise=null}}async close(){try{await this.openPromise}finally{var t;(t=this.ws)===null||t===void 0||t.close()}}};K(fo,"connectCount",0);var Gt=class{constructor(e){K(this,"links",void 0),K(this,"runtime",void 0),K(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return Ir({links:this.links,op:$($({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(Er())}async requestAsPromise(e){try{const t=this.$request(e);return(await Pr(t)).result.data}catch(t){throw Ce.from(t)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(r){switch(r.result.type){case"state":var i;(i=n.onConnectionStateChange)===null||i===void 0||i.call(n,r.result);break;case"started":var s;(s=n.onStarted)===null||s===void 0||s.call(n,{context:r.context});break;case"stopped":var a;(a=n.onStopped)===null||a===void 0||a.call(n);break;case"data":case void 0:var c;(c=n.onData)===null||c===void 0||c.call(n,r.result.data)}},error(r){var i;(i=n.onError)===null||i===void 0||i.call(n,r)},complete(){var r;(r=n.onComplete)===null||r===void 0||r.call(n)}})}};const Jt=Symbol.for("trpc_untypedClient"),yo={query:"query",mutate:"mutation",subscribe:"subscription"},vo=e=>yo[e];function go(e){const t=zt(({path:n,args:r})=>{const i=[...n],s=vo(i.pop()),a=i.join(".");return e[s](a,...r)});return qr(n=>n===Jt?e:t[n])}function bo(e){return go(new Gt(e))}function _o(e){return e[Jt]}function we(e){"@babel/helpers - typeof";return we=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},we(e)}function wo(e,t){if(we(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(we(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function So(e){var t=wo(e,"string");return we(t)=="symbol"?t:t+""}function ko(e,t,n){return(t=So(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gt(Object(n),!0).forEach(function(r){ko(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Po(e){var t,n,r,i=2;for(typeof Symbol<"u"&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&(t=e[n])!=null)return t.call(e);if(r&&(t=e[r])!=null)return new Oe(t.call(e));n="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function Oe(e){function t(n){if(Object(n)!==n)return Promise.reject(new TypeError(n+" is not an object."));var r=n.done;return Promise.resolve(n.value).then(function(i){return{value:i,done:r}})}return Oe=function(r){this.s=r,this.n=r.next},Oe.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(r){var i=this.s.return;return i===void 0?Promise.resolve({value:r,done:!0}):t(i.apply(this.s,arguments))},throw:function(r){var i=this.s.return;return i===void 0?Promise.reject(r):t(i.apply(this.s,arguments))}},new Oe(e)}function Eo(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function To(e,t){if(e==null)return{};var n,r,i=Eo(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const Io=["cursor","direction"];function $e(e){return{path:e.path.join(".")}}function xo(e){return e.length>=3}function Oo(e){return xo(e)?{type:"prefixed",prefix:e[0],path:e[1],args:e[2]}:{type:"unprefixed",prefix:void 0,path:e[0],args:e[1]}}function et(e,t,n){var r;const i=Oo(e);let s=(r=i.args)===null||r===void 0?void 0:r.input;if(n){var a,c;s=k(k(k({},(a=(c=i.args)===null||c===void 0?void 0:c.input)!==null&&a!==void 0?a:{}),n.pageParam!==void 0?{cursor:n.pageParam}:{}),{},{direction:n.direction})}return[i.path.join("."),s,t?.trpc]}async function No(e,t,n){const r=t.getQueryCache().build(t,{queryKey:n});r.setState({data:[],status:"success"});const i=[];var s=!1,a=!1,c;try{for(var l=Po(e),u;s=!(u=await l.next()).done;s=!1){const d=u.value;i.push(d),r.setState({data:[...i]})}}catch(d){a=!0,c=d}finally{try{s&&l.return!=null&&await l.return()}finally{if(a)throw c}}return i}function re(e){const t=Rr(()=>{const{input:n,type:r}=e,i=e.path.flatMap(s=>s.split("."));if(!n&&r==="any")return i.length?[i]:[];if(r==="infinite"&&le(n)&&("direction"in n||"cursor"in n)){const{cursor:s,direction:a}=n;return[i,{input:To(n,Io),type:"infinite"}]}return[i,k(k({},typeof n<"u"&&n!==de&&{input:n}),r&&r!=="any"&&{type:r})]});return e.prefix&&t.unshift([e.prefix]),t}function Yt(e){const t=[e.path.flatMap(n=>n.split("."))];return e.prefix&&t.unshift([e.prefix]),t}function tt(e){return Nr(e)?e():e}function Co(e){var t;const{input:n,query:r,path:i,queryKey:s,opts:a}=e,c=n===de,l=async u=>{var d;const m=k(k({},a),{},{trpc:k(k({},a?.trpc),!(a==null||(d=a.trpc)===null||d===void 0)&&d.abortOnUnmount?{signal:u.signal}:{signal:null})});return await r(...et(s,m,{direction:u.direction,pageParam:u.pageParam}))};return Object.assign(On(k(k({},a??{}),{},{queryKey:s,queryFn:c?de:l,initialPageParam:(t=a?.initialCursor)!==null&&t!==void 0?t:n?.cursor})),{trpc:$e({path:i})})}function Ao(e){var t,n;const{mutate:r,path:i,prefix:s,opts:a,overrides:c}=e,l=tt(e.queryClient),u=Yt({path:i,prefix:(t=a?.keyPrefix)!==null&&t!==void 0?t:s}),d=l.defaultMutationOptions(l.getMutationDefaults(u)),m=(n=c?.onSuccess)!==null&&n!==void 0?n:(h=>h.originalFn()),p=async h=>await r(...et([...u,{input:h}],a));return k(k({},a),{},{mutationKey:u,mutationFn:p,onSuccess(...h){var f,O;return m({originalFn:()=>{var j,H,A;return(j=a==null||(H=a.onSuccess)===null||H===void 0?void 0:H.call(a,...h))!==null&&j!==void 0?j:d==null||(A=d.onSuccess)===null||A===void 0?void 0:A.call(d,...h)},queryClient:l,meta:(f=(O=a?.meta)!==null&&O!==void 0?O:d?.meta)!==null&&f!==void 0?f:{}})},trpc:$e({path:i})})}function Lo(e){const{input:t,query:n,path:r,queryKey:i,opts:s}=e,a=tt(e.queryClient),c=t===de,l=async u=>{var d;const m=k(k({},s),{},{trpc:k(k({},s?.trpc),!(s==null||(d=s.trpc)===null||d===void 0)&&d.abortOnUnmount?{signal:u.signal}:{signal:null})}),p=u.queryKey,h=await n(...et(p,m));return Lr(h)?No(h,a,p):h};return Object.assign(Nn(k(k({},s),{},{queryKey:i,queryFn:c?de:l})),{trpc:$e({path:r})})}const Ro=e=>{const{subscribe:t,path:n,queryKey:r,input:i,opts:s={}}=e,a="enabled"in s?!!s.enabled:i!==de,c=l=>t(n.join("."),i===de?void 0:i,l);return k(k({},s),{},{enabled:a,subscribe:c,queryKey:r,trpc:$e({path:n})})};function qo(e){const t=e.keyPrefix,n=r=>(i,s,a)=>"router"in e?Promise.resolve(tt(e.ctx)).then(c=>zr({router:e.router,path:i,getRawInput:async()=>s,ctx:c,type:r,signal:void 0,batchIndex:0})):(e.client instanceof Gt?e.client:_o(e.client))[r](i,s,a);return zt(({args:r,path:i})=>{const s=[...i],a=s.pop(),[c,l]=r;return{"~types":void 0,pathKey:()=>re({path:s,type:"any",prefix:t}),pathFilter:()=>k(k({},c),{},{queryKey:re({path:s,type:"any",prefix:t})}),queryOptions:()=>Lo({input:c,opts:l,path:s,queryClient:e.queryClient,queryKey:re({path:s,input:c,type:"query",prefix:t}),query:n("query")}),queryKey:()=>re({path:s,input:c,type:"query",prefix:t}),queryFilter:()=>k(k({},l),{},{queryKey:re({path:s,input:c,type:"query",prefix:t})}),infiniteQueryOptions:()=>Co({input:c,opts:l,path:s,queryKey:re({path:s,input:c,type:"infinite",prefix:t}),query:n("query")}),infiniteQueryKey:()=>re({path:s,input:c,type:"infinite",prefix:t}),infiniteQueryFilter:()=>k(k({},l),{},{queryKey:re({path:s,input:c,type:"infinite",prefix:t})}),mutationOptions:()=>{var u;return Ao({opts:c,path:s,prefix:t,queryClient:e.queryClient,mutate:n("mutation"),overrides:(u=e.overrides)===null||u===void 0?void 0:u.mutations})},mutationKey:()=>Yt({path:s,prefix:t}),subscriptionOptions:()=>Ro({opts:l,path:s,input:c,queryKey:re({path:s,input:c,type:"any",prefix:t}),subscribe:n("subscription")})}[a]()})}function $o(){const e=oe(null),t=oe(null),n=s=>{const a=pe(()=>qo({client:s.trpcClient,queryClient:s.queryClient,keyPrefix:s.keyPrefix}),[s.trpcClient,s.queryClient,s.keyPrefix]);return M(e.Provider,{value:s.trpcClient},M(t.Provider,{value:a},s.children))};n.displayName="TRPCProvider";function r(){const s=ie(t);if(!s)throw new Error("useTRPC() can only be used inside of a <TRPCProvider>");return s}function i(){const s=ie(e);if(!s)throw new Error("useTRPCClient() can only be used inside of a <TRPCProvider>");return s}return{TRPCProvider:n,useTRPC:r,useTRPCClient:i}}const ze={lan:new Set,animepahe:new Set,jasmr:new Set};function Qe(e){for(const t of[...ze[e]])try{t()}catch(n){console.error(`auth-bus listener failed (${e}):`,n)}}function Zt(e,t){return ze[e].add(t),()=>{ze[e].delete(t)}}const Do=e=>new Promise(t=>setTimeout(t,e));async function jo(e,t){const n={"Content-Type":"application/json"},r=typeof e=="string"?e:e.toString();if(r.startsWith("/")||typeof window<"u"&&r.startsWith(window.location.origin)){const a=localStorage.getItem("animepahe_ua"),c=localStorage.getItem("animepahe_cookie"),l=localStorage.getItem("jasmr_ua"),u=localStorage.getItem("jasmr_cookie");a&&(n["x-animepahe-ua"]=a),c&&(n["x-animepahe-cookie"]=c),l&&(n["x-jasmr-ua"]=l),u&&(n["x-jasmr-cookie"]=u)}let s=await fetch(e,{...t,headers:{...n,...t?.headers}});for(let a=0;s.status===503&&a<8;a++)await Do(Math.min(500*2**a,4e3)),s=await fetch(e,{...t,headers:{...n,...t?.headers}});if(s.status===401)try{(await s.clone().json())?.error==="LAN_AUTH_REQUIRED"&&Qe("lan")}catch{}return await Mo(s),s}async function Mo(e){try{if(!e.headers.get("content-type")?.includes("json"))return;const t=await e.clone().json(),n=Array.isArray(t)?t:[t];for(const r of n){const i=r?.error;if(!i||typeof i!="object")continue;const s=i.data?.cause;(i.message==="AUTH_REQUIRED"||s?.code==="AUTH_REQUIRED")&&(s?.provider==="animepahe"||s?.provider==="jasmr")&&Qe(s.provider),(i.message==="LAN_AUTH_REQUIRED"||s?.code==="LAN_AUTH_REQUIRED")&&Qe("lan")}}catch{}}const{TRPCProvider:Bo,useTRPC:P}=$o(),U=bo({links:[co({url:"/api/trpc",fetch:jo})]}),ge=new Map,Fo=500,Wo=(e,t,n)=>{if(!e||e.trim()==="")return"/placeholder.svg";if(e.includes("/api/image-proxy")){let a=e;if(t&&!a.includes("w=")){const c=a.includes("?")?"&":"?";a+=`${c}w=${t}`}if(n&&!a.includes("h=")){const c=a.includes("?")?"&":"?";a+=`${c}h=${n}`}return a}let r=e;r.includes("aln.youtube-anime.com")&&(r=r.replace(/https?:\/\/allanime\.day\/aln\.youtube-anime\.com/,"https://aln.youtube-anime.com"),r.includes("/images/mcovers")&&(r=r.replace("/images/mcovers","/mcovers")),r.includes("/images/images2")&&(r=r.replace("/images/images2","/images2"))),r.includes("allanime.day/s4.anilist.co")&&(r=r.replace(/https?:\/\/allanime\.day\/s4\.anilist\.co/,"https://s4.anilist.co")),r.includes("wp.youtube-anime.com/s4.anilist.co")&&(r=r.replace(/https?:\/\/wp\.youtube-anime\.com\/s4\.anilist\.co/,"https://s4.anilist.co"));const i=`${r}-${t}-${n}`;if(ge.has(i))return ge.get(i);let s;if(r.startsWith("https://s4.anilist.co"))s=r,t&&(s+=`${s.includes("?")?"&":"?"}w=${t}`),n&&(s+=`${s.includes("?")?"&":"?"}h=${n}`);else if(r.includes("animepahe")){s=`/api/image-proxy?url=${encodeURIComponent(r)}`;const a=localStorage.getItem("animepahe_cookie"),c=localStorage.getItem("animepahe_ua");a&&(s+=`&cookie=${encodeURIComponent(a)}`),c&&(s+=`&ua=${encodeURIComponent(c)}`)}else if(r.startsWith("http"))s=`/api/image-proxy?url=${encodeURIComponent(r)}`,t&&(s+=`&w=${t}`),n?s+=`&h=${n}`:t||(s+="&w=300");else{const c=`${r.startsWith("mcovers")||r.startsWith("images2")?"https://aln.youtube-anime.com":"https://aln.youtube-anime.com/images"}/${r}`;s=`/api/image-proxy?url=${encodeURIComponent(c)}`,t&&(s+=`&w=${t}`),n?s+=`&h=${n}`:t||(s+="&w=300")}return ge.size>Fo&&ge.clear(),ge.set(i,s),s},Dc=e=>{if(isNaN(e)||e<=0)return"00:00";const t=new Date(e*1e3).toISOString().slice(11,19);return parseInt(t.slice(0,2),10)>0?t:t.slice(3)};function jc(e){return e?e.replace(/<[^>]*>?/gm,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").trim():""}function Mc(e){return e==null?e:e>10?Number((e/10).toFixed(1)):e}const Xt=oe(void 0),Ko=()=>{const e=ie(Xt);if(e===void 0)throw new Error("useTitlePreference must be used within a TitlePreferenceProvider");return e},Bc=()=>{const e=P();return Q({...e.data.spotlight.queryOptions(),staleTime:1e3*60*5,retry:1})},Fc=(e="TRENDING_DESC",t=10)=>Ze({queryKey:["trendingList",e,t],queryFn:({pageParam:n=1})=>U.data.popularList.query({sort:e,page:n,size:t}),initialPageParam:1,getNextPageParam:(n,r)=>n.length>=t?r.length+1:void 0}),Wc=(e="TV",t=12)=>Ze({queryKey:["latestReleases",e,t],queryFn:({pageParam:n=1})=>U.data.latestReleases.query({format:e,page:n,size:t}),initialPageParam:1,getNextPageParam:(n,r)=>n.length>=t?r.length+1:void 0}),Kc=(e,t="TV",n=!0)=>{const r=P();return Q({...r.data.seasonal.queryOptions({page:e,format:t}),enabled:n,staleTime:1e3*60*5})},Uo=["query","sortBy","type","status","season","year","country","genres","excludeGenres","excludeTags","minScore","minEpisodes","adult"],Uc=(e,t,n=14)=>{const r=P(),i=new URLSearchParams(e),s={page:t,limit:n};for(const a of Uo){const c=i.get(a);c!==null&&(s[a]=c)}return Q({...r.data.search.queryOptions(s),enabled:e!=null})},zc=()=>{const e=P();return Q(e.queue.list.queryOptions())},zo=()=>{const e=P(),t=z();return Y(e.queue.add.mutationOptions({onSuccess:n=>{n.queued?g.success("Added to queue"):g.success("Removed from queue"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]})},onError:n=>{g.error(`Failed to update queue: ${n.message}`)}}))},Qc=()=>{const e=P(),t=z();return Y(e.queue.remove.mutationOptions({onSuccess:()=>{g.success("Removed from queue"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},Hc=(e,t=!0)=>Q({queryKey:["queue-remaining",e],queryFn:()=>U.watchlist.queueRemaining.query({showId:e}),enabled:!!e&&t,staleTime:1e3*60}),Vc=()=>{const e=P(),t=z();return Y(e.queue.addBatch.mutationOptions({onSuccess:(n,r)=>{const i=n.added??r.episodeNumbers.length;g.success(`${i} ${i===1?"episode":"episodes"} added to queue`),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]})},onError:n=>{g.error(`Failed to update queue: ${n.message}`)}}))},Gc=()=>{const e=P(),t=z();return Y(e.queue.removeMany.mutationOptions({onSuccess:()=>{g.success("Removed from queue"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},Jc=()=>{const e=P(),t=z();return Y(e.queue.clear.mutationOptions({onSuccess:()=>{g.success("Queue cleared"),t.invalidateQueries(e.queue.pathFilter()),t.invalidateQueries({queryKey:["queue-remaining"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to clear queue: ${n.message}`)}}))},Yc=()=>{const e=P(),t=z(),n=e.queue.list.queryOptions().queryKey;return Y(e.queue.reorder.mutationOptions({onMutate:async r=>{await t.cancelQueries({queryKey:n});const i=t.getQueryData(n);return t.setQueryData(n,s=>{if(!s)return s;const a=new Map(s.map(c=>[c.id,c]));return r.map((c,l)=>{const u=a.get(c.id??-1);return u?{...u,queue_order:l}:void 0}).filter(c=>!!c)}),{previousQueue:i}},onError:(r,i,s)=>{s?.previousQueue&&t.setQueryData(n,s.previousQueue)},onSettled:()=>{t.invalidateQueries(e.queue.pathFilter())}}))},Qo=["status","showMature","query","type","season","year","genres","excludeGenres","sortBy","titlePreference"];function nt(e,t,n){const r=new URLSearchParams(e),i={page:t,limit:n};for(const s of Qo){const a=r.get(s);a!==null&&(i[s]=a)}return i}const Zc=(e,t="",n,r=14)=>Q({queryKey:["watchlist",e,t,n,r],queryFn:async()=>{const i=new URLSearchParams(t);return i.set("status",e),await U.watchlist.list.query(nt(i.toString(),n,r))}}),Xc=(e="")=>Ze({queryKey:["allContinueWatching",e],queryFn:async({pageParam:t=1})=>await U.watchlist.continueWatchingAll.query(nt(e,t,14)),initialPageParam:1,getNextPageParam:t=>{if(!(t.data.length===0||t.page*t.limit>=t.total))return t.page+1},select:t=>({...t,pages:t.pages.flatMap(n=>n.data)})}),el=(e="",t,n=14)=>Q({queryKey:["allContinueWatching",e,t,n],queryFn:async()=>await U.watchlist.continueWatchingAll.query(nt(e,t,n))}),tl=()=>{const e=P(),t=z();return Y(e.watchlist.remove.mutationOptions({onSuccess:()=>{g.success("Removed from watchlist"),t.invalidateQueries(e.watchlist.pathFilter()),t.invalidateQueries({queryKey:["watchlist"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},nl=()=>{const e=P(),t=z();return Y(e.watchlist.batchStatus.mutationOptions({onSuccess:n=>{g.success(`Status updated for ${n.updated??0} items`),t.invalidateQueries(e.watchlist.pathFilter()),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to update statuses: ${n.message}`)}}))},rl=()=>{const e=P(),t=z();return Y(e.watchlist.removeMany.mutationOptions({onSuccess:n=>{const r=n.removed??0;g.success(`Removed ${r} ${r===1?"item":"items"} from watchlist`),t.invalidateQueries(e.watchlist.pathFilter()),t.invalidateQueries({queryKey:["watchlist"]}),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},ol=()=>{const e=P(),t=z();return Y(e.continueWatching.removeMany.mutationOptions({onSuccess:n=>{const r=n.removed??0;g.success(`Removed ${r} ${r===1?"item":"items"} from continue watching`),t.invalidateQueries(e.continueWatching.pathFilter()),t.invalidateQueries({queryKey:["allContinueWatching"]})},onError:n=>{g.error(`Failed to remove: ${n.message}`)}}))},en=(e=!0)=>{const t=P();return Q({...t.notifications.list.queryOptions(),enabled:e,refetchInterval:3e4})},tn=(e=!0)=>{const t=P();return Q({...t.data.systemNotifications.queryOptions(),enabled:e,refetchInterval:3e4})},nn=(e=!0)=>{const t=P();return Q({...t.discovery.status.queryOptions(),enabled:e,refetchInterval:n=>n.state.data?.running?2e3:!1})},Ho=()=>{const e=P(),t=z(),n=e.discovery.status.queryOptions().queryKey;return Y(e.discovery.refresh.mutationOptions({onSuccess:r=>{t.setQueryData(n,{running:r.running,state:r.state,total:r.total,done:r.done,lastRunAt:r.lastRunAt}),t.invalidateQueries(e.notifications.pathFilter()),t.invalidateQueries({queryKey:["notifications"]})},onError:()=>{t.invalidateQueries({queryKey:n})}}))},Vo=()=>{const e=P(),t=z();return Y(e.notifications.dismiss.mutationOptions({onSuccess:()=>{t.invalidateQueries(e.notifications.pathFilter())}}))},Go=()=>{const e=P(),t=z();return Y(e.notifications.clearAll.mutationOptions({onSuccess:()=>{t.invalidateQueries(e.notifications.pathFilter())}}))},il=()=>{const e=P();return Q({...e.continueWatching.thisWeek.queryOptions(),staleTime:1e3*60*5})},sl=()=>{const e=P();return Q({...e.data.genresAndTags.queryOptions(),staleTime:1e3*60*60})},al=()=>Q({queryKey:["genreCards"],queryFn:()=>U.insights.genreCards.query()}),Jo="_container_z68uz_1",Yo="_bellBtn_z68uz_7",Zo="_badge_z68uz_56",Xo="_dropdown_z68uz_96",ei="_dropdownHeader_z68uz_127",ti="_clearAllBtn_z68uz_141",ni="_discoveryStatusRow_z68uz_156",ri="_statusDot_z68uz_167",oi="_statusDotRunning_z68uz_174",ii="_statusDotOk_z68uz_179",si="_statusDotInfo_z68uz_183",ai="_statusDotError_z68uz_187",ci="_statusDotIdle_z68uz_191",li="_list_z68uz_205",ui="_item_z68uz_219",di="_thumbnail_z68uz_234",mi="_itemInfo_z68uz_243",pi="_itemTitle_z68uz_248",hi="_itemMeta_z68uz_259",fi="_systemItemMeta_z68uz_269",yi="_removeItem_z68uz_286",vi="_queueItem_z68uz_316",gi="_emptyState_z68uz_320",y={container:Jo,bellBtn:Yo,badge:Zo,dropdown:Xo,dropdownHeader:ei,clearAllBtn:ti,discoveryStatusRow:ni,statusDot:ri,statusDotRunning:oi,statusDotOk:ii,statusDotInfo:si,statusDotError:ai,statusDotIdle:ci,list:li,item:ui,thumbnail:di,itemInfo:mi,itemTitle:pi,itemMeta:hi,systemItemMeta:fi,removeItem:yi,queueItem:vi,emptyState:gi},bi=({notification:e})=>{const t=Vo(),n=zo(),[r,i]=Je.useState(!1),s=d=>{d.preventDefault(),d.stopPropagation(),t.mutate({showId:e.showId,episodeNumber:e.episodeNumber})},a=()=>{t.mutate({showId:e.showId,episodeNumber:e.episodeNumber})},c=d=>{d.preventDefault(),d.stopPropagation(),i(!0),n.mutate({showId:e.showId,episodeNumber:e.episodeNumber,showName:e.name,showThumbnail:e.thumbnail,nativeName:e.nativeName,englishName:e.englishName}),t.mutate({showId:e.showId,episodeNumber:e.episodeNumber}),window.setTimeout(()=>i(!1),1e3)},{titlePreference:l}=Ko(),u=l==="nativeName"?e.nativeName||e.name:l==="englishName"&&e.englishName||e.name;return o(J,{to:`/watch/${e.showId}/${e.episodeNumber}`,className:y.item,onClick:a,children:[o("img",{src:Wo(e.thumbnail,48,64),alt:e.name,className:y.thumbnail,loading:"lazy",decoding:"async"}),o("div",{className:y.itemInfo,children:[o("span",{className:y.itemTitle,children:u}),o("span",{className:y.itemMeta,children:["New Episode ",e.episodeNumber]})]}),o("button",{className:`${y.removeItem} ${y.queueItem}`,onClick:c,"aria-label":"Add notification to queue",children:r?o(v,{name:"check"}):o(v,{name:"plus"})}),o("button",{className:y.removeItem,onClick:s,"aria-label":"Remove notification",children:o(v,{name:"times"})})]})};function Me({width:e="100%",height:t="1em",variant:n="rectangular",className:r="",style:i}){return o("div",{className:`skeleton skeleton-${n} ${r}`,style:{width:e,height:t,...i}})}const _i=({count:e=3})=>o(G,{children:Array.from({length:e}).map((t,n)=>o("div",{className:y.item,style:{borderBottom:"1px solid var(--border-primary)",pointerEvents:"none"},children:[o("div",{className:y.thumbnail,style:{overflow:"hidden"},children:o(Me,{width:"100%",height:"100%",variant:"rectangular"})}),o("div",{className:y.itemInfo,children:[o(Me,{width:"80%",height:"1rem",variant:"text",style:{marginBottom:"4px"}}),o(Me,{width:"40%",height:"0.7rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},n))}),wi=()=>{const{data:e=[],isLoading:t}=en(),{data:n=[]}=tn(),{data:r}=nn(),i=Go(),s=z(),[a,c]=_(null);b(()=>{s.invalidateQueries({queryKey:["notifications"]})},[s]);const l=()=>{i.mutate(void 0)},u=n.find(d=>d.id===a)??null;return o("div",{className:y.dropdown,children:[o("div",{className:y.dropdownHeader,children:[o("h4",{children:"Notifications"}),e.length>0&&o("button",{className:y.clearAllBtn,onClick:l,children:"Clear All"})]}),o("div",{className:y.discoveryStatusRow,children:r?.running?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotRunning}`,"aria-hidden":"true"}),o("span",{children:r.total>0?`Checking ${Math.min(r.done,r.total)}/${r.total} shows...`:"Checking for new episodes..."})]}):r?.state==="complete"?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotOk}`,"aria-hidden":"true"}),o("span",{children:["Discovery complete — checked ",r.total," ",r.total===1?"show":"shows"]})]}):r?.state==="empty"?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotInfo}`,"aria-hidden":"true"}),o("span",{children:"No shows set to Watching — nothing to check"})]}):r?.state==="error"?o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotError}`,"aria-hidden":"true"}),o("span",{children:"Last check failed — will retry automatically"})]}):o(G,{children:[o("span",{className:`${y.statusDot} ${y.statusDotIdle}`,"aria-hidden":"true"}),o("span",{children:r?.lastRunAt?`Last checked ${Math.max(1,Math.round((Date.now()-r.lastRunAt)/1e3))}s ago`:"Auto-checks every few minutes"})]})}),o("div",{className:y.list,children:t&&n.length===0?o(_i,{count:4}):o(G,{children:[n.map(d=>o("div",{className:y.item,children:[o("div",{className:y.thumbnail,style:{background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:0,boxShadow:"none"},children:o(v,{name:"info-circle",size:32,color:"#6c9fff"})}),o("div",{className:y.itemInfo,children:[o("span",{className:y.itemTitle,children:d.title}),o("button",{type:"button",className:y.systemItemMeta,onClick:()=>c(d.id),title:"View full status",children:d.message.length>40?d.message.slice(0,40)+"…":d.message})]}),o("button",{className:y.removeItem,disabled:!0,style:{opacity:.3,cursor:"not-allowed"},"aria-hidden":"true",children:o(v,{name:"plus"})}),o("button",{className:y.removeItem,disabled:!0,style:{opacity:.3,cursor:"not-allowed"},"aria-hidden":"true",children:o(v,{name:"times"})})]},d.id)),n.length>0&&e.length>0&&o("div",{className:y.notificationDivider}),e.length>0?e.map(d=>o(bi,{notification:d},d.id)):!t&&n.length===0&&o("div",{className:y.emptyState,children:"No new notifications"})]})}),u&&Rt(o("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem",backdropFilter:"blur(3px)"},onClick:()=>c(null),children:o("div",{style:{backgroundColor:"var(--bg-secondary)",padding:"1.5rem",borderRadius:"var(--radius-lg)",maxWidth:"420px",width:"100%",boxShadow:"var(--shadow-xl)",border:"1px solid var(--border-primary)"},onClick:d=>d.stopPropagation(),children:[o("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem"},children:[o(v,{name:"info-circle",color:"#6c9fff"}),o("span",{style:{color:"#fff",fontWeight:600,fontSize:"1rem"},children:u.title})]}),o("p",{style:{color:"var(--text-secondary)",marginBottom:"1.5rem",lineHeight:1.5},children:u.message}),o("div",{style:{display:"flex",justifyContent:"flex-end"},children:o("button",{type:"button",onClick:()=>c(null),style:{background:"var(--primary-color)",color:"#fff",border:"none",padding:"0.5rem 1rem",borderRadius:"var(--radius-md)",cursor:"pointer",fontWeight:600},children:"OK"})})]})}),document.body)]})},Si=()=>{const[e,t]=_(!1),n=B(null),r=z(),i=P(),s=Ho(),{data:a=[]}=en(),{data:c=[]}=tn(),{data:l}=nn(),u=a.length+c.length,d=u>5?"5+":u,m=B(!1);b(()=>{const h=f=>{n.current&&!n.current.contains(f.target)&&t(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),b(()=>{const h=!!l?.running;m.current&&!h&&(r.invalidateQueries(i.notifications.pathFilter()),r.invalidateQueries(i.discovery.pathFilter())),m.current=h},[l?.running,r,i]);const p=()=>{const h=!e;t(h),h&&s.mutate()};return o("div",{className:y.container,ref:n,children:[o("button",{className:y.bellBtn,onClick:p,"aria-label":"Notifications",children:[o(v,{name:"bell"}),u>0&&o("span",{className:y.badge,children:d})]}),e&&o(wi,{})]})},rn=oe(void 0),on=()=>{const e=ie(rn);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},cl=[{id:"iris",label:"Taro (default)",blurb:"Deep purple",swatch:"#7d6df0"},{id:"mochi",label:"Mochi",blurb:"Monochrome pearl",swatch:"#f0f0f0"},{id:"sakura",label:"Sakura",blurb:"Soft pink",swatch:"#e0b0e0"}],bt={iris:"/logo.png",mochi:"/logo-mochi.png",sakura:"/logo-sakura.png"},sn=({className:e})=>{const{theme:t}=on(),n=bt[t]||bt.iris;return o("img",{src:n,alt:"dango",className:e,decoding:"async",style:{height:"var(--logo-height, 75px)",width:"auto",display:"block",objectFit:"contain"}})},an=oe(void 0),rt=()=>{const e=ie(an);if(e===void 0)throw new Error("useSidebar must be used within a SidebarProvider");return e},cn=oe(void 0),ln=()=>{const e=ie(cn);if(e===void 0)throw new Error("useContentType must be used within a ContentTypeProvider");return e},He="virtual-keyboard:hide",_t="virtual-keyboard:enabled-change",un="virtual_keyboard_enabled",ki=!1;function wt(){const e=localStorage.getItem(un);return e===null?ki:e==="true"}const St=e=>e instanceof HTMLInputElement&&e.type==="text"&&!e.disabled&&!e.readOnly;function Pi(){window.dispatchEvent(new CustomEvent(He))}function Ei(){const[e,t]=_(!1),[n,r]=_(wt),i=B(null);return b(()=>{const s=d=>{n&&St(d.target)&&(i.current=d.target,t(!0))},a=d=>{d.target===i.current&&window.setTimeout(()=>{if(St(document.activeElement)){i.current=document.activeElement,t(!0);return}i.current=null,t(!1)},0)},c=()=>{i.current=null,t(!1)},l=d=>{if(d.key!==un)return;const m=d.newValue==="true";r(m),m||c()},u=()=>{const d=wt();r(d),d||c()};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),window.addEventListener(He,c),window.addEventListener("storage",l),window.addEventListener(_t,u),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a),window.removeEventListener(He,c),window.removeEventListener("storage",l),window.removeEventListener(_t,u)}},[n]),{activeInputRef:i,isVisible:n&&e,hide:()=>t(!1)}}const Ti="_header_1elij_1",Ii="_hidden_1elij_21",xi="_scrolled_1elij_25",Oi="_logo_1elij_31",Ni="_headerInner_1elij_44",Ci="_leftSection_1elij_54",Ai="_desktopNav_1elij_60",Li="_navLink_1elij_67",Ri="_navLinkActive_1elij_83",qi="_rightSection_1elij_102",$i="_searchWrapper_1elij_108",Di="_searchInput_1elij_114",ji="_searchButton_1elij_144",Mi="_searchIcon_1elij_168",Bi="_profileBtn_1elij_178",Fi="_profileImg_1elij_211",Wi="_hamburgerBtn_1elij_217",Ki="_mobileSearchBar_1elij_245",Ui="_mobileSearchBarHidden_1elij_272",zi="_mobileSearchInner_1elij_289",Qi="_mobileSearchIcon_1elij_305",Hi="_mobileSearchInput_1elij_312",S={header:Ti,hidden:Ii,scrolled:xi,logo:Oi,headerInner:Ni,leftSection:Ci,desktopNav:Ai,navLink:Li,navLinkActive:Ri,rightSection:qi,searchWrapper:$i,searchInput:Di,searchButton:ji,searchIcon:Mi,profileBtn:Bi,profileImg:Fi,hamburgerBtn:Wi,mobileSearchBar:Ki,mobileSearchBarHidden:Ui,mobileSearchInner:zi,mobileSearchIcon:Qi,mobileSearchInput:Hi},Vi=async()=>{let e;try{e=await U.auth.syncSettings.query()}catch{return null}const t=e.actualActiveProvider;if(t==="github")try{const n=await U.auth.githubStatus.query();if(n.authenticated&&n.user)return{name:n.user.name||n.user.login,picture:n.user.avatarUrl,provider:"github"}}catch{}if(t==="google")try{const n=await U.auth.user.query();if(n)return{name:n.name,picture:n.picture,email:n.email,provider:"google"}}catch{}return null},Gi=()=>{const{toggleSidebar:e}=rt(),{contentType:t}=ln(),[n,r]=_(""),[i,s]=_(!0),[a,c]=_(!1),[l,u]=_(!0),[d,m]=_(!1),p=qt(),h=Ye(),f=B(null),O=B(!1),D=B(null),j=B(null),H=B(null),A=B(null),{data:R}=Q({queryKey:["sync-profile"],queryFn:Vi,staleTime:3e4});b(()=>{const N=window.visualViewport;if(!N)return;const V=()=>{A.current?.style.setProperty("--vv-top",`${N.offsetTop}px`)};return V(),N.addEventListener("scroll",V),N.addEventListener("resize",V),()=>{N.removeEventListener("scroll",V),N.removeEventListener("resize",V)}},[]),b(()=>{const N=()=>{f.current&&(window.clearTimeout(f.current),f.current=null)},V=()=>{O.current||(O.current=!0,D.current=requestAnimationFrame(()=>{O.current=!1,D.current=null;const ne=window.scrollY<=10;u(ve=>ve===ne?ve:ne),s(ve=>ve||!0),N(),ne||(f.current=window.setTimeout(()=>{s(!1)},2500))}))},st=ne=>{(ne.metaKey||ne.ctrlKey)&&ne.key==="k"?(ne.preventDefault(),E.current?.focus({preventScroll:!0})):ne.key==="Escape"&&document.activeElement===E.current&&E.current?.blur()};return window.addEventListener("scroll",V,{passive:!0}),window.addEventListener("keydown",st),()=>{window.removeEventListener("scroll",V),window.removeEventListener("keydown",st),N(),D.current!==null&&(cancelAnimationFrame(D.current),D.current=null),O.current=!1}},[a]);const E=Je.useRef(null),Z=()=>window.innerWidth<=1024,fe=()=>{Z()?(m(!0),setTimeout(()=>H.current?.focus({preventScroll:!0}),50)):document.activeElement===E.current&&n.trim()?De():E.current?.focus({preventScroll:!0})},X=N=>{j.current?.contains(N.relatedTarget)||m(!1)},ke=t==="manga"?"Search manga...":t==="tv"?"Search TV & movies...":t==="asmr"?"Search ASMR...":"Search anime...",ye=t==="manga"?{to:"/reading-list",label:"Reading List"}:t==="tv"?{to:"/tv-watchlist",label:"TV Watchlist"}:t==="asmr"?{to:"/listening-list",label:"Listening List"}:{to:"/watchlist",label:"Watchlist"},De=N=>{Pi();const V=n.trim();V&&p(t==="manga"?`/manga?q=${encodeURIComponent(V)}`:t==="tv"?`/tv-search?q=${encodeURIComponent(V)}`:t==="asmr"?`/asmr?q=${encodeURIComponent(V)}`:`/search?query=${encodeURIComponent(V)}`)};return o(G,{children:o("header",{ref:A,className:`${S.header} ${i?"":S.hidden} ${l?"":S.scrolled}`,children:[o("div",{className:S.headerInner,children:[o("div",{className:S.leftSection,children:[o("button",{className:S.hamburgerBtn,onClick:e,"aria-label":"Menu",children:o(v,{name:"bars"})}),o(J,{to:"/",className:S.logo,"aria-label":"Ani-Web Home",children:o(sn,{})}),o("nav",{className:S.desktopNav,children:[o(J,{to:"/",className:`${S.navLink} ${h.pathname==="/"?S.navLinkActive:""}`,children:"Home"}),o(J,{to:ye.to,className:`${S.navLink} ${h.pathname.startsWith(ye.to)?S.navLinkActive:""}`,children:ye.label}),t==="anime"&&o(J,{to:"/insights",className:`${S.navLink} ${h.pathname==="/insights"?S.navLinkActive:""}`,children:"Insights"}),o(J,{to:"/settings",className:`${S.navLink} ${h.pathname.startsWith("/settings")?S.navLinkActive:""}`,children:"Settings"})]})]}),o("div",{className:S.rightSection,children:[o("div",{className:S.searchWrapper,children:[o("input",{ref:E,type:"text","data-virtual-keyboard":"true",className:S.searchInput,placeholder:ke,value:n,onChange:N=>r(N.target.value),onFocus:()=>c(!0),onBlur:()=>c(!1),onKeyDown:N=>{N.key==="Enter"&&De()}}),o("button",{type:"button",className:S.searchButton,"aria-label":"Search",onMouseDown:N=>N.preventDefault(),onClick:fe,children:o(v,{name:"search",className:S.searchIcon})})]}),o(Si,{}),o(J,{to:"/settings?tab=sync",className:S.profileBtn,"aria-label":"Sync settings",children:R?.picture?o("img",{src:R.picture,alt:R.name,className:S.profileImg,referrerPolicy:"no-referrer",decoding:"async"}):R?.provider==="github"?o(v,{name:"github"}):o(v,{name:"cloud"})})]})]}),d&&o("div",{className:`${S.mobileSearchBar} ${i?"":S.mobileSearchBarHidden}`,ref:j,onBlur:X,children:o("div",{className:S.mobileSearchInner,children:[o(v,{name:"search",className:S.mobileSearchIcon}),o("input",{ref:H,type:"text","data-virtual-keyboard":"true",className:S.mobileSearchInput,placeholder:ke,value:n,onChange:N=>r(N.target.value),onKeyDown:N=>{N.key==="Enter"?(De(),m(!1)):N.key==="Escape"&&m(!1)}})]})})]})})},Ve="agreedToViewMature";function kt(){try{return localStorage.getItem(Ve)==="true"}catch{return!1}}function Ji(){const[e,t]=_(kt);b(()=>{const i=()=>t(kt());return window.addEventListener("storage",i),window.addEventListener("focus",i),()=>{window.removeEventListener("storage",i),window.removeEventListener("focus",i)}},[]);const n=F(()=>{try{localStorage.setItem(Ve,"true")}catch{}t(!0)},[]),r=F(()=>{try{localStorage.removeItem(Ve)}catch{}t(!1)},[]);return{hasConsent:e,grant:n,revoke:r}}const Yi="_sidebar_153jc_1",Zi="_open_153jc_20",Xi="_sidebarHeader_153jc_25",es="_closeBtn_153jc_33",ts="_logo_153jc_57",ns="_navSection_153jc_69",rs="_navLink_153jc_75",os="_active_153jc_108",is="_overlay_153jc_118",ss="_versionInfo_153jc_138",ee={sidebar:Yi,open:Zi,sidebarHeader:Xi,closeBtn:es,logo:ts,navSection:ns,navLink:rs,active:os,overlay:is,versionInfo:ss},as="dango-client",cs="3.4.6",ls="module",us={node:">=22.12.0"},ds={start:"vite",dev:"vite",build:"tsc && vite build",lint:"eslint .",test:"vitest run",preview:"vite preview","start:prod":"vite preview",format:"prettier --write ."},ms={"@floating-ui/react":"^0.27.20","@tanstack/react-query":"^5.99.2","@trpc/client":"11.19.0","@trpc/tanstack-react-query":"11.19.0","anime4k-webgpu-async":"^2.0.0","embla-carousel-react":"^8.6.0","hls.js":"^1.5.13",preact:"^10.29.1","react-hot-toast":"^2.6.0","react-router":"^8.3.0","react-simple-maps":"^5.0.3"},ps={"@preact/preset-vite":"^2.10.5","@webgpu/types":"^0.1.72","eslint-plugin-react-hooks":"^7.1.1","eslint-plugin-react-refresh":"^0.5.2",vite:"^7.3.1",vitest:"^5.0.0"},ot={name:as,private:!0,version:cs,type:ls,engines:us,scripts:ds,dependencies:ms,devDependencies:ps},hs=()=>{const{isOpen:e,setIsOpen:t}=rt(),{contentType:n}=ln(),{hasConsent:r}=Ji(),i=()=>{t(!1)},s=n==="manga",a=n==="tv",c=n==="asmr",l=[{to:"/",icon:o(v,{name:"home"}),label:"Home"},s?{to:"/manga",icon:o(v,{name:"book"}),label:"Manga"}:a?{to:"/tv-search",icon:o(v,{name:"tv"}),label:"TV and Movies"}:c?{to:"/asmr",icon:o(v,{name:"headphones"}),label:"ASMR"}:{to:"/search",icon:o(v,{name:"search"}),label:"Search"},s?{to:"/reading-list",icon:o(v,{name:"bookmark"}),label:"Reading List"}:a?{to:"/tv-watchlist",icon:o(v,{name:"clock"}),label:"TV Watchlist"}:c?{to:"/listening-list",icon:o(v,{name:"history"}),label:"Listening List"}:{to:"/watchlist",icon:o(v,{name:"clock"}),label:"Watchlist"},...n==="anime"?[{to:"/insights",icon:o(v,{name:"chart-pie"}),label:"Insights"}]:[],{to:"/trackers",icon:o(v,{name:"sync-alt"}),label:"Trackers"},{to:"/radio",icon:o(v,{name:"broadcast-tower"}),label:"Radio"},{to:"/music",icon:o(v,{name:"headphones"}),label:"Music"},...r?[{to:"/mature",icon:o(v,{name:"pepper-hot"}),label:"Mature"}]:[],{to:"/settings",icon:o(v,{name:"cog"}),label:"Settings"}];return o(G,{children:[o("aside",{className:`${ee.sidebar} ${e?ee.open:""} sidebar`,children:[o("div",{className:ee.sidebarHeader,children:[o("button",{className:ee.closeBtn,onClick:()=>t(!1),"aria-label":"Close menu",children:"×"}),o(J,{to:"/",className:ee.logo,onClick:i,children:o(sn,{})})]}),o("nav",{className:ee.navSection,children:l.map(u=>o(Sn,{to:u.to,className:({isActive:d})=>`${ee.navLink} ${d?ee.active:""}`,onClick:i,end:u.to==="/",children:[u.icon,o("span",{children:u.label})]},u.to))}),o("div",{className:ee.versionInfo,children:["v",ot.version]})]}),e&&o("div",{className:ee.overlay,onClick:()=>t(!1),"aria-label":"Close sidebar"})]})},fs="_footer_1p5nb_1",ys="_footerInner_1p5nb_15",vs="_brandSection_1p5nb_27",gs="_logoRow_1p5nb_39",bs="_logoText_1p5nb_59",_s="_brandMeta_1p5nb_65",ws="_brandTagline_1p5nb_74",Ss="_statusPill_1p5nb_81",ks="_statusDot_1p5nb_94",Ps="_linksGrid_1p5nb_102",Es="_linkColumn_1p5nb_110",Ts="_columnTitle_1p5nb_116",Is="_bottomBar_1p5nb_140",xs="_copyright_1p5nb_150",Os="_brand_1p5nb_27",Ns="_heartIcon_1p5nb_166",Cs="_backToTop_1p5nb_171",C={footer:fs,footerInner:ys,brandSection:vs,logoRow:gs,logoText:bs,brandMeta:_s,brandTagline:ws,statusPill:Ss,statusDot:ks,linksGrid:Ps,linkColumn:Es,columnTitle:Ts,bottomBar:Is,copyright:xs,brand:Os,heartIcon:Ns,backToTop:Cs},Pt={iris:"/logo.png",mochi:"/logo-mochi.png",sakura:"/logo-sakura.png"},As=()=>{const{theme:e}=on(),t=Pt[e]||Pt.iris,n=new Date().getFullYear(),r=()=>{window.scrollTo({top:0,behavior:"smooth"})};return o("footer",{className:C.footer,children:[o("div",{className:C.footerInner,children:[o("div",{className:C.brandSection,children:[o("div",{className:C.logoRow,children:o("img",{src:t,className:C.logoText,alt:"dango",loading:"lazy",decoding:"async"})}),o("div",{className:C.brandMeta,children:[o("div",{className:C.statusPill,children:[o("span",{className:C.statusDot}),o("span",{children:["v",ot.version]})]}),o("p",{className:C.brandTagline,children:"Fast, local anime streaming."})]})]}),o("div",{className:C.linksGrid,children:[o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Navigation"}),o(J,{to:"/",children:"Home"}),o(J,{to:"/watchlist",children:"Watchlist"}),o(J,{to:"/settings",children:"Settings"})]}),o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Features"}),o(J,{to:"/search",children:"Search Anime"}),o(J,{to:"/trackers",children:"Trackers"}),o(J,{to:"/insights",children:"Insights"})]}),o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Community"}),o("a",{href:"https://discord.gg/2FTSPXCsvn",target:"_blank",rel:"noopener noreferrer",children:[o(v,{name:"discord",style:{marginRight:"6px"}})," Discord"]}),o("a",{href:"https://github.com/serifpersia/dango",target:"_blank",rel:"noopener noreferrer",children:[o(v,{name:"github",style:{marginRight:"6px"}})," GitHub"]})]}),o("div",{className:C.linkColumn,children:[o("h4",{className:C.columnTitle,children:"Project"}),o("a",{href:"https://github.com/serifpersia/dango/releases",target:"_blank",rel:"noopener noreferrer",children:"Releases"}),o("a",{href:"https://github.com/serifpersia/dango/issues",target:"_blank",rel:"noopener noreferrer",children:"Feedback"})]})]})]}),o("div",{className:C.bottomBar,children:[o("p",{className:C.copyright,children:["© ",n," ",o("span",{className:C.brand,children:"dango"})," • Crafted with"," ",o(v,{name:"heart",className:C.heartIcon})," by"," ",o("a",{href:"https://github.com/serifpersia",target:"_blank",rel:"noopener noreferrer",children:"serifpersia"})]}),o("button",{className:C.backToTop,onClick:r,"aria-label":"Back to top",children:[o(v,{name:"chevron-up",size:14}),o("span",{children:"Top"})]})]})]})},Ls=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),Ae="https://script.google.com/macros/s/AKfycbxpllCbhqNjqFN02er9WV-0Tv-Y9br13UqXZqGHzSMetAgqKaFX5oFKGHgxji1fxJ6udw/exec",Rs=()=>{const e=navigator.userAgent;let t="Unknown Browser",n="Unknown OS";return e.includes("Firefox")?t="Firefox":e.includes("SamsungBrowser")?t="Samsung Browser":e.includes("Opera")||e.includes("OPR")?t="Opera":e.includes("Trident")?t="Internet Explorer":e.includes("Edge")?t="Edge":e.includes("Chrome")?t="Chrome":e.includes("Safari")&&(t="Safari"),e.includes("Windows")?n="Windows":e.includes("Mac")?n="MacOS":e.includes("Linux")?n="Linux":e.includes("Android")?n="Android":(e.includes("iPhone")||e.includes("iPad")||e.includes("iPod"))&&(n="iOS"),`${t} on ${n}`},qs=async()=>{localStorage.removeItem("last_telemetry_ping");const e=localStorage.getItem("installation_id");if(e&&Ae)try{await fetch(Ae,{method:"POST",mode:"no-cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"delete"})})}catch(t){console.error("Telemetry delete request failed:",t)}};let Be=!1;const $s=async()=>{if(!Be){Be=!0,localStorage.setItem("last_telemetry_ping",Date.now().toString());try{let e=localStorage.getItem("installation_id");if(!e)try{const t=await U.settings.installationId.query();t.id&&(e=t.id,localStorage.setItem("installation_id",e))}catch(t){console.error("Failed to fetch hardware ID:",t)}e||(e=Ls(),localStorage.setItem("installation_id",e)),await fetch(Ae,{method:"POST",mode:"no-cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,version:ot.version,userAgent:Rs(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}catch(e){console.error("Telemetry ping failed:",e)}finally{Be=!1}}},Ds=()=>{const[e,t]=_(!1);return b(()=>{if(!localStorage.getItem("telemetry_notice_v2")){const r=setTimeout(()=>t(!0),3e3);return()=>clearTimeout(r)}},[]),b(()=>{if(!(localStorage.getItem("telemetry_enabled")!=="false")||!Ae)return;const r=localStorage.getItem("last_telemetry_ping"),i=Date.now(),s=1440*60*1e3;r&&i-parseInt(r)<s||$s()},[]),{showTelemetryModal:e,setShowTelemetryModal:t}},js="_overlay_1juub_1",Ms="_fadeIn_1juub_1",Bs="_content_1juub_11",Fs="_modalIn_1juub_1",Ws="_sm_1juub_29",Ks="_md_1juub_33",Us="_lg_1juub_37",zs="_title_1juub_41",Qs="_body_1juub_48",Hs="_footer_1juub_52",me={overlay:js,fadeIn:Ms,content:Bs,modalIn:Fs,sm:Ws,md:Ks,lg:Us,title:zs,body:Qs,footer:Hs};function dn({children:e}){return o("h2",{className:me.title,children:e})}function mn({children:e}){return o("div",{className:me.body,children:e})}function pn({children:e}){return o("div",{className:me.footer,children:e})}function he({isOpen:e,onClose:t,title:n,children:r,footer:i,width:s="md"}){const a=B(null);return b(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&t?.()};document.addEventListener("keydown",c);const l=document.body.style.overflow;return document.body.style.overflow="hidden",a.current?.focus(),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=l}},[e,t]),e?Rt(o("div",{role:"presentation",onMouseDown:c=>c.stopPropagation(),children:[o("div",{className:me.overlay,onClick:()=>t?.(),"aria-hidden":"true"}),o("div",{ref:a,className:`${me.content} ${me[s]}`,role:"dialog","aria-modal":"true","aria-label":n,tabIndex:-1,children:[n&&o(dn,{children:n}),o(mn,{children:r}),i&&o(pn,{children:i})]})]}),document.body):null}he.Header=dn;he.Body=mn;he.Actions=pn;const Vs="_slider_1f1gi_15",Et={switch:"_switch_1f1gi_1",slider:Vs},Gs=({isChecked:e,onChange:t,id:n,disabled:r=!1})=>o("label",{className:Et.switch,htmlFor:n,children:[o("input",{type:"checkbox",id:n,checked:e,onChange:t,disabled:r}),o("span",{className:Et.slider})]}),Js="_container_1hh92_1",Ys="_description_1hh92_8",Zs="_dataList_1hh92_14",Xs="_dataTitle_1hh92_20",ea="_toggleRow_1hh92_39",ta="_toggleLabel_1hh92_46",na="_actions_1hh92_50",ra="_okButton_1hh92_55",oa="_previewToggle_1hh92_71",ia="_chevron_1hh92_89",sa="_chevronOpen_1hh92_94",aa="_previewBox_1hh92_98",ca="_previewItem_1hh92_107",la="_previewKey_1hh92_114",ua="_previewVal_1hh92_118",T={container:Js,description:Ys,dataList:Zs,dataTitle:Xs,toggleRow:ea,toggleLabel:ta,actions:na,okButton:ra,previewToggle:oa,chevron:ia,chevronOpen:sa,previewBox:aa,previewItem:ca,previewKey:la,previewVal:ua},da="3.4.6",ma={version:da},pa=()=>{const e=navigator.userAgent;return e.includes("Firefox")?"Firefox":e.includes("SamsungBrowser")?"Samsung Browser":e.includes("Opera")||e.includes("OPR")?"Opera":e.includes("Edge")?"Edge":e.includes("Chrome")?"Chrome":e.includes("Safari")?"Safari":"Unknown"},ha=()=>{const e=navigator.userAgent;return e.includes("Windows")?"Windows":e.includes("Mac")?"macOS":e.includes("Linux")?"Linux":e.includes("Android")?"Android":e.includes("iPhone")||e.includes("iPad")?"iOS":"Unknown"},fa=({isOpen:e,onClose:t})=>{const[n,r]=_(!0),[i,s]=_(!1),a=()=>{localStorage.setItem("telemetry_enabled",String(n)),localStorage.setItem("telemetry_notice_v2","true"),n||qs(),t()};return o(he,{isOpen:e,onClose:()=>{},title:"Telemetry",children:o("div",{className:T.container,children:[o("p",{className:T.description,children:"Dango collects anonymous usage data to help track how many people use the app. This information is used to measure the project's install base and popularity. Participation is completely optional."}),o("div",{className:T.dataList,children:[o("p",{className:T.dataTitle,children:"What is collected:"}),o("ul",{children:[o("li",{children:"Browser type and operating system"}),o("li",{children:"Your timezone (e.g. Europe/Berlin)"}),o("li",{children:"Anonymous timestamps (first seen / last seen)"})]})]}),o("button",{className:T.previewToggle,onClick:()=>s(!i),children:[o("span",{children:"See exactly what data is sent"}),o(v,{name:"chevron-down",className:`${T.chevron} ${i?T.chevronOpen:""}`})]}),i&&o("div",{className:T.previewBox,children:[o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"Browser:"}),o("span",{className:T.previewVal,children:pa()})]}),o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"OS:"}),o("span",{className:T.previewVal,children:ha()})]}),o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"Timezone:"}),o("span",{className:T.previewVal,children:Intl.DateTimeFormat().resolvedOptions().timeZone})]}),o("div",{className:T.previewItem,children:[o("span",{className:T.previewKey,children:"App Version:"}),o("span",{className:T.previewVal,children:ma.version})]})]}),o("div",{className:T.toggleRow,children:[o("span",{className:T.toggleLabel,children:"Send anonymous telemetry"}),o(Gs,{isChecked:n,onChange:c=>r(c.target.checked),id:"telemetry-notice-toggle"})]}),o("div",{className:T.actions,children:o("button",{className:T.okButton,onClick:a,children:"Ok"})})]})})},ya="_promoWrapper_1vfnt_1",va="_visible_1vfnt_11",ga="_panel_1vfnt_16",ba="_closeBtn_1vfnt_29",_a="_header_1vfnt_55",wa="_discordIcon_1vfnt_62",Sa="_headerText_1vfnt_74",ka="_body_1vfnt_89",Pa="_rolePreview_1vfnt_96",Ea="_badge_1vfnt_103",Ta="_badgeRank_1vfnt_111",Ia="_badgeDere_1vfnt_117",xa="_actions_1vfnt_123",Oa="_btnJoin_1vfnt_129",Na="_btnSettings_1vfnt_155",Ca="_skipLink_1vfnt_180",Aa="_hint_1vfnt_200",L={promoWrapper:ya,visible:va,panel:ga,closeBtn:ba,header:_a,discordIcon:wa,headerText:Sa,body:ka,rolePreview:Pa,badge:Ea,badgeRank:Ta,badgeDere:Ia,actions:xa,btnJoin:Oa,btnSettings:Na,skipLink:Ca,hint:Aa},Tt="discord_community_promo_dismissed",La=4500;function Ra({workerUrl:e}){const t=qt(),[n,r]=_(!1),i=B(!1);b(()=>{if(localStorage.getItem(Tt)==="true"||localStorage.getItem("dango_discord_user"))return;const c=setTimeout(()=>r(!0),La);return()=>clearTimeout(c)},[]);const s=()=>{i.current||(i.current=!0,r(!1),localStorage.setItem(Tt,"true"))},a=()=>{s(),t("/settings?tab=community")};return e?o("div",{className:`${L.promoWrapper} ${n?L.visible:""}`,"aria-live":"polite",children:o("div",{className:L.panel,children:[o("button",{className:L.closeBtn,onClick:s,"aria-label":"Dismiss",children:"✕"}),o("div",{className:L.header,children:[o("div",{className:L.discordIcon,children:o("svg",{width:"20",height:"16",viewBox:"0 0 71 55",fill:"white","aria-hidden":"true",children:o("path",{d:"M60.1 4.9A58.5 58.5 0 0 0 45.5.3a.22.22 0 0 0-.23.11 40.8 40.8 0 0 0-1.8 3.7 54 54 0 0 0-16.2 0 37.5 37.5 0 0 0-1.83-3.7.23.23 0 0 0-.23-.11A58.3 58.3 0 0 0 10.9 4.9a.2.2 0 0 0-.1.08C1.58 18.73-1 32.23.31 45.55a.24.24 0 0 0 .09.17 58.8 58.8 0 0 0 17.7 8.95.23.23 0 0 0 .25-.08 42 42 0 0 0 3.61-5.88.22.22 0 0 0-.12-.31 38.7 38.7 0 0 1-5.53-2.64.23.23 0 0 1-.02-.37 29 29 0 0 0 1.1-.86.22.22 0 0 1 .23-.03c11.6 5.3 24.14 5.3 35.6 0a.22.22 0 0 1 .23.03c.36.3.73.58 1.1.86a.23.23 0 0 1-.02.37 36.4 36.4 0 0 1-5.53 2.64.22.22 0 0 0-.12.31 47.1 47.1 0 0 0 3.61 5.88.22.22 0 0 0 .25.08 58.6 58.6 0 0 0 17.72-8.95.23.23 0 0 0 .09-.16c1.47-15.27-2.47-28.65-10.46-40.47a.18.18 0 0 0-.09-.09ZM23.73 37.55c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.82 7.15-6.37 7.15Zm23.54 0c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.79 7.15-6.37 7.15Z"})})}),o("div",{className:L.headerText,children:[o("h4",{children:"Join the Dango Community"}),o("p",{children:"Earn roles based on your watch stats"})]})]}),o("div",{className:L.body,children:[o("p",{style:{margin:"0 0 6px"},children:"Connect your Discord account and earn exclusive server roles based on how much you watch:"}),o("div",{className:L.rolePreview,children:[o("span",{className:`${L.badge} ${L.badgeRank}`,children:"S-Rank"}),o("span",{className:`${L.badge} ${L.badgeRank}`,children:"F–A Rank"}),o("span",{className:`${L.badge} ${L.badgeDere}`,children:"Tsundere"}),o("span",{className:`${L.badge} ${L.badgeDere}`,children:"Kamidere…"})]})]}),o("div",{className:L.actions,children:[o("a",{className:L.btnJoin,href:"https://discord.gg/6yPAZjDzg8",target:"_blank",rel:"noopener noreferrer",children:[o("svg",{width:"16",height:"12",viewBox:"0 0 71 55",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M60.1 4.9A58.5 58.5 0 0 0 45.5.3a.22.22 0 0 0-.23.11 40.8 40.8 0 0 0-1.8 3.7 54 54 0 0 0-16.2 0 37.5 37.5 0 0 0-1.83-3.7.23.23 0 0 0-.23-.11A58.3 58.3 0 0 0 10.9 4.9a.2.2 0 0 0-.1.08C1.58 18.73-1 32.23.31 45.55a.24.24 0 0 0 .09.17 58.8 58.8 0 0 0 17.7 8.95.23.23 0 0 0 .25-.08 42 42 0 0 0 3.61-5.88.22.22 0 0 0-.12-.31 38.7 38.7 0 0 1-5.53-2.64.23.23 0 0 1-.02-.37 29 29 0 0 0 1.1-.86.22.22 0 0 1 .23-.03c11.6 5.3 24.14 5.3 35.6 0a.22.22 0 0 1 .23.03c.36.3.73.58 1.1.86a.23.23 0 0 1-.02.37 36.4 36.4 0 0 1-5.53 2.64.22.22 0 0 0-.12.31 47.1 47.1 0 0 0 3.61 5.88.22.22 0 0 0 .25.08 58.6 58.6 0 0 0 17.72-8.95.23.23 0 0 0 .09-.16c1.47-15.27-2.47-28.65-10.46-40.47a.18.18 0 0 0-.09-.09ZM23.73 37.55c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.82 7.15-6.37 7.15Zm23.54 0c-3.49 0-6.37-3.21-6.37-7.15s2.82-7.15 6.37-7.15c3.58 0 6.42 3.24 6.37 7.15 0 3.94-2.79 7.15-6.37 7.15Z"})}),"Join Discord Server"]}),o("button",{className:L.btnSettings,onClick:a,children:[o("span",{children:"⚙"})," Get Roles & Settings"]})]}),o("button",{className:L.skipLink,onClick:s,children:"Skip — don't show again"}),o("p",{className:L.hint,children:"You can always find this in Settings → Community"})]})}):null}const it=e=>{const t=P();return Q({...t.settings.getByKey.queryOptions({key:e}),select:n=>n.value})},hn=()=>{const e=P(),t=z();return Y(e.settings.set.mutationOptions({onSuccess:()=>{g.success("Setting updated!"),t.invalidateQueries(e.settings.pathFilter()),t.invalidateQueries({queryKey:["settings"]})},onError:n=>{g.error(`Failed to update setting: ${n.message}`)}}))};function fn(e){return JSON.stringify({0:e??{}})}function yn(e){return`/api/trpc/${e}?batch=1`}function Ge(e,t){const n=fn(t),r=yn(e);try{if(navigator.sendBeacon){navigator.sendBeacon(r,new Blob([n],{type:"application/json"}));return}}catch{}fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}).catch(()=>{})}async function ll(e,t){await fetch(yn(e),{method:"POST",headers:{"Content-Type":"application/json"},body:fn(t),keepalive:!0})}function ul(e){e&&(Ge("discord.clear",{sessionId:e}),Ge("discord.heartbeat",{sessionId:e,bye:!0}))}function qa(){const e=Ye(),{data:t}=it("discordRPCEnabled"),n=B("");n.current||(n.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`tab-${Date.now()}-${Math.random().toString(36).slice(2)}`),b(()=>{if(t===!1||t==="false")return;const r=n.current,i=()=>U.discord.heartbeat.mutate({sessionId:r}).catch(()=>{});i();const s=setInterval(i,15e3),a=()=>{Ge("discord.heartbeat",{sessionId:r,bye:!0})};return window.addEventListener("pagehide",a),()=>{clearInterval(s),window.removeEventListener("pagehide",a)}},[t]),b(()=>{if(t===!1||t==="false")return;const r=e.pathname;if(r.startsWith("/watch/")||r.startsWith("/player/"))return;let i="home";r.startsWith("/search")||r.startsWith("/mature")?i="search":r.startsWith("/watchlist")?i="watchlist":r.startsWith("/anime/")?i="anime":r.startsWith("/insights")?i="insights":r.startsWith("/settings")?i="settings":r.startsWith("/map")?i="map":r.startsWith("/trackers")?i="trackers":r.startsWith("/asmr")?i="asmr":r.startsWith("/manga")?i="manga":r.startsWith("/radio")?i="radio":r.startsWith("/music")?i="music":r.startsWith("/tv")&&(i="tv"),U.discord.pageStatus.mutate({page:i}).catch(()=>{})},[e.pathname,t])}function vn(e,t){const[n,r]=_(()=>{try{const s=localStorage.getItem(e);if(s===null)return t;if(typeof t=="string")return s;try{return JSON.parse(s)}catch{return s}}catch{return t}});b(()=>{const s=a=>{if(a.key===e)try{if(a.newValue===null){r(t);return}if(typeof t=="string"){r(a.newValue);return}try{r(JSON.parse(a.newValue))}catch{r(a.newValue)}}catch{}};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[e,t]);const i=F(s=>{r(a=>{const c=typeof s=="function"?s(a):s;try{typeof c=="string"?localStorage.setItem(e,c):localStorage.setItem(e,JSON.stringify(c))}catch{}return c})},[e]);return[n,i]}const gn=oe(void 0),$a=()=>{const e=ie(gn);if(!e)throw new Error("useAnimePaheCookie must be used within an AnimePaheCookieProvider");return e},Da="_container_e96gf_1",ja="_field_e96gf_9",Ma="_textarea_e96gf_20",Ba="_input_e96gf_40",Fa="_button_e96gf_58",Wa="_secondaryButton_e96gf_78",Ka="_actions_e96gf_95",Ua="_hint_e96gf_104",za="_link_e96gf_117",W={container:Da,field:ja,textarea:Ma,input:Ba,button:Fa,secondaryButton:Wa,actions:Ka,hint:Ua,link:za},Qa="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Ha=e=>{try{return JSON.parse(e.detail)}catch{return null}},Va=({isOpen:e,onClose:t,onSuccess:n})=>{const[r,i]=_(1),[s,a]=_(navigator.userAgent),[c,l]=_(""),[u,d]=_(!1),m=B(null),p=navigator.userAgent,h=/android/i.test(p),f=/firefox|fxios/i.test(p)&&!h,O=!f&&!h&&/chrome|chromium|edg|brave/i.test(p),D=f||O;b(()=>{e&&(i(1),a(navigator.userAgent),l(""),d(!1))},[e]),b(()=>()=>{m.current&&(window.removeEventListener("dango:pahe-cookie",m.current),m.current=null)},[]);const j=()=>{localStorage.setItem("animepahe_ua",s),window.open("https://animepahe.pw","_blank","noopener,noreferrer"),i(2)},H=()=>{if(u)return;d(!0);const R=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,E=window.setTimeout(()=>{d(!1),m.current&&(window.removeEventListener("dango:pahe-cookie",m.current),m.current=null),g.error("Helper not detected — install it via about:debugging first.")},3e3),Z=fe=>{const X=Ha(fe);if(!(!X||X.requestId!==R))if(window.clearTimeout(E),window.removeEventListener("dango:pahe-cookie",Z),m.current=null,d(!1),X?.ok&&X.cookie)l(X.cookie),g.success("Cookie extracted from helper!");else if(X?.error==="NO_COOKIE"){const ke=X.debug?.stores?.length??0,ye=X.debug?.names??[];g.error(`Helper found no cf_clearance (checked ${ke} stores, saw: ${ye.join(", ")||"none"}) — solve the challenge on the AnimePahe tab first.`)}else g.error("Helper request failed — try again.")};m.current=Z,window.addEventListener("dango:pahe-cookie",Z),window.dispatchEvent(new CustomEvent("dango:get-pahe-cookie",{detail:{requestId:R}}))},A=()=>{const R=c.trim();if(!R){g.error("Please enter the cf_clearance cookie");return}try{localStorage.setItem("animepahe_cookie",R),g.success("Cookie updated successfully! Reloading…"),n?.(),t(),window.setTimeout(()=>window.location.reload(),1e3)}catch{g.error("Failed to save cookie")}};return o(he,{isOpen:e,onClose:t,title:"AnimePahe Verification Required",children:o("div",{className:W.container,children:r===1?o(G,{children:[o("p",{children:"AnimePahe requires a manual verification to bypass Cloudflare/DDoS-Guard protection."}),o("div",{className:W.field,children:[o("label",{children:"Your User-Agent (will be used for requests):"}),o("textarea",{value:s,readOnly:!0,rows:3,className:W.textarea})]}),o("div",{className:W.actions,children:[o("button",{className:W.secondaryButton,onClick:t,children:"Cancel"}),o("button",{className:W.button,onClick:j,children:"Start Verification (Opens AnimePahe)"})]})]}):o(G,{children:[o("p",{children:["1. Solve the challenge on the ",o("strong",{children:"AnimePahe tab"})," (keep that tab open).",o("br",{}),"2. Copy the ",o("strong",{children:"cf_clearance"})," cookie value using one of these:",o("br",{}),o("br",{}),o("strong",{children:"Chrome / Edge — DevTools:"})," press ",o("code",{children:"F12"})," →"," ",o("strong",{children:"Application"})," → ",o("strong",{children:"Cookies"})," →"," ",o("code",{children:"https://animepahe.pw"}),". Find ",o("strong",{children:"cf_clearance"}),", double-click its ",o("strong",{children:"Value"})," to select it, then copy.",o("br",{}),o("br",{}),o("strong",{children:"Firefox — Storage Inspector:"})," press ",o("code",{children:"F12"})," →"," ",o("strong",{children:"Storage"})," → ",o("strong",{children:"Cookies"})," →"," ",o("code",{children:"https://animepahe.pw"}),". Find ",o("strong",{children:"cf_clearance"}),", right-click the value → ",o("strong",{children:"Copy Value"}),".",o("br",{}),o("br",{}),o("strong",{children:"Either browser — extension:"})," open"," ",o("strong",{children:"Cookie Manager"})," while on the AnimePahe tab, find"," ",o("strong",{children:"cf_clearance"}),", and copy its value (or use the extension's export).",o("br",{}),o("br",{}),"3. Paste it below. Copy ",o("strong",{children:"only the value"})," — remove any"," ",o("code",{children:"cf_clearance="})," prefix or quotes if they were included."]}),D&&o("div",{className:W.hint,children:[o("strong",{children:"Dango helper (one-time setup):"})," ",f?o(G,{children:["type ",o("code",{children:"about:debugging"})," in the address bar →"," ",o("strong",{children:"This Firefox"})," → ",o("strong",{children:"Load Temporary Add-on"})," ","→ open the ",o("code",{children:"dango-extension/firefox"})," folder and pick"," ",o("code",{children:"manifest.json"}),". (Temporary helpers unload when Firefox closes — repeat after a restart.)"]}):o(G,{children:["type ",o("code",{children:"chrome://extensions"})," in the address bar → enable"," ",o("strong",{children:"Developer mode"})," → ",o("strong",{children:"Load unpacked"})," → open the ",o("code",{children:"dango-extension/chrome"})," folder. (Unpacked helpers show a developer-mode notice — expected.)"]})," ","Use this link to download the extension and extract it:"," ",o("a",{href:Qa,target:"_blank",rel:"noreferrer",className:W.link,children:"dango-extension.zip"}),". Then click Extract below and the field fills itself.",o("div",{className:W.actions,children:o("button",{className:W.button,onClick:H,disabled:u,type:"button",children:u?"Extracting…":"Extract cookie from helper"})})]}),o("div",{className:W.field,children:[o("label",{children:"cf_clearance cookie value:"}),o("input",{type:"text",value:c,onChange:R=>l(R.target.value),placeholder:"e.g. xxxxxxxx.xxxxxxxx.xxxxxxx-xxxxxxx",className:W.input})]}),o("div",{className:W.actions,children:[o("button",{className:W.secondaryButton,onClick:t,children:"Cancel"}),o("button",{className:W.secondaryButton,onClick:()=>i(1),children:"Back"}),o("button",{className:W.button,onClick:A,children:"Submit"})]})]})})})};function Ga(){const[e,t]=_(!1);return b(()=>{const n=window.setTimeout(()=>t(!0),120);return()=>window.clearTimeout(n)},[]),e?o("div",{className:"top-progress-bar",role:"progressbar","aria-label":"Loading"}):null}class Ja extends kn{state={hasError:!1};static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?o("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100%",backgroundColor:"#1a1b1c",color:"#fff",textAlign:"center",padding:"2rem"},children:[o(v,{name:"exclamation-triangle",style:{fontSize:"4rem",color:"#ff4d4d",marginBottom:"1rem"}}),o("h1",{style:{marginBottom:"1rem"},children:"Something went wrong"}),o("p",{style:{color:"#aaa",marginBottom:"2rem"},children:"The application encountered an unexpected error."}),o("button",{onClick:()=>{this.setState({hasError:!1}),window.location.href="/"},style:{padding:"0.8rem 1.5rem",backgroundColor:"var(--accent, #3d5afe)",color:"#fff",border:"none",borderRadius:"0.5rem",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"1rem",transition:"background-color 0.2s"},onMouseOver:t=>t.currentTarget.style.backgroundColor="#536dfe",onMouseOut:t=>t.currentTarget.style.backgroundColor="var(--accent, #3d5afe)",children:[o(v,{name:"home"}),"Go back Home"]})]}):this.props.children}}const bn=oe(void 0),Ya=({children:e})=>{const[t,n]=_(!1),r=F(()=>n(!0),[]),i=F(()=>n(!1),[]);return b(()=>Zt("lan",r),[r]),o(bn.Provider,{value:{isOpen:t,openModal:r,closeModal:i},children:e})},Za=()=>{const e=ie(bn);if(!e)throw new Error("useLanAuth must be used within a LanAuthProvider");return e},Xa="_container_88bss_1",ec="_field_88bss_8",tc="_input_88bss_19",nc="_actions_88bss_37",Te={container:Xa,field:ec,input:tc,actions:nc},It=Pn(({variant:e="primary",size:t="md",loading:n,children:r,className:i="",disabled:s,...a},c)=>{const l=["btn",`btn-${e}`,t!=="md"&&`btn-${t}`,n&&"btn-loading",i].filter(Boolean).join(" ");return o("button",{className:l,disabled:s||n,ref:c,...a,children:n?o("span",{className:"btn-spinner"}):r})}),rc=({isOpen:e,onClose:t,onSuccess:n})=>{const[r,i]=_(""),[s,a]=_(!1);Je.useEffect(()=>{e&&i("")},[e]);const c=async()=>{if(!r){g.error("Please enter your password");return}a(!0);try{const l=await fetch("/api/auth/app-login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})}),u=await l.json().catch(()=>({}));if(!l.ok){g.error(u.error||"Login failed");return}g.success("Authenticated successfully"),n(),t(),window.location.reload()}catch{g.error("Network error")}finally{a(!1)}};return o(he,{isOpen:e,onClose:t,title:"LAN Authentication Required",children:o("div",{className:Te.container,children:[o("p",{children:"This instance is protected. Enter the password to access from this device."}),o("div",{className:Te.field,children:[o("label",{htmlFor:"lan-password",children:"Password"}),o("input",{id:"lan-password",type:"password",value:r,onChange:l=>i(l.target.value),placeholder:"Enter password...",className:Te.input,onKeyDown:l=>l.key==="Enter"&&c()})]}),o("div",{className:Te.actions,children:[o(It,{variant:"secondary",onClick:t,disabled:s,children:"Cancel"}),o(It,{variant:"primary",onClick:c,loading:s,children:"Unlock"})]})]})})},oc=I(()=>x(()=>import("./Home-KdnP7sNM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]))),ic=I(()=>x(()=>import("./Watchlist-Dw8cPe0n.js"),__vite__mapDeps([29,1,2,4,6,7,8,9,10,11,12,13,3,5,14,15,30,31]))),sc=I(()=>x(()=>import("./Settings-DQt_S5Qw.js"),__vite__mapDeps([32,1,2,4,33]))),xt=I(()=>x(()=>import("./Player-Be_7Ne5p.js"),__vite__mapDeps([34,1,2,35,4,36,37,12,17,18,8,9,10,22,38,39,40,41,42]))),ac=I(()=>x(()=>import("./Search-DjjKA_Wu.js"),__vite__mapDeps([43,1,4,3,5,6,7,2,8,9,10,11,12,13,14,15,44,45]))),cc=I(()=>x(()=>import("./Mature-Db53R-LR.js"),__vite__mapDeps([46,1,2,4,3,5,6,7,8,9,10,11,12,13,14,15,22,44,45,47]))),Ot=I(()=>x(()=>import("./Asmr-BrjzzyOi.js"),__vite__mapDeps([48,1,4,2,11,9,12,13,27,49,50,51,37]))),lc=I(()=>x(()=>import("./Manga-J6XoqEKq.js"),__vite__mapDeps([52,1,4,14,15,11,9,12,13,19,20,2,22,53,54]))),uc=I(()=>x(()=>import("./MangaInfoPage-N7TxsN5u.js"),__vite__mapDeps([55,1,4,14,15,20,2,53,54]))),dc=I(()=>x(()=>import("./MangaReadPage-D_VzSNWq.js"),__vite__mapDeps([56,1,14,4,15,2,20,53,54]))),mc=I(()=>x(()=>import("./ReadingList-qXW7Dk5z.js"),__vite__mapDeps([57,1,11,9,4,12,13,58,3,5,14,15,30,31,19,20,2,21,16]))),pc=I(()=>x(()=>import("./Radio-DU0ma3GA.js"),__vite__mapDeps([59,1,4,2,49,50,60,61]))),hc=I(()=>x(()=>import("./Music-DjxQjJOl.js"),__vite__mapDeps([62,1,4,49,50,60,61,2,63]))),Nt=I(()=>x(()=>import("./TvSearch-BIypjbU3.js"),__vite__mapDeps([64,1,4,3,5,23,11,9,12,13,24,25,2,14,15,44,45]))),fc=I(()=>x(()=>import("./TvInfo-CUd1agFy.js"),__vite__mapDeps([65,1,4,25,2,66]))),yc=I(()=>x(()=>import("./Tv-COvyHdeJ.js"),__vite__mapDeps([67,1,2,4,35,36,68,22,25,37,12,40,41,69]))),vc=I(()=>x(()=>import("./TvWatchlist-DZrBdiqZ.js"),__vite__mapDeps([70,1,11,9,4,12,13,58,3,5,14,15,30,31,16,24,25,2]))),gc=I(()=>x(()=>import("./ListeningList-DSMbMZT7.js"),__vite__mapDeps([71,1,11,9,4,12,13,58,3,5,14,15,30,31,51,27,2,49,50,26,16]))),bc=I(()=>x(()=>import("./Trackers-BcGzeqj2.js"),__vite__mapDeps([72,1,2,4,73]))),_c=I(()=>x(()=>import("./Insights-DDWry-t1.js"),__vite__mapDeps([74,1,2,4,75]))),wc=I(()=>x(()=>import("./Map-BtXwpBOC.js"),__vite__mapDeps([76,1,4,77]))),Sc=I(()=>x(()=>import("./AnimeInfoPage-Cw-Tq3YX.js"),__vite__mapDeps([78,1,2,4]))),kc=I(()=>x(()=>import("./PlayerRedirect-fv2tzEUu.js"),__vite__mapDeps([79,1]))),Pc=I(()=>x(()=>import("./VirtualKeyboard-BmqZPZXR.js"),__vite__mapDeps([80,1,81])));function Ec(){const{isOpen:e,closeModal:t,onSuccess:n}=$a(),{isOpen:r,setIsOpen:i}=rt(),{isOpen:s,openModal:a,closeModal:c}=Za(),l=Ye(),u=En(),d=B(new Map),m=Ei(),{showTelemetryModal:p,setShowTelemetryModal:h}=Ds();qa();const[f,O]=_("");b(()=>{U.discord.rolesConfig.query().then(E=>{E.workerUrl&&O(E.workerUrl)}).catch(()=>{})},[]);const[D,j]=_(!1);b(()=>{fetch("/api/auth/app-status").then(E=>E.json()).then(E=>{E.hasPassword&&!E.isAuthenticated&&(j(!0),a())}).catch(()=>{})},[a]);const[H,A]=vn("lan_auth_notice_shown","false"),R=B(!1);return b(()=>{if(H==="true"||R.current)return;R.current=!0,A("true");const E=setTimeout(()=>{g("Optional LAN lock is available. Set a password in Settings to protect access from other devices on your network.",{duration:1e4,icon:"🔒"})},3e3);return()=>clearTimeout(E)},[H,A]),b(()=>{try{window.history.scrollRestoration="manual"}catch{}},[]),b(()=>{const E=l.key,Z=d.current;if(u==="POP"){const fe=Z.get(E)??0;window.scrollTo({top:fe,behavior:"instant"})}else window.scrollTo({top:0,behavior:"instant"});return()=>{Z.set(E,window.scrollY)}},[l.key,u]),b(()=>{const E=Z=>{r&&Z.key==="Escape"&&i(!1)};return r?document.body.classList.add("sidebar-open"):document.body.classList.remove("sidebar-open"),window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E),document.body.classList.remove("sidebar-open")}},[r,i]),o("div",{className:"app-container",children:[o(Va,{isOpen:e,onClose:t,onSuccess:n}),o(fa,{isOpen:p,onClose:()=>h(!1)}),o(rc,{isOpen:s,onClose:D?()=>{}:c,onSuccess:()=>{j(!1),c()}}),f&&o(Ra,{workerUrl:f}),o(Sr,{position:"top-center",toastOptions:{style:{background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border-primary)"},success:{style:{background:"var(--accent)",color:"var(--accent-text)"},iconTheme:{primary:"var(--accent-text)",secondary:"var(--accent)"}},error:{style:{background:"rgba(153, 42, 42, 0.95)",color:"#fff"}}}}),o(Gi,{}),o(hs,{}),o("main",{className:"main-content",children:o(Ja,{children:o(at,{fallback:o(Ga,{}),children:o(Tn,{children:[o(w,{path:"/",element:o(oc,{})}),o(w,{path:"/watchlist/:filter?",element:o(ic,{})}),o(w,{path:"/reading-list/:filter?",element:o(mc,{})}),o(w,{path:"/search",element:o(ac,{})}),o(w,{path:"/mature",element:o(cc,{})}),o(w,{path:"/asmr",element:o(Ot,{})}),o(w,{path:"/asmr/:rj",element:o(Ot,{})}),o(w,{path:"/manga",element:o(lc,{})}),o(w,{path:"/manga/:provider/:id",element:o(uc,{})}),o(w,{path:"/manga/:provider/:id/read",element:o(dc,{})}),o(w,{path:"/radio",element:o(pc,{})}),o(w,{path:"/music",element:o(hc,{})}),o(w,{path:"/tv",element:o(Nt,{})}),o(w,{path:"/tv/:id",element:o(fc,{})}),o(w,{path:"/tv/:id/watch",element:o(yc,{})}),o(w,{path:"/tv-search",element:o(Nt,{})}),o(w,{path:"/tv-watchlist/:filter?",element:o(vc,{})}),o(w,{path:"/listening-list/:filter?",element:o(gc,{})}),o(w,{path:"/settings",element:o(sc,{})}),o(w,{path:"/trackers",element:o(bc,{})}),o(w,{path:"/mal",element:o(ct,{to:"/trackers",replace:!0})}),o(w,{path:"/insights",element:o(_c,{})}),o(w,{path:"/map",element:o(wc,{})}),o(w,{path:"/anime/:id",element:o(Sc,{})}),o(w,{path:"/watch/:id",element:o(xt,{})}),o(w,{path:"/watch/:id/:episodeNumber",element:o(xt,{})}),o(w,{path:"/player/:id/:episodeNumber?",element:o(kc,{})}),o(w,{path:"*",element:o(ct,{to:"/",replace:!0})})]})})})}),o(As,{}),m.isVisible&&o(at,{fallback:null,children:o(Pc,{activeInputRef:m.activeInputRef,isVisible:m.isVisible,onClose:m.hide})})]})}function Tc(){return o(Ya,{children:o(Ec,{})})}const Ic=({children:e})=>{const[t,n]=_(!1),r=F(()=>{n(s=>!s)},[]),i=pe(()=>({isOpen:t,setIsOpen:n,toggleSidebar:r}),[t,r]);return o(an.Provider,{value:i,children:e})},xc=({children:e})=>{const[t,n]=vn("dango_content_type","anime"),r=pe(()=>({contentType:t,setContentType:n}),[t,n]);return o(cn.Provider,{value:r,children:e})},Oc=({children:e})=>{const[t,n]=_("englishName"),[r,i]=_(!0);b(()=>{(async()=>{try{const c=await U.settings.getByKey.query({key:"titlePreference"});c.value&&n(c.value)}catch(c){console.error("Error fetching title preference in context:",c)}finally{i(!1)}})()},[]);const s=pe(()=>({titlePreference:t,setTitlePreference:n,loading:r}),[t,r]);return o(Xt.Provider,{value:s,children:e})},_n=oe(void 0),dl=()=>{const e=ie(_n);if(e===void 0)throw new Error("useLowEndMode must be used within a LowEndModeProvider");return e},Nc=({children:e})=>{const{data:t,isLoading:n}=it("lowEndMode"),r=hn(),[i,s]=_(!1);b(()=>{t!==void 0&&s(t==="true"||t===!0)},[t]),b(()=>{i?document.body.classList.add("low-end"):document.body.classList.remove("low-end")},[i]);const a=F(l=>{s(l),r.mutate({key:"lowEndMode",value:String(l)})},[r]),c=pe(()=>({lowEndMode:i,setLowEndMode:a,loading:n}),[i,a,n]);return o(_n.Provider,{value:c,children:e})},Cc=["iris","mochi","sakura"];function Ct(e){e==="iris"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const Ac=({children:e})=>{const{data:t,isLoading:n}=it("theme"),r=hn(),[i,s]=_("iris");b(()=>{typeof t=="string"&&Cc.includes(t)&&s(t)},[t]),b(()=>{Ct(i)},[i]);const a=F(l=>{l!==i&&(s(l),Ct(l),r.mutate({key:"theme",value:l}))},[r,i]),c=pe(()=>({theme:i,setTheme:a,loading:n}),[i,a,n]);return o(rn.Provider,{value:c,children:e})},Lc=({children:e})=>{const[t,n]=_(!1),[r,i]=_(void 0),s=F(c=>{i(()=>c),n(!0)},[]),a=F(()=>{n(!1),i(void 0)},[]);return b(()=>Zt("animepahe",()=>s()),[s]),o(gn.Provider,{value:{isOpen:t,openModal:s,closeModal:a,onSuccess:r},children:e})};try{window.history.scrollRestoration="manual"}catch{}const At=new Cn({defaultOptions:{queries:{staleTime:1e3*60*5,refetchOnWindowFocus:!1,refetchIntervalInBackground:!1,retry:1}}}),Lt=document.getElementById("root");Lt&&In(o(xn,{children:o(Bo,{trpcClient:U,queryClient:At,children:o(An,{client:At,children:o(Lc,{children:o(Ic,{children:o(xc,{children:o(Oc,{children:o(Nc,{children:o(Ac,{children:o(Tc,{})})})})})})})})})}),Lt);export{Qe as $,hn as A,It as B,rl as C,ol as D,nl as E,q as F,on as G,cl as H,wt as I,ma as J,Rs as K,_t as L,he as M,$s as N,qs as O,Mc as P,Va as Q,Uc as R,Me as S,Gs as T,Pi as U,un as V,ul as W,W as X,Zt as Y,ll as Z,x as _,vn as a,rt as a0,al as a1,Ga as a2,Vc as a3,Gc as a4,Hc as a5,Fc as b,Wc as c,Ko as d,Ji as e,Wo as f,Dc as g,P as h,Kc as i,ln as j,tl as k,zc as l,Qc as m,Jc as n,Yc as o,il as p,Xc as q,Bc as r,jc as s,U as t,dl as u,sl as v,el as w,Zc as x,it as y,g as z};
@@ -1 +1 @@
1
- import{q as g}from"./vendor-core-DfaOB3Rn.js";import{u as p,b as q,a as M}from"./vendor-query-BBT5_sHx.js";import{h as v,z as h,t as y}from"./index-CVB5dYhT.js";import{u as Q}from"./QueueOptionsButton-5eloKF5J.js";function b(t){const s=p(),c=v(),{data:i,isLoading:w,error:u}=Q(t),n=c.watchlist.check.queryOptions({showId:t??""}).queryKey,{data:d}=q({...c.watchlist.check.queryOptions({showId:t??""}),enabled:!!t}),r=d?.inWatchlist??!1,{mutateAsync:l}=M({mutationFn:async({wasIn:e,meta:a})=>{if(!t)throw new Error("Missing showId");if(e)await y.watchlist.remove.mutate({id:t});else{const o=a?.names,m=a?.name||o?.romaji;if(!m)throw new Error("Missing show name");await y.watchlist.add.mutate({id:t,name:m,thumbnail:a?.thumbnail,nativeName:o?.native,englishName:o?.english,type:a?.type,isAdult:a?.isAdult})}return!e},onMutate:async({wasIn:e})=>{await s.cancelQueries({queryKey:n}),s.setQueryData(n,a=>({...a,inWatchlist:!e}))},onError:e=>{s.invalidateQueries({queryKey:n}),h.error(e instanceof Error?e.message:"Failed to update watchlist")},onSuccess:e=>{h.success(e?"Added to watchlist":"Removed from watchlist"),s.invalidateQueries({queryKey:["watchlist"]})}}),f=g(async()=>{!t||!i||await l({wasIn:r,meta:i})},[t,i,r,l]);return{showMeta:i,inWatchlist:r,loadingMeta:w,error:u?u.message:null,toggleWatchlist:f}}export{b as u};
1
+ import{q as g}from"./vendor-core-DfaOB3Rn.js";import{u as p,b as q,a as M}from"./vendor-query-BBT5_sHx.js";import{h as v,z as h,t as y}from"./index-gMxawd-E.js";import{u as Q}from"./QueueOptionsButton-ClVTpH8J.js";function b(t){const s=p(),c=v(),{data:i,isLoading:w,error:u}=Q(t),n=c.watchlist.check.queryOptions({showId:t??""}).queryKey,{data:d}=q({...c.watchlist.check.queryOptions({showId:t??""}),enabled:!!t}),r=d?.inWatchlist??!1,{mutateAsync:l}=M({mutationFn:async({wasIn:e,meta:a})=>{if(!t)throw new Error("Missing showId");if(e)await y.watchlist.remove.mutate({id:t});else{const o=a?.names,m=a?.name||o?.romaji;if(!m)throw new Error("Missing show name");await y.watchlist.add.mutate({id:t,name:m,thumbnail:a?.thumbnail,nativeName:o?.native,englishName:o?.english,type:a?.type,isAdult:a?.isAdult})}return!e},onMutate:async({wasIn:e})=>{await s.cancelQueries({queryKey:n}),s.setQueryData(n,a=>({...a,inWatchlist:!e}))},onError:e=>{s.invalidateQueries({queryKey:n}),h.error(e instanceof Error?e.message:"Failed to update watchlist")},onSuccess:e=>{h.success(e?"Added to watchlist":"Removed from watchlist"),s.invalidateQueries({queryKey:["watchlist"]})}}),f=g(async()=>{!t||!i||await l({wasIn:r,meta:i})},[t,i,r,l]);return{showMeta:i,inWatchlist:r,loadingMeta:w,error:u?u.message:null,toggleWatchlist:f}}export{b as u};