@serifpersia/dango 3.3.8 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-D4qo4289.js → AnimeCard-CJy1SXH3.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-BdRRm4So.js → AnimeInfo-BoXlVvZ-.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-DeJNAKMR.js → AnimeInfoPage-BxbA_7AV.js} +2 -2
  5. package/client/dist/assets/Asmr--Zc8G9zv.js +2 -0
  6. package/client/dist/assets/AsmrResetProgressModal-CKYm-8cp.js +1 -0
  7. package/client/dist/assets/AvSyncCalibrator-3yjZS7s6.js +10 -0
  8. package/client/dist/assets/Home-rrhOGQcg.js +1 -0
  9. package/client/dist/assets/Insights-Bay90Yeg.js +1 -0
  10. package/client/dist/assets/{LibraryListPage-D3hTqTRU.js → LibraryListPage-HzuDavbb.js} +1 -1
  11. package/client/dist/assets/{ListeningList-BgWsfu40.js → ListeningList-DYcQnnsG.js} +1 -1
  12. package/client/dist/assets/{Manga-Dn-CYins.js → Manga-D8CT9aO0.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-EmQoK7Bv.js → MangaInfoPage-DGK6CYp1.js} +1 -1
  14. package/client/dist/assets/MangaReadPage-B9XoDKF9.js +1 -0
  15. package/client/dist/assets/{MangaResetProgressModal-Dian37PQ.js → MangaResetProgressModal-QjZyIAjl.js} +1 -1
  16. package/client/dist/assets/Mature-CHt_-Hz5.js +1 -0
  17. package/client/dist/assets/MediaCard-B5584Cq9.js +1 -0
  18. package/client/dist/assets/Music-HeLrEZ2d.js +1 -0
  19. package/client/dist/assets/OptionListMenu-CJ90CdwI.js +1 -0
  20. package/client/dist/assets/Player-BYtEax_z.js +56 -0
  21. package/client/dist/assets/PlayerSettings-4-cUAY4B.js +1 -0
  22. package/client/dist/assets/QueueOptionsButton-Ba0dg_82.js +1 -0
  23. package/client/dist/assets/{QueueRail-B7DeSFoA.js → QueueRail-O7f4RqjB.js} +1 -1
  24. package/client/dist/assets/Radio-DPZxQnyD.js +1 -0
  25. package/client/dist/assets/{ReadingList-BT8kUjCB.js → ReadingList-n6rr8ygy.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-DWeiO-hs.js → ResetProgressModal-CcStlbhP.js} +1 -1
  27. package/client/dist/assets/Search-C2wrWOdy.js +1 -0
  28. package/client/dist/assets/Settings-CluUYs8U.js +21 -0
  29. package/client/dist/assets/{SkeletonGrid-B5loz7ii.js → SkeletonGrid-CLEPY9nP.js} +1 -1
  30. package/client/dist/assets/Trackers-CTGPxs0V.js +2 -0
  31. package/client/dist/assets/Tv-BwHlDdi8.js +4 -0
  32. package/client/dist/assets/Tv-ZEA45gXK.css +1 -0
  33. package/client/dist/assets/TvInfo-CXnrLekr.js +1 -0
  34. package/client/dist/assets/TvPopup-BekfiNcX.js +1 -0
  35. package/client/dist/assets/{TvSearch-BYwCf5kO.js → TvSearch-DuqR-z3v.js} +1 -1
  36. package/client/dist/assets/{TvWatchlist-BiJU6pKT.js → TvWatchlist-CBvgFrA0.js} +1 -1
  37. package/client/dist/assets/Watchlist-mj8mTOam.js +1 -0
  38. package/client/dist/assets/{hls-C11FOWHj.js → hls-Boje3IOE.js} +1 -1
  39. package/client/dist/assets/index-BXwhFWB_.js +178 -0
  40. package/client/dist/assets/useAnimeInfoData-DJ7A4B4T.js +1 -0
  41. package/client/dist/assets/useAsmr-DIwIsJXF.js +1 -0
  42. package/client/dist/assets/{useAsmrPopup-cT_Uu41e.js → useAsmrPopup-e4zNN9ig.js} +1 -1
  43. package/client/dist/assets/useMangaLibrary-C9Lci5N4.js +1 -0
  44. package/client/dist/assets/{useMangaPopup-PnmSctHu.js → useMangaPopup-B8nnpvyi.js} +1 -1
  45. package/client/dist/assets/useProviders-B5Qr4I1y.js +1 -0
  46. package/client/dist/assets/useTv-Dm8MCYlL.js +1 -0
  47. package/client/dist/assets/useTvLibrary-B7jEk2Q7.js +1 -0
  48. package/client/dist/assets/{vendor-query-BXRECSI6.js → vendor-query-BUTye89G.js} +1 -1
  49. package/client/dist/index.html +2 -2
  50. package/orchestrator.js +1 -2
  51. package/package.json +2 -6
  52. package/server/dist/app-auth.js +9 -29
  53. package/server/dist/app-hono.js +621 -0
  54. package/server/dist/config.js +0 -1
  55. package/server/dist/db/drizzle.js +32 -0
  56. package/server/dist/db/schema-anime.js +64 -0
  57. package/server/dist/db/schema-asmr.js +25 -0
  58. package/server/dist/db/schema-manga.js +31 -0
  59. package/server/dist/db/schema-tv.js +33 -0
  60. package/server/dist/db.js +75 -4
  61. package/server/dist/discord-gateway.js +1 -1
  62. package/server/dist/google.js +0 -7
  63. package/server/dist/hono/asmr.js +1 -0
  64. package/server/dist/hono/auth.js +56 -0
  65. package/server/dist/hono/music.js +419 -0
  66. package/server/dist/{controllers/proxy.controller.js → hono/proxy.js} +390 -394
  67. package/server/dist/hono/tv.js +197 -0
  68. package/server/dist/hono/watchlist.js +733 -0
  69. package/server/dist/lib/anilist.js +3 -3
  70. package/server/dist/lib/insights.js +185 -0
  71. package/server/dist/lib/ipc.js +1 -2
  72. package/server/dist/lib/kitsu.js +1 -28
  73. package/server/dist/lib/mal-import.js +291 -0
  74. package/server/dist/lib/migration.js +20 -34
  75. package/server/dist/lib/offline-db.js +36 -36
  76. package/server/dist/lib/tracker/manga-sync.service.js +21 -21
  77. package/server/dist/lib/tracker/sync.service.js +20 -20
  78. package/server/dist/lib/translate.js +79 -0
  79. package/server/dist/lib/ytmusic.js +15 -4
  80. package/server/dist/providers/title-matching.js +0 -1
  81. package/server/dist/repositories/asmr.repository.js +90 -87
  82. package/server/dist/repositories/insights.repository.js +24 -13
  83. package/server/dist/repositories/library.repository.js +33 -93
  84. package/server/dist/repositories/manga.repository.js +108 -116
  85. package/server/dist/repositories/notifications.repository.js +50 -31
  86. package/server/dist/repositories/queue.repository.js +36 -25
  87. package/server/dist/repositories/settings.repository.js +18 -8
  88. package/server/dist/repositories/shows-meta.repository.js +54 -41
  89. package/server/dist/repositories/temp-show-ids.repository.js +43 -31
  90. package/server/dist/repositories/tv.repository.js +98 -115
  91. package/server/dist/repositories/watched-episodes.repository.js +52 -20
  92. package/server/dist/repositories/watchlist.repository.js +36 -48
  93. package/server/dist/server.js +59 -151
  94. package/server/dist/sync.js +41 -4
  95. package/server/dist/trpc/context.js +7 -0
  96. package/server/dist/trpc/errors.js +21 -0
  97. package/server/dist/trpc/index.js +19 -0
  98. package/server/dist/trpc/router.js +49 -0
  99. package/server/dist/trpc/routers/asmr-library.js +122 -0
  100. package/server/dist/trpc/routers/asmr-progress.js +133 -0
  101. package/server/dist/trpc/routers/asmr.js +87 -0
  102. package/server/dist/trpc/routers/auth.js +247 -0
  103. package/server/dist/trpc/routers/continue-watching.js +83 -0
  104. package/server/dist/trpc/routers/data.js +1039 -0
  105. package/server/dist/trpc/routers/discord.js +288 -0
  106. package/server/dist/trpc/routers/discovery.js +15 -0
  107. package/server/dist/trpc/routers/insights.js +45 -0
  108. package/server/dist/trpc/routers/manga-library.js +280 -0
  109. package/server/dist/trpc/routers/manga-progress.js +181 -0
  110. package/server/dist/trpc/routers/manga.js +201 -0
  111. package/server/dist/{controllers/music.controller.js → trpc/routers/music.js} +235 -295
  112. package/server/dist/trpc/routers/notifications.js +80 -0
  113. package/server/dist/trpc/routers/progress.js +15 -0
  114. package/server/dist/trpc/routers/queue.js +95 -0
  115. package/server/dist/{routes/radio.routes.js → trpc/routers/radio.js} +30 -23
  116. package/server/dist/trpc/routers/settings.js +105 -0
  117. package/server/dist/trpc/routers/tracker.js +219 -0
  118. package/server/dist/trpc/routers/tv-library.js +145 -0
  119. package/server/dist/trpc/routers/tv-progress.js +171 -0
  120. package/server/dist/trpc/routers/tv.js +565 -0
  121. package/server/dist/trpc/routers/watchlist.js +564 -0
  122. package/server/dist/trpc/validation.js +159 -0
  123. package/server/dist/utils/security.utils.js +0 -18
  124. package/server/package.json +5 -10
  125. package/client/dist/assets/Asmr-D0EGRYsv.js +0 -2
  126. package/client/dist/assets/AsmrResetProgressModal-Gs0GmVaT.js +0 -1
  127. package/client/dist/assets/AvSyncCalibrator-D8hqarVB.js +0 -10
  128. package/client/dist/assets/Home-BnBzjFkW.js +0 -1
  129. package/client/dist/assets/Insights-i9QgY3nE.js +0 -1
  130. package/client/dist/assets/MangaReadPage-xJB8K2YU.js +0 -1
  131. package/client/dist/assets/Mature-DQtXKOXc.js +0 -1
  132. package/client/dist/assets/MediaCard-DpKoY-1j.js +0 -1
  133. package/client/dist/assets/Music-BP43Zqmq.js +0 -1
  134. package/client/dist/assets/OptionListMenu-Bj9ebsW3.js +0 -1
  135. package/client/dist/assets/Player-O2Cy2GF1.js +0 -56
  136. package/client/dist/assets/PlayerSettings-DYZ272Yp.js +0 -1
  137. package/client/dist/assets/QueueOptionsButton-lv26-6jp.js +0 -1
  138. package/client/dist/assets/Radio-qQBYnVfY.js +0 -1
  139. package/client/dist/assets/Search-BkvPYN33.js +0 -1
  140. package/client/dist/assets/Settings-CyZEBF6S.js +0 -21
  141. package/client/dist/assets/Trackers-JK-aXBYC.js +0 -2
  142. package/client/dist/assets/Tv-BwXWJxMy.js +0 -4
  143. package/client/dist/assets/Tv-C2SWcVzN.css +0 -1
  144. package/client/dist/assets/TvInfo-Dzyq6ucH.js +0 -1
  145. package/client/dist/assets/TvPopup-PlCU30FO.js +0 -1
  146. package/client/dist/assets/Watchlist-BOEeGXH9.js +0 -1
  147. package/client/dist/assets/index-CtoKRNLc.js +0 -178
  148. package/client/dist/assets/useAnimeInfoData-kr3WOIWH.js +0 -1
  149. package/client/dist/assets/useAsmr-CB9THf0m.js +0 -1
  150. package/client/dist/assets/useMangaLibrary-rM6z3_0E.js +0 -1
  151. package/client/dist/assets/useProviders-B3VB7A9M.js +0 -1
  152. package/client/dist/assets/useTv-BTUKMH7Q.js +0 -1
  153. package/client/dist/assets/useTvLibrary-C0sX-ilZ.js +0 -1
  154. package/server/dist/controllers/asmr-library.controller.js +0 -288
  155. package/server/dist/controllers/auth.controller.js +0 -225
  156. package/server/dist/controllers/data.controller.js +0 -767
  157. package/server/dist/controllers/insights.controller.js +0 -203
  158. package/server/dist/controllers/manga-library.controller.js +0 -350
  159. package/server/dist/controllers/settings.controller.js +0 -609
  160. package/server/dist/controllers/tv-library.controller.js +0 -314
  161. package/server/dist/controllers/watchlist.controller.js +0 -1069
  162. package/server/dist/request-logger.js +0 -16
  163. package/server/dist/routes/asmr-library.routes.js +0 -23
  164. package/server/dist/routes/asmr.routes.js +0 -81
  165. package/server/dist/routes/auth.routes.js +0 -25
  166. package/server/dist/routes/data.routes.js +0 -47
  167. package/server/dist/routes/discord-gateway.routes.js +0 -51
  168. package/server/dist/routes/insights.routes.js +0 -35
  169. package/server/dist/routes/lan-auth.routes.js +0 -46
  170. package/server/dist/routes/manga-library.routes.js +0 -25
  171. package/server/dist/routes/manga.routes.js +0 -141
  172. package/server/dist/routes/music.routes.js +0 -20
  173. package/server/dist/routes/providers.routes.js +0 -17
  174. package/server/dist/routes/proxy.routes.js +0 -12
  175. package/server/dist/routes/settings.routes.js +0 -24
  176. package/server/dist/routes/tracker.routes.js +0 -287
  177. package/server/dist/routes/translate.routes.js +0 -88
  178. package/server/dist/routes/tv-library.routes.js +0 -23
  179. package/server/dist/routes/tv.routes.js +0 -629
  180. package/server/dist/routes/watchlist.routes.js +0 -341
@@ -1 +1 @@
1
- import{o as te,d as N,T as le,h as C,u as a,l as ne,S as re}from"./vendor-core-8R2fFbyN.js";import{I as T}from"./vendor-icons-CDMuNDeL.js";import{T as se,M as oe,B as q,Q as ie}from"./index-CtoKRNLc.js";import{E as ce}from"./ErrorMessage-z4f4WGgP.js";import{M as de}from"./MediaCard-DpKoY-1j.js";import{u as ue,M as ge}from"./useMangaPopup-PnmSctHu.js";import{f as pe,u as he,m as D,i as ve,b as me,c as be}from"./useMangaLibrary-rM6z3_0E.js";import{u as fe}from"./useProviders-B3VB7A9M.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BXRECSI6.js";import"./vendor-ui-CUDCvRS_.js";import"./useIsMobile-Dm_b6Ob3.js";const Se=[{value:"popular",label:"Popular"},{value:"latest",label:"Latest"},{value:"rating",label:"Top Rated"},{value:"followed",label:"Most Followed"}],ye=[{value:"",label:"Any Status"},{value:"ongoing",label:"Ongoing"},{value:"completed",label:"Completed"},{value:"hiatus",label:"Hiatus"},{value:"cancelled",label:"Cancelled"}],Ne=[{value:"",label:"Any Status"},{value:"publishing",label:"Publishing"},{value:"finished",label:"Finished"},{value:"on hiatus",label:"On Hiatus"},{value:"discontinued",label:"Discontinued"}],Ce=[{value:"",label:"All Types"},{value:"manga",label:"Manga"},{value:"novel",label:"Novel"},{value:"one-shot",label:"One-Shot"},{value:"doujinshi",label:"Doujinshi"}],Te=[{value:"safe",label:"Safe"}],Me=[{value:"safe",label:"Safe"},{value:"suggestive",label:"Suggestive"},{value:"erotica",label:"Erotica"},{value:"pornographic",label:"Pornographic"}],M="agreedToViewMature";function Oe(){const[r,w]=te(),[v,I]=N(()=>localStorage.getItem(M)==="true"),[P,m]=N(!1),[k,L]=N(r.get("q")||""),{options:R,isLoading:$,refetch:z}=fe(),d=le(()=>R.filter(e=>e.kind==="manga").map(e=>({value:e.value,label:e.label})),[R]),b=r.get("provider")||"",i=d.some(e=>e.value===b)?b:d[0]?.value??b,f=r.get("q")||"",u=parseInt(r.get("page")||"1"),B=r.get("sort")||"popular",E=r.get("status")||"",x=r.get("type")||"",g=r.get("rating")||"safe",A=r.get("id")||"";C(()=>{document.title="Manga - dango"},[]),C(()=>{const e=()=>I(localStorage.getItem(M)==="true");return window.addEventListener("focus",e),window.addEventListener("storage",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("storage",e)}},[]);const c=v,S=c?g:"safe",H=c?Me:Te,o=(e,l=!1)=>{const n=new URLSearchParams(r);for(const[h,j]of Object.entries(e))j?n.set(h,j):n.delete(h);l&&n.delete("page"),w(n)},p=pe({provider:i,query:f,page:u,sort:B,status:E,type:x,rating:S,mature:c}),y=p.data?.items??[],G=p.data?.hasNext??!1,{toggle:V,bookmarkedIds:Y}=he(),{popup:s,openPopup:K,scheduleClose:F,cancelClose:O,closePopup:Q}=ue();if(C(()=>{L(f)},[f]),A){const e=new URLSearchParams;c&&g!=="safe"&&e.set("rating",g);const l=r.get("chapter")||"";l&&e.set("chapter",l);const n=e.toString()?`?${e.toString()}`:"",h=`/manga/${i}/${encodeURIComponent(A)}${l?`/read${n}`:n}`;return a(ne,{to:h,replace:!0})}const W=e=>{e.preventDefault(),ie(),o({q:k},!0)},X=e=>{e.target.checked&&!v&&m(!0)},J=()=>{localStorage.setItem(M,"true"),I(!0),m(!1),o({},!0)},U=()=>{m(!1)},_=e=>{const l=new URLSearchParams;c&&g!=="safe"&&l.set("rating",g);const n=l.toString()?`?${l.toString()}`:"";return`/manga/${e.provider}/${encodeURIComponent(e.id)}${n}`},Z=i==="mangapill"?Ne:ye,ee=i==="mangapill",ae=i==="mangadex";return a("div",{className:t.page,children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:[a(T,{name:"book"})," Manga"]}),a("form",{className:t.searchForm,onSubmit:W,children:[a("input",{className:t.searchInput,value:k,onChange:e=>L(e.target.value),placeholder:"Search manga titles...","aria-label":"Search manga"}),a("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:a(T,{name:"search",size:14})})]}),a("select",{className:t.select,value:i,disabled:d.length===0,onChange:e=>{const l=new URLSearchParams(r);l.set("provider",e.target.value),l.delete("page"),l.delete("id"),l.delete("chapter"),l.delete("status"),l.delete("type"),w(l)},"aria-label":"Manga provider",children:d.length===0?a("option",{value:"",children:$?"Loading providers…":"No providers available"}):d.map(e=>a("option",{value:e.value,children:e.label},e.value))}),d.length===0&&!$&&a("button",{className:t.searchBtn,type:"button",onClick:()=>z(),"aria-label":"Retry loading providers",children:a(T,{name:"redo",size:14})})]}),a("div",{className:t.filterRow,children:[i==="mangadex"&&a("select",{className:t.select,value:B,onChange:e=>o({sort:e.target.value},!0),"aria-label":"Sort manga",children:Se.map(e=>a("option",{value:e.value,children:e.label},e.value))}),a("select",{className:t.select,value:E,onChange:e=>o({status:e.target.value},!0),"aria-label":"Filter by status",children:Z.map(e=>a("option",{value:e.value,children:e.label},e.label))}),ee&&a("select",{className:t.select,value:x,onChange:e=>o({type:e.target.value},!0),"aria-label":"Filter by type",children:Ce.filter(e=>e.value!=="doujinshi"||c).map(e=>a("option",{value:e.value,children:e.label},e.value))}),ae&&a("select",{className:t.select,value:S,onChange:e=>o({rating:e.target.value},!0),"aria-label":"Content rating",children:H.map(e=>a("option",{value:e.value,children:e.label},e.value))}),!v&&a("div",{className:t.matureToggleWrap,children:[a("label",{className:t.matureLabel,htmlFor:"manga-mature-toggle",children:"Mature"}),a(se,{id:"manga-mature-toggle",isChecked:!1,onChange:X})]})]}),p.isError?a(ce,{message:"Failed to load manga. Please try again."}):p.isLoading&&y.length===0?a("div",{className:t.grid,"aria-hidden":!0,children:Array.from({length:12}).map((e,l)=>a("div",{className:t.skeletonCard,children:[a("div",{className:`${t.skeletonThumb} ${t.shimmer}`}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"88%"}}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"55%"}})]},l))}):y.length===0?a("p",{className:t.statusMsg,children:"No titles found. Try another search or provider."}):a(re,{children:[a("div",{className:`${t.grid} ${p.isFetching?t.fetching:""}`,children:y.map(e=>{const l=D(e.provider,e.id);return a(de,{item:{id:l,title:e.title,...be(e),thumbnail:me(e.provider,e.cover),typeBadge:e.type||void 0,chapterBadge:e.latestChapter?`Ch. ${e.latestChapter}`:null,isAdult:ve(e)},linkTo:_(e),hoverIcon:"info",display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:n=>K(n,{provider:e.provider,mangaId:e.id,title:e.title,altTitle:e.altTitle,cover:e.cover,contentRating:e.contentRating,readTarget:_(e),rating:S,mature:c}),onPopupHoverIntent:n=>n?O():F(),rawThumbnail:!0},`${e.provider}-${e.id}`)})}),a("nav",{className:t.pagination,children:[a("button",{className:t.pageBtn,disabled:u<=1,onClick:()=>o({page:String(u-1)}),children:"Previous"}),a("span",{className:t.pageIndicator,children:["Page ",u]}),a("button",{className:t.pageBtn,disabled:!G,onClick:()=>o({page:String(u+1)}),children:"Next"})]})]}),s&&a(ge,{data:s.data,anchorRect:s.rect,bookmarked:Y.has(D(s.data.provider,s.data.mangaId)),onToggleBookmark:()=>V({id:s.data.mangaId,provider:s.data.provider,title:s.data.title,cover:s.data.cover,altTitle:s.data.altTitle??void 0,contentRating:s.data.contentRating}),onMouseEnter:O,onMouseLeave:F,onRequestClose:Q}),P&&a(oe,{isOpen:P,title:"Content Warning",onClose:U,children:a("div",{style:{padding:"var(--space-4)",textAlign:"center"},children:[a("p",{children:"This section contains mature content intended for adult audiences."}),a("p",{children:["By proceeding, you confirm that you are ",a("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),a("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-secondary)",marginTop:"var(--space-4)"},children:["You can reset this preference at any time in the ",a("strong",{children:"Settings"})," page."]}),a("div",{style:{marginTop:"var(--space-4)",display:"flex",gap:"var(--space-2-5)",justifyContent:"center"},children:[a(q,{variant:"secondary",onClick:U,children:"Go Back"}),a(q,{onClick:J,children:"I'm 18+, Continue"})]})]})})]})}export{Oe as default};
1
+ import{o as te,d as N,T as le,h as C,u as a,l as ne,S as re}from"./vendor-core-8R2fFbyN.js";import{I as T}from"./vendor-icons-CDMuNDeL.js";import{T as se,M as oe,B as q,R as ie}from"./index-BXwhFWB_.js";import{E as ce}from"./ErrorMessage-z4f4WGgP.js";import{M as de}from"./MediaCard-B5584Cq9.js";import{u as ue,M as ge}from"./useMangaPopup-B8nnpvyi.js";import{f as pe,u as he,m as D,i as ve,b as me,c as be}from"./useMangaLibrary-C9Lci5N4.js";import{u as fe}from"./useProviders-B5Qr4I1y.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BUTye89G.js";import"./vendor-ui-CUDCvRS_.js";import"./useIsMobile-Dm_b6Ob3.js";const Se=[{value:"popular",label:"Popular"},{value:"latest",label:"Latest"},{value:"rating",label:"Top Rated"},{value:"followed",label:"Most Followed"}],ye=[{value:"",label:"Any Status"},{value:"ongoing",label:"Ongoing"},{value:"completed",label:"Completed"},{value:"hiatus",label:"Hiatus"},{value:"cancelled",label:"Cancelled"}],Ne=[{value:"",label:"Any Status"},{value:"publishing",label:"Publishing"},{value:"finished",label:"Finished"},{value:"on hiatus",label:"On Hiatus"},{value:"discontinued",label:"Discontinued"}],Ce=[{value:"",label:"All Types"},{value:"manga",label:"Manga"},{value:"novel",label:"Novel"},{value:"one-shot",label:"One-Shot"},{value:"doujinshi",label:"Doujinshi"}],Te=[{value:"safe",label:"Safe"}],Me=[{value:"safe",label:"Safe"},{value:"suggestive",label:"Suggestive"},{value:"erotica",label:"Erotica"},{value:"pornographic",label:"Pornographic"}],M="agreedToViewMature";function Oe(){const[r,w]=te(),[v,I]=N(()=>localStorage.getItem(M)==="true"),[P,m]=N(!1),[k,L]=N(r.get("q")||""),{options:R,isLoading:$,refetch:z}=fe(),d=le(()=>R.filter(e=>e.kind==="manga").map(e=>({value:e.value,label:e.label})),[R]),b=r.get("provider")||"",i=d.some(e=>e.value===b)?b:d[0]?.value??b,f=r.get("q")||"",u=parseInt(r.get("page")||"1"),B=r.get("sort")||"popular",E=r.get("status")||"",x=r.get("type")||"",g=r.get("rating")||"safe",A=r.get("id")||"";C(()=>{document.title="Manga - dango"},[]),C(()=>{const e=()=>I(localStorage.getItem(M)==="true");return window.addEventListener("focus",e),window.addEventListener("storage",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("storage",e)}},[]);const c=v,S=c?g:"safe",H=c?Me:Te,o=(e,l=!1)=>{const n=new URLSearchParams(r);for(const[h,j]of Object.entries(e))j?n.set(h,j):n.delete(h);l&&n.delete("page"),w(n)},p=pe({provider:i,query:f,page:u,sort:B,status:E,type:x,rating:S,mature:c}),y=p.data?.items??[],G=p.data?.hasNext??!1,{toggle:V,bookmarkedIds:Y}=he(),{popup:s,openPopup:K,scheduleClose:F,cancelClose:O,closePopup:W}=ue();if(C(()=>{L(f)},[f]),A){const e=new URLSearchParams;c&&g!=="safe"&&e.set("rating",g);const l=r.get("chapter")||"";l&&e.set("chapter",l);const n=e.toString()?`?${e.toString()}`:"",h=`/manga/${i}/${encodeURIComponent(A)}${l?`/read${n}`:n}`;return a(ne,{to:h,replace:!0})}const X=e=>{e.preventDefault(),ie(),o({q:k},!0)},Q=e=>{e.target.checked&&!v&&m(!0)},J=()=>{localStorage.setItem(M,"true"),I(!0),m(!1),o({},!0)},U=()=>{m(!1)},_=e=>{const l=new URLSearchParams;c&&g!=="safe"&&l.set("rating",g);const n=l.toString()?`?${l.toString()}`:"";return`/manga/${e.provider}/${encodeURIComponent(e.id)}${n}`},Z=i==="mangapill"?Ne:ye,ee=i==="mangapill",ae=i==="mangadex";return a("div",{className:t.page,children:[a("div",{className:t.header,children:[a("h1",{className:t.pageTitle,children:[a(T,{name:"book"})," Manga"]}),a("form",{className:t.searchForm,onSubmit:X,children:[a("input",{className:t.searchInput,value:k,onChange:e=>L(e.target.value),placeholder:"Search manga titles...","aria-label":"Search manga"}),a("button",{className:t.searchBtn,type:"submit","aria-label":"Search",children:a(T,{name:"search",size:14})})]}),a("select",{className:t.select,value:i,disabled:d.length===0,onChange:e=>{const l=new URLSearchParams(r);l.set("provider",e.target.value),l.delete("page"),l.delete("id"),l.delete("chapter"),l.delete("status"),l.delete("type"),w(l)},"aria-label":"Manga provider",children:d.length===0?a("option",{value:"",children:$?"Loading providers…":"No providers available"}):d.map(e=>a("option",{value:e.value,children:e.label},e.value))}),d.length===0&&!$&&a("button",{className:t.searchBtn,type:"button",onClick:()=>z(),"aria-label":"Retry loading providers",children:a(T,{name:"redo",size:14})})]}),a("div",{className:t.filterRow,children:[i==="mangadex"&&a("select",{className:t.select,value:B,onChange:e=>o({sort:e.target.value},!0),"aria-label":"Sort manga",children:Se.map(e=>a("option",{value:e.value,children:e.label},e.value))}),a("select",{className:t.select,value:E,onChange:e=>o({status:e.target.value},!0),"aria-label":"Filter by status",children:Z.map(e=>a("option",{value:e.value,children:e.label},e.label))}),ee&&a("select",{className:t.select,value:x,onChange:e=>o({type:e.target.value},!0),"aria-label":"Filter by type",children:Ce.filter(e=>e.value!=="doujinshi"||c).map(e=>a("option",{value:e.value,children:e.label},e.value))}),ae&&a("select",{className:t.select,value:S,onChange:e=>o({rating:e.target.value},!0),"aria-label":"Content rating",children:H.map(e=>a("option",{value:e.value,children:e.label},e.value))}),!v&&a("div",{className:t.matureToggleWrap,children:[a("label",{className:t.matureLabel,htmlFor:"manga-mature-toggle",children:"Mature"}),a(se,{id:"manga-mature-toggle",isChecked:!1,onChange:Q})]})]}),p.isError?a(ce,{message:"Failed to load manga. Please try again."}):p.isLoading&&y.length===0?a("div",{className:t.grid,"aria-hidden":!0,children:Array.from({length:12}).map((e,l)=>a("div",{className:t.skeletonCard,children:[a("div",{className:`${t.skeletonThumb} ${t.shimmer}`}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"88%"}}),a("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"55%"}})]},l))}):y.length===0?a("p",{className:t.statusMsg,children:"No titles found. Try another search or provider."}):a(re,{children:[a("div",{className:`${t.grid} ${p.isFetching?t.fetching:""}`,children:y.map(e=>{const l=D(e.provider,e.id);return a(de,{item:{id:l,title:e.title,...be(e),thumbnail:me(e.provider,e.cover),typeBadge:e.type||void 0,chapterBadge:e.latestChapter?`Ch. ${e.latestChapter}`:null,isAdult:ve(e)},linkTo:_(e),hoverIcon:"info",display:{elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!1,meta:!1}}},onOpenDetails:n=>K(n,{provider:e.provider,mangaId:e.id,title:e.title,altTitle:e.altTitle,cover:e.cover,contentRating:e.contentRating,readTarget:_(e),rating:S,mature:c}),onPopupHoverIntent:n=>n?O():F(),rawThumbnail:!0},`${e.provider}-${e.id}`)})}),a("nav",{className:t.pagination,children:[a("button",{className:t.pageBtn,disabled:u<=1,onClick:()=>o({page:String(u-1)}),children:"Previous"}),a("span",{className:t.pageIndicator,children:["Page ",u]}),a("button",{className:t.pageBtn,disabled:!G,onClick:()=>o({page:String(u+1)}),children:"Next"})]})]}),s&&a(ge,{data:s.data,anchorRect:s.rect,bookmarked:Y.has(D(s.data.provider,s.data.mangaId)),onToggleBookmark:()=>V({id:s.data.mangaId,provider:s.data.provider,title:s.data.title,cover:s.data.cover,altTitle:s.data.altTitle??void 0,contentRating:s.data.contentRating}),onMouseEnter:O,onMouseLeave:F,onRequestClose:W}),P&&a(oe,{isOpen:P,title:"Content Warning",onClose:U,children:a("div",{style:{padding:"var(--space-4)",textAlign:"center"},children:[a("p",{children:"This section contains mature content intended for adult audiences."}),a("p",{children:["By proceeding, you confirm that you are ",a("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),a("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-secondary)",marginTop:"var(--space-4)"},children:["You can reset this preference at any time in the ",a("strong",{children:"Settings"})," page."]}),a("div",{style:{marginTop:"var(--space-4)",display:"flex",gap:"var(--space-2-5)",justifyContent:"center"},children:[a(q,{variant:"secondary",onClick:U,children:"Go Back"}),a(q,{onClick:J,children:"I'm 18+, Continue"})]})]})})]})}export{Oe as default};
@@ -1 +1 @@
1
- import{u as e,a as D,d as $,S as j,n as G,o as H,h as E,T as M}from"./vendor-core-8R2fFbyN.js";import{I as C}from"./vendor-icons-CDMuNDeL.js";import{B as A,d as Y}from"./index-CtoKRNLc.js";import{E as J}from"./ErrorMessage-z4f4WGgP.js";import{b as q,g as K,f as Q,h as F,j as X,m as R,k as Z,l as ee,n as te,r as ae,o as re,p as ne,q as se,s as ie,M as oe}from"./useMangaLibrary-rM6z3_0E.js";import{s as r}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BXRECSI6.js";const le=({detail:a,altTitle:c,onBack:x,onOpenChapter:m,bookmarkButton:i,statusSelect:y,primaryAction:g,progressByChapter:w})=>{const l=[a.type,a.status,a.year?String(a.year):"",a.author?`by ${a.author}`:""].filter(Boolean);return e("div",{children:[e("button",{className:r.backBtn,onClick:x,children:[e(C,{name:"chevron-left",size:12})," Back to browse"]}),e("div",{className:r.detail,children:[a.cover&&e("img",{className:r.detailCover,src:q(a.provider,a.cover),alt:a.title,decoding:"async",draggable:!1}),e("div",{className:r.detailInfo,children:[e("h2",{className:r.detailTitle,children:a.title}),c&&e("p",{className:r.detailAltTitle,children:["Also known as: ",c]}),l.length>0&&e("div",{className:r.detailMeta,children:l.map(n=>e("span",{className:r.badge,children:n},n))}),a.genres&&a.genres.length>0&&e("div",{className:r.detailMeta,children:a.genres.map(n=>e("span",{className:r.badge,children:n},n))}),a.description&&e("p",{className:r.detailDesc,children:a.description}),(i||y||g)&&e("div",{className:r.detailActions,children:[g,i,y]})]})]}),e("h3",{className:r.detailTitle,style:{fontSize:"1rem"},children:["Chapters (",a.chapters.length,")"]}),a.chapters.length===0?e("p",{className:r.statusMsg,children:"No chapters found for this title on this provider."}):e("div",{className:r.chapterList,children:a.chapters.map(n=>{const t=w?.get(n.id),h=!!t&&t.pageCount>0&&t.page>=t.pageCount;return e("button",{className:`${r.chapterRow} ${h?r.chapterDone:""}`,onClick:()=>m(n),title:n.externalUrl?"External only — opens on source site":void 0,children:[e("span",{children:["Ch. ",n.number,n.title?` — ${n.title}`:""]}),e("span",{className:r.chapterMeta,children:[t&&t.pageCount>0?h?"read":`p. ${t.page}/${t.pageCount}`:"",n.group,n.externalUrl?"external":""].filter(Boolean).join(" · ")})]},n.id)})})]})},ce=({libId:a,anilistId:c})=>{const x=D(),m=K(a),i=m.data?.item,[y,g]=$(null),[w,l]=$(null),n=y??i?.title??"",t=Q({provider:"mangadex",query:n,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!n),h=Q({provider:"mangapill",query:n,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!n),f=F(),I=X(),u=async o=>{const v=R(o.provider,o.id);l(v);try{await f.mutateAsync({provider:o.provider,mangaId:o.id,title:o.title,cover:o.cover,altTitle:o.altTitle,contentRating:o.contentRating,silent:!0}),await I.mutateAsync({id:v,anilistId:c}),x(`/manga/${o.provider}/${encodeURIComponent(o.id)}`)}catch{return}finally{l(null)}},L=(o,v,T)=>e("div",{style:{marginTop:"12px"},children:[e("div",{style:{fontWeight:600,textTransform:"capitalize",marginBottom:"6px"},children:o}),T?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"Searching…"}):!v||v.length===0?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"No matches."}):v.slice(0,6).map(d=>{const b=R(d.provider,d.id),B=w===b;return e("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"6px 0",borderTop:"1px solid var(--border, #223)"},children:[d.cover&&e("img",{src:q(d.provider,d.cover),alt:"",loading:"lazy",style:{width:"34px",height:"48px",objectFit:"cover",borderRadius:"4px"}}),e("div",{style:{flex:1,minWidth:0},children:[e("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.title}),d.latestChapter&&e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.75rem"},children:d.latestChapter})]}),e(A,{onClick:()=>u(d),disabled:B,children:[e(C,{name:"external-link-alt",size:12})," ",B?"Linking…":"Link"]})]},b)})]});return e("div",{children:[e("button",{onClick:()=>x("/manga"),style:{background:"none",border:"none",color:"var(--accent)",cursor:"pointer",marginBottom:"12px"},children:[e(C,{name:"chevron-left",size:12})," Back to browse"]}),m.isLoading?e("div",{style:{color:"var(--text-tertiary)"},children:"Loading library entry…"}):i?e(j,{children:[e("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[i.cover&&e("img",{src:i.cover,alt:"",style:{width:"64px",height:"90px",objectFit:"cover",borderRadius:"6px"}}),e("div",{children:[e("h2",{style:{margin:"0 0 4px"},children:i.title}),e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:["Tracked on AniList",i.lastChapterNumber?` · Ch. ${i.lastChapterNumber}`:"",i.status?` · ${i.status}`:""]})]})]}),e("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",marginTop:"12px"},children:"AniList doesn't host chapters. Search your providers below and link the matching manga — your AniList status and chapter progress will sync to it from now on."}),e("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:e("input",{type:"text",value:y??i.title,onChange:o=>g(o.target.value),placeholder:"Search providers…",style:{flex:1,padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border, #223)",background:"var(--bg-secondary, transparent)",color:"inherit"}})}),L("mangadex",t.data?.items,t.isLoading),L("mangapill",h.data?.items,h.isLoading)]}):e("div",{style:{color:"var(--text-tertiary)"},children:"This AniList entry is no longer in your library."})]})};function ye(){const{provider:a="",id:c=""}=G(),[x]=H(),m=D(),[i,y]=$(()=>localStorage.getItem("agreedToViewMature")==="true");E(()=>{const s=()=>y(localStorage.getItem("agreedToViewMature")==="true");return window.addEventListener("focus",s),window.addEventListener("storage",s),()=>{window.removeEventListener("focus",s),window.removeEventListener("storage",s)}},[]);const g=x.get("rating")||"safe",w=i?g:"safe",l=a&&c?R(a,c):void 0,n=Z(a||null,c||null,w,i),t=n.data,h=ee(l),f=te(l),{titlePreference:I}=Y(),u=M(()=>t&&{...t,title:ae(t,I)},[t,I]),L=F(),o=re(),v=ne();E(()=>{u&&(document.title=`${u.title} - dango`)},[u]);const T=M(()=>{const s=new Map;for(const p of f.data?.progress??[])s.set(p.chapterId,p);return s},[f.data]),d=a.toLowerCase()==="anilist"&&/^\d+$/.test(c)?parseInt(c,10):null,b=h.data?.inLibrary??!1,B=h.data?.status??"Reading",P=M(()=>(t?.chapters??[]).filter(s=>!s.externalUrl),[t]),k=M(()=>{if(!t)return null;const s=[...f.data?.progress??[]].sort((p,N)=>N.updatedAt-p.updatedAt);for(const p of s){const N=t.chapters.find(S=>S.id===p.chapterId);if(N&&!N.externalUrl)return N;const U=se(p.chapterId);if(U!=null){const S=ie(t.chapters,U);if(S&&!S.externalUrl)return S}}return P[0]??null},[t,f.data,P]),W=k?T.get(k.id):void 0,_=(f.data?.progress?.length??0)>0,O=k&&(W||_)?`Continue Ch. ${k?.number}`:"Start Reading",z=s=>{if(s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const p=new URLSearchParams;p.set("chapter",s.id),i&&g!=="safe"&&p.set("rating",g),m(`/manga/${a}/${encodeURIComponent(c)}/read?${p.toString()}`)},V=()=>{!t||!l||(b?o.mutate(l):L.mutate({provider:a,mangaId:c,title:t.title,cover:t.cover,author:t.author,altTitle:t.altTitle,contentRating:t.contentRating}))};return e("div",{className:r.page,children:n.isLoading?e("div",{"aria-hidden":!0,children:[e("div",{className:`${r.skeletonThumb} ${r.shimmer}`,style:{maxWidth:"12rem"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"40%"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"70%"}})]}):n.isError||!t||!u?d!=null&&l?e(ce,{libId:l,anilistId:d}):e(j,{children:[e("button",{className:r.backBtn,onClick:()=>m("/manga"),children:[e(C,{name:"chevron-left",size:12})," Back to browse"]}),e(J,{message:"Failed to load this title. Please try again."})]}):e(le,{detail:u,altTitle:t.altTitle!==u.title?t.altTitle:void 0,onBack:()=>m("/manga"),onOpenChapter:z,progressByChapter:T,primaryAction:k?e(A,{onClick:()=>k&&z(k),children:[e(C,{name:"book",size:13})," ",O]}):void 0,bookmarkButton:e(A,{variant:b?"secondary":"primary",onClick:V,disabled:L.isPending||o.isPending,children:[e(C,{name:"bookmark",size:13})," ",b?"Bookmarked":"Bookmark"]}),statusSelect:b?e("select",{className:r.detailSelect,value:B,onChange:s=>l&&v.mutate({id:l,status:s.target.value}),"aria-label":"Reading status",children:oe.map(s=>e("option",{value:s,children:s},s))}):void 0})})}export{ye as default};
1
+ import{u as e,a as D,d as $,S as j,n as G,o as H,h as E,T as M}from"./vendor-core-8R2fFbyN.js";import{I as C}from"./vendor-icons-CDMuNDeL.js";import{B as A,d as Y}from"./index-BXwhFWB_.js";import{E as J}from"./ErrorMessage-z4f4WGgP.js";import{b as q,g as K,f as Q,h as F,j as X,m as R,k as Z,l as ee,n as te,r as ae,o as re,p as ne,q as se,s as ie,M as oe}from"./useMangaLibrary-C9Lci5N4.js";import{s as r}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BUTye89G.js";const le=({detail:a,altTitle:c,onBack:x,onOpenChapter:m,bookmarkButton:i,statusSelect:y,primaryAction:g,progressByChapter:w})=>{const l=[a.type,a.status,a.year?String(a.year):"",a.author?`by ${a.author}`:""].filter(Boolean);return e("div",{children:[e("button",{className:r.backBtn,onClick:x,children:[e(C,{name:"chevron-left",size:12})," Back to browse"]}),e("div",{className:r.detail,children:[a.cover&&e("img",{className:r.detailCover,src:q(a.provider,a.cover),alt:a.title,decoding:"async",draggable:!1}),e("div",{className:r.detailInfo,children:[e("h2",{className:r.detailTitle,children:a.title}),c&&e("p",{className:r.detailAltTitle,children:["Also known as: ",c]}),l.length>0&&e("div",{className:r.detailMeta,children:l.map(n=>e("span",{className:r.badge,children:n},n))}),a.genres&&a.genres.length>0&&e("div",{className:r.detailMeta,children:a.genres.map(n=>e("span",{className:r.badge,children:n},n))}),a.description&&e("p",{className:r.detailDesc,children:a.description}),(i||y||g)&&e("div",{className:r.detailActions,children:[g,i,y]})]})]}),e("h3",{className:r.detailTitle,style:{fontSize:"1rem"},children:["Chapters (",a.chapters.length,")"]}),a.chapters.length===0?e("p",{className:r.statusMsg,children:"No chapters found for this title on this provider."}):e("div",{className:r.chapterList,children:a.chapters.map(n=>{const t=w?.get(n.id),h=!!t&&t.pageCount>0&&t.page>=t.pageCount;return e("button",{className:`${r.chapterRow} ${h?r.chapterDone:""}`,onClick:()=>m(n),title:n.externalUrl?"External only — opens on source site":void 0,children:[e("span",{children:["Ch. ",n.number,n.title?` — ${n.title}`:""]}),e("span",{className:r.chapterMeta,children:[t&&t.pageCount>0?h?"read":`p. ${t.page}/${t.pageCount}`:"",n.group,n.externalUrl?"external":""].filter(Boolean).join(" · ")})]},n.id)})})]})},ce=({libId:a,anilistId:c})=>{const x=D(),m=K(a),i=m.data?.item,[y,g]=$(null),[w,l]=$(null),n=y??i?.title??"",t=Q({provider:"mangadex",query:n,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!n),h=Q({provider:"mangapill",query:n,page:1,sort:"",status:"",type:"",rating:"safe",mature:!1},!!n),f=F(),I=X(),u=async o=>{const v=R(o.provider,o.id);l(v);try{await f.mutateAsync({provider:o.provider,mangaId:o.id,title:o.title,cover:o.cover,altTitle:o.altTitle,contentRating:o.contentRating,silent:!0}),await I.mutateAsync({id:v,anilistId:c}),x(`/manga/${o.provider}/${encodeURIComponent(o.id)}`)}catch{return}finally{l(null)}},L=(o,v,T)=>e("div",{style:{marginTop:"12px"},children:[e("div",{style:{fontWeight:600,textTransform:"capitalize",marginBottom:"6px"},children:o}),T?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"Searching…"}):!v||v.length===0?e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:"No matches."}):v.slice(0,6).map(d=>{const b=R(d.provider,d.id),B=w===b;return e("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"6px 0",borderTop:"1px solid var(--border, #223)"},children:[d.cover&&e("img",{src:q(d.provider,d.cover),alt:"",loading:"lazy",style:{width:"34px",height:"48px",objectFit:"cover",borderRadius:"4px"}}),e("div",{style:{flex:1,minWidth:0},children:[e("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.title}),d.latestChapter&&e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.75rem"},children:d.latestChapter})]}),e(A,{onClick:()=>u(d),disabled:B,children:[e(C,{name:"external-link-alt",size:12})," ",B?"Linking…":"Link"]})]},b)})]});return e("div",{children:[e("button",{onClick:()=>x("/manga"),style:{background:"none",border:"none",color:"var(--accent)",cursor:"pointer",marginBottom:"12px"},children:[e(C,{name:"chevron-left",size:12})," Back to browse"]}),m.isLoading?e("div",{style:{color:"var(--text-tertiary)"},children:"Loading library entry…"}):i?e(j,{children:[e("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[i.cover&&e("img",{src:i.cover,alt:"",style:{width:"64px",height:"90px",objectFit:"cover",borderRadius:"6px"}}),e("div",{children:[e("h2",{style:{margin:"0 0 4px"},children:i.title}),e("div",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem"},children:["Tracked on AniList",i.lastChapterNumber?` · Ch. ${i.lastChapterNumber}`:"",i.status?` · ${i.status}`:""]})]})]}),e("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",marginTop:"12px"},children:"AniList doesn't host chapters. Search your providers below and link the matching manga — your AniList status and chapter progress will sync to it from now on."}),e("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:e("input",{type:"text",value:y??i.title,onChange:o=>g(o.target.value),placeholder:"Search providers…",style:{flex:1,padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border, #223)",background:"var(--bg-secondary, transparent)",color:"inherit"}})}),L("mangadex",t.data?.items,t.isLoading),L("mangapill",h.data?.items,h.isLoading)]}):e("div",{style:{color:"var(--text-tertiary)"},children:"This AniList entry is no longer in your library."})]})};function ye(){const{provider:a="",id:c=""}=G(),[x]=H(),m=D(),[i,y]=$(()=>localStorage.getItem("agreedToViewMature")==="true");E(()=>{const s=()=>y(localStorage.getItem("agreedToViewMature")==="true");return window.addEventListener("focus",s),window.addEventListener("storage",s),()=>{window.removeEventListener("focus",s),window.removeEventListener("storage",s)}},[]);const g=x.get("rating")||"safe",w=i?g:"safe",l=a&&c?R(a,c):void 0,n=Z(a||null,c||null,w,i),t=n.data,h=ee(l),f=te(l),{titlePreference:I}=Y(),u=M(()=>t&&{...t,title:ae(t,I)},[t,I]),L=F(),o=re(),v=ne();E(()=>{u&&(document.title=`${u.title} - dango`)},[u]);const T=M(()=>{const s=new Map;for(const p of f.data?.progress??[])s.set(p.chapterId,p);return s},[f.data]),d=a.toLowerCase()==="anilist"&&/^\d+$/.test(c)?parseInt(c,10):null,b=h.data?.inLibrary??!1,B=h.data?.status??"Reading",P=M(()=>(t?.chapters??[]).filter(s=>!s.externalUrl),[t]),k=M(()=>{if(!t)return null;const s=[...f.data?.progress??[]].sort((p,N)=>N.updatedAt-p.updatedAt);for(const p of s){const N=t.chapters.find(S=>S.id===p.chapterId);if(N&&!N.externalUrl)return N;const U=se(p.chapterId);if(U!=null){const S=ie(t.chapters,U);if(S&&!S.externalUrl)return S}}return P[0]??null},[t,f.data,P]),W=k?T.get(k.id):void 0,_=(f.data?.progress?.length??0)>0,O=k&&(W||_)?`Continue Ch. ${k?.number}`:"Start Reading",z=s=>{if(s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const p=new URLSearchParams;p.set("chapter",s.id),i&&g!=="safe"&&p.set("rating",g),m(`/manga/${a}/${encodeURIComponent(c)}/read?${p.toString()}`)},V=()=>{!t||!l||(b?o.mutate(l):L.mutate({provider:a,mangaId:c,title:t.title,cover:t.cover,author:t.author,altTitle:t.altTitle,contentRating:t.contentRating}))};return e("div",{className:r.page,children:n.isLoading?e("div",{"aria-hidden":!0,children:[e("div",{className:`${r.skeletonThumb} ${r.shimmer}`,style:{maxWidth:"12rem"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"40%"}}),e("div",{className:`${r.skeletonLine} ${r.shimmer}`,style:{width:"70%"}})]}):n.isError||!t||!u?d!=null&&l?e(ce,{libId:l,anilistId:d}):e(j,{children:[e("button",{className:r.backBtn,onClick:()=>m("/manga"),children:[e(C,{name:"chevron-left",size:12})," Back to browse"]}),e(J,{message:"Failed to load this title. Please try again."})]}):e(le,{detail:u,altTitle:t.altTitle!==u.title?t.altTitle:void 0,onBack:()=>m("/manga"),onOpenChapter:z,progressByChapter:T,primaryAction:k?e(A,{onClick:()=>k&&z(k),children:[e(C,{name:"book",size:13})," ",O]}):void 0,bookmarkButton:e(A,{variant:b?"secondary":"primary",onClick:V,disabled:L.isPending||o.isPending,children:[e(C,{name:"bookmark",size:13})," ",b?"Bookmarked":"Bookmark"]}),statusSelect:b?e("select",{className:r.detailSelect,value:B,onChange:s=>l&&v.mutate({id:l,status:s.target.value}),"aria-label":"Reading status",children:oe.map(s=>e("option",{value:s,children:s},s))}):void 0})})}export{ye as default};
@@ -0,0 +1 @@
1
+ import{d as F,A as I,q as Z,h as u,u as e,S as J,n as ce,o as le,a as de,T as ue}from"./vendor-core-8R2fFbyN.js";import{E as ge}from"./ErrorMessage-z4f4WGgP.js";import{I as x}from"./vendor-icons-CDMuNDeL.js";import{u as he}from"./vendor-query-BUTye89G.js";import{t as me,v as pe,m as fe,k as ve,r as be,n as Ne,w as we,q as ye,s as Ce}from"./useMangaLibrary-C9Lci5N4.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import{d as Ie,t as G}from"./index-BXwhFWB_.js";const ee="mangaReadMode",te="mangaFitMode";function Se(){try{return localStorage.getItem(ee)==="page"?"page":"strip"}catch{return"strip"}}function $e(){try{return localStorage.getItem(te)==="height"?"height":"width"}catch{return"width"}}const ke=({provider:d,mangaTitle:h,chapter:p,chapters:b,onBack:N,onOpenChapter:v,initialPage:l=0,onProgress:D,savedPage:$=0})=>{const[c,U]=F(Se),[i,_]=F($e),[g,M]=F(0),[T,m]=F(new Set),[w,S]=F(0),E=I(null),B=I([]),z=he(),{data:V,isLoading:k,isError:L}=me(d,p.id),a=V?.pages??[],K=a.map(n=>pe(d,n)),y=I(0),Q=I(0),P=I(!1);Q.current=a.length;const s=b.findIndex(n=>n.id===p.id),o=s>0?[...b.slice(0,s)].reverse().find(n=>!n.externalUrl)??null:null,C=s>=0?b.slice(s+1).find(n=>!n.externalUrl)??null:null,R=Z(n=>{P.current=!0,M(r=>{const f=r+n;return f<0?(o&&v(o),0):f>=a.length?(C&&v(C),r):f})},[a.length,o,C,v]);u(()=>{P.current=!1,y.current=Math.max(0,l),M(Math.max(0,l)),m(new Set),B.current=[],l<=0&&window.scrollTo(0,0)},[p.id,l]);const H=I(D);H.current=D;const X=I("");u(()=>{y.current=g,a.length!==0&&H.current?.(Math.min(g+1,a.length),a.length)},[g,a.length]),u(()=>{l<=0||P.current||y.current===0&&(P.current=!1,y.current=l,M(l))},[l]),u(()=>{if(c!=="strip"||a.length===0||l<=0)return;const n=`${p.id}:${l}`;if(X.current===n)return;X.current=n;const r=window.setTimeout(()=>{B.current[Math.min(l,a.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[c,a.length,l,p.id]),u(()=>{document.title=`${h} Ch. ${p.number} - dango`},[h,p.number]),u(()=>{try{localStorage.setItem(ee,c)}catch{}},[c]),u(()=>{try{localStorage.setItem(te,i)}catch{}},[i]),u(()=>{c==="page"&&window.scrollTo(0,0)},[c]),u(()=>{if(c!=="page"||a.length===0)return;const n=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),R(1)):r.key==="ArrowLeft"&&(r.preventDefault(),R(-1))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c,a.length,R]),u(()=>{if(c!=="strip"||a.length===0)return;const n=new IntersectionObserver(r=>{for(const f of r)if(f.isIntersecting){const W=Number(f.target.dataset.pageIndex);Number.isNaN(W)||(W!==y.current&&(P.current=!0),M(W))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return B.current.forEach(r=>r&&n.observe(r)),()=>n.disconnect()},[c,a.length,V]);const ne=n=>{E.current=n.touches[0].clientX},ae=n=>{if(E.current===null)return;const r=n.changedTouches[0].clientX-E.current;E.current=null,!(Math.abs(r)<50)&&R(r<0?1:-1)},q=n=>{n&&v(n)},O=n=>m(r=>{if(r.has(n))return r;const f=new Set(r);return f.add(n),f}),re=n=>{m(r=>{const f=new Set(r);return f.delete(n),f}),S(r=>r+1)},se=()=>{m(new Set),S(n=>n+1),z.invalidateQueries({queryKey:["mangaPages",d,p.id]})},ie=a.length>0&&T.size>=a.length,Y=n=>w>0?`${n}&n=${w}`:n,j=n=>e("div",{className:t.deadPage,role:"alert",children:[e("span",{children:["Page ",n+1," failed to load"]}),e("button",{className:t.pageBtn,onClick:()=>re(n),children:[e(x,{name:"sync-alt",size:12})," Retry"]})]}),A=i==="height",oe=$>0?$-1:-1;return e("div",{className:t.readerShell,children:[e("div",{className:t.readerBar,children:[e("button",{className:t.readerIconBtn,onClick:N,"aria-label":"Back to chapters",children:e(x,{name:"chevron-left",size:14})}),e("span",{className:t.readerTitle,children:[h," — Ch. ",p.number,p.title?` ${p.title}`:""]}),a.length>0&&e("span",{className:t.readerCounter,children:[Math.min(g+1,a.length)," / ",a.length]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":c==="strip",className:c==="strip"?t.readerSegmentActive:"",onClick:()=>U("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":c==="page",className:c==="page"?t.readerSegmentActive:"",onClick:()=>U("page"),children:"Page"})]}),e("div",{className:t.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!A,className:A?"":t.readerSegmentActive,onClick:()=>_("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":A,className:A?t.readerSegmentActive:"",onClick:()=>_("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:t.readerIconBtn,disabled:!o,onClick:()=>q(o),"aria-label":"Previous chapter",children:e(x,{name:"chevron-left",size:14})}),e("button",{className:t.readerIconBtn,disabled:!C,onClick:()=>q(C),"aria-label":"Next chapter",children:e(x,{name:"chevron-right",size:14})})]}),L?e("p",{className:t.statusMsg,children:"Failed to load pages. Please try again."}):k?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((n,r)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):a.length===0?e("p",{className:t.statusMsg,children:"No pages found for this chapter."}):ie?e("div",{className:t.failedBox,children:[e("p",{className:t.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:t.pageBtn,onClick:se,children:[e(x,{name:"sync-alt",size:12})," Reload pages"]})]}):c==="strip"?e("div",{className:`${t.readerPages} ${A?t.readerPagesTall:""}`,children:K.map((n,r)=>e("div",{ref:f=>{B.current[r]=f},"data-page-index":r,className:t.readerPageWrap,children:[r===oe&&e("div",{className:t.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(x,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",$]})]}),T.has(r)?j(r):e("img",{className:t.readerPage,src:Y(n),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>O(r)})]},`${r}-${a[r].slice(-32)}`))}):e(J,{children:[e("div",{className:`${t.pageView} ${A?t.pageViewTall:""}`,onTouchStart:ne,onTouchEnd:ae,children:[e("button",{className:`${t.tapZone} ${t.tapZoneLeft}`,onClick:()=>R(-1),"aria-label":"Previous page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-left",size:16})})}),T.has(g)?j(g):e("img",{className:t.pageImage,src:Y(K[g]),alt:`Page ${g+1} of ${a.length}`,decoding:"async",draggable:!1,onError:()=>O(g)},`${g}-${a[g].slice(-32)}`),e("button",{className:`${t.tapZone} ${t.tapZoneRight}`,onClick:()=>R(1),"aria-label":"Next page",children:e("span",{className:t.tapChevron,children:e(x,{name:"chevron-right",size:16})})})]}),e("nav",{className:t.pagination,"aria-label":"Page navigation",children:[e("button",{className:t.pageBtn,disabled:g<=0,onClick:()=>R(-1),children:"Previous page"}),e("span",{className:t.pageIndicator,children:[g+1," / ",a.length]}),e("button",{className:t.pageBtn,disabled:g>=a.length-1,onClick:()=>R(1),children:"Next page"})]})]}),(o||C)&&e("nav",{className:t.pagination,children:[e("button",{className:t.pageBtn,disabled:!o,onClick:()=>q(o),children:"Previous chapter"}),e("button",{className:t.pageBtn,disabled:!C,onClick:()=>q(C),children:"Next chapter"})]})]})},Pe=800,Re=5e3;function Ue(){const{provider:d="",id:h=""}=ce(),[p]=le(),b=de(),N=p.get("chapter")||"",v=p.get("rating")||"safe",l=typeof localStorage<"u"&&localStorage.getItem("agreedToViewMature")==="true",D=l?v:"safe",$=d&&h?fe(d,h):"",c=d.toLowerCase()==="anilist";u(()=>{c&&h&&b(`/manga/anilist/${encodeURIComponent(h)}`,{replace:!0})},[c,h,b]);const U=ve(!c&&d?d:null,!c&&h?h:null,D,l),i=U.data,{titlePreference:_}=Ie(),g=i?be(i,_):"Manga",M=Ne($||void 0),T=we(),m=i&&N?i.chapters.find(s=>s.id===N)??null:null,w=ye(N),S=w!=null&&i?Ce(i.chapters,w):null;u(()=>{if(w!=null&&S&&S.id!==N){const s=new URLSearchParams;s.set("chapter",S.id),l&&v!=="safe"&&s.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${s.toString()}`,{replace:!0})}},[w,S,N,l,v,d,h,b]);const E=w!=null&&!!i&&!!S,B=w!=null&&!!i&&!S,z=ue(()=>{const s=(M.data?.progress??[]).find(o=>o.chapterId===N);return s&&s.page>0?s.page:0},[M.data,N]),V=z>1?z-1:0,k=I(null),L=I(null),a=Z(()=>{k.current&&(clearTimeout(k.current),k.current=null);const s=L.current;L.current=null,s&&$&&T.mutate({mangaId:$,chapterId:s.chapterId,chapterNumber:s.chapterNumber,page:s.page,pageCount:s.pageCount,title:i?.title??null,cover:i?.cover??null,provider:d||null,altTitle:i?.altTitle??null,contentRating:i?.contentRating??null})},[$,T,i?.title,i?.cover,i?.altTitle,i?.contentRating,d]),K=Z((s,o)=>{m&&(L.current={chapterId:m.id,chapterNumber:m.number,page:s,pageCount:o},k.current&&clearTimeout(k.current),k.current=setTimeout(a,Pe))},[m,a]);u(()=>{a()},[N,a]),u(()=>()=>a(),[a]),u(()=>{const s=window.setInterval(()=>{L.current&&a()},Re);return()=>window.clearInterval(s)},[a]),u(()=>{const s=()=>{document.visibilityState==="hidden"&&a()},o=()=>a();return document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",o)}},[a]);const y=I("");y.current||(y.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),u(()=>{if(!i||!m)return;const s=i.contentRating==="erotica"||i.contentRating==="pornographic"||i.type==="doujinshi",o=()=>{G.discord.mangaPresence.mutate({title:i.title,chapterLabel:`Chapter ${m.number}`,isPlaying:!0,thumbnail:i.cover||"",thumbnails:[i.cover].filter(Boolean),isAdult:s,sessionId:y.current}).catch(()=>{}),G.discord.heartbeat.mutate({sessionId:y.current}).catch(()=>{})};o();const C=window.setInterval(o,6e4);return()=>window.clearInterval(C)},[i,m]);const Q=s=>{if(a(),s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),l&&v!=="safe"&&o.set("rating",v),b(`/manga/${d}/${encodeURIComponent(h)}/read?${o.toString()}`)},P=()=>{a();const s=new URLSearchParams;l&&v!=="safe"&&s.set("rating",v);const o=s.toString()?`?${s.toString()}`:"";b(`/manga/${d}/${encodeURIComponent(h)}${o}`)};return c?null:e("div",{className:t.page,children:U.isLoading||E?e("div",{className:t.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((s,o)=>e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!i||!m?e(J,{children:[e("button",{className:t.backBtn,onClick:P,children:"Back to title"}),e(ge,{message:B?`Chapter ${w} isn't available from ${d} for this title.`:"Failed to load this chapter. Please try again."})]}):e(ke,{provider:d,mangaTitle:g,chapter:m,chapters:i.chapters,onBack:P,onOpenChapter:Q,initialPage:V,onProgress:K,savedPage:z},m.id)})}export{Ue as default};
@@ -1 +1 @@
1
- import{d as n,u as l}from"./vendor-core-8R2fFbyN.js";import{R as i}from"./ResetProgressModal-DWeiO-hs.js";import{B as f,o as R}from"./useMangaLibrary-rM6z3_0E.js";const p=({mangaId:e,title:a,onClose:s})=>{const[r,o]=n(!1),t=f(),m=R();return l(i,{isOpen:!!e,itemName:a,progressKind:"reading",listLabel:"my reading list",alsoRemove:r,onAlsoRemoveChange:o,onClose:()=>{o(!1),s()},onConfirm:()=>{e&&(t.mutate({mangaId:e}),r&&m.mutate(e),o(!1),s())}})};export{p as M};
1
+ import{d as n,u as l}from"./vendor-core-8R2fFbyN.js";import{R as i}from"./ResetProgressModal-CcStlbhP.js";import{B as f,o as R}from"./useMangaLibrary-C9Lci5N4.js";const p=({mangaId:e,title:a,onClose:s})=>{const[r,o]=n(!1),t=f(),m=R();return l(i,{isOpen:!!e,itemName:a,progressKind:"reading",listLabel:"my reading list",alsoRemove:r,onAlsoRemoveChange:o,onClose:()=>{o(!1),s()},onConfirm:()=>{e&&(t.mutate({mangaId:e}),r&&m.mutate(e),o(!1),s())}})};export{p as M};
@@ -0,0 +1 @@
1
+ import{u as t,a as we,o as ke,h as de,d as l,T as ue,S as me}from"./vendor-core-8R2fFbyN.js";import{b as he}from"./vendor-query-BUTye89G.js";import{B as O,M as $e,g as qe,R as Fe,t as x,z as xe}from"./index-BXwhFWB_.js";import{I as ge}from"./vendor-icons-CDMuNDeL.js";import{S as Ue,P as pe}from"./SkeletonGrid-CLEPY9nP.js";import{A as Ye}from"./AnimeCard-CJy1SXH3.js";import{E as Ve}from"./ErrorMessage-z4f4WGgP.js";import{u as We}from"./useMatureConsent-CT7-KfzG.js";import{u as je}from"./useProviders-B5Qr4I1y.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-DJ7A4B4T.js";import"./QueueOptionsButton-Ba0dg_82.js";import"./vendor-ui-CUDCvRS_.js";import"./MediaCard-B5584Cq9.js";import"./useIsMobile-Dm_b6Ob3.js";const He=({isOpen:u,onClose:c,onGrant:s})=>t($e,{isOpen:u,title:"Content Warning",onClose:c,children:t("div",{style:{padding:"1rem",textAlign:"center"},children:[t("p",{children:"This title contains mature content intended for adult audiences."}),t("p",{children:["By proceeding, you confirm that you are ",t("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),t("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[t(O,{variant:"secondary",onClick:c,children:"Go Back"}),t(O,{onClick:s,children:"I'm 18+, Continue"})]})]})}),Ke="_shrinkSelect_130sm_1",Qe="_tightGrid_130sm_7",Q={shrinkSelect:Ke,tightGrid:Qe},ze=[{value:"anilist",label:"AniList"},{value:"mal",label:"MAL"}],Ze=[{value:"POPULARITY_DESC",label:"Popularity"},{value:"TRENDING_DESC",label:"Trending"},{value:"SCORE_DESC",label:"Score"},{value:"START_DATE_DESC",label:"Newest"},{value:"FAVOURITES_DESC",label:"Favourites"}],Je=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Xe=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],et={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},tt=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=u=>u.split("-").map(c=>c&&c[0].toUpperCase()+c.slice(1)).join(" "),at=new Set(["page","limit","year","minScore","minEpisodes"]),rt=new Set(["provider","query","page","limit","type","status","season","year","country","genres","genre","excludeGenres","sortBy","order","studio","blacklist","minScore","minEpisodes"]);function st(u){const c=new URLSearchParams(u),s={};for(const[y,b]of c.entries())rt.has(y)&&(at.has(y)?s[y]=Number(b)||0:s[y]=b);return s}function Ct(){const u=we(),c=qe(),[s,y]=ke(),{hasConsent:b,grant:fe}=We();de(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(s.get("provider")||"anilist"),[C,z]=l(s.get("query")||""),[T,U]=l(s.get("query")||""),[I,g]=l(parseInt(s.get("page")||"1",10)||1),[_,Y]=l(()=>{const e=s.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[M,Z]=l(s.get("sortBy")||""),[N,ye]=l(s.get("status")||""),[D,be]=l(s.get("season")||"ALL"),[G,Ce]=l(s.get("year")||"ALL"),[p,B]=l(s.get("genre")||s.get("genres")||""),[V,Ne]=l(s.get("order")||"recent"),[W,Ae]=l(s.get("studio")||""),[w,Ee]=l(s.get("studio")||""),[J,X]=l([]),[j,Pe]=l(!1),[Re,ee]=l(null),{options:te}=je(),ae=ue(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=ue(()=>[...ze,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:k}=he({...c.data.matureFilters.queryOptions(),enabled:b,staleTime:1/0}),d=i==="anilist"||i==="mal",H=d?void 0:k?.providers?.[i],P=H?.browse,R=H?.genres??[],A=H?.orders??[],se=A.length>0&&!A.includes(V)?A[0]:V,$=!d&&(P?.genre===!0||R.length>0||J.length>0),v=!d&&(P?.order===!0||A.length>0),E=!d&&P?.studio===!0,ie=!d&&P?.sort===!0,q=d?14:P?.pageSize??14,f=e=>{const r=new URLSearchParams;if(e.provider!=="anilist"&&r.set("provider",e.provider),e.query.trim()&&r.set("query",e.query.trim()),e.page>1&&r.set("page",String(e.page)),e.provider==="anilist")e.sort!=="POPULARITY_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status),e.season!=="ALL"&&r.set("season",e.season),e.year!=="ALL"&&r.set("year",e.year);else if(e.provider==="mal")e.sort!=="SCORE_DESC"&&r.set("sortBy",e.sort),e.status&&r.set("status",e.status);else{const n=k?.providers?.[e.provider]?.browse,m=k?.providers?.[e.provider]?.orders??[],o=m.length>0&&!m.includes(e.remoteOrder)?m[0]:e.remoteOrder;(!n||n.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!n||n.genre)&&e.genre&&r.set("genre",e.genre),(!n||n.order)&&o!==(m[0]??"recent")&&r.set("order",o),(!n||n.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}y(r,{replace:!0})},S=(e={})=>({provider:i,query:T,page:I,sort:_,remoteSort:M,status:N,season:D,year:G,genre:p,remoteOrder:V,studio:w,...e}),Le=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(I)),e.set("limit",String(q)),i==="anilist"&&(e.set("sortBy",_),N&&e.set("status",N),D!=="ALL"&&e.set("season",D),G!=="ALL"&&e.set("year",G)),i==="mal"?(e.set("sortBy",_),N&&e.set("status",N)):d||($&&p&&e.set("genre",p),v&&e.set("order",se),ie&&M&&e.set("sortBy",M),E&&w.trim()&&e.set("studio",w.trim())),e.toString()})(),{data:h,isLoading:Oe,isError:Te,error:Ie}=he({...c.data.matureSearch.queryOptions(st(Le)),enabled:b});de(()=>{const e=h?.genres;!d&&R.length===0&&e&&e.length>0&&X(r=>{const n=new Set(r.map(o=>o.slug)),m=[...r];for(const o of e)o.slug&&!n.has(o.slug)&&(n.add(o.slug),m.push(o));return m.length===r.length?r:m})},[h,i,d,R.length]);const F=(h?.data||[]).map(e=>({...e,isAdult:!0})),le=h?.hasMore??!1,L=()=>{Fe(),g(1);let e=p;!d&&!v&&C.trim()&&(e=""),B(e),E&&Ee(W),U(C),f(S({query:C,page:1,genre:e,studio:E?W:w}))},_e=e=>{Se(e),g(1),Z(""),B(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(C),f(S({provider:e,page:1,remoteSort:"",genre:"",query:C}))},Me=e=>{B(e),g(1),e&&(z(""),U("")),f(S({genre:e,page:1,query:e?"":T}))},ne=e=>{g(e),f(S({page:e})),window.scrollTo({top:0,behavior:"smooth"})},De=async(e,r)=>{const n=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(n)&&(e.preventDefault(),e.stopPropagation(),!Re)){ee(n);try{if(i!=="anilist"){let o=!1;try{o=(await x.data.anilistStatus.query())?.available===!0}catch{o=!1}if(o){const ce=await x.data.matureResolve.query({title:r.name});u(`/anime/${ce.id}`);return}const oe=await x.data.matureAllocate.mutate({provider:i,nativeId:n,title:r.name,thumbnail:r.thumbnail});if(!oe?.id)throw new Error("Allocate failed");u(`/anime/${oe.id}`);return}const m=await x.data.matureResolve.query({title:r.name});u(`/anime/${m.id}`)}catch{xe.error("Could not match this title on AniList")}finally{ee(null)}}},K=new Date().getFullYear(),Ge=[{value:"ALL",label:"All Years"},...Array.from({length:K-1980+1},(e,r)=>({value:String(K-r),label:String(K-r)}))],Be=R.length>0?R.map(e=>({value:e,label:ve(e)})):J.map(e=>({value:e.slug,label:e.name}));return b?t("div",{className:"page-container",children:[t("div",{className:a.header,children:[t("h1",{className:a.pageTitle,children:"Mature"}),t("p",{className:a.pageSubtitle,children:"Browse 18+ titles across AniList and streaming providers"})]}),t("div",{className:a.filterContainer,children:[t("div",{className:a.searchBarWrapper,children:[t("div",{className:a.inputIconWrapper,children:[t(ge,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:C,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>_e(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(O,{onClick:L,className:a.searchBtn,children:"Search"}),d&&t("button",{onClick:()=>Pe(!j),className:`${a.filterToggleBtn} ${j?a.active:""}`,children:[t(ge,{name:"filter"})," Filters"]}),ie&&t("select",{value:M,onChange:e=>{Z(e.target.value),g(1),f(S({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Xe.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${j?a.show:""}`,children:[t("div",{className:a.filterDivider}),t("div",{className:a.filterGrid,children:[t("div",{className:a.filterItem,children:[t("label",{children:"Sort By"}),t("select",{value:_,onChange:e=>Y(e.currentTarget.value),children:Ze.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Status"}),t("select",{value:N,onChange:e=>ye(e.currentTarget.value),children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(me,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:D,onChange:e=>be(e.currentTarget.value),children:tt.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),t("div",{className:a.filterItem,children:[t("label",{children:"Year"}),t("select",{value:G,onChange:e=>Ce(e.currentTarget.value),children:Ge.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]}),!d&&!!k&&($||v||E)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${Q.tightGrid}`,children:[v&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:se,onChange:e=>{Ne(e.target.value),g(1),f(S({remoteOrder:e.target.value,page:1}))},children:(A.length>0?A:["recent"]).map(e=>t("option",{value:e,children:et[e]||e},e))})]}),$&&t("div",{className:`${a.filterItem} ${Q.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:p,onChange:e=>{v?(B(e.target.value),g(1),f(S({genre:e.target.value,page:1}))):Me(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),Be.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),E&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:W,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&L()},className:a.searchInput})]})]}),p&&$&&!v&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(p)," genre — search text is ignored while a genre is selected."]}),(v||E)&&t("div",{className:a.filterActions,children:t(O,{onClick:L,className:a.searchBtn,children:"Apply Filters"})})]})]}),Te&&t(Ve,{message:Ie?.message||"Search failed"}),Oe?t(Ue,{count:q}):F.length===0?t("div",{className:a.noResults,children:[t("h3",{children:"No results found"}),t("p",{children:"Try a different query, genre or provider"})]}):t(me,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[h?.total??F.length," result",(h?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>De(r,e),children:t(Ye,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:t(pe,{page:I,totalPages:Math.max(1,Math.ceil((h?.total??0)/q)),canGoNext:le,onChange:ne,variant:"labeled"})})})]})]}):t(He,{isOpen:!0,onClose:()=>u("/"),onGrant:fe})}export{Ct as default};
@@ -0,0 +1 @@
1
+ import{d as y,g as T,u as e,S as ee,$ as Ne,h as K,A as x,q as d,N as Ee,a as Se,L as Ie}from"./vendor-core-8R2fFbyN.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-CUDCvRS_.js";import{I as v}from"./vendor-icons-CDMuNDeL.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-BXwhFWB_.js";import{u as Ge}from"./useIsMobile-Dm_b6Ob3.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
@@ -0,0 +1 @@
1
+ import{A as _,d as b,h as E,g as We,u as e,S as w,$ as je,o as Ve,T as Q}from"./vendor-core-8R2fFbyN.js";import{t as _e,g as F,z as M}from"./index-BXwhFWB_.js";import{I as g}from"./vendor-icons-CDMuNDeL.js";import{a as n}from"./Asmr.module-ChUXDZKx.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Ce,a as Pe}from"./vendor-query-BUTye89G.js";function Be(a){if(!Number.isFinite(a)||a<0)return"0:00";const r=Math.floor(a/60),y=Math.floor(a%60);return`${r}:${String(y).padStart(2,"0")}`}const Je=({track:a,shuffle:r,onToggleShuffle:y,onTrackStep:R,onTrackFailed:be,onClose:se,liked:G,likeVisible:Z,likePending:re,onToggleLike:K})=>{const C=_(null),X=_(!1),[q,I]=b(!1),[he,c]=b(!0),[k,H]=b(!1),[$,A]=b(0),[U,oe]=b(0),[x,z]=b(()=>{const s=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(s)?s:1}),[B,le]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),W=_(x);W.current=x;const N=_(B);N.current=B;const f=_(0),D=_(0),O=_(null),Y=_("");Y.current||(Y.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const ee=`/api/music/audio?videoId=${encodeURIComponent(a.id)}`,j=()=>{O.current&&(window.clearTimeout(O.current),O.current=null)},te=s=>{const o=C.current;if(!o)return;j(),c(!0),H(!1);const v=()=>{if(o.removeEventListener("loadedmetadata",v),s>5&&Number.isFinite(o.duration)&&s<o.duration-5)try{o.currentTime=s}catch{}};o.addEventListener("loadedmetadata",v),o.src=ee,o.load(),o.volume=W.current,o.play().catch(()=>{})},ve=()=>{c(!1),H(!0),be?.(a),N.current&&R(1)},ce=()=>{if(!O.current){if(D.current>=3){ve();return}D.current+=1,O.current=window.setTimeout(()=>{O.current=null,te(f.current)},5e3)}},ke=()=>{D.current=0,te(f.current)};E(()=>{f.current=0,D.current=0,I(!1),A(0),oe(0);const s=C.current;return te(f.current),()=>{j(),s&&s.removeAttribute("src")}},[ee]),E(()=>{const s=C.current;s&&(s.volume=x)},[x]),E(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const P=a.thumbnails?.[a.thumbnails.length-1]?.url??null,ne=We.useCallback(s=>{const o=C.current;_e.discord.musicPresence.mutate({title:a.title,artistLabel:a.artists,isPlaying:s,thumbnail:P||"",currentTime:o?.currentTime??0,duration:Number.isFinite(o?.duration??NaN)?o?.duration:0,sessionId:Y.current}).catch(()=>{}),_e.discord.heartbeat.mutate({sessionId:Y.current}).catch(()=>{})},[a,P]);E(()=>{ne(q)},[ne,q,a.id]),E(()=>{if(!q)return;const s=window.setInterval(()=>ne(!0),15e3);return()=>window.clearInterval(s)},[q,ne]),E(()=>{const s=Y.current,o=()=>{if(!s)return;const S=JSON.stringify({sessionId:s});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([S],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:s,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:S,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,bye:!0}),keepalive:!0}).catch(()=>{}))},v=()=>o(),ae=()=>{document.visibilityState==="hidden"&&o()};return window.addEventListener("pagehide",v),window.addEventListener("beforeunload",v),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("pagehide",v),window.removeEventListener("beforeunload",v),document.removeEventListener("visibilitychange",ae),o()}},[]);const pe=()=>{const s=C.current;s&&(s.paused?s.play().catch(()=>{}):s.pause())},[Ne,ge]=b(!1);E(()=>{ge(!1)},[P]);const ue=`${a.title} — ${a.artists}`,Se=e(w,{children:[e("div",{className:n.playerButtons,children:[e("button",{className:n.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${n.playerBtn} ${n.playBtn}`,onClick:pe,"aria-label":q?"Pause":"Play",children:q?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:n.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),k&&e("button",{className:n.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:n.seekRow,children:[e("span",{className:n.timeLabel,children:Be($)}),e("input",{className:n.seekBar,type:"range",min:0,max:U||0,step:.1,value:Math.min($,U||0),onChange:s=>{const o=C.current;!o||!Number.isFinite(o.duration)||(o.currentTime=parseFloat(s.target.value),A(o.currentTime))},onPointerDown:()=>{X.current=!0},onPointerUp:()=>{X.current=!1},style:{"--played-percent":`${U>0?$/U*100:0}%`},"aria-label":"Seek"}),e("span",{className:n.timeLabel,children:Be(U)}),he&&!k&&e("span",{className:n.timeLabel,children:"loading…"})]})]}),ye=e(w,{children:[a.thumbnails?.[0]?.url&&!Ne&&e("img",{src:a.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>ge(!0)}),e("div",{className:n.playerInfo,children:[e("p",{className:n.playerTitle,title:ue,children:ue}),e("p",{className:n.playerTrack,children:a.artists})]}),e("div",{className:n.playerControls,children:Se}),e("div",{className:n.playerRight,children:[x===0?e(g,{name:"volume-mute",className:n.volumeIcon}):x<.5?e(g,{name:"volume-down",className:n.volumeIcon}):e(g,{name:"volume-up",className:n.volumeIcon}),e("input",{className:n.volumeBar,type:"range",min:0,max:1,step:.01,value:x,onChange:s=>{const o=parseFloat(s.target.value);z(o),localStorage.setItem("musicVolume",String(o))},style:{"--volume-percent":`${x*100}%`},"aria-label":"Volume"})]}),e("div",{className:n.playerActions,children:[Z&&K&&e("button",{className:`${n.playerBtn} ${G?n.playerBtnActive:""}`,onClick:K,disabled:re,title:G?"Remove from Liked Music":"Add to Liked Music","aria-label":G?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!G,children:e(g,{name:"heart"})}),e("button",{className:`${n.playerBtn} ${r?n.playerBtnActive:""}`,onClick:y,title:r?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":r,children:e(g,{name:"shuffle"})}),e("button",{className:`${n.playerBtn} ${B?n.playerBtnActive:""}`,onClick:()=>{le(s=>(localStorage.setItem("musicAutoplay",String(!s)),!s))},title:B?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":B,children:e(g,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(a.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:n.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(g,{name:"external-link-alt"})}),e("button",{className:n.playerBtn,onClick:se,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return je(e(w,{children:[e("audio",{ref:C,preload:"none",onPlay:()=>{I(!0),c(!1),H(!1),D.current=0,j()},onPause:()=>I(!1),onWaiting:()=>{k||c(!0)},onPlaying:()=>{c(!1),D.current=0,j()},onTimeUpdate:s=>{const o=s.target.currentTime;f.current=o,j(),X.current||A(o)},onStalled:()=>{ce()},onLoadedMetadata:s=>{const o=s.target.duration;Number.isFinite(o)&&oe(o)},onDurationChange:s=>{const o=s.target.duration;Number.isFinite(o)&&oe(o)},onError:()=>{ce()},onEnded:()=>{N.current&&R(1)}}),e("div",{className:n.playerBar,children:ye})]}),document.body)},Ze=()=>e("div",{style:{marginTop:"0.9rem",paddingTop:"0.9rem",borderTop:"1px dashed var(--border-color)"},children:[e("h4",{style:{margin:"0 0 0.35rem",fontSize:"0.95rem"},children:"Where to get the cookie"}),e("p",{style:{margin:"0 0 0.6rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"Google marks its login cookies unreadable to page scripts, so this has to come from DevTools — it takes about 20 seconds:"}),e("ol",{style:{margin:"0 0 0.75rem",paddingLeft:"1.25rem",fontSize:"0.85rem",color:"var(--text-secondary)",display:"grid",gap:"0.3rem"},children:[e("li",{children:["Open"," ",e("a",{href:"https://music.youtube.com/",target:"_blank",rel:"noopener noreferrer",children:"music.youtube.com"})," ","and make sure you are logged in."]}),e("li",{children:["Press ",e("kbd",{children:"F12"}),", go to the ",e("strong",{children:"Network"})," tab, and type ",e("kbd",{children:"browse"})," ","in the filter box."]}),e("li",{children:["Click any ",e("kbd",{children:"POST"})," browse entry, then scroll to Request Headers."]}),e("li",{children:[e("strong",{children:"Right-click"})," the ",e("kbd",{children:"Cookie"})," value and choose"," ",e("strong",{children:"Copy value"})," — right-click copies the full unwrapped value, selecting the text by hand truncates it."]}),e("li",{children:"Paste it into the sign-in box above and press Sign in."})]})]}),me=300*1e3,Ke=()=>{const a=F();return J({...a.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:r=>r.state.data?.authenticated?!1:3e3,retry:1})},Xe=()=>{const a=F(),r=Ce();return Pe(a.music.authStart.mutationOptions({onSuccess:(y,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),r.invalidateQueries(a.music.pathFilter())}}))},et=()=>{const a=F(),r=Ce();return Pe(a.music.signOut.mutationOptions({onSuccess:()=>{r.invalidateQueries(a.music.pathFilter())}}))},tt=a=>{const r=F();return J({...r.music.search.queryOptions({q:a}),enabled:a.trim().length>0,staleTime:me,retry:1})},nt=a=>{const r=F();return J({...r.music.library.queryOptions(),enabled:a,staleTime:me,retry:1})},at=a=>{const r=F();return J({...r.music.track.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},it=a=>{const r=F();return J({...r.music.playlist.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},st=a=>{const r=F();return J({...r.music.upnext.queryOptions({id:a||void 0}),enabled:!!a,staleTime:me,retry:1})},rt=a=>{const r=F();return J({...r.music.likes.queryOptions(),enabled:a,staleTime:120*1e3,retry:1})},ot=()=>{const a=F(),r=Ce();return Pe(a.music.like.mutationOptions({onSuccess:()=>{r.invalidateQueries(a.music.pathFilter())}}))},lt="_authRow_10tvv_1",ct="_btn_10tvv_9",ut="_btnGhost_10tvv_42",dt="_cookieForm_10tvv_74",mt="_cookieInput_10tvv_83",ht="_link_10tvv_99",pt="_contentLayout_10tvv_109",gt="_mainCol_10tvv_116",yt="_upnextAside_10tvv_120",ft="_upnextHeader_10tvv_131",bt="_upnextTitle_10tvv_139",vt="_upnextActions_10tvv_149",kt="_nowPlayingLabel_10tvv_156",Nt="_nowPlayingWrap_10tvv_168",St="_likeBtn_10tvv_172",wt="_likeActive_10tvv_196",p={authRow:lt,btn:ct,btnGhost:ut,cookieForm:dt,cookieInput:mt,link:ht,contentLayout:pt,mainCol:gt,upnextAside:yt,upnextHeader:ft,upnextTitle:bt,upnextActions:vt,nowPlayingLabel:kt,nowPlayingWrap:Nt,likeBtn:St,likeActive:wt};function Oe(a){const r=a.trim();if(!r)return null;const y=r.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??r.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return y||(/^[A-Za-z0-9_-]{11}$/.test(r)?r:null)}const Tt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Rt=()=>{const[a,r]=Ve(),y=Oe(a.get("v")??""),[R,be]=b(""),[se,G]=b(""),[Z,re]=b(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[K,C]=b(!1),[X,q]=b(()=>localStorage.getItem("musicShuffle")==="true"),[I,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[c,k]=b(null),[H,$]=b([]),[A,U]=b(null),[oe,x]=b({}),z=_([]);z.current=H;const B=_(null);B.current=c;const le=_(!1),W=_(new Set),{data:N}=Ke(),f=Xe(),D=et(),O=typeof navigator<"u"?navigator.userAgent:"",Y=/android/i.test(O),ee=/firefox|fxios/i.test(O)&&!Y,j=!ee&&!Y&&/chrome|chromium|edg|brave/i.test(O),te=ee||j,ve=()=>{if(K)return;C(!0);const t=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",i),C(!1),M.error("Helper not detected — install the Dango Helper extension first.")},3e3),i=u=>{window.clearTimeout(t),window.removeEventListener("dango:ytmusic-cookie",i),C(!1);try{const l=JSON.parse(u.detail);if(l?.ok&&l.cookie){const m=l.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(m.includes("…")||m.includes("...")){M.error(`Helper returned a truncated cookie (${m.length} chars) — reload music.youtube.com and Extract again.`);return}re(m),M.success("Cookie extracted from helper — signing in…"),f.mutate({cookie:m})}else l?.error==="NO_COOKIE"?M.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):M.error("Helper request failed — try again.")}catch{M.error("Helper request failed — try again.")}};window.addEventListener("dango:ytmusic-cookie",i),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie"))},{data:ce,isLoading:ke}=tt(se),{data:P,isLoading:ne,isFetching:pe,error:Ne,refetch:ge}=nt(N?.authenticated===!0),{data:ue,isLoading:Se}=it(A?.id??null),{data:ye,isLoading:we}=st(c?.id??null),{data:s}=rt(N?.authenticated===!0),o=ot(),v=Q(()=>ce?.tracks||[],[ce]),ae=Q(()=>P?.playlists||[],[P]),S=Q(()=>P?.tracks||[],[P]),V=Q(()=>ue?.tracks||[],[ue]),T=Q(()=>{const t=ye?.tracks||[];return c?t.filter(i=>i.id!==c.id):t},[ye,c]),Ee=Q(()=>new Set(s?.likedIds||[]),[s]),Te=t=>oe[t.id]??(Ee.has(t.id)||t.liked===!0);E(()=>{N?.authenticated!==!0&&x({})},[N?.authenticated]);const Fe=Q(()=>[...v,...V,...S,...T],[v,V,S,T]),De=y&&c?.id!==y&&!Fe.some(t=>t.id===y)?y:null,{data:Re}=at(De),xe=c?.id;E(()=>{document.title=c?`${c.title} - dango`:"Music - dango"},[c]),E(()=>{if(!y){xe&&k(null);return}if(xe===y)return;const t=l=>{const m=l.find(d=>d.id===y);return m?(k(m),$(d=>d.some(ie=>ie.id===y)?d:l.length>0?l:[m]),!0):!1};if(t(v)||t(V)||t(S))return;const i=T.find(l=>l.id===y);if(i){k(i),$(l=>l.some(m=>m.id===i.id)?l:[i]);return}const u=Re?.track;u&&u.id===y&&(k(u),$(l=>l.some(m=>m.id===u.id)?l:[u]))},[y,xe,v,V,S,T,Re]);const Le=(t,i)=>{W.current.delete(t.id),k(t),$(i.length>0?i:[t]),r({v:t.id})},qe=t=>{W.current.add(t.id),M.error(`Couldn't play “${t.title}” — skipped.`)},He=async()=>{if(le.current)return;const t=z.current,i=t[t.length-1]??B.current;if(i){le.current=!0;try{const u=await _e.music.upnext.query({id:i.id}),l=new Set(t.map(d=>d.id)),m=(u.tracks||[]).filter(d=>!l.has(d.id)&&!W.current.has(d.id));if(m.length===0){const d=z.current[0];d&&(k(d),r({v:d.id}));return}$([...z.current,...m]),k(m[0]),r({v:m[0].id})}catch{const u=z.current[0];u&&(k(u),r({v:u.id}))}finally{le.current=!1}}},Ue=t=>{const i=z.current,u=B.current;if(!u||i.length===0)return;const l=i.findIndex(L=>L.id===u.id);if(t>0&&I&&(l<0||l===i.length-1)){He();return}const m=L=>W.current.has(L.id),d=i.length;let ie;if(X&&d>1){let L=Math.floor(Math.random()*d);for(let Me=0;Me<d&&(L===l||m(i[L]));Me++)L=Math.floor(Math.random()*d);ie=i[L]}else{const L=t>0?1:-1;let fe=(((l<0?L>0?-1:0:l)+L)%d+d)%d;for(let Ae=1;Ae<d&&m(i[fe]);Ae++)fe=((fe+L)%d+d)%d;ie=i[fe]}k(ie),r({v:ie.id})},ze=()=>{if(I){he(!1),localStorage.setItem("musicRadio","false");return}const t=B.current;if(!t)return;if(T.length===0){M.error("No radio suggestions for this song yet.");return}const i=new Set,u=[];for(const l of[t,...T])i.has(l.id)||(i.add(l.id),u.push(l));he(!0),localStorage.setItem("musicRadio","true"),$(u),M.success(`Radio started — ${T.length} songs queued.`)},Ie=t=>{if(N?.authenticated!==!0){M.error("Sign in to like songs.");return}const i=!Te(t);x(u=>({...u,[t.id]:i})),o.mutate({id:t.id,like:i},{onError:()=>{x(u=>{const l={...u};return delete l[t.id],l}),M.error("Like action failed — try again.")}})},Ye=()=>{q(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Qe=t=>e("button",{className:h.stationRow,onClick:()=>U(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),de=(t,i,u)=>{const l=c?.id===t.id,m=Te(t),d=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${l?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>u?u(t):Le(t,i),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,d?` · ${d}`:""]})]})]}),N?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${m?p.likeActive:""}`,onClick:()=>Ie(t),disabled:o.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(g,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(g,{name:"external-link-alt"})})]},t.id)},$e=Q(()=>{if(!c)return T;const t=new Set,i=[];for(const u of[c,...T])t.has(u.id)||(t.add(u.id),i.push(u));return i},[c,T]),Ge=t=>{Le(t,$e)};return e("div",{className:`${n.page} ${c?n.pageWithPlayer:""}`,children:[e("div",{className:n.header,children:[e("h1",{className:n.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:n.searchForm,onSubmit:t=>{t.preventDefault();const i=Oe(R);i?(G(""),r({v:i})):G(R)},children:[e("input",{className:n.searchInput,value:R,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:n.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[N?.authenticated?e(w,{children:[e("span",{className:n.statusMsg,children:["Signed in to YouTube Music",P&&` — ${P.tracks.length} songs, ${P.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>D.mutate(),disabled:D.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=Z.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){M.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==Z&&re(i),f.mutate({cookie:i})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:Z,onChange:t=>re(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:f.isPending||!Z.trim(),children:f.isPending?"Checking…":"Sign in"}),te&&e("button",{className:p.btnGhost,type:"button",onClick:ve,disabled:K||f.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:K?"Extracting…":"Extract from helper"})]}),te&&e("p",{className:n.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Tt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",ee?e(w,{children:[e("code",{children:"about:debugging"})," → ",e("strong",{children:"This Firefox"})," →"," ",e("strong",{children:"Load Temporary Add-on"})," →"," ",e("code",{children:"dango-extension/firefox/manifest.json"})]}):e(w,{children:[e("code",{children:"chrome://extensions"})," → ",e("strong",{children:"Developer mode"})," →"," ",e("strong",{children:"Load unpacked"})," → ",e("code",{children:"dango-extension/chrome"})]}),", log in on a music.youtube.com tab, and click Extract."]}),e(Ze,{})]}),f.isSuccess&&e("p",{className:n.statusMsg,children:["Signed in — found ",f.data.tracks," songs and ",f.data.playlists," ","playlists."]}),f.isError&&e("p",{className:n.statusMsg,children:f.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!N?.authenticated&&!f.isError&&!f.isSuccess&&e("p",{className:n.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:c?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:se?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",se,"”"]}),ke?e("p",{className:n.statusMsg,children:"Searching…"}):v.length===0?e("p",{className:n.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:v.map(t=>de(t,v))})]}):N?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ne?e("p",{className:n.statusMsg,children:"Loading library…"}):ae.length===0&&S.length===0&&!A?e(w,{children:[e("p",{className:n.statusMsg,children:Ne?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{ge()},disabled:pe,"aria-label":"Retry loading library",children:pe?"Retrying…":"Retry"})}),e("p",{className:n.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[ae.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:ae.map(t=>Qe(t))})]}),S.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",S.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Le(S[0],S),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:S.map(t=>de(t,S))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>U(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),Se?e("p",{className:n.statusMsg,children:"Loading playlist…"}):V.length===0?e("p",{className:n.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:V.map(t=>de(t,V))})]}):null]})]}):e("p",{className:n.statusMsg,children:"Search above, or sign in to see your library."})}),c&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),de(c,H.length>0?H:[c])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:ze,disabled:!I&&(we||T.length===0),"aria-pressed":I,title:I?"Stop the radio — the queue will loop instead of fetching more songs":"Queue these suggestions after the current song and keep the mix going",children:I?"Stop radio":"Start radio"})}),we?e("p",{className:n.statusMsg,children:"Loading suggestions…"}):T.length===0?e("p",{className:n.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:T.map(t=>de(t,$e,Ge))})]})]}),c&&e(Je,{track:c,queue:H,shuffle:X,onToggleShuffle:Ye,onTrackStep:Ue,onTrackFailed:qe,onClose:()=>{k(null),r({})},liked:c?Te(c):!1,likeVisible:N?.authenticated===!0,likePending:o.isPending,onToggleLike:()=>Ie(c)})]})};export{Rt as default};
@@ -0,0 +1 @@
1
+ import{u as e,S as p,d as y,h as S}from"./vendor-core-8R2fFbyN.js";import{I as m}from"./vendor-icons-CDMuNDeL.js";import{M as s,y as b,T as g,B as f,z as k,D as C}from"./AvSyncCalibrator-3yjZS7s6.js";const O=({classes:n,title:i,titleTag:o="span",showBack:l=!0,onBack:t,panelRef:d,onPanelClick:a,children:c})=>{const r=o;return e("div",{ref:d,className:n.panel,onClick:a,"data-speed-boost-ignore":"true",children:[e("div",{className:n.header,children:[l&&e("button",{className:n.backBtn,onClick:t,children:e(m,{name:"chevron-left"})}),e(r,{className:n.title||void 0,children:i})]}),e("div",{className:n.content,children:c})]})},z=({classes:n,values:i,onChange:o})=>{const l=()=>{const t=C;o("fontSize",t.fontSize),o("position",t.position),o("bgOpacity",t.bgOpacity),o("bgColor",t.bgColor),o("textColor",t.textColor),o("edge",t.edge),o("bold",t.bold)};return e(p,{children:[e(s,{label:"Font Size",display:i.fontSize.toFixed(1),min:.5,max:10,step:.5,value:i.fontSize,percent:(i.fontSize-.5)/9.5*100,onChange:t=>{Number.isFinite(t)&&o("fontSize",t)}}),e(s,{label:"Vertical Position",display:`${i.position}`,min:0,max:100,step:1,value:i.position,percent:i.position,onChange:t=>{Number.isFinite(t)&&o("position",Math.round(t))}}),e(s,{label:"Background Opacity",display:`${Math.round(i.bgOpacity*100)}%`,min:0,max:1,step:.05,value:i.bgOpacity,percent:i.bgOpacity*100,onChange:t=>{Number.isFinite(t)&&o("bgOpacity",t)}}),e(b,{label:"Text Color",colors:g,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:f,value:i.bgColor,onChange:t=>o("bgColor",t)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:i.edge,onChange:t=>o("edge",t)}),e("button",{type:"button",className:`${n.item} ${i.bold?n.active:""}`,onClick:()=>o("bold",!i.bold),children:[e("span",{children:"Bold Text"}),i.bold&&e(m,{name:"check",size:12})]}),e("button",{type:"button",className:n.item,onClick:l,children:e("span",{children:"Reset to Defaults"})})]})},M=({classes:n,enabled:i,delayMs:o,onToggle:l,onDelayChange:t,onCalibrate:d})=>{const[a,c]=y(null),r=a??o;S(()=>{c(null)},[o]);const u=()=>{a!==null&&(t(a),c(null))};return e(p,{children:[e("button",{type:"button",className:`${n.item} ${i?n.active:""}`,onClick:()=>l(!i),children:[e("span",{children:"Video delay"}),i&&e(m,{name:"check",size:12})]}),e(s,{label:"Video delay",display:`${r}ms`,min:0,max:500,step:5,value:r,percent:r/500*100,onChange:h=>c(Math.round(h)),onCommit:u}),e("div",{className:n.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),d&&e("button",{type:"button",className:n.item,onClick:d,children:e("span",{children:"Calibrate…"})})]})},E=({classes:n,options:i,onSelect:o})=>e(p,{children:i.map(l=>e("button",{type:"button",className:`${n.item} ${l.selected?n.active:""}`,onClick:()=>o(l.key),children:[e("span",{children:l.label}),l.selected&&e(m,{name:"check",size:12})]},l.key))});export{M as A,E as O,O as S,z as a};
@@ -0,0 +1,56 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-4-cUAY4B.js","assets/vendor-core-8R2fFbyN.js","assets/vendor-icons-CDMuNDeL.js","assets/OptionListMenu-CJ90CdwI.js","assets/AvSyncCalibrator-3yjZS7s6.js","assets/index-BXwhFWB_.js","assets/vendor-query-BUTye89G.js","assets/index-CUm1meqr.css","assets/useProviders-B5Qr4I1y.js","assets/AvSyncCalibrator-BPa6KaGC.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
2
+ import{g as Wt,h as x,u as r,P as Or,z as Wr,d as Q,A as v,q as O,y as Vr,T as ut,n as Ur,a as qr,c as Qr,_ as zr,S as kt}from"./vendor-core-8R2fFbyN.js";import{_ as fr,S as Nt,g as Gr,t as Le,z as Ke,O as Kr,k as Hr,l as jr,m as Yr,n as Xr,d as Jr,u as Zr,M as Be,B as st,P as en,f as tn}from"./index-BXwhFWB_.js";import{u as hr,b as ur,a as jt}from"./vendor-query-BUTye89G.js";import{C as rn,S as nn,U as sn,a as on,p as Yt,s as an,l as ln,u as cn,b as un,i as dn,c as pn,d as dr,f as pr,e as mn,g as fn,h as hn,r as vn,j as Ge,E as gn,k as bn,m as u,n as yn,A as Sn,P as En,o as wn,q as kn}from"./AvSyncCalibrator-3yjZS7s6.js";import{I as q}from"./vendor-icons-CDMuNDeL.js";import{l as Tn}from"./hls-Boje3IOE.js";import{u as Cn}from"./useMatureConsent-CT7-KfzG.js";import{u as Rn}from"./useIsMobile-Dm_b6Ob3.js";import{s as ot,Q as Mn}from"./QueueRail-O7f4RqjB.js";import{u as vr,f as _n}from"./useProviders-B5Qr4I1y.js";import{u as Nn,Q as Pn}from"./QueueOptionsButton-Ba0dg_82.js";import{A as xn}from"./AnimeMetaDetails-BPvv5xIl.js";import{S as An}from"./SynopsisText-BcpwT5iw.js";import"./vendor-ui-CUDCvRS_.js";const Bn={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Ln={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},In=["direct","cookie","embed"],Dn="_controlsOverlay_1b7ea_1",$n="_hidden_1b7ea_21",Fn="_topControls_1b7ea_27",On="_backBtn_1b7ea_47",Wn="_videoTitleInfo_1b7ea_67",Vn="_animeTitle_1b7ea_73",Un="_episodeNumber_1b7ea_81",qn="_bottomControls_1b7ea_89",Qn="_progressBarContainer_1b7ea_108",zn="_progressBar_1b7ea_108",Gn="_thumb_1b7ea_127",Kn="_scrubbing_1b7ea_142",Hn="_watchedBar_1b7ea_146",jn="_bufferedBar_1b7ea_147",Yn="_timeBubble_1b7ea_185",Xn="_skipSegment_1b7ea_219",Jn="_op_1b7ea_229",Zn="_ed_1b7ea_232",es="_recap_1b7ea_235",ts="_bottomControlsRow_1b7ea_239",rs="_leftControls_1b7ea_247",ns="_rightControls_1b7ea_248",ss="_controlBtn_1b7ea_255",os="_theaterBtn_1b7ea_296",as="_nextEpisodeBtn_1b7ea_300",is="_active_1b7ea_317",ls="_timeDisplay_1b7ea_321",cs="_skipControls_1b7ea_329",us="_skipBtn_1b7ea_335",ds="_volumeContainer_1b7ea_376",ps="_volumeSlider_1b7ea_382",ms="_playerPageLayout_1b7ea_440",fs="_videoPlayerWrapper_1b7ea_444",hs="_playerInfoContainer_1b7ea_449",vs="_visible_1b7ea_566",gs="_shortcuts_1b7ea_584",w={controlsOverlay:Dn,hidden:$n,topControls:Fn,backBtn:On,videoTitleInfo:Wn,animeTitle:Vn,episodeNumber:Un,bottomControls:qn,progressBarContainer:Qn,progressBar:zn,thumb:Gn,scrubbing:Kn,watchedBar:Hn,bufferedBar:jn,timeBubble:Yn,skipSegment:Xn,op:Jn,ed:Zn,recap:es,bottomControlsRow:ts,leftControls:rs,rightControls:ns,controlBtn:ss,theaterBtn:os,nextEpisodeBtn:as,active:is,timeDisplay:ls,skipControls:cs,skipBtn:us,volumeContainer:ds,volumeSlider:ps,playerPageLayout:ms,videoPlayerWrapper:fs,playerInfoContainer:hs,visible:vs,shortcuts:gs},bs=Wr(()=>fr(()=>import("./PlayerSettings-4-cUAY4B.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),ys=({player:n,isAutoplayEnabled:g,onAutoplayChange:k,showNextEpisodeButton:j,onNextEpisode:b,videoSources:R,selectedSource:E,selectedLink:L,onSourceChange:B,loadingVideo:z,skipIntervals:ke,animeTitle:e,episodeNumber:f,isTheaterMode:Te,onTheaterModeToggle:N,anime4kEnabled:ae,onAnime4kToggle:Fe,anime4kSupported:W,anime4kProfile:A,onAnime4kProfileChange:$,anime4kInitializing:Oe,anime4kError:He,videoDelayEnabled:a,onVideoDelayToggle:p,videoDelayMs:M,onVideoDelayChange:pe,onCalibrateAvSync:We,fallbackChoice:je,onFallbackChoiceChange:be,children:Ye,overlays:ee,isInteractingExtra:Ce=!1,className:ce,hideChrome:d=!1})=>{const{state:o,refs:l,actions:h}=n,{showSettings:D}=o,{setShowSettings:Y,setShowVolumeSlider:G}=h,V=Wt.useRef(null),ie=Wt.useRef(null);x(()=>{const m=P=>{V.current&&!V.current.contains(P.target)&&ie.current&&!ie.current.contains(P.target)&&D&&Y(!1)};return D&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[D,Y]);const ye=Wt.useRef(null),at=m=>{l.videoRef.current&&(l.videoRef.current.volume=m,l.videoRef.current.muted=m===0,localStorage.setItem("playerVolume",m.toString()))},Xe=m=>{!l.videoRef.current||isNaN(o.duration)||o.duration===0||(l.videoRef.current.currentTime=m*o.duration,h.sendProgressUpdate(!1,!0))},bt=()=>{l.videoRef.current&&(h.setIsScrubbing(!0),h.wasPlayingBeforeScrub.current=!l.videoRef.current.paused,l.videoRef.current.pause())},K=m=>{!l.videoRef.current||!o.duration||(l.videoRef.current.currentTime=m*o.duration)},it=()=>{h.setIsScrubbing(!1),h.wasPlayingBeforeScrub.current&&l.videoRef.current?.play()},dt=m=>{if(!l.videoRef.current)return;h.setActiveSubtitleTrack(m);try{if(m===null||m==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const T=o.availableSubtitles.find(Ue=>Ue.label===m||Ue.lang===m);T?localStorage.setItem("playerLastSubtitle",an(T)):localStorage.setItem("playerLastSubtitle",m)}}catch{}let P=!1;Array.from(l.videoRef.current.textTracks).forEach(T=>{const Ie=m!==null&&m!=="off"&&(T.language===m||T.label===m)&&!P;T.mode=Ie?"showing":"hidden",Ie&&(P=!0)})},te=o.activeSubtitleTrack!==null&&o.activeSubtitleTrack!=="off",ue=()=>{if(!l.videoRef.current)return;if(te){dt("off");return}if(o.availableSubtitles.length===0)return;let m=null;try{m=localStorage.getItem("playerLastSubtitle")}catch{}const P=Yt(o.availableSubtitles,{lastKey:m,enabled:!0});if(P<0)return;const T=o.availableSubtitles[P];dt(T.label||T.lang)},Re=()=>o.isMuted||o.volume===0?r(q,{name:"volume-mute"}):o.volume<.5?r(q,{name:"volume-down"}):r(q,{name:"volume-up"}),yt=r("div",{className:`${w.controlsOverlay} ${!o.showControls&&!D&&!o.isScrubbing?w.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none"},children:r("div",{className:w.topControls,onClick:m=>m.stopPropagation(),children:[r("button",{className:w.backBtn,onClick:m=>{m.stopPropagation(),window.history.back()},title:"Back","aria-label":"Back",children:r(q,{name:"chevron-left"})}),r("div",{className:w.videoTitleInfo,children:[r("span",{className:w.animeTitle,children:e}),f&&r("span",{className:w.episodeNumber,children:["Episode ",f]})]})]})}),F=!z&&!o.isBuffering&&o.duration>0?r(rn,{isPlaying:o.isPlaying,onTogglePlay:h.togglePlay,onSkipBack:()=>h.seek(-10),onSkipForward:()=>h.seek(10)}):null,Ve=r("div",{className:`${w.controlsOverlay} ${!o.showControls&&!D&&!o.isScrubbing?w.hidden:""} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:w.bottomControls,"data-speed-boost-ignore":"true",onClick:m=>m.stopPropagation(),children:[r(nn,{classes:{container:w.progressBarContainer,scrubbing:w.scrubbing,timeBubble:w.timeBubble,bar:w.progressBar,buffered:w.bufferedBar,watched:w.watchedBar,thumb:w.thumb},videoRef:l.videoRef,duration:o.duration,formatTime:h.formatTime,isScrubbing:o.isScrubbing,onSeek:Xe,onScrubStart:bt,onScrubMove:K,onScrubEnd:it,timeLabelRef:ye,children:[o.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${w.skipSegment} ${w[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/o.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/o.duration*100}% `}}),ke.map(m=>{const P=m.start_time/o.duration*100,T=(m.end_time-m.start_time)/o.duration*100;return r("div",{className:`${w.skipSegment} ${w[m.skip_type]} `,style:{left:`${P}% `,width:`${T}% `},title:m.skip_type.toUpperCase()},m.skip_id)})]}),r("div",{className:w.bottomControlsRow,children:[r("div",{className:w.leftControls,children:[r("button",{className:w.controlBtn,onClick:h.togglePlay,"aria-label":o.isPlaying?"Pause":"Play",children:o.isPlaying?r(q,{name:"pause"}):r(q,{name:"play"})}),r(sn,{muted:o.isMuted,volume:o.volume,volumeIcon:Re(),buttonClassName:w.controlBtn,onToggleMute:h.toggleMute,onVolumeChange:at,onExpandedChange:m=>G(m)}),r("span",{className:w.timeDisplay,ref:ye,children:[h.formatTime(0)," / ",h.formatTime(o.duration)]}),o.currentSkipInterval&&!o.isAutoSkipEnabled&&r("button",{className:w.controlBtn,onClick:()=>{l.videoRef.current&&o.currentSkipInterval&&(l.videoRef.current.currentTime=o.currentSkipInterval.end_time,h.setCurrentSkipInterval(null))},children:["Skip ",o.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:w.rightControls,children:[r("div",{className:w.skipControls,children:j&&r("button",{className:w.nextEpisodeBtn,onClick:b,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${w.controlBtn} ${te?w.active:""}`,onClick:ue,title:te?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(q,{name:"closed-captioning",size:22})}),r("button",{ref:ie,className:`${w.controlBtn} ${D?w.active:""} `,onClick:()=>Y(!D),"aria-label":"Settings",children:r(q,{name:"cog"})}),r("button",{className:`${w.controlBtn} ${w.theaterBtn} ${Te?w.active:""} `,onClick:m=>{m.stopPropagation(),N()},title:Te?"Exit Theater Mode":"Theater Mode","aria-label":Te?"Exit Theater Mode":"Theater Mode",children:r(q,{name:"tv"})}),r("button",{className:w.controlBtn,onClick:h.toggleFullscreen,"aria-label":o.isFullscreen?"Exit Fullscreen":"Fullscreen",children:o.isFullscreen?r(q,{name:"compress"}):r(q,{name:"expand"})})]})]})]})}),pt=r(Or,{fallback:null,children:r(bs,{ref:V,isOpen:D,onClose:()=>Y(!1),videoSources:R,currentSource:E,currentLink:L,onSourceChange:B,subtitles:o.availableSubtitles,activeSubtitleTrack:o.activeSubtitleTrack,onSubtitleChange:dt,subtitleSettings:{fontSize:o.subtitleFontSize,position:o.subtitlePosition,bgOpacity:o.subtitleBgOpacity,bgColor:o.subtitleBgColor,textColor:o.subtitleTextColor,edge:o.subtitleEdge,bold:o.subtitleBold},onSubtitleSettingsChange:(m,P)=>{const T=(Ue,Ie)=>{try{localStorage.setItem(Ue,String(Ie))}catch{}};switch(m){case"fontSize":h.setSubtitleFontSize(P),T("subtitleFontSize",P);break;case"position":h.setSubtitlePosition(P),T("subtitlePosition",P);break;case"bgOpacity":h.setSubtitleBgOpacity(P),T("subtitleBgOpacity",P);break;case"bgColor":h.setSubtitleBgColor(P),T("subtitleBgColor",P);break;case"textColor":h.setSubtitleTextColor(P),T("subtitleTextColor",P);break;case"edge":h.setSubtitleEdge(P),T("subtitleEdge",P);break;case"bold":h.setSubtitleBold(P),T("subtitleBold",P);break}},useNativeControls:o.useNativeControls,onNativeControlsToggle:h.setUseNativeControls,anime4kEnabled:ae,onAnime4kToggle:Fe,anime4kSupported:W,anime4kProfile:A,onAnime4kProfileChange:$,anime4kInitializing:Oe,anime4kError:He,videoDelayEnabled:a,onVideoDelayToggle:p,videoDelayMs:M,onVideoDelayChange:pe,onCalibrateAvSync:We,isAutoSkipEnabled:o.isAutoSkipEnabled,onAutoSkipChange:m=>{h.setIsAutoSkipEnabled(m);try{localStorage.setItem("autoSkipEnabled",m.toString())}catch{}},isAutoplayEnabled:g,onAutoplayChange:k,fallbackChoice:je,onFallbackChoiceChange:be})}),lt=D?r("div",{"data-speed-boost-ignore":"true",onClick:m=>m.stopPropagation(),children:pt}):null;return r(on,{player:n,topBar:yt,centerControls:F,bottomBar:!z&&!o.isBuffering&&o.duration>0?Ve:null,settingsPanel:lt,overlays:ee,isInteracting:Ce,className:ce,chromeDisabled:d,children:Ye})},Ss=({count:n=3})=>r("section",{className:ot.section,children:[r("div",{className:ot.header,children:r("button",{className:ot.headerToggle,disabled:!0,children:[r("span",{className:ot.title,children:r(Nt,{width:"60px",height:"1.2rem",variant:"text"})}),r(q,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:ot.list,children:Array.from({length:n}).map((g,k)=>r("div",{className:ot.item,style:{pointerEvents:"none"},children:[r("div",{className:ot.dragHandle,style:{opacity:.2},children:r(Nt,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:ot.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(Nt,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:ot.meta,children:[r(Nt,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(Nt,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},k))})]}),Es="_sourceSelectionContainer_c5tub_76",ws="_providerSelectContainer_c5tub_89",ks="_providerSelect_c5tub_89",Ts="_sourceSelect_c5tub_76",Cs="_sourceButtons_c5tub_145",Rs="_sourceButton_c5tub_145",Ms="_active_c5tub_170",gt={sourceSelectionContainer:Es,providerSelectContainer:ws,providerSelect:ks,sourceSelect:Ts,sourceButtons:Cs,sourceButton:Rs,active:Ms},_s=({selectedProvider:n,onProviderChange:g,isAdult:k,options:j})=>{const b=j&&j.length>0?j:[],R=k===void 0?b:b.filter(E=>E.mature===k);return r("div",{className:gt.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:gt.providerSelect,value:n,onChange:E=>g(E.target.value),children:In.map(E=>{const L=R.filter(B=>(B.tier??"direct")===E);return L.length===0?null:r("optgroup",{label:Ln[E],children:L.map(B=>r("option",{value:B.value,children:B.sub?`${B.label} (${Bn[B.sub]})`:B.label},B.value))},E)})})]})},Ns=({videoSources:n,selectedSource:g,selectedLink:k,onSourceChange:j,onLinkChange:b})=>{const R=Array.isArray(n)?n:[];if(R.length===0)return null;const E=g?.type==="iframe"&&(g.links?.length??0)>1;return r("div",{className:gt.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:gt.sourceButtons,children:R.map((L,B)=>r("button",{className:`${gt.sourceButton} ${g?.sourceName===L.sourceName?gt.active:""} `,onClick:()=>j(L),children:L.sourceName},`${L.sourceName}-${B}`))}),E&&r("select",{className:gt.sourceSelect,"aria-label":"Fallback embed quality",value:k?.link??g.links[0]?.link??"",onChange:L=>{const B=g.links.find(z=>z.link===L.target.value);B&&b(B)},children:g.links.map(L=>r("option",{value:L.link,children:L.resolutionStr},L.link))})]})},Ps=Wt.memo(Ns,(n,g)=>n.selectedSource?.sourceName===g.selectedSource?.sourceName&&n.selectedLink?.link===g.selectedLink?.link&&n.videoSources===g.videoSources),xs={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},As={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Bs=5,Ls=15e3,Is=`
3
+ @group(0) @binding(0) var extTex: texture_external;
4
+ @group(0) @binding(1) var extSamp: sampler;
5
+ struct VSOut {
6
+ @builtin(position) pos: vec4f,
7
+ @location(0) uv: vec2f,
8
+ };
9
+ @vertex
10
+ fn vs(@builtin(vertex_index) idx: u32) -> VSOut {
11
+ var positions = array<vec2f, 6>(
12
+ vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
13
+ vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
14
+ );
15
+ var uvs = array<vec2f, 6>(
16
+ vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
17
+ vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
18
+ );
19
+ var out: VSOut;
20
+ out.pos = vec4f(positions[idx], 0.0, 1.0);
21
+ out.uv = uvs[idx];
22
+ return out;
23
+ }
24
+ @fragment
25
+ fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
26
+ return textureSampleBaseClampToEdge(extTex, extSamp, uv);
27
+ }
28
+ `;function Ds({videoRef:n,canvasRef:g,profile:k="balanced",delayMs:j=0}){const[b,R]=Q(!1),[E,L]=Q(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[B,z]=Q(!1),[ke,e]=Q(null),[f,Te]=Q(0),N=v(0),ae=v(null),Fe=v(null),W=v(null),A=v(null),$=v(null),Oe=v(null),He=v(null),a=v(null),p=v(null),M=v(!1),pe=v(-1),We=v(0),je=v(j);je.current=j;const be=v([]),Ye=v(!1),ee=v(!1),Ce=v(!1),ce=v(null),d=v(-1),o=v(-1),l=v(!1),h=v(0);x(()=>{async function G(){if(typeof navigator>"u"||!navigator.gpu){R(!1);return}try{const V=await navigator.gpu.requestAdapter();R(!!V)}catch{R(!1)}}G()},[]),x(()=>{if(!E||!b)return;let G=!1;const V=++N.current,ie=K=>{if(K)try{K.close()}catch{}},ye=()=>{for(const K of be.current)ie(K.bitmap);be.current=[]},at=K=>Math.max(8,Math.min(40,Math.ceil(K/16.7)+4));function Xe(){p.current!==null&&(cancelAnimationFrame(p.current),p.current=null)}async function bt(){let K=n.current;const it=g.current;if(!K||!it||N.current!==V)return;const dt=performance.now()+Ls;for(;(!K||K.videoWidth===0)&&performance.now()<dt;){if(await new Promise(T=>requestAnimationFrame(T)),G||N.current!==V)return;K=n.current}if(!K||K.videoWidth===0){!G&&N.current===V&&(e("Timed out waiting for video metadata"),z(!1),L(!1));return}const te=K.videoWidth,ue=K.videoHeight,Re=Math.max(te,ue),yt=window.innerWidth,F=window.innerHeight,Ve=Math.max(yt,F),pt=Re<Ve?Ve/Re:1,lt=xs[k],m=Re<=480?lt.sd:Re<=720?lt.hd:Re<=1080?lt.fhd:1,P=Math.min(m,pt);it.width=Math.round(te*P),it.height=Math.round(ue*P),z(!0),e(null),We.current=0,pe.current=-1,d.current=-1,o.current=-1,l.current=!1,h.current=0,ye(),M.current=!1;try{let T=function(){G||N.current!==V||(Xe(),p.current=requestAnimationFrame(()=>{mt()}))};const{ModeA:Ue,ModeB:Ie,ModeC:Tt,ModeAA:Jt}=await fr(async()=>{const{ModeA:I,ModeB:re,ModeC:$e,ModeAA:ne}=await import("./index-BOKlZEHq.js").then(me=>me.i);return{ModeA:I,ModeB:re,ModeC:$e,ModeAA:ne}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const Pt=await navigator.gpu.requestAdapter();if(!Pt)throw new Error("No GPU adapter found");const _=await Pt.requestDevice();if(!_)throw new Error("Failed to get GPU device");const De=it.getContext("webgpu");if(!De)throw new Error("Failed to get WebGPU context");const Je=navigator.gpu.getPreferredCanvasFormat();De.configure({device:_,format:Je,alphaMode:"premultiplied"});const Se=_.createTexture({size:[te,ue],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Ct=As[k],qe=Math.round(te*P),Qe=Math.round(ue*P),Ze=(()=>{switch(Ct){case"ModeB":return new Ie({device:_,inputTexture:Se,nativeDimensions:{width:te,height:ue},targetDimensions:{width:qe,height:Qe}});case"ModeC":return new Tt({device:_,inputTexture:Se,nativeDimensions:{width:te,height:ue},targetDimensions:{width:qe,height:Qe}});case"ModeAA":return new Jt({device:_,inputTexture:Se,nativeDimensions:{width:te,height:ue},targetDimensions:{width:qe,height:Qe}});default:return new Ue({device:_,inputTexture:Se,nativeDimensions:{width:te,height:ue},targetDimensions:{width:qe,height:Qe}})}})(),ze=Ze.getOutputTexture(),Me=_.createSampler({magFilter:"linear",minFilter:"linear"}),et=_.createShaderModule({code:`
29
+ @group(0) @binding(0) var tex: texture_2d<f32>;
30
+ @group(0) @binding(1) var samp: sampler;
31
+ struct VertexOutput {
32
+ @builtin(position) pos: vec4f,
33
+ @location(0) uv: vec2f,
34
+ }
35
+ @vertex
36
+ fn vs(@builtin(vertex_index) idx: u32) -> VertexOutput {
37
+ var positions = array<vec2f, 6>(
38
+ vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(-1.0, 1.0),
39
+ vec2f(-1.0, 1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0)
40
+ );
41
+ var uvs = array<vec2f, 6>(
42
+ vec2f(0.0, 1.0), vec2f(1.0, 1.0), vec2f(0.0, 0.0),
43
+ vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(1.0, 0.0)
44
+ );
45
+ var out: VertexOutput;
46
+ out.pos = vec4f(positions[idx], 0.0, 1.0);
47
+ out.uv = uvs[idx];
48
+ return out;
49
+ }
50
+ @fragment
51
+ fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
52
+ return textureSample(tex, samp, uv);
53
+ }
54
+ `}),St=_.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),_e=_.createRenderPipeline({layout:_.createPipelineLayout({bindGroupLayouts:[St]}),vertex:{module:et,entryPoint:"vs"},fragment:{module:et,entryPoint:"fs",targets:[{format:Je}]},primitive:{topology:"triangle-list"}}),xt=_.createBindGroup({layout:St,entries:[{binding:0,resource:ze.createView()},{binding:1,resource:Me}]});try{const I=_.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),re=_.createShaderModule({code:Is}),$e=_.createRenderPipeline({layout:_.createPipelineLayout({bindGroupLayouts:[I]}),vertex:{module:re,entryPoint:"vs"},fragment:{module:re,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});ce.current={pipeline:$e,layout:I,inputView:Se.createView()}}catch{ce.current=null}if(N.current!==V){Se.destroy(),_.destroy();return}ae.current=_,Fe.current=De,W.current=Ze,A.current=Se,$.current=ze,Oe.current=_e,He.current=Me,a.current=St,ee.current=!1,Ce.current=!1;async function Rt(){const I=ce.current;if(!I||ee.current)return!1;const re=n.current;if(!re)return!1;const $e=!Ce.current;$e&&_.pushErrorScope("validation");try{const ne=_.importExternalTexture({source:re}),me=_.createBindGroup({layout:I.layout,entries:[{binding:0,resource:ne},{binding:1,resource:Me}]}),Ee=_.createCommandEncoder(),Ne=Ee.beginRenderPass({colorAttachments:[{view:I.inputView,loadOp:"load",storeOp:"store"}]});Ne.setPipeline(I.pipeline),Ne.setBindGroup(0,me),Ne.draw(6),Ne.end(),_.queue.submit([Ee.finish()])}catch{return ee.current=!0,ce.current=null,!1}if($e){const ne=await _.popErrorScope().catch(()=>null);if(ne)return console.warn("[anime4k] blit probe failed:",ne.message),ee.current=!0,ce.current=null,!1;Ce.current=!0}return!0}z(!1);async function mt(){if(G||N.current!==V)return;const I=n.current;if(!I||I.videoWidth===0){T();return}if(I!==K||I.videoWidth!==te||I.videoHeight!==ue){Te(me=>me+1);return}if(I.paused||I.ended||document.hidden||I.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){T();return}const re=I.getVideoPlaybackQuality().totalVideoFrames;if(re===o.current){T();return}if(M.current){T();return}const $e=I.currentTime;(I.seeking||d.current>=0&&Math.abs($e-d.current)>.5)&&(ye(),l.current=!1,h.current=0,o.current=-1),d.current=$e;const ne=Math.max(0,je.current||0);ne>h.current&&(l.current=!1),M.current=!0;try{const me=performance.now();let Ee=null,Ne=!1;if(ne<=0){be.current.length>0&&ye(),l.current=!1,h.current=0;let Pe=!1;if(!Ye.current)try{_.queue.copyExternalImageToTexture({source:I},{texture:Se},[te,ue]),o.current=re,Pe=!0}catch(y){if(y instanceof TypeError)Ye.current=!0;else throw y}if(!Pe&&!ee.current&&ce.current&&await Rt()&&(o.current=re,Pe=!0),!Pe){const y=await createImageBitmap(I);o.current=re,_.queue.copyExternalImageToTexture({source:y},{texture:Se},[te,ue]),ie(y)}}else{const Pe=await createImageBitmap(I);o.current=re;const y=be.current;y.push({bitmap:Pe,capture:me});const Vt=at(ne);for(;y.length>Vt;)ie(y.shift()?.bitmap);let rt=-1;for(let fe=y.length-1;fe>=0;fe--)if(me-y[fe].capture>=ne){rt=fe;break}if(rt!==-1){for(let At=0;At<rt;At++)ie(y.shift()?.bitmap);const fe=y.shift();fe?(Ee=fe.bitmap,l.current=!0,h.current=ne):(Ee=Pe,Ne=!0)}else if(!l.current)Ee=Pe,Ne=!0;else{const fe=y.shift();Ee=fe?fe.bitmap:Pe,fe||(Ne=!0)}if(!Ee){M.current=!1,T();return}_.queue.copyExternalImageToTexture({source:Ee},{texture:Se},[te,ue]),Ne||ie(Ee)}const ve=_.createCommandEncoder();await Ze.pass(ve);const tt=ve.beginRenderPass({colorAttachments:[{view:De.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});tt.setPipeline(_e),tt.setBindGroup(0,xt),tt.draw(6),tt.end(),_.queue.submit([ve.finish()]),pe.current=re,We.current=0,_.queue.onSubmittedWorkDone().then(()=>{N.current===V&&(M.current=!1)})}catch(me){if(M.current=!1,We.current+=1,We.current>=Bs&&!G&&N.current===V){console.error(me),e(me instanceof Error?me.message:"Render error"),L(!1);return}}T()}T()}catch(T){!G&&N.current===V&&(e(T instanceof Error?T.message:"Failed to initialize upscaler"),z(!1),L(!1))}}return bt(),()=>{G=!0,N.current+=1,Xe(),ye(),A.current&&(A.current.destroy(),A.current=null),$.current&&($.current.destroy(),$.current=null),ae.current&&(ae.current.destroy(),ae.current=null),W.current=null,Oe.current=null,He.current=null,a.current=null,ce.current=null,Fe.current=null,M.current=!1}},[E,b,n,g,k,f]);const D=O(G=>{L(G);try{localStorage.setItem("anime4kEnabled",String(G))}catch{}},[]),Y=O(()=>{L(G=>{const V=!G;try{localStorage.setItem("anime4kEnabled",String(V))}catch{}return V})},[]);return{isWebGPUSupported:b,isEnabled:E,isInitializing:B,error:ke,toggle:Y,setEnabled:D}}const $s=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Fs=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},gr=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:$s(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,forceNativePlayer:localStorage.getItem("forceNativePlayer")==="true",isAutoplayEnabled:ln(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Fs(),loadingShowData:!0,loadingVideo:!1,loadingDetails:!1,error:null,detailsError:null,showCookieModal:!1,cookieProvider:null});gr();function Os(n,g){switch(g.type){case"SET_STATE":return{...n,...g.payload};case"SET_MODE":return{...n,currentMode:g.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:g.payload};case"SET_OVERRIDE_SOURCE":return{...n,selectedSource:g.payload?.source??null,selectedLink:g.payload?.link??null};default:return n}}async function mr(n,g,k,j,b=!1){if(!n||!g)throw new Error("Missing params");try{const[R,E,L,B]=await Promise.all([Le.data.video.query({showId:n,episodeNumber:g,mode:k.currentMode,provider:k.selectedProvider}).catch(()=>null),Le.progress.getEpisode.query({showId:n,episodeNumber:g}).catch(()=>null),Le.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Le.data.skipTimes.query({showId:n,episodeNumber:g}).catch(()=>[])]),z=L?.value,ke=R?.filter(A=>{const $=A.sourceName.toLowerCase();return k.currentMode==="dub"?$.includes("eng")||$.includes("dub"):$.includes("jpn")||$.includes("sub")||!$.includes("eng")&&!$.includes("dub")})??[],e=ke.length>0?ke:R??[];let f=e.length>0?e[0]:null;if(z){const A=e.find($=>$.sourceName===z);A&&(f=A)}const Te=f&&f.links.length>0?f.links.sort((A,$)=>(parseInt($.resolutionStr)||0)-(parseInt(A.resolutionStr)||0))[0]:null,N=E?.currentTime||0,ae=E?.duration||0,W=(Array.isArray(B)?B:B?.results||[]).map(A=>({skip_id:A.skip_id||"",skip_type:A.skip_type||"",start_time:A.interval?.start_time??A.start_time??0,end_time:A.interval?.end_time??A.end_time??0})).filter(A=>A.end_time>0);return(!R||R.length===0)&&(b||Ke.error(`No video sources found for ${k.selectedProvider}`)),{videoSources:R,selectedSource:f,selectedLink:Te,resumeTime:N,resumeDuration:ae,showResumeModal:N>5&&f?.type!=="iframe",skipIntervals:W,fetchedEpisodeNumber:g}}catch(R){const E=R;if(E.message==="AUTH_REQUIRED")return j({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:E.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:g};throw R}}const Ws=(n,g,k,j)=>{const[b,R]=Vr(Os,k,d=>({...gr(),showMeta:d?.name?{name:d.name,thumbnail:d.thumbnail,nativeName:d.nativeName,englishName:d.englishName,names:{romaji:d.name||d.englishName,english:d.englishName||d.name,native:d.nativeName}}:{}})),E=hr(),L=Gr(),B=v(null),z=v(null),{options:ke}=vr(),e=ut(()=>ke.filter(d=>(d.kind??"anime")==="anime"),[ke]),f=g||b.initialEpisode,Te=v(f);x(()=>{Te.current!==f&&(Te.current=f,R({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[f,R]),x(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&b.selectedProvider!=="animepahe"&&B.current!==n&&(B.current=n,R({type:"SET_PROVIDER",payload:"animepahe"}))},[n,b.selectedProvider]);const{data:N,isLoading:ae,error:Fe}=Nn(n),{data:W}=ur({queryKey:["player-data",n,b.currentMode,b.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const d=async()=>{try{const Y=await Le.data.episodes.query({showId:n,mode:b.currentMode,provider:b.selectedProvider}).catch(()=>null);if(Y?.episodes?.length)return Y}catch{}return null},[o,l,h]=await Promise.all([d(),Le.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Le.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),D=o?.episodes?o.episodes.sort((Y,G)=>parseFloat(Y)-parseFloat(G)):[];return{description:o?.description||"",episodes:D,inWatchlist:l.inWatchlist,watchlistStatus:l.status??null,watchedEpisodes:h}},enabled:!!n});x(()=>{!g&&W?.episodes&&W.episodes.length>0&&!g&&R({type:"SET_STATE",payload:{initialEpisode:W.episodes[0]}})},[W,g]),x(()=>{if(N?.isAdult===void 0)return;const o=new Set(e.filter(l=>l.mature).map(l=>l.value)).has(b.selectedProvider);if(z.current!==n){if(N.isAdult&&!o){z.current=n;const l=e.find(h=>h.mature);if(!l)return;R({type:"SET_PROVIDER",payload:l.value}),localStorage.setItem("preferredProvider",l.value)}if(!N.isAdult&&o){z.current=n;const l=e.find(h=>!h.mature);if(!l)return;R({type:"SET_PROVIDER",payload:l.value}),localStorage.setItem("preferredProvider",l.value)}}},[N?.isAdult,b.selectedProvider,n,e]),x(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||z.current===`temp:${n}`)return;const d=N?.provider;d&&(z.current=`temp:${n}`,d!==b.selectedProvider&&R({type:"SET_PROVIDER",payload:d}))},[n,N,b.selectedProvider]);const{data:A,isLoading:$,error:Oe}=ur({queryKey:["video-sources",n,f,b.selectedProvider,b.currentMode],queryFn:()=>mr(n,f,b,R),enabled:!!n&&!!f&&!(b.showMeta?.isAdult===!0&&!j?.hasMatureConsent)}),He=!1,{mutateAsync:a}=jt({mutationFn:async({wasIn:d,showMeta:o})=>{if(!n)throw new Error("Missing showId");if(d)await Le.watchlist.remove.mutate({id:n});else{const l=o.name||o.names?.romaji;if(!l)throw new Error("Missing show name");await Le.watchlist.add.mutate({id:n,name:l,thumbnail:o.thumbnail,nativeName:o.names?.native,englishName:o.names?.english,type:o.type,isAdult:o.isAdult})}return!d},onSuccess:d=>{Ke.success(d?"Added to watchlist":"Removed from watchlist"),E.invalidateQueries({queryKey:["player-data",n]}),E.invalidateQueries({queryKey:["show-data",n]}),E.invalidateQueries({queryKey:["watchlist"]})},onError:d=>Ke.error(d instanceof Error?d.message:"Failed to update watchlist")}),p=O(async()=>{!n||!N||await a({wasIn:!!W?.inWatchlist,showMeta:N})},[n,N,W?.inWatchlist,a]),M=O(async d=>{try{await Le.settings.set.mutate({key:"preferredSource",value:d})}catch(o){console.error(o)}},[]),{mutateAsync:pe,isPending:We}=jt({mutationFn:async({status:d})=>{if(!n)throw new Error("Missing showId");return await Le.watchlist.setStatus.mutate({id:n,status:d}),d},onSuccess:d=>{R({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:d}}),Ke.success(`Moved to ${d}`),E.invalidateQueries({queryKey:["show-data",n]}),E.invalidateQueries({queryKey:["watchlist"]}),E.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>Ke.error("Failed to update watchlist status")}),je=O(async()=>{await pe({status:"Completed"})},[pe]),{mutateAsync:be}=jt({mutationFn:async({episodeNumber:d,duration:o,showMeta:l,episodes:h})=>{await _n("/api/update-progress",{method:"POST",body:JSON.stringify({showId:n,episodeNumber:d,currentTime:o,duration:o,showName:l.name,showThumbnail:l.thumbnail,nativeName:l.names?.native,englishName:l.names?.english,genres:l.genres?.map(D=>D.name),popularityScore:Kr(l.score??l.stats?.averageScore),type:l.type,status:l.status,episodeCount:h.length,isAdult:l.isAdult}),keepalive:!0})},onSuccess:(d,o)=>{Ke.success(`Episode ${o.episodeNumber} marked as watched`),E.invalidateQueries({queryKey:["player-data",n]}),E.invalidateQueries({queryKey:["show-meta",n]}),E.invalidateQueries({queryKey:["video-sources",n,o.episodeNumber]}),E.invalidateQueries({queryKey:["allContinueWatching"]}),E.invalidateQueries({queryKey:["thisWeekSchedule"]}),E.invalidateQueries(L.continueWatching.pathFilter())},onError:()=>Ke.error("Failed to mark episode as watched")}),Ye=O(async(d,o)=>{!n||!N||await be({episodeNumber:d,duration:o,showMeta:N,episodes:W?.episodes||[]})},[n,N,W?.episodes,be]),ee=O(async()=>{R({type:"SET_STATE",payload:{showCombinedDetails:!b.showCombinedDetails}})},[b.showCombinedDetails]),Ce=ut(()=>{const d=Fe||Oe,o=d?d.message:null,l=o==="AUTH_REQUIRED"?null:o,h=A&&A.fetchedEpisodeNumber===f?A:null,D=!!A&&!h;return{...b,currentEpisode:f,showMeta:{...b.showMeta||{},...N||{}},episodes:W?.episodes||[],watchedEpisodes:W?.watchedEpisodes||[],inWatchlist:!!W?.inWatchlist,watchlistStatus:W?.watchlistStatus??b.watchlistStatus??null,videoSources:h?.videoSources||[],selectedSource:b.selectedSource||h?.selectedSource||null,selectedLink:b.selectedLink||h?.selectedLink||null,resumeTime:h?.resumeTime||0,resumeDuration:h?.resumeDuration||0,showResumeModal:b.showResumeModal&&(h?.showResumeModal??!1),skipIntervals:h?.skipIntervals||[],loadingShowData:ae,loadingVideo:$||D,loadingDetails:He,error:l,fetchedEpisodeNumber:h?.fetchedEpisodeNumber}},[b,N,W,A,ae,$,He,Fe,Oe,f]),ce=O((d,o)=>{const l=o||n;if(!l||!d||l===n&&d===f)return;const D=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(l)&&b.selectedProvider!=="animepahe"?"animepahe":b.selectedProvider,Y=["video-sources",l,d,D,b.currentMode];E.getQueryState(Y)?.status!=="success"&&E.prefetchQuery({queryKey:Y,queryFn:()=>mr(l,d,{selectedProvider:D,currentMode:b.currentMode},R,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,f,E,b,R]);return{state:Ce,dispatch:R,toggleWatchlist:p,moveToCompleted:je,setPreferredSource:M,handleToggleDetails:ee,markEpisodeWatched:Ye,prefetchEpisodeSources:ce,isMarkingWatched:be.isPending,isUpdatingWatchlistStatus:We}},Xt="fallbackChoice";function Vs(){try{const n=localStorage.getItem(Xt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Us(n){try{n===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,n)}catch{}}const io=()=>{const{id:n,episodeNumber:g}=Ur(),k=qr(),j=hr(),b=Qr(),{hasConsent:R,grant:E}=Cn(),{options:L}=vr(),B=ut(()=>L.filter(t=>(t.kind??"anime")==="anime"),[L]),z=ut(()=>B.map(t=>t.value),[B]),ke=ut(()=>new Set(B.filter(t=>t.mature).map(t=>t.value)),[B]),{state:e,dispatch:f,toggleWatchlist:Te,moveToCompleted:N,setPreferredSource:ae,handleToggleDetails:Fe,markEpisodeWatched:W,prefetchEpisodeSources:A,isMarkingWatched:$,isUpdatingWatchlistStatus:Oe}=Ws(n,g,b.state||null,{hasMatureConsent:R});x(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=g?`/watch/${e.showMeta.id}/${g}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;k(t,{replace:!0})}},[n,e.showMeta?.id,g,k]);const He=ut(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),a=cn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:He}),{refs:p,actions:M}=a,pe=v(null),We=Rn(),je=v(null),be=v(null),Ye=v(null),ee=v(0),Ce=v(e.resumeTime),ce=v(e.showResumeModal),[d,o]=Q(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),[l,h]=Q(()=>{try{const t=Number(localStorage.getItem("playerVideoDelayMs"));if(Number.isFinite(t)&&t>=0&&t<=500)return Math.round(t)}catch{}return 180}),[D,Y]=Q(()=>{try{return localStorage.getItem("playerVideoDelayEnabled")==="true"}catch{return!1}}),[G,V]=Q(!1),[ie,ye]=Q(!1),at=v(null),Xe=v(null),bt=(t,s)=>{try{localStorage.setItem("playerVideoDelayMs",String(t)),localStorage.setItem("playerVideoDelayEnabled",String(s))}catch{}},K=t=>{const s=Math.max(0,Math.min(500,Math.round(t)));h(s);try{localStorage.setItem("playerVideoDelayMs",String(s))}catch{}},it=()=>{at.current={enabled:D,ms:l},Y(!0);try{localStorage.setItem("playerVideoDelayEnabled","true")}catch{}M.setShowSettings(!1),V(!0)},dt=()=>{const t=at.current;at.current=null,t&&(h(t.ms),Y(t.enabled),bt(t.ms,t.enabled)),ye(!1),V(!1)},te=()=>{at.current=null,Y(!0),bt(l,!0),ye(!1),V(!1)},ue=()=>{if(ie){ye(!1);return}const t=p.videoRef.current;t&&!isNaN(t.currentTime)&&(Xe.current=t.currentTime),ye(!0)},Re=D?l:0,yt=v(null),F=Ds({videoRef:p.videoRef,canvasRef:be,profile:d,delayMs:Re}),Ve=F.isEnabled&&F.isWebGPUSupported,pt=`${n??""}:${e.currentEpisode??""}`,lt=v(null),m=v(!1),P=v(!1),T=v(F.setEnabled);T.current=F.setEnabled,x(()=>{const t=lt.current;lt.current=pt,!(t===null||t===pt)&&(!F.isEnabled||!F.isWebGPUSupported||(m.current=!0,P.current=!1,T.current(!1)))},[pt,F.isEnabled,F.isWebGPUSupported]),x(()=>{if(!m.current)return;if(F.isEnabled){P.current&&(m.current=!1);return}if(P.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){m.current=!1,T.current(!0);return}const t=p.videoRef.current;if(!t)return;let s,i=!1;const c=()=>{i||(i=!0,m.current=!1,T.current(!0))};if(t.readyState>=2)return s=window.setTimeout(c,500),()=>window.clearTimeout(s);const C=()=>{window.setTimeout(c,500)};return t.addEventListener("canplay",C,{once:!0}),t.addEventListener("playing",C,{once:!0}),s=window.setTimeout(c,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",C),t.removeEventListener("playing",C)}},[F.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,p.videoRef]),un({videoRef:p.videoRef,canvasRef:yt,delayMs:Re,enabled:D&&!Ve});const Ue=D&&!Ve,Ie=Ve||Ue;x(()=>{Ce.current=e.resumeTime,ce.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[Tt,Jt]=Q(null),[Pt,_]=Q(!1),[De,Je]=Q(!1),[Se,Ct]=Q(!1),qe=v(!1),[Qe,Ze]=Q(null),ze=v(!1),Me=v([]),et=v(!1),[St,_e]=Q(null),[xt,Rt]=Q(!1),[mt,I]=Q(!1),[re,$e]=Q(()=>Vs()??"ask"),ne=O(t=>{$e(t),Us(t==="ask"?null:t)},[]),me=v(re);me.current=re;const Ee=v(e.videoSources);Ee.current=e.videoSources;const Ne=v(()=>{}),[ve,tt]=Q(null),Pe=v(g);x(()=>{Pe.current!==g&&(Pe.current=g,tt(null),Ze(null),qe.current=!1,ye(!1),V(!1))},[g]),x(()=>{ze.current=!1,Me.current=[],et.current=!1,_e(null),Rt(!1)},[n,e.currentEpisode]),x(()=>{De||(qe.current=!1)},[De]);const{data:y=[],isLoading:Vt}=Hr(),rt=jr(),fe=v(rt);fe.current=rt;const At=Yr(),br=Xr(),[ge,Ut]=Q(()=>{try{return localStorage.getItem("playerTheaterMode")==="true"}catch{return!1}});x(()=>{try{ge?document.body.classList.add("theater-mode"):document.body.classList.remove("theater-mode")}catch(t){console.error(t)}return()=>{try{document.body.classList.remove("theater-mode")}catch(t){console.error(t)}}},[ge]),zr(()=>{if(a.state.isFullscreen||ge)return;const t=p.playerContainerRef.current,s=je.current;if(!t||!s)return;const i=()=>{const C=t.getBoundingClientRect().height;s.style.height=`${C}px`};i();const c=new ResizeObserver(i);return c.observe(t),()=>c.disconnect()},[a.state.isFullscreen,ge,p.playerContainerRef]);const ft=ut(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),qt=ft>0?e.episodes[ft-1]:null,xe=ft>=0&&ft<e.episodes.length-1?e.episodes[ft+1]:null,Qt=ft>-1&&ft<e.episodes.length-1,yr=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,Sr=String(e.showMeta.status||"").trim().toLowerCase(),Er=["finished","completed","complete","ended"].some(t=>Sr.includes(t)),zt=dn(e.resumeTime,e.resumeDuration)||De,ct=yr&&Er&&zt,Zt=e.showResumeModal&&(ct||!zt),Bt=zt&&!ct&&y.length===0&&!ve&&(e.showResumeModal||De),ht=Zt||Bt;pn(a,!!e.selectedLink&&!ge&&!ht),x(()=>{const t=p.videoRef.current;if(!t)return;let s=!1;for(pe.current&&(pe.current.destroy(),pe.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(ie)return t.src="/av-sync-test.mp4",t.play().catch(()=>{M.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){ee.current=0;return}Xe.current!=null?(ee.current=Xe.current,Xe.current=null):Ce.current>5&&!ce.current?ee.current=Ce.current:ce.current&&(ee.current=0);let i=e.selectedLink.link;if(i.startsWith("/api/proxy")||(i=`/api/proxy?url=${encodeURIComponent(i)}`,e.selectedLink.headers?.Referer&&(i+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const de=localStorage.getItem("playerSubtitlesEnabled")!=="false";let we=null;try{we=localStorage.getItem("playerLastSubtitle")}catch{}const X=Yt(e.selectedSource.subtitles,{lastKey:we,enabled:de}),Ae=X>=0?e.selectedSource.subtitles[X]:null;e.selectedSource.subtitles.forEach(he=>{const J=document.createElement("track");J.kind="subtitles",J.label=he.label,J.srclang=he.lang;const S=he.src??he.url;if(S){let Z=`/api/subtitle-proxy?url=${encodeURIComponent(S)}`;const oe=e.selectedLink?.headers?.Referer,Et=S.includes("anilight.live")?"https://anilight.live/":"",Ot=oe||Et;Ot&&(Z+=`&referer=${encodeURIComponent(Ot)}`),J.src=Z}Ae&&he.label===Ae.label&&he.lang===Ae.lang&&(J.default=!0),t.appendChild(J)}),de||M.setActiveSubtitleTrack("off"),M.setAvailableSubtitles(e.selectedSource.subtitles)}const c=ee.current;ee.current=0;const C=()=>{c>0&&(t.currentTime=c)};t.addEventListener("loadedmetadata",C,{once:!0});const le=!(ce.current&&Ce.current>5),H=()=>{le&&t.play().catch(()=>{M.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const de=await Tn();if(s)return;if(!de||!de.isSupported()){t.src=i,H();return}const we=document.body.classList.contains("low-end"),X=new de({maxBufferLength:we?15:30,maxMaxBufferLength:we?30:60,maxBufferSize:we?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});pe.current=X,X.on(de.Events.ERROR,(J,S)=>{S.fatal&&!ze.current&&Ne.current()});const Ae=(e.selectedSource?.subtitles?.length??0)>0,he=()=>{try{Ae&&typeof X.subtitleTrack=="number"&&X.subtitleTrack!==-1&&(X.subtitleTrack=-1)}catch{}};X.on(de.Events.SUBTITLE_TRACK_SWITCH,(J,S)=>{S?.id!==-1&&he()}),he(),X.loadSource(i),X.attachMedia(t),X.once(de.Events.MANIFEST_PARSED,()=>{s||H()})})():(t.src=i,H());const U=localStorage.getItem("playerVolume"),se=localStorage.getItem("playerMuted");return U!==null&&(t.volume=parseFloat(U)),se!==null&&(t.muted=se==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",C),pe.current&&(pe.current.destroy(),pe.current=null)}},[e.selectedSource,e.selectedLink,p.videoRef,M,e.loadingVideo,ie]);const Lt=O(t=>{if(ze.current)return;ze.current=!0;const s=t.links[0];ae(t.sourceName),f({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),_e(null)},[f,ae]),It=O(()=>{const s=Ee.current.find(i=>i.type==="iframe");return s?.links?.length?s:null},[]),Dt=O(async()=>{const t=e.showMeta?.isAdult,s=z.filter(i=>{if(Me.current.includes(i))return!1;const c=ke.has(i);return t===void 0?!0:c===t});Rt(!0);try{for(const i of s){Me.current.push(i);let c=null;try{c=await Le.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:i})}catch{continue}const C=(c??[]).filter(U=>{const se=U.sourceName.toLowerCase();return e.currentMode==="dub"?se.includes("eng")||se.includes("dub"):se.includes("jpn")||se.includes("sub")||!se.includes("eng")&&!se.includes("dub")});if((C.length>0?C:c??[]).find(U=>U.type!=="iframe"&&U.links?.length)){Me.current=[e.selectedProvider],et.current=!1,f({type:"SET_STATE",payload:{selectedProvider:i,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",i),_e(null),Ke.success(`Switched to ${i} (direct stream)`);return}}_e({retryFailed:!0}),Ke.error("No working direct stream found on other providers")}finally{Rt(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,f,z,ke]),er=O(()=>{if(ze.current||et.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;Me.current.includes(e.selectedProvider)||Me.current.push(e.selectedProvider);const s=me.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}M.setShowControls(!0),_e({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,M]);Ne.current=er;const wr=O(()=>{et.current=!0,_e(null),I(!1)},[]),kr=O(()=>{mt&&ne("iframe");const t=It();t?Lt(t):_e(null)},[mt,ne,It,Lt]),Tr=O(()=>{mt&&ne("retry"),Dt()},[mt,ne,Dt]),Mt=(t,s,i)=>t.showId===s||!!i&&t.showId===i,$t=O(()=>{M.onEnded();const t=y.find(i=>Mt(i,n,e.showMeta?.id)&&i.episodeNumber===e.currentEpisode);if(y.length>0){const i=y.findIndex(C=>Mt(C,n,e.showMeta?.id)&&C.episodeNumber===e.currentEpisode),c=i>=0?y[i+1]||null:y[0];tt({nextItem:c,playedItem:t||null}),Ze(2)}else t&&fe.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&y.length===0){const i=e.episodes.findIndex(c=>c===e.currentEpisode);if(i>-1&&i<e.episodes.length-1){const c=e.episodes[i+1];j.invalidateQueries({queryKey:["allContinueWatching"]}),k(`/watch/${n}/${c}`),s=!0}}if(!s&&y.length===0&&!ve&&!qe.current){const i=e.episodes.length>0&&!!e.currentEpisode&&e.episodes[e.episodes.length-1]===e.currentEpisode,c=String(e.showMeta.status||"").trim().toLowerCase(),C=["finished","completed","complete","ended"].some(le=>c.includes(le));i&&C&&f({type:"SET_STATE",payload:{showResumeModal:!0}})}},[M,k,y,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,ve,f,j]),Gt=O(()=>{if(y.length===0)return;M.onEnded();const t=y.find(c=>Mt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),s=y.findIndex(c=>Mt(c,n,e.showMeta?.id)&&c.episodeNumber===e.currentEpisode),i=s>=0?y[s+1]||null:y[0];t&&rt.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),i?k(`/watch/${i.showId}/${i.episodeNumber}`):t&&f({type:"SET_STATE",payload:{showResumeModal:!0}})},[M,k,y,rt,n,e.showMeta?.id,e.currentEpisode,f]),_t=O(()=>{xe&&(j.invalidateQueries({queryKey:["allContinueWatching"]}),Je(!1),k(`/watch/${n}/${xe}`)),f({type:"SET_STATE",payload:{showResumeModal:!1}})},[xe,k,n,f,j]),tr=O(()=>{y.length>0?Gt():xe?_t():Ke.error("No next episode available")},[y.length,Gt,_t,xe]),Cr=()=>{qt&&k(`/watch/${n}/${qt}`)};x(()=>{const t=p.videoRef.current;if(!t)return;const s=()=>{ie||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,p.videoRef,ie]),x(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&$t()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[$t,e.selectedSource?.type]),x(()=>{if(!ve||Qe===null)return;if(Qe<=0){const{nextItem:s,playedItem:i}=ve;tt(null),Ze(null),i&&fe.current.mutate({showId:i.showId,episodeNumber:i.episodeNumber}),s?k(`/watch/${s.showId}/${s.episodeNumber}`):i&&f({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{Ze(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[ve,Qe,k,f]),x(()=>{ht&&a.state.isFullscreen&&a.actions.toggleFullscreen()},[ht,a.state.isFullscreen,a.actions]),x(()=>{ht&&p.videoRef.current&&p.videoRef.current.pause()},[ht,p.videoRef]);const{titlePreference:Ft}=Jr(),{lowEndMode:Rr}=Zr(),vt=ut(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Ft==="name"?t||"Loading...":Ft==="nativeName"?s?.native||t||"Loading...":Ft==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Ft,e.loadingShowData]);x(()=>{vt&&vt!=="Loading..."&&e.currentEpisode&&(document.title=`► ${vt} Episode ${e.currentEpisode} - dango`)},[vt,e.currentEpisode]),x(()=>{const t=s=>{if(!s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')&&(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(M.setShowControls(!0),a.actions.inactivityTimer.current&&clearTimeout(a.actions.inactivityTimer.current),a.actions.inactivityTimer.current=window.setTimeout(()=>{M.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&tr(),s.key.toLowerCase()==="t")){const c=!ge;Ut(c),localStorage.setItem("playerTheaterMode",c.toString())}};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[M,a.actions.inactivityTimer,tr,ge]);const{setAvailableSubtitles:rr,setActiveSubtitleTrack:Kt}=M;x(()=>{const t=p.videoRef.current;if(!t)return;const s=()=>{const i=Array.from(t.textTracks).map(c=>({label:c.label,lang:c.language,src:void 0,mode:c.mode}));rr(i)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[p.videoRef,rr]),x(()=>{if(a.state.activeSubtitleTrack===null&&a.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Yt(a.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Kt("off");return}const i=a.state.availableSubtitles[s];Kt(i.lang||i.label)}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,Kt]),x(()=>{const t=p.videoRef.current;if(!t||a.state.availableSubtitles.length===0)return;const s=a.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(C=>{C.mode="hidden"});return}let c=!1;if(Array.from(t.textTracks).forEach(C=>{const H=(C.language===s||C.label===s)&&!c;C.mode=H?"showing":"hidden",H&&(c=!0)}),!c&&t.textTracks.length>0){const C=Array.from(t.textTracks).find(le=>le.language==="en"||le.label==="English")||t.textTracks[0];C&&(C.mode="showing")}},[a.state.activeSubtitleTrack,a.state.availableSubtitles,p.videoRef]);const[nr,Mr]=Q(0);x(()=>{const t=p.videoRef.current;if(!t)return;const s=()=>Mr(t.clientHeight||0);s();const i=new ResizeObserver(s);return i.observe(t),()=>i.disconnect()},[p.videoRef,e.selectedSource,e.selectedLink]),x(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const i={fontSize:a.state.subtitleFontSize,position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold};s.textContent=dr(i);const c=p.videoRef.current;if(!c)return;const C=pr(a.state.subtitleFontSize,nr||c.clientHeight||720);s.textContent=dr({...i,fontSize:C});const le=()=>{const S=Number(a.state.subtitlePosition),Z=isNaN(S)?0:Math.max(0,Math.min(100,S));return Math.max(0,Math.min(100,100-Z))},H=(S,Z)=>{try{const oe=S;oe.snapToLines=!1,oe.line=Z}catch{}},U=()=>{const S=C*16,Z=c.videoHeight||c.clientHeight||720,oe=c.videoWidth||c.clientWidth||1280;return{step:S*1.3/Z*100,chars:Math.max(20,Math.floor(oe/(S*.55)))}},se=S=>{const Z=le(),oe=Array.from(S.activeCues??[]);if(oe.length<=1){oe.forEach(wt=>H(wt,Z));return}const{step:Et,chars:Ot}=U();let lr=Z;for(let wt=oe.length-1;wt>=0;wt--){const Dr=String(oe[wt].text??"").replace(/<[^>]*>/g,"").split(`
55
+ `).reduce(($r,Fr)=>$r+Math.max(1,Math.ceil(Fr.length/Ot)),0),cr=lr-Dr*Et;H(oe[wt],Math.max(0,cr)),lr=cr-Et*.4}},de=S=>{if(!S.cues)return;const Z=le();Array.from(S.cues).forEach(oe=>H(oe,Z)),S.mode==="showing"&&se(S)},we=()=>{Array.from(c.textTracks).forEach(de)};we();const X=S=>{const Z=S.target;Z.mode==="showing"&&se(Z)};Array.from(c.textTracks).forEach(S=>{S.addEventListener("cuechange",X)});const Ae=()=>{Array.from(c.textTracks).forEach(S=>{S.removeEventListener("cuechange",X),S.addEventListener("cuechange",X)}),we()};c.textTracks.addEventListener("addtrack",Ae),c.textTracks.addEventListener("removetrack",Ae);const he=Array.from(c.querySelectorAll("track")),J=()=>{we()};return he.forEach(S=>{S.addEventListener("load",J)}),()=>{Array.from(c.textTracks).forEach(S=>{S.removeEventListener("cuechange",X)}),c.textTracks.removeEventListener("addtrack",Ae),c.textTracks.removeEventListener("removetrack",Ae),he.forEach(S=>{S.removeEventListener("load",J)})}},[a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,a.state.availableSubtitles,e.selectedSource,e.selectedLink,p.videoRef,nr]),x(()=>{if(!Ie)return;const t=p.videoRef.current,s=Ye.current;if(!t||!s)return;const i=localStorage.getItem("playerSubtitlesEnabled")!=="false",c=a.state.activeSubtitleTrack;function C(){if(s.innerHTML="",!i||c==="off"||c===null)return;const U=Array.from(t.textTracks).find(J=>J.language===c||J.label===c);if(!U||U.mode!=="showing")return;const se=Re/1e3;let de;if(se>0&&U.cues){const J=t.currentTime-se;de=Array.from(U.cues).filter(S=>S.startTime<=J&&J<=S.endTime)}else de=Array.from(U.activeCues??[]);if(de.length===0)return;const we={fontSize:pr(a.state.subtitleFontSize,t.clientHeight||0),position:a.state.subtitlePosition,bgOpacity:a.state.subtitleBgOpacity,bgColor:a.state.subtitleBgColor,textColor:a.state.subtitleTextColor,edge:a.state.subtitleEdge,bold:a.state.subtitleBold},X=mn(we),Ae=fn(t,we.position),he=Array.from(de);he.forEach((J,S)=>{const Z=String(J.text??"");if(!hn(Z).trim())return;const oe=document.createElement("div"),Et=(he.length-1-S)*1.7;oe.style.cssText=`${X}
56
+ bottom: calc(${Ae}px + ${Et}em);`,oe.innerHTML=vn(Z),s.appendChild(oe)})}const le=()=>C(),H=()=>C();return Array.from(t.textTracks).forEach(U=>{U.addEventListener("cuechange",le)}),t.addEventListener("timeupdate",H),C(),()=>{Array.from(t.textTracks).forEach(U=>{U.removeEventListener("cuechange",le)}),t.removeEventListener("timeupdate",H),s.innerHTML=""}},[F.isEnabled,F.isWebGPUSupported,a.state.subtitleFontSize,a.state.subtitlePosition,a.state.subtitleBgOpacity,a.state.subtitleBgColor,a.state.subtitleTextColor,a.state.subtitleEdge,a.state.subtitleBold,a.state.activeSubtitleTrack,p.videoRef,Ie,Re]),x(()=>{try{localStorage.setItem("anime4kProfile",d)}catch{}},[d]);const _r=()=>{p.videoRef.current&&(p.videoRef.current.currentTime=e.resumeTime,p.videoRef.current.play()),f({type:"SET_STATE",payload:{showResumeModal:!1}})},Nr=()=>{p.videoRef.current&&(p.videoRef.current.currentTime=0,p.videoRef.current.play()),f({type:"SET_STATE",payload:{showResumeModal:!1}})},sr=O(()=>{ct&&(qe.current=!0),Bt&&Je(!1),f({type:"SET_STATE",payload:{showResumeModal:!1}})},[f,ct,Bt]),Pr=O(()=>{if(Je(!1),p.videoRef.current)try{p.videoRef.current.currentTime=0,p.videoRef.current.play().catch(()=>{})}catch{}f({type:"SET_STATE",payload:{showResumeModal:!1}})},[f,p]),xr=O(async()=>{try{await N(),f({type:"SET_STATE",payload:{showResumeModal:!1}}),k("/")}catch{}},[N,f,k]),or=(t,s)=>r("div",{className:t,children:[r("button",{className:`${u.episodeNavBtn} ${u.secondary}`,onClick:Cr,disabled:!qt,type:"button",children:[r(q,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${u.episodeNavBtn} ${u.primary}`,onClick:_t,disabled:!xe,type:"button",children:["Next EP",r(q,{name:"chevron-right",size:12})]}),s==="mobile"&&We&&r("button",{className:`${u.episodeNavBtn} ${u.episodePickerBtn}`,onClick:()=>Ct(!0),type:"button",children:[r(q,{name:"list-ul",size:12}),"Episodes"]})]});x(()=>{De&&(e.showResumeModal||y.length>0||ve||qe.current||ct&&f({type:"SET_STATE",payload:{showResumeModal:!0}}))},[De,ct,e.showResumeModal,y.length,ve,f]);const Ar=t=>{f({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),kn(t)},ar=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),Br=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Ht=v(A);Ht.current=A;const ir=v("");x(()=>{const t=p.videoRef.current;if(_(!1),Je(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const i=t.duration,c=t.currentTime;if(!i||Number.isNaN(i)){_(!1),Je(!1);return}const C=c/i;if(i-c<=60){const le=y.findIndex(se=>Mt(se,n,e.showMeta?.id)&&se.episodeNumber===e.currentEpisode),H=y.length>0?le>=0?y[le+1]||null:y[0]:null,U=H?`${H.showId}:${H.episodeNumber}`:Qt?`${n}:${xe}`:"";U&&ir.current!==U&&(ir.current=U,H?Ht.current(H.episodeNumber,H.showId):Ht.current(xe))}_(Qt&&C>=.8),Je(c>=Math.max(i*.98,i-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[p.videoRef,Qt,e.currentEpisode,e.selectedSource,xe,n,y,e.showMeta?.id]);const Lr=O(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||$)return;const t=p.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await W(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,W,$,p.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const nt=e.loadingShowData||e.loadingVideo,Ir=t=>{ge&&t.target===t.currentTarget&&(Ut(!1),localStorage.setItem("playerTheaterMode","false"))};return e.showMeta?.isAdult===!0&&!R?r("div",{className:Ge.playerPageLayout,children:r(Be,{isOpen:!0,title:"Content Warning",onClose:()=>k("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(st,{variant:"secondary",onClick:()=>k("/home"),children:"Go Back"}),r(st,{onClick:E,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Ge.playerPageLayout} ${ge?Ge.theaterMode:""}`,onClick:Ir,children:[r(Be,{isOpen:Zt,onClose:sr,title:ct?"Show Completed!":"Resume Playback?",width:"sm",children:ct?r(kt,{children:[r(Be.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r(Be.Actions,{children:r(st,{onClick:xr,disabled:Oe,children:Oe?"Saving...":"Move to Completed"})})]}):r(kt,{children:[r(Be.Body,{children:r("p",{children:["You were watching at ",r("strong",{children:a.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]})}),r(Be.Actions,{children:[r(st,{variant:"secondary",onClick:Nr,children:"Start Over"}),r(st,{onClick:_r,children:"Resume"})]})]})}),r(Be,{isOpen:Bt,onClose:sr,title:"Episode Completed",width:"sm",children:[r(Be.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",xe?" Would you like to watch the next episode?":""]})}),r(Be.Actions,{children:[r(st,{variant:"secondary",onClick:Pr,children:"Replay"}),xe&&r(st,{onClick:_t,children:`Watch EP ${xe}`})]})]}),r(Be,{isOpen:!!St,onClose:wr,title:"Direct stream failed",width:"sm",children:[r(Be.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),St?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:mt,onChange:t=>I(t.target.checked)}),"Remember my choice"]})]}),r(Be.Actions,{children:[r(st,{variant:"secondary",onClick:kr,children:"Continue with iframe"}),r(st,{onClick:Tr,disabled:xt,children:xt?"Searching…":"Try another provider"})]})]}),r(en,{isOpen:!!e.showCookieModal,onClose:()=>f({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{j.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!ge&&r("aside",{ref:je,className:Ge.episodeSidebar,children:e.loadingShowData?r(gn,{variant:"sidebar"}):r(bn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>k(`/watch/${n}/${t}`)})}),r("div",{className:Ge.playerMain,children:[r("div",{className:`${u.videoContainer} ${a.state.isFullscreen?"":Ge.videoPlayerWrapper} ${a.state.isFullscreen?u.fullscreenActive:""}`,style:{...ht?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(ys,{player:a,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Ar,fallbackChoice:re,onFallbackChoiceChange:ne,showNextEpisodeButton:!ht&&Pt&&y.length===0,onNextEpisode:_t,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{p.videoRef.current&&!isNaN(p.videoRef.current.currentTime)&&(ee.current=p.videoRef.current.currentTime),ae(t.sourceName),f({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:nt,skipIntervals:e.skipIntervals,animeTitle:vt,episodeNumber:e.currentEpisode,isTheaterMode:ge,onTheaterModeToggle:()=>{const t=!ge;Ut(t),localStorage.setItem("playerTheaterMode",t.toString())},anime4kEnabled:F.isEnabled,onAnime4kToggle:F.toggle,anime4kSupported:F.isWebGPUSupported,anime4kProfile:d,onAnime4kProfileChange:o,anime4kInitializing:F.isInitializing,anime4kError:F.error,videoDelayEnabled:D,onVideoDelayToggle:t=>{Y(t);try{localStorage.setItem("playerVideoDelayEnabled",String(t))}catch{}},videoDelayMs:l,onVideoDelayChange:K,onCalibrateAvSync:it,isInteractingExtra:Se||G,className:yn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(kt,{children:[a.state.isSpeedBoostActive&&r("div",{className:u.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(q,{name:"forward",size:12})]}),Qe!==null&&ve?.nextItem&&r("div",{className:u.queueCountdown,children:["Queue next in ",Qe,"s"]})]}),children:[Tt&&r("div",{className:`${u.skipIndicatorContainer} ${Tt.side==="left"?u.leftSkip:u.rightSkip} `,children:r("div",{className:u.skipBubble,children:[r("div",{className:u.skipIcon,children:Tt.side==="left"?r(q,{name:"backward"}):r(q,{name:"forward"})}),r("div",{className:u.skipText,children:"15s"})]})}),nt&&r("div",{className:u.loadingOverlay,children:r("div",{className:u.loadingDots,children:[r("div",{className:u.dot}),r("div",{className:u.dot}),r("div",{className:u.dot})]})}),a.state.isBuffering&&!nt&&e.selectedSource?.type!=="iframe"&&r("div",{className:u.bufferingOverlay,children:r("div",{className:u.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!nt&&r("iframe",{src:e.selectedLink?.link,className:u.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):r(kt,{children:[!nt&&e.videoSources.length===0&&r("div",{className:u.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:u.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:u.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!nt&&e.videoSources.length>0&&r("video",{ref:p.videoRef,controls:a.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:M.onPlay,onPause:M.onPause,onLoadedMetadata:M.onLoadedMetadata,onTimeUpdate:()=>{ie||(M.onTimeUpdate(),ve&&p.videoRef.current&&p.videoRef.current.currentTime<p.videoRef.current.duration-1&&(tt(null),Ze(null)))},onProgress:M.onProgress,onVolumeChange:M.onVolumeChange,onWaiting:M.onWaiting,onPlaying:M.onPlaying,onError:er,onContextMenu:t=>t.preventDefault(),className:Ie?u.videoElementHidden:""}),F.isWebGPUSupported&&!nt&&e.videoSources.length>0&&r("canvas",{ref:be,className:`${u.upscalerCanvas} ${Ve?u.upscalerActive:""}`}),!Ve&&!nt&&e.videoSources.length>0&&r("canvas",{ref:yt,className:`${u.upscalerCanvas} ${Ue?u.upscalerActive:""}`}),F.isEnabled&&F.isWebGPUSupported&&F.isInitializing&&r("div",{className:u.upscalerStatusBadge,children:"Preparing upscaler…"}),Ie&&r("div",{ref:Ye,className:u.subtitleOverlay}),r(Sn,{isOpen:G,ms:l,onChange:K,onApply:te,onClose:dt,testClipActive:ie,onTestClip:ue})]})]})}),!ge&&r(En,{}),!ge&&r(kt,{children:[Vt&&y.length===0?r(Ss,{count:3}):r(Mn,{title:"Queue",items:y,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Gt,onRemove:t=>rt.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>At.mutate(),showClearAll:!0,onReorder:t=>br.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:u.providerAndEpisodeRow,children:[r(_s,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:B,onProviderChange:t=>{ze.current=!1,Me.current=[],et.current=!1,_e(null),f({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),or(`${u.episodeActions} ${u.desktopEpisodeActions}`,"desktop")]}),nt?r("div",{className:u.sourceLoader,children:r("div",{className:u.spinner})}):r(kt,{children:r(Ps,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{p.videoRef.current&&!isNaN(p.videoRef.current.currentTime)&&(ee.current=p.videoRef.current.currentTime);const i=(t.links||[]).sort((c,C)=>(parseInt(C.resolutionStr)||0)-(parseInt(c.resolutionStr)||0))[0]||null;ae(t.sourceName),f({type:"SET_STATE",payload:{selectedSource:t,selectedLink:i,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(ae(e.selectedSource.sourceName),f({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Ge.playerInfoContainer,children:[r("div",{className:Ge.playerInfoHeader,children:[r("div",{className:Ge.playerAnimeCard,children:r("img",{src:tn(e.showMeta.thumbnail||""),alt:vt,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Ge.videoTitleSection,children:[r("div",{className:u.titleContainer,children:[r("h1",{children:vt}),r("div",{className:u.scheduleInfo,children:[e.showMeta.status&&r("span",{className:u.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:u.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:u.controls,children:[r("button",{className:`${u.watchlistBtn} ${e.inWatchlist?u.inList:""}`,onClick:Te,children:[e.inWatchlist?r(q,{name:"check",size:14}):r(q,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(Pn,{showId:n,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${u.watchlistBtn} ${u.queueBtn}`,activeClassName:u.queueActive}),Br&&r("button",{className:`${u.watchlistBtn} ${u.markWatchedBtn} ${ar?u.markWatchedDone:""}`,onClick:Lr,disabled:$||!e.currentEpisode,children:[r(q,{name:"check",size:14}),$?"Saving...":ar?"Watched":"Mark Watched"]}),r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${e.currentMode==="dub"?u.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";ze.current=!1,Me.current=[],et.current=!1,_e(null),f({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),Rr&&r("button",{className:`${u.watchlistBtn} ${u.modeToggleBtn} ${a.state.useNativeControls?u.modeToggleActive:""}`,onClick:()=>{const t=!a.state.useNativeControls;a.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:a.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),or(`${u.episodeActions} ${u.mobileEpisodeActions}`,"mobile"),r("div",{className:u.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(An,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:u.detailsToggleBtn,onClick:Fe,children:[e.showCombinedDetails?r(q,{name:"chevron-up"}):r(q,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(xn,{showMeta:e.showMeta,styles:u})]})]})]}),r(wn,{isOpen:Se,onClose:()=>Ct(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{Ct(!1),k(`/watch/${n}/${t}`)}})]})};export{io as default};
@@ -0,0 +1 @@
1
+ import{g as I,d as X,T as Y,u as e}from"./vendor-core-8R2fFbyN.js";import{I as o}from"./vendor-icons-CDMuNDeL.js";import{S as Z,O as _,a as ee,A as ne}from"./OptionListMenu-CJ90CdwI.js";import{u as te}from"./index-BXwhFWB_.js";import"./AvSyncCalibrator-3yjZS7s6.js";import"./vendor-query-BUTye89G.js";import"./useProviders-B5Qr4I1y.js";const ae="_settingsPanel_y6z3b_1",se="_header_y6z3b_33",le="_backBtn_y6z3b_56",ie="_contentWrapper_y6z3b_76",re="_menuContent_y6z3b_82",ce="_menuItem_y6z3b_89",oe="_selected_y6z3b_114",de="_currentValue_y6z3b_134",me="_menuNote_y6z3b_141",ue="_menuError_y6z3b_150",n={settingsPanel:ae,header:se,backBtn:le,contentWrapper:ie,menuContent:re,menuItem:ce,selected:oe,currentValue:de,menuNote:me,menuError:ue},he=(A,z)=>{const{isOpen:b,onClose:pe,videoSources:be,currentSource:v,currentLink:k,onSourceChange:w,subtitles:$,activeSubtitleTrack:y,onSubtitleChange:P,subtitleSettings:V,onSubtitleSettingsChange:O,useNativeControls:g,onNativeControlsToggle:E,anime4kEnabled:u,onAnime4kToggle:U,anime4kSupported:C,anime4kProfile:i,onAnime4kProfileChange:h,anime4kInitializing:B,anime4kError:f,videoDelayEnabled:N,onVideoDelayToggle:T,videoDelayMs:S,onVideoDelayChange:D,onCalibrateAvSync:M,isAutoSkipEnabled:d,onAutoSkipChange:x,isAutoplayEnabled:m,onAutoplayChange:L,fallbackChoice:p,onFallbackChoiceChange:W}=A,{lowEndMode:G}=te(),[a,r]=X("main");I.useEffect(()=>{if(!b){const t=setTimeout(()=>r("main"),300);return()=>clearTimeout(t)}},[b]);const j=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>r("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:k?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:y||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),G&&e("button",{className:`${n.menuItem} ${g?n.selected:""}`,onClick:()=>{const t=!g;E(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),g&&e(o,{name:"check",size:12})]}),C&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{U(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),C&&u&&e("button",{className:n.menuItem,onClick:()=>r("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>r("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:N?`${S}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>r("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[d?"Auto-skip On":null,m?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]})]}),q=()=>{const t=v?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:k?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&w(v,c)}})})},F=()=>e("div",{className:n.menuContent,children:e(_,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:y==="off"},...$.map(t=>({key:t.label||t.lang,label:t.label,selected:y===(t.label||t.lang)}))],onSelect:t=>P(t)})}),Q=()=>e("div",{className:n.menuContent,children:e(ee,{classes:{item:n.menuItem,active:n.selected},values:V,onChange:O})}),R=Y(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),H=()=>e("div",{className:n.menuContent,children:[B&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),f&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",f]}),!R&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${i==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),i==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),i==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),i==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${i==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),i==="denoise"&&e(o,{name:"check",size:12})]})]}),K=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>x(!d),"aria-pressed":d,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>L(!m),"aria-pressed":m,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>W(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),J=()=>e("div",{className:n.menuContent,children:e(ne,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:N,delayMs:S,onToggle:T,onDelayChange:D,onCalibrate:M})});return b?e(Z,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>r("main"),panelRef:z,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&j(),a==="quality"&&q(),a==="subtitles"&&F(),a==="subtitle-style"&&Q(),a==="upscaler"&&H(),a==="av-sync"&&J(),a==="playback"&&K()]}):null},Se=I.forwardRef(he);export{Se as default};
@@ -0,0 +1 @@
1
+ import{b as F}from"./vendor-query-BUTye89G.js";import{t as T,k as H,a0 as J,a1 as W,a2 as X}from"./index-BXwhFWB_.js";import{d as Y,T as R,q as r,u as t,$ as Z,S as w}from"./vendor-core-8R2fFbyN.js";import{a as ee,c as te,d as ne,b as se,o as ae,f as oe,s as ie}from"./vendor-ui-CUDCvRS_.js";import{I as u}from"./vendor-icons-CDMuNDeL.js";function Pe(n){return F({queryKey:["show-meta",n],queryFn:async()=>n?T.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}async function re(n){try{return await T.watchlist.queueSuggested.query({showId:n})}catch{throw new Error("Failed to resolve suggested episode")}}const ue="_trigger_1vova_6",me="_triggerBtn_1vova_11",le="_chevron_1vova_25",ce="_menu_1vova_34",de="_menuTitle_1vova_51",pe="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",o={trigger:ue,triggerBtn:me,chevron:le,menu:ce,menuTitle:de,menuItem:pe,removeItem:ge,menuEmpty:fe},ve=8,qe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:z="",activeClassName:A="",align:D="right",onMenuOpenChange:p})=>{const{data:E=[]}=H(),P=J(),q=W(),[m,f]=Y(!1),{refs:Q,floatingStyles:M,context:S}=ee({open:m,onOpenChange:e=>{e||(f(!1),p?.(!1))},placement:D==="left"?"bottom-start":"bottom-end",middleware:[ae(ve),oe({padding:8}),ie({padding:8})],whileElementsMounted:se}),x=te(S,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:C,getFloatingProps:I}=ne([x]),l=R(()=>E.filter(e=>e.showId===n),[E,n]),{data:K}=F({queryKey:["suggestedEpisode",n],queryFn:()=>re(n),enabled:!!n}),{data:$,isFetching:N}=X(n,m),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),p?.(!0)},[p]),c=r(()=>{f(!1),p?.(!1)},[p]),d=l.length>0,a=s.length>0,g=K?.episodeNumber,i=r(e=>{!n||e.length===0||(P.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,P,c]),L=r(()=>{!n||l.length===0||(q.mutate({showId:n,episodeNumbers:l.map(e=>e.episodeNumber)}),c())},[n,l,q,c]),O=r(()=>{a?i([s[0]]):g&&i([String(g)])},[a,s,g,i]),U=r(()=>{a&&i(s.slice(0,3))},[a,s,i]),G=r(()=>{a&&i([...s])},[a,s,i]),B=s[0],V=s[Math.min(2,s.length-1)],j=t("div",{className:o.trigger,ref:Q.setReference,children:t("span",{className:`${o.triggerBtn} ${z} ${d?A:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":m,"aria-label":d?"Queued":"Queue",...C(),onClick:e=>{e.preventDefault(),e.stopPropagation(),m?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),m?c():k())},children:[d?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),d?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:o.chevron})]})});return t(w,{children:[j,m&&Z(t("div",{ref:Q.setFloating,className:o.menu,style:M,role:"menu",...I(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:o.menuTitle,children:"Queue episodes"}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a&&!g,onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:a?`+3 — EP ${B}${s.length>1?`-${V}`:""}`:"+3"})]}),t("button",{className:o.menuItem,role:"menuitem",type:"button",disabled:!a,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:o.menuEmpty,children:d?"All episodes are already queued":"No remaining unwatched episodes"}),d&&t("button",{className:`${o.menuItem} ${o.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),L()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",l.length>0?` (${l.length})`:""]})]})]}),document.body)]})};export{qe as Q,Pe as u};