@serifpersia/dango 3.4.9 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +1 -15
  2. package/client/dist/assets/{AnimeCard-Dnps_uQ4.js → AnimeCard-B2ErWl4t.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-pfps3FSr.js → AnimeInfo-Dfd4zWTx.js} +1 -1
  4. package/client/dist/assets/AnimeInfoPage-_DAHOnnx.js +2 -0
  5. package/client/dist/assets/{Asmr-D_IQfb8x.js → Asmr-CppKRwf3.js} +2 -2
  6. package/client/dist/assets/{AsmrResetProgressModal-BYtWVQA9.js → AsmrResetProgressModal-DqZ8um_v.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-jI6WLW45.js → AvSyncCalibrator-DH6KEsbi.js} +1 -1
  8. package/client/dist/assets/{Home-CpaYOxPA.js → Home-bqn1BmP7.js} +1 -1
  9. package/client/dist/assets/Insights-KlshyXuf.js +1 -0
  10. package/client/dist/assets/{LibraryListPage-DW0HqYwj.js → LibraryListPage-Ba7501DJ.js} +1 -1
  11. package/client/dist/assets/{ListeningList-NIRGPFnw.js → ListeningList-CycltWkq.js} +1 -1
  12. package/client/dist/assets/Manga-C3foLd_W.js +1 -0
  13. package/client/dist/assets/{MangaInfoPage-3Ah2UkzA.js → MangaInfoPage-CKgBcwjP.js} +1 -1
  14. package/client/dist/assets/{MangaReadPage-DpLMkSK1.js → MangaReadPage-B0Nr5zbg.js} +1 -1
  15. package/client/dist/assets/{MangaResetProgressModal-CXyMR31_.js → MangaResetProgressModal-C9YlH9oi.js} +1 -1
  16. package/client/dist/assets/{Mature-Ii7NKE5X.js → Mature-DVvlLfAy.js} +1 -1
  17. package/client/dist/assets/{MediaCard-DcB-RhSF.js → MediaCard-Auk42bqx.js} +1 -1
  18. package/client/dist/assets/Music-BeCMeHS7.js +1 -0
  19. package/client/dist/assets/{OptionListMenu-B3xlVT-D.js → OptionListMenu-AHGTsUIM.js} +1 -1
  20. package/client/dist/assets/{Player-CF7briPT.js → Player-Diz4QXSs.js} +6 -6
  21. package/client/dist/assets/{PlayerSettings-g4xFrRiD.js → PlayerSettings-B8CsR3hI.js} +1 -1
  22. package/client/dist/assets/QueueOptionsButton-tpZ79_8s.js +1 -0
  23. package/client/dist/assets/{QueueRail-wmxRrTaD.js → QueueRail-CvrVAD_w.js} +1 -1
  24. package/client/dist/assets/{Radio-DdGONwsq.js → Radio-s_2zeYYn.js} +1 -1
  25. package/client/dist/assets/{ReadingList-BZtJHLAG.js → ReadingList-DLKfiYLy.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-CzJaHmde.js → ResetProgressModal-jPtyfyf0.js} +1 -1
  27. package/client/dist/assets/{Search-CUHWC7IZ.js → Search-UfzxfJ8k.js} +1 -1
  28. package/client/dist/assets/Settings-CLP_y7EE.js +21 -0
  29. package/client/dist/assets/{Settings-AuFxQcJF.css → Settings-CwIWLSfY.css} +1 -1
  30. package/client/dist/assets/{SkeletonGrid-BnRGuRMg.js → SkeletonGrid-21to5FX0.js} +1 -1
  31. package/client/dist/assets/ToggleSwitch-BPil0d_k.css +1 -0
  32. package/client/dist/assets/ToggleSwitch-CN_ppEc9.js +1 -0
  33. package/client/dist/assets/{Trackers-m2fBLuJo.js → Trackers-QqnmwIKk.js} +1 -1
  34. package/client/dist/assets/{Tv-C7mRP4gg.js → Tv-D3yVtdDx.js} +4 -4
  35. package/client/dist/assets/{TvInfo-D8zdqjdN.js → TvInfo-gue0nYi0.js} +1 -1
  36. package/client/dist/assets/{TvPopup-_GPNroa1.js → TvPopup-CkXBuHHD.js} +1 -1
  37. package/client/dist/assets/{TvSearch-CiFB0G_Y.js → TvSearch-DLP_3Nf2.js} +1 -1
  38. package/client/dist/assets/{TvWatchlist-6tIsBVyA.js → TvWatchlist-DzgVXuh9.js} +1 -1
  39. package/client/dist/assets/{Watchlist-YyxXLuno.js → Watchlist-DeO4iNhW.js} +1 -1
  40. package/client/dist/assets/{hls-DpOQmcQm.js → hls-D3SWhYIU.js} +1 -1
  41. package/client/dist/assets/index-BGCpLf49.js +178 -0
  42. package/client/dist/assets/index-w_r2lTCe.css +1 -0
  43. package/client/dist/assets/{useAnimeInfoData-DJrFWjlu.js → useAnimeInfoData-CWRGC9fX.js} +1 -1
  44. package/client/dist/assets/{useAsmr-XJn2_7ol.js → useAsmr-5n3wPm5z.js} +1 -1
  45. package/client/dist/assets/{useAsmrPopup-DmZ3Np3r.js → useAsmrPopup-BxGzhLmJ.js} +1 -1
  46. package/client/dist/assets/{useMangaLibrary-COua_Bkn.js → useMangaLibrary-DUteTFgU.js} +1 -1
  47. package/client/dist/assets/{useMangaPopup-o6xoB0uh.js → useMangaPopup-BWU1Tz5e.js} +1 -1
  48. package/client/dist/assets/{useProviders-DIy3z1fe.js → useProviders-mkl-w-e4.js} +1 -1
  49. package/client/dist/assets/{useTv-Y_cF_10L.js → useTv-Dl-E6HBp.js} +1 -1
  50. package/client/dist/assets/{useTvLibrary-DpqGf6Bp.js → useTvLibrary-BVECcmlW.js} +1 -1
  51. package/client/dist/index.html +2 -2
  52. package/package.json +2 -2
  53. package/server/dist/app-hono.js +0 -6
  54. package/server/dist/config.js +0 -1
  55. package/server/dist/db/schema-anime.js +3 -2
  56. package/server/dist/lib/{discord-roles-sync.service.js → recommendations.service.js} +0 -149
  57. package/server/dist/server.js +0 -2
  58. package/server/dist/shipped-defaults.js +0 -1
  59. package/server/dist/sync.js +1 -0
  60. package/server/dist/trpc/routers/discord.js +0 -4
  61. package/server/dist/trpc/routers/insights.js +1 -31
  62. package/server/dist/trpc/routers/settings.js +0 -10
  63. package/server/package.json +1 -1
  64. package/client/dist/assets/AnimeInfoPage-CN99oEZn.js +0 -2
  65. package/client/dist/assets/Insights-07y8ViuK.js +0 -1
  66. package/client/dist/assets/Manga-c2X095B3.js +0 -1
  67. package/client/dist/assets/Map-BtXwpBOC.js +0 -1
  68. package/client/dist/assets/Map-CXFqXmsZ.css +0 -1
  69. package/client/dist/assets/Music-CeiL8cZv.js +0 -1
  70. package/client/dist/assets/QueueOptionsButton-B3cSHa0L.js +0 -1
  71. package/client/dist/assets/Settings-Bxqc5fmz.js +0 -21
  72. package/client/dist/assets/index-Cc1Up_NI.css +0 -1
  73. package/client/dist/assets/index-Dyiy_9L6.js +0 -178
  74. package/server/dist/utils/machine-id.js +0 -39
@@ -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-DfaOB3Rn.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-3qrARCPr.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-Dyiy_9L6.js";import{u as Ge}from"./useIsMobile-Dvx1uJ82.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
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-DfaOB3Rn.js";import{a as Re,b as Ae,f as Le,s as $e}from"./vendor-ui-3qrARCPr.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as ke,d as Oe,u as ze,a as De,f as Ue,M as Ve,B as Q}from"./index-BGCpLf49.js";import{u as Ge}from"./useIsMobile-Dvx1uJ82.js";const We="_popupPortal_7glox_1",Ye="_popupContent_7glox_6",je="_popupBackdrop_7glox_31",Fe="_mobile_7glox_38",Xe="_header_7glox_62",qe="_title_7glox_67",He="_body_7glox_87",Je="_metaRow_7glox_94",Ke="_metaItem_7glox_101",Qe="_scoreIcon_7glox_107",Ze="_synopsis_7glox_111",et="_details_7glox_121",tt="_detailItem_7glox_129",nt="_genres_7glox_133",ot="_genre_7glox_133",rt="_footer_7glox_148",st="_primaryAction_7glox_157",at="_watchBtn_7glox_161",lt="_secondaryActions_7glox_184",ct="_watchlistBtn_7glox_189",it="_detailsBtn_7glox_190",dt="_active_7glox_216",ut="_loading_7glox_227",_t="_spinner_7glox_237",R={popupPortal:We,popupContent:Ye,popupBackdrop:je,mobile:Fe,header:Xe,title:qe,body:He,metaRow:Je,metaItem:Ke,scoreIcon:Qe,synopsis:Ze,details:et,detailItem:tt,genres:nt,genre:ot,footer:rt,primaryAction:st,watchBtn:at,secondaryActions:lt,watchlistBtn:ct,detailsBtn:it,active:dt,loading:ut,spinner:_t},cn=({anchorRect:t,onMouseEnter:a,onMouseLeave:l,onRequestClose:c,children:u})=>{const[i]=y(()=>window.matchMedia("(pointer: coarse)").matches),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Re({placement:"right-start",middleware:[Le({fallbackAxisSideDirection:"start"}),$e({padding:20})],whileElementsMounted:Ae});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C}},[i]);const _=e(ee,{children:[i&&e("div",{className:R.popupBackdrop,onClick:()=>c?.()}),e("div",{ref:i?void 0:w.setFloating,className:`${R.popupPortal} ${i?R.mobile:""}`,style:i?void 0:b,onMouseEnter:a,onMouseLeave:l,children:e("div",{className:R.popupContent,children:u})})]});return Ne(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=y(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return ke.data.showMeta.query({id:t}).then(i=>{const r=i?.thumbnail;!u&&r&&r.trim()!==""&&!r.includes("placeholder")&&c(r)}).catch(()=>{}),()=>{u=!0}},[t,a]),{thumbnail:l}}const mt="_cardWrapper_w7bu0_1",ft="_card_w7bu0_1",ht="_cardButton_w7bu0_35",bt="_hoverOverlay_w7bu0_60",Bt="_matureOverlay_w7bu0_81",wt="_posterContainer_w7bu0_91",vt="_horizontal_w7bu0_100",yt="_posterImg_w7bu0_104",Ct="_blurred_w7bu0_116",Mt="_flat_w7bu0_139",xt="_loaded_w7bu0_143",Tt="_posterGradient_w7bu0_147",Pt="_progressSection_w7bu0_167",Nt="_titleSection_w7bu0_174",Et="_title_w7bu0_174",St="_titleText_w7bu0_193",It="_badge_w7bu0_205",Rt="_typeBadge_w7bu0_216 _badge_w7bu0_205",At="_epBadge_w7bu0_225 _badge_w7bu0_205",Lt="_airTime_w7bu0_234",$t="_adultBadge_w7bu0_241 _badge_w7bu0_205",kt="_gated_w7bu0_254",Ot="_notAiredBadge_w7bu0_260 _badge_w7bu0_205",zt="_metaRow_w7bu0_275",Dt="_metaItem_w7bu0_286",Ut="_progressContainer_w7bu0_303",Vt="_progressBar_w7bu0_311",Gt="_timestamp_w7bu0_318",Wt="_removeBtn_w7bu0_323",Yt="_infoBtn_w7bu0_324",jt="_mobileBadges_w7bu0_375",Ft="_mobileBadgeBase_w7bu0_382",Xt="_mobileType_w7bu0_390 _mobileBadgeBase_w7bu0_382",qt="_mobileEp_w7bu0_397 _mobileBadgeBase_w7bu0_382",Ht="_vertical_w7bu0_489",Jt="_placeholder_w7bu0_504",Kt="_placeholderText_w7bu0_513",Qt="_lowEnd_w7bu0_520",n={cardWrapper:mt,card:ft,cardButton:ht,hoverOverlay:bt,matureOverlay:Bt,posterContainer:wt,horizontal:vt,posterImg:yt,blurred:Ct,flat:Mt,loaded:xt,posterGradient:Tt,progressSection:Pt,titleSection:Nt,title:Et,titleText:St,badge:It,typeBadge:Rt,epBadge:At,airTime:Lt,adultBadge:$t,gated:kt,notAiredBadge:Ot,metaRow:zt,metaItem:Dt,progressContainer:Ut,progressBar:Vt,timestamp:Gt,removeBtn:Wt,infoBtn:Yt,mobileBadges:jt,mobileBadgeBase:Ft,mobileType:Xt,mobileEp:qt,vertical:Ht,placeholder:Jt,placeholderText:Kt,lowEnd:Qt},Zt=500,Z=20,en=300;function tn(t){const a=x(null),l=x(null),c=x(!1),u=x({x:0,y:0}),i=x(null),r=d(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),w=d(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),b=d(s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(s,en)},[]),_=d((s,p=!1)=>{c.current=p,t(s,p)},[t]),C=d((s,p)=>{if(p||s.pointerType==="mouse")return;i.current=s.pointerType,c.current=!1,u.current={x:s.clientX,y:s.clientY};const m=s.currentTarget.getBoundingClientRect();r(),l.current=setTimeout(()=>{l.current=null,_(m,!0)},Zt)},[r,_]),B=d(s=>{if(!l.current)return;const p=Math.abs(s.clientX-u.current.x),m=Math.abs(s.clientY-u.current.y);(p>Z||m>Z)&&r()},[r]),g=d(()=>{r(),i.current=null},[r]),P=d((s,p)=>{s.preventDefault(),s.stopPropagation(),i.current==="touch"?l.current&&(clearTimeout(l.current),l.current=null,_(s.currentTarget.getBoundingClientRect(),!0)):!p&&!c.current&&_(s.currentTarget.getBoundingClientRect())},[_]),A=d(()=>c.current?(c.current=!1,!0):!1,[]);return{longPressFiredRef:c,cancelLongPress:r,clearPopupTimeout:w,schedulePopupClose:b,openViaHold:_,handlePointerDown:C,handlePointerMove:B,handlePointerUpOrCancel:g,handleContextMenu:P,consumeLongPressClick:A}}const z={elements:{poster:{typeBadge:!0,chapterBadge:!0,adultBadge:!0},info:{title:!0,mobileBadges:!0,progress:!0,meta:!0}}},dn=Ee(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:C=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Se(),m=Ge(),{titlePreference:te}=Oe(),{lowEndMode:M}=ze(),[ne,oe]=y(!1),[re,D]=y(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=y(!1),[G,W]=y(null),Y=o=>{W(o),V(!0)},$=d(()=>{V(!1),W(null)},[]),f=tn(o=>{if(B){B(o);return}g&&Y(o)}),k=d(()=>{f.schedulePopupClose($)},[f,$]),j=f.clearPopupTimeout,se=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},ae=()=>{g&&k()},le=()=>{j()},ce=()=>{g&&k()},ie=o=>{f.handlePointerDown(o,h)},de=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},ue=o=>{if(B){o.preventDefault(),o.stopPropagation(),B(o.currentTarget.getBoundingClientRect());return}if(g){f.handleContextMenu(o,h);return}f.handleContextMenu(o,h)},X={...r,elements:{...z.elements,...r?.elements||{},poster:{...z.elements?.poster,...r?.elements?.poster||{}},info:{...z.elements?.info,...r?.elements?.info||{}}}},O=t[te]||t.title,N=X.elements?.poster,E=X.elements?.info,_e=(N?.typeBadge??!0)&&!!t.typeBadge,pe=(N?.chapterBadge??!0)&&!!t.chapterBadge,ge=_??N?.removeButton??!!b,me=N?.adultBadge??!0,fe=E?.mobileBadges??!0,he=E?.progress??!0,be=E?.meta??!0,Be=u&&!!c&&c.percent>0,q=!!t.isAdult,[we,ve]=De("agreedToViewMature","false"),ye=we==="true",[H,S]=T.useState(!1),I=T.useRef(null),Ce=()=>{ve("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!ye,Me=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},xe=l==="book"?e(v,{name:"book",size:28}):l==="play"?e(v,{name:"play",size:28}):l==="info"?e(v,{name:"info-circle",size:28}):e(v,{name:"info-circle",size:28}),Te=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Pe=A?U??t.thumbnail:Ue(U,M?100:150,M?150:200);return e("div",{className:`${n.cardWrapper} ${M?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Ie,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:Me,onContextMenu:ue,onPointerDown:ie,onPointerMove:de,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${M?n.flat:""}`}),e("img",{src:Pe,alt:O,className:`${n.posterImg} ${ne?n.loaded:""} ${h&&!M?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>oe(!0)}),!m&&e(ee,{children:[_e&&e("div",{className:n.typeBadge,children:t.typeBadge}),pe&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),me&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&re&&e("div",{className:n.hoverOverlay,children:xe})]}),he&&u&&Be&&c&&e("div",{className:n.progressSection,children:[e("div",{className:n.progressContainer,children:e("div",{className:n.progressBar,style:{width:`${c.percent}%`}})}),e("div",{className:n.timestamp,children:c.label})]}),e("div",{className:n.titleSection,children:[m&&fe&&e("div",{className:n.mobileBadges,children:[!!t.typeBadge&&e("span",{className:n.mobileType,children:t.typeBadge}),t.chapterBadge&&e("span",{className:n.mobileEp,children:t.chapterBadge})]}),E?.title!==!1&&e("div",{className:n.title,title:O,children:e("span",{className:n.titleText,children:O})}),be&&i&&e("div",{className:n.metaRow,children:i})]})]}),H&&e(Ve,{isOpen:H,title:"Content Warning",onClose:()=>S(!1),children:e("div",{style:{padding:"1rem",textAlign:"center"},children:[e("p",{children:"This title contains mature content intended for adult audiences."}),e("p",{children:["By proceeding, you confirm that you are ",e("strong",{children:"18 years of age or older"})," ","(or the age of majority in your jurisdiction) and wish to view this content."]}),e("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"1rem"},children:["You can reset this preference at any time in the ",e("strong",{children:"Settings"})," page."]}),e("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[e(Q,{variant:"secondary",onClick:()=>S(!1),children:"Go Back"}),e(Q,{onClick:Ce,children:"I'm 18+, Continue"})]})]})}),ge&&e("button",{className:n.removeBtn,onClick:Te,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),C&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:se,onMouseLeave:ae,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:le,onMouseLeave:ce}):null]})});export{dn as M,cn as a,n as m,R as p};
@@ -0,0 +1 @@
1
+ import{A as M,d as y,g as Ce,h as P,u as e,S as w,$ as Ze,p as je,T as G}from"./vendor-core-DfaOB3Rn.js";import{t as Pe,O as Je,h as B,z as C}from"./index-BGCpLf49.js";import{I as g}from"./vendor-icons-DrybRNxP.js";import{a as i}from"./Asmr.module-CdWlioTY.js";import{r as h}from"./Radio.module-DGSZLpKM.js";import{b as X,u as Re,a as Ie}from"./vendor-query-BBT5_sHx.js";import{p as K}from"./page.module-C1MlZzf3.js";function Be(n){if(!Number.isFinite(n)||n<0)return"0:00";const l=Math.floor(n/60),f=Math.floor(n%60);return`${l}:${String(f).padStart(2,"0")}`}const Ke=({track:n,shuffle:l,onToggleShuffle:f,onTrackStep:R,onTrackFailed:pe,onClose:Q,liked:F,likeVisible:oe,likePending:le,onToggleLike:ee})=>{const I=M(null),ce=M(!1),[S,te]=y(!1),[m,b]=y(!0),[z,$]=y(!1),[A,ne]=y(0),[V,W]=y(0),[k,ae]=y(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[q,ie]=y(()=>localStorage.getItem("musicAutoplay")!=="false"),T=M(k);T.current=k;const v=M(q);v.current=q;const Y=M(0),E=M(0),D=M(null),U=M("");U.current||(U.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const ge=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,O=Ce.useCallback(()=>{D.current&&(window.clearTimeout(D.current),D.current=null)},[]),se=Ce.useCallback(r=>{const s=I.current;if(!s)return;O(),b(!0),$(!1);const _=()=>{if(s.removeEventListener("loadedmetadata",_),r>5&&Number.isFinite(s.duration)&&r<s.duration-5)try{s.currentTime=r}catch{}};s.addEventListener("loadedmetadata",_),s.src=ge,s.load(),s.volume=T.current,s.play().catch(()=>{})},[ge,O]),fe=()=>{b(!1),$(!0),pe?.(n),v.current&&R(1)},ye=()=>{if(!D.current){if(E.current>=3){fe();return}E.current+=1,D.current=window.setTimeout(()=>{D.current=null,se(Y.current)},5e3)}},H=()=>{E.current=0,se(Y.current)};P(()=>{Y.current=0,E.current=0,te(!1),ne(0),W(0);const r=I.current;return se(Y.current),()=>{O(),r&&r.removeAttribute("src")}},[se,O]),P(()=>{const r=I.current;r&&(r.volume=k)},[k]),P(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const ue=n.thumbnails?.[n.thumbnails.length-1]?.url??null,Z=Ce.useCallback(r=>{const s=I.current;Pe.discord.musicPresence.mutate({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:ue||"",currentTime:s?.currentTime??0,duration:Number.isFinite(s?.duration??NaN)?s?.duration:0,sessionId:U.current}).catch(()=>{}),Pe.discord.heartbeat.mutate({sessionId:U.current}).catch(()=>{})},[n,ue]);P(()=>{Z(S)},[Z,S,n.id]),P(()=>{if(!S)return;const r=window.setInterval(()=>Z(!0),15e3);return()=>window.clearInterval(r)},[S,Z]),P(()=>{const r=U.current,s=()=>Je(r),_=()=>s(),N=()=>{document.visibilityState==="hidden"&&s()};return window.addEventListener("pagehide",_),window.addEventListener("beforeunload",_),document.addEventListener("visibilitychange",N),()=>{window.removeEventListener("pagehide",_),window.removeEventListener("beforeunload",_),document.removeEventListener("visibilitychange",N),s()}},[]);const we=()=>{const r=I.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},[Se,de]=y(!1);P(()=>{de(!1)},[ue]);const be=`${n.title} — ${n.artists}`,ve=e(w,{children:[e("div",{className:i.playerButtons,children:[e("button",{className:i.playerBtn,onClick:()=>R(-1),"aria-label":"Previous track",children:e(g,{name:"step-backward"})}),e("button",{className:`${i.playerBtn} ${i.playBtn}`,onClick:we,"aria-label":S?"Pause":"Play",children:S?e(g,{name:"pause"}):e(g,{name:"play"})}),e("button",{className:i.playerBtn,onClick:()=>R(1),"aria-label":"Next track",children:e(g,{name:"step-forward"})}),z&&e("button",{className:i.playerBtn,onClick:H,title:"Retry playback","aria-label":"Retry playback",children:e(g,{name:"redo"})})]}),e("div",{className:i.seekRow,children:[e("span",{className:i.timeLabel,children:Be(A)}),e("input",{className:i.seekBar,type:"range",min:0,max:V||0,step:.1,value:Math.min(A,V||0),onChange:r=>{const s=I.current;!s||!Number.isFinite(s.duration)||(s.currentTime=parseFloat(r.target.value),ne(s.currentTime))},onPointerDown:()=>{ce.current=!0},onPointerUp:()=>{ce.current=!1},style:{"--played-percent":`${V>0?A/V*100:0}%`},"aria-label":"Seek"}),e("span",{className:i.timeLabel,children:Be(V)}),m&&!z&&e("span",{className:i.timeLabel,children:"loading…"})]})]}),ke=e(w,{children:[n.thumbnails?.[0]?.url&&!Se&&e("img",{src:n.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async",onError:()=>de(!0)}),e("div",{className:i.playerInfo,children:[e("p",{className:i.playerTitle,title:be,children:be}),e("p",{className:i.playerTrack,children:n.artists})]}),e("div",{className:i.playerControls,children:ve}),e("div",{className:i.playerRight,children:[k===0?e(g,{name:"volume-mute",className:i.volumeIcon}):k<.5?e(g,{name:"volume-down",className:i.volumeIcon}):e(g,{name:"volume-up",className:i.volumeIcon}),e("input",{className:i.volumeBar,type:"range",min:0,max:1,step:.01,value:k,onChange:r=>{const s=parseFloat(r.target.value);ae(s),localStorage.setItem("musicVolume",String(s))},style:{"--volume-percent":`${k*100}%`},"aria-label":"Volume"})]}),e("div",{className:i.playerActions,children:[oe&&ee&&e("button",{className:`${i.playerBtn} ${F?i.playerBtnActive:""}`,onClick:ee,disabled:le,title:F?"Remove from Liked Music":"Add to Liked Music","aria-label":F?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!F,children:e(g,{name:"heart"})}),e("button",{className:`${i.playerBtn} ${l?i.playerBtnActive:""}`,onClick:f,title:l?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":l,children:e(g,{name:"shuffle"})}),e("button",{className:`${i.playerBtn} ${q?i.playerBtnActive:""}`,onClick:()=>{ie(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:q?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":q,children:e(g,{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(g,{name:"external-link-alt"})}),e("button",{className:i.playerBtn,onClick:Q,"aria-label":"Close player",children:e(g,{name:"times"})})]})]});return Ze(e(w,{children:[e("audio",{ref:I,preload:"none",onPlay:()=>{te(!0),b(!1),$(!1),E.current=0,O()},onPause:()=>te(!1),onWaiting:()=>{z||b(!0)},onPlaying:()=>{b(!1),E.current=0,O()},onTimeUpdate:r=>{const s=r.target.currentTime;Y.current=s,O(),ce.current||ne(s)},onStalled:()=>{ye()},onLoadedMetadata:r=>{const s=r.target.duration;Number.isFinite(s)&&W(s)},onDurationChange:r=>{const s=r.target.duration;Number.isFinite(s)&&W(s)},onError:()=>{ye()},onEnded:()=>{v.current&&R(1)}}),e("div",{className:i.playerBar,children:ke})]}),document.body)},Xe=()=>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."})]})]}),he=300*1e3,et=()=>{const n=B();return X({...n.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:l=>l.state.data?.authenticated?!1:3e3,retry:1})},tt=()=>{const n=B(),l=Re();return Ie(n.music.authStart.mutationOptions({onSuccess:(f,R)=>{localStorage.setItem("ytmusic_cookie",R.cookie??""),l.invalidateQueries(n.music.pathFilter())}}))},nt=()=>{const n=B(),l=Re();return Ie(n.music.signOut.mutationOptions({onSuccess:()=>{l.invalidateQueries(n.music.pathFilter())}}))},at=n=>{const l=B();return X({...l.music.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:he,retry:1})},it=n=>{const l=B();return X({...l.music.library.queryOptions(),enabled:n,staleTime:he,retry:1})},st=n=>{const l=B();return X({...l.music.track.queryOptions({id:n||void 0}),enabled:!!n,staleTime:he,retry:1})},rt=n=>{const l=B();return X({...l.music.playlist.queryOptions({id:n||void 0}),enabled:!!n,staleTime:he,retry:1})},ot=n=>{const l=B();return X({...l.music.upnext.queryOptions({id:n||void 0}),enabled:!!n,staleTime:he,retry:1})},lt=n=>{const l=B();return X({...l.music.likes.queryOptions(),enabled:n,staleTime:120*1e3,retry:1})},ct=()=>{const n=B(),l=Re();return Ie(n.music.like.mutationOptions({onSuccess:()=>{l.invalidateQueries(n.music.pathFilter())}}))},ut="_authRow_10tvv_1",dt="_btn_10tvv_9",mt="_btnGhost_10tvv_42",ht="_cookieForm_10tvv_74",pt="_cookieInput_10tvv_83",gt="_link_10tvv_99",ft="_contentLayout_10tvv_109",yt="_mainCol_10tvv_116",bt="_upnextAside_10tvv_120",vt="_upnextHeader_10tvv_131",kt="_upnextTitle_10tvv_139",Nt="_upnextActions_10tvv_149",wt="_nowPlayingLabel_10tvv_156",St="_nowPlayingWrap_10tvv_168",Tt="_likeBtn_10tvv_172",xt="_likeActive_10tvv_196",p={authRow:ut,btn:dt,btnGhost:mt,cookieForm:ht,cookieInput:pt,link:gt,contentLayout:ft,mainCol:yt,upnextAside:bt,upnextHeader:vt,upnextTitle:kt,upnextActions:Nt,nowPlayingLabel:wt,nowPlayingWrap:St,likeBtn:Tt,likeActive:xt};function Fe(n){const l=n.trim();if(!l)return null;const f=l.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??l.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return f||(/^[A-Za-z0-9_-]{11}$/.test(l)?l:null)}const Lt="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",At=()=>{const[n,l]=je(),f=Fe(n.get("v")??""),[R,pe]=y(()=>n.get("q")??""),Q=n.get("q")??"";P(()=>{pe(Q)},[Q]);const[F,oe]=y(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[le,ee]=y(!1),[I,ce]=y(()=>localStorage.getItem("musicShuffle")==="true"),[S,te]=y(()=>localStorage.getItem("musicRadio")!=="false"),[m,b]=y(null),[z,$]=y([]),[A,ne]=y(null),[V,W]=y({}),k=M([]);k.current=z;const ae=M(null);ae.current=m;const q=M(!1),ie=M(new Set),{data:T}=et(),v=tt(),Y=nt(),E=typeof navigator<"u"?navigator.userAgent:"",D=/android/i.test(E),U=/firefox|fxios/i.test(E)&&!D,ge=!U&&!D&&/chrome|chromium|edg|brave/i.test(E),O=U||ge,se=()=>{if(le)return;ee(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,a=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",o),ee(!1),C.error("Helper not detected — install the Dango Helper extension first.")},3e3),o=u=>{let d;try{d=JSON.parse(u.detail)}catch{return}if(!(!d||d.requestId!==t))if(window.clearTimeout(a),window.removeEventListener("dango:ytmusic-cookie",o),ee(!1),d?.ok&&d.cookie){const c=d.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(c.includes("…")||c.includes("...")){C.error(`Helper returned a truncated cookie (${c.length} chars) — reload music.youtube.com and Extract again.`);return}oe(c),C.success("Cookie extracted from helper — signing in…"),v.mutate({cookie:c})}else d?.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.")};window.addEventListener("dango:ytmusic-cookie",o),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:fe,isLoading:ye}=at(Q),{data:H,isLoading:ue,isFetching:Z,error:we,refetch:Se}=it(T?.authenticated===!0),{data:de,isLoading:be}=rt(A?.id??null),{data:ve,isLoading:ke}=ot(m?.id??null),{data:Te}=lt(T?.authenticated===!0),r=ct(),s=G(()=>fe?.tracks||[],[fe]),_=G(()=>H?.playlists||[],[H]),N=G(()=>H?.tracks||[],[H]),j=G(()=>de?.tracks||[],[de]),x=G(()=>{const t=ve?.tracks||[];return m?t.filter(a=>a.id!==m.id):t},[ve,m]),qe=G(()=>new Set(Te?.likedIds||[]),[Te]),xe=t=>V[t.id]??(qe.has(t.id)||t.liked===!0);P(()=>{T?.authenticated!==!0&&W({})},[T?.authenticated]);const De=G(()=>[...s,...j,...N,...x],[s,j,N,x]),Ue=f&&m?.id!==f&&!De.some(t=>t.id===f)?f:null,{data:$e}=st(Ue),Le=m?.id;P(()=>{document.title=m?`${m.title} - dango`:"Music - dango"},[m]),P(()=>{if(!f){Le&&b(null);return}if(Le===f)return;const t=u=>{const d=u.find(c=>c.id===f);return d?(b(d),$(c=>c.some(re=>re.id===f)?c:u.length>0?u:[d]),!0):!1};if(t(s)||t(j)||t(N))return;const a=x.find(u=>u.id===f);if(a){b(a),$(u=>u.some(d=>d.id===a.id)?u:[a]);return}const o=$e?.track;o&&o.id===f&&(b(o),$(u=>u.some(d=>d.id===o.id)?u:[o]))},[f,Le,s,j,N,x,$e]);const J=t=>{l(a=>{const o=new URLSearchParams(a);return t?o.set("v",t):o.delete("v"),o})},Me=(t,a)=>{ie.current.delete(t.id),b(t),$(a.length>0?a:[t]),J(t.id)},He=t=>{ie.current.add(t.id),C.error(`Couldn't play “${t.title}” — skipped.`)},ze=async()=>{if(q.current)return;const t=k.current,a=t[t.length-1]??ae.current;if(a){q.current=!0;try{const o=await Pe.music.upnext.query({id:a.id}),u=new Set(t.map(c=>c.id)),d=(o.tracks||[]).filter(c=>!u.has(c.id)&&!ie.current.has(c.id));if(d.length===0){const c=k.current[0];c&&(b(c),J(c.id));return}$([...k.current,...d]),b(d[0]),J(d[0].id)}catch{const o=k.current[0];o&&(b(o),J(o.id))}finally{q.current=!1}}},Ye=t=>{const a=k.current,o=ae.current;if(!o||a.length===0)return;const u=a.findIndex(L=>L.id===o.id);if(t>0&&S&&(u<0||u===a.length-1)){ze();return}const d=L=>ie.current.has(L.id),c=a.length;let re;if(I&&c>1){let L=Math.floor(Math.random()*c);for(let _e=0;_e<c&&(L===u||d(a[L]));_e++)L=Math.floor(Math.random()*c);re=a[L]}else{const L=t>0?1:-1;let Ne=(((u<0?L>0?-1:0:u)+L)%c+c)%c;for(let Oe=1;Oe<c&&d(a[Ne]);Oe++)Ne=((Ne+L)%c+c)%c;re=a[Ne]}b(re),J(re.id)},Ge=()=>{if(S){te(!1),localStorage.setItem("musicRadio","false");return}const t=ae.current;if(!t)return;if(x.length===0){C.error("No radio suggestions for this song yet.");return}const a=new Set,o=[];for(const u of[t,...x])a.has(u.id)||(a.add(u.id),o.push(u));te(!0),localStorage.setItem("musicRadio","true"),$(o),C.success(`Radio started — ${x.length} songs queued.`)},Ae=t=>{if(T?.authenticated!==!0){C.error("Sign in to like songs.");return}const a=!xe(t);W(o=>({...o,[t.id]:a})),r.mutate({id:t.id,like:a},{onError:()=>{W(o=>{const u={...o};return delete u[t.id],u}),C.error("Like action failed — try again.")}})},Qe=()=>{ce(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Ve=t=>e("button",{className:h.stationRow,onClick:()=>ne(t),"aria-label":`Open ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),t.subtitle&&e("span",{className:h.stationSub,children:t.subtitle})]})]},t.id),me=(t,a,o)=>{const u=m?.id===t.id,d=xe(t),c=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${h.stationRow} ${u?h.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>o?o(t):Me(t,a),className:h.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[t.thumbnails?.[0]?.url?e("img",{src:t.thumbnails[0].url,alt:"",className:h.stationThumb,loading:"lazy",decoding:"async"}):e("span",{className:h.stationThumbPlaceholder,children:e(g,{name:"headphones"})}),e("span",{className:h.stationMeta,children:[e("span",{className:h.stationName,children:t.title}),e("span",{className:h.stationSub,children:[t.artists,c?` · ${c}`:""]})]})]}),T?.authenticated===!0&&e("button",{className:`${p.likeBtn} ${d?p.likeActive:""}`,onClick:()=>Ae(t),disabled:r.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(g,{name:"heart"})}),e("a",{href:`https://music.youtube.com/watch?v=${encodeURIComponent(t.id)}`,target:"_blank",rel:"noreferrer",title:"Open in YouTube Music","aria-label":`Open ${t.title} in YouTube Music`,style:{padding:8,color:"inherit",opacity:.7,flexShrink:0},children:e(g,{name:"external-link-alt"})})]},t.id)},Ee=G(()=>{if(!m)return x;const t=new Set,a=[];for(const o of[m,...x])t.has(o.id)||(t.add(o.id),a.push(o));return a},[m,x]),We=t=>{Me(t,Ee)};return e("div",{className:`${K.page} ${m?K.pageWithPlayer:""}`,children:[e("div",{className:K.header,children:[e("h1",{className:K.pageTitle,children:[e(g,{name:"headphones"})," Music"]}),e("form",{className:K.searchForm,onSubmit:t=>{t.preventDefault();const a=Fe(R);if(a)J(a);else{const o=R.trim();l(u=>{const d=new URLSearchParams(u);return o?d.set("q",o):d.delete("q"),d})}},children:[e("input",{className:K.searchInput,value:R,onChange:t=>pe(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:K.searchBtn,type:"submit","aria-label":"Search",children:e(g,{name:"search"})})]})]}),e("div",{className:p.authRow,children:[T?.authenticated?e(w,{children:[e("span",{className:i.statusMsg,children:["Signed in to YouTube Music",H&&` — ${H.tracks.length} songs, ${H.playlists.length} playlists`]}),e("button",{className:p.btnGhost,onClick:()=>Y.mutate(),disabled:Y.isPending,children:"Sign out"})]}):e(w,{children:[e("form",{onSubmit:t=>{t.preventDefault();const a=F.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(a){if(a.includes("…")||a.includes("...")){C.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}a!==F&&oe(a),v.mutate({cookie:a})}},className:p.cookieForm,children:[e("input",{className:p.cookieInput,value:F,onChange:t=>oe(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:p.btn,type:"submit",disabled:v.isPending||!F.trim(),children:v.isPending?"Checking…":"Sign in"}),O&&e("button",{className:p.btnGhost,type:"button",onClick:se,disabled:le||v.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:le?"Extracting…":"Extract from helper"})]}),O&&e("p",{className:i.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Lt,target:"_blank",rel:"noreferrer",className:p.link,children:"dango-extension.zip"})," ","then"," ",U?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(Xe,{})]}),v.isSuccess&&e("p",{className:i.statusMsg,children:["Signed in — found ",v.data.tracks," songs and ",v.data.playlists," ","playlists."]}),v.isError&&e("p",{className:i.statusMsg,children:v.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!T?.authenticated&&!v.isError&&!v.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:m?p.contentLayout:void 0,children:[e("div",{className:p.mainCol,children:Q?e(w,{children:[e("h2",{className:h.sectionTitle,children:["Results for “",Q,"”"]}),ye?e("p",{className:i.statusMsg,children:"Searching…"}):s.length===0?e("p",{className:i.statusMsg,children:"No tracks found."}):e("div",{className:h.stationList,children:s.map(t=>me(t,s))})]}):T?.authenticated?e(w,{children:[e("h2",{className:h.sectionTitle,children:"Your library"}),ue?e("p",{className:i.statusMsg,children:"Loading library…"}):_.length===0&&N.length===0&&!A?e(w,{children:[e("p",{className:i.statusMsg,children:we?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>{Se()},disabled:Z,"aria-label":"Retry loading library",children:Z?"Retrying…":"Retry"})}),e("p",{className:i.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(w,{children:[_.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:"Playlists"}),e("div",{className:h.stationList,children:_.map(t=>Ve(t))})]}),N.length>0&&!A&&e(w,{children:[e("h3",{className:h.sectionTitle,children:["Liked songs (",N.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:p.btnGhost,onClick:()=>Me(N[0],N),"aria-label":"Play all liked songs",children:[e(g,{name:"play"})," Play all"]})}),e("div",{className:h.stationList,children:N.map(t=>me(t,N))})]}),A?e(w,{children:[e("button",{className:p.btnGhost,onClick:()=>ne(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:h.sectionTitle,children:A.title}),be?e("p",{className:i.statusMsg,children:"Loading playlist…"}):j.length===0?e("p",{className:i.statusMsg,children:"No tracks in this playlist."}):e("div",{className:h.stationList,children:j.map(t=>me(t,j))})]}):null]})]}):e("p",{className:i.statusMsg,children:"Search above, or sign in to see your library."})}),m&&e("aside",{className:p.upnextAside,"aria-label":"Up next",children:[e("div",{className:p.upnextHeader,children:e("span",{className:p.upnextTitle,children:[e(g,{name:"list-ul"})," Up Next"]})}),e("div",{className:p.nowPlayingWrap,children:[e("p",{className:p.nowPlayingLabel,children:"Now playing"}),me(m,z.length>0?z:[m])]}),e("div",{className:p.upnextActions,children:e("button",{className:p.btnGhost,onClick:Ge,disabled:!S&&(ke||x.length===0),"aria-pressed":S,title:S?"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:S?"Stop radio":"Start radio"})}),ke?e("p",{className:i.statusMsg,children:"Loading suggestions…"}):x.length===0?e("p",{className:i.statusMsg,children:"No suggestions for this song."}):e("div",{className:h.stationList,children:x.map(t=>me(t,Ee,We))})]})]}),m&&e(Ke,{track:m,queue:z,shuffle:I,onToggleShuffle:Qe,onTrackStep:Ye,onTrackFailed:He,onClose:()=>{b(null),J(null)},liked:m?xe(m):!1,likeVisible:T?.authenticated===!0,likePending:r.isPending,onToggleLike:()=>Ae(m)})]})};export{At as default};
@@ -1 +1 @@
1
- import{u as e,S as s,d as y,h as g}from"./vendor-core-DfaOB3Rn.js";import{I as p}from"./vendor-icons-DrybRNxP.js";import{M as l,H as m,T as S,I as f,J as k,K as x,L as N}from"./AvSyncCalibrator-jI6WLW45.js";const C=({classes:o,title:t,titleTag:i="span",showBack:a=!0,onBack:n,panelRef:b,onPanelClick:r,children:c})=>{const d=i;return e("div",{ref:b,className:o.panel,onClick:r,"data-speed-boost-ignore":"true",children:[e("div",{className:o.header,children:[a&&e("button",{className:o.backBtn,onClick:n,children:e(p,{name:"chevron-left"})}),e(d,{className:o.title||void 0,children:t})]}),e("div",{className:o.content,children:c})]})},$=({classes:o,values:t,onChange:i})=>{const a=()=>{const n=x;i("fontSize",n.fontSize),i("position",n.position),i("bgOpacity",n.bgOpacity),i("bgColor",n.bgColor),i("textColor",n.textColor),i("edge",n.edge),i("bold",n.bold)};return e(s,{children:[e(l,{label:"Font Size",display:t.fontSize.toFixed(1),min:.5,max:10,step:.5,value:t.fontSize,percent:(t.fontSize-.5)/9.5*100,onChange:n=>{Number.isFinite(n)&&i("fontSize",n)}}),e(l,{label:"Vertical Position",display:`${t.position}`,min:0,max:100,step:1,value:t.position,percent:t.position,onChange:n=>{Number.isFinite(n)&&i("position",Math.round(n))}}),e(l,{label:"Background Opacity",display:`${Math.round(t.bgOpacity*100)}%`,min:0,max:1,step:.05,value:t.bgOpacity,percent:t.bgOpacity*100,onChange:n=>{Number.isFinite(n)&&i("bgOpacity",n)}}),e(m,{label:"Text Color",colors:S,value:t.textColor,onChange:n=>i("textColor",n)}),e(m,{label:"Background Color",colors:f,value:t.bgColor,onChange:n=>i("bgColor",n)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:t.edge,onChange:n=>i("edge",n)}),e("button",{type:"button",className:`${o.item} ${t.bold?o.active:""}`,onClick:()=>i("bold",!t.bold),children:[e("span",{children:"Bold Text"}),t.bold&&e(p,{name:"check",size:12})]}),e("button",{type:"button",className:o.item,onClick:a,children:e("span",{children:"Reset to Defaults"})})]})},z=({classes:o,enabled:t,delayMs:i,onToggle:a,onDelayChange:n,onCalibrate:b})=>{const[r,c]=y(null),d=r??i;g(()=>{c(null)},[i]);const h=()=>{r!==null&&(n(r),c(null))};return e(s,{children:[e("button",{type:"button",className:`${o.item} ${t?o.active:""}`,onClick:()=>a(!t),children:[e("span",{children:"Video delay"}),t&&e(p,{name:"check",size:12})]}),e(l,{label:"Video delay",display:`${d}ms`,min:0,max:500,step:5,value:d,percent:d/500*100,onChange:u=>c(Math.round(u)),onCommit:h}),e("div",{className:o.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),b&&e("button",{type:"button",className:o.item,onClick:b,children:e("span",{children:"Calibrate…"})})]})},E=({classes:o,values:t,onChange:i})=>e(s,{children:[e("button",{type:"button",className:`${o.item} ${t.enabled?o.active:""}`,onClick:()=>i({enabled:!t.enabled}),"aria-pressed":t.enabled,children:[e("span",{children:"Ambient light"}),e("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t.enabled?"On":"Off",t.enabled&&e(p,{name:"check",size:12})]})]}),e(l,{label:"Blur",display:`${t.blur}px`,min:0,max:120,step:2,value:t.blur,percent:t.blur/120*100,onChange:a=>i({blur:Math.round(a)})}),e(l,{label:"Saturation",display:`${t.saturation}%`,min:0,max:200,step:5,value:t.saturation,percent:t.saturation/200*100,onChange:a=>i({saturation:Math.round(a)})}),e(l,{label:"Brightness",display:`${t.brightness}%`,min:20,max:120,step:5,value:t.brightness,percent:(t.brightness-20)/100*100,onChange:a=>i({brightness:Math.round(a)})}),e(l,{label:"Opacity",display:`${t.opacity}%`,min:10,max:100,step:5,value:t.opacity,percent:(t.opacity-10)/90*100,onChange:a=>i({opacity:Math.round(a)})}),e("div",{className:o.note,children:"Mirrors the video onto the backdrop behind the player. Turn off for pure black."}),e("button",{type:"button",className:o.item,onClick:()=>i({...N}),children:e("span",{children:"Reset to defaults"})})]}),B=({classes:o,options:t,onSelect:i})=>e(s,{children:t.map(a=>e("button",{type:"button",className:`${o.item} ${a.selected?o.active:""}`,onClick:()=>i(a.key),children:[e("span",{children:a.label}),a.selected&&e(p,{name:"check",size:12})]},a.key))});export{z as A,B as O,C as S,$ as a,E as b};
1
+ import{u as e,S as s,d as y,h as g}from"./vendor-core-DfaOB3Rn.js";import{I as p}from"./vendor-icons-DrybRNxP.js";import{M as l,H as m,T as S,I as f,J as k,K as x,L as N}from"./AvSyncCalibrator-DH6KEsbi.js";const C=({classes:o,title:t,titleTag:i="span",showBack:a=!0,onBack:n,panelRef:b,onPanelClick:r,children:c})=>{const d=i;return e("div",{ref:b,className:o.panel,onClick:r,"data-speed-boost-ignore":"true",children:[e("div",{className:o.header,children:[a&&e("button",{className:o.backBtn,onClick:n,children:e(p,{name:"chevron-left"})}),e(d,{className:o.title||void 0,children:t})]}),e("div",{className:o.content,children:c})]})},$=({classes:o,values:t,onChange:i})=>{const a=()=>{const n=x;i("fontSize",n.fontSize),i("position",n.position),i("bgOpacity",n.bgOpacity),i("bgColor",n.bgColor),i("textColor",n.textColor),i("edge",n.edge),i("bold",n.bold)};return e(s,{children:[e(l,{label:"Font Size",display:t.fontSize.toFixed(1),min:.5,max:10,step:.5,value:t.fontSize,percent:(t.fontSize-.5)/9.5*100,onChange:n=>{Number.isFinite(n)&&i("fontSize",n)}}),e(l,{label:"Vertical Position",display:`${t.position}`,min:0,max:100,step:1,value:t.position,percent:t.position,onChange:n=>{Number.isFinite(n)&&i("position",Math.round(n))}}),e(l,{label:"Background Opacity",display:`${Math.round(t.bgOpacity*100)}%`,min:0,max:1,step:.05,value:t.bgOpacity,percent:t.bgOpacity*100,onChange:n=>{Number.isFinite(n)&&i("bgOpacity",n)}}),e(m,{label:"Text Color",colors:S,value:t.textColor,onChange:n=>i("textColor",n)}),e(m,{label:"Background Color",colors:f,value:t.bgColor,onChange:n=>i("bgColor",n)}),e(k,{label:"Text Edge",options:["shadow","outline","none"],value:t.edge,onChange:n=>i("edge",n)}),e("button",{type:"button",className:`${o.item} ${t.bold?o.active:""}`,onClick:()=>i("bold",!t.bold),children:[e("span",{children:"Bold Text"}),t.bold&&e(p,{name:"check",size:12})]}),e("button",{type:"button",className:o.item,onClick:a,children:e("span",{children:"Reset to Defaults"})})]})},z=({classes:o,enabled:t,delayMs:i,onToggle:a,onDelayChange:n,onCalibrate:b})=>{const[r,c]=y(null),d=r??i;g(()=>{c(null)},[i]);const h=()=>{r!==null&&(n(r),c(null))};return e(s,{children:[e("button",{type:"button",className:`${o.item} ${t?o.active:""}`,onClick:()=>a(!t),children:[e("span",{children:"Video delay"}),t&&e(p,{name:"check",size:12})]}),e(l,{label:"Video delay",display:`${d}ms`,min:0,max:500,step:5,value:d,percent:d/500*100,onChange:u=>c(Math.round(u)),onCommit:h}),e("div",{className:o.note,children:"For Bluetooth headsets where audio arrives late. Video is held back via canvas; audio plays untouched."}),b&&e("button",{type:"button",className:o.item,onClick:b,children:e("span",{children:"Calibrate…"})})]})},E=({classes:o,values:t,onChange:i})=>e(s,{children:[e("button",{type:"button",className:`${o.item} ${t.enabled?o.active:""}`,onClick:()=>i({enabled:!t.enabled}),"aria-pressed":t.enabled,children:[e("span",{children:"Ambient light"}),e("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t.enabled?"On":"Off",t.enabled&&e(p,{name:"check",size:12})]})]}),e(l,{label:"Blur",display:`${t.blur}px`,min:0,max:120,step:2,value:t.blur,percent:t.blur/120*100,onChange:a=>i({blur:Math.round(a)})}),e(l,{label:"Saturation",display:`${t.saturation}%`,min:0,max:200,step:5,value:t.saturation,percent:t.saturation/200*100,onChange:a=>i({saturation:Math.round(a)})}),e(l,{label:"Brightness",display:`${t.brightness}%`,min:20,max:120,step:5,value:t.brightness,percent:(t.brightness-20)/100*100,onChange:a=>i({brightness:Math.round(a)})}),e(l,{label:"Opacity",display:`${t.opacity}%`,min:10,max:100,step:5,value:t.opacity,percent:(t.opacity-10)/90*100,onChange:a=>i({opacity:Math.round(a)})}),e("div",{className:o.note,children:"Mirrors the video onto the backdrop behind the player. Turn off for pure black."}),e("button",{type:"button",className:o.item,onClick:()=>i({...N}),children:e("span",{children:"Reset to defaults"})})]}),B=({classes:o,options:t,onSelect:i})=>e(s,{children:t.map(a=>e("button",{type:"button",className:`${o.item} ${a.selected?o.active:""}`,onClick:()=>i(a.key),children:[e("span",{children:a.label}),a.selected&&e(p,{name:"check",size:12})]},a.key))});export{z as A,B as O,C as S,$ as a,E as b};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-g4xFrRiD.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-B3xlVT-D.js","assets/AvSyncCalibrator-jI6WLW45.js","assets/index-Dyiy_9L6.js","assets/vendor-query-BBT5_sHx.js","assets/index-Cc1Up_NI.css","assets/AvSyncCalibrator-gEONBv5a.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
2
- import{u as r,g as Ot,h as B,P as Br,z as Lr,d as ue,A as f,q as H,y as Ir,T as Je,o as Dr,a as $r,c as Fr,_ as Wr,S as Mt}from"./vendor-core-DfaOB3Rn.js";import{_ as mr,S as _t,h as Or,t as Ee,z as We,P as Ur,e as Vr,l as qr,m as Qr,n as zr,o as Gr,d as Hr,u as Kr,M as $e,B as it,Q as jr,f as Yr}from"./index-Dyiy_9L6.js";import{u as fr,b as lr,a as jt}from"./vendor-query-BBT5_sHx.js";import{S as Xr,U as Jr,p as Yt,s as Zr,C as en,a as tn,b as rn,l as nn,u as sn,c as on,d as an,e as ln,i as cn,f as cr,g as un,h as dn,j as ur,k as dr,m as pn,n as mn,o as fn,r as hn,q as Fe,A as vn,R as bn,E as gn,t as yn,v as p,w as Sn,x as En,P as wn,y as Tn,z as kn}from"./AvSyncCalibrator-jI6WLW45.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Cn}from"./hls-DpOQmcQm.js";import{u as Rn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as Mn}from"./QueueRail-wmxRrTaD.js";import{u as _n,Q as Nn}from"./QueueOptionsButton-B3cSHa0L.js";import{u as hr}from"./useProviders-DIy3z1fe.js";import{A as Pn}from"./AnimeMetaDetails-BogOi_bM.js";import{S as xn}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const An={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Bn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Ln=["direct","cookie","embed"],In="_controlsOverlay_1b7ea_1",Dn="_hidden_1b7ea_21",$n="_topControls_1b7ea_27",Fn="_backBtn_1b7ea_47",Wn="_videoTitleInfo_1b7ea_67",On="_animeTitle_1b7ea_73",Un="_episodeNumber_1b7ea_81",Vn="_bottomControls_1b7ea_89",qn="_progressBarContainer_1b7ea_108",Qn="_progressBar_1b7ea_108",zn="_thumb_1b7ea_127",Gn="_scrubbing_1b7ea_142",Hn="_watchedBar_1b7ea_146",Kn="_bufferedBar_1b7ea_147",jn="_timeBubble_1b7ea_185",Yn="_skipSegment_1b7ea_219",Xn="_op_1b7ea_229",Jn="_ed_1b7ea_232",Zn="_recap_1b7ea_235",es="_bottomControlsRow_1b7ea_239",ts="_leftControls_1b7ea_247",rs="_rightControls_1b7ea_248",ns="_controlBtn_1b7ea_255",ss="_theaterBtn_1b7ea_296",os="_nextEpisodeBtn_1b7ea_300",is="_active_1b7ea_317",as="_timeDisplay_1b7ea_321",ls="_skipControls_1b7ea_329",cs="_skipBtn_1b7ea_335",us="_volumeContainer_1b7ea_376",ds="_volumeSlider_1b7ea_382",ps="_playerPageLayout_1b7ea_440",ms="_videoPlayerWrapper_1b7ea_444",fs="_playerInfoContainer_1b7ea_449",hs="_visible_1b7ea_566",vs="_shortcuts_1b7ea_584",C={controlsOverlay:In,hidden:Dn,topControls:$n,backBtn:Fn,videoTitleInfo:Wn,animeTitle:On,episodeNumber:Un,bottomControls:Vn,progressBarContainer:qn,progressBar:Qn,thumb:zn,scrubbing:Gn,watchedBar:Hn,bufferedBar:Kn,timeBubble:jn,skipSegment:Yn,op:Xn,ed:Jn,recap:Zn,bottomControlsRow:es,leftControls:ts,rightControls:rs,controlBtn:ns,theaterBtn:ss,nextEpisodeBtn:os,active:is,timeDisplay:as,skipControls:ls,skipBtn:cs,volumeContainer:us,volumeSlider:ds,playerPageLayout:ps,videoPlayerWrapper:ms,playerInfoContainer:fs,visible:hs,shortcuts:vs},bs=({player:n,handlers:l,visible:m,skipIntervals:D,showNextEpisodeButton:h,onNextEpisode:S,isTheaterMode:g,onTheaterModeToggle:A,settingsBtnRef:P,timeDisplayRef:$})=>{const{state:T,refs:e,actions:o}=n,{showSettings:J}=T,b=()=>T.isMuted||T.volume===0?r(Z,{name:"volume-mute"}):T.volume<.5?r(Z,{name:"volume-down"}):r(Z,{name:"volume-up"});return r("div",{className:`${C.controlsOverlay} ${m?"":C.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:C.bottomControls,"data-speed-boost-ignore":"true",onClick:x=>x.stopPropagation(),children:[r(Xr,{classes:{container:C.progressBarContainer,scrubbing:C.scrubbing,timeBubble:C.timeBubble,bar:C.progressBar,buffered:C.bufferedBar,watched:C.watchedBar,thumb:C.thumb},videoRef:e.videoRef,duration:T.duration,formatTime:o.formatTime,isScrubbing:T.isScrubbing,onSeek:l.handleSeek,onScrubStart:l.handleScrubStart,onScrubMove:l.handleScrubMove,onScrubEnd:l.handleScrubEnd,timeLabelRef:$,children:[T.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${C.skipSegment} ${C[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/T.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/T.duration*100}% `}}),D.map(x=>{const de=x.start_time/T.duration*100,U=(x.end_time-x.start_time)/T.duration*100;return r("div",{className:`${C.skipSegment} ${C[x.skip_type]} `,style:{left:`${de}% `,width:`${U}% `},title:x.skip_type.toUpperCase()},x.skip_id)})]}),r("div",{className:C.bottomControlsRow,children:[r("div",{className:C.leftControls,children:[r("button",{className:C.controlBtn,onClick:o.togglePlay,"aria-label":T.isPlaying?"Pause":"Play",children:T.isPlaying?r(Z,{name:"pause"}):r(Z,{name:"play"})}),r(Jr,{muted:T.isMuted,volume:T.volume,volumeIcon:b(),buttonClassName:C.controlBtn,onToggleMute:o.toggleMute,onVolumeChange:l.handleVolumeChange,onExpandedChange:x=>o.setShowVolumeSlider(x)}),r("span",{className:C.timeDisplay,ref:$,children:[o.formatTime(0)," / ",o.formatTime(T.duration)]}),T.currentSkipInterval&&!T.isAutoSkipEnabled&&r("button",{className:C.controlBtn,onClick:()=>{e.videoRef.current&&T.currentSkipInterval&&(e.videoRef.current.currentTime=T.currentSkipInterval.end_time,o.setCurrentSkipInterval(null))},children:["Skip ",T.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:C.rightControls,children:[r("div",{className:C.skipControls,children:h&&r("button",{className:C.nextEpisodeBtn,onClick:S,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${C.controlBtn} ${l.isSubtitleActive?C.active:""}`,onClick:l.handleCCToggle,title:l.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(Z,{name:"closed-captioning",size:22})}),r("button",{ref:P,className:`${C.controlBtn} ${J?C.active:""} `,onClick:()=>o.setShowSettings(!J),"aria-label":"Settings",children:r(Z,{name:"cog"})}),r("button",{className:`${C.controlBtn} ${C.theaterBtn} ${g?C.active:""} `,onClick:x=>{x.stopPropagation(),A()},title:g?"Exit Theater Mode":"Theater Mode","aria-label":g?"Exit Theater Mode":"Theater Mode",children:r(Z,{name:"tv"})}),r("button",{className:C.controlBtn,onClick:o.toggleFullscreen,"aria-label":T.isFullscreen?"Exit Fullscreen":"Fullscreen",children:T.isFullscreen?r(Z,{name:"compress"}):r(Z,{name:"expand"})})]})]})]})})};function gs(n){const{state:l,refs:m,actions:D}=n,h=o=>{m.videoRef.current&&(m.videoRef.current.volume=o,m.videoRef.current.muted=o===0)},S=o=>{!m.videoRef.current||isNaN(l.duration)||l.duration===0||(m.videoRef.current.currentTime=o*l.duration,D.sendProgressUpdate(!1,!0))},g=()=>{m.videoRef.current&&(D.setIsScrubbing(!0),D.wasPlayingBeforeScrub.current=!m.videoRef.current.paused,m.videoRef.current.pause())},A=o=>{!m.videoRef.current||!l.duration||(m.videoRef.current.currentTime=o*l.duration)},P=()=>{D.setIsScrubbing(!1),D.wasPlayingBeforeScrub.current&&m.videoRef.current?.play()},$=o=>{if(!m.videoRef.current)return;D.setActiveSubtitleTrack(o);try{if(o===null||o==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const b=l.availableSubtitles.find(x=>x.label===o||x.lang===o);b?localStorage.setItem("playerLastSubtitle",Zr(b)):localStorage.setItem("playerLastSubtitle",o)}}catch{}let J=!1;Array.from(m.videoRef.current.textTracks).forEach(b=>{const de=o!==null&&o!=="off"&&(b.language===o||b.label===o)&&!J;b.mode=de?"showing":"hidden",de&&(J=!0)})},T=l.activeSubtitleTrack!==null&&l.activeSubtitleTrack!=="off";return{handleVolumeChange:h,handleSeek:S,handleScrubStart:g,handleScrubMove:A,handleScrubEnd:P,handleSubtitleSelection:$,isSubtitleActive:T,handleCCToggle:()=>{if(!m.videoRef.current)return;if(T){$("off");return}if(l.availableSubtitles.length===0)return;let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const J=Yt(l.availableSubtitles,{lastKey:o,enabled:!0});if(J<0)return;const b=l.availableSubtitles[J];$(b.label||b.lang)}}}const ys=Lr(()=>mr(()=>import("./PlayerSettings-g4xFrRiD.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Ss=({player:n,isAutoplayEnabled:l,onAutoplayChange:m,showNextEpisodeButton:D,onNextEpisode:h,videoSources:S,selectedSource:g,selectedLink:A,onSourceChange:P,loadingVideo:$,skipIntervals:T,animeTitle:e,episodeNumber:o,isTheaterMode:J,onTheaterModeToggle:b,anime4kEnabled:x,onAnime4kToggle:de,anime4kSupported:U,anime4kProfile:L,onAnime4kProfileChange:V,anime4kInitializing:Ae,anime4kError:Oe,videoDelayEnabled:i,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Be,fallbackChoice:_e,onFallbackChoiceChange:Ne,ambientSettings:Ue,onAmbientChange:oe,children:we,overlays:c,isInteractingExtra:y=!1,className:v,hideChrome:I=!1})=>{const{state:R,actions:q}=n,{showSettings:ye}=R,{setShowSettings:Y}=q,G=gs(n),Te=Ot.useRef(null),Le=Ot.useRef(null),yt=Ot.useRef(null);B(()=>{const F=W=>{Te.current&&!Te.current.contains(W.target)&&Le.current&&!Le.current.contains(W.target)&&ye&&Y(!1)};return ye&&document.addEventListener("mousedown",F),()=>{document.removeEventListener("mousedown",F)}},[ye,Y]);const Ze=R.showControls||ye||R.isScrubbing,St=r(rn,{visible:Ze,title:e,episode:o?`Episode ${o}`:void 0,onBack:()=>window.history.back(),classes:{overlay:C.controlsOverlay,hidden:C.hidden,top:C.topControls,backBtn:C.backBtn,titleInfo:C.videoTitleInfo,title:C.animeTitle,episode:C.episodeNumber}}),K=!$&&!R.isBuffering&&R.duration>0?r(en,{isPlaying:R.isPlaying,onTogglePlay:q.togglePlay,onSkipBack:()=>q.seek(-10),onSkipForward:()=>q.seek(10)}):null,Pe=r(bs,{player:n,handlers:G,visible:Ze,skipIntervals:T,showNextEpisodeButton:D,onNextEpisode:h,isTheaterMode:J,onTheaterModeToggle:b,settingsBtnRef:Le,timeDisplayRef:yt}),lt=r(Br,{fallback:null,children:r(ys,{ref:Te,isOpen:ye,onClose:()=>Y(!1),videoSources:S,currentSource:g,currentLink:A,onSourceChange:P,subtitles:R.availableSubtitles,activeSubtitleTrack:R.activeSubtitleTrack,onSubtitleChange:G.handleSubtitleSelection,subtitleSettings:{fontSize:R.subtitleFontSize,position:R.subtitlePosition,bgOpacity:R.subtitleBgOpacity,bgColor:R.subtitleBgColor,textColor:R.subtitleTextColor,edge:R.subtitleEdge,bold:R.subtitleBold},onSubtitleSettingsChange:(F,W)=>{const ke=(Ve,Ge)=>{try{localStorage.setItem(Ve,String(Ge))}catch{}};switch(F){case"fontSize":q.setSubtitleFontSize(W),ke("subtitleFontSize",W);break;case"position":q.setSubtitlePosition(W),ke("subtitlePosition",W);break;case"bgOpacity":q.setSubtitleBgOpacity(W),ke("subtitleBgOpacity",W);break;case"bgColor":q.setSubtitleBgColor(W),ke("subtitleBgColor",W);break;case"textColor":q.setSubtitleTextColor(W),ke("subtitleTextColor",W);break;case"edge":q.setSubtitleEdge(W),ke("subtitleEdge",W);break;case"bold":q.setSubtitleBold(W),ke("subtitleBold",W);break}},useNativeControls:R.useNativeControls,onNativeControlsToggle:q.setUseNativeControls,anime4kEnabled:x,onAnime4kToggle:de,anime4kSupported:U,anime4kProfile:L,onAnime4kProfileChange:V,anime4kInitializing:Ae,anime4kError:Oe,videoDelayEnabled:i,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Be,isAutoSkipEnabled:R.isAutoSkipEnabled,onAutoSkipChange:F=>{q.setIsAutoSkipEnabled(F);try{localStorage.setItem("autoSkipEnabled",F.toString())}catch{}},isAutoplayEnabled:l,onAutoplayChange:m,fallbackChoice:_e,onFallbackChoiceChange:Ne,isTheaterMode:J,ambientSettings:Ue,onAmbientChange:oe})}),_=ye?r("div",{"data-speed-boost-ignore":"true",onClick:F=>F.stopPropagation(),children:lt}):null;return r(tn,{player:n,topBar:St,centerControls:K,bottomBar:!$&&R.duration>0?Pe:null,settingsPanel:_,overlays:c,isInteracting:y,className:v,chromeDisabled:I,children:we})},Es=({count:n=3})=>r("section",{className:ze.section,children:[r("div",{className:ze.header,children:r("button",{className:ze.headerToggle,disabled:!0,children:[r("span",{className:ze.title,children:r(_t,{width:"60px",height:"1.2rem",variant:"text"})}),r(Z,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:ze.list,children:Array.from({length:n}).map((l,m)=>r("div",{className:ze.item,style:{pointerEvents:"none"},children:[r("div",{className:ze.dragHandle,style:{opacity:.2},children:r(_t,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:ze.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(_t,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:ze.meta,children:[r(_t,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(_t,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},m))})]}),ws="_sourceSelectionContainer_c5tub_76",Ts="_providerSelectContainer_c5tub_89",ks="_providerSelect_c5tub_89",Cs="_sourceSelect_c5tub_76",Rs="_sourceButtons_c5tub_145",Ms="_sourceButton_c5tub_145",_s="_active_c5tub_170",at={sourceSelectionContainer:ws,providerSelectContainer:Ts,providerSelect:ks,sourceSelect:Cs,sourceButtons:Rs,sourceButton:Ms,active:_s},Ns=({selectedProvider:n,onProviderChange:l,isAdult:m,options:D})=>{const h=D&&D.length>0?D:[],S=m===void 0?h:h.filter(g=>g.mature===m);return r("div",{className:at.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:at.providerSelect,value:n,onChange:g=>l(g.target.value),children:Ln.map(g=>{const A=S.filter(P=>(P.tier??"direct")===g);return A.length===0?null:r("optgroup",{label:Bn[g],children:A.map(P=>r("option",{value:P.value,children:P.sub?`${P.label} (${An[P.sub]})`:P.label},P.value))},g)})})]})},Ps=({videoSources:n,selectedSource:l,selectedLink:m,onSourceChange:D,onLinkChange:h})=>{const S=Array.isArray(n)?n:[];if(S.length===0)return null;const g=l?.type==="iframe"&&(l.links?.length??0)>1;return r("div",{className:at.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:at.sourceButtons,children:S.map((A,P)=>r("button",{className:`${at.sourceButton} ${l?.sourceName===A.sourceName?at.active:""} `,onClick:()=>D(A),children:A.sourceName},`${A.sourceName}-${P}`))}),g&&r("select",{className:at.sourceSelect,"aria-label":"Fallback embed quality",value:m?.link??l.links[0]?.link??"",onChange:A=>{const P=l.links.find($=>$.link===A.target.value);P&&h(P)},children:l.links.map(A=>r("option",{value:A.link,children:A.resolutionStr},A.link))})]})},xs=Ot.memo(Ps,(n,l)=>n.selectedSource?.sourceName===l.selectedSource?.sourceName&&n.selectedLink?.link===l.selectedLink?.link&&n.videoSources===l.videoSources),As={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},Bs={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Ls=5,Is=15e3,Ds=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PlayerSettings-B8CsR3hI.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-AHGTsUIM.js","assets/AvSyncCalibrator-DH6KEsbi.js","assets/index-BGCpLf49.js","assets/vendor-query-BBT5_sHx.js","assets/index-w_r2lTCe.css","assets/AvSyncCalibrator-gEONBv5a.css","assets/PlayerSettings-Bj6SsmQ2.css"])))=>i.map(i=>d[i]);
2
+ import{u as r,g as Ot,h as B,P as Br,z as Lr,d as ue,A as f,q as K,y as Ir,T as Je,o as Dr,a as $r,c as Fr,_ as Wr,S as Mt}from"./vendor-core-DfaOB3Rn.js";import{_ as mr,S as _t,h as Or,t as Ee,z as We,J as Ur,e as Vr,l as qr,m as Qr,n as zr,o as Gr,d as Kr,u as Hr,M as $e,B as it,K as jr,f as Yr}from"./index-BGCpLf49.js";import{u as fr,b as lr,a as jt}from"./vendor-query-BBT5_sHx.js";import{S as Xr,U as Jr,p as Yt,s as Zr,C as en,a as tn,b as rn,l as nn,u as sn,c as on,d as an,e as ln,i as cn,f as cr,g as un,h as dn,j as ur,k as dr,m as pn,n as mn,o as fn,r as hn,q as Fe,A as vn,R as bn,E as gn,t as yn,v as p,w as Sn,x as En,P as wn,y as Tn,z as kn}from"./AvSyncCalibrator-DH6KEsbi.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Cn}from"./hls-D3SWhYIU.js";import{u as Rn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as Mn}from"./QueueRail-CvrVAD_w.js";import{u as _n,Q as Nn}from"./QueueOptionsButton-tpZ79_8s.js";import{u as hr}from"./useProviders-mkl-w-e4.js";import{A as xn}from"./AnimeMetaDetails-BogOi_bM.js";import{S as Pn}from"./SynopsisText-B3Sa5pRv.js";import"./vendor-ui-3qrARCPr.js";const An={soft:"Softsub",hard:"Hardsub",mixed:"Mixed"},Bn={direct:"Direct",embed:"Embed",cookie:"Needs cookie"},Ln=["direct","cookie","embed"],In="_controlsOverlay_1b7ea_1",Dn="_hidden_1b7ea_21",$n="_topControls_1b7ea_27",Fn="_backBtn_1b7ea_47",Wn="_videoTitleInfo_1b7ea_67",On="_animeTitle_1b7ea_73",Un="_episodeNumber_1b7ea_81",Vn="_bottomControls_1b7ea_89",qn="_progressBarContainer_1b7ea_108",Qn="_progressBar_1b7ea_108",zn="_thumb_1b7ea_127",Gn="_scrubbing_1b7ea_142",Kn="_watchedBar_1b7ea_146",Hn="_bufferedBar_1b7ea_147",jn="_timeBubble_1b7ea_185",Yn="_skipSegment_1b7ea_219",Xn="_op_1b7ea_229",Jn="_ed_1b7ea_232",Zn="_recap_1b7ea_235",es="_bottomControlsRow_1b7ea_239",ts="_leftControls_1b7ea_247",rs="_rightControls_1b7ea_248",ns="_controlBtn_1b7ea_255",ss="_theaterBtn_1b7ea_296",os="_nextEpisodeBtn_1b7ea_300",is="_active_1b7ea_317",as="_timeDisplay_1b7ea_321",ls="_skipControls_1b7ea_329",cs="_skipBtn_1b7ea_335",us="_volumeContainer_1b7ea_376",ds="_volumeSlider_1b7ea_382",ps="_playerPageLayout_1b7ea_440",ms="_videoPlayerWrapper_1b7ea_444",fs="_playerInfoContainer_1b7ea_449",hs="_visible_1b7ea_566",vs="_shortcuts_1b7ea_584",C={controlsOverlay:In,hidden:Dn,topControls:$n,backBtn:Fn,videoTitleInfo:Wn,animeTitle:On,episodeNumber:Un,bottomControls:Vn,progressBarContainer:qn,progressBar:Qn,thumb:zn,scrubbing:Gn,watchedBar:Kn,bufferedBar:Hn,timeBubble:jn,skipSegment:Yn,op:Xn,ed:Jn,recap:Zn,bottomControlsRow:es,leftControls:ts,rightControls:rs,controlBtn:ns,theaterBtn:ss,nextEpisodeBtn:os,active:is,timeDisplay:as,skipControls:ls,skipBtn:cs,volumeContainer:us,volumeSlider:ds,playerPageLayout:ps,videoPlayerWrapper:ms,playerInfoContainer:fs,visible:hs,shortcuts:vs},bs=({player:n,handlers:l,visible:m,skipIntervals:D,showNextEpisodeButton:h,onNextEpisode:S,isTheaterMode:g,onTheaterModeToggle:A,settingsBtnRef:x,timeDisplayRef:$})=>{const{state:T,refs:e,actions:o}=n,{showSettings:J}=T,b=()=>T.isMuted||T.volume===0?r(Z,{name:"volume-mute"}):T.volume<.5?r(Z,{name:"volume-down"}):r(Z,{name:"volume-up"});return r("div",{className:`${C.controlsOverlay} ${m?"":C.hidden} `,"data-speed-boost-ignore":"true",style:{pointerEvents:"none",background:"none",justifyContent:"flex-end"},children:r("div",{className:C.bottomControls,"data-speed-boost-ignore":"true",onClick:P=>P.stopPropagation(),children:[r(Xr,{classes:{container:C.progressBarContainer,scrubbing:C.scrubbing,timeBubble:C.timeBubble,bar:C.progressBar,buffered:C.bufferedBar,watched:C.watchedBar,thumb:C.thumb},videoRef:e.videoRef,duration:T.duration,formatTime:o.formatTime,isScrubbing:T.isScrubbing,onSeek:l.handleSeek,onScrubStart:l.handleScrubStart,onScrubMove:l.handleScrubMove,onScrubEnd:l.handleScrubEnd,timeLabelRef:$,children:[T.duration>0&&n.state.currentSkipInterval&&r("div",{className:`${C.skipSegment} ${C[n.state.currentSkipInterval.skip_type]} `,style:{left:`${n.state.currentSkipInterval.start_time/T.duration*100}% `,width:`${(n.state.currentSkipInterval.end_time-n.state.currentSkipInterval.start_time)/T.duration*100}% `}}),D.map(P=>{const de=P.start_time/T.duration*100,U=(P.end_time-P.start_time)/T.duration*100;return r("div",{className:`${C.skipSegment} ${C[P.skip_type]} `,style:{left:`${de}% `,width:`${U}% `},title:P.skip_type.toUpperCase()},P.skip_id)})]}),r("div",{className:C.bottomControlsRow,children:[r("div",{className:C.leftControls,children:[r("button",{className:C.controlBtn,onClick:o.togglePlay,"aria-label":T.isPlaying?"Pause":"Play",children:T.isPlaying?r(Z,{name:"pause"}):r(Z,{name:"play"})}),r(Jr,{muted:T.isMuted,volume:T.volume,volumeIcon:b(),buttonClassName:C.controlBtn,onToggleMute:o.toggleMute,onVolumeChange:l.handleVolumeChange,onExpandedChange:P=>o.setShowVolumeSlider(P)}),r("span",{className:C.timeDisplay,ref:$,children:[o.formatTime(0)," / ",o.formatTime(T.duration)]}),T.currentSkipInterval&&!T.isAutoSkipEnabled&&r("button",{className:C.controlBtn,onClick:()=>{e.videoRef.current&&T.currentSkipInterval&&(e.videoRef.current.currentTime=T.currentSkipInterval.end_time,o.setCurrentSkipInterval(null))},children:["Skip ",T.currentSkipInterval.skip_type==="op"?"Opening":"Ending"]})]}),r("div",{className:C.rightControls,children:[r("div",{className:C.skipControls,children:h&&r("button",{className:C.nextEpisodeBtn,onClick:S,title:"Play next episode",children:"Next EP"})}),r("button",{className:`${C.controlBtn} ${l.isSubtitleActive?C.active:""}`,onClick:l.handleCCToggle,title:l.isSubtitleActive?"Disable Subtitles":"Enable Subtitles","aria-label":"Toggle Subtitles",children:r(Z,{name:"closed-captioning",size:22})}),r("button",{ref:x,className:`${C.controlBtn} ${J?C.active:""} `,onClick:()=>o.setShowSettings(!J),"aria-label":"Settings",children:r(Z,{name:"cog"})}),r("button",{className:`${C.controlBtn} ${C.theaterBtn} ${g?C.active:""} `,onClick:P=>{P.stopPropagation(),A()},title:g?"Exit Theater Mode":"Theater Mode","aria-label":g?"Exit Theater Mode":"Theater Mode",children:r(Z,{name:"tv"})}),r("button",{className:C.controlBtn,onClick:o.toggleFullscreen,"aria-label":T.isFullscreen?"Exit Fullscreen":"Fullscreen",children:T.isFullscreen?r(Z,{name:"compress"}):r(Z,{name:"expand"})})]})]})]})})};function gs(n){const{state:l,refs:m,actions:D}=n,h=o=>{m.videoRef.current&&(m.videoRef.current.volume=o,m.videoRef.current.muted=o===0)},S=o=>{!m.videoRef.current||isNaN(l.duration)||l.duration===0||(m.videoRef.current.currentTime=o*l.duration,D.sendProgressUpdate(!1,!0))},g=()=>{m.videoRef.current&&(D.setIsScrubbing(!0),D.wasPlayingBeforeScrub.current=!m.videoRef.current.paused,m.videoRef.current.pause())},A=o=>{!m.videoRef.current||!l.duration||(m.videoRef.current.currentTime=o*l.duration)},x=()=>{D.setIsScrubbing(!1),D.wasPlayingBeforeScrub.current&&m.videoRef.current?.play()},$=o=>{if(!m.videoRef.current)return;D.setActiveSubtitleTrack(o);try{if(o===null||o==="off")localStorage.setItem("playerSubtitlesEnabled","false");else{localStorage.setItem("playerSubtitlesEnabled","true");const b=l.availableSubtitles.find(P=>P.label===o||P.lang===o);b?localStorage.setItem("playerLastSubtitle",Zr(b)):localStorage.setItem("playerLastSubtitle",o)}}catch{}let J=!1;Array.from(m.videoRef.current.textTracks).forEach(b=>{const de=o!==null&&o!=="off"&&(b.language===o||b.label===o)&&!J;b.mode=de?"showing":"hidden",de&&(J=!0)})},T=l.activeSubtitleTrack!==null&&l.activeSubtitleTrack!=="off";return{handleVolumeChange:h,handleSeek:S,handleScrubStart:g,handleScrubMove:A,handleScrubEnd:x,handleSubtitleSelection:$,isSubtitleActive:T,handleCCToggle:()=>{if(!m.videoRef.current)return;if(T){$("off");return}if(l.availableSubtitles.length===0)return;let o=null;try{o=localStorage.getItem("playerLastSubtitle")}catch{}const J=Yt(l.availableSubtitles,{lastKey:o,enabled:!0});if(J<0)return;const b=l.availableSubtitles[J];$(b.label||b.lang)}}}const ys=Lr(()=>mr(()=>import("./PlayerSettings-B8CsR3hI.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Ss=({player:n,isAutoplayEnabled:l,onAutoplayChange:m,showNextEpisodeButton:D,onNextEpisode:h,videoSources:S,selectedSource:g,selectedLink:A,onSourceChange:x,loadingVideo:$,skipIntervals:T,animeTitle:e,episodeNumber:o,isTheaterMode:J,onTheaterModeToggle:b,anime4kEnabled:P,onAnime4kToggle:de,anime4kSupported:U,anime4kProfile:L,onAnime4kProfileChange:V,anime4kInitializing:Ae,anime4kError:Oe,videoDelayEnabled:i,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Be,fallbackChoice:_e,onFallbackChoiceChange:Ne,ambientSettings:Ue,onAmbientChange:oe,children:we,overlays:c,isInteractingExtra:y=!1,className:v,hideChrome:I=!1})=>{const{state:R,actions:q}=n,{showSettings:ye}=R,{setShowSettings:Y}=q,G=gs(n),Te=Ot.useRef(null),Le=Ot.useRef(null),yt=Ot.useRef(null);B(()=>{const F=W=>{Te.current&&!Te.current.contains(W.target)&&Le.current&&!Le.current.contains(W.target)&&ye&&Y(!1)};return ye&&document.addEventListener("mousedown",F),()=>{document.removeEventListener("mousedown",F)}},[ye,Y]);const Ze=R.showControls||ye||R.isScrubbing,St=r(rn,{visible:Ze,title:e,episode:o?`Episode ${o}`:void 0,onBack:()=>window.history.back(),classes:{overlay:C.controlsOverlay,hidden:C.hidden,top:C.topControls,backBtn:C.backBtn,titleInfo:C.videoTitleInfo,title:C.animeTitle,episode:C.episodeNumber}}),H=!$&&!R.isBuffering&&R.duration>0?r(en,{isPlaying:R.isPlaying,onTogglePlay:q.togglePlay,onSkipBack:()=>q.seek(-10),onSkipForward:()=>q.seek(10)}):null,xe=r(bs,{player:n,handlers:G,visible:Ze,skipIntervals:T,showNextEpisodeButton:D,onNextEpisode:h,isTheaterMode:J,onTheaterModeToggle:b,settingsBtnRef:Le,timeDisplayRef:yt}),lt=r(Br,{fallback:null,children:r(ys,{ref:Te,isOpen:ye,onClose:()=>Y(!1),videoSources:S,currentSource:g,currentLink:A,onSourceChange:x,subtitles:R.availableSubtitles,activeSubtitleTrack:R.activeSubtitleTrack,onSubtitleChange:G.handleSubtitleSelection,subtitleSettings:{fontSize:R.subtitleFontSize,position:R.subtitlePosition,bgOpacity:R.subtitleBgOpacity,bgColor:R.subtitleBgColor,textColor:R.subtitleTextColor,edge:R.subtitleEdge,bold:R.subtitleBold},onSubtitleSettingsChange:(F,W)=>{const ke=(Ve,Ge)=>{try{localStorage.setItem(Ve,String(Ge))}catch{}};switch(F){case"fontSize":q.setSubtitleFontSize(W),ke("subtitleFontSize",W);break;case"position":q.setSubtitlePosition(W),ke("subtitlePosition",W);break;case"bgOpacity":q.setSubtitleBgOpacity(W),ke("subtitleBgOpacity",W);break;case"bgColor":q.setSubtitleBgColor(W),ke("subtitleBgColor",W);break;case"textColor":q.setSubtitleTextColor(W),ke("subtitleTextColor",W);break;case"edge":q.setSubtitleEdge(W),ke("subtitleEdge",W);break;case"bold":q.setSubtitleBold(W),ke("subtitleBold",W);break}},useNativeControls:R.useNativeControls,onNativeControlsToggle:q.setUseNativeControls,anime4kEnabled:P,onAnime4kToggle:de,anime4kSupported:U,anime4kProfile:L,onAnime4kProfileChange:V,anime4kInitializing:Ae,anime4kError:Oe,videoDelayEnabled:i,onVideoDelayToggle:d,videoDelayMs:k,onVideoDelayChange:ve,onCalibrateAvSync:Be,isAutoSkipEnabled:R.isAutoSkipEnabled,onAutoSkipChange:F=>{q.setIsAutoSkipEnabled(F);try{localStorage.setItem("autoSkipEnabled",F.toString())}catch{}},isAutoplayEnabled:l,onAutoplayChange:m,fallbackChoice:_e,onFallbackChoiceChange:Ne,isTheaterMode:J,ambientSettings:Ue,onAmbientChange:oe})}),_=ye?r("div",{"data-speed-boost-ignore":"true",onClick:F=>F.stopPropagation(),children:lt}):null;return r(tn,{player:n,topBar:St,centerControls:H,bottomBar:!$&&R.duration>0?xe:null,settingsPanel:_,overlays:c,isInteracting:y,className:v,chromeDisabled:I,children:we})},Es=({count:n=3})=>r("section",{className:ze.section,children:[r("div",{className:ze.header,children:r("button",{className:ze.headerToggle,disabled:!0,children:[r("span",{className:ze.title,children:r(_t,{width:"60px",height:"1.2rem",variant:"text"})}),r(Z,{name:"chevron-down",style:{opacity:.3}})]})}),r("div",{className:ze.list,children:Array.from({length:n}).map((l,m)=>r("div",{className:ze.item,style:{pointerEvents:"none"},children:[r("div",{className:ze.dragHandle,style:{opacity:.2},children:r(_t,{width:"16px",height:"16px",variant:"rectangular"})}),r("div",{className:ze.thumbnail,style:{overflow:"hidden",background:"transparent"},children:r(_t,{width:"100%",height:"100%",variant:"rectangular"})}),r("div",{className:ze.meta,children:[r(_t,{width:"80%",height:"1.2rem",variant:"text",className:"mb-2"}),r(_t,{width:"40%",height:"0.8rem",variant:"rectangular",style:{borderRadius:"var(--radius-sm)"}})]})]},m))})]}),ws="_sourceSelectionContainer_c5tub_76",Ts="_providerSelectContainer_c5tub_89",ks="_providerSelect_c5tub_89",Cs="_sourceSelect_c5tub_76",Rs="_sourceButtons_c5tub_145",Ms="_sourceButton_c5tub_145",_s="_active_c5tub_170",at={sourceSelectionContainer:ws,providerSelectContainer:Ts,providerSelect:ks,sourceSelect:Cs,sourceButtons:Rs,sourceButton:Ms,active:_s},Ns=({selectedProvider:n,onProviderChange:l,isAdult:m,options:D})=>{const h=D&&D.length>0?D:[],S=m===void 0?h:h.filter(g=>g.mature===m);return r("div",{className:at.providerSelectContainer,children:[r("h4",{children:"Provider"}),r("select",{className:at.providerSelect,value:n,onChange:g=>l(g.target.value),children:Ln.map(g=>{const A=S.filter(x=>(x.tier??"direct")===g);return A.length===0?null:r("optgroup",{label:Bn[g],children:A.map(x=>r("option",{value:x.value,children:x.sub?`${x.label} (${An[x.sub]})`:x.label},x.value))},g)})})]})},xs=({videoSources:n,selectedSource:l,selectedLink:m,onSourceChange:D,onLinkChange:h})=>{const S=Array.isArray(n)?n:[];if(S.length===0)return null;const g=l?.type==="iframe"&&(l.links?.length??0)>1;return r("div",{className:at.sourceSelectionContainer,children:[r("h4",{children:"Source"}),r("div",{className:at.sourceButtons,children:S.map((A,x)=>r("button",{className:`${at.sourceButton} ${l?.sourceName===A.sourceName?at.active:""} `,onClick:()=>D(A),children:A.sourceName},`${A.sourceName}-${x}`))}),g&&r("select",{className:at.sourceSelect,"aria-label":"Fallback embed quality",value:m?.link??l.links[0]?.link??"",onChange:A=>{const x=l.links.find($=>$.link===A.target.value);x&&h(x)},children:l.links.map(A=>r("option",{value:A.link,children:A.resolutionStr},A.link))})]})},Ps=Ot.memo(xs,(n,l)=>n.selectedSource?.sourceName===l.selectedSource?.sourceName&&n.selectedLink?.link===l.selectedLink?.link&&n.videoSources===l.videoSources),As={low:{sd:1.5,hd:1.3,fhd:1.25},balanced:{sd:2,hd:1.5,fhd:1.25},high:{sd:2.5,hd:2,fhd:1.5},denoise:{sd:1.5,hd:1.5,fhd:1.5}},Bs={low:"ModeB",balanced:"ModeA",high:"ModeAA",denoise:"ModeC"},Ls=5,Is=15e3,Ds=`
3
3
  @group(0) @binding(0) var extTex: texture_external;
4
4
  @group(0) @binding(1) var extSamp: sampler;
5
5
  struct VSOut {
@@ -25,7 +25,7 @@ import{u as r,g as Ot,h as B,P as Br,z as Lr,d as ue,A as f,q as H,y as Ir,T as
25
25
  fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
26
26
  return textureSampleBaseClampToEdge(extTex, extSamp, uv);
27
27
  }
28
- `;function $s({videoRef:n,canvasRef:l,profile:m="balanced",delayMs:D=0}){const[h,S]=ue(!1),[g,A]=ue(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[P,$]=ue(!1),[T,e]=ue(null),[o,J]=ue(0),b=f(0),x=f(null),de=f(null),U=f(null),L=f(null),V=f(null),Ae=f(null),Oe=f(null),i=f(null),d=f(null),k=f(!1),ve=f(-1),Be=f(0),_e=f(D);_e.current=D;const Ne=f([]),Ue=f(!1),oe=f(!1),we=f(!1),c=f(null),y=f(-1),v=f(-1),I=f(!1),R=f(0);B(()=>{async function Y(){if(typeof navigator>"u"||!navigator.gpu){S(!1);return}try{const G=await navigator.gpu.requestAdapter();S(!!G)}catch{S(!1)}}Y()},[]),B(()=>{if(!g||!h)return;let Y=!1;const G=++b.current,Te=K=>{if(K)try{K.close()}catch{}},Le=()=>{for(const K of Ne.current)Te(K.bitmap);Ne.current=[]},yt=K=>Math.max(8,Math.min(40,Math.ceil(K/16.7)+4));function Ze(){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)}async function St(){let K=n.current;const Pe=l.current;if(!K||!Pe||b.current!==G)return;const lt=performance.now()+Is;for(;(!K||K.videoWidth===0)&&performance.now()<lt;){if(await new Promise(le=>requestAnimationFrame(le)),Y||b.current!==G)return;K=n.current}if(!K||K.videoWidth===0){!Y&&b.current===G&&(e("Timed out waiting for video metadata"),$(!1),A(!1));return}const _=K.videoWidth,F=K.videoHeight,W=Math.max(_,F),ke=window.innerWidth,Ve=window.innerHeight,Ge=Math.max(ke,Ve),ct=W<Ge?Ge/W:1,ut=As[m],dt=W<=480?ut.sd:W<=720?ut.hd:W<=1080?ut.fhd:1,pt=Math.min(dt,ct);Pe.width=Math.round(_*pt),Pe.height=Math.round(F*pt),$(!0),e(null),Be.current=0,ve.current=-1,y.current=-1,v.current=-1,I.current=!1,R.current=0,Le(),k.current=!1;try{let le=function(){Y||b.current!==G||(Ze(),d.current=requestAnimationFrame(()=>{At()}))};const{ModeA:He,ModeB:Ke,ModeC:Nt,ModeAA:Et}=await mr(async()=>{const{ModeA:O,ModeB:Q,ModeC:ge,ModeAA:pe}=await import("./index-BOKlZEHq.js").then(E=>E.i);return{ModeA:O,ModeB:Q,ModeC:ge,ModeAA:pe}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const je=await navigator.gpu.requestAdapter();if(!je)throw new Error("No GPU adapter found");const M=await je.requestDevice();if(!M)throw new Error("Failed to get GPU device");const Ie=Pe.getContext("webgpu");if(!Ie)throw new Error("Failed to get WebGPU context");const De=navigator.gpu.getPreferredCanvasFormat();Ie.configure({device:M,format:De,alphaMode:"premultiplied"});const ee=M.createTexture({size:[_,F],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Ye=Bs[m],et=Math.round(_*pt),be=Math.round(F*pt),mt=(()=>{switch(Ye){case"ModeB":return new Ke({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}});case"ModeC":return new Nt({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}});case"ModeAA":return new Et({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}});default:return new He({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}})}})(),ft=mt.getOutputTexture(),qe=M.createSampler({magFilter:"linear",minFilter:"linear"}),wt=M.createShaderModule({code:`
28
+ `;function $s({videoRef:n,canvasRef:l,profile:m="balanced",delayMs:D=0}){const[h,S]=ue(!1),[g,A]=ue(()=>{try{return localStorage.getItem("anime4kEnabled")==="true"}catch{return!1}}),[x,$]=ue(!1),[T,e]=ue(null),[o,J]=ue(0),b=f(0),P=f(null),de=f(null),U=f(null),L=f(null),V=f(null),Ae=f(null),Oe=f(null),i=f(null),d=f(null),k=f(!1),ve=f(-1),Be=f(0),_e=f(D);_e.current=D;const Ne=f([]),Ue=f(!1),oe=f(!1),we=f(!1),c=f(null),y=f(-1),v=f(-1),I=f(!1),R=f(0);B(()=>{async function Y(){if(typeof navigator>"u"||!navigator.gpu){S(!1);return}try{const G=await navigator.gpu.requestAdapter();S(!!G)}catch{S(!1)}}Y()},[]),B(()=>{if(!g||!h)return;let Y=!1;const G=++b.current,Te=H=>{if(H)try{H.close()}catch{}},Le=()=>{for(const H of Ne.current)Te(H.bitmap);Ne.current=[]},yt=H=>Math.max(8,Math.min(40,Math.ceil(H/16.7)+4));function Ze(){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)}async function St(){let H=n.current;const xe=l.current;if(!H||!xe||b.current!==G)return;const lt=performance.now()+Is;for(;(!H||H.videoWidth===0)&&performance.now()<lt;){if(await new Promise(le=>requestAnimationFrame(le)),Y||b.current!==G)return;H=n.current}if(!H||H.videoWidth===0){!Y&&b.current===G&&(e("Timed out waiting for video metadata"),$(!1),A(!1));return}const _=H.videoWidth,F=H.videoHeight,W=Math.max(_,F),ke=window.innerWidth,Ve=window.innerHeight,Ge=Math.max(ke,Ve),ct=W<Ge?Ge/W:1,ut=As[m],dt=W<=480?ut.sd:W<=720?ut.hd:W<=1080?ut.fhd:1,pt=Math.min(dt,ct);xe.width=Math.round(_*pt),xe.height=Math.round(F*pt),$(!0),e(null),Be.current=0,ve.current=-1,y.current=-1,v.current=-1,I.current=!1,R.current=0,Le(),k.current=!1;try{let le=function(){Y||b.current!==G||(Ze(),d.current=requestAnimationFrame(()=>{At()}))};const{ModeA:Ke,ModeB:He,ModeC:Nt,ModeAA:Et}=await mr(async()=>{const{ModeA:O,ModeB:Q,ModeC:ge,ModeAA:pe}=await import("./index-BOKlZEHq.js").then(E=>E.i);return{ModeA:O,ModeB:Q,ModeC:ge,ModeAA:pe}},[]);if(!navigator.gpu)throw new Error("WebGPU not available");const je=await navigator.gpu.requestAdapter();if(!je)throw new Error("No GPU adapter found");const M=await je.requestDevice();if(!M)throw new Error("Failed to get GPU device");const Ie=xe.getContext("webgpu");if(!Ie)throw new Error("Failed to get WebGPU context");const De=navigator.gpu.getPreferredCanvasFormat();Ie.configure({device:M,format:De,alphaMode:"premultiplied"});const ee=M.createTexture({size:[_,F],format:"rgba16float",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),Ye=Bs[m],et=Math.round(_*pt),be=Math.round(F*pt),mt=(()=>{switch(Ye){case"ModeB":return new He({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}});case"ModeC":return new Nt({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}});case"ModeAA":return new Et({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}});default:return new Ke({device:M,inputTexture:ee,nativeDimensions:{width:_,height:F},targetDimensions:{width:et,height:be}})}})(),ft=mt.getOutputTexture(),qe=M.createSampler({magFilter:"linear",minFilter:"linear"}),wt=M.createShaderModule({code:`
29
29
  @group(0) @binding(0) var tex: texture_2d<f32>;
30
30
  @group(0) @binding(1) var samp: sampler;
31
31
  struct VertexOutput {
@@ -51,6 +51,6 @@ import{u as r,g as Ot,h as B,P as Br,z as Lr,d as ue,A as f,q as H,y as Ir,T as
51
51
  fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
52
52
  return textureSample(tex, samp, uv);
53
53
  }
54
- `}),tt=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Pt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[tt]}),vertex:{module:wt,entryPoint:"vs"},fragment:{module:wt,entryPoint:"fs",targets:[{format:De}]},primitive:{topology:"triangle-list"}}),rt=M.createBindGroup({layout:tt,entries:[{binding:0,resource:ft.createView()},{binding:1,resource:qe}]});try{const O=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Q=M.createShaderModule({code:Ds}),ge=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[O]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:ge,layout:O,inputView:ee.createView()}}catch{c.current=null}if(b.current!==G){ee.destroy(),M.destroy();return}x.current=M,de.current=Ie,U.current=mt,L.current=ee,V.current=ft,Ae.current=Pt,Oe.current=qe,i.current=tt,oe.current=!1,we.current=!1;async function xt(){const O=c.current;if(!O||oe.current)return!1;const Q=n.current;if(!Q)return!1;const ge=!we.current;ge&&M.pushErrorScope("validation");try{const pe=M.importExternalTexture({source:Q}),E=M.createBindGroup({layout:O.layout,entries:[{binding:0,resource:pe},{binding:1,resource:qe}]}),Ce=M.createCommandEncoder(),me=Ce.beginRenderPass({colorAttachments:[{view:O.inputView,loadOp:"load",storeOp:"store"}]});me.setPipeline(O.pipeline),me.setBindGroup(0,E),me.draw(6),me.end(),M.queue.submit([Ce.finish()])}catch{return oe.current=!0,c.current=null,!1}if(ge){const pe=await M.popErrorScope().catch(()=>null);if(pe)return console.warn("[anime4k] blit probe failed:",pe.message),oe.current=!0,c.current=null,!1;we.current=!0}return!0}$(!1);async function At(){if(Y||b.current!==G)return;const O=n.current;if(!O||O.videoWidth===0){le();return}if(O!==K||O.videoWidth!==_||O.videoHeight!==F){J(E=>E+1);return}if(O.paused||O.ended||document.hidden||O.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const Q=O.getVideoPlaybackQuality().totalVideoFrames;if(Q===v.current){le();return}if(k.current){le();return}const ge=O.currentTime;(O.seeking||y.current>=0&&Math.abs(ge-y.current)>.5)&&(Le(),I.current=!1,R.current=0,v.current=-1),y.current=ge;const pe=Math.max(0,_e.current||0);pe>R.current&&(I.current=!1),k.current=!0;try{const E=performance.now();let Ce=null,me=!1;if(pe<=0){Ne.current.length>0&&Le(),I.current=!1,R.current=0;let xe=!1;if(!Ue.current)try{M.queue.copyExternalImageToTexture({source:O},{texture:ee},[_,F]),v.current=Q,xe=!0}catch(z){if(z instanceof TypeError)Ue.current=!0;else throw z}if(!xe&&!oe.current&&c.current&&await xt()&&(v.current=Q,xe=!0),!xe){const z=await createImageBitmap(O);v.current=Q,M.queue.copyExternalImageToTexture({source:z},{texture:ee},[_,F]),Te(z)}}else{const xe=await createImageBitmap(O);v.current=Q;const z=Ne.current;z.push({bitmap:xe,capture:E});const Tt=yt(pe);for(;z.length>Tt;)Te(z.shift()?.bitmap);let kt=-1;for(let te=z.length-1;te>=0;te--)if(E-z[te].capture>=pe){kt=te;break}if(kt!==-1){for(let vt=0;vt<kt;vt++)Te(z.shift()?.bitmap);const te=z.shift();te?(Ce=te.bitmap,I.current=!0,R.current=pe):(Ce=xe,me=!0)}else if(!I.current)Ce=xe,me=!0;else{const te=z.shift();Ce=te?te.bitmap:xe,te||(me=!0)}if(!Ce){k.current=!1,le();return}M.queue.copyExternalImageToTexture({source:Ce},{texture:ee},[_,F]),me||Te(Ce)}const nt=M.createCommandEncoder();await mt.pass(nt);const ht=nt.beginRenderPass({colorAttachments:[{view:Ie.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});ht.setPipeline(Pt),ht.setBindGroup(0,rt),ht.draw(6),ht.end(),M.queue.submit([nt.finish()]),ve.current=Q,Be.current=0,M.queue.onSubmittedWorkDone().then(()=>{b.current===G&&(k.current=!1)})}catch(E){if(k.current=!1,Be.current+=1,Be.current>=Ls&&!Y&&b.current===G){console.error(E),e(E instanceof Error?E.message:"Render error"),A(!1);return}}le()}le()}catch(le){!Y&&b.current===G&&(e(le instanceof Error?le.message:"Failed to initialize upscaler"),$(!1),A(!1))}}return St(),()=>{Y=!0,b.current+=1,Ze(),Le(),L.current&&(L.current.destroy(),L.current=null),V.current&&(V.current.destroy(),V.current=null),x.current&&(x.current.destroy(),x.current=null),U.current=null,Ae.current=null,Oe.current=null,i.current=null,c.current=null,de.current=null,k.current=!1}},[g,h,n,l,m,o]);const q=H(Y=>{A(Y);try{localStorage.setItem("anime4kEnabled",String(Y))}catch{}},[]),ye=H(()=>{A(Y=>{const G=!Y;try{localStorage.setItem("anime4kEnabled",String(G))}catch{}return G})},[]);return{isWebGPUSupported:h,isEnabled:g,isInitializing:P,error:T,toggle:ye,setEnabled:q}}const Fs=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ws=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},Os=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Fs(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:nn(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ws(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Us(n,l){switch(l.type){case"SET_STATE":return{...n,...l.payload};case"SET_MODE":return{...n,currentMode:l.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:l.payload};default:return n}}async function pr(n,l,m,D,h=!1){if(!n||!l)throw new Error("Missing params");try{const[S,g,A,P]=await Promise.all([Ee.data.video.query({showId:n,episodeNumber:l,mode:m.currentMode,provider:m.selectedProvider}).catch(()=>null),Ee.progress.getEpisode.query({showId:n,episodeNumber:l}).catch(()=>null),Ee.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Ee.data.skipTimes.query({showId:n,episodeNumber:l}).catch(()=>[])]),$=A?.value,T=S?.filter(L=>{const V=L.sourceName.toLowerCase();return m.currentMode==="dub"?V.includes("eng")||V.includes("dub"):V.includes("jpn")||V.includes("sub")||!V.includes("eng")&&!V.includes("dub")})??[],e=T.length>0?T:S??[];let o=e.length>0?e[0]:null;if($){const L=e.find(V=>V.sourceName===$);L&&(o=L)}const J=o&&o.links.length>0?o.links.sort((L,V)=>(parseInt(V.resolutionStr)||0)-(parseInt(L.resolutionStr)||0))[0]:null,b=g?.currentTime||0,x=g?.duration||0,U=(Array.isArray(P)?P:P?.results||[]).map(L=>({skip_id:L.skip_id||"",skip_type:L.skip_type||"",start_time:L.interval?.start_time??L.start_time??0,end_time:L.interval?.end_time??L.end_time??0})).filter(L=>L.end_time>0);return(!S||S.length===0)&&(h||We.error(`No video sources found for ${m.selectedProvider}`)),{videoSources:S,selectedSource:o,selectedLink:J,resumeTime:b,resumeDuration:x,showResumeModal:b>5&&o?.type!=="iframe",skipIntervals:U,fetchedEpisodeNumber:l}}catch(S){const g=S;if(g.message==="AUTH_REQUIRED")return D({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:g.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:l};throw S}}const Vs=(n,l,m,D)=>{const[h,S]=Ir(Us,m,c=>({...Os(),showMeta:c?.name?{name:c.name,thumbnail:c.thumbnail,nativeName:c.nativeName,englishName:c.englishName,names:{romaji:c.name||c.englishName,english:c.englishName||c.name,native:c.nativeName}}:{}})),g=fr(),A=Or(),P=f(null),$=f(null),{options:T}=hr(),e=Je(()=>T.filter(c=>(c.kind??"anime")==="anime"),[T]),o=l||h.initialEpisode,J=f(o);B(()=>{J.current!==o&&(J.current=o,S({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[o,S]),B(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&h.selectedProvider!=="animepahe"&&P.current!==n&&(P.current=n,S({type:"SET_PROVIDER",payload:"animepahe"}))},[n,h.selectedProvider]);const{data:b,isLoading:x,error:de}=_n(n),{data:U}=lr({queryKey:["player-data",n,h.currentMode,h.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const q=await Ee.data.episodes.query({showId:n,mode:h.currentMode,provider:h.selectedProvider}).catch(()=>null);if(q?.episodes?.length)return q}catch{}return null},[y,v,I]=await Promise.all([c(),Ee.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Ee.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),R=y?.episodes?y.episodes.sort((q,ye)=>parseFloat(q)-parseFloat(ye)):[];return{description:y?.description||"",episodes:R,inWatchlist:v.inWatchlist,watchlistStatus:v.status??null,watchedEpisodes:I}},enabled:!!n});B(()=>{!l&&U?.episodes&&U.episodes.length>0&&!l&&S({type:"SET_STATE",payload:{initialEpisode:U.episodes[0]}})},[U,l]),B(()=>{if(b?.isAdult===void 0)return;const y=new Set(e.filter(v=>v.mature).map(v=>v.value)).has(h.selectedProvider);if($.current!==n){if(b.isAdult&&!y){const v=e.find(I=>I.mature);if(!v)return;$.current=n,S({type:"SET_PROVIDER",payload:v.value}),localStorage.setItem("preferredProvider",v.value)}if(!b.isAdult&&y){const v=e.find(I=>!I.mature);if(!v)return;$.current=n,S({type:"SET_PROVIDER",payload:v.value}),localStorage.setItem("preferredProvider",v.value)}}},[b?.isAdult,h.selectedProvider,n,e]),B(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||$.current===`temp:${n}`)return;const c=b?.provider;c&&($.current=`temp:${n}`,c!==h.selectedProvider&&S({type:"SET_PROVIDER",payload:c}))},[n,b,h.selectedProvider]);const{data:L,isLoading:V,error:Ae}=lr({queryKey:["video-sources",n,o,h.selectedProvider,h.currentMode],queryFn:()=>pr(n,o,h,S),enabled:!!n&&!!o&&!(h.showMeta?.isAdult===!0&&!D?.hasMatureConsent)}),{mutateAsync:Oe}=jt({mutationFn:async({wasIn:c,showMeta:y})=>{if(!n)throw new Error("Missing showId");if(c)await Ee.watchlist.remove.mutate({id:n});else{const v=y.name||y.names?.romaji;if(!v)throw new Error("Missing show name");await Ee.watchlist.add.mutate({id:n,name:v,thumbnail:y.thumbnail,nativeName:y.names?.native,englishName:y.names?.english,type:y.type,isAdult:y.isAdult})}return!c},onSuccess:c=>{We.success(c?"Added to watchlist":"Removed from watchlist"),g.invalidateQueries({queryKey:["player-data",n]}),g.invalidateQueries({queryKey:["show-data",n]}),g.invalidateQueries({queryKey:["watchlist"]})},onError:c=>We.error(c instanceof Error?c.message:"Failed to update watchlist")}),i=H(async()=>{!n||!b||await Oe({wasIn:!!U?.inWatchlist,showMeta:b})},[n,b,U?.inWatchlist,Oe]),d=H(async c=>{try{await Ee.settings.set.mutate({key:"preferredSource",value:c})}catch(y){console.error(y)}},[]),{mutateAsync:k,isPending:ve}=jt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Ee.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{S({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),We.success(`Moved to ${c}`),g.invalidateQueries({queryKey:["show-data",n]}),g.invalidateQueries({queryKey:["watchlist"]}),g.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>We.error("Failed to update watchlist status")}),Be=H(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:_e}=jt({mutationFn:async({episodeNumber:c,duration:y,showMeta:v,episodes:I})=>{await Ee.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:y,duration:y,showName:v.name,showThumbnail:v.thumbnail,nativeName:v.names?.native,englishName:v.names?.english,genres:v.genres?.map(R=>R.name),popularityScore:Ur(v.score??v.stats?.averageScore),type:v.type,status:v.status,episodeCount:I.length,isAdult:v.isAdult})},onSuccess:(c,y)=>{We.success(`Episode ${y.episodeNumber} marked as watched`),g.invalidateQueries({queryKey:["player-data",n]}),g.invalidateQueries({queryKey:["show-meta",n]}),g.invalidateQueries({queryKey:["video-sources",n,y.episodeNumber]}),g.invalidateQueries({queryKey:["allContinueWatching"]}),g.invalidateQueries({queryKey:["thisWeekSchedule"]}),g.invalidateQueries(A.continueWatching.pathFilter())},onError:()=>We.error("Failed to mark episode as watched")}),Ne=H(async(c,y)=>{!n||!b||await _e({episodeNumber:c,duration:y,showMeta:b,episodes:U?.episodes||[]})},[n,b,U?.episodes,_e]),Ue=H(async()=>{S({type:"SET_STATE",payload:{showCombinedDetails:!h.showCombinedDetails}})},[h.showCombinedDetails]),oe=Je(()=>{const c=de||Ae,y=c?c.message:null,v=y==="AUTH_REQUIRED"?null:y,I=L&&L.fetchedEpisodeNumber===o?L:null,R=!!L&&!I;return{...h,currentEpisode:o,showMeta:{...h.showMeta||{},...b||{}},episodes:U?.episodes||[],watchedEpisodes:U?.watchedEpisodes||[],inWatchlist:!!U?.inWatchlist,watchlistStatus:U?.watchlistStatus??h.watchlistStatus??null,videoSources:I?.videoSources||[],selectedSource:h.selectedSource||I?.selectedSource||null,selectedLink:h.selectedLink||I?.selectedLink||null,resumeTime:I?.resumeTime||0,resumeDuration:I?.resumeDuration||0,showResumeModal:h.showResumeModal&&(I?.showResumeModal??!1),skipIntervals:I?.skipIntervals||[],loadingShowData:x,loadingVideo:V||R,error:v,fetchedEpisodeNumber:I?.fetchedEpisodeNumber}},[h,b,U,L,x,V,de,Ae,o]),we=H((c,y)=>{const v=y||n;if(!v||!c||v===n&&c===o)return;const R=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v)&&h.selectedProvider!=="animepahe"?"animepahe":h.selectedProvider,q=["video-sources",v,c,R,h.currentMode];g.getQueryState(q)?.status!=="success"&&g.prefetchQuery({queryKey:q,queryFn:()=>pr(v,c,{selectedProvider:R,currentMode:h.currentMode},S,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,o,g,h,S]);return{state:oe,dispatch:S,toggleWatchlist:i,moveToCompleted:Be,setPreferredSource:d,handleToggleDetails:Ue,markEpisodeWatched:Ne,prefetchEpisodeSources:we,isMarkingWatched:_e.isPending,isUpdatingWatchlistStatus:ve}},Xt="fallbackChoice";function qs(){try{const n=localStorage.getItem(Xt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Qs(n){try{n===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,n)}catch{}}const lo=()=>{const{id:n,episodeNumber:l}=Dr(),m=$r(),D=fr(),h=Fr(),{hasConsent:S,grant:g}=Vr(),{options:A}=hr(),P=Je(()=>A.filter(t=>(t.kind??"anime")==="anime"),[A]),$=Je(()=>P.map(t=>t.value),[P]),T=Je(()=>new Set(P.filter(t=>t.mature).map(t=>t.value)),[P]),{state:e,dispatch:o,toggleWatchlist:J,moveToCompleted:b,setPreferredSource:x,handleToggleDetails:de,markEpisodeWatched:U,prefetchEpisodeSources:L,isMarkingWatched:V,isUpdatingWatchlistStatus:Ae}=Vs(n,l,h.state||null,{hasMatureConsent:S});B(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=l?`/watch/${e.showMeta.id}/${l}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;m(t,{replace:!0})}},[n,e.showMeta?.id,l,m]);const Oe=Je(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),i=sn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:Oe}),{refs:d,actions:k}=i,ve=f(null),Be=Rn(),_e=f(null),Ne=f(null),Ue=f(null),oe=f(0),we=f(e.resumeTime),c=f(e.showResumeModal),[y,v]=ue(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),{videoDelayMs:I,videoDelayEnabled:R,setDelayEnabled:q,handleVideoDelayChange:ye,isCalibrating:Y,testClipActive:G,stopCalibration:Te,openAvSyncCalibrator:Le,cancelAvSyncCalibrator:yt,applyAvSyncCalibrator:Ze,toggleTestClip:St,calibReturnRef:K,effectiveVideoDelayMs:Pe}=on(d.videoRef,()=>k.setShowSettings(!1)),lt=f(null),_=$s({videoRef:d.videoRef,canvasRef:Ne,profile:y,delayMs:Pe}),F=_.isEnabled&&_.isWebGPUSupported,W=`${n??""}:${e.currentEpisode??""}`,ke=f(null),Ve=f(!1),Ge=f(!1),ct=f(_.setEnabled);ct.current=_.setEnabled,B(()=>{const t=ke.current;ke.current=W,!(t===null||t===W)&&(!_.isEnabled||!_.isWebGPUSupported||(Ve.current=!0,Ge.current=!1,ct.current(!1)))},[W,_.isEnabled,_.isWebGPUSupported]),B(()=>{if(!Ve.current)return;if(_.isEnabled){Ge.current&&(Ve.current=!1);return}if(Ge.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){Ve.current=!1,ct.current(!0);return}const t=d.videoRef.current;if(!t)return;let s,a=!1;const u=()=>{a||(a=!0,Ve.current=!1,ct.current(!0))};if(t.readyState>=2)return s=window.setTimeout(u,500),()=>window.clearTimeout(s);const N=()=>{window.setTimeout(u,500)};return t.addEventListener("canplay",N,{once:!0}),t.addEventListener("playing",N,{once:!0}),s=window.setTimeout(u,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",N),t.removeEventListener("playing",N)}},[_.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,d.videoRef]),an({videoRef:d.videoRef,canvasRef:lt,delayMs:Pe,enabled:R&&!F});const ut=R&&!F,dt=F||ut;B(()=>{we.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[pt,le]=ue(!1),[He,Ke]=ue(!1),[Nt,Et]=ue(!1),je=f(!1),[M,Ie]=ue(null),De=f(!1),ee=f([]),Ye=f(!1),[et,be]=ue(null),[mt,ft]=ue(!1),[qe,wt]=ue(!1),[tt,Pt]=ue(()=>qs()??"ask"),rt=H(t=>{Pt(t),Qs(t==="ask"?null:t)},[]),xt=f(tt);xt.current=tt;const At=f(e.videoSources);At.current=e.videoSources;const O=f(()=>{}),[Q,ge]=ue(null),pe=f(l);B(()=>{pe.current!==l&&(pe.current=l,ge(null),Ie(null),je.current=!1,Te())},[l,Te]),B(()=>{De.current=!1,ee.current=[],Ye.current=!1,be(null),ft(!1)},[n,e.currentEpisode]),B(()=>{He||(je.current=!1)},[He]);const{data:E=[],isLoading:Ce}=qr(),me=Qr(),nt=f(me);nt.current=me;const ht=zr(),xe=Gr(),{isTheaterMode:z,toggleTheaterMode:Tt,handleLayoutClick:kt}=ln();Wr(()=>{if(i.state.isFullscreen||z)return;const t=d.playerContainerRef.current,s=_e.current;if(!t||!s)return;const a=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};a();const u=new ResizeObserver(a);return u.observe(t),()=>u.disconnect()},[i.state.isFullscreen,z,d.playerContainerRef]);const te=Je(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),vt=te>0?e.episodes[te-1]:null,Re=te>=0&&te<e.episodes.length-1?e.episodes[te+1]:null,Ut=te>-1&&te<e.episodes.length-1,Vt=cn(e.resumeTime,e.resumeDuration)||He,Xe=Vt&&cr(e.episodes,e.currentEpisode,e.showMeta.status),qt=e.showResumeModal&&(Xe||!Vt),Bt=Vt&&!Xe&&E.length===0&&!Q&&(e.showResumeModal||He),st=qt||Bt;un(i,!!e.selectedLink&&!z&&!st),B(()=>{const t=d.videoRef.current;if(!t)return;let s=!1;for(ve.current&&(ve.current.destroy(),ve.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(G)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){oe.current=0;return}K.current!=null?(oe.current=K.current,K.current=null):we.current>5&&!c.current?oe.current=we.current:c.current&&(oe.current=0);let a=e.selectedLink.link;if(a.startsWith("/api/proxy")||(a=`/api/proxy?url=${encodeURIComponent(a)}`,e.selectedLink.headers?.Referer&&(a+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const ce=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Se=null;try{Se=localStorage.getItem("playerLastSubtitle")}catch{}const re=Yt(e.selectedSource.subtitles,{lastKey:Se,enabled:ce}),Me=re>=0?e.selectedSource.subtitles[re]:null;e.selectedSource.subtitles.forEach(he=>{const ne=document.createElement("track");ne.kind="subtitles",ne.label=he.label,ne.srclang=he.lang;const w=he.src??he.url;if(w){let se=`/api/subtitle-proxy?url=${encodeURIComponent(w)}`;const ae=e.selectedLink?.headers?.Referer,bt=w.includes("anilight.live")?"https://anilight.live/":"",Wt=ae||bt;Wt&&(se+=`&referer=${encodeURIComponent(Wt)}`),ne.src=se}Me&&he.label===Me.label&&he.lang===Me.lang&&(ne.default=!0),t.appendChild(ne)}),ce||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const u=oe.current;oe.current=0;const N=()=>{u>0&&(t.currentTime=u)};t.addEventListener("loadedmetadata",N,{once:!0});const fe=!(c.current&&we.current>5),X=()=>{fe&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const ce=await Cn();if(s)return;if(!ce||!ce.isSupported()){t.src=a,X();return}const Se=document.body.classList.contains("low-end"),re=new ce({maxBufferLength:Se?15:30,maxMaxBufferLength:Se?30:60,maxBufferSize:Se?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ve.current=re,re.on(ce.Events.ERROR,(ne,w)=>{w.fatal&&!De.current&&O.current()});const Me=(e.selectedSource?.subtitles?.length??0)>0,he=()=>{try{Me&&typeof re.subtitleTrack=="number"&&re.subtitleTrack!==-1&&(re.subtitleTrack=-1)}catch{}};re.on(ce.Events.SUBTITLE_TRACK_SWITCH,(ne,w)=>{w?.id!==-1&&he()}),he(),re.loadSource(a),re.attachMedia(t),re.once(ce.Events.MANIFEST_PARSED,()=>{s||X()})})():(t.src=a,X());const j=localStorage.getItem("playerVolume"),ie=localStorage.getItem("playerMuted");return j!==null&&(t.volume=parseFloat(j)),ie!==null&&(t.muted=ie==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),ve.current&&(ve.current.destroy(),ve.current=null)}},[e.selectedSource,e.selectedLink,d.videoRef,K,k,e.loadingVideo,G]);const Lt=H(t=>{if(De.current)return;De.current=!0;const s=t.links[0];x(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),be(null)},[o,x]),It=H(()=>{const s=At.current.find(a=>a.type==="iframe");return s?.links?.length?s:null},[]),Dt=H(async()=>{const t=e.showMeta?.isAdult,s=$.filter(a=>{if(ee.current.includes(a))return!1;const u=T.has(a);return t===void 0?!0:u===t});ft(!0);try{for(const a of s){ee.current.push(a);let u=null;try{u=await Ee.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:a})}catch{continue}const N=(u??[]).filter(j=>{const ie=j.sourceName.toLowerCase();return e.currentMode==="dub"?ie.includes("eng")||ie.includes("dub"):ie.includes("jpn")||ie.includes("sub")||!ie.includes("eng")&&!ie.includes("dub")});if((N.length>0?N:u??[]).find(j=>j.type!=="iframe"&&j.links?.length)){ee.current=[e.selectedProvider],Ye.current=!1,o({type:"SET_STATE",payload:{selectedProvider:a,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",a),be(null),We.success(`Switched to ${a} (direct stream)`);return}}be({retryFailed:!0}),We.error("No working direct stream found on other providers")}finally{ft(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,o,$,T]),Jt=H(()=>{if(De.current||Ye.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;ee.current.includes(e.selectedProvider)||ee.current.push(e.selectedProvider);const s=xt.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}k.setShowControls(!0),be({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,k]);O.current=Jt;const vr=H(()=>{Ye.current=!0,be(null),wt(!1)},[]),br=H(()=>{qe&&rt("iframe");const t=It();t?Lt(t):be(null)},[qe,rt,It,Lt]),gr=H(()=>{qe&&rt("retry"),Dt()},[qe,rt,Dt]),Ct=(t,s,a)=>t.showId===s||!!a&&t.showId===a,$t=H(()=>{k.onEnded();const t=E.find(a=>Ct(a,n,e.showMeta?.id)&&a.episodeNumber===e.currentEpisode);if(E.length>0){const a=E.findIndex(N=>Ct(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),u=a>=0?E[a+1]||null:E[0];ge({nextItem:u,playedItem:t||null}),Ie(2)}else t&&nt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&E.length===0){const a=e.episodes.findIndex(u=>u===e.currentEpisode);if(a>-1&&a<e.episodes.length-1){const u=e.episodes[a+1];D.invalidateQueries({queryKey:["allContinueWatching"]}),m(`/watch/${n}/${u}`),s=!0}}!s&&E.length===0&&!Q&&!je.current&&cr(e.episodes,e.currentEpisode,e.showMeta.status)&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,m,E,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,Q,o,D]),Qt=H(()=>{if(E.length===0)return;k.onEnded();const t=E.find(u=>Ct(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),s=E.findIndex(u=>Ct(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),a=s>=0?E[s+1]||null:E[0];t&&me.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),a?m(`/watch/${a.showId}/${a.episodeNumber}`):t&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,m,E,me,n,e.showMeta?.id,e.currentEpisode,o]),Rt=H(()=>{Re&&(D.invalidateQueries({queryKey:["allContinueWatching"]}),Ke(!1),m(`/watch/${n}/${Re}`)),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[Re,m,n,o,D]),Zt=H(()=>{E.length>0?Qt():Re?Rt():We.error("No next episode available")},[E.length,Qt,Rt,Re]),yr=()=>{vt&&m(`/watch/${n}/${vt}`)};B(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{G||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,d.videoRef,G]),B(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&$t()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[$t,e.selectedSource?.type]),B(()=>{if(!Q||M===null)return;if(M<=0){const{nextItem:s,playedItem:a}=Q;ge(null),Ie(null),a&&nt.current.mutate({showId:a.showId,episodeNumber:a.episodeNumber}),s?m(`/watch/${s.showId}/${s.episodeNumber}`):a&&o({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{Ie(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[Q,M,m,o]),B(()=>{st&&i.state.isFullscreen&&i.actions.toggleFullscreen()},[st,i.state.isFullscreen,i.actions]),B(()=>{st&&d.videoRef.current&&d.videoRef.current.pause()},[st,d.videoRef]);const{titlePreference:Ft}=Hr(),{lowEndMode:er}=Kr(),{settings:zt,update:Sr}=dn(),Er=z&&zt.enabled&&!er&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,ot=Je(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Ft==="name"?t||"Loading...":Ft==="nativeName"?s?.native||t||"Loading...":Ft==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Ft,e.loadingShowData]);B(()=>{ot&&ot!=="Loading..."&&e.currentEpisode&&(document.title=`► ${ot} Episode ${e.currentEpisode} - dango`)},[ot,e.currentEpisode]),B(()=>{const t=s=>{s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),i.actions.inactivityTimer.current&&clearTimeout(i.actions.inactivityTimer.current),i.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&Zt(),s.key.toLowerCase()==="t"&&Tt())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,i.actions.inactivityTimer,Zt,Tt]);const{setAvailableSubtitles:tr,setActiveSubtitleTrack:Gt}=k;B(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{const a=Array.from(t.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));tr(a)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[d.videoRef,tr]),B(()=>{if(i.state.activeSubtitleTrack===null&&i.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Yt(i.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Gt("off");return}const a=i.state.availableSubtitles[s];Gt(a.lang||a.label)}},[i.state.activeSubtitleTrack,i.state.availableSubtitles,Gt]),B(()=>{const t=d.videoRef.current;if(!t||i.state.availableSubtitles.length===0)return;const s=i.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let u=!1;if(Array.from(t.textTracks).forEach(N=>{const X=(N.language===s||N.label===s)&&!u;N.mode=X?"showing":"hidden",X&&(u=!0)}),!u&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(fe=>fe.language==="en"||fe.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[i.state.activeSubtitleTrack,i.state.availableSubtitles,d.videoRef]);const[rr,wr]=ue(0);B(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>wr(t.clientHeight||0);s();const a=new ResizeObserver(s);return a.observe(t),()=>a.disconnect()},[d.videoRef,e.selectedSource,e.selectedLink]),B(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const a={fontSize:i.state.subtitleFontSize,position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold};s.textContent=ur(a);const u=d.videoRef.current;if(!u)return;const N=dr(i.state.subtitleFontSize,rr||u.clientHeight||720);s.textContent=ur({...a,fontSize:N});const fe=()=>{const w=Number(i.state.subtitlePosition),se=isNaN(w)?0:Math.max(0,Math.min(100,w));return Math.max(0,Math.min(100,100-se))},X=(w,se)=>{try{const ae=w;ae.snapToLines=!1,ae.line=se}catch{}},j=()=>{const w=N*16,se=u.videoHeight||u.clientHeight||720,ae=u.videoWidth||u.clientWidth||1280;return{step:w*1.3/se*100,chars:Math.max(20,Math.floor(ae/(w*.55)))}},ie=w=>{const se=fe(),ae=Array.from(w.activeCues??[]);if(ae.length<=1){ae.forEach(gt=>X(gt,se));return}const{step:bt,chars:Wt}=j();let ir=se;for(let gt=ae.length-1;gt>=0;gt--){const Pr=String(ae[gt].text??"").replace(/<[^>]*>/g,"").split(`
55
- `).reduce((xr,Ar)=>xr+Math.max(1,Math.ceil(Ar.length/Wt)),0),ar=ir-Pr*bt;X(ae[gt],Math.max(0,ar)),ir=ar-bt*.4}},ce=w=>{if(!w.cues)return;const se=fe();Array.from(w.cues).forEach(ae=>X(ae,se)),w.mode==="showing"&&ie(w)},Se=()=>{Array.from(u.textTracks).forEach(ce)};Se();const re=w=>{const se=w.target;se.mode==="showing"&&ie(se)};Array.from(u.textTracks).forEach(w=>{w.addEventListener("cuechange",re)});const Me=()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re),w.addEventListener("cuechange",re)}),Se()};u.textTracks.addEventListener("addtrack",Me),u.textTracks.addEventListener("removetrack",Me);const he=Array.from(u.querySelectorAll("track")),ne=()=>{Se()};return he.forEach(w=>{w.addEventListener("load",ne)}),()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re)}),u.textTracks.removeEventListener("addtrack",Me),u.textTracks.removeEventListener("removetrack",Me),he.forEach(w=>{w.removeEventListener("load",ne)})}},[i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold,i.state.activeSubtitleTrack,i.state.availableSubtitles,e.selectedSource,e.selectedLink,d.videoRef,rr]),B(()=>{if(!dt)return;const t=d.videoRef.current,s=Ue.current;if(!t||!s)return;const a=localStorage.getItem("playerSubtitlesEnabled")!=="false",u=i.state.activeSubtitleTrack;function N(){if(s.innerHTML="",!a||u==="off"||u===null)return;const j=Array.from(t.textTracks).find(ne=>ne.language===u||ne.label===u);if(!j||j.mode!=="showing")return;const ie=Pe/1e3;let ce;if(ie>0&&j.cues){const ne=t.currentTime-ie;ce=Array.from(j.cues).filter(w=>w.startTime<=ne&&ne<=w.endTime)}else ce=Array.from(j.activeCues??[]);if(ce.length===0)return;const Se={fontSize:dr(i.state.subtitleFontSize,t.clientHeight||0),position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold},re=pn(Se),Me=mn(t,Se.position),he=Array.from(ce);he.forEach((ne,w)=>{const se=String(ne.text??"");if(!fn(se).trim())return;const ae=document.createElement("div"),bt=(he.length-1-w)*1.7;ae.style.cssText=`${re}
56
- bottom: calc(${Me}px + ${bt}em);`,ae.innerHTML=hn(se),s.appendChild(ae)})}const fe=()=>N(),X=()=>N();return Array.from(t.textTracks).forEach(j=>{j.addEventListener("cuechange",fe)}),t.addEventListener("timeupdate",X),N(),()=>{Array.from(t.textTracks).forEach(j=>{j.removeEventListener("cuechange",fe)}),t.removeEventListener("timeupdate",X),s.innerHTML=""}},[_.isEnabled,_.isWebGPUSupported,i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold,i.state.activeSubtitleTrack,d.videoRef,dt,Pe]),B(()=>{try{localStorage.setItem("anime4kProfile",y)}catch{}},[y]);const Tr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=e.resumeTime,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=0,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Ht=H(()=>{Xe&&(je.current=!0),Bt&&Ke(!1),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,Xe,Bt]),Cr=H(()=>{if(Ke(!1),d.videoRef.current)try{d.videoRef.current.currentTime=0,d.videoRef.current.play().catch(()=>{})}catch{}o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,d]),Rr=H(async()=>{try{await b(),o({type:"SET_STATE",payload:{showResumeModal:!1}}),m("/")}catch{}},[b,o,m]),nr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${p.episodeNavBtn} ${p.secondary}`,onClick:yr,disabled:!vt,type:"button",children:[r(Z,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${p.episodeNavBtn} ${p.primary}`,onClick:Rt,disabled:!Re,type:"button",children:["Next EP",r(Z,{name:"chevron-right",size:12})]}),s==="mobile"&&Be&&r("button",{className:`${p.episodeNavBtn} ${p.episodePickerBtn}`,onClick:()=>Et(!0),type:"button",children:[r(Z,{name:"list-ul",size:12}),"Episodes"]})]});B(()=>{He&&(e.showResumeModal||E.length>0||Q||je.current||Xe&&o({type:"SET_STATE",payload:{showResumeModal:!0}}))},[He,Xe,e.showResumeModal,E.length,Q,o]);const Mr=t=>{o({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),kn(t)},sr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),_r=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Kt=f(L);Kt.current=L;const or=f("");B(()=>{const t=d.videoRef.current;if(le(!1),Ke(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const a=t.duration,u=t.currentTime;if(!a||Number.isNaN(a)){le(!1),Ke(!1);return}const N=u/a;if(a-u<=60){const fe=E.findIndex(ie=>Ct(ie,n,e.showMeta?.id)&&ie.episodeNumber===e.currentEpisode),X=E.length>0?fe>=0?E[fe+1]||null:E[0]:null,j=X?`${X.showId}:${X.episodeNumber}`:Ut?`${n}:${Re}`:"";j&&or.current!==j&&(or.current=j,X?Kt.current(X.episodeNumber,X.showId):Kt.current(Re))}le(Ut&&N>=.8),Ke(u>=Math.max(a*.98,a-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[d.videoRef,Ut,e.currentEpisode,e.selectedSource,Re,n,E,e.showMeta?.id]);const Nr=H(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||V)return;const t=d.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await U(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,U,V,d.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const Qe=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!S?r("div",{className:Fe.playerPageLayout,children:r($e,{isOpen:!0,title:"Content Warning",onClose:()=>m("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(it,{variant:"secondary",onClick:()=>m("/home"),children:"Go Back"}),r(it,{onClick:g,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Fe.playerPageLayout} ${z?Fe.theaterMode:""}`,onClick:kt,children:[z&&r(vn,{videoRef:d.videoRef,active:Er,settings:zt}),r($e,{isOpen:qt&&Xe,onClose:Ht,title:"Show Completed!",width:"sm",children:[r($e.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r($e.Actions,{children:r(it,{onClick:Rr,disabled:Ae,children:Ae?"Saving...":"Move to Completed"})})]}),r(bn,{isOpen:qt&&!Xe,onClose:Ht,title:"Resume Playback?",message:r(Mt,{children:["You were watching at ",r("strong",{children:i.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Tr,onRestart:kr}),r($e,{isOpen:Bt,onClose:Ht,title:"Episode Completed",width:"sm",children:[r($e.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Re?" Would you like to watch the next episode?":""]})}),r($e.Actions,{children:[r(it,{variant:"secondary",onClick:Cr,children:"Replay"}),Re&&r(it,{onClick:Rt,children:`Watch EP ${Re}`})]})]}),r($e,{isOpen:!!et,onClose:vr,title:"Direct stream failed",width:"sm",children:[r($e.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),et?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:qe,onChange:t=>wt(t.target.checked)}),"Remember my choice"]})]}),r($e.Actions,{children:[r(it,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(it,{onClick:gr,disabled:mt,children:mt?"Searching…":"Try another provider"})]})]}),r(jr,{isOpen:!!e.showCookieModal,onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{D.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!z&&r("aside",{ref:_e,className:Fe.episodeSidebar,children:e.loadingShowData?r(gn,{variant:"sidebar"}):r(yn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>m(`/watch/${n}/${t}`)})}),r("div",{className:Fe.playerMain,children:[r("div",{className:`${p.videoContainer} ${i.state.isFullscreen?"":Fe.videoPlayerWrapper} ${i.state.isFullscreen?p.fullscreenActive:""}`,style:{...st?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(Ss,{player:i,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Mr,fallbackChoice:tt,onFallbackChoiceChange:rt,ambientSettings:zt,onAmbientChange:Sr,showNextEpisodeButton:!st&&pt&&E.length===0,onNextEpisode:Rt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime),x(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Qe,skipIntervals:e.skipIntervals,animeTitle:ot,episodeNumber:e.currentEpisode,isTheaterMode:z,onTheaterModeToggle:Tt,anime4kEnabled:_.isEnabled,onAnime4kToggle:_.toggle,anime4kSupported:_.isWebGPUSupported,anime4kProfile:y,onAnime4kProfileChange:v,anime4kInitializing:_.isInitializing,anime4kError:_.error,videoDelayEnabled:R,onVideoDelayToggle:q,videoDelayMs:I,onVideoDelayChange:ye,onCalibrateAvSync:Le,isInteractingExtra:Nt||Y,className:Sn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Mt,{children:[i.state.isSpeedBoostActive&&r("div",{className:p.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(Z,{name:"forward",size:12})]}),M!==null&&Q?.nextItem&&r("div",{className:p.queueCountdown,children:["Queue next in ",M,"s"]})]}),children:[Qe&&r("div",{className:p.loadingOverlay,children:r("div",{className:p.loadingDots,children:[r("div",{className:p.dot}),r("div",{className:p.dot}),r("div",{className:p.dot})]})}),i.state.isBuffering&&!Qe&&e.selectedSource?.type!=="iframe"&&r("div",{className:p.bufferingOverlay,children:r("div",{className:p.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Qe&&r("iframe",{src:e.selectedLink?.link,className:p.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):r(Mt,{children:[!Qe&&e.videoSources.length===0&&r("div",{className:p.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:p.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:p.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Qe&&e.videoSources.length>0&&r("video",{ref:d.videoRef,controls:i.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{G||(k.onTimeUpdate(),Q&&d.videoRef.current&&d.videoRef.current.currentTime<d.videoRef.current.duration-1&&(ge(null),Ie(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onCanPlay:k.onCanPlay,onError:Jt,onContextMenu:t=>t.preventDefault(),className:dt?p.videoElementHidden:""}),_.isWebGPUSupported&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:Ne,className:`${p.upscalerCanvas} ${F?p.upscalerActive:""}`}),!F&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:lt,className:`${p.upscalerCanvas} ${ut?p.upscalerActive:""}`}),_.isEnabled&&_.isWebGPUSupported&&_.isInitializing&&r("div",{className:p.upscalerStatusBadge,children:"Preparing upscaler…"}),dt&&r("div",{ref:Ue,className:p.subtitleOverlay}),r(En,{isOpen:Y,ms:I,onChange:ye,onApply:Ze,onClose:yt,testClipActive:G,onTestClip:St})]})]})}),!z&&r(wn,{}),!z&&r(Mt,{children:[Ce&&E.length===0?r(Es,{count:3}):r(Mn,{title:"Queue",items:E,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>me.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>ht.mutate(),showClearAll:!0,onReorder:t=>xe.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:p.providerAndEpisodeRow,children:[r(Ns,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:P,onProviderChange:t=>{De.current=!1,ee.current=[],Ye.current=!1,be(null),o({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),nr(`${p.episodeActions} ${p.desktopEpisodeActions}`,"desktop")]}),Qe?r("div",{className:p.sourceLoader,children:r("div",{className:p.spinner})}):r(Mt,{children:r(xs,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime);const a=(t.links||[]).sort((u,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(u.resolutionStr)||0))[0]||null;x(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:a,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(x(e.selectedSource.sourceName),o({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Fe.playerInfoContainer,children:[r("div",{className:Fe.playerInfoHeader,children:[r("div",{className:Fe.playerAnimeCard,children:r("img",{src:Yr(e.showMeta.thumbnail||""),alt:ot,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Fe.videoTitleSection,children:[r("div",{className:p.titleContainer,children:[r("h1",{children:ot}),r("div",{className:p.scheduleInfo,children:[e.showMeta.status&&r("span",{className:p.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:p.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:p.controls,children:[r("button",{className:`${p.watchlistBtn} ${e.inWatchlist?p.inList:""}`,onClick:J,children:[e.inWatchlist?r(Z,{name:"check",size:14}):r(Z,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(Nn,{showId:n,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${p.watchlistBtn} ${p.queueBtn}`,activeClassName:p.queueActive}),_r&&r("button",{className:`${p.watchlistBtn} ${p.markWatchedBtn} ${sr?p.markWatchedDone:""}`,onClick:Nr,disabled:V||!e.currentEpisode,children:[r(Z,{name:"check",size:14}),V?"Saving...":sr?"Watched":"Mark Watched"]}),r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${e.currentMode==="dub"?p.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";De.current=!1,ee.current=[],Ye.current=!1,be(null),o({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),er&&r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${i.state.useNativeControls?p.modeToggleActive:""}`,onClick:()=>{const t=!i.state.useNativeControls;i.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:i.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),nr(`${p.episodeActions} ${p.mobileEpisodeActions}`,"mobile"),r("div",{className:p.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(xn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:p.detailsToggleBtn,onClick:de,children:[e.showCombinedDetails?r(Z,{name:"chevron-up"}):r(Z,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(Pn,{showMeta:e.showMeta,styles:p})]})]})]}),r(Tn,{isOpen:Nt,onClose:()=>Et(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{Et(!1),m(`/watch/${n}/${t}`)}})]})};export{lo as default};
54
+ `}),tt=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),xt=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[tt]}),vertex:{module:wt,entryPoint:"vs"},fragment:{module:wt,entryPoint:"fs",targets:[{format:De}]},primitive:{topology:"triangle-list"}}),rt=M.createBindGroup({layout:tt,entries:[{binding:0,resource:ft.createView()},{binding:1,resource:qe}]});try{const O=M.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),Q=M.createShaderModule({code:Ds}),ge=M.createRenderPipeline({layout:M.createPipelineLayout({bindGroupLayouts:[O]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list"}});c.current={pipeline:ge,layout:O,inputView:ee.createView()}}catch{c.current=null}if(b.current!==G){ee.destroy(),M.destroy();return}P.current=M,de.current=Ie,U.current=mt,L.current=ee,V.current=ft,Ae.current=xt,Oe.current=qe,i.current=tt,oe.current=!1,we.current=!1;async function Pt(){const O=c.current;if(!O||oe.current)return!1;const Q=n.current;if(!Q)return!1;const ge=!we.current;ge&&M.pushErrorScope("validation");try{const pe=M.importExternalTexture({source:Q}),E=M.createBindGroup({layout:O.layout,entries:[{binding:0,resource:pe},{binding:1,resource:qe}]}),Ce=M.createCommandEncoder(),me=Ce.beginRenderPass({colorAttachments:[{view:O.inputView,loadOp:"load",storeOp:"store"}]});me.setPipeline(O.pipeline),me.setBindGroup(0,E),me.draw(6),me.end(),M.queue.submit([Ce.finish()])}catch{return oe.current=!0,c.current=null,!1}if(ge){const pe=await M.popErrorScope().catch(()=>null);if(pe)return console.warn("[anime4k] blit probe failed:",pe.message),oe.current=!0,c.current=null,!1;we.current=!0}return!0}$(!1);async function At(){if(Y||b.current!==G)return;const O=n.current;if(!O||O.videoWidth===0){le();return}if(O!==H||O.videoWidth!==_||O.videoHeight!==F){J(E=>E+1);return}if(O.paused||O.ended||document.hidden||O.readyState<HTMLMediaElement.HAVE_CURRENT_DATA){le();return}const Q=O.getVideoPlaybackQuality().totalVideoFrames;if(Q===v.current){le();return}if(k.current){le();return}const ge=O.currentTime;(O.seeking||y.current>=0&&Math.abs(ge-y.current)>.5)&&(Le(),I.current=!1,R.current=0,v.current=-1),y.current=ge;const pe=Math.max(0,_e.current||0);pe>R.current&&(I.current=!1),k.current=!0;try{const E=performance.now();let Ce=null,me=!1;if(pe<=0){Ne.current.length>0&&Le(),I.current=!1,R.current=0;let Pe=!1;if(!Ue.current)try{M.queue.copyExternalImageToTexture({source:O},{texture:ee},[_,F]),v.current=Q,Pe=!0}catch(z){if(z instanceof TypeError)Ue.current=!0;else throw z}if(!Pe&&!oe.current&&c.current&&await Pt()&&(v.current=Q,Pe=!0),!Pe){const z=await createImageBitmap(O);v.current=Q,M.queue.copyExternalImageToTexture({source:z},{texture:ee},[_,F]),Te(z)}}else{const Pe=await createImageBitmap(O);v.current=Q;const z=Ne.current;z.push({bitmap:Pe,capture:E});const Tt=yt(pe);for(;z.length>Tt;)Te(z.shift()?.bitmap);let kt=-1;for(let te=z.length-1;te>=0;te--)if(E-z[te].capture>=pe){kt=te;break}if(kt!==-1){for(let vt=0;vt<kt;vt++)Te(z.shift()?.bitmap);const te=z.shift();te?(Ce=te.bitmap,I.current=!0,R.current=pe):(Ce=Pe,me=!0)}else if(!I.current)Ce=Pe,me=!0;else{const te=z.shift();Ce=te?te.bitmap:Pe,te||(me=!0)}if(!Ce){k.current=!1,le();return}M.queue.copyExternalImageToTexture({source:Ce},{texture:ee},[_,F]),me||Te(Ce)}const nt=M.createCommandEncoder();await mt.pass(nt);const ht=nt.beginRenderPass({colorAttachments:[{view:Ie.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});ht.setPipeline(xt),ht.setBindGroup(0,rt),ht.draw(6),ht.end(),M.queue.submit([nt.finish()]),ve.current=Q,Be.current=0,M.queue.onSubmittedWorkDone().then(()=>{b.current===G&&(k.current=!1)})}catch(E){if(k.current=!1,Be.current+=1,Be.current>=Ls&&!Y&&b.current===G){console.error(E),e(E instanceof Error?E.message:"Render error"),A(!1);return}}le()}le()}catch(le){!Y&&b.current===G&&(e(le instanceof Error?le.message:"Failed to initialize upscaler"),$(!1),A(!1))}}return St(),()=>{Y=!0,b.current+=1,Ze(),Le(),L.current&&(L.current.destroy(),L.current=null),V.current&&(V.current.destroy(),V.current=null),P.current&&(P.current.destroy(),P.current=null),U.current=null,Ae.current=null,Oe.current=null,i.current=null,c.current=null,de.current=null,k.current=!1}},[g,h,n,l,m,o]);const q=K(Y=>{A(Y);try{localStorage.setItem("anime4kEnabled",String(Y))}catch{}},[]),ye=K(()=>{A(Y=>{const G=!Y;try{localStorage.setItem("anime4kEnabled",String(G))}catch{}return G})},[]);return{isWebGPUSupported:h,isEnabled:g,isInitializing:x,error:T,toggle:ye,setEnabled:q}}const Fs=()=>localStorage.getItem("preferredMode")==="dub"?"dub":"sub",Ws=()=>{const n=localStorage.getItem("preferredProvider");return n&&/^[a-z0-9-]+$/i.test(n)?n:"megaplay"},Os=()=>({showMeta:{},episodes:[],watchedEpisodes:[],watchlistStatus:null,showCombinedDetails:!1,currentMode:Fs(),inWatchlist:!1,videoSources:[],selectedSource:null,selectedLink:null,isAutoplayEnabled:nn(),showResumeModal:!0,resumeTime:0,resumeDuration:0,skipIntervals:[],selectedProvider:Ws(),loadingShowData:!0,loadingVideo:!1,error:null,showCookieModal:!1,cookieProvider:null});function Us(n,l){switch(l.type){case"SET_STATE":return{...n,...l.payload};case"SET_MODE":return{...n,currentMode:l.payload,videoSources:[],selectedSource:null,selectedLink:null};case"SET_PROVIDER":return{...n,selectedProvider:l.payload};default:return n}}async function pr(n,l,m,D,h=!1){if(!n||!l)throw new Error("Missing params");try{const[S,g,A,x]=await Promise.all([Ee.data.video.query({showId:n,episodeNumber:l,mode:m.currentMode,provider:m.selectedProvider}).catch(()=>null),Ee.progress.getEpisode.query({showId:n,episodeNumber:l}).catch(()=>null),Ee.settings.getByKey.query({key:"preferredSource"}).catch(()=>null),Ee.data.skipTimes.query({showId:n,episodeNumber:l}).catch(()=>[])]),$=A?.value,T=S?.filter(L=>{const V=L.sourceName.toLowerCase();return m.currentMode==="dub"?V.includes("eng")||V.includes("dub"):V.includes("jpn")||V.includes("sub")||!V.includes("eng")&&!V.includes("dub")})??[],e=T.length>0?T:S??[];let o=e.length>0?e[0]:null;if($){const L=e.find(V=>V.sourceName===$);L&&(o=L)}const J=o&&o.links.length>0?o.links.sort((L,V)=>(parseInt(V.resolutionStr)||0)-(parseInt(L.resolutionStr)||0))[0]:null,b=g?.currentTime||0,P=g?.duration||0,U=(Array.isArray(x)?x:x?.results||[]).map(L=>({skip_id:L.skip_id||"",skip_type:L.skip_type||"",start_time:L.interval?.start_time??L.start_time??0,end_time:L.interval?.end_time??L.end_time??0})).filter(L=>L.end_time>0);return(!S||S.length===0)&&(h||We.error(`No video sources found for ${m.selectedProvider}`)),{videoSources:S,selectedSource:o,selectedLink:J,resumeTime:b,resumeDuration:P,showResumeModal:b>5&&o?.type!=="iframe",skipIntervals:U,fetchedEpisodeNumber:l}}catch(S){const g=S;if(g.message==="AUTH_REQUIRED")return D({type:"SET_STATE",payload:{showCookieModal:!0,cookieProvider:g.provider}}),{videoSources:[],selectedSource:null,selectedLink:null,resumeTime:0,resumeDuration:0,showResumeModal:!1,skipIntervals:[],fetchedEpisodeNumber:l};throw S}}const Vs=(n,l,m,D)=>{const[h,S]=Ir(Us,m,c=>({...Os(),showMeta:c?.name?{name:c.name,thumbnail:c.thumbnail,nativeName:c.nativeName,englishName:c.englishName,names:{romaji:c.name||c.englishName,english:c.englishName||c.name,native:c.nativeName}}:{}})),g=fr(),A=Or(),x=f(null),$=f(null),{options:T}=hr(),e=Je(()=>T.filter(c=>(c.kind??"anime")==="anime"),[T]),o=l||h.initialEpisode,J=f(o);B(()=>{J.current!==o&&(J.current=o,S({type:"SET_STATE",payload:{selectedSource:null,selectedLink:null}}))},[o,S]),B(()=>{n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)&&h.selectedProvider!=="animepahe"&&x.current!==n&&(x.current=n,S({type:"SET_PROVIDER",payload:"animepahe"}))},[n,h.selectedProvider]);const{data:b,isLoading:P,error:de}=_n(n),{data:U}=lr({queryKey:["player-data",n,h.currentMode,h.selectedProvider],queryFn:async()=>{if(!n)throw new Error("No showId");const c=async()=>{try{const q=await Ee.data.episodes.query({showId:n,mode:h.currentMode,provider:h.selectedProvider}).catch(()=>null);if(q?.episodes?.length)return q}catch{}return null},[y,v,I]=await Promise.all([c(),Ee.watchlist.check.query({showId:n}).catch(()=>({inWatchlist:!1,status:null})),Ee.progress.getWatchedEpisodes.query({showId:n}).catch(()=>[])]),R=y?.episodes?y.episodes.sort((q,ye)=>parseFloat(q)-parseFloat(ye)):[];return{description:y?.description||"",episodes:R,inWatchlist:v.inWatchlist,watchlistStatus:v.status??null,watchedEpisodes:I}},enabled:!!n});B(()=>{!l&&U?.episodes&&U.episodes.length>0&&!l&&S({type:"SET_STATE",payload:{initialEpisode:U.episodes[0]}})},[U,l]),B(()=>{if(b?.isAdult===void 0)return;const y=new Set(e.filter(v=>v.mature).map(v=>v.value)).has(h.selectedProvider);if($.current!==n){if(b.isAdult&&!y){const v=e.find(I=>I.mature);if(!v)return;$.current=n,S({type:"SET_PROVIDER",payload:v.value}),localStorage.setItem("preferredProvider",v.value)}if(!b.isAdult&&y){const v=e.find(I=>!I.mature);if(!v)return;$.current=n,S({type:"SET_PROVIDER",payload:v.value}),localStorage.setItem("preferredProvider",v.value)}}},[b?.isAdult,h.selectedProvider,n,e]),B(()=>{if(!n||!/^dango-mt-\d+$/.test(n)||$.current===`temp:${n}`)return;const c=b?.provider;c&&($.current=`temp:${n}`,c!==h.selectedProvider&&S({type:"SET_PROVIDER",payload:c}))},[n,b,h.selectedProvider]);const{data:L,isLoading:V,error:Ae}=lr({queryKey:["video-sources",n,o,h.selectedProvider,h.currentMode],queryFn:()=>pr(n,o,h,S),enabled:!!n&&!!o&&!(h.showMeta?.isAdult===!0&&!D?.hasMatureConsent)}),{mutateAsync:Oe}=jt({mutationFn:async({wasIn:c,showMeta:y})=>{if(!n)throw new Error("Missing showId");if(c)await Ee.watchlist.remove.mutate({id:n});else{const v=y.name||y.names?.romaji;if(!v)throw new Error("Missing show name");await Ee.watchlist.add.mutate({id:n,name:v,thumbnail:y.thumbnail,nativeName:y.names?.native,englishName:y.names?.english,type:y.type,isAdult:y.isAdult})}return!c},onSuccess:c=>{We.success(c?"Added to watchlist":"Removed from watchlist"),g.invalidateQueries({queryKey:["player-data",n]}),g.invalidateQueries({queryKey:["show-data",n]}),g.invalidateQueries({queryKey:["watchlist"]})},onError:c=>We.error(c instanceof Error?c.message:"Failed to update watchlist")}),i=K(async()=>{!n||!b||await Oe({wasIn:!!U?.inWatchlist,showMeta:b})},[n,b,U?.inWatchlist,Oe]),d=K(async c=>{try{await Ee.settings.set.mutate({key:"preferredSource",value:c})}catch(y){console.error(y)}},[]),{mutateAsync:k,isPending:ve}=jt({mutationFn:async({status:c})=>{if(!n)throw new Error("Missing showId");return await Ee.watchlist.setStatus.mutate({id:n,status:c}),c},onSuccess:c=>{S({type:"SET_STATE",payload:{inWatchlist:!0,watchlistStatus:c}}),We.success(`Moved to ${c}`),g.invalidateQueries({queryKey:["show-data",n]}),g.invalidateQueries({queryKey:["watchlist"]}),g.invalidateQueries({queryKey:["allContinueWatching"]})},onError:()=>We.error("Failed to update watchlist status")}),Be=K(async()=>{await k({status:"Completed"})},[k]),{mutateAsync:_e}=jt({mutationFn:async({episodeNumber:c,duration:y,showMeta:v,episodes:I})=>{await Ee.progress.updateProgress.mutate({showId:n,episodeNumber:c,currentTime:y,duration:y,showName:v.name,showThumbnail:v.thumbnail,nativeName:v.names?.native,englishName:v.names?.english,genres:v.genres?.map(R=>R.name),popularityScore:Ur(v.score??v.stats?.averageScore),type:v.type,status:v.status,episodeCount:I.length,isAdult:v.isAdult})},onSuccess:(c,y)=>{We.success(`Episode ${y.episodeNumber} marked as watched`),g.invalidateQueries({queryKey:["player-data",n]}),g.invalidateQueries({queryKey:["show-meta",n]}),g.invalidateQueries({queryKey:["video-sources",n,y.episodeNumber]}),g.invalidateQueries({queryKey:["allContinueWatching"]}),g.invalidateQueries({queryKey:["thisWeekSchedule"]}),g.invalidateQueries(A.continueWatching.pathFilter())},onError:()=>We.error("Failed to mark episode as watched")}),Ne=K(async(c,y)=>{!n||!b||await _e({episodeNumber:c,duration:y,showMeta:b,episodes:U?.episodes||[]})},[n,b,U?.episodes,_e]),Ue=K(async()=>{S({type:"SET_STATE",payload:{showCombinedDetails:!h.showCombinedDetails}})},[h.showCombinedDetails]),oe=Je(()=>{const c=de||Ae,y=c?c.message:null,v=y==="AUTH_REQUIRED"?null:y,I=L&&L.fetchedEpisodeNumber===o?L:null,R=!!L&&!I;return{...h,currentEpisode:o,showMeta:{...h.showMeta||{},...b||{}},episodes:U?.episodes||[],watchedEpisodes:U?.watchedEpisodes||[],inWatchlist:!!U?.inWatchlist,watchlistStatus:U?.watchlistStatus??h.watchlistStatus??null,videoSources:I?.videoSources||[],selectedSource:h.selectedSource||I?.selectedSource||null,selectedLink:h.selectedLink||I?.selectedLink||null,resumeTime:I?.resumeTime||0,resumeDuration:I?.resumeDuration||0,showResumeModal:h.showResumeModal&&(I?.showResumeModal??!1),skipIntervals:I?.skipIntervals||[],loadingShowData:P,loadingVideo:V||R,error:v,fetchedEpisodeNumber:I?.fetchedEpisodeNumber}},[h,b,U,L,P,V,de,Ae,o]),we=K((c,y)=>{const v=y||n;if(!v||!c||v===n&&c===o)return;const R=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v)&&h.selectedProvider!=="animepahe"?"animepahe":h.selectedProvider,q=["video-sources",v,c,R,h.currentMode];g.getQueryState(q)?.status!=="success"&&g.prefetchQuery({queryKey:q,queryFn:()=>pr(v,c,{selectedProvider:R,currentMode:h.currentMode},S,!0),staleTime:300*1e3,gcTime:1800*1e3})},[n,o,g,h,S]);return{state:oe,dispatch:S,toggleWatchlist:i,moveToCompleted:Be,setPreferredSource:d,handleToggleDetails:Ue,markEpisodeWatched:Ne,prefetchEpisodeSources:we,isMarkingWatched:_e.isPending,isUpdatingWatchlistStatus:ve}},Xt="fallbackChoice";function qs(){try{const n=localStorage.getItem(Xt);return n==="iframe"||n==="retry"?n:null}catch{return null}}function Qs(n){try{n===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,n)}catch{}}const lo=()=>{const{id:n,episodeNumber:l}=Dr(),m=$r(),D=fr(),h=Fr(),{hasConsent:S,grant:g}=Vr(),{options:A}=hr(),x=Je(()=>A.filter(t=>(t.kind??"anime")==="anime"),[A]),$=Je(()=>x.map(t=>t.value),[x]),T=Je(()=>new Set(x.filter(t=>t.mature).map(t=>t.value)),[x]),{state:e,dispatch:o,toggleWatchlist:J,moveToCompleted:b,setPreferredSource:P,handleToggleDetails:de,markEpisodeWatched:U,prefetchEpisodeSources:L,isMarkingWatched:V,isUpdatingWatchlistStatus:Ae}=Vs(n,l,h.state||null,{hasMatureConsent:S});B(()=>{if(n&&e.showMeta?.id&&e.showMeta.id!==n){const t=l?`/watch/${e.showMeta.id}/${l}${window.location.search}`:`/watch/${e.showMeta.id}${window.location.search}`;m(t,{replace:!0})}},[n,e.showMeta?.id,l,m]);const Oe=Je(()=>{if(e.showMeta.name)return{name:e.showMeta.name,thumbnail:e.showMeta.thumbnail,names:e.showMeta.names,genres:e.showMeta.genres,score:e.showMeta.score,isAdult:e.showMeta.isAdult}},[e.showMeta.name,e.showMeta.thumbnail,e.showMeta.names,e.showMeta.genres,e.showMeta.score,e.showMeta.isAdult]),i=sn({skipIntervals:e.skipIntervals,showId:n,episodeNumber:e.currentEpisode?.toString(),episodeCount:e.episodes.length||void 0,sourceType:e.selectedSource?.type,showMeta:Oe}),{refs:d,actions:k}=i,ve=f(null),Be=Rn(),_e=f(null),Ne=f(null),Ue=f(null),oe=f(0),we=f(e.resumeTime),c=f(e.showResumeModal),[y,v]=ue(()=>{try{const t=localStorage.getItem("anime4kProfile");return["low","balanced","high","denoise"].includes(t)?t:"balanced"}catch{return"balanced"}}),{videoDelayMs:I,videoDelayEnabled:R,setDelayEnabled:q,handleVideoDelayChange:ye,isCalibrating:Y,testClipActive:G,stopCalibration:Te,openAvSyncCalibrator:Le,cancelAvSyncCalibrator:yt,applyAvSyncCalibrator:Ze,toggleTestClip:St,calibReturnRef:H,effectiveVideoDelayMs:xe}=on(d.videoRef,()=>k.setShowSettings(!1)),lt=f(null),_=$s({videoRef:d.videoRef,canvasRef:Ne,profile:y,delayMs:xe}),F=_.isEnabled&&_.isWebGPUSupported,W=`${n??""}:${e.currentEpisode??""}`,ke=f(null),Ve=f(!1),Ge=f(!1),ct=f(_.setEnabled);ct.current=_.setEnabled,B(()=>{const t=ke.current;ke.current=W,!(t===null||t===W)&&(!_.isEnabled||!_.isWebGPUSupported||(Ve.current=!0,Ge.current=!1,ct.current(!1)))},[W,_.isEnabled,_.isWebGPUSupported]),B(()=>{if(!Ve.current)return;if(_.isEnabled){Ge.current&&(Ve.current=!1);return}if(Ge.current=!0,e.loadingVideo||!e.selectedLink)return;if(e.selectedSource?.type==="iframe"){Ve.current=!1,ct.current(!0);return}const t=d.videoRef.current;if(!t)return;let s,a=!1;const u=()=>{a||(a=!0,Ve.current=!1,ct.current(!0))};if(t.readyState>=2)return s=window.setTimeout(u,500),()=>window.clearTimeout(s);const N=()=>{window.setTimeout(u,500)};return t.addEventListener("canplay",N,{once:!0}),t.addEventListener("playing",N,{once:!0}),s=window.setTimeout(u,5e3),()=>{window.clearTimeout(s),t.removeEventListener("canplay",N),t.removeEventListener("playing",N)}},[_.isEnabled,e.loadingVideo,e.selectedLink,e.selectedSource?.type,d.videoRef]),an({videoRef:d.videoRef,canvasRef:lt,delayMs:xe,enabled:R&&!F});const ut=R&&!F,dt=F||ut;B(()=>{we.current=e.resumeTime,c.current=e.showResumeModal},[e.resumeTime,e.showResumeModal]);const[pt,le]=ue(!1),[Ke,He]=ue(!1),[Nt,Et]=ue(!1),je=f(!1),[M,Ie]=ue(null),De=f(!1),ee=f([]),Ye=f(!1),[et,be]=ue(null),[mt,ft]=ue(!1),[qe,wt]=ue(!1),[tt,xt]=ue(()=>qs()??"ask"),rt=K(t=>{xt(t),Qs(t==="ask"?null:t)},[]),Pt=f(tt);Pt.current=tt;const At=f(e.videoSources);At.current=e.videoSources;const O=f(()=>{}),[Q,ge]=ue(null),pe=f(l);B(()=>{pe.current!==l&&(pe.current=l,ge(null),Ie(null),je.current=!1,Te())},[l,Te]),B(()=>{De.current=!1,ee.current=[],Ye.current=!1,be(null),ft(!1)},[n,e.currentEpisode]),B(()=>{Ke||(je.current=!1)},[Ke]);const{data:E=[],isLoading:Ce}=qr(),me=Qr(),nt=f(me);nt.current=me;const ht=zr(),Pe=Gr(),{isTheaterMode:z,toggleTheaterMode:Tt,handleLayoutClick:kt}=ln();Wr(()=>{if(i.state.isFullscreen||z)return;const t=d.playerContainerRef.current,s=_e.current;if(!t||!s)return;const a=()=>{const N=t.getBoundingClientRect().height;s.style.height=`${N}px`};a();const u=new ResizeObserver(a);return u.observe(t),()=>u.disconnect()},[i.state.isFullscreen,z,d.playerContainerRef]);const te=Je(()=>e.episodes.findIndex(t=>t===e.currentEpisode),[e.episodes,e.currentEpisode]),vt=te>0?e.episodes[te-1]:null,Re=te>=0&&te<e.episodes.length-1?e.episodes[te+1]:null,Ut=te>-1&&te<e.episodes.length-1,Vt=cn(e.resumeTime,e.resumeDuration)||Ke,Xe=Vt&&cr(e.episodes,e.currentEpisode,e.showMeta.status),qt=e.showResumeModal&&(Xe||!Vt),Bt=Vt&&!Xe&&E.length===0&&!Q&&(e.showResumeModal||Ke),st=qt||Bt;un(i,!!e.selectedLink&&!z&&!st),B(()=>{const t=d.videoRef.current;if(!t)return;let s=!1;for(ve.current&&(ve.current.destroy(),ve.current=null),(e.loadingVideo||e.selectedSource)&&(t.pause(),t.removeAttribute("src"),t.load());t.firstChild;)t.removeChild(t.firstChild);if(G)return t.src="/av-sync-test.mp4",t.play().catch(()=>{k.setShowControls(!0)}),()=>{s=!0};if(!e.selectedSource||!e.selectedLink)return;if(e.selectedSource.type==="iframe"){oe.current=0;return}H.current!=null?(oe.current=H.current,H.current=null):we.current>5&&!c.current?oe.current=we.current:c.current&&(oe.current=0);let a=e.selectedLink.link;if(a.startsWith("/api/proxy")||(a=`/api/proxy?url=${encodeURIComponent(a)}`,e.selectedLink.headers?.Referer&&(a+=`&referer=${encodeURIComponent(e.selectedLink.headers.Referer)}`)),e.selectedSource.subtitles){const ce=localStorage.getItem("playerSubtitlesEnabled")!=="false";let Se=null;try{Se=localStorage.getItem("playerLastSubtitle")}catch{}const re=Yt(e.selectedSource.subtitles,{lastKey:Se,enabled:ce}),Me=re>=0?e.selectedSource.subtitles[re]:null;e.selectedSource.subtitles.forEach(he=>{const ne=document.createElement("track");ne.kind="subtitles",ne.label=he.label,ne.srclang=he.lang;const w=he.src??he.url;if(w){let se=`/api/subtitle-proxy?url=${encodeURIComponent(w)}`;const ae=e.selectedLink?.headers?.Referer,bt=w.includes("anilight.live")?"https://anilight.live/":"",Wt=ae||bt;Wt&&(se+=`&referer=${encodeURIComponent(Wt)}`),ne.src=se}Me&&he.label===Me.label&&he.lang===Me.lang&&(ne.default=!0),t.appendChild(ne)}),ce||k.setActiveSubtitleTrack("off"),k.setAvailableSubtitles(e.selectedSource.subtitles)}const u=oe.current;oe.current=0;const N=()=>{u>0&&(t.currentTime=u)};t.addEventListener("loadedmetadata",N,{once:!0});const fe=!(c.current&&we.current>5),X=()=>{fe&&t.play().catch(()=>{k.setShowControls(!0)})};e.selectedLink.hls?(async()=>{const ce=await Cn();if(s)return;if(!ce||!ce.isSupported()){t.src=a,X();return}const Se=document.body.classList.contains("low-end"),re=new ce({maxBufferLength:Se?15:30,maxMaxBufferLength:Se?30:60,maxBufferSize:Se?25*1e3*1e3:60*1e3*1e3,startLevel:-1,enableWorker:!0});ve.current=re,re.on(ce.Events.ERROR,(ne,w)=>{w.fatal&&!De.current&&O.current()});const Me=(e.selectedSource?.subtitles?.length??0)>0,he=()=>{try{Me&&typeof re.subtitleTrack=="number"&&re.subtitleTrack!==-1&&(re.subtitleTrack=-1)}catch{}};re.on(ce.Events.SUBTITLE_TRACK_SWITCH,(ne,w)=>{w?.id!==-1&&he()}),he(),re.loadSource(a),re.attachMedia(t),re.once(ce.Events.MANIFEST_PARSED,()=>{s||X()})})():(t.src=a,X());const j=localStorage.getItem("playerVolume"),ie=localStorage.getItem("playerMuted");return j!==null&&(t.volume=parseFloat(j)),ie!==null&&(t.muted=ie==="true"),()=>{s=!0,t.removeEventListener("loadedmetadata",N),ve.current&&(ve.current.destroy(),ve.current=null)}},[e.selectedSource,e.selectedLink,d.videoRef,H,k,e.loadingVideo,G]);const Lt=K(t=>{if(De.current)return;De.current=!0;const s=t.links[0];P(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s}}),be(null)},[o,P]),It=K(()=>{const s=At.current.find(a=>a.type==="iframe");return s?.links?.length?s:null},[]),Dt=K(async()=>{const t=e.showMeta?.isAdult,s=$.filter(a=>{if(ee.current.includes(a))return!1;const u=T.has(a);return t===void 0?!0:u===t});ft(!0);try{for(const a of s){ee.current.push(a);let u=null;try{u=await Ee.data.video.query({showId:n,episodeNumber:e.currentEpisode,mode:e.currentMode,provider:a})}catch{continue}const N=(u??[]).filter(j=>{const ie=j.sourceName.toLowerCase();return e.currentMode==="dub"?ie.includes("eng")||ie.includes("dub"):ie.includes("jpn")||ie.includes("sub")||!ie.includes("eng")&&!ie.includes("dub")});if((N.length>0?N:u??[]).find(j=>j.type!=="iframe"&&j.links?.length)){ee.current=[e.selectedProvider],Ye.current=!1,o({type:"SET_STATE",payload:{selectedProvider:a,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",a),be(null),We.success(`Switched to ${a} (direct stream)`);return}}be({retryFailed:!0}),We.error("No working direct stream found on other providers")}finally{ft(!1)}},[n,e.currentEpisode,e.currentMode,e.showMeta?.isAdult,e.selectedProvider,o,$,T]),Jt=K(()=>{if(De.current||Ye.current||e.selectedSource?.type!=="player")return;const t=It();if(!t)return;ee.current.includes(e.selectedProvider)||ee.current.push(e.selectedProvider);const s=Pt.current;if(s==="iframe"){Lt(t);return}if(s==="retry"){Dt();return}k.setShowControls(!0),be({retryFailed:!1})},[e.selectedSource,e.selectedProvider,It,Lt,Dt,k]);O.current=Jt;const vr=K(()=>{Ye.current=!0,be(null),wt(!1)},[]),br=K(()=>{qe&&rt("iframe");const t=It();t?Lt(t):be(null)},[qe,rt,It,Lt]),gr=K(()=>{qe&&rt("retry"),Dt()},[qe,rt,Dt]),Ct=(t,s,a)=>t.showId===s||!!a&&t.showId===a,$t=K(()=>{k.onEnded();const t=E.find(a=>Ct(a,n,e.showMeta?.id)&&a.episodeNumber===e.currentEpisode);if(E.length>0){const a=E.findIndex(N=>Ct(N,n,e.showMeta?.id)&&N.episodeNumber===e.currentEpisode),u=a>=0?E[a+1]||null:E[0];ge({nextItem:u,playedItem:t||null}),Ie(2)}else t&&nt.current.mutate({showId:t.showId,episodeNumber:t.episodeNumber});let s=!1;if(e.isAutoplayEnabled&&E.length===0){const a=e.episodes.findIndex(u=>u===e.currentEpisode);if(a>-1&&a<e.episodes.length-1){const u=e.episodes[a+1];D.invalidateQueries({queryKey:["allContinueWatching"]}),m(`/watch/${n}/${u}`),s=!0}}!s&&E.length===0&&!Q&&!je.current&&cr(e.episodes,e.currentEpisode,e.showMeta.status)&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,m,E,n,e.showMeta?.id,e.showMeta?.status,e.currentEpisode,e.episodes,e.isAutoplayEnabled,Q,o,D]),Qt=K(()=>{if(E.length===0)return;k.onEnded();const t=E.find(u=>Ct(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),s=E.findIndex(u=>Ct(u,n,e.showMeta?.id)&&u.episodeNumber===e.currentEpisode),a=s>=0?E[s+1]||null:E[0];t&&me.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),a?m(`/watch/${a.showId}/${a.episodeNumber}`):t&&o({type:"SET_STATE",payload:{showResumeModal:!0}})},[k,m,E,me,n,e.showMeta?.id,e.currentEpisode,o]),Rt=K(()=>{Re&&(D.invalidateQueries({queryKey:["allContinueWatching"]}),He(!1),m(`/watch/${n}/${Re}`)),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[Re,m,n,o,D]),Zt=K(()=>{E.length>0?Qt():Re?Rt():We.error("No next episode available")},[E.length,Qt,Rt,Re]),yr=()=>{vt&&m(`/watch/${n}/${vt}`)};B(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{G||$t()};return t.addEventListener("ended",s),()=>{t&&t.removeEventListener("ended",s)}},[$t,d.videoRef,G]),B(()=>{const t=s=>{s.origin===window.location.origin&&e.selectedSource?.type==="iframe"&&s.data?.type==="ANI_WEB_MEDIA_ENDED"&&$t()};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[$t,e.selectedSource?.type]),B(()=>{if(!Q||M===null)return;if(M<=0){const{nextItem:s,playedItem:a}=Q;ge(null),Ie(null),a&&nt.current.mutate({showId:a.showId,episodeNumber:a.episodeNumber}),s?m(`/watch/${s.showId}/${s.episodeNumber}`):a&&o({type:"SET_STATE",payload:{showResumeModal:!0}});return}const t=window.setTimeout(()=>{Ie(s=>s===null?null:s-1)},1e3);return()=>window.clearTimeout(t)},[Q,M,m,o]),B(()=>{st&&i.state.isFullscreen&&i.actions.toggleFullscreen()},[st,i.state.isFullscreen,i.actions]),B(()=>{st&&d.videoRef.current&&d.videoRef.current.pause()},[st,d.videoRef]);const{titlePreference:Ft}=Kr(),{lowEndMode:er}=Hr(),{settings:zt,update:Sr}=dn(),Er=z&&zt.enabled&&!er&&e.selectedSource?.type!=="iframe"&&!!e.selectedLink,ot=Je(()=>{if(!e.showMeta||e.loadingShowData)return"Loading...";const{name:t,names:s}=e.showMeta;return Ft==="name"?t||"Loading...":Ft==="nativeName"?s?.native||t||"Loading...":Ft==="englishName"?s?.english||t||"Loading...":t||"Loading..."},[e.showMeta,Ft,e.loadingShowData]);B(()=>{ot&&ot!=="Loading..."&&e.currentEpisode&&(document.title=`► ${ot} Episode ${e.currentEpisode} - dango`)},[ot,e.currentEpisode]),B(()=>{const t=s=>{s.target.closest('input, textarea, button, select, a, [role="button"], [contenteditable="true"]')||(["arrowup","arrowdown","arrowleft","arrowright"].includes(s.key.toLowerCase())&&(k.setShowControls(!0),i.actions.inactivityTimer.current&&clearTimeout(i.actions.inactivityTimer.current),i.actions.inactivityTimer.current=window.setTimeout(()=>{k.setShowControls(!1)},1e3)),s.key.toLowerCase()==="n"&&Zt(),s.key.toLowerCase()==="t"&&Tt())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[k,i.actions.inactivityTimer,Zt,Tt]);const{setAvailableSubtitles:tr,setActiveSubtitleTrack:Gt}=k;B(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>{const a=Array.from(t.textTracks).map(u=>({label:u.label,lang:u.language,src:void 0,mode:u.mode}));tr(a)};return t.textTracks.addEventListener("addtrack",s),t.textTracks.addEventListener("removetrack",s),s(),()=>{t&&(t.textTracks.removeEventListener("addtrack",s),t.textTracks.removeEventListener("removetrack",s))}},[d.videoRef,tr]),B(()=>{if(i.state.activeSubtitleTrack===null&&i.state.availableSubtitles.length>0&&localStorage.getItem("playerSubtitlesEnabled")!=="false"){let t=null;try{t=localStorage.getItem("playerLastSubtitle")}catch{}const s=Yt(i.state.availableSubtitles,{lastKey:t,enabled:!0});if(s<0){Gt("off");return}const a=i.state.availableSubtitles[s];Gt(a.lang||a.label)}},[i.state.activeSubtitleTrack,i.state.availableSubtitles,Gt]),B(()=>{const t=d.videoRef.current;if(!t||i.state.availableSubtitles.length===0)return;const s=i.state.activeSubtitleTrack;if(!(localStorage.getItem("playerSubtitlesEnabled")!=="false")||s==="off"||s===null){Array.from(t.textTracks).forEach(N=>{N.mode="hidden"});return}let u=!1;if(Array.from(t.textTracks).forEach(N=>{const X=(N.language===s||N.label===s)&&!u;N.mode=X?"showing":"hidden",X&&(u=!0)}),!u&&t.textTracks.length>0){const N=Array.from(t.textTracks).find(fe=>fe.language==="en"||fe.label==="English")||t.textTracks[0];N&&(N.mode="showing")}},[i.state.activeSubtitleTrack,i.state.availableSubtitles,d.videoRef]);const[rr,wr]=ue(0);B(()=>{const t=d.videoRef.current;if(!t)return;const s=()=>wr(t.clientHeight||0);s();const a=new ResizeObserver(s);return a.observe(t),()=>a.disconnect()},[d.videoRef,e.selectedSource,e.selectedLink]),B(()=>{const t="dynamic-subtitle-styles";let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,document.head.appendChild(s));const a={fontSize:i.state.subtitleFontSize,position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold};s.textContent=ur(a);const u=d.videoRef.current;if(!u)return;const N=dr(i.state.subtitleFontSize,rr||u.clientHeight||720);s.textContent=ur({...a,fontSize:N});const fe=()=>{const w=Number(i.state.subtitlePosition),se=isNaN(w)?0:Math.max(0,Math.min(100,w));return Math.max(0,Math.min(100,100-se))},X=(w,se)=>{try{const ae=w;ae.snapToLines=!1,ae.line=se}catch{}},j=()=>{const w=N*16,se=u.videoHeight||u.clientHeight||720,ae=u.videoWidth||u.clientWidth||1280;return{step:w*1.3/se*100,chars:Math.max(20,Math.floor(ae/(w*.55)))}},ie=w=>{const se=fe(),ae=Array.from(w.activeCues??[]);if(ae.length<=1){ae.forEach(gt=>X(gt,se));return}const{step:bt,chars:Wt}=j();let ir=se;for(let gt=ae.length-1;gt>=0;gt--){const xr=String(ae[gt].text??"").replace(/<[^>]*>/g,"").split(`
55
+ `).reduce((Pr,Ar)=>Pr+Math.max(1,Math.ceil(Ar.length/Wt)),0),ar=ir-xr*bt;X(ae[gt],Math.max(0,ar)),ir=ar-bt*.4}},ce=w=>{if(!w.cues)return;const se=fe();Array.from(w.cues).forEach(ae=>X(ae,se)),w.mode==="showing"&&ie(w)},Se=()=>{Array.from(u.textTracks).forEach(ce)};Se();const re=w=>{const se=w.target;se.mode==="showing"&&ie(se)};Array.from(u.textTracks).forEach(w=>{w.addEventListener("cuechange",re)});const Me=()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re),w.addEventListener("cuechange",re)}),Se()};u.textTracks.addEventListener("addtrack",Me),u.textTracks.addEventListener("removetrack",Me);const he=Array.from(u.querySelectorAll("track")),ne=()=>{Se()};return he.forEach(w=>{w.addEventListener("load",ne)}),()=>{Array.from(u.textTracks).forEach(w=>{w.removeEventListener("cuechange",re)}),u.textTracks.removeEventListener("addtrack",Me),u.textTracks.removeEventListener("removetrack",Me),he.forEach(w=>{w.removeEventListener("load",ne)})}},[i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold,i.state.activeSubtitleTrack,i.state.availableSubtitles,e.selectedSource,e.selectedLink,d.videoRef,rr]),B(()=>{if(!dt)return;const t=d.videoRef.current,s=Ue.current;if(!t||!s)return;const a=localStorage.getItem("playerSubtitlesEnabled")!=="false",u=i.state.activeSubtitleTrack;function N(){if(s.innerHTML="",!a||u==="off"||u===null)return;const j=Array.from(t.textTracks).find(ne=>ne.language===u||ne.label===u);if(!j||j.mode!=="showing")return;const ie=xe/1e3;let ce;if(ie>0&&j.cues){const ne=t.currentTime-ie;ce=Array.from(j.cues).filter(w=>w.startTime<=ne&&ne<=w.endTime)}else ce=Array.from(j.activeCues??[]);if(ce.length===0)return;const Se={fontSize:dr(i.state.subtitleFontSize,t.clientHeight||0),position:i.state.subtitlePosition,bgOpacity:i.state.subtitleBgOpacity,bgColor:i.state.subtitleBgColor,textColor:i.state.subtitleTextColor,edge:i.state.subtitleEdge,bold:i.state.subtitleBold},re=pn(Se),Me=mn(t,Se.position),he=Array.from(ce);he.forEach((ne,w)=>{const se=String(ne.text??"");if(!fn(se).trim())return;const ae=document.createElement("div"),bt=(he.length-1-w)*1.7;ae.style.cssText=`${re}
56
+ bottom: calc(${Me}px + ${bt}em);`,ae.innerHTML=hn(se),s.appendChild(ae)})}const fe=()=>N(),X=()=>N();return Array.from(t.textTracks).forEach(j=>{j.addEventListener("cuechange",fe)}),t.addEventListener("timeupdate",X),N(),()=>{Array.from(t.textTracks).forEach(j=>{j.removeEventListener("cuechange",fe)}),t.removeEventListener("timeupdate",X),s.innerHTML=""}},[_.isEnabled,_.isWebGPUSupported,i.state.subtitleFontSize,i.state.subtitlePosition,i.state.subtitleBgOpacity,i.state.subtitleBgColor,i.state.subtitleTextColor,i.state.subtitleEdge,i.state.subtitleBold,i.state.activeSubtitleTrack,d.videoRef,dt,xe]),B(()=>{try{localStorage.setItem("anime4kProfile",y)}catch{}},[y]);const Tr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=e.resumeTime,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},kr=()=>{d.videoRef.current&&(d.videoRef.current.currentTime=0,d.videoRef.current.play()),o({type:"SET_STATE",payload:{showResumeModal:!1}})},Kt=K(()=>{Xe&&(je.current=!0),Bt&&He(!1),o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,Xe,Bt]),Cr=K(()=>{if(He(!1),d.videoRef.current)try{d.videoRef.current.currentTime=0,d.videoRef.current.play().catch(()=>{})}catch{}o({type:"SET_STATE",payload:{showResumeModal:!1}})},[o,d]),Rr=K(async()=>{try{await b(),o({type:"SET_STATE",payload:{showResumeModal:!1}}),m("/")}catch{}},[b,o,m]),nr=(t,s)=>r("div",{className:t,children:[r("button",{className:`${p.episodeNavBtn} ${p.secondary}`,onClick:yr,disabled:!vt,type:"button",children:[r(Z,{name:"chevron-left",size:12}),"Prev EP"]}),r("button",{className:`${p.episodeNavBtn} ${p.primary}`,onClick:Rt,disabled:!Re,type:"button",children:["Next EP",r(Z,{name:"chevron-right",size:12})]}),s==="mobile"&&Be&&r("button",{className:`${p.episodeNavBtn} ${p.episodePickerBtn}`,onClick:()=>Et(!0),type:"button",children:[r(Z,{name:"list-ul",size:12}),"Episodes"]})]});B(()=>{Ke&&(e.showResumeModal||E.length>0||Q||je.current||Xe&&o({type:"SET_STATE",payload:{showResumeModal:!0}}))},[Ke,Xe,e.showResumeModal,E.length,Q,o]);const Mr=t=>{o({type:"SET_STATE",payload:{isAutoplayEnabled:t}}),kn(t)},sr=!!(e.currentEpisode&&e.watchedEpisodes.includes(e.currentEpisode)),_r=e.selectedProvider!=="megaplay"||e.selectedSource?.type==="iframe",Ht=f(L);Ht.current=L;const or=f("");B(()=>{const t=d.videoRef.current;if(le(!1),He(!1),!t||e.selectedSource?.type==="iframe")return;const s=()=>{const a=t.duration,u=t.currentTime;if(!a||Number.isNaN(a)){le(!1),He(!1);return}const N=u/a;if(a-u<=60){const fe=E.findIndex(ie=>Ct(ie,n,e.showMeta?.id)&&ie.episodeNumber===e.currentEpisode),X=E.length>0?fe>=0?E[fe+1]||null:E[0]:null,j=X?`${X.showId}:${X.episodeNumber}`:Ut?`${n}:${Re}`:"";j&&or.current!==j&&(or.current=j,X?Ht.current(X.episodeNumber,X.showId):Ht.current(Re))}le(Ut&&N>=.8),He(u>=Math.max(a*.98,a-10))};return s(),t.addEventListener("timeupdate",s),t.addEventListener("loadedmetadata",s),()=>{t.removeEventListener("timeupdate",s),t.removeEventListener("loadedmetadata",s)}},[d.videoRef,Ut,e.currentEpisode,e.selectedSource,Re,n,E,e.showMeta?.id]);const Nr=K(async()=>{if(!n||!e.currentEpisode||!e.showMeta.name||V)return;const t=d.videoRef.current?.duration,s=Math.max(t||0,e.resumeDuration||0,(e.showMeta.lengthMin||0)*60,1);await U(e.currentEpisode,s)},[n,e.currentEpisode,e.showMeta,e.resumeDuration,U,V,d.videoRef]);if(e.error&&!e.showMeta.name&&e.videoSources.length===0&&e.episodes.length===0)return r("p",{className:"error-message",children:["Error: ",e.error]});const Qe=e.loadingShowData||e.loadingVideo;return e.showMeta?.isAdult===!0&&!S?r("div",{className:Fe.playerPageLayout,children:r($e,{isOpen:!0,title:"Content Warning",onClose:()=>m("/home"),children:r("div",{style:{padding:"1rem",textAlign:"center"},children:[r("p",{children:"This title contains mature content intended for adult audiences."}),r("p",{children:["By proceeding, you confirm that you are ",r("strong",{children:"18 years of age or older"})," (or the age of majority in your jurisdiction) and wish to view this content."]}),r("div",{style:{marginTop:"1rem",display:"flex",gap:"10px",justifyContent:"center"},children:[r(it,{variant:"secondary",onClick:()=>m("/home"),children:"Go Back"}),r(it,{onClick:g,children:"I'm 18+, Continue"})]})]})})}):r("div",{className:`${Fe.playerPageLayout} ${z?Fe.theaterMode:""}`,onClick:kt,children:[z&&r(vn,{videoRef:d.videoRef,active:Er,settings:zt}),r($e,{isOpen:qt&&Xe,onClose:Kt,title:"Show Completed!",width:"sm",children:[r($e.Body,{children:r("p",{children:"Congratulations! You've finished the final episode of this series."})}),r($e.Actions,{children:r(it,{onClick:Rr,disabled:Ae,children:Ae?"Saving...":"Move to Completed"})})]}),r(bn,{isOpen:qt&&!Xe,onClose:Kt,title:"Resume Playback?",message:r(Mt,{children:["You were watching at ",r("strong",{children:i.actions.formatTime(e.resumeTime)}),". Would you like to continue?"]}),onResume:Tr,onRestart:kr}),r($e,{isOpen:Bt,onClose:Kt,title:"Episode Completed",width:"sm",children:[r($e.Body,{children:r("p",{children:["You've already watched Episode ",r("strong",{children:e.currentEpisode}),".",Re?" Would you like to watch the next episode?":""]})}),r($e.Actions,{children:[r(it,{variant:"secondary",onClick:Cr,children:"Replay"}),Re&&r(it,{onClick:Rt,children:`Watch EP ${Re}`})]})]}),r($e,{isOpen:!!et,onClose:vr,title:"Direct stream failed",width:"sm",children:[r($e.Body,{children:[r("p",{children:[r("strong",{children:e.selectedProvider}),"'s direct stream failed for this episode."]}),et?.retryFailed&&r("p",{children:"No working direct stream was found on the other providers either."}),r("p",{children:["You can continue with the embedded (iframe) player, but embedded players may show"," ",r("strong",{children:"ads and pop-ups"}),"."]}),r("label",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"0.75rem",cursor:"pointer"},children:[r("input",{type:"checkbox",checked:qe,onChange:t=>wt(t.target.checked)}),"Remember my choice"]})]}),r($e.Actions,{children:[r(it,{variant:"secondary",onClick:br,children:"Continue with iframe"}),r(it,{onClick:gr,disabled:mt,children:mt?"Searching…":"Try another provider"})]})]}),r(jr,{isOpen:!!e.showCookieModal,onClose:()=>o({type:"SET_STATE",payload:{showCookieModal:!1}}),onSuccess:()=>{D.invalidateQueries({queryKey:["video-sources",n,e.currentEpisode,e.selectedProvider,e.currentMode]})}}),!z&&r("aside",{ref:_e,className:Fe.episodeSidebar,children:e.loadingShowData?r(gn,{variant:"sidebar"}):r(yn,{episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>m(`/watch/${n}/${t}`)})}),r("div",{className:Fe.playerMain,children:[r("div",{className:`${p.videoContainer} ${i.state.isFullscreen?"":Fe.videoPlayerWrapper} ${i.state.isFullscreen?p.fullscreenActive:""}`,style:{...st?{visibility:"hidden"}:{}},onContextMenu:t=>t.preventDefault(),children:r(Ss,{player:i,isAutoplayEnabled:e.isAutoplayEnabled,onAutoplayChange:Mr,fallbackChoice:tt,onFallbackChoiceChange:rt,ambientSettings:zt,onAmbientChange:Sr,showNextEpisodeButton:!st&&pt&&E.length===0,onNextEpisode:Rt,videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:(t,s)=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime),P(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:s,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},loadingVideo:Qe,skipIntervals:e.skipIntervals,animeTitle:ot,episodeNumber:e.currentEpisode,isTheaterMode:z,onTheaterModeToggle:Tt,anime4kEnabled:_.isEnabled,onAnime4kToggle:_.toggle,anime4kSupported:_.isWebGPUSupported,anime4kProfile:y,onAnime4kProfileChange:v,anime4kInitializing:_.isInitializing,anime4kError:_.error,videoDelayEnabled:R,onVideoDelayToggle:q,videoDelayMs:I,onVideoDelayChange:ye,onCalibrateAvSync:Le,isInteractingExtra:Nt||Y,className:Sn.shellFill,hideChrome:e.selectedSource?.type==="iframe",overlays:r(Mt,{children:[i.state.isSpeedBoostActive&&r("div",{className:p.speedBoostBadge,"aria-hidden":"true",children:[r("span",{children:"2x"}),r(Z,{name:"forward",size:12})]}),M!==null&&Q?.nextItem&&r("div",{className:p.queueCountdown,children:["Queue next in ",M,"s"]})]}),children:[Qe&&r("div",{className:p.loadingOverlay,children:r("div",{className:p.loadingDots,children:[r("div",{className:p.dot}),r("div",{className:p.dot}),r("div",{className:p.dot})]})}),i.state.isBuffering&&!Qe&&e.selectedSource?.type!=="iframe"&&r("div",{className:p.bufferingOverlay,children:r("div",{className:p.bufferingSpinner})}),e.selectedSource?.type==="iframe"?!Qe&&r("iframe",{src:e.selectedLink?.link,className:p.videoIframe,allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,sandbox:e.selectedSource.sandbox?`${e.selectedSource.sandbox} allow-fullscreen allow-popups allow-popups-to-escape-sandbox`:void 0}):r(Mt,{children:[!Qe&&e.videoSources.length===0&&r("div",{className:p.errorOverlay,children:[r("p",{children:["No sources found for this episode with ",e.selectedProvider,"."]}),r("p",{className:p.errorSubtext,children:"Please try selecting a different provider below."}),r("button",{className:p.retryButton,onClick:()=>window.location.reload(),"data-speed-boost-ignore":"true",style:{marginTop:8},children:"Retry"})]}),!Qe&&e.videoSources.length>0&&r("video",{ref:d.videoRef,controls:i.state.useNativeControls,playsInline:!0,"webkit-playsinline":"true",disablePictureInPicture:!0,disableRemotePlayback:!0,onPlay:k.onPlay,onPause:k.onPause,onLoadedMetadata:k.onLoadedMetadata,onTimeUpdate:()=>{G||(k.onTimeUpdate(),Q&&d.videoRef.current&&d.videoRef.current.currentTime<d.videoRef.current.duration-1&&(ge(null),Ie(null)))},onProgress:k.onProgress,onVolumeChange:k.onVolumeChange,onWaiting:k.onWaiting,onPlaying:k.onPlaying,onCanPlay:k.onCanPlay,onError:Jt,onContextMenu:t=>t.preventDefault(),className:dt?p.videoElementHidden:""}),_.isWebGPUSupported&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:Ne,className:`${p.upscalerCanvas} ${F?p.upscalerActive:""}`}),!F&&!Qe&&e.videoSources.length>0&&r("canvas",{ref:lt,className:`${p.upscalerCanvas} ${ut?p.upscalerActive:""}`}),_.isEnabled&&_.isWebGPUSupported&&_.isInitializing&&r("div",{className:p.upscalerStatusBadge,children:"Preparing upscaler…"}),dt&&r("div",{ref:Ue,className:p.subtitleOverlay}),r(En,{isOpen:Y,ms:I,onChange:ye,onApply:Ze,onClose:yt,testClipActive:G,onTestClip:St})]})]})}),!z&&r(wn,{}),!z&&r(Mt,{children:[Ce&&E.length===0?r(Es,{count:3}):r(Mn,{title:"Queue",items:E,currentShowId:n,currentEpisode:e.currentEpisode,onNextQueue:Qt,onRemove:t=>me.mutate({showId:t.showId,episodeNumber:t.episodeNumber}),onClear:()=>ht.mutate(),showClearAll:!0,onReorder:t=>Pe.mutate(t.map(s=>({id:s.id,showId:s.showId,episodeNumber:s.episodeNumber})))}),r("div",{className:p.providerAndEpisodeRow,children:[r(Ns,{selectedProvider:e.selectedProvider,isAdult:e.showMeta?.isAdult,options:x,onProviderChange:t=>{De.current=!1,ee.current=[],Ye.current=!1,be(null),o({type:"SET_STATE",payload:{selectedProvider:t,videoSources:[],selectedSource:null,selectedLink:null,loadingVideo:!0}}),localStorage.setItem("preferredProvider",t)}}),nr(`${p.episodeActions} ${p.desktopEpisodeActions}`,"desktop")]}),Qe?r("div",{className:p.sourceLoader,children:r("div",{className:p.spinner})}):r(Mt,{children:r(Ps,{videoSources:e.videoSources,selectedSource:e.selectedSource,selectedLink:e.selectedLink,onSourceChange:t=>{d.videoRef.current&&!isNaN(d.videoRef.current.currentTime)&&(oe.current=d.videoRef.current.currentTime);const a=(t.links||[]).sort((u,N)=>(parseInt(N.resolutionStr)||0)-(parseInt(u.resolutionStr)||0))[0]||null;P(t.sourceName),o({type:"SET_STATE",payload:{selectedSource:t,selectedLink:a,showResumeModal:e.showResumeModal&&t.type!=="iframe"}})},onLinkChange:t=>{e.selectedSource&&(P(e.selectedSource.sourceName),o({type:"SET_STATE",payload:{selectedLink:t}}))}})}),r("div",{className:Fe.playerInfoContainer,children:[r("div",{className:Fe.playerInfoHeader,children:[r("div",{className:Fe.playerAnimeCard,children:r("img",{src:Yr(e.showMeta.thumbnail||""),alt:ot,loading:"lazy",decoding:"async",onError:t=>{t.target.src="/placeholder.svg"}})}),r("div",{className:Fe.videoTitleSection,children:[r("div",{className:p.titleContainer,children:[r("h1",{children:ot}),r("div",{className:p.scheduleInfo,children:[e.showMeta.status&&r("span",{className:p.status,children:e.showMeta.status}),e.showMeta.nextEpisodeAirDate&&r("span",{className:p.nextEpisode,children:["Next episode: ",e.showMeta.nextEpisodeAirDate]})]})]}),r("div",{className:p.controls,children:[r("button",{className:`${p.watchlistBtn} ${e.inWatchlist?p.inList:""}`,onClick:J,children:[e.inWatchlist?r(Z,{name:"check",size:14}):r(Z,{name:"plus",size:14}),e.inWatchlist?"In Watchlist":"Add to Watchlist"]}),r(Nn,{showId:n,showName:e.showMeta.name||e.showMeta.names?.romaji,showThumbnail:e.showMeta.thumbnail,nativeName:e.showMeta.names?.native,englishName:e.showMeta.names?.english,showType:e.showMeta.type,className:`${p.watchlistBtn} ${p.queueBtn}`,activeClassName:p.queueActive}),_r&&r("button",{className:`${p.watchlistBtn} ${p.markWatchedBtn} ${sr?p.markWatchedDone:""}`,onClick:Nr,disabled:V||!e.currentEpisode,children:[r(Z,{name:"check",size:14}),V?"Saving...":sr?"Watched":"Mark Watched"]}),r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${e.currentMode==="dub"?p.modeToggleActive:""}`,onClick:()=>{const t=e.currentMode==="dub"?"sub":"dub";De.current=!1,ee.current=[],Ye.current=!1,be(null),o({type:"SET_MODE",payload:t}),localStorage.setItem("preferredMode",t)},type:"button","aria-pressed":e.currentMode==="dub",children:e.currentMode==="dub"?"DUB":"SUB"}),er&&r("button",{className:`${p.watchlistBtn} ${p.modeToggleBtn} ${i.state.useNativeControls?p.modeToggleActive:""}`,onClick:()=>{const t=!i.state.useNativeControls;i.actions.setUseNativeControls(t),localStorage.setItem("playerUseNativeControls",t.toString())},type:"button",children:i.state.useNativeControls?"NATIVE: ON":"NATIVE: OFF"})]})]})]}),nr(`${p.episodeActions} ${p.mobileEpisodeActions}`,"mobile"),r("div",{className:p.descriptionSection,children:[r("h3",{children:"Synopsis"}),r(Pn,{text:e.showMeta.description?e.showMeta.description.replace(/<[^>]*>?/gm,""):"",emptyText:"No description available."})]}),r("button",{className:p.detailsToggleBtn,onClick:de,children:[e.showCombinedDetails?r(Z,{name:"chevron-up"}):r(Z,{name:"chevron-down"}),e.showCombinedDetails?"Hide Details":"Show Details"]}),e.showCombinedDetails&&r(xn,{showMeta:e.showMeta,styles:p})]})]})]}),r(Tn,{isOpen:Nt,onClose:()=>Et(!1),episodes:e.episodes,currentEpisode:e.currentEpisode,watchedEpisodes:e.watchedEpisodes,onEpisodeClick:t=>{Et(!1),m(`/watch/${n}/${t}`)}})]})};export{lo as default};
@@ -1 +1 @@
1
- import{g as z,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-B3xlVT-D.js";import{u as re}from"./index-Dyiy_9L6.js";import"./AvSyncCalibrator-jI6WLW45.js";import"./vendor-query-BBT5_sHx.js";const ce="_settingsPanel_y6z3b_1",oe="_header_y6z3b_33",de="_backBtn_y6z3b_56",me="_contentWrapper_y6z3b_76",ue="_menuContent_y6z3b_82",he="_menuItem_y6z3b_89",pe="_selected_y6z3b_114",be="_currentValue_y6z3b_134",ye="_menuNote_y6z3b_141",ge="_menuError_y6z3b_150",n={settingsPanel:ce,header:oe,backBtn:de,contentWrapper:me,menuContent:ue,menuItem:he,selected:pe,currentValue:be,menuNote:ye,menuError:ge},ve=(w,$)=>{const{isOpen:y,onClose:ke,videoSources:Ce,currentSource:C,currentLink:N,onSourceChange:P,subtitles:V,activeSubtitleTrack:g,onSubtitleChange:O,subtitleSettings:E,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:f,anime4kProfile:r,onAnime4kProfileChange:h,anime4kInitializing:L,anime4kError:S,videoDelayEnabled:_,onVideoDelayToggle:M,videoDelayMs:I,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:d,onAutoSkipChange:W,isAutoplayEnabled:m,onAutoplayChange:G,fallbackChoice:p,onFallbackChoiceChange:j,isTheaterMode:q,ambientSettings:b,onAmbientChange:k}=w,{lowEndMode:F}=re(),[a,i]=ne("main");z.useEffect(()=>{if(!y){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[y]);const Q=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>i("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:N?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:g||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),F&&e("button",{className:`${n.menuItem} ${v?n.selected:""}`,onClick:()=>{const t=!v;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),f&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),f&&u&&e("button",{className:n.menuItem,onClick:()=>i("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>i("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:_?`${I}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[d?"Auto-skip On":null,m?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]}),q&&b&&k&&e("button",{className:n.menuItem,onClick:()=>i("ambient"),children:[e("span",{children:"Ambient Light"}),e("span",{className:n.currentValue,children:b.enabled?"On":"Off"})]})]}),R=()=>{const t=C?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:N?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&P(C,c)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:g==="off"},...V.map(t=>({key:t.label||t.lang,label:t.label,selected:g===(t.label||t.lang)}))],onSelect:t=>O(t)})}),K=()=>e("div",{className:n.menuContent,children:e(se,{classes:{item:n.menuItem,active:n.selected},values:E,onChange:T})}),J=te(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),X=()=>e("div",{className:n.menuContent,children:[L&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),S&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",S]}),!J&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${r==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),r==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),r==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),r==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),r==="denoise"&&e(o,{name:"check",size:12})]})]}),Y=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>W(!d),"aria-pressed":d,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>G(!m),"aria-pressed":m,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>j(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),Z=()=>e("div",{className:n.menuContent,children:e(le,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&k?e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:k})}):null;return y?e(ae,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>i("main"),panelRef:$,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&Q(),a==="quality"&&R(),a==="subtitles"&&H(),a==="subtitle-style"&&K(),a==="upscaler"&&X(),a==="av-sync"&&Z(),a==="playback"&&Y(),a==="ambient"&&ee()]}):null},ze=z.forwardRef(ve);export{ze as default};
1
+ import{g as z,d as ne,T as te,u as e}from"./vendor-core-DfaOB3Rn.js";import{I as o}from"./vendor-icons-DrybRNxP.js";import{S as ae,O as A,a as se,A as le,b as ie}from"./OptionListMenu-AHGTsUIM.js";import{u as re}from"./index-BGCpLf49.js";import"./AvSyncCalibrator-DH6KEsbi.js";import"./vendor-query-BBT5_sHx.js";const ce="_settingsPanel_y6z3b_1",oe="_header_y6z3b_33",de="_backBtn_y6z3b_56",me="_contentWrapper_y6z3b_76",ue="_menuContent_y6z3b_82",he="_menuItem_y6z3b_89",pe="_selected_y6z3b_114",be="_currentValue_y6z3b_134",ye="_menuNote_y6z3b_141",ge="_menuError_y6z3b_150",n={settingsPanel:ce,header:oe,backBtn:de,contentWrapper:me,menuContent:ue,menuItem:he,selected:pe,currentValue:be,menuNote:ye,menuError:ge},ve=(w,$)=>{const{isOpen:y,onClose:ke,videoSources:Ce,currentSource:C,currentLink:N,onSourceChange:P,subtitles:V,activeSubtitleTrack:g,onSubtitleChange:O,subtitleSettings:E,onSubtitleSettingsChange:T,useNativeControls:v,onNativeControlsToggle:U,anime4kEnabled:u,onAnime4kToggle:B,anime4kSupported:f,anime4kProfile:r,onAnime4kProfileChange:h,anime4kInitializing:L,anime4kError:S,videoDelayEnabled:_,onVideoDelayToggle:M,videoDelayMs:I,onVideoDelayChange:D,onCalibrateAvSync:x,isAutoSkipEnabled:d,onAutoSkipChange:W,isAutoplayEnabled:m,onAutoplayChange:G,fallbackChoice:p,onFallbackChoiceChange:j,isTheaterMode:q,ambientSettings:b,onAmbientChange:k}=w,{lowEndMode:F}=re(),[a,i]=ne("main");z.useEffect(()=>{if(!y){const t=setTimeout(()=>i("main"),300);return()=>clearTimeout(t)}},[y]);const Q=()=>e("div",{className:n.menuContent,children:[e("button",{className:n.menuItem,onClick:()=>i("quality"),children:[e("span",{children:"Quality"}),e("span",{className:n.currentValue,children:N?.resolutionStr||"Auto"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitles"),children:[e("span",{children:"Subtitles"}),e("span",{className:n.currentValue,children:g||"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("subtitle-style"),children:e("span",{children:"Subtitle Style"})}),F&&e("button",{className:`${n.menuItem} ${v?n.selected:""}`,onClick:()=>{const t=!v;U(t),localStorage.setItem("playerUseNativeControls",t.toString())},children:[e("span",{children:"Native Controls"}),v&&e(o,{name:"check",size:12})]}),f&&e("button",{className:`${n.menuItem} ${u?n.selected:""}`,onClick:()=>{B(!u)},children:[e("span",{children:"Anime4K Upscaler"}),u&&e(o,{name:"check",size:12})]}),f&&u&&e("button",{className:n.menuItem,onClick:()=>i("upscaler"),children:e("span",{children:"Upscaler Settings"})}),e("button",{className:n.menuItem,onClick:()=>i("av-sync"),children:[e("span",{children:"A/V Sync"}),e("span",{className:n.currentValue,children:_?`${I}ms`:"Off"})]}),e("button",{className:n.menuItem,onClick:()=>i("playback"),children:[e("span",{children:"Playback"}),e("span",{className:n.currentValue,children:[d?"Auto-skip On":null,m?"Autoplay On":null].filter(Boolean).join(" • ")||"Off"})]}),q&&b&&k&&e("button",{className:n.menuItem,onClick:()=>i("ambient"),children:[e("span",{children:"Ambient Light"}),e("span",{className:n.currentValue,children:b.enabled?"On":"Off"})]})]}),R=()=>{const t=C?.links.sort((s,c)=>(parseInt(c.resolutionStr)||0)-(parseInt(s.resolutionStr)||0))||[];return e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:t.map(s=>({key:s.resolutionStr,label:s.resolutionStr,selected:N?.resolutionStr===s.resolutionStr})),onSelect:s=>{const c=t.find(l=>l.resolutionStr===s);c&&P(C,c)}})})},H=()=>e("div",{className:n.menuContent,children:e(A,{classes:{item:n.menuItem,active:n.selected},options:[{key:"off",label:"Off",selected:g==="off"},...V.map(t=>({key:t.label||t.lang,label:t.label,selected:g===(t.label||t.lang)}))],onSelect:t=>O(t)})}),K=()=>e("div",{className:n.menuContent,children:e(se,{classes:{item:n.menuItem,active:n.selected},values:E,onChange:T})}),J=te(()=>{try{const s=navigator.userAgentData?.brands?.map(l=>l.brand.toLowerCase())??[];if(s.length>0)return s.some(l=>l.includes("chromium")||l.includes("chrome")||l.includes("edge")||l.includes("opera")||l.includes("brave")||l.includes("vivaldi"));const c=navigator.userAgent.toLowerCase();return c.includes("chrome")||c.includes("chromium")||c.includes("edg")}catch{return!0}},[]),X=()=>e("div",{className:n.menuContent,children:[L&&e("div",{className:n.menuNote,role:"status",children:"Preparing GPU, this can take a few seconds…"}),S&&e("div",{className:n.menuError,role:"alert",children:["Upscaler failed: ",S]}),!J&&e("div",{className:n.menuNote,children:"Upscaling performs best in Chrome-based browsers."}),e("button",{className:`${n.menuItem} ${r==="low"?n.selected:""}`,onClick:()=>h("low"),children:[e("div",{children:[e("div",{children:"Low"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Lightest, best for weaker GPUs"})]}),r==="low"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="balanced"?n.selected:""}`,onClick:()=>h("balanced"),children:[e("div",{children:[e("div",{children:"Balanced"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Source + display aware"})]}),r==="balanced"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="high"?n.selected:""}`,onClick:()=>h("high"),children:[e("div",{children:[e("div",{children:"High"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Aggressive, needs strong GPU"})]}),r==="high"&&e(o,{name:"check",size:12})]}),e("button",{className:`${n.menuItem} ${r==="denoise"?n.selected:""}`,onClick:()=>h("denoise"),children:[e("div",{children:[e("div",{children:"Denoise"}),e("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Denoise + upscale noisy, compressed sources"})]}),r==="denoise"&&e(o,{name:"check",size:12})]})]}),Y=()=>e("div",{className:n.menuContent,children:[e("button",{type:"button",className:`${n.menuItem} ${d?n.selected:""}`,onClick:()=>W(!d),"aria-pressed":d,children:[e("span",{children:"Auto-skip openings and endings"}),e("span",{className:n.currentValue,children:d?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically jump past opening, ending and recap segments when detected."}),e("button",{type:"button",className:`${n.menuItem} ${m?n.selected:""}`,onClick:()=>G(!m),"aria-pressed":m,children:[e("span",{children:"Autoplay next episode"}),e("span",{className:n.currentValue,children:m?"On":"Off"})]}),e("div",{className:n.menuNote,children:"Automatically start the next episode when this one ends."}),e("button",{type:"button",className:n.menuItem,onClick:()=>j(p==="ask"?"iframe":p==="iframe"?"retry":"ask"),children:[e("span",{children:"Failed direct stream"}),e("span",{className:n.currentValue,children:p==="iframe"?"Use iframe":p==="retry"?"Try provider":"Ask me"})]}),e("div",{className:n.menuNote,children:"When a direct stream fails: ask each time, go straight to the embedded player (may show ads), or automatically try another provider."})]}),Z=()=>e("div",{className:n.menuContent,children:e(le,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},enabled:_,delayMs:I,onToggle:M,onDelayChange:D,onCalibrate:x})}),ee=()=>b&&k?e("div",{className:n.menuContent,children:e(ie,{classes:{item:n.menuItem,active:n.selected,note:n.menuNote},values:b,onChange:k})}):null;return y?e(ae,{classes:{panel:n.settingsPanel,header:n.header,backBtn:n.backBtn,title:"",content:n.contentWrapper},title:a==="main"?"Settings":a==="ambient"?"Ambient Light":a.charAt(0).toUpperCase()+a.slice(1).replace("-"," "),titleTag:"h3",showBack:a!=="main",onBack:()=>i("main"),panelRef:$,onPanelClick:t=>t.stopPropagation(),children:[a==="main"&&Q(),a==="quality"&&R(),a==="subtitles"&&H(),a==="subtitle-style"&&K(),a==="upscaler"&&X(),a==="av-sync"&&Z(),a==="playback"&&Y(),a==="ambient"&&ee()]}):null},ze=z.forwardRef(ve);export{ze as default};
@@ -0,0 +1 @@
1
+ import{b as F}from"./vendor-query-BBT5_sHx.js";import{t as T,l as j,Z as H,$ as J,a0 as W}from"./index-BGCpLf49.js";import{d as X,T as R,q as r,u as t,$ as Y,S as w}from"./vendor-core-DfaOB3Rn.js";import{a as ee,c as te,d as ne,b as se,o as oe,f as ae,s as ie}from"./vendor-ui-3qrARCPr.js";import{I as u}from"./vendor-icons-DrybRNxP.js";function Pe(n){return F({queryKey:["show-meta",n],queryFn:async()=>n?T.data.showMeta.query({id:n}):{},enabled:!!n,staleTime:3e4})}async function re(n){try{return await T.watchlist.queueSuggested.query({showId:n})}catch{throw new Error("Failed to resolve suggested episode")}}const ue="_trigger_1vova_6",le="_triggerBtn_1vova_11",me="_chevron_1vova_25",ce="_menu_1vova_34",de="_menuTitle_1vova_51",pe="_menuItem_1vova_60",ge="_removeItem_1vova_91",fe="_menuEmpty_1vova_99",a={trigger:ue,triggerBtn:le,chevron:me,menu:ce,menuTitle:de,menuItem:pe,removeItem:ge,menuEmpty:fe},ve=8,qe=({showId:n,showName:v,showThumbnail:h,nativeName:y,englishName:_,showType:b,className:z="",activeClassName:A="",align:D="right",onMenuOpenChange:p})=>{const{data:E=[]}=j(),P=H(),q=J(),[l,f]=X(!1),{refs:Q,floatingStyles:M,context:S}=ee({open:l,onOpenChange:e=>{e||(f(!1),p?.(!1))},placement:D==="left"?"bottom-start":"bottom-end",middleware:[oe(ve),ae({padding:8}),ie({padding:8})],whileElementsMounted:se}),x=te(S,{outsidePress:!0,escapeKey:!0,referencePress:!1}),{getReferenceProps:C,getFloatingProps:I}=ne([x]),m=R(()=>E.filter(e=>e.showId===n),[E,n]),{data:K}=F({queryKey:["suggestedEpisode",n],queryFn:()=>re(n),enabled:!!n}),{data:$,isFetching:N}=W(n,l),s=R(()=>$?.episodes||[],[$]),k=r(()=>{f(!0),p?.(!0)},[p]),c=r(()=>{f(!1),p?.(!1)},[p]),d=m.length>0,o=s.length>0,g=K?.episodeNumber,i=r(e=>{!n||e.length===0||(P.mutate({showId:n,episodeNumbers:e,showName:v,showThumbnail:h,nativeName:y,englishName:_,type:b}),c())},[n,v,h,y,_,b,P,c]),L=r(()=>{!n||m.length===0||(q.mutate({showId:n,episodeNumbers:m.map(e=>e.episodeNumber)}),c())},[n,m,q,c]),O=r(()=>{o?i([s[0]]):g&&i([String(g)])},[o,s,g,i]),U=r(()=>{o&&i(s.slice(0,3))},[o,s,i]),G=r(()=>{o&&i([...s])},[o,s,i]),B=s[0],V=s[Math.min(2,s.length-1)],Z=t("div",{className:a.trigger,ref:Q.setReference,children:t("span",{className:`${a.triggerBtn} ${z} ${d?A:""}`,role:"button",tabIndex:0,"aria-haspopup":"menu","aria-expanded":l,"aria-label":d?"Queued":"Queue",...C(),onClick:e=>{e.preventDefault(),e.stopPropagation(),l?c():k()},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),l?c():k())},children:[d?t(u,{name:"check",size:14}):t(u,{name:"plus",size:14}),d?"Queued":"Queue",t(u,{name:"chevron-down",size:10,className:a.chevron})]})});return t(w,{children:[Z,l&&Y(t("div",{ref:Q.setFloating,className:a.menu,style:M,role:"menu",...I(),onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[t("div",{className:a.menuTitle,children:"Queue episodes"}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o&&!g,onClick:e=>{e.stopPropagation(),O()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+1 — EP ${B}`:`+1 — EP ${g||"?"}`})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),U()},children:[t(u,{name:"plus",size:11}),t("span",{children:o?`+3 — EP ${B}${s.length>1?`-${V}`:""}`:"+3"})]}),t("button",{className:a.menuItem,role:"menuitem",type:"button",disabled:!o,onClick:e=>{e.stopPropagation(),G()},children:[t(u,{name:"plus",size:11}),t("span",{children:["All Remaining",N?"":` (${Math.max(s.length,0)})`]})]}),!N&&s.length===0&&t("div",{className:a.menuEmpty,children:d?"All episodes are already queued":"No remaining unwatched episodes"}),d&&t("button",{className:`${a.menuItem} ${a.removeItem}`,role:"menuitem",type:"button",onClick:e=>{e.stopPropagation(),L()},children:[t(u,{name:"times",size:11}),t("span",{children:["Remove from Queue",m.length>0?` (${m.length})`:""]})]})]}),document.body)]})};export{qe as Q,Pe as u};