@serifpersia/dango 3.3.4 → 3.3.5

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 (59) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/AnimeCard-CXx2EIN7.js +1 -0
  3. package/client/dist/assets/{AnimeInfo-0huPAq0O.js → AnimeInfo-C6ehrfYW.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-Dqr5QH6R.js → AnimeInfoPage-pgnMg0On.js} +2 -2
  5. package/client/dist/assets/{Asmr-B6ZiqkmU.js → Asmr-DfA8xB-U.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-Cqsoo3XC.js → AsmrResetProgressModal-QUNnEh9C.js} +1 -1
  7. package/client/dist/assets/AvSyncCalibrator-Bs4iejCG.js +10 -0
  8. package/client/dist/assets/Home-Csx6zT32.js +1 -0
  9. package/client/dist/assets/{Insights-ZlgPrzGD.js → Insights-MW8oRqeX.js} +1 -1
  10. package/client/dist/assets/{LibraryListPage-CCiee-Ot.js → LibraryListPage-VYaHXgXt.js} +1 -1
  11. package/client/dist/assets/{ListeningList-ctAz_6Zi.js → ListeningList-BzbQwmh0.js} +1 -1
  12. package/client/dist/assets/{Manga-BI9WMTx5.js → Manga-223panCD.js} +1 -1
  13. package/client/dist/assets/{MangaInfoPage-DcrEr7Sk.js → MangaInfoPage-DBqX-Ord.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-SYg63m48.js → MangaReadPage-DuXdVyTd.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-DX-1PS4h.js → MangaResetProgressModal-6C3iaR6g.js} +1 -1
  16. package/client/dist/assets/{Mature-Dqh_9SA3.js → Mature-3VlywJMR.js} +1 -1
  17. package/client/dist/assets/{MediaCard-Be1ST9oj.js → MediaCard-xfJv6irD.js} +1 -1
  18. package/client/dist/assets/{Music-zsPwT8_5.js → Music-DkIeCRq1.js} +1 -1
  19. package/client/dist/assets/{OptionListMenu-Drc_vybW.js → OptionListMenu-JQ_--ggT.js} +1 -1
  20. package/client/dist/assets/Player-Czg_D7FN.js +56 -0
  21. package/client/dist/assets/{PlayerSettings-Cwoji-P7.js → PlayerSettings-KrFECely.js} +1 -1
  22. package/client/dist/assets/{QueueOptionsButton-B6BMq66e.js → QueueOptionsButton-BKNDfpCl.js} +1 -1
  23. package/client/dist/assets/{QueueRail-VxpUDBSm.js → QueueRail-Cgljhm64.js} +1 -1
  24. package/client/dist/assets/{Radio-B2Q_Egj7.js → Radio-wbxhaiqy.js} +1 -1
  25. package/client/dist/assets/{ReadingList-O0QPwXu7.js → ReadingList-DNJAx_LW.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-CR_ovLAu.js → ResetProgressModal-By-iSYwL.js} +1 -1
  27. package/client/dist/assets/{Search-C8e2nlDD.js → Search-63TcSgOa.js} +1 -1
  28. package/client/dist/assets/{Settings-BgPWBl2V.js → Settings-BeS0llCE.js} +1 -1
  29. package/client/dist/assets/{SkeletonGrid-CtHKKMLj.js → SkeletonGrid-CnE_aoEU.js} +1 -1
  30. package/client/dist/assets/{Trackers-Bfoiyuzy.js → Trackers-ACFHfLXZ.js} +1 -1
  31. package/client/dist/assets/Tv-BCmNLUsp.js +4 -0
  32. package/client/dist/assets/{TvInfo-D_scgw_h.js → TvInfo-fFNHV1RJ.js} +1 -1
  33. package/client/dist/assets/{TvPopup-YTI7dEbJ.js → TvPopup-DYKTHRrD.js} +1 -1
  34. package/client/dist/assets/{TvSearch-CxU33UOf.js → TvSearch-CpenLEBz.js} +1 -1
  35. package/client/dist/assets/TvWatchlist-CTUZAvfa.js +1 -0
  36. package/client/dist/assets/{Watchlist-P6YMZUdF.js → Watchlist-B10pIG1F.js} +1 -1
  37. package/client/dist/assets/{hls-C4cG9wQw.js → hls-Cbou9Eb-.js} +1 -1
  38. package/client/dist/assets/index-CfvzoNYQ.js +178 -0
  39. package/client/dist/assets/{useAnimeInfoData-DeuwDSnI.js → useAnimeInfoData-D-vEehTG.js} +1 -1
  40. package/client/dist/assets/{useAsmr-CbMVRjmV.js → useAsmr-B-3EYd-B.js} +1 -1
  41. package/client/dist/assets/{useAsmrPopup-D91Q3CBg.js → useAsmrPopup-D9BxuTDg.js} +1 -1
  42. package/client/dist/assets/{useMangaLibrary-BPvFb1lU.js → useMangaLibrary-DtRKgk2x.js} +1 -1
  43. package/client/dist/assets/{useMangaPopup-BOL2mQJs.js → useMangaPopup-BNWJ5pR2.js} +1 -1
  44. package/client/dist/assets/{useProviders-BsRGONMA.js → useProviders-jxh6fvMH.js} +1 -1
  45. package/client/dist/assets/{useTv-D37MfTHA.js → useTv-CP4mofvR.js} +1 -1
  46. package/client/dist/assets/{useTvLibrary-Cwxgy_Bg.js → useTvLibrary-DeGkJuvp.js} +1 -1
  47. package/client/dist/index.html +1 -1
  48. package/package.json +2 -2
  49. package/server/dist/controllers/tv-library.controller.js +9 -5
  50. package/server/dist/repositories/tv.repository.js +10 -8
  51. package/server/dist/sync.js +19 -1
  52. package/server/package.json +1 -1
  53. package/client/dist/assets/AnimeCard-B5A20jAI.js +0 -1
  54. package/client/dist/assets/AvSyncCalibrator-C8ZoIwMY.js +0 -10
  55. package/client/dist/assets/Home-thJhPfs1.js +0 -1
  56. package/client/dist/assets/Player-BEtAYps2.js +0 -56
  57. package/client/dist/assets/Tv-Ca0fCdko.js +0 -3
  58. package/client/dist/assets/TvWatchlist-B4X1fWEH.js +0 -1
  59. package/client/dist/assets/index-IZgh1beL.js +0 -178
@@ -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-IZgh1beL.js";import{E as ce}from"./ErrorMessage-z4f4WGgP.js";import{M as de}from"./MediaCard-Be1ST9oj.js";import{u as ue,M as ge}from"./useMangaPopup-BOL2mQJs.js";import{f as pe,u as he,m as D,i as ve,b as me,c as be}from"./useMangaLibrary-BPvFb1lU.js";import{u as fe}from"./useProviders-BsRGONMA.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,Q as ie}from"./index-CfvzoNYQ.js";import{E as ce}from"./ErrorMessage-z4f4WGgP.js";import{M as de}from"./MediaCard-xfJv6irD.js";import{u as ue,M as ge}from"./useMangaPopup-BNWJ5pR2.js";import{f as pe,u as he,m as D,i as ve,b as me,c as be}from"./useMangaLibrary-DtRKgk2x.js";import{u as fe}from"./useProviders-jxh6fvMH.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 +1 @@
1
- import{u as e,n as E,o as z,a as D,d as Q,h as L,T as b,S as _}from"./vendor-core-8R2fFbyN.js";import{I as N}from"./vendor-icons-CDMuNDeL.js";import{d as j,B as I}from"./index-IZgh1beL.js";import{E as V}from"./ErrorMessage-z4f4WGgP.js";import{b as F,m as G,g as H,h as O,j as W,r as Y,k as q,l as J,n as K,M as X}from"./useMangaLibrary-BPvFb1lU.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BXRECSI6.js";const Z=({detail:r,altTitle:l,onBack:C,onOpenChapter:u,bookmarkButton:c,statusSelect:v,primaryAction:d,progressByChapter:y})=>{const i=[r.type,r.status,r.year?String(r.year):"",r.author?`by ${r.author}`:""].filter(Boolean);return e("div",{children:[e("button",{className:t.backBtn,onClick:C,children:[e(N,{name:"chevron-left",size:12})," Back to browse"]}),e("div",{className:t.detail,children:[r.cover&&e("img",{className:t.detailCover,src:F(r.provider,r.cover),alt:r.title,decoding:"async",draggable:!1}),e("div",{className:t.detailInfo,children:[e("h2",{className:t.detailTitle,children:r.title}),l&&e("p",{className:t.detailAltTitle,children:["Also known as: ",l]}),i.length>0&&e("div",{className:t.detailMeta,children:i.map(n=>e("span",{className:t.badge,children:n},n))}),r.genres&&r.genres.length>0&&e("div",{className:t.detailMeta,children:r.genres.map(n=>e("span",{className:t.badge,children:n},n))}),r.description&&e("p",{className:t.detailDesc,children:r.description}),(c||v||d)&&e("div",{className:t.detailActions,children:[d,c,v]})]})]}),e("h3",{className:t.detailTitle,style:{fontSize:"1rem"},children:["Chapters (",r.chapters.length,")"]}),r.chapters.length===0?e("p",{className:t.statusMsg,children:"No chapters found for this title on this provider."}):e("div",{className:t.chapterList,children:r.chapters.map(n=>{const a=y?.get(n.id),p=!!a&&a.pageCount>0&&a.page>=a.pageCount;return e("button",{className:`${t.chapterRow} ${p?t.chapterDone:""}`,onClick:()=>u(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:t.chapterMeta,children:[a&&a.pageCount>0?p?"read":`p. ${a.page}/${a.pageCount}`:"",n.group,n.externalUrl?"external":""].filter(Boolean).join(" · ")})]},n.id)})})]})};function le(){const{provider:r="",id:l=""}=E(),[C]=z(),u=D(),[c,v]=Q(()=>localStorage.getItem("agreedToViewMature")==="true");L(()=>{const s=()=>v(localStorage.getItem("agreedToViewMature")==="true");return window.addEventListener("focus",s),window.addEventListener("storage",s),()=>{window.removeEventListener("focus",s),window.removeEventListener("storage",s)}},[]);const d=C.get("rating")||"safe",y=c?d:"safe",i=r&&l?G(r,l):void 0,n=H(r||null,l||null,y,c),a=n.data,p=O(i),f=W(i),{titlePreference:w}=j(),m=b(()=>a&&{...a,title:Y(a,w)},[a,w]),M=q(),B=J(),P=K();L(()=>{m&&(document.title=`${m.title} - dango`)},[m]);const S=b(()=>{const s=new Map;for(const o of f.data?.progress??[])s.set(o.chapterId,o);return s},[f.data]),k=p.data?.inLibrary??!1,R=p.data?.status??"Reading",$=b(()=>(a?.chapters??[]).filter(s=>!s.externalUrl),[a]),g=b(()=>{if(!a)return null;const s=[...f.data?.progress??[]].sort((o,h)=>h.updatedAt-o.updatedAt);for(const o of s){const h=a.chapters.find(U=>U.id===o.chapterId);if(h&&!h.externalUrl)return h}return $[0]??null},[a,f.data,$]),x=(g?S.get(g.id):void 0)?`Continue Ch. ${g?.number}`:"Start Reading",T=s=>{if(s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),c&&d!=="safe"&&o.set("rating",d),u(`/manga/${r}/${encodeURIComponent(l)}/read?${o.toString()}`)},A=()=>{!a||!i||(k?B.mutate(i):M.mutate({provider:r,mangaId:l,title:a.title,cover:a.cover,author:a.author,altTitle:a.altTitle,contentRating:a.contentRating}))};return e("div",{className:t.page,children:n.isLoading?e("div",{"aria-hidden":!0,children:[e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{maxWidth:"12rem"}}),e("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"40%"}}),e("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"70%"}})]}):n.isError||!a||!m?e(_,{children:[e("button",{className:t.backBtn,onClick:()=>u("/manga"),children:[e(N,{name:"chevron-left",size:12})," Back to browse"]}),e(V,{message:"Failed to load this title. Please try again."})]}):e(Z,{detail:m,altTitle:a.altTitle!==m.title?a.altTitle:void 0,onBack:()=>u("/manga"),onOpenChapter:T,progressByChapter:S,primaryAction:g?e(I,{onClick:()=>g&&T(g),children:[e(N,{name:"book",size:13})," ",x]}):void 0,bookmarkButton:e(I,{variant:k?"secondary":"primary",onClick:A,disabled:M.isPending||B.isPending,children:[e(N,{name:"bookmark",size:13})," ",k?"Bookmarked":"Bookmark"]}),statusSelect:k?e("select",{className:t.detailSelect,value:R,onChange:s=>i&&P.mutate({id:i,status:s.target.value}),"aria-label":"Reading status",children:X.map(s=>e("option",{value:s,children:s},s))}):void 0})})}export{le as default};
1
+ import{u as e,n as E,o as z,a as D,d as Q,h as L,T as b,S as _}from"./vendor-core-8R2fFbyN.js";import{I as N}from"./vendor-icons-CDMuNDeL.js";import{d as j,B as I}from"./index-CfvzoNYQ.js";import{E as V}from"./ErrorMessage-z4f4WGgP.js";import{b as F,m as G,g as H,h as O,j as W,r as Y,k as q,l as J,n as K,M as X}from"./useMangaLibrary-DtRKgk2x.js";import{s as t}from"./Manga.module-BcfOdsNP.js";import"./vendor-query-BXRECSI6.js";const Z=({detail:r,altTitle:l,onBack:C,onOpenChapter:u,bookmarkButton:c,statusSelect:v,primaryAction:d,progressByChapter:y})=>{const i=[r.type,r.status,r.year?String(r.year):"",r.author?`by ${r.author}`:""].filter(Boolean);return e("div",{children:[e("button",{className:t.backBtn,onClick:C,children:[e(N,{name:"chevron-left",size:12})," Back to browse"]}),e("div",{className:t.detail,children:[r.cover&&e("img",{className:t.detailCover,src:F(r.provider,r.cover),alt:r.title,decoding:"async",draggable:!1}),e("div",{className:t.detailInfo,children:[e("h2",{className:t.detailTitle,children:r.title}),l&&e("p",{className:t.detailAltTitle,children:["Also known as: ",l]}),i.length>0&&e("div",{className:t.detailMeta,children:i.map(n=>e("span",{className:t.badge,children:n},n))}),r.genres&&r.genres.length>0&&e("div",{className:t.detailMeta,children:r.genres.map(n=>e("span",{className:t.badge,children:n},n))}),r.description&&e("p",{className:t.detailDesc,children:r.description}),(c||v||d)&&e("div",{className:t.detailActions,children:[d,c,v]})]})]}),e("h3",{className:t.detailTitle,style:{fontSize:"1rem"},children:["Chapters (",r.chapters.length,")"]}),r.chapters.length===0?e("p",{className:t.statusMsg,children:"No chapters found for this title on this provider."}):e("div",{className:t.chapterList,children:r.chapters.map(n=>{const a=y?.get(n.id),p=!!a&&a.pageCount>0&&a.page>=a.pageCount;return e("button",{className:`${t.chapterRow} ${p?t.chapterDone:""}`,onClick:()=>u(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:t.chapterMeta,children:[a&&a.pageCount>0?p?"read":`p. ${a.page}/${a.pageCount}`:"",n.group,n.externalUrl?"external":""].filter(Boolean).join(" · ")})]},n.id)})})]})};function le(){const{provider:r="",id:l=""}=E(),[C]=z(),u=D(),[c,v]=Q(()=>localStorage.getItem("agreedToViewMature")==="true");L(()=>{const s=()=>v(localStorage.getItem("agreedToViewMature")==="true");return window.addEventListener("focus",s),window.addEventListener("storage",s),()=>{window.removeEventListener("focus",s),window.removeEventListener("storage",s)}},[]);const d=C.get("rating")||"safe",y=c?d:"safe",i=r&&l?G(r,l):void 0,n=H(r||null,l||null,y,c),a=n.data,p=O(i),f=W(i),{titlePreference:w}=j(),m=b(()=>a&&{...a,title:Y(a,w)},[a,w]),M=q(),B=J(),P=K();L(()=>{m&&(document.title=`${m.title} - dango`)},[m]);const S=b(()=>{const s=new Map;for(const o of f.data?.progress??[])s.set(o.chapterId,o);return s},[f.data]),k=p.data?.inLibrary??!1,R=p.data?.status??"Reading",$=b(()=>(a?.chapters??[]).filter(s=>!s.externalUrl),[a]),g=b(()=>{if(!a)return null;const s=[...f.data?.progress??[]].sort((o,h)=>h.updatedAt-o.updatedAt);for(const o of s){const h=a.chapters.find(U=>U.id===o.chapterId);if(h&&!h.externalUrl)return h}return $[0]??null},[a,f.data,$]),x=(g?S.get(g.id):void 0)?`Continue Ch. ${g?.number}`:"Start Reading",T=s=>{if(s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",s.id),c&&d!=="safe"&&o.set("rating",d),u(`/manga/${r}/${encodeURIComponent(l)}/read?${o.toString()}`)},A=()=>{!a||!i||(k?B.mutate(i):M.mutate({provider:r,mangaId:l,title:a.title,cover:a.cover,author:a.author,altTitle:a.altTitle,contentRating:a.contentRating}))};return e("div",{className:t.page,children:n.isLoading?e("div",{"aria-hidden":!0,children:[e("div",{className:`${t.skeletonThumb} ${t.shimmer}`,style:{maxWidth:"12rem"}}),e("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"40%"}}),e("div",{className:`${t.skeletonLine} ${t.shimmer}`,style:{width:"70%"}})]}):n.isError||!a||!m?e(_,{children:[e("button",{className:t.backBtn,onClick:()=>u("/manga"),children:[e(N,{name:"chevron-left",size:12})," Back to browse"]}),e(V,{message:"Failed to load this title. Please try again."})]}):e(Z,{detail:m,altTitle:a.altTitle!==m.title?a.altTitle:void 0,onBack:()=>u("/manga"),onOpenChapter:T,progressByChapter:S,primaryAction:g?e(I,{onClick:()=>g&&T(g),children:[e(N,{name:"book",size:13})," ",x]}):void 0,bookmarkButton:e(I,{variant:k?"secondary":"primary",onClick:A,disabled:M.isPending||B.isPending,children:[e(N,{name:"bookmark",size:13})," ",k?"Bookmarked":"Bookmark"]}),statusSelect:k?e("select",{className:t.detailSelect,value:R,onChange:s=>i&&P.mutate({id:i,status:s.target.value}),"aria-label":"Reading status",children:X.map(s=>e("option",{value:s,children:s},s))}):void 0})})}export{le as default};
@@ -1 +1 @@
1
- import{d as A,A as v,q,h as g,u as e,S as J,n as ie,o as ce,a as le,T as de}from"./vendor-core-8R2fFbyN.js";import{E as ge}from"./ErrorMessage-z4f4WGgP.js";import{I as C}from"./vendor-icons-CDMuNDeL.js";import{u as ue}from"./vendor-query-BXRECSI6.js";import{o as he,p as me,m as pe,g as fe,r as ve,j as be,q as Ne}from"./useMangaLibrary-BPvFb1lU.js";import{s as n}from"./Manga.module-BcfOdsNP.js";import{d as ye}from"./index-IZgh1beL.js";const Y="mangaReadMode",G="mangaFitMode";function we(){try{return localStorage.getItem(Y)==="page"?"page":"strip"}catch{return"strip"}}function Se(){try{return localStorage.getItem(G)==="height"?"height":"width"}catch{return"width"}}const Ie=({provider:p,mangaTitle:b,chapter:u,chapters:R,onBack:$,onOpenChapter:f,initialPage:l=0,onProgress:z,savedPage:w=0})=>{const[i,s]=A(we),[B,F]=A(Se),[d,x]=A(0),[h,S]=A(new Set),[D,N]=A(0),y=v(null),c=v([]),O=ue(),{data:T,isLoading:K,isError:U}=he(p,u.id),t=T?.pages??[],o=t.map(a=>me(p,a)),M=v(0),ee=v(0),L=v(!1);ee.current=t.length;const _=R.findIndex(a=>a.id===u.id),I=_>0?[...R.slice(0,_)].reverse().find(a=>!a.externalUrl)??null:null,k=_>=0?R.slice(_+1).find(a=>!a.externalUrl)??null:null,P=q(a=>{L.current=!0,x(r=>{const m=r+a;return m<0?(I&&f(I),0):m>=t.length?(k&&f(k),r):m})},[t.length,I,k,f]);g(()=>{L.current=!1,M.current=Math.max(0,l),x(Math.max(0,l)),S(new Set),c.current=[],l<=0&&window.scrollTo(0,0)},[u.id,l]);const Q=v(z);Q.current=z;const W=v("");g(()=>{M.current=d,t.length!==0&&Q.current?.(Math.min(d+1,t.length),t.length)},[d,t.length]),g(()=>{l<=0||L.current||M.current===0&&(L.current=!1,M.current=l,x(l))},[l]),g(()=>{if(i!=="strip"||t.length===0||l<=0)return;const a=`${u.id}:${l}`;if(W.current===a)return;W.current=a;const r=window.setTimeout(()=>{c.current[Math.min(l,t.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[i,t.length,l,u.id]),g(()=>{document.title=`${b} Ch. ${u.number} - dango`},[b,u.number]),g(()=>{try{localStorage.setItem(Y,i)}catch{}},[i]),g(()=>{try{localStorage.setItem(G,B)}catch{}},[B]),g(()=>{i==="page"&&window.scrollTo(0,0)},[i]),g(()=>{if(i!=="page"||t.length===0)return;const a=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),P(1)):r.key==="ArrowLeft"&&(r.preventDefault(),P(-1))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i,t.length,P]),g(()=>{if(i!=="strip"||t.length===0)return;const a=new IntersectionObserver(r=>{for(const m of r)if(m.isIntersecting){const j=Number(m.target.dataset.pageIndex);Number.isNaN(j)||(j!==M.current&&(L.current=!0),x(j))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return c.current.forEach(r=>r&&a.observe(r)),()=>a.disconnect()},[i,t.length,T]);const te=a=>{y.current=a.touches[0].clientX},ne=a=>{if(y.current===null)return;const r=a.changedTouches[0].clientX-y.current;y.current=null,!(Math.abs(r)<50)&&P(r<0?1:-1)},V=a=>{a&&f(a)},Z=a=>S(r=>{if(r.has(a))return r;const m=new Set(r);return m.add(a),m}),ae=a=>{S(r=>{const m=new Set(r);return m.delete(a),m}),N(r=>r+1)},re=()=>{S(new Set),N(a=>a+1),O.invalidateQueries({queryKey:["mangaPages",p,u.id]})},se=t.length>0&&h.size>=t.length,H=a=>D>0?`${a}&n=${D}`:a,X=a=>e("div",{className:n.deadPage,role:"alert",children:[e("span",{children:["Page ",a+1," failed to load"]}),e("button",{className:n.pageBtn,onClick:()=>ae(a),children:[e(C,{name:"sync-alt",size:12})," Retry"]})]}),E=B==="height",oe=w>0?w-1:-1;return e("div",{className:n.readerShell,children:[e("div",{className:n.readerBar,children:[e("button",{className:n.readerIconBtn,onClick:$,"aria-label":"Back to chapters",children:e(C,{name:"chevron-left",size:14})}),e("span",{className:n.readerTitle,children:[b," — Ch. ",u.number,u.title?` ${u.title}`:""]}),t.length>0&&e("span",{className:n.readerCounter,children:[Math.min(d+1,t.length)," / ",t.length]}),e("div",{className:n.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":i==="strip",className:i==="strip"?n.readerSegmentActive:"",onClick:()=>s("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":i==="page",className:i==="page"?n.readerSegmentActive:"",onClick:()=>s("page"),children:"Page"})]}),e("div",{className:n.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!E,className:E?"":n.readerSegmentActive,onClick:()=>F("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":E,className:E?n.readerSegmentActive:"",onClick:()=>F("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:n.readerIconBtn,disabled:!I,onClick:()=>V(I),"aria-label":"Previous chapter",children:e(C,{name:"chevron-left",size:14})}),e("button",{className:n.readerIconBtn,disabled:!k,onClick:()=>V(k),"aria-label":"Next chapter",children:e(C,{name:"chevron-right",size:14})})]}),U?e("p",{className:n.statusMsg,children:"Failed to load pages. Please try again."}):K?e("div",{className:n.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((a,r)=>e("div",{className:`${n.skeletonThumb} ${n.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):t.length===0?e("p",{className:n.statusMsg,children:"No pages found for this chapter."}):se?e("div",{className:n.failedBox,children:[e("p",{className:n.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:n.pageBtn,onClick:re,children:[e(C,{name:"sync-alt",size:12})," Reload pages"]})]}):i==="strip"?e("div",{className:`${n.readerPages} ${E?n.readerPagesTall:""}`,children:o.map((a,r)=>e("div",{ref:m=>{c.current[r]=m},"data-page-index":r,className:n.readerPageWrap,children:[r===oe&&e("div",{className:n.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(C,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",w]})]}),h.has(r)?X(r):e("img",{className:n.readerPage,src:H(a),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>Z(r)})]},`${r}-${t[r].slice(-32)}`))}):e(J,{children:[e("div",{className:`${n.pageView} ${E?n.pageViewTall:""}`,onTouchStart:te,onTouchEnd:ne,children:[e("button",{className:`${n.tapZone} ${n.tapZoneLeft}`,onClick:()=>P(-1),"aria-label":"Previous page",children:e("span",{className:n.tapChevron,children:e(C,{name:"chevron-left",size:16})})}),h.has(d)?X(d):e("img",{className:n.pageImage,src:H(o[d]),alt:`Page ${d+1} of ${t.length}`,decoding:"async",draggable:!1,onError:()=>Z(d)},`${d}-${t[d].slice(-32)}`),e("button",{className:`${n.tapZone} ${n.tapZoneRight}`,onClick:()=>P(1),"aria-label":"Next page",children:e("span",{className:n.tapChevron,children:e(C,{name:"chevron-right",size:16})})})]}),e("nav",{className:n.pagination,"aria-label":"Page navigation",children:[e("button",{className:n.pageBtn,disabled:d<=0,onClick:()=>P(-1),children:"Previous page"}),e("span",{className:n.pageIndicator,children:[d+1," / ",t.length]}),e("button",{className:n.pageBtn,disabled:d>=t.length-1,onClick:()=>P(1),children:"Next page"})]})]}),(I||k)&&e("nav",{className:n.pagination,children:[e("button",{className:n.pageBtn,disabled:!I,onClick:()=>V(I),children:"Previous chapter"}),e("button",{className:n.pageBtn,disabled:!k,onClick:()=>V(k),children:"Next chapter"})]})]})},ke=800,Pe=5e3;function Be(){const{provider:p="",id:b=""}=ie(),[u]=ce(),R=le(),$=u.get("chapter")||"",f=u.get("rating")||"safe",l=typeof localStorage<"u"&&localStorage.getItem("agreedToViewMature")==="true",z=l?f:"safe",w=p&&b?pe(p,b):"",i=fe(p||null,b||null,z,l),s=i.data,{titlePreference:B}=ye(),F=s?ve(s,B):"Manga",d=be(w||void 0),x=Ne(),h=s&&$?s.chapters.find(t=>t.id===$)??null:null,S=de(()=>{const t=(d.data?.progress??[]).find(o=>o.chapterId===$);return t&&t.page>0?t.page:0},[d.data,$]),D=S>1?S-1:0,N=v(null),y=v(null),c=q(()=>{N.current&&(clearTimeout(N.current),N.current=null);const t=y.current;y.current=null,t&&w&&x.mutate({mangaId:w,chapterId:t.chapterId,chapterNumber:t.chapterNumber,page:t.page,pageCount:t.pageCount,title:s?.title??null,cover:s?.cover??null,provider:p||null,altTitle:s?.altTitle??null,contentRating:s?.contentRating??null})},[w,x,s?.title,s?.cover,s?.altTitle,s?.contentRating,p]),O=q((t,o)=>{h&&(y.current={chapterId:h.id,chapterNumber:h.number,page:t,pageCount:o},N.current&&clearTimeout(N.current),N.current=setTimeout(c,ke))},[h,c]);g(()=>{c()},[$,c]),g(()=>()=>c(),[c]),g(()=>{const t=window.setInterval(()=>{y.current&&c()},Pe);return()=>window.clearInterval(t)},[c]),g(()=>{const t=()=>{document.visibilityState==="hidden"&&c()},o=()=>c();return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",o)}},[c]);const T=v("");T.current||(T.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),g(()=>{if(!s||!h)return;const t=s.contentRating==="erotica"||s.contentRating==="pornographic"||s.type==="doujinshi",o=()=>{fetch("/api/discord/manga",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s.title,chapterLabel:`Chapter ${h.number}`,isPlaying:!0,thumbnail:s.cover||"",thumbnails:[s.cover].filter(Boolean),isAdult:t,sessionId:T.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:T.current})}).catch(()=>{})};o();const M=window.setInterval(o,6e4);return()=>window.clearInterval(M)},[s,h]);const K=t=>{if(c(),t.externalUrl){window.open(t.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",t.id),l&&f!=="safe"&&o.set("rating",f),R(`/manga/${p}/${encodeURIComponent(b)}/read?${o.toString()}`)},U=()=>{c();const t=new URLSearchParams;l&&f!=="safe"&&t.set("rating",f);const o=t.toString()?`?${t.toString()}`:"";R(`/manga/${p}/${encodeURIComponent(b)}${o}`)};return e("div",{className:n.page,children:i.isLoading?e("div",{className:n.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((t,o)=>e("div",{className:`${n.skeletonThumb} ${n.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!s||!h?e(J,{children:[e("button",{className:n.backBtn,onClick:U,children:"Back to title"}),e(ge,{message:"Failed to load this chapter. Please try again."})]}):e(Ie,{provider:p,mangaTitle:F,chapter:h,chapters:s.chapters,onBack:U,onOpenChapter:K,initialPage:D,onProgress:O,savedPage:S},h.id)})}export{Be as default};
1
+ import{d as A,A as v,q,h as g,u as e,S as J,n as ie,o as ce,a as le,T as de}from"./vendor-core-8R2fFbyN.js";import{E as ge}from"./ErrorMessage-z4f4WGgP.js";import{I as C}from"./vendor-icons-CDMuNDeL.js";import{u as ue}from"./vendor-query-BXRECSI6.js";import{o as he,p as me,m as pe,g as fe,r as ve,j as be,q as Ne}from"./useMangaLibrary-DtRKgk2x.js";import{s as n}from"./Manga.module-BcfOdsNP.js";import{d as ye}from"./index-CfvzoNYQ.js";const Y="mangaReadMode",G="mangaFitMode";function we(){try{return localStorage.getItem(Y)==="page"?"page":"strip"}catch{return"strip"}}function Se(){try{return localStorage.getItem(G)==="height"?"height":"width"}catch{return"width"}}const Ie=({provider:p,mangaTitle:b,chapter:u,chapters:R,onBack:$,onOpenChapter:f,initialPage:l=0,onProgress:z,savedPage:w=0})=>{const[i,s]=A(we),[B,F]=A(Se),[d,x]=A(0),[h,S]=A(new Set),[D,N]=A(0),y=v(null),c=v([]),O=ue(),{data:T,isLoading:K,isError:U}=he(p,u.id),t=T?.pages??[],o=t.map(a=>me(p,a)),M=v(0),ee=v(0),L=v(!1);ee.current=t.length;const _=R.findIndex(a=>a.id===u.id),I=_>0?[...R.slice(0,_)].reverse().find(a=>!a.externalUrl)??null:null,k=_>=0?R.slice(_+1).find(a=>!a.externalUrl)??null:null,P=q(a=>{L.current=!0,x(r=>{const m=r+a;return m<0?(I&&f(I),0):m>=t.length?(k&&f(k),r):m})},[t.length,I,k,f]);g(()=>{L.current=!1,M.current=Math.max(0,l),x(Math.max(0,l)),S(new Set),c.current=[],l<=0&&window.scrollTo(0,0)},[u.id,l]);const Q=v(z);Q.current=z;const W=v("");g(()=>{M.current=d,t.length!==0&&Q.current?.(Math.min(d+1,t.length),t.length)},[d,t.length]),g(()=>{l<=0||L.current||M.current===0&&(L.current=!1,M.current=l,x(l))},[l]),g(()=>{if(i!=="strip"||t.length===0||l<=0)return;const a=`${u.id}:${l}`;if(W.current===a)return;W.current=a;const r=window.setTimeout(()=>{c.current[Math.min(l,t.length-1)]?.scrollIntoView({block:"start"})},150);return()=>window.clearTimeout(r)},[i,t.length,l,u.id]),g(()=>{document.title=`${b} Ch. ${u.number} - dango`},[b,u.number]),g(()=>{try{localStorage.setItem(Y,i)}catch{}},[i]),g(()=>{try{localStorage.setItem(G,B)}catch{}},[B]),g(()=>{i==="page"&&window.scrollTo(0,0)},[i]),g(()=>{if(i!=="page"||t.length===0)return;const a=r=>{r.key==="ArrowRight"||r.key===" "?(r.preventDefault(),P(1)):r.key==="ArrowLeft"&&(r.preventDefault(),P(-1))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i,t.length,P]),g(()=>{if(i!=="strip"||t.length===0)return;const a=new IntersectionObserver(r=>{for(const m of r)if(m.isIntersecting){const j=Number(m.target.dataset.pageIndex);Number.isNaN(j)||(j!==M.current&&(L.current=!0),x(j))}},{rootMargin:"-45% 0px -45% 0px",threshold:0});return c.current.forEach(r=>r&&a.observe(r)),()=>a.disconnect()},[i,t.length,T]);const te=a=>{y.current=a.touches[0].clientX},ne=a=>{if(y.current===null)return;const r=a.changedTouches[0].clientX-y.current;y.current=null,!(Math.abs(r)<50)&&P(r<0?1:-1)},V=a=>{a&&f(a)},Z=a=>S(r=>{if(r.has(a))return r;const m=new Set(r);return m.add(a),m}),ae=a=>{S(r=>{const m=new Set(r);return m.delete(a),m}),N(r=>r+1)},re=()=>{S(new Set),N(a=>a+1),O.invalidateQueries({queryKey:["mangaPages",p,u.id]})},se=t.length>0&&h.size>=t.length,H=a=>D>0?`${a}&n=${D}`:a,X=a=>e("div",{className:n.deadPage,role:"alert",children:[e("span",{children:["Page ",a+1," failed to load"]}),e("button",{className:n.pageBtn,onClick:()=>ae(a),children:[e(C,{name:"sync-alt",size:12})," Retry"]})]}),E=B==="height",oe=w>0?w-1:-1;return e("div",{className:n.readerShell,children:[e("div",{className:n.readerBar,children:[e("button",{className:n.readerIconBtn,onClick:$,"aria-label":"Back to chapters",children:e(C,{name:"chevron-left",size:14})}),e("span",{className:n.readerTitle,children:[b," — Ch. ",u.number,u.title?` ${u.title}`:""]}),t.length>0&&e("span",{className:n.readerCounter,children:[Math.min(d+1,t.length)," / ",t.length]}),e("div",{className:n.readerSegment,role:"group","aria-label":"Reading mode",children:[e("button",{type:"button","aria-pressed":i==="strip",className:i==="strip"?n.readerSegmentActive:"",onClick:()=>s("strip"),children:"Strip"}),e("button",{type:"button","aria-pressed":i==="page",className:i==="page"?n.readerSegmentActive:"",onClick:()=>s("page"),children:"Page"})]}),e("div",{className:n.readerSegment,role:"group","aria-label":"Fit mode",children:[e("button",{type:"button","aria-pressed":!E,className:E?"":n.readerSegmentActive,onClick:()=>F("width"),title:"Fit width — best for portrait / phones",children:"Wide"}),e("button",{type:"button","aria-pressed":E,className:E?n.readerSegmentActive:"",onClick:()=>F("height"),title:"Fit height — best for landscape / desktop",children:"Tall"})]}),e("button",{className:n.readerIconBtn,disabled:!I,onClick:()=>V(I),"aria-label":"Previous chapter",children:e(C,{name:"chevron-left",size:14})}),e("button",{className:n.readerIconBtn,disabled:!k,onClick:()=>V(k),"aria-label":"Next chapter",children:e(C,{name:"chevron-right",size:14})})]}),U?e("p",{className:n.statusMsg,children:"Failed to load pages. Please try again."}):K?e("div",{className:n.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((a,r)=>e("div",{className:`${n.skeletonThumb} ${n.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},r))}):t.length===0?e("p",{className:n.statusMsg,children:"No pages found for this chapter."}):se?e("div",{className:n.failedBox,children:[e("p",{className:n.statusMsg,children:"Page images failed to load (expired or blocked links)."}),e("button",{className:n.pageBtn,onClick:re,children:[e(C,{name:"sync-alt",size:12})," Reload pages"]})]}):i==="strip"?e("div",{className:`${n.readerPages} ${E?n.readerPagesTall:""}`,children:o.map((a,r)=>e("div",{ref:m=>{c.current[r]=m},"data-page-index":r,className:n.readerPageWrap,children:[r===oe&&e("div",{className:n.saveMarker,role:"note","aria-label":"Saved reading position",children:[e(C,{name:"bookmark",size:12}),e("span",{children:["Saved · p. ",w]})]}),h.has(r)?X(r):e("img",{className:n.readerPage,src:H(a),alt:`Page ${r+1}`,loading:r<3?"eager":"lazy",decoding:"async",draggable:!1,onError:()=>Z(r)})]},`${r}-${t[r].slice(-32)}`))}):e(J,{children:[e("div",{className:`${n.pageView} ${E?n.pageViewTall:""}`,onTouchStart:te,onTouchEnd:ne,children:[e("button",{className:`${n.tapZone} ${n.tapZoneLeft}`,onClick:()=>P(-1),"aria-label":"Previous page",children:e("span",{className:n.tapChevron,children:e(C,{name:"chevron-left",size:16})})}),h.has(d)?X(d):e("img",{className:n.pageImage,src:H(o[d]),alt:`Page ${d+1} of ${t.length}`,decoding:"async",draggable:!1,onError:()=>Z(d)},`${d}-${t[d].slice(-32)}`),e("button",{className:`${n.tapZone} ${n.tapZoneRight}`,onClick:()=>P(1),"aria-label":"Next page",children:e("span",{className:n.tapChevron,children:e(C,{name:"chevron-right",size:16})})})]}),e("nav",{className:n.pagination,"aria-label":"Page navigation",children:[e("button",{className:n.pageBtn,disabled:d<=0,onClick:()=>P(-1),children:"Previous page"}),e("span",{className:n.pageIndicator,children:[d+1," / ",t.length]}),e("button",{className:n.pageBtn,disabled:d>=t.length-1,onClick:()=>P(1),children:"Next page"})]})]}),(I||k)&&e("nav",{className:n.pagination,children:[e("button",{className:n.pageBtn,disabled:!I,onClick:()=>V(I),children:"Previous chapter"}),e("button",{className:n.pageBtn,disabled:!k,onClick:()=>V(k),children:"Next chapter"})]})]})},ke=800,Pe=5e3;function Be(){const{provider:p="",id:b=""}=ie(),[u]=ce(),R=le(),$=u.get("chapter")||"",f=u.get("rating")||"safe",l=typeof localStorage<"u"&&localStorage.getItem("agreedToViewMature")==="true",z=l?f:"safe",w=p&&b?pe(p,b):"",i=fe(p||null,b||null,z,l),s=i.data,{titlePreference:B}=ye(),F=s?ve(s,B):"Manga",d=be(w||void 0),x=Ne(),h=s&&$?s.chapters.find(t=>t.id===$)??null:null,S=de(()=>{const t=(d.data?.progress??[]).find(o=>o.chapterId===$);return t&&t.page>0?t.page:0},[d.data,$]),D=S>1?S-1:0,N=v(null),y=v(null),c=q(()=>{N.current&&(clearTimeout(N.current),N.current=null);const t=y.current;y.current=null,t&&w&&x.mutate({mangaId:w,chapterId:t.chapterId,chapterNumber:t.chapterNumber,page:t.page,pageCount:t.pageCount,title:s?.title??null,cover:s?.cover??null,provider:p||null,altTitle:s?.altTitle??null,contentRating:s?.contentRating??null})},[w,x,s?.title,s?.cover,s?.altTitle,s?.contentRating,p]),O=q((t,o)=>{h&&(y.current={chapterId:h.id,chapterNumber:h.number,page:t,pageCount:o},N.current&&clearTimeout(N.current),N.current=setTimeout(c,ke))},[h,c]);g(()=>{c()},[$,c]),g(()=>()=>c(),[c]),g(()=>{const t=window.setInterval(()=>{y.current&&c()},Pe);return()=>window.clearInterval(t)},[c]),g(()=>{const t=()=>{document.visibilityState==="hidden"&&c()},o=()=>c();return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",o),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",o)}},[c]);const T=v("");T.current||(T.current=`manga-${Date.now()}-${Math.random().toString(36).slice(2)}`),g(()=>{if(!s||!h)return;const t=s.contentRating==="erotica"||s.contentRating==="pornographic"||s.type==="doujinshi",o=()=>{fetch("/api/discord/manga",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s.title,chapterLabel:`Chapter ${h.number}`,isPlaying:!0,thumbnail:s.cover||"",thumbnails:[s.cover].filter(Boolean),isAdult:t,sessionId:T.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:T.current})}).catch(()=>{})};o();const M=window.setInterval(o,6e4);return()=>window.clearInterval(M)},[s,h]);const K=t=>{if(c(),t.externalUrl){window.open(t.externalUrl,"_blank","noopener,noreferrer");return}const o=new URLSearchParams;o.set("chapter",t.id),l&&f!=="safe"&&o.set("rating",f),R(`/manga/${p}/${encodeURIComponent(b)}/read?${o.toString()}`)},U=()=>{c();const t=new URLSearchParams;l&&f!=="safe"&&t.set("rating",f);const o=t.toString()?`?${t.toString()}`:"";R(`/manga/${p}/${encodeURIComponent(b)}${o}`)};return e("div",{className:n.page,children:i.isLoading?e("div",{className:n.readerPages,"aria-hidden":!0,children:Array.from({length:3}).map((t,o)=>e("div",{className:`${n.skeletonThumb} ${n.shimmer}`,style:{width:"100%",maxWidth:"56rem",aspectRatio:"3 / 4"}},o))}):!s||!h?e(J,{children:[e("button",{className:n.backBtn,onClick:U,children:"Back to title"}),e(ge,{message:"Failed to load this chapter. Please try again."})]}):e(Ie,{provider:p,mangaTitle:F,chapter:h,chapters:s.chapters,onBack:U,onOpenChapter:K,initialPage:D,onProgress:O,savedPage:S},h.id)})}export{Be as default};
@@ -1 +1 @@
1
- import{d as n,u as l}from"./vendor-core-8R2fFbyN.js";import{R as i}from"./ResetProgressModal-CR_ovLAu.js";import{x as f,l as R}from"./useMangaLibrary-BPvFb1lU.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-By-iSYwL.js";import{x as f,l as R}from"./useMangaLibrary-DtRKgk2x.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 +1 @@
1
- import{u as t,a as $e,o as Ge,h as me,d as l,T as he,S as ge}from"./vendor-core-8R2fFbyN.js";import{b as pe}from"./vendor-query-BXRECSI6.js";import{B as L,M as we,q as O,Q as Fe,z as Me}from"./index-IZgh1beL.js";import{I as A}from"./vendor-icons-CDMuNDeL.js";import{A as qe}from"./AnimeCard-B5A20jAI.js";import{S as xe}from"./SkeletonGrid-CtHKKMLj.js";import{E as Ue}from"./ErrorMessage-z4f4WGgP.js";import{u as Ye}from"./useMatureConsent-CT7-KfzG.js";import{u as je}from"./useProviders-BsRGONMA.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-DeuwDSnI.js";import"./QueueOptionsButton-B6BMq66e.js";import"./vendor-ui-CUDCvRS_.js";import"./MediaCard-Be1ST9oj.js";import"./useIsMobile-Dm_b6Ob3.js";const Ke=({isOpen:m,onClose:n,onGrant:q})=>t(we,{isOpen:m,title:"Content Warning",onClose:n,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(L,{variant:"secondary",onClick:n,children:"Go Back"}),t(L,{onClick:q,children:"I'm 18+, Continue"})]})]})}),Qe="_shrinkSelect_130sm_1",Ve="_tightGrid_130sm_7",z={shrinkSelect:Qe,tightGrid:Ve},We=[{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"}],He=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Je=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],Ze={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},Xe=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=m=>m.split("-").map(n=>n&&n[0].toUpperCase()+n.slice(1)).join(" ");function vt(){const m=$e(),[n,q]=Ge(),{hasConsent:x,grant:fe}=Ye();me(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(n.get("provider")||"anilist"),[S,H]=l(n.get("query")||""),[T,U]=l(n.get("query")||""),[d,h]=l(parseInt(n.get("page")||"1",10)||1),[R,Y]=l(()=>{const e=n.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[_,J]=l(n.get("sortBy")||""),[b,be]=l(n.get("status")||""),[B,ye]=l(n.get("season")||"ALL"),[k,Ne]=l(n.get("year")||"ALL"),[g,D]=l(n.get("genre")||n.get("genres")||""),[j,Ce]=l(n.get("order")||"recent"),[K,Ae]=l(n.get("studio")||""),[$,Ie]=l(n.get("studio")||""),[Z,X]=l([]),[Q,Pe]=l(!1),[Ee,ee]=l(null),{options:te}=je(),ae=he(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=he(()=>[...We,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:G}=pe({queryKey:["mature-filters"],queryFn:()=>O("/api/mature/filters"),enabled:x,staleTime:1/0}),c=i==="anilist"||i==="mal",V=c?void 0:G?.providers?.[i],I=V?.browse,P=V?.genres??[],y=V?.orders??[],ne=y.length>0&&!y.includes(j)?y[0]:j,w=!c&&(I?.genre===!0||P.length>0||Z.length>0),p=!c&&(I?.order===!0||y.length>0),N=!c&&I?.studio===!0,ie=!c&&I?.sort===!0,le=c?14:I?.pageSize??14,v=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 s=G?.providers?.[e.provider]?.browse,u=G?.providers?.[e.provider]?.orders??[],o=u.length>0&&!u.includes(e.remoteOrder)?u[0]:e.remoteOrder;(!s||s.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!s||s.genre)&&e.genre&&r.set("genre",e.genre),(!s||s.order)&&o!==(u[0]??"recent")&&r.set("order",o),(!s||s.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}q(r,{replace:!0})},f=(e={})=>({provider:i,query:T,page:d,sort:R,remoteSort:_,status:b,season:B,year:k,genre:g,remoteOrder:j,studio:$,...e}),se=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(d)),e.set("limit",String(le)),i==="anilist"&&(e.set("sortBy",R),b&&e.set("status",b),B!=="ALL"&&e.set("season",B),k!=="ALL"&&e.set("year",k)),i==="mal"?(e.set("sortBy",R),b&&e.set("status",b)):c||(w&&g&&e.set("genre",g),p&&e.set("order",ne),ie&&_&&e.set("sortBy",_),N&&$.trim()&&e.set("studio",$.trim())),e.toString()})(),{data:C,isLoading:Oe,isError:Le,error:Te}=pe({queryKey:["mature-search",se],queryFn:()=>O(`/api/mature/search?${se}`),enabled:x});me(()=>{const e=C?.genres;!c&&P.length===0&&e&&e.length>0&&X(r=>{const s=new Set(r.map(o=>o.slug)),u=[...r];for(const o of e)o.slug&&!s.has(o.slug)&&(s.add(o.slug),u.push(o));return u.length===r.length?r:u})},[C,i,c,P.length]);const F=(C?.data||[]).map(e=>({...e,isAdult:!0})),oe=C?.hasMore??!1,E=()=>{Fe(),h(1);let e=g;!c&&!p&&S.trim()&&(e=""),D(e),N&&Ie(K),U(S),v(f({query:S,page:1,genre:e,studio:N?K:$}))},Re=e=>{Se(e),h(1),J(""),D(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(S),v(f({provider:e,page:1,remoteSort:"",genre:"",query:S}))},_e=e=>{D(e),h(1),e&&(H(""),U("")),v(f({genre:e,page:1,query:e?"":T}))},M=e=>{h(e),v(f({page:e})),window.scrollTo({top:0,behavior:"smooth"})},Be=async(e,r)=>{const s=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(s)&&(e.preventDefault(),e.stopPropagation(),!Ee)){ee(s);try{if(i!=="anilist"){let o=!1;try{o=(await O("/api/anilist-status"))?.available===!0}catch{o=!1}if(o){const ue=await O(`/api/mature/resolve?title=${encodeURIComponent(r.name)}`);m(`/anime/${ue.id}`);return}const ce=await fetch("/api/mature/allocate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,nativeId:s,title:r.name,thumbnail:r.thumbnail})}),de=await ce.json().catch(()=>null);if(!ce.ok||!de?.id)throw new Error("Allocate failed");m(`/anime/${de.id}`);return}const u=await O(`/api/mature/resolve?title=${encodeURIComponent(r.name)}`);m(`/anime/${u.id}`)}catch{Me.error("Could not match this title on AniList")}finally{ee(null)}}},W=new Date().getFullYear(),ke=[{value:"ALL",label:"All Years"},...Array.from({length:W-1980+1},(e,r)=>({value:String(W-r),label:String(W-r)}))],De=P.length>0?P.map(e=>({value:e,label:ve(e)})):Z.map(e=>({value:e.slug,label:e.name}));return x?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(A,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:S,onChange:e=>H(e.target.value),onKeyDown:e=>{e.key==="Enter"&&E()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>Re(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(L,{onClick:E,className:a.searchBtn,children:"Search"}),c&&t("button",{onClick:()=>Pe(!Q),className:`${a.filterToggleBtn} ${Q?a.active:""}`,children:[t(A,{name:"filter"})," Filters"]}),ie&&t("select",{value:_,onChange:e=>{J(e.target.value),h(1),v(f({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${Q?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:R,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:b,onChange:e=>be(e.currentTarget.value),children:He.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(ge,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:B,onChange:e=>ye(e.currentTarget.value),children:Xe.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:k,onChange:e=>Ne(e.currentTarget.value),children:ke.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(L,{onClick:E,className:a.searchBtn,children:"Apply Filters"})})]}),!c&&!!G&&(w||p||N)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${z.tightGrid}`,children:[p&&t("div",{className:`${a.filterItem} ${z.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:ne,onChange:e=>{Ce(e.target.value),h(1),v(f({remoteOrder:e.target.value,page:1}))},children:(y.length>0?y:["recent"]).map(e=>t("option",{value:e,children:Ze[e]||e},e))})]}),w&&t("div",{className:`${a.filterItem} ${z.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:g,onChange:e=>{p?(D(e.target.value),h(1),v(f({genre:e.target.value,page:1}))):_e(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),De.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),N&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:K,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&E()},className:a.searchInput})]})]}),g&&w&&!p&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(g)," genre — search text is ignored while a genre is selected."]}),(p||N)&&t("div",{className:a.filterActions,children:t(L,{onClick:E,className:a.searchBtn,children:"Apply Filters"})})]})]}),Le&&t(Ue,{message:Te?.message||"Search failed"}),Oe?t(xe,{count:le}):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(ge,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[C?.total??F.length," result",(C?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:[t("button",{className:a.pageBtn,disabled:d<=1,onClick:()=>M(d-1),children:[t(A,{name:"chevron-left"})," ",t("span",{children:"Prev"})]}),t("span",{className:a.pageInfo,children:["Page ",t("strong",{children:d})]}),t("button",{className:a.pageBtn,disabled:!oe,onClick:()=>M(d+1),children:[t("span",{children:"Next"})," ",t(A,{name:"chevron-right"})]})]})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>Be(r,e),children:t(qe,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:[t("button",{className:a.pageBtn,disabled:d<=1,onClick:()=>M(d-1),children:[t(A,{name:"chevron-left"})," ",t("span",{children:"Prev"})]}),t("span",{className:a.pageInfo,children:["Page ",t("strong",{children:d})]}),t("button",{className:a.pageBtn,disabled:!oe,onClick:()=>M(d+1),children:[t("span",{children:"Next"})," ",t(A,{name:"chevron-right"})]})]})})]})]}):t(Ke,{isOpen:!0,onClose:()=>m("/"),onGrant:fe})}export{vt as default};
1
+ import{u as t,a as $e,o as Ge,h as me,d as l,T as he,S as ge}from"./vendor-core-8R2fFbyN.js";import{b as pe}from"./vendor-query-BXRECSI6.js";import{B as L,M as we,q as O,Q as Fe,z as Me}from"./index-CfvzoNYQ.js";import{I as A}from"./vendor-icons-CDMuNDeL.js";import{A as qe}from"./AnimeCard-CXx2EIN7.js";import{S as xe}from"./SkeletonGrid-CnE_aoEU.js";import{E as Ue}from"./ErrorMessage-z4f4WGgP.js";import{u as Ye}from"./useMatureConsent-CT7-KfzG.js";import{u as je}from"./useProviders-jxh6fvMH.js";import{s as a}from"./Search.module-CMEai-B-.js";import"./useAnimeInfoData-D-vEehTG.js";import"./QueueOptionsButton-BKNDfpCl.js";import"./vendor-ui-CUDCvRS_.js";import"./MediaCard-xfJv6irD.js";import"./useIsMobile-Dm_b6Ob3.js";const Ke=({isOpen:m,onClose:n,onGrant:q})=>t(we,{isOpen:m,title:"Content Warning",onClose:n,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(L,{variant:"secondary",onClick:n,children:"Go Back"}),t(L,{onClick:q,children:"I'm 18+, Continue"})]})]})}),Qe="_shrinkSelect_130sm_1",Ve="_tightGrid_130sm_7",z={shrinkSelect:Qe,tightGrid:Ve},We=[{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"}],He=[{value:"",label:"All Status"},{value:"RELEASING",label:"Currently Airing"},{value:"FINISHED",label:"Finished"},{value:"NOT_YET_RELEASED",label:"Not Yet Released"}],Je=[{value:"",label:"Relevance"},{value:"visits:desc",label:"Most Visited"},{value:"title:asc",label:"Title A-Z"}],Ze={recent:"Latest",popular:"Popular",views:"Most Viewed",rating:"Top Rated",random:"Random"},Xe=[{value:"ALL",label:"All Seasons"},{value:"Winter",label:"Winter"},{value:"Spring",label:"Spring"},{value:"Summer",label:"Summer"},{value:"Fall",label:"Fall"}],ve=m=>m.split("-").map(n=>n&&n[0].toUpperCase()+n.slice(1)).join(" ");function vt(){const m=$e(),[n,q]=Ge(),{hasConsent:x,grant:fe}=Ye();me(()=>{document.title="Mature - dango"},[]);const[i,Se]=l(n.get("provider")||"anilist"),[S,H]=l(n.get("query")||""),[T,U]=l(n.get("query")||""),[d,h]=l(parseInt(n.get("page")||"1",10)||1),[R,Y]=l(()=>{const e=n.get("sortBy");return e||(i==="mal"?"SCORE_DESC":"POPULARITY_DESC")}),[_,J]=l(n.get("sortBy")||""),[b,be]=l(n.get("status")||""),[B,ye]=l(n.get("season")||"ALL"),[k,Ne]=l(n.get("year")||"ALL"),[g,D]=l(n.get("genre")||n.get("genres")||""),[j,Ce]=l(n.get("order")||"recent"),[K,Ae]=l(n.get("studio")||""),[$,Ie]=l(n.get("studio")||""),[Z,X]=l([]),[Q,Pe]=l(!1),[Ee,ee]=l(null),{options:te}=je(),ae=he(()=>te.filter(e=>e.mature&&(e.kind??"anime")==="anime"),[te]),re=he(()=>[...We,...ae.map(e=>({value:e.value,label:e.label}))],[ae]),{data:G}=pe({queryKey:["mature-filters"],queryFn:()=>O("/api/mature/filters"),enabled:x,staleTime:1/0}),c=i==="anilist"||i==="mal",V=c?void 0:G?.providers?.[i],I=V?.browse,P=V?.genres??[],y=V?.orders??[],ne=y.length>0&&!y.includes(j)?y[0]:j,w=!c&&(I?.genre===!0||P.length>0||Z.length>0),p=!c&&(I?.order===!0||y.length>0),N=!c&&I?.studio===!0,ie=!c&&I?.sort===!0,le=c?14:I?.pageSize??14,v=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 s=G?.providers?.[e.provider]?.browse,u=G?.providers?.[e.provider]?.orders??[],o=u.length>0&&!u.includes(e.remoteOrder)?u[0]:e.remoteOrder;(!s||s.sort)&&e.remoteSort&&r.set("sortBy",e.remoteSort),(!s||s.genre)&&e.genre&&r.set("genre",e.genre),(!s||s.order)&&o!==(u[0]??"recent")&&r.set("order",o),(!s||s.studio)&&e.studio.trim()&&r.set("studio",e.studio.trim())}q(r,{replace:!0})},f=(e={})=>({provider:i,query:T,page:d,sort:R,remoteSort:_,status:b,season:B,year:k,genre:g,remoteOrder:j,studio:$,...e}),se=(()=>{const e=new URLSearchParams;return e.set("provider",i),T.trim()&&e.set("query",T.trim()),e.set("page",String(d)),e.set("limit",String(le)),i==="anilist"&&(e.set("sortBy",R),b&&e.set("status",b),B!=="ALL"&&e.set("season",B),k!=="ALL"&&e.set("year",k)),i==="mal"?(e.set("sortBy",R),b&&e.set("status",b)):c||(w&&g&&e.set("genre",g),p&&e.set("order",ne),ie&&_&&e.set("sortBy",_),N&&$.trim()&&e.set("studio",$.trim())),e.toString()})(),{data:C,isLoading:Oe,isError:Le,error:Te}=pe({queryKey:["mature-search",se],queryFn:()=>O(`/api/mature/search?${se}`),enabled:x});me(()=>{const e=C?.genres;!c&&P.length===0&&e&&e.length>0&&X(r=>{const s=new Set(r.map(o=>o.slug)),u=[...r];for(const o of e)o.slug&&!s.has(o.slug)&&(s.add(o.slug),u.push(o));return u.length===r.length?r:u})},[C,i,c,P.length]);const F=(C?.data||[]).map(e=>({...e,isAdult:!0})),oe=C?.hasMore??!1,E=()=>{Fe(),h(1);let e=g;!c&&!p&&S.trim()&&(e=""),D(e),N&&Ie(K),U(S),v(f({query:S,page:1,genre:e,studio:N?K:$}))},Re=e=>{Se(e),h(1),J(""),D(""),X([]),e==="mal"?Y("SCORE_DESC"):e==="anilist"&&Y("POPULARITY_DESC"),U(S),v(f({provider:e,page:1,remoteSort:"",genre:"",query:S}))},_e=e=>{D(e),h(1),e&&(H(""),U("")),v(f({genre:e,page:1,query:e?"":T}))},M=e=>{h(e),v(f({page:e})),window.scrollTo({top:0,behavior:"smooth"})},Be=async(e,r)=>{const s=r.id||r._id;if(i!=="mal"&&!/^\d+$/.test(s)&&(e.preventDefault(),e.stopPropagation(),!Ee)){ee(s);try{if(i!=="anilist"){let o=!1;try{o=(await O("/api/anilist-status"))?.available===!0}catch{o=!1}if(o){const ue=await O(`/api/mature/resolve?title=${encodeURIComponent(r.name)}`);m(`/anime/${ue.id}`);return}const ce=await fetch("/api/mature/allocate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,nativeId:s,title:r.name,thumbnail:r.thumbnail})}),de=await ce.json().catch(()=>null);if(!ce.ok||!de?.id)throw new Error("Allocate failed");m(`/anime/${de.id}`);return}const u=await O(`/api/mature/resolve?title=${encodeURIComponent(r.name)}`);m(`/anime/${u.id}`)}catch{Me.error("Could not match this title on AniList")}finally{ee(null)}}},W=new Date().getFullYear(),ke=[{value:"ALL",label:"All Years"},...Array.from({length:W-1980+1},(e,r)=>({value:String(W-r),label:String(W-r)}))],De=P.length>0?P.map(e=>({value:e,label:ve(e)})):Z.map(e=>({value:e.slug,label:e.name}));return x?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(A,{name:"search",className:a.searchIcon}),t("input",{type:"text",placeholder:`Search ${re.find(e=>e.value===i)?.label}...`,value:S,onChange:e=>H(e.target.value),onKeyDown:e=>{e.key==="Enter"&&E()},className:a.searchInput})]}),t("div",{className:a.searchActions,children:[t("select",{value:i,onChange:e=>Re(e.target.value),className:a.providerSelect,"aria-label":"Provider",children:re.map(e=>t("option",{value:e.value,children:e.label},e.value))}),t(L,{onClick:E,className:a.searchBtn,children:"Search"}),c&&t("button",{onClick:()=>Pe(!Q),className:`${a.filterToggleBtn} ${Q?a.active:""}`,children:[t(A,{name:"filter"})," Filters"]}),ie&&t("select",{value:_,onChange:e=>{J(e.target.value),h(1),v(f({remoteSort:e.target.value,page:1}))},className:a.providerSelect,"aria-label":"Sort",children:Je.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]}),(i==="anilist"||i==="mal")&&t("div",{className:`${a.advancedFilters} ${Q?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:R,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:b,onChange:e=>be(e.currentTarget.value),children:He.map(e=>t("option",{value:e.value,children:e.label},e.value))})]}),i==="anilist"&&t(ge,{children:[t("div",{className:a.filterItem,children:[t("label",{children:"Season"}),t("select",{value:B,onChange:e=>ye(e.currentTarget.value),children:Xe.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:k,onChange:e=>Ne(e.currentTarget.value),children:ke.map(e=>t("option",{value:e.value,children:e.label},e.value))})]})]})]}),t("div",{className:a.filterActions,children:t(L,{onClick:E,className:a.searchBtn,children:"Apply Filters"})})]}),!c&&!!G&&(w||p||N)&&t("div",{className:`${a.advancedFilters} ${a.show}`,children:[t("div",{className:a.filterDivider}),t("div",{className:`${a.filterGrid} ${z.tightGrid}`,children:[p&&t("div",{className:`${a.filterItem} ${z.shrinkSelect}`,children:[t("label",{children:"Order"}),t("select",{value:ne,onChange:e=>{Ce(e.target.value),h(1),v(f({remoteOrder:e.target.value,page:1}))},children:(y.length>0?y:["recent"]).map(e=>t("option",{value:e,children:Ze[e]||e},e))})]}),w&&t("div",{className:`${a.filterItem} ${z.shrinkSelect}`,children:[t("label",{children:"Genre"}),t("select",{value:g,onChange:e=>{p?(D(e.target.value),h(1),v(f({genre:e.target.value,page:1}))):_e(e.target.value)},children:[t("option",{value:"",children:"All Genres"}),De.map(e=>t("option",{value:e.value,children:e.label},e.value))]})]}),N&&t("div",{className:a.filterItem,children:[t("label",{children:"Studio"}),t("input",{type:"text",placeholder:"Studio name...",value:K,onChange:e=>Ae(e.target.value),onKeyDown:e=>{e.key==="Enter"&&E()},className:a.searchInput})]})]}),g&&w&&!p&&t("p",{className:a.pageSubtitle,children:["Browsing the ",ve(g)," genre — search text is ignored while a genre is selected."]}),(p||N)&&t("div",{className:a.filterActions,children:t(L,{onClick:E,className:a.searchBtn,children:"Apply Filters"})})]})]}),Le&&t(Ue,{message:Te?.message||"Search failed"}),Oe?t(xe,{count:le}):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(ge,{children:[t("div",{className:a.resultsHeader,children:[t("h2",{className:a.resultsTitle,children:[C?.total??F.length," result",(C?.total??F.length)===1?"":"s"]}),t("div",{className:a.pagination,children:[t("button",{className:a.pageBtn,disabled:d<=1,onClick:()=>M(d-1),children:[t(A,{name:"chevron-left"})," ",t("span",{children:"Prev"})]}),t("span",{className:a.pageInfo,children:["Page ",t("strong",{children:d})]}),t("button",{className:a.pageBtn,disabled:!oe,onClick:()=>M(d+1),children:[t("span",{children:"Next"})," ",t(A,{name:"chevron-right"})]})]})]}),t("div",{className:a.resultsGrid,children:F.map(e=>t("div",{onClickCapture:r=>Be(r,e),children:t(qe,{anime:e})},`${i}-${e._id}`))}),t("div",{className:a.bottomPagination,children:t("div",{className:a.pagination,children:[t("button",{className:a.pageBtn,disabled:d<=1,onClick:()=>M(d-1),children:[t(A,{name:"chevron-left"})," ",t("span",{children:"Prev"})]}),t("span",{className:a.pageInfo,children:["Page ",t("strong",{children:d})]}),t("button",{className:a.pageBtn,disabled:!oe,onClick:()=>M(d+1),children:[t("span",{children:"Next"})," ",t(A,{name:"chevron-right"})]})]})})]})]}):t(Ke,{isOpen:!0,onClose:()=>m("/"),onGrant:fe})}export{vt as default};
@@ -1 +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 $e,s as Le}from"./vendor-ui-CUDCvRS_.js";import{I as v}from"./vendor-icons-CDMuNDeL.js";import{q as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-IZgh1beL.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",ct="_secondaryActions_7glox_184",lt="_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:ct,watchlistBtn:lt,detailsBtn:it,active:dt,loading:ut,spinner:_t},ln=({anchorRect:t,onMouseEnter:a,onMouseLeave:c,onRequestClose:l,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:[$e({fallbackAxisSideDirection:"start"}),Le({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:()=>l?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:c,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[c,l]=y(a);return K(()=>{l(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke(`/api/show-meta/${t}`).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&l(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:c}}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",$t="_airTime_w7bu0_234",Lt="_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:$t,adultBadge:Lt,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),c=x(null),l=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{c.current&&(clearTimeout(c.current),c.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)=>{l.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,l.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),c.current=setTimeout(()=>{c.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!c.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"?c.current&&(clearTimeout(c.current),c.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!l.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>l.current?(l.current=!1,!0):!1,[]);return{longPressFiredRef:l,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:c,progress:l,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),[$,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},L=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose(L)},[f,L]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},ce=()=>{j()},le=()=>{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&&!!l&&l.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=c==="book"?e(v,{name:"book",size:28}):c==="play"?e(v,{name:"play",size:28}):c==="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),$&&j()},onMouseLeave:()=>{D(!1),P?.(!1),$&&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&&l&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${l.percent}%`}})}),e("div",{className:n.timestamp,children:l.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&&$&&G?g(G,{close:L,onMouseEnter:ce,onMouseLeave:le}):null]})});export{dn as M,ln as a,n as m,R as p};
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 $e,s as Le}from"./vendor-ui-CUDCvRS_.js";import{I as v}from"./vendor-icons-CDMuNDeL.js";import{q as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-CfvzoNYQ.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",ct="_secondaryActions_7glox_184",lt="_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:ct,watchlistBtn:lt,detailsBtn:it,active:dt,loading:ut,spinner:_t},ln=({anchorRect:t,onMouseEnter:a,onMouseLeave:c,onRequestClose:l,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:[$e({fallbackAxisSideDirection:"start"}),Le({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:()=>l?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:c,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[c,l]=y(a);return K(()=>{l(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke(`/api/show-meta/${t}`).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&l(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:c}}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",$t="_airTime_w7bu0_234",Lt="_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:$t,adultBadge:Lt,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),c=x(null),l=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{c.current&&(clearTimeout(c.current),c.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)=>{l.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,l.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),c.current=setTimeout(()=>{c.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!c.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"?c.current&&(clearTimeout(c.current),c.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!l.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>l.current?(l.current=!1,!0):!1,[]);return{longPressFiredRef:l,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:c,progress:l,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),[$,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},L=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose(L)},[f,L]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},ce=()=>{j()},le=()=>{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&&!!l&&l.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=c==="book"?e(v,{name:"book",size:28}):c==="play"?e(v,{name:"play",size:28}):c==="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),$&&j()},onMouseLeave:()=>{D(!1),P?.(!1),$&&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&&l&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${l.percent}%`}})}),e("div",{className:n.timestamp,children:l.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&&$&&G?g(G,{close:L,onMouseEnter:ce,onMouseLeave:le}):null]})});export{dn as M,ln as a,n as m,R as p};
@@ -1 +1 @@
1
- import{A as L,d as b,h as F,g as Ke,u as e,S as w,$ as Qe,o as ze,T as z}from"./vendor-core-8R2fFbyN.js";import{q as P,z as C}from"./index-IZgh1beL.js";import{I as p}from"./vendor-icons-CDMuNDeL.js";import{a as i}from"./Asmr.module-ChUXDZKx.js";import{r as m}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Ce,a as Le}from"./vendor-query-BXRECSI6.js";function Ie(n){if(!Number.isFinite(n)||n<0)return"0:00";const h=Math.floor(n/60),g=Math.floor(n%60);return`${h}:${String(g).padStart(2,"0")}`}const Ye=({track:n,shuffle:h,onToggleShuffle:g,onTrackStep:O,onTrackFailed:be,onClose:ie,liked:Y,likeVisible:W,likePending:ae,onToggleLike:V})=>{const M=L(null),Z=L(!1),[q,R]=b(!1),[he,l]=b(!0),[N,D]=b(!1),[I,B]=b(0),[U,se]=b(0),[T,H]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[$,re]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),j=L(T);j.current=T;const S=L($);S.current=$;const f=L(0),E=L(0),A=L(null),K=L("");K.current||(K.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const X=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,G=()=>{A.current&&(window.clearTimeout(A.current),A.current=null)},ee=r=>{const a=M.current;if(!a)return;G(),l(!0),D(!1);const k=()=>{if(a.removeEventListener("loadedmetadata",k),r>5&&Number.isFinite(a.duration)&&r<a.duration-5)try{a.currentTime=r}catch{}};a.addEventListener("loadedmetadata",k),a.src=X,a.load(),a.volume=j.current,a.play().catch(()=>{})},ve=()=>{l(!1),D(!0),be?.(n),S.current&&O(1)},oe=()=>{if(!A.current){if(E.current>=3){ve();return}E.current+=1,A.current=window.setTimeout(()=>{A.current=null,ee(f.current)},5e3)}},ke=()=>{E.current=0,ee(f.current)};F(()=>{f.current=0,E.current=0,R(!1),B(0),se(0);const r=M.current;return ee(f.current),()=>{G(),r&&r.removeAttribute("src")}},[X]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=n.thumbnails?.[n.thumbnails.length-1]?.url??null,te=Ke.useCallback(r=>{const a=M.current;fetch("/api/discord/music",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:_||"",currentTime:a?.currentTime??0,duration:Number.isFinite(a?.duration??NaN)?a?.duration:0,sessionId:K.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:K.current})}).catch(()=>{})},[n,_]);F(()=>{te(q)},[te,q,n.id]),F(()=>{if(!q)return;const r=window.setInterval(()=>te(!0),15e3);return()=>window.clearInterval(r)},[q,te]),F(()=>{const r=K.current,a=()=>{if(!r)return;const ye=JSON.stringify({sessionId:r});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([ye],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:r,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:ye,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,bye:!0}),keepalive:!0}).catch(()=>{}))},k=()=>a(),v=()=>{document.visibilityState==="hidden"&&a()};return window.addEventListener("pagehide",k),window.addEventListener("beforeunload",k),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("pagehide",k),window.removeEventListener("beforeunload",k),document.removeEventListener("visibilitychange",v),a()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,le]=b(!1);F(()=>{le(!1)},[_]);const ce=`${n.title} — ${n.artists}`,ge=e(w,{children:[e("div",{className:i.playerButtons,children:[e("button",{className:i.playerBtn,onClick:()=>O(-1),"aria-label":"Previous track",children:e(p,{name:"step-backward"})}),e("button",{className:`${i.playerBtn} ${i.playBtn}`,onClick:pe,"aria-label":q?"Pause":"Play",children:q?e(p,{name:"pause"}):e(p,{name:"play"})}),e("button",{className:i.playerBtn,onClick:()=>O(1),"aria-label":"Next track",children:e(p,{name:"step-forward"})}),N&&e("button",{className:i.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(p,{name:"redo"})})]}),e("div",{className:i.seekRow,children:[e("span",{className:i.timeLabel,children:Ie(I)}),e("input",{className:i.seekBar,type:"range",min:0,max:U||0,step:.1,value:Math.min(I,U||0),onChange:r=>{const a=M.current;!a||!Number.isFinite(a.duration)||(a.currentTime=parseFloat(r.target.value),B(a.currentTime))},onPointerDown:()=>{Z.current=!0},onPointerUp:()=>{Z.current=!1},style:{"--played-percent":`${U>0?I/U*100:0}%`},"aria-label":"Seek"}),e("span",{className:i.timeLabel,children:Ie(U)}),he&&!N&&e("span",{className:i.timeLabel,children:"loading…"})]})]}),ue=e(w,{children:[n.thumbnails?.[0]?.url&&!Ne&&e("img",{src:n.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async",onError:()=>le(!0)}),e("div",{className:i.playerInfo,children:[e("p",{className:i.playerTitle,title:ce,children:ce}),e("p",{className:i.playerTrack,children:n.artists})]}),e("div",{className:i.playerControls,children:ge}),e("div",{className:i.playerRight,children:[T===0?e(p,{name:"volume-mute",className:i.volumeIcon}):T<.5?e(p,{name:"volume-down",className:i.volumeIcon}):e(p,{name:"volume-up",className:i.volumeIcon}),e("input",{className:i.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const a=parseFloat(r.target.value);H(a),localStorage.setItem("musicVolume",String(a))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:i.playerActions,children:[W&&V&&e("button",{className:`${i.playerBtn} ${Y?i.playerBtnActive:""}`,onClick:V,disabled:ae,title:Y?"Remove from Liked Music":"Add to Liked Music","aria-label":Y?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!Y,children:e(p,{name:"heart"})}),e("button",{className:`${i.playerBtn} ${h?i.playerBtnActive:""}`,onClick:g,title:h?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":h,children:e(p,{name:"shuffle"})}),e("button",{className:`${i.playerBtn} ${$?i.playerBtnActive:""}`,onClick:()=>{re(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:$?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":$,children:e(p,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:i.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(p,{name:"external-link-alt"})}),e("button",{className:i.playerBtn,onClick:ie,"aria-label":"Close player",children:e(p,{name:"times"})})]})]});return Qe(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{R(!0),l(!1),D(!1),E.current=0,G()},onPause:()=>R(!1),onWaiting:()=>{N||l(!0)},onPlaying:()=>{l(!1),E.current=0,G()},onTimeUpdate:r=>{const a=r.target.currentTime;f.current=a,G(),Z.current||B(a)},onStalled:()=>{oe()},onLoadedMetadata:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onDurationChange:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onError:()=>{oe()},onEnded:()=>{S.current&&O(1)}}),e("div",{className:i.playerBar,children:ue})]}),document.body)},je=()=>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,Ge=()=>J({queryKey:["music-auth"],queryFn:()=>P("/api/music/auth/status"),staleTime:30*1e3,refetchInterval:n=>n.state.data?.authenticated?!1:3e3,retry:1}),Je=()=>{const n=Ce();return Le({mutationFn:h=>P("/api/music/auth/start",{method:"POST",body:JSON.stringify({cookie:h})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},We=()=>{const n=Ce();return Le({mutationFn:()=>P("/api/music/auth/signout",{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},Ve=n=>J({queryKey:["music-search",n],queryFn:()=>P(`/api/music/search?q=${encodeURIComponent(n)}`),enabled:n.trim().length>0,staleTime:me,retry:1}),Ze=n=>J({queryKey:["music-library"],queryFn:()=>P("/api/music/library"),enabled:n,staleTime:me,retry:1}),Xe=n=>J({queryKey:["music-track",n],queryFn:()=>P(`/api/music/track?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),et=n=>J({queryKey:["music-playlist",n],queryFn:()=>P(`/api/music/playlist?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),tt=n=>J({queryKey:["music-upnext",n],queryFn:()=>P(`/api/music/upnext?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),nt=n=>J({queryKey:["music-likes"],queryFn:()=>P("/api/music/likes"),enabled:n,staleTime:120*1e3,retry:1}),it=()=>{const n=Ce();return Le({mutationFn:({id:h,like:g})=>P("/api/music/like",{method:"POST",body:JSON.stringify({id:h,like:g})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-likes"]}),n.invalidateQueries({queryKey:["music-library"]}),n.invalidateQueries({queryKey:["music-upnext"]})}})},at="_authRow_10tvv_1",st="_btn_10tvv_9",rt="_btnGhost_10tvv_42",ot="_cookieForm_10tvv_74",lt="_cookieInput_10tvv_83",ct="_link_10tvv_99",ut="_contentLayout_10tvv_109",dt="_mainCol_10tvv_116",mt="_upnextAside_10tvv_120",ht="_upnextHeader_10tvv_131",pt="_upnextTitle_10tvv_139",gt="_upnextActions_10tvv_149",yt="_nowPlayingLabel_10tvv_156",ft="_nowPlayingWrap_10tvv_168",bt="_likeBtn_10tvv_172",vt="_likeActive_10tvv_196",y={authRow:at,btn:st,btnGhost:rt,cookieForm:ot,cookieInput:lt,link:ct,contentLayout:ut,mainCol:dt,upnextAside:mt,upnextHeader:ht,upnextTitle:pt,upnextActions:gt,nowPlayingLabel:yt,nowPlayingWrap:ft,likeBtn:bt,likeActive:vt};function $e(n){const h=n.trim();if(!h)return null;const g=h.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??h.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return g||(/^[A-Za-z0-9_-]{11}$/.test(h)?h:null)}const kt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Lt=()=>{const[n,h]=ze(),g=$e(n.get("v")??""),[O,be]=b(""),[ie,Y]=b(""),[W,ae]=b(""),[V,M]=b(!1),[Z,q]=b(()=>localStorage.getItem("musicShuffle")==="true"),[R,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[l,N]=b(null),[D,I]=b([]),[B,U]=b(null),[se,T]=b({}),H=L([]);H.current=D;const $=L(null);$.current=l;const re=L(!1),j=L(new Set),{data:S}=Ge(),f=Je(),E=We(),A=typeof navigator<"u"?navigator.userAgent:"",K=/android/i.test(A),X=/firefox|fxios/i.test(A)&&!K,G=!X&&!K&&/chrome|chromium|edg|brave/i.test(A),ee=X||G,ve=()=>{if(V)return;M(!0);const t=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",s),M(!1),C.error("Helper not detected — install the Dango Helper extension first.")},3e3),s=c=>{window.clearTimeout(t),window.removeEventListener("dango:ytmusic-cookie",s),M(!1);try{const o=JSON.parse(c.detail);if(o?.ok&&o.cookie){const d=o.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(d.includes("…")||d.includes("...")){C.error(`Helper returned a truncated cookie (${d.length} chars) — reload music.youtube.com and Extract again.`);return}ae(d),C.success("Cookie extracted from helper — signing in…"),f.mutate(d)}else o?.error==="NO_COOKIE"?C.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):C.error("Helper request failed — try again.")}catch{C.error("Helper request failed — try again.")}};window.addEventListener("dango:ytmusic-cookie",s),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie"))},{data:oe,isLoading:ke}=Ve(ie),{data:_,isLoading:te}=Ze(S?.authenticated===!0),{data:pe,isLoading:Ne}=et(B?.id??null),{data:le,isLoading:ce}=tt(l?.id??null),{data:ge}=nt(S?.authenticated===!0),ue=it(),Q=z(()=>oe?.tracks||[],[oe]),r=z(()=>_?.playlists||[],[_]),a=z(()=>_?.tracks||[],[_]),k=z(()=>pe?.tracks||[],[pe]),v=z(()=>{const t=le?.tracks||[];return l?t.filter(s=>s.id!==l.id):t},[le,l]),ye=z(()=>new Set(ge?.likedIds||[]),[ge]),Se=t=>se[t.id]??(ye.has(t.id)||t.liked===!0);F(()=>{S?.authenticated!==!0&&T({})},[S?.authenticated]);const Ae=z(()=>[...Q,...k,...a,...v],[Q,k,a,v]),Fe=g&&l?.id!==g&&!Ae.some(t=>t.id===g)?g:null,{data:Me}=Xe(Fe),we=l?.id;F(()=>{document.title=l?`${l.title} - dango`:"Music - dango"},[l]),F(()=>{if(!g){we&&N(null);return}if(we===g)return;const t=o=>{const d=o.find(u=>u.id===g);return d?(N(d),I(u=>u.some(ne=>ne.id===g)?u:o.length>0?o:[d]),!0):!1};if(t(Q)||t(k)||t(a))return;const s=v.find(o=>o.id===g);if(s){N(s),I(o=>o.some(d=>d.id===s.id)?o:[s]);return}const c=Me?.track;c&&c.id===g&&(N(c),I(o=>o.some(d=>d.id===c.id)?o:[c]))},[g,we,Q,k,a,v,Me]);const Te=(t,s)=>{j.current.delete(t.id),N(t),I(s.length>0?s:[t]),h({v:t.id})},Be=t=>{j.current.add(t.id),C.error(`Couldn't play “${t.title}” — skipped.`)},Ee=async()=>{if(re.current)return;const t=H.current,s=t[t.length-1]??$.current;if(s){re.current=!0;try{const c=await P(`/api/music/upnext?id=${encodeURIComponent(s.id)}`),o=new Set(t.map(u=>u.id)),d=(c.tracks||[]).filter(u=>!o.has(u.id)&&!j.current.has(u.id));if(d.length===0){const u=H.current[0];u&&(N(u),h({v:u.id}));return}I([...H.current,...d]),N(d[0]),h({v:d[0].id})}catch{const c=H.current[0];c&&(N(c),h({v:c.id}))}finally{re.current=!1}}},Oe=t=>{const s=H.current,c=$.current;if(!c||s.length===0)return;const o=s.findIndex(x=>x.id===c.id);if(t>0&&R&&(o<0||o===s.length-1)){Ee();return}const d=x=>j.current.has(x.id),u=s.length;let ne;if(Z&&u>1){let x=Math.floor(Math.random()*u);for(let xe=0;xe<u&&(x===o||d(s[x]));xe++)x=Math.floor(Math.random()*u);ne=s[x]}else{const x=t>0?1:-1;let fe=(((o<0?x>0?-1:0:o)+x)%u+u)%u;for(let Re=1;Re<u&&d(s[fe]);Re++)fe=((fe+x)%u+u)%u;ne=s[fe]}N(ne),h({v:ne.id})},qe=()=>{if(R){he(!1),localStorage.setItem("musicRadio","false");return}const t=$.current;if(!t)return;if(v.length===0){C.error("No radio suggestions for this song yet.");return}const s=new Set,c=[];for(const o of[t,...v])s.has(o.id)||(s.add(o.id),c.push(o));he(!0),localStorage.setItem("musicRadio","true"),I(c),C.success(`Radio started — ${v.length} songs queued.`)},_e=t=>{if(S?.authenticated!==!0){C.error("Sign in to like songs.");return}const s=!Se(t);T(c=>({...c,[t.id]:s})),ue.mutate({id:t.id,like:s},{onError:()=>{T(c=>{const o={...c};return delete o[t.id],o}),C.error("Like action failed — try again.")}})},De=()=>{q(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ue=t=>e("button",{className:m.stationRow,onClick:()=>U(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),t.subtitle&&e("span",{className:m.stationSub,children:t.subtitle})]})]},t.id),de=(t,s,c)=>{const o=l?.id===t.id,d=Se(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${m.stationRow} ${o?m.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Te(t,s),className:m.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:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),e("span",{className:m.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),S?.authenticated===!0&&e("button",{className:`${y.likeBtn} ${d?y.likeActive:""}`,onClick:()=>_e(t),disabled:ue.isPending,title:d?"Remove from Liked Music":"Add to Liked Music","aria-label":d?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":d,children:e(p,{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(p,{name:"external-link-alt"})})]},t.id)},Pe=z(()=>{if(!l)return v;const t=new Set,s=[];for(const c of[l,...v])t.has(c.id)||(t.add(c.id),s.push(c));return s},[l,v]),He=t=>{Te(t,Pe)};return e("div",{className:`${i.page} ${l?i.pageWithPlayer:""}`,children:[e("div",{className:i.header,children:[e("h1",{className:i.pageTitle,children:[e(p,{name:"headphones"})," Music"]}),e("form",{className:i.searchForm,onSubmit:t=>{t.preventDefault();const s=$e(O);s?(Y(""),h({v:s})):Y(O)},children:[e("input",{className:i.searchInput,value:O,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:i.searchBtn,type:"submit","aria-label":"Search",children:e(p,{name:"search"})})]})]}),e("div",{className:y.authRow,children:[S?.authenticated?e(w,{children:[e("span",{className:i.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:y.btnGhost,onClick:()=>E.mutate(),disabled:E.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const s=W.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(s){if(s.includes("…")||s.includes("...")){C.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}s!==W&&ae(s),f.mutate(s)}},className:y.cookieForm,children:[e("input",{className:y.cookieInput,value:W,onChange:t=>ae(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:y.btn,type:"submit",disabled:f.isPending||!W.trim(),children:f.isPending?"Checking…":"Sign in"}),ee&&e("button",{className:y.btnGhost,type:"button",onClick:ve,disabled:V||f.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:V?"Extracting…":"Extract from helper"})]}),ee&&e("p",{className:i.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:kt,target:"_blank",rel:"noreferrer",className:y.link,children:"dango-extension.zip"})," ","then"," ",X?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(je,{})]}),f.isSuccess&&e("p",{className:i.statusMsg,children:["Signed in — found ",f.data.tracks," songs and ",f.data.playlists," ","playlists."]}),f.isError&&e("p",{className:i.statusMsg,children:f.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!S?.authenticated&&!f.isError&&!f.isSuccess&&e("p",{className:i.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:l?y.contentLayout:void 0,children:[e("div",{className:y.mainCol,children:ie?e(w,{children:[e("h2",{className:m.sectionTitle,children:["Results for “",ie,"”"]}),ke?e("p",{className:i.statusMsg,children:"Searching…"}):Q.length===0?e("p",{className:i.statusMsg,children:"No tracks found."}):e("div",{className:m.stationList,children:Q.map(t=>de(t,Q))})]}):S?.authenticated?e(w,{children:[e("h2",{className:m.sectionTitle,children:"Your library"}),te?e("p",{className:i.statusMsg,children:"Loading library…"}):e(w,{children:[r.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:"Playlists"}),e("div",{className:m.stationList,children:r.map(t=>Ue(t))})]}),a.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:["Liked songs (",a.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:y.btnGhost,onClick:()=>Te(a[0],a),"aria-label":"Play all liked songs",children:[e(p,{name:"play"})," Play all"]})}),e("div",{className:m.stationList,children:a.map(t=>de(t,a))})]}),B?e(w,{children:[e("button",{className:y.btnGhost,onClick:()=>U(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:m.sectionTitle,children:B.title}),Ne?e("p",{className:i.statusMsg,children:"Loading playlist…"}):k.length===0?e("p",{className:i.statusMsg,children:"No tracks in this playlist."}):e("div",{className:m.stationList,children:k.map(t=>de(t,k))})]}):null]})]}):e("p",{className:i.statusMsg,children:"Search above, or sign in to see your library."})}),l&&e("aside",{className:y.upnextAside,"aria-label":"Up next",children:[e("div",{className:y.upnextHeader,children:e("span",{className:y.upnextTitle,children:[e(p,{name:"list-ul"})," Up Next"]})}),e("div",{className:y.nowPlayingWrap,children:[e("p",{className:y.nowPlayingLabel,children:"Now playing"}),de(l,D.length>0?D:[l])]}),e("div",{className:y.upnextActions,children:e("button",{className:y.btnGhost,onClick:qe,disabled:!R&&(ce||v.length===0),"aria-pressed":R,title:R?"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:R?"Stop radio":"Start radio"})}),ce?e("p",{className:i.statusMsg,children:"Loading suggestions…"}):v.length===0?e("p",{className:i.statusMsg,children:"No suggestions for this song."}):e("div",{className:m.stationList,children:v.map(t=>de(t,Pe,He))})]})]}),l&&e(Ye,{track:l,queue:D,shuffle:Z,onToggleShuffle:De,onTrackStep:Oe,onTrackFailed:Be,onClose:()=>{N(null),h({})},liked:l?Se(l):!1,likeVisible:S?.authenticated===!0,likePending:ue.isPending,onToggleLike:()=>_e(l)})]})};export{Lt as default};
1
+ import{A as L,d as b,h as F,g as Ke,u as e,S as w,$ as Qe,o as ze,T as z}from"./vendor-core-8R2fFbyN.js";import{q as P,z as C}from"./index-CfvzoNYQ.js";import{I as p}from"./vendor-icons-CDMuNDeL.js";import{a as i}from"./Asmr.module-ChUXDZKx.js";import{r as m}from"./Radio.module-DGSZLpKM.js";import{b as J,u as Ce,a as Le}from"./vendor-query-BXRECSI6.js";function Ie(n){if(!Number.isFinite(n)||n<0)return"0:00";const h=Math.floor(n/60),g=Math.floor(n%60);return`${h}:${String(g).padStart(2,"0")}`}const Ye=({track:n,shuffle:h,onToggleShuffle:g,onTrackStep:O,onTrackFailed:be,onClose:ie,liked:Y,likeVisible:W,likePending:ae,onToggleLike:V})=>{const M=L(null),Z=L(!1),[q,R]=b(!1),[he,l]=b(!0),[N,D]=b(!1),[I,B]=b(0),[U,se]=b(0),[T,H]=b(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[$,re]=b(()=>localStorage.getItem("musicAutoplay")!=="false"),j=L(T);j.current=T;const S=L($);S.current=$;const f=L(0),E=L(0),A=L(null),K=L("");K.current||(K.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const X=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,G=()=>{A.current&&(window.clearTimeout(A.current),A.current=null)},ee=r=>{const a=M.current;if(!a)return;G(),l(!0),D(!1);const k=()=>{if(a.removeEventListener("loadedmetadata",k),r>5&&Number.isFinite(a.duration)&&r<a.duration-5)try{a.currentTime=r}catch{}};a.addEventListener("loadedmetadata",k),a.src=X,a.load(),a.volume=j.current,a.play().catch(()=>{})},ve=()=>{l(!1),D(!0),be?.(n),S.current&&O(1)},oe=()=>{if(!A.current){if(E.current>=3){ve();return}E.current+=1,A.current=window.setTimeout(()=>{A.current=null,ee(f.current)},5e3)}},ke=()=>{E.current=0,ee(f.current)};F(()=>{f.current=0,E.current=0,R(!1),B(0),se(0);const r=M.current;return ee(f.current),()=>{G(),r&&r.removeAttribute("src")}},[X]),F(()=>{const r=M.current;r&&(r.volume=T)},[T]),F(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const _=n.thumbnails?.[n.thumbnails.length-1]?.url??null,te=Ke.useCallback(r=>{const a=M.current;fetch("/api/discord/music",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:_||"",currentTime:a?.currentTime??0,duration:Number.isFinite(a?.duration??NaN)?a?.duration:0,sessionId:K.current})}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:K.current})}).catch(()=>{})},[n,_]);F(()=>{te(q)},[te,q,n.id]),F(()=>{if(!q)return;const r=window.setInterval(()=>te(!0),15e3);return()=>window.clearInterval(r)},[q,te]),F(()=>{const r=K.current,a=()=>{if(!r)return;const ye=JSON.stringify({sessionId:r});navigator.sendBeacon?(navigator.sendBeacon("/api/discord/clear",new Blob([ye],{type:"application/json"})),navigator.sendBeacon("/api/discord/heartbeat",new Blob([JSON.stringify({sessionId:r,bye:!0})],{type:"application/json"}))):(fetch("/api/discord/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:ye,keepalive:!0}).catch(()=>{}),fetch("/api/discord/heartbeat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,bye:!0}),keepalive:!0}).catch(()=>{}))},k=()=>a(),v=()=>{document.visibilityState==="hidden"&&a()};return window.addEventListener("pagehide",k),window.addEventListener("beforeunload",k),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("pagehide",k),window.removeEventListener("beforeunload",k),document.removeEventListener("visibilitychange",v),a()}},[]);const pe=()=>{const r=M.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Ne,le]=b(!1);F(()=>{le(!1)},[_]);const ce=`${n.title} — ${n.artists}`,ge=e(w,{children:[e("div",{className:i.playerButtons,children:[e("button",{className:i.playerBtn,onClick:()=>O(-1),"aria-label":"Previous track",children:e(p,{name:"step-backward"})}),e("button",{className:`${i.playerBtn} ${i.playBtn}`,onClick:pe,"aria-label":q?"Pause":"Play",children:q?e(p,{name:"pause"}):e(p,{name:"play"})}),e("button",{className:i.playerBtn,onClick:()=>O(1),"aria-label":"Next track",children:e(p,{name:"step-forward"})}),N&&e("button",{className:i.playerBtn,onClick:ke,title:"Retry playback","aria-label":"Retry playback",children:e(p,{name:"redo"})})]}),e("div",{className:i.seekRow,children:[e("span",{className:i.timeLabel,children:Ie(I)}),e("input",{className:i.seekBar,type:"range",min:0,max:U||0,step:.1,value:Math.min(I,U||0),onChange:r=>{const a=M.current;!a||!Number.isFinite(a.duration)||(a.currentTime=parseFloat(r.target.value),B(a.currentTime))},onPointerDown:()=>{Z.current=!0},onPointerUp:()=>{Z.current=!1},style:{"--played-percent":`${U>0?I/U*100:0}%`},"aria-label":"Seek"}),e("span",{className:i.timeLabel,children:Ie(U)}),he&&!N&&e("span",{className:i.timeLabel,children:"loading…"})]})]}),ue=e(w,{children:[n.thumbnails?.[0]?.url&&!Ne&&e("img",{src:n.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async",onError:()=>le(!0)}),e("div",{className:i.playerInfo,children:[e("p",{className:i.playerTitle,title:ce,children:ce}),e("p",{className:i.playerTrack,children:n.artists})]}),e("div",{className:i.playerControls,children:ge}),e("div",{className:i.playerRight,children:[T===0?e(p,{name:"volume-mute",className:i.volumeIcon}):T<.5?e(p,{name:"volume-down",className:i.volumeIcon}):e(p,{name:"volume-up",className:i.volumeIcon}),e("input",{className:i.volumeBar,type:"range",min:0,max:1,step:.01,value:T,onChange:r=>{const a=parseFloat(r.target.value);H(a),localStorage.setItem("musicVolume",String(a))},style:{"--volume-percent":`${T*100}%`},"aria-label":"Volume"})]}),e("div",{className:i.playerActions,children:[W&&V&&e("button",{className:`${i.playerBtn} ${Y?i.playerBtnActive:""}`,onClick:V,disabled:ae,title:Y?"Remove from Liked Music":"Add to Liked Music","aria-label":Y?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!Y,children:e(p,{name:"heart"})}),e("button",{className:`${i.playerBtn} ${h?i.playerBtnActive:""}`,onClick:g,title:h?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":h,children:e(p,{name:"shuffle"})}),e("button",{className:`${i.playerBtn} ${$?i.playerBtnActive:""}`,onClick:()=>{re(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:$?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":$,children:e(p,{name:"forward"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(n.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":"Open in YouTube Music",className:i.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(p,{name:"external-link-alt"})}),e("button",{className:i.playerBtn,onClick:ie,"aria-label":"Close player",children:e(p,{name:"times"})})]})]});return Qe(e(w,{children:[e("audio",{ref:M,preload:"none",onPlay:()=>{R(!0),l(!1),D(!1),E.current=0,G()},onPause:()=>R(!1),onWaiting:()=>{N||l(!0)},onPlaying:()=>{l(!1),E.current=0,G()},onTimeUpdate:r=>{const a=r.target.currentTime;f.current=a,G(),Z.current||B(a)},onStalled:()=>{oe()},onLoadedMetadata:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onDurationChange:r=>{const a=r.target.duration;Number.isFinite(a)&&se(a)},onError:()=>{oe()},onEnded:()=>{S.current&&O(1)}}),e("div",{className:i.playerBar,children:ue})]}),document.body)},je=()=>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,Ge=()=>J({queryKey:["music-auth"],queryFn:()=>P("/api/music/auth/status"),staleTime:30*1e3,refetchInterval:n=>n.state.data?.authenticated?!1:3e3,retry:1}),Je=()=>{const n=Ce();return Le({mutationFn:h=>P("/api/music/auth/start",{method:"POST",body:JSON.stringify({cookie:h})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},We=()=>{const n=Ce();return Le({mutationFn:()=>P("/api/music/auth/signout",{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-auth"]}),n.invalidateQueries({queryKey:["music-library"]})}})},Ve=n=>J({queryKey:["music-search",n],queryFn:()=>P(`/api/music/search?q=${encodeURIComponent(n)}`),enabled:n.trim().length>0,staleTime:me,retry:1}),Ze=n=>J({queryKey:["music-library"],queryFn:()=>P("/api/music/library"),enabled:n,staleTime:me,retry:1}),Xe=n=>J({queryKey:["music-track",n],queryFn:()=>P(`/api/music/track?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),et=n=>J({queryKey:["music-playlist",n],queryFn:()=>P(`/api/music/playlist?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),tt=n=>J({queryKey:["music-upnext",n],queryFn:()=>P(`/api/music/upnext?id=${encodeURIComponent(n||"")}`),enabled:!!n,staleTime:me,retry:1}),nt=n=>J({queryKey:["music-likes"],queryFn:()=>P("/api/music/likes"),enabled:n,staleTime:120*1e3,retry:1}),it=()=>{const n=Ce();return Le({mutationFn:({id:h,like:g})=>P("/api/music/like",{method:"POST",body:JSON.stringify({id:h,like:g})}),onSuccess:()=>{n.invalidateQueries({queryKey:["music-likes"]}),n.invalidateQueries({queryKey:["music-library"]}),n.invalidateQueries({queryKey:["music-upnext"]})}})},at="_authRow_10tvv_1",st="_btn_10tvv_9",rt="_btnGhost_10tvv_42",ot="_cookieForm_10tvv_74",lt="_cookieInput_10tvv_83",ct="_link_10tvv_99",ut="_contentLayout_10tvv_109",dt="_mainCol_10tvv_116",mt="_upnextAside_10tvv_120",ht="_upnextHeader_10tvv_131",pt="_upnextTitle_10tvv_139",gt="_upnextActions_10tvv_149",yt="_nowPlayingLabel_10tvv_156",ft="_nowPlayingWrap_10tvv_168",bt="_likeBtn_10tvv_172",vt="_likeActive_10tvv_196",y={authRow:at,btn:st,btnGhost:rt,cookieForm:ot,cookieInput:lt,link:ct,contentLayout:ut,mainCol:dt,upnextAside:mt,upnextHeader:ht,upnextTitle:pt,upnextActions:gt,nowPlayingLabel:yt,nowPlayingWrap:ft,likeBtn:bt,likeActive:vt};function $e(n){const h=n.trim();if(!h)return null;const g=h.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??h.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return g||(/^[A-Za-z0-9_-]{11}$/.test(h)?h:null)}const kt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Lt=()=>{const[n,h]=ze(),g=$e(n.get("v")??""),[O,be]=b(""),[ie,Y]=b(""),[W,ae]=b(""),[V,M]=b(!1),[Z,q]=b(()=>localStorage.getItem("musicShuffle")==="true"),[R,he]=b(()=>localStorage.getItem("musicRadio")!=="false"),[l,N]=b(null),[D,I]=b([]),[B,U]=b(null),[se,T]=b({}),H=L([]);H.current=D;const $=L(null);$.current=l;const re=L(!1),j=L(new Set),{data:S}=Ge(),f=Je(),E=We(),A=typeof navigator<"u"?navigator.userAgent:"",K=/android/i.test(A),X=/firefox|fxios/i.test(A)&&!K,G=!X&&!K&&/chrome|chromium|edg|brave/i.test(A),ee=X||G,ve=()=>{if(V)return;M(!0);const t=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",s),M(!1),C.error("Helper not detected — install the Dango Helper extension first.")},3e3),s=c=>{window.clearTimeout(t),window.removeEventListener("dango:ytmusic-cookie",s),M(!1);try{const o=JSON.parse(c.detail);if(o?.ok&&o.cookie){const d=o.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(d.includes("…")||d.includes("...")){C.error(`Helper returned a truncated cookie (${d.length} chars) — reload music.youtube.com and Extract again.`);return}ae(d),C.success("Cookie extracted from helper — signing in…"),f.mutate(d)}else o?.error==="NO_COOKIE"?C.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):C.error("Helper request failed — try again.")}catch{C.error("Helper request failed — try again.")}};window.addEventListener("dango:ytmusic-cookie",s),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie"))},{data:oe,isLoading:ke}=Ve(ie),{data:_,isLoading:te}=Ze(S?.authenticated===!0),{data:pe,isLoading:Ne}=et(B?.id??null),{data:le,isLoading:ce}=tt(l?.id??null),{data:ge}=nt(S?.authenticated===!0),ue=it(),Q=z(()=>oe?.tracks||[],[oe]),r=z(()=>_?.playlists||[],[_]),a=z(()=>_?.tracks||[],[_]),k=z(()=>pe?.tracks||[],[pe]),v=z(()=>{const t=le?.tracks||[];return l?t.filter(s=>s.id!==l.id):t},[le,l]),ye=z(()=>new Set(ge?.likedIds||[]),[ge]),Se=t=>se[t.id]??(ye.has(t.id)||t.liked===!0);F(()=>{S?.authenticated!==!0&&T({})},[S?.authenticated]);const Ae=z(()=>[...Q,...k,...a,...v],[Q,k,a,v]),Fe=g&&l?.id!==g&&!Ae.some(t=>t.id===g)?g:null,{data:Me}=Xe(Fe),we=l?.id;F(()=>{document.title=l?`${l.title} - dango`:"Music - dango"},[l]),F(()=>{if(!g){we&&N(null);return}if(we===g)return;const t=o=>{const d=o.find(u=>u.id===g);return d?(N(d),I(u=>u.some(ne=>ne.id===g)?u:o.length>0?o:[d]),!0):!1};if(t(Q)||t(k)||t(a))return;const s=v.find(o=>o.id===g);if(s){N(s),I(o=>o.some(d=>d.id===s.id)?o:[s]);return}const c=Me?.track;c&&c.id===g&&(N(c),I(o=>o.some(d=>d.id===c.id)?o:[c]))},[g,we,Q,k,a,v,Me]);const Te=(t,s)=>{j.current.delete(t.id),N(t),I(s.length>0?s:[t]),h({v:t.id})},Be=t=>{j.current.add(t.id),C.error(`Couldn't play “${t.title}” — skipped.`)},Ee=async()=>{if(re.current)return;const t=H.current,s=t[t.length-1]??$.current;if(s){re.current=!0;try{const c=await P(`/api/music/upnext?id=${encodeURIComponent(s.id)}`),o=new Set(t.map(u=>u.id)),d=(c.tracks||[]).filter(u=>!o.has(u.id)&&!j.current.has(u.id));if(d.length===0){const u=H.current[0];u&&(N(u),h({v:u.id}));return}I([...H.current,...d]),N(d[0]),h({v:d[0].id})}catch{const c=H.current[0];c&&(N(c),h({v:c.id}))}finally{re.current=!1}}},Oe=t=>{const s=H.current,c=$.current;if(!c||s.length===0)return;const o=s.findIndex(x=>x.id===c.id);if(t>0&&R&&(o<0||o===s.length-1)){Ee();return}const d=x=>j.current.has(x.id),u=s.length;let ne;if(Z&&u>1){let x=Math.floor(Math.random()*u);for(let xe=0;xe<u&&(x===o||d(s[x]));xe++)x=Math.floor(Math.random()*u);ne=s[x]}else{const x=t>0?1:-1;let fe=(((o<0?x>0?-1:0:o)+x)%u+u)%u;for(let Re=1;Re<u&&d(s[fe]);Re++)fe=((fe+x)%u+u)%u;ne=s[fe]}N(ne),h({v:ne.id})},qe=()=>{if(R){he(!1),localStorage.setItem("musicRadio","false");return}const t=$.current;if(!t)return;if(v.length===0){C.error("No radio suggestions for this song yet.");return}const s=new Set,c=[];for(const o of[t,...v])s.has(o.id)||(s.add(o.id),c.push(o));he(!0),localStorage.setItem("musicRadio","true"),I(c),C.success(`Radio started — ${v.length} songs queued.`)},_e=t=>{if(S?.authenticated!==!0){C.error("Sign in to like songs.");return}const s=!Se(t);T(c=>({...c,[t.id]:s})),ue.mutate({id:t.id,like:s},{onError:()=>{T(c=>{const o={...c};return delete o[t.id],o}),C.error("Like action failed — try again.")}})},De=()=>{q(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ue=t=>e("button",{className:m.stationRow,onClick:()=>U(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),t.subtitle&&e("span",{className:m.stationSub,children:t.subtitle})]})]},t.id),de=(t,s,c)=>{const o=l?.id===t.id,d=Se(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${m.stationRow} ${o?m.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>c?c(t):Te(t,s),className:m.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:m.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:m.stationThumbPlaceholder,children:e(p,{name:"headphones"})}),e("span",{className:m.stationMeta,children:[e("span",{className:m.stationName,children:t.title}),e("span",{className:m.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),S?.authenticated===!0&&e("button",{className:`${y.likeBtn} ${d?y.likeActive:""}`,onClick:()=>_e(t),disabled:ue.isPending,title:d?"Remove from Liked Music":"Add to Liked Music","aria-label":d?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":d,children:e(p,{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(p,{name:"external-link-alt"})})]},t.id)},Pe=z(()=>{if(!l)return v;const t=new Set,s=[];for(const c of[l,...v])t.has(c.id)||(t.add(c.id),s.push(c));return s},[l,v]),He=t=>{Te(t,Pe)};return e("div",{className:`${i.page} ${l?i.pageWithPlayer:""}`,children:[e("div",{className:i.header,children:[e("h1",{className:i.pageTitle,children:[e(p,{name:"headphones"})," Music"]}),e("form",{className:i.searchForm,onSubmit:t=>{t.preventDefault();const s=$e(O);s?(Y(""),h({v:s})):Y(O)},children:[e("input",{className:i.searchInput,value:O,onChange:t=>be(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:i.searchBtn,type:"submit","aria-label":"Search",children:e(p,{name:"search"})})]})]}),e("div",{className:y.authRow,children:[S?.authenticated?e(w,{children:[e("span",{className:i.statusMsg,children:["Signed in to YouTube Music",_&&` — ${_.tracks.length} songs, ${_.playlists.length} playlists`]}),e("button",{className:y.btnGhost,onClick:()=>E.mutate(),disabled:E.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const s=W.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(s){if(s.includes("…")||s.includes("...")){C.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}s!==W&&ae(s),f.mutate(s)}},className:y.cookieForm,children:[e("input",{className:y.cookieInput,value:W,onChange:t=>ae(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:y.btn,type:"submit",disabled:f.isPending||!W.trim(),children:f.isPending?"Checking…":"Sign in"}),ee&&e("button",{className:y.btnGhost,type:"button",onClick:ve,disabled:V||f.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:V?"Extracting…":"Extract from helper"})]}),ee&&e("p",{className:i.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:kt,target:"_blank",rel:"noreferrer",className:y.link,children:"dango-extension.zip"})," ","then"," ",X?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(je,{})]}),f.isSuccess&&e("p",{className:i.statusMsg,children:["Signed in — found ",f.data.tracks," songs and ",f.data.playlists," ","playlists."]}),f.isError&&e("p",{className:i.statusMsg,children:f.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!S?.authenticated&&!f.isError&&!f.isSuccess&&e("p",{className:i.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:l?y.contentLayout:void 0,children:[e("div",{className:y.mainCol,children:ie?e(w,{children:[e("h2",{className:m.sectionTitle,children:["Results for “",ie,"”"]}),ke?e("p",{className:i.statusMsg,children:"Searching…"}):Q.length===0?e("p",{className:i.statusMsg,children:"No tracks found."}):e("div",{className:m.stationList,children:Q.map(t=>de(t,Q))})]}):S?.authenticated?e(w,{children:[e("h2",{className:m.sectionTitle,children:"Your library"}),te?e("p",{className:i.statusMsg,children:"Loading library…"}):e(w,{children:[r.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:"Playlists"}),e("div",{className:m.stationList,children:r.map(t=>Ue(t))})]}),a.length>0&&!B&&e(w,{children:[e("h3",{className:m.sectionTitle,children:["Liked songs (",a.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:y.btnGhost,onClick:()=>Te(a[0],a),"aria-label":"Play all liked songs",children:[e(p,{name:"play"})," Play all"]})}),e("div",{className:m.stationList,children:a.map(t=>de(t,a))})]}),B?e(w,{children:[e("button",{className:y.btnGhost,onClick:()=>U(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:m.sectionTitle,children:B.title}),Ne?e("p",{className:i.statusMsg,children:"Loading playlist…"}):k.length===0?e("p",{className:i.statusMsg,children:"No tracks in this playlist."}):e("div",{className:m.stationList,children:k.map(t=>de(t,k))})]}):null]})]}):e("p",{className:i.statusMsg,children:"Search above, or sign in to see your library."})}),l&&e("aside",{className:y.upnextAside,"aria-label":"Up next",children:[e("div",{className:y.upnextHeader,children:e("span",{className:y.upnextTitle,children:[e(p,{name:"list-ul"})," Up Next"]})}),e("div",{className:y.nowPlayingWrap,children:[e("p",{className:y.nowPlayingLabel,children:"Now playing"}),de(l,D.length>0?D:[l])]}),e("div",{className:y.upnextActions,children:e("button",{className:y.btnGhost,onClick:qe,disabled:!R&&(ce||v.length===0),"aria-pressed":R,title:R?"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:R?"Stop radio":"Start radio"})}),ce?e("p",{className:i.statusMsg,children:"Loading suggestions…"}):v.length===0?e("p",{className:i.statusMsg,children:"No suggestions for this song."}):e("div",{className:m.stationList,children:v.map(t=>de(t,Pe,He))})]})]}),l&&e(Ye,{track:l,queue:D,shuffle:Z,onToggleShuffle:De,onTrackStep:Oe,onTrackFailed:Be,onClose:()=>{N(null),h({})},liked:l?Se(l):!1,likeVisible:S?.authenticated===!0,likePending:ue.isPending,onToggleLike:()=>_e(l)})]})};export{Lt as default};
@@ -1 +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,n as b,T as f,B as g,o as k,D as C}from"./AvSyncCalibrator-C8ZoIwMY.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,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:f,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:g,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};
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 f,B as g,z as k,D as C}from"./AvSyncCalibrator-Bs4iejCG.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,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:f,value:i.textColor,onChange:t=>o("textColor",t)}),e(b,{label:"Background Color",colors:g,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};