@serifpersia/dango 3.5.0 → 3.5.2
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.
- package/README.md +1 -15
- package/client/dist/assets/{AnimeCard-CpMObnqU.js → AnimeCard-BVnAhrys.js} +1 -1
- package/client/dist/assets/{AnimeInfo-DkDW8o1k.js → AnimeInfo-DYBLIXmE.js} +1 -1
- package/client/dist/assets/AnimeInfoPage-DnXV4EMC.js +2 -0
- package/client/dist/assets/{Asmr-B08Aimrk.js → Asmr-Dwlv-Af8.js} +2 -2
- package/client/dist/assets/{AsmrResetProgressModal-CZMbyJZz.js → AsmrResetProgressModal-CnF9ZTJQ.js} +1 -1
- package/client/dist/assets/{AvSyncCalibrator-VoOEtoX9.js → AvSyncCalibrator-Cr9n1euF.js} +1 -1
- package/client/dist/assets/Home-B_q2l74h.css +1 -0
- package/client/dist/assets/{Home-C3Vck_99.js → Home-CUZPz_wy.js} +1 -1
- package/client/dist/assets/Insights-hvaO1jbY.js +1 -0
- package/client/dist/assets/{LibraryListPage-CUzEUs5k.js → LibraryListPage-BeYz_I1y.js} +1 -1
- package/client/dist/assets/{ListeningList-CoeQ17lz.js → ListeningList-D-D-W7JK.js} +1 -1
- package/client/dist/assets/Manga-DqIR2B6F.js +1 -0
- package/client/dist/assets/{MangaInfoPage-wqYZN_sT.js → MangaInfoPage-CWqxWbb3.js} +1 -1
- package/client/dist/assets/{MangaReadPage-BbyExwBN.js → MangaReadPage-BlyJ-OdY.js} +1 -1
- package/client/dist/assets/{MangaResetProgressModal-Dg0xhJQI.js → MangaResetProgressModal-gvz9_X7z.js} +1 -1
- package/client/dist/assets/{Mature-ZKR5vMIv.js → Mature-B1Cuj67a.js} +1 -1
- package/client/dist/assets/MediaCard-GwFTnacn.js +1 -0
- package/client/dist/assets/Music-BEmRDuSo.js +1 -0
- package/client/dist/assets/{OptionListMenu-DcHg1QsF.js → OptionListMenu-Dlk9eHM7.js} +1 -1
- package/client/dist/assets/{Player-V9IueAzT.js → Player-khTFa_o1.js} +6 -6
- package/client/dist/assets/{PlayerSettings-BZtjBWWq.js → PlayerSettings-B16FnAO_.js} +1 -1
- package/client/dist/assets/QueueOptionsButton-DjBOibpt.js +1 -0
- package/client/dist/assets/{QueueRail-CO2ocUNx.js → QueueRail-DcLtEU46.js} +1 -1
- package/client/dist/assets/{Radio-CJ-ra4vb.js → Radio-rpaFuI72.js} +1 -1
- package/client/dist/assets/{ReadingList-CSvUUtZ3.js → ReadingList-DTnI5411.js} +1 -1
- package/client/dist/assets/{ResetProgressModal-5FOWMuqi.js → ResetProgressModal-Bcv92v7c.js} +1 -1
- package/client/dist/assets/{Search-q0GUdNMS.js → Search-DNxPl_On.js} +1 -1
- package/client/dist/assets/Settings-CQ-ykTG3.js +21 -0
- package/client/dist/assets/{Settings-AuFxQcJF.css → Settings-CwIWLSfY.css} +1 -1
- package/client/dist/assets/{SkeletonGrid-DY_7CXpX.js → SkeletonGrid-ZN-kS9re.js} +1 -1
- package/client/dist/assets/ToggleSwitch-BPil0d_k.css +1 -0
- package/client/dist/assets/ToggleSwitch-CN_ppEc9.js +1 -0
- package/client/dist/assets/{Trackers-Dn7P6AfI.js → Trackers-EN1_ol5G.js} +1 -1
- package/client/dist/assets/{Tv-BfaWoR72.js → Tv-C-4wd-BS.js} +4 -4
- package/client/dist/assets/{TvInfo-CgEVN57T.js → TvInfo-Mpzun3PF.js} +1 -1
- package/client/dist/assets/{TvPopup-B-vYyDQF.js → TvPopup-YYgg9-7r.js} +1 -1
- package/client/dist/assets/{TvSearch-CnnVkms6.js → TvSearch-CdL9EA-S.js} +1 -1
- package/client/dist/assets/{TvWatchlist-BLVF_row.js → TvWatchlist-DD6nRESU.js} +1 -1
- package/client/dist/assets/{Watchlist-wd9cCDOK.js → Watchlist-CD8UqukO.js} +1 -1
- package/client/dist/assets/{hls-Bej65gvf.js → hls-E94cMCjR.js} +1 -1
- package/client/dist/assets/index-CZW1But9.js +178 -0
- package/client/dist/assets/index-w_r2lTCe.css +1 -0
- package/client/dist/assets/{useAnimeInfoData-ZmMruFBq.js → useAnimeInfoData-C9tOyy6E.js} +1 -1
- package/client/dist/assets/{useAsmr-z-txLq1s.js → useAsmr-B4HAapZD.js} +1 -1
- package/client/dist/assets/{useAsmrPopup-DU55UhPN.js → useAsmrPopup-trIV7nUr.js} +1 -1
- package/client/dist/assets/{useMangaLibrary-D92WQbf5.js → useMangaLibrary-CZ2Gke8p.js} +1 -1
- package/client/dist/assets/{useMangaPopup-TJOA229J.js → useMangaPopup-80Daa4y-.js} +1 -1
- package/client/dist/assets/{useProviders-fmZrOyDC.js → useProviders-CqMq_6ue.js} +1 -1
- package/client/dist/assets/{useTv-CmfxzpS-.js → useTv-CHDhiKWu.js} +1 -1
- package/client/dist/assets/{useTvLibrary-0y9NZnsk.js → useTvLibrary-DWUGDtld.js} +1 -1
- package/client/dist/index.html +2 -2
- package/package.json +2 -2
- package/server/dist/app-hono.js +2 -10
- package/server/dist/config.js +0 -1
- package/server/dist/db/schema-anime.js +0 -4
- package/server/dist/db/schema-asmr.js +0 -12
- package/server/dist/db/schema-tv.js +0 -15
- package/server/dist/discord-gateway.js +0 -6
- package/server/dist/discord-rpc.js +0 -14
- package/server/dist/github-sync.js +1 -5
- package/server/dist/hono/proxy.js +19 -2
- package/server/dist/hono/tv.js +1 -1
- package/server/dist/hono/watchlist.js +8 -13
- package/server/dist/lib/anilist.js +2 -26
- package/server/dist/lib/anischedule.js +0 -3
- package/server/dist/lib/mal.js +0 -9
- package/server/dist/lib/{discord-roles-sync.service.js → recommendations.service.js} +0 -149
- package/server/dist/lib/tracker/anilist-tracker.js +0 -3
- package/server/dist/lib/tracker/sync.service.js +0 -1
- package/server/dist/providers/manga/manga.types.js +1 -7
- package/server/dist/repositories/mal-cache.repository.js +0 -3
- package/server/dist/server.js +0 -2
- package/server/dist/shipped-defaults.js +0 -1
- package/server/dist/sync.js +0 -1
- package/server/dist/trpc/errors.js +0 -6
- package/server/dist/trpc/index.js +0 -1
- package/server/dist/trpc/routers/discord.js +0 -4
- package/server/dist/trpc/routers/discovery.js +1 -5
- package/server/dist/trpc/routers/insights.js +1 -31
- package/server/dist/trpc/routers/settings.js +0 -10
- package/server/dist/trpc/routers/watchlist.js +3 -3
- package/server/package.json +1 -1
- package/client/dist/assets/AnimeInfoPage-l0wIHS7j.js +0 -2
- package/client/dist/assets/Home-B6bte0tw.css +0 -1
- package/client/dist/assets/Insights-nW34Wbg1.js +0 -1
- package/client/dist/assets/Manga-CeSb5K2w.js +0 -1
- package/client/dist/assets/Map-BtXwpBOC.js +0 -1
- package/client/dist/assets/Map-CXFqXmsZ.css +0 -1
- package/client/dist/assets/MediaCard-9NGAjN3E.js +0 -1
- package/client/dist/assets/Music-CljVJFCj.js +0 -1
- package/client/dist/assets/QueueOptionsButton-CzzisJ3N.js +0 -1
- package/client/dist/assets/Settings-CyT9Lyhz.js +0 -21
- package/client/dist/assets/index-Cc1Up_NI.css +0 -1
- package/client/dist/assets/index-Dk0ASzEz.js +0 -178
- package/server/dist/sync-config.js +0 -23
- package/server/dist/utils/machine-id.js +0 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as T,u as e,S as ee,$ as Ee,d as x,h as K,A as M,q as d,N as Se,a as Ie,L as Re}from"./vendor-core-DfaOB3Rn.js";import{a as Ae,b as Le,f as $e,s as ke}from"./vendor-ui-3qrARCPr.js";import{u as te}from"./useIsMobile-Dvx1uJ82.js";import{I as v}from"./vendor-icons-DrybRNxP.js";import{t as Oe,d as ze,u as De,a as Ue,f as Ve,M as Ge,B as Q}from"./index-CZW1But9.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=te(),r=T.useMemo(()=>({getBoundingClientRect:()=>t}),[t]),{refs:w,floatingStyles:b}=Ae({placement:"right-start",middleware:[$e({fallbackAxisSideDirection:"start"}),ke({padding:20})],whileElementsMounted:Le});T.useEffect(()=>{w.setPositionReference(r)},[w,r]),T.useEffect(()=>{if(!i)return;const y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=y}},[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 Ee(_,document.body)},pt=t=>!t||t.trim()===""?!0:t.includes("placeholder");function gt(t,a){const[l,c]=x(a);return K(()=>{c(a)},[a]),K(()=>{if(!pt(a)||!t)return;let u=!1;return Oe.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=M(null),l=M(null),c=M(!1),u=M({x:0,y:0}),i=M(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]),y=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:y,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=Se(({item:t,linkTo:a,hoverIcon:l,progress:c,showProgress:u=!1,metaRow:i,display:r,layout:w="vertical",onRemove:b,showRemoveButton:_,showInfoButton:y=!1,onOpenDetails:B,renderPopup:g,onPopupHoverIntent:P,rawThumbnail:A,enrichedId:s})=>{const p=Ie(),m=te(),{titlePreference:ne}=ze(),{lowEndMode:C}=De(),[oe,re]=x(!1),[se,D]=x(!1),{thumbnail:U}=gt(s,t.thumbnail),[L,V]=x(!1),[G,W]=x(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,ae=o=>{if(m)return;const J=o.currentTarget.getBoundingClientRect();if(B){B(J);return}g&&Y(J)},le=()=>{g&&k()},ce=()=>{j()},ie=()=>{g&&k()},de=o=>{f.handlePointerDown(o,h)},ue=o=>{f.handlePointerMove(o)},F=()=>{f.handlePointerUpOrCancel()},_e=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[ne]||t.title,N=X.elements?.poster,E=X.elements?.info,pe=(N?.typeBadge??!0)&&!!t.typeBadge,ge=(N?.chapterBadge??!0)&&!!t.chapterBadge,me=_??N?.removeButton??!!b,fe=N?.adultBadge??!0,he=E?.mobileBadges??!0,be=E?.progress??!0,Be=E?.meta??!0,we=u&&!!c&&c.percent>0,q=!!t.isAdult,[ve,ye]=Ue("agreedToViewMature","false"),Ce=ve==="true",[H,S]=T.useState(!1),I=T.useRef(null),Me=()=>{ye("true"),S(!1),I.current&&(p(I.current),I.current=null)},h=q&&!Ce,xe=o=>{if(f.consumeLongPressClick()){o.preventDefault(),o.stopPropagation();return}h&&(o.preventDefault(),o.stopPropagation(),I.current=a,S(!0))},Te=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}),Pe=d(o=>{o.preventDefault(),o.stopPropagation(),b&&b(t.id)},[b,t.id]),Ne=A?U??t.thumbnail:Ve(U,C?100:150,C?150:200);return e("div",{className:`${n.cardWrapper} ${C?n.lowEnd:""}`,onMouseEnter:()=>{D(!0),P?.(!0),L&&j()},onMouseLeave:()=>{D(!1),P?.(!1),L&&k()},children:[e(Re,{to:a,className:`${n.card} ${n[w]} ${h?n.cardButton:""}`,onClick:xe,onContextMenu:_e,onPointerDown:de,onPointerMove:ue,onPointerUp:F,onPointerCancel:F,children:[e("div",{className:n.posterContainer,children:[h&&e("div",{className:`${n.matureOverlay} ${C?n.flat:""}`}),e("img",{src:Ne,alt:O,className:`${n.posterImg} ${oe?n.loaded:""} ${h&&!C?n.blurred:""}`,loading:"lazy",decoding:"async",onLoad:()=>re(!0)}),!m&&e(ee,{children:[pe&&e("div",{className:n.typeBadge,children:t.typeBadge}),ge&&e("div",{className:n.epBadge,children:[t.chapterBadge,t.airMeta&&e("span",{className:n.airTime,children:t.airMeta})]})]}),fe&&q&&e("div",{className:`${n.adultBadge} ${h?n.gated:""}`,children:"18+"}),t.notAired&&e("div",{className:n.notAiredBadge,children:"NOT AIRED"}),!m&&se&&e("div",{className:n.hoverOverlay,children:Te})]}),be&&u&&we&&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&&he&&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(Ge,{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:Me,children:"I'm 18+, Continue"})]})]})}),me&&e("button",{className:n.removeBtn,onClick:Pe,"aria-label":"Remove",children:e(v,{name:"times",size:10})}),y&&!m&&!h&&e("button",{className:n.infoBtn,onMouseEnter:ae,onMouseLeave:le,"aria-label":"Info",children:e(v,{name:"info",size:11})}),g&&L&&G?g(G,{close:$,onMouseEnter:ce,onMouseLeave:ie}):null]})});export{dn as M,cn as a,n as m,R as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as y,h as A,u as e,A as R,g as Ie,S,$ as tt,p as nt,T as j}from"./vendor-core-DfaOB3Rn.js";import{t as Pe,O as it,h as H,z as $}from"./index-CZW1But9.js";import{I as f}from"./vendor-icons-DrybRNxP.js";import{r as p}from"./Radio.module-DGSZLpKM.js";import{a}from"./Asmr.module-CdWlioTY.js";import{b as ne,u as Ae,a as Ee}from"./vendor-query-BBT5_sHx.js";import{p as te}from"./page.module-C1MlZzf3.js";const pe=new Set,ue=new Map,qe=n=>`/api/image-proxy?url=${encodeURIComponent(n)}&strict=1`,ze=n=>/googleusercontent\.com/.test(n)?n.replace(/=w\d+-h\d+(?:-l\d+)?(?:-rj)?$/,"=w544-h544-l90-rj"):n,Ye=/^[A-Za-z0-9_-]{11}$/;function st(n,s){const l=[],b=n?ue.get(n):void 0;b&&!pe.has(b)&&l.push(b);for(const x of s??[]){if(!x?.url)continue;const w=qe(ze(x.url));pe.has(w)||l.includes(w)||l.push(w)}if(n&&Ye.test(n)){const x=qe(`https://i.ytimg.com/vi/${n}/hqdefault.jpg`);!pe.has(x)&&!l.includes(x)&&l.push(x)}return l}function at(n,s){const l=s?.[0]?.url;return l?ze(l):n&&Ye.test(n)?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:""}function rt(n,s){!n||pe.has(s)||(ue.set(n,s),ue.size>500&&ue.clear())}function ot(n){pe.add(n);for(const[s,l]of ue)l===n&&ue.delete(s)}function $e({id:n,thumbnails:s}){const[l,b]=y(0),[x,w]=y(!1);A(()=>{b(0),w(!1)},[n]);const _=st(n,s),E=_[l];return x||!E?e("span",{className:p.stationThumbPlaceholder,children:e(f,{name:"headphones"})}):e("img",{src:E,alt:"",className:p.stationThumb,loading:"lazy",decoding:"async",onLoad:()=>rt(n,E),onError:()=>{ot(E),l+1<_.length?b(l+1):w(!0)}})}function Ue(n){if(!Number.isFinite(n)||n<0)return"0:00";const s=Math.floor(n/60),l=Math.floor(n%60);return`${s}:${String(l).padStart(2,"0")}`}const ct=({track:n,shuffle:s,onToggleShuffle:l,onTrackStep:b,onTrackFailed:x,onClose:w,liked:_,likeVisible:E,likePending:de,onToggleLike:ie})=>{const O=R(null),me=R(!1),[T,se]=y(!1),[h,v]=y(!0),[V,B]=y(!1),[F,ae]=y(0),[Z,J]=y(0),[N,re]=y(()=>{const r=parseFloat(localStorage.getItem("musicVolume")||"");return Number.isFinite(r)?r:1}),[z,oe]=y(()=>localStorage.getItem("musicAutoplay")!=="false"),L=R(N);L.current=N;const k=R(z);k.current=z;const W=R(0),D=R(0),Y=R(null),G=R("");G.current||(G.current=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`music-${Date.now()}-${Math.random().toString(36).slice(2)}`);const fe=`/api/music/audio?videoId=${encodeURIComponent(n.id)}`,q=Ie.useCallback(()=>{Y.current&&(window.clearTimeout(Y.current),Y.current=null)},[]),ce=Ie.useCallback(r=>{const c=O.current;if(!c)return;q(),v(!0),B(!1);const I=()=>{if(c.removeEventListener("loadedmetadata",I),r>5&&Number.isFinite(c.duration)&&r<c.duration-5)try{c.currentTime=r}catch{}};c.addEventListener("loadedmetadata",I),c.src=fe,c.load(),c.volume=L.current,c.play().catch(()=>{})},[fe,q]),ye=()=>{v(!1),B(!0),x?.(n),k.current&&b(1)},be=()=>{if(!Y.current){if(D.current>=3){ye();return}D.current+=1,Y.current=window.setTimeout(()=>{Y.current=null,ce(W.current)},5e3)}},Q=()=>{D.current=0,ce(W.current)};A(()=>{W.current=0,D.current=0,se(!1),ae(0),J(0);const r=O.current;return ce(W.current),()=>{q(),r&&r.removeAttribute("src")}},[ce,q]),A(()=>{const r=O.current;r&&(r.volume=N)},[N]),A(()=>(document.body.classList.add("asmr-player-open"),()=>document.body.classList.remove("asmr-player-open")),[]);const ve=at(n.id,n.thumbnails),K=Ie.useCallback(r=>{const c=O.current;Pe.discord.musicPresence.mutate({title:n.title,artistLabel:n.artists,isPlaying:r,thumbnail:ve||"",currentTime:c?.currentTime??0,duration:Number.isFinite(c?.duration??NaN)?c?.duration:0,sessionId:G.current}).catch(()=>{}),Pe.discord.heartbeat.mutate({sessionId:G.current}).catch(()=>{})},[n,ve]);A(()=>{K(T)},[K,T,n.id]),A(()=>{if(!T)return;const r=window.setInterval(()=>K(!0),15e3);return()=>window.clearInterval(r)},[T,K]),A(()=>{const r=G.current,c=()=>it(r),I=()=>c(),U=()=>{document.visibilityState==="hidden"&&c()};return window.addEventListener("pagehide",I),window.addEventListener("beforeunload",I),document.addEventListener("visibilitychange",U),()=>{window.removeEventListener("pagehide",I),window.removeEventListener("beforeunload",I),document.removeEventListener("visibilitychange",U),c()}},[]);const Se=()=>{const r=O.current;r&&(r.paused?r.play().catch(()=>{}):r.pause())},ke=`${n.title} — ${n.artists}`,Ne=e(S,{children:[e("div",{className:a.playerButtons,children:[e("button",{className:a.playerBtn,onClick:()=>b(-1),"aria-label":"Previous track",children:e(f,{name:"step-backward"})}),e("button",{className:`${a.playerBtn} ${a.playBtn}`,onClick:Se,"aria-label":T?"Pause":"Play",children:T?e(f,{name:"pause"}):e(f,{name:"play"})}),e("button",{className:a.playerBtn,onClick:()=>b(1),"aria-label":"Next track",children:e(f,{name:"step-forward"})}),V&&e("button",{className:a.playerBtn,onClick:Q,title:"Retry playback","aria-label":"Retry playback",children:e(f,{name:"redo"})})]}),e("div",{className:a.seekRow,children:[e("span",{className:a.timeLabel,children:Ue(F)}),e("input",{className:a.seekBar,type:"range",min:0,max:Z||0,step:.1,value:Math.min(F,Z||0),onChange:r=>{const c=O.current;!c||!Number.isFinite(c.duration)||(c.currentTime=parseFloat(r.target.value),ae(c.currentTime))},onPointerDown:()=>{me.current=!0},onPointerUp:()=>{me.current=!1},style:{"--played-percent":`${Z>0?F/Z*100:0}%`},"aria-label":"Seek"}),e("span",{className:a.timeLabel,children:Ue(Z)}),h&&!V&&e("span",{className:a.timeLabel,children:"loading…"})]})]}),xe=e(S,{children:[e($e,{id:n.id,thumbnails:n.thumbnails}),e("div",{className:a.playerInfo,children:[e("p",{className:a.playerTitle,title:ke,children:ke}),e("p",{className:a.playerTrack,children:n.artists})]}),e("div",{className:a.playerControls,children:Ne}),e("div",{className:a.playerRight,children:[N===0?e(f,{name:"volume-mute",className:a.volumeIcon}):N<.5?e(f,{name:"volume-down",className:a.volumeIcon}):e(f,{name:"volume-up",className:a.volumeIcon}),e("input",{className:a.volumeBar,type:"range",min:0,max:1,step:.01,value:N,onChange:r=>{const c=parseFloat(r.target.value);re(c),localStorage.setItem("musicVolume",String(c))},style:{"--volume-percent":`${N*100}%`},"aria-label":"Volume"})]}),e("div",{className:a.playerActions,children:[E&&ie&&e("button",{className:`${a.playerBtn} ${_?a.playerBtnActive:""}`,onClick:ie,disabled:de,title:_?"Remove from Liked Music":"Add to Liked Music","aria-label":_?"Remove from Liked Music":"Add to Liked Music","aria-pressed":!!_,children:e(f,{name:"heart"})}),e("button",{className:`${a.playerBtn} ${s?a.playerBtnActive:""}`,onClick:l,title:s?"Shuffle on":"Shuffle off","aria-label":"Toggle shuffle","aria-pressed":s,children:e(f,{name:"shuffle"})}),e("button",{className:`${a.playerBtn} ${z?a.playerBtnActive:""}`,onClick:()=>{oe(r=>(localStorage.setItem("musicAutoplay",String(!r)),!r))},title:z?"Autoplay on: next track plays automatically":"Autoplay off","aria-label":"Toggle autoplay","aria-pressed":z,children:e(f,{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:a.playerBtn,style:{display:"inline-flex",alignItems:"center"},children:e(f,{name:"external-link-alt"})}),e("button",{className:a.playerBtn,onClick:w,"aria-label":"Close player",children:e(f,{name:"times"})})]})]});return tt(e(S,{children:[e("audio",{ref:O,preload:"none",onPlay:()=>{se(!0),v(!1),B(!1),D.current=0,q()},onPause:()=>se(!1),onWaiting:()=>{V||v(!0)},onPlaying:()=>{v(!1),D.current=0,q()},onTimeUpdate:r=>{const c=r.target.currentTime;W.current=c,q(),me.current||ae(c)},onStalled:()=>{be()},onLoadedMetadata:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onDurationChange:r=>{const c=r.target.duration;Number.isFinite(c)&&J(c)},onError:()=>{be()},onEnded:()=>{k.current&&b(1)}}),e("div",{className:a.playerBar,children:xe})]}),document.body)},lt=()=>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."})]})]}),ge=300*1e3,ut=()=>{const n=H();return ne({...n.music.authStatus.queryOptions(),staleTime:30*1e3,refetchInterval:s=>s.state.data?.authenticated?!1:3e3,retry:1})},dt=()=>{const n=H(),s=Ae();return Ee(n.music.authStart.mutationOptions({onSuccess:(l,b)=>{localStorage.setItem("ytmusic_cookie",b.cookie??""),s.invalidateQueries(n.music.pathFilter())}}))},mt=()=>{const n=H(),s=Ae();return Ee(n.music.signOut.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},ht=n=>{const s=H();return ne({...s.music.search.queryOptions({q:n}),enabled:n.trim().length>0,staleTime:ge,retry:1})},pt=n=>{const s=H();return ne({...s.music.library.queryOptions(),enabled:n,staleTime:ge,retry:1})},gt=n=>{const s=H();return ne({...s.music.track.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},ft=n=>{const s=H();return ne({...s.music.playlist.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},yt=n=>{const s=H();return ne({...s.music.upnext.queryOptions({id:n||void 0}),enabled:!!n,staleTime:ge,retry:1})},bt=n=>{const s=H();return ne({...s.music.likes.queryOptions(),enabled:n,staleTime:120*1e3,retry:1})},vt=()=>{const n=H(),s=Ae();return Ee(n.music.like.mutationOptions({onSuccess:()=>{s.invalidateQueries(n.music.pathFilter())}}))},kt="_authRow_10tvv_1",Nt="_btn_10tvv_9",wt="_btnGhost_10tvv_42",St="_cookieForm_10tvv_74",xt="_cookieInput_10tvv_83",Tt="_link_10tvv_99",Lt="_contentLayout_10tvv_109",Mt="_mainCol_10tvv_116",_t="_upnextAside_10tvv_120",Ct="_upnextHeader_10tvv_131",Rt="_upnextTitle_10tvv_139",It="_upnextActions_10tvv_149",Pt="_nowPlayingLabel_10tvv_156",$t="_nowPlayingWrap_10tvv_168",At="_likeBtn_10tvv_172",Et="_likeActive_10tvv_196",g={authRow:kt,btn:Nt,btnGhost:wt,cookieForm:St,cookieInput:xt,link:Tt,contentLayout:Lt,mainCol:Mt,upnextAside:_t,upnextHeader:Ct,upnextTitle:Rt,upnextActions:It,nowPlayingLabel:Pt,nowPlayingWrap:$t,likeBtn:At,likeActive:Et};function He(n){const s=n.trim();if(!s)return null;const l=s.match(/[?&]v=([A-Za-z0-9_-]{11})/)?.[1]??s.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)?.[1]??null;return l||(/^[A-Za-z0-9_-]{11}$/.test(s)?s:null)}const Ot="https://github.com/serifpersia/dango/releases/latest/download/dango-extension.zip",Yt=()=>{const[n,s]=nt(),l=He(n.get("v")??""),[b,x]=y(()=>n.get("q")??""),w=n.get("q")??"";A(()=>{x(w)},[w]);const[_,E]=y(()=>{try{return localStorage.getItem("ytmusic_cookie")??""}catch{return""}}),[de,ie]=y(!1),[O,me]=y(()=>localStorage.getItem("musicShuffle")==="true"),[T,se]=y(()=>localStorage.getItem("musicRadio")!=="false"),[h,v]=y(null),[V,B]=y([]),[F,ae]=y(null),[Z,J]=y({}),N=R([]);N.current=V;const re=R(null);re.current=h;const z=R(!1),oe=R(new Set),{data:L}=ut(),k=dt(),W=mt(),D=typeof navigator<"u"?navigator.userAgent:"",Y=/android/i.test(D),G=/firefox|fxios/i.test(D)&&!Y,fe=!G&&!Y&&/chrome|chromium|edg|brave/i.test(D),q=G||fe,ce=()=>{if(de)return;ie(!0);const t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=window.setTimeout(()=>{window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),$.error("Helper not detected — install the Dango Helper extension first.")},3e3),o=d=>{let m;try{m=JSON.parse(d.detail)}catch{return}if(!(!m||m.requestId!==t))if(window.clearTimeout(i),window.removeEventListener("dango:ytmusic-cookie",o),ie(!1),m?.ok&&m.cookie){const u=m.cookie.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(u.includes("…")||u.includes("...")){$.error(`Helper returned a truncated cookie (${u.length} chars) — reload music.youtube.com and Extract again.`);return}E(u),$.success("Cookie extracted from helper — signing in…"),k.mutate({cookie:u})}else m?.error==="NO_COOKIE"?$.error("Helper found no YouTube login — log in on a music.youtube.com tab first."):$.error("Helper request failed — try again.")};window.addEventListener("dango:ytmusic-cookie",o),window.dispatchEvent(new CustomEvent("dango:get-ytmusic-cookie",{detail:{requestId:t}}))},{data:ye,isLoading:be}=ht(w),{data:Q,isLoading:ve,isFetching:K,error:Se,refetch:ke}=pt(L?.authenticated===!0),{data:Ne,isLoading:xe}=ft(F?.id??null),{data:Te,isLoading:r}=yt(h?.id??null),{data:c}=bt(L?.authenticated===!0),I=vt(),U=j(()=>ye?.tracks||[],[ye]),Le=j(()=>Q?.playlists||[],[Q]),P=j(()=>Q?.tracks||[],[Q]),X=j(()=>Ne?.tracks||[],[Ne]),M=j(()=>{const t=Te?.tracks||[];return h?t.filter(i=>i.id!==h.id):t},[Te,h]),Ge=j(()=>new Set(c?.likedIds||[]),[c]),Me=t=>Z[t.id]??(Ge.has(t.id)||t.liked===!0);A(()=>{L?.authenticated!==!0&&J({})},[L?.authenticated]);const Qe=j(()=>[...U,...X,...P,...M],[U,X,P,M]),Ve=l&&h?.id!==l&&!Qe.some(t=>t.id===l)?l:null,{data:Oe}=gt(Ve),_e=h?.id;A(()=>{document.title=h?`${h.title} - dango`:"Music - dango"},[h]),A(()=>{if(!l){_e&&v(null);return}if(_e===l)return;const t=d=>{const m=d.find(u=>u.id===l);return m?(v(m),B(u=>u.some(le=>le.id===l)?u:d.length>0?d:[m]),!0):!1};if(t(U)||t(X)||t(P))return;const i=M.find(d=>d.id===l);if(i){v(i),B(d=>d.some(m=>m.id===i.id)?d:[i]);return}const o=Oe?.track;o&&o.id===l&&(v(o),B(d=>d.some(m=>m.id===o.id)?d:[o]))},[l,_e,U,X,P,M,Oe]);const ee=t=>{s(i=>{const o=new URLSearchParams(i);return t?o.set("v",t):o.delete("v"),o})},Ce=(t,i)=>{oe.current.delete(t.id),v(t),B(i.length>0?i:[t]),ee(t.id)},We=t=>{oe.current.add(t.id),$.error(`Couldn't play “${t.title}” — skipped.`)},je=async()=>{if(z.current)return;const t=N.current,i=t[t.length-1]??re.current;if(i){z.current=!0;try{const o=await Pe.music.upnext.query({id:i.id}),d=new Set(t.map(u=>u.id)),m=(o.tracks||[]).filter(u=>!d.has(u.id)&&!oe.current.has(u.id));if(m.length===0){const u=N.current[0];u&&(v(u),ee(u.id));return}B([...N.current,...m]),v(m[0]),ee(m[0].id)}catch{const o=N.current[0];o&&(v(o),ee(o.id))}finally{z.current=!1}}},Ze=t=>{const i=N.current,o=re.current;if(!o||i.length===0)return;const d=i.findIndex(C=>C.id===o.id);if(t>0&&T&&(d<0||d===i.length-1)){je();return}const m=C=>oe.current.has(C.id),u=i.length;let le;if(O&&u>1){let C=Math.floor(Math.random()*u);for(let Re=0;Re<u&&(C===d||m(i[C]));Re++)C=Math.floor(Math.random()*u);le=i[C]}else{const C=t>0?1:-1;let we=(((d<0?C>0?-1:0:d)+C)%u+u)%u;for(let De=1;De<u&&m(i[we]);De++)we=((we+C)%u+u)%u;le=i[we]}v(le),ee(le.id)},Je=()=>{if(T){se(!1),localStorage.setItem("musicRadio","false");return}const t=re.current;if(!t)return;if(M.length===0){$.error("No radio suggestions for this song yet.");return}const i=new Set,o=[];for(const d of[t,...M])i.has(d.id)||(i.add(d.id),o.push(d));se(!0),localStorage.setItem("musicRadio","true"),B(o),$.success(`Radio started — ${M.length} songs queued.`)},Be=t=>{if(L?.authenticated!==!0){$.error("Sign in to like songs.");return}const i=!Me(t);J(o=>({...o,[t.id]:i})),I.mutate({id:t.id,like:i},{onError:()=>{J(o=>{const d={...o};return delete d[t.id],d}),$.error("Like action failed — try again.")}})},Ke=()=>{me(t=>(localStorage.setItem("musicShuffle",String(!t)),!t))},Xe=t=>e("button",{className:p.stationRow,onClick:()=>ae(t),"aria-label":`Open ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),t.subtitle&&e("span",{className:p.stationSub,children:t.subtitle})]})]},t.id),he=(t,i,o)=>{const d=h?.id===t.id,m=Me(t),u=[t.album,t.duration].filter(Boolean).join(" · ");return e("div",{className:`${p.stationRow} ${d?p.stationRowActive:""}`,style:{cursor:"default"},children:[e("button",{onClick:()=>o?o(t):Ce(t,i),className:p.stationRow,style:{flex:1,minWidth:0,background:"transparent",border:0,padding:0},"aria-label":`Play ${t.title}`,children:[e($e,{id:t.id,thumbnails:t.thumbnails}),e("span",{className:p.stationMeta,children:[e("span",{className:p.stationName,children:t.title}),e("span",{className:p.stationSub,children:[t.artists,u?` · ${u}`:""]})]})]}),L?.authenticated===!0&&e("button",{className:`${g.likeBtn} ${m?g.likeActive:""}`,onClick:()=>Be(t),disabled:I.isPending,title:m?"Remove from Liked Music":"Add to Liked Music","aria-label":m?`Remove ${t.title} from Liked Music`:`Add ${t.title} to Liked Music`,"aria-pressed":m,children:e(f,{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(f,{name:"external-link-alt"})})]},t.id)},Fe=j(()=>{if(!h)return M;const t=new Set,i=[];for(const o of[h,...M])t.has(o.id)||(t.add(o.id),i.push(o));return i},[h,M]),et=t=>{Ce(t,Fe)};return e("div",{className:`${te.page} ${h?te.pageWithPlayer:""}`,children:[e("div",{className:te.header,children:[e("h1",{className:te.pageTitle,children:[e(f,{name:"headphones"})," Music"]}),e("form",{className:te.searchForm,onSubmit:t=>{t.preventDefault();const i=He(b);if(i)ee(i);else{const o=b.trim();s(d=>{const m=new URLSearchParams(d);return o?m.set("q",o):m.delete("q"),m})}},children:[e("input",{className:te.searchInput,value:b,onChange:t=>x(t.target.value),placeholder:"Search YouTube Music…","aria-label":"Search music"}),e("button",{className:te.searchBtn,type:"submit","aria-label":"Search",children:e(f,{name:"search"})})]})]}),e("div",{className:g.authRow,children:[L?.authenticated?e(S,{children:[e("span",{className:a.statusMsg,children:["Signed in to YouTube Music",Q&&` — ${Q.tracks.length} songs, ${Q.playlists.length} playlists`]}),e("button",{className:g.btnGhost,onClick:()=>W.mutate(),disabled:W.isPending,children:"Sign out"})]}):e(S,{children:[e("form",{onSubmit:t=>{t.preventDefault();const i=_.replace(/^cookie\s*:\s*/i,"").replace(/^["']+|["']+$/g,"").trim();if(i){if(i.includes("…")||i.includes("...")){$.error("That cookie is truncated (contains …). Right-click the Cookie header → Copy value, not the wrapped preview.");return}i!==_&&E(i),k.mutate({cookie:i})}},className:g.cookieForm,children:[e("input",{className:g.cookieInput,value:_,onChange:t=>E(t.target.value),placeholder:"Paste music.youtube.com Cookie header…","aria-label":"YouTube Music cookie",type:"password"}),e("button",{className:g.btn,type:"submit",disabled:k.isPending||!_.trim(),children:k.isPending?"Checking…":"Sign in"}),q&&e("button",{className:g.btnGhost,type:"button",onClick:ce,disabled:de||k.isPending,title:"Read the YouTube Music cookie via the Dango Helper extension (same zip as AnimePahe/JapaneseASMR)",children:de?"Extracting…":"Extract from helper"})]}),q&&e("p",{className:a.statusMsg,children:["Two ways to sign in: paste the Cookie header manually (steps below), or download"," ",e("a",{href:Ot,target:"_blank",rel:"noreferrer",className:g.link,children:"dango-extension.zip"})," ","then"," ",G?e(S,{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(S,{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(lt,{})]}),k.isSuccess&&e("p",{className:a.statusMsg,children:["Signed in — found ",k.data.tracks," songs and ",k.data.playlists," ","playlists."]}),k.isError&&e("p",{className:a.statusMsg,children:k.error?.message||"Sign-in failed. Paste a fresh Cookie header from music.youtube.com."}),!L?.authenticated&&!k.isError&&!k.isSuccess&&e("p",{className:a.statusMsg,children:"Sign in with your YouTube Music cookie to see your library. Search and playback work without sign-in."})]}),e("div",{className:h?g.contentLayout:void 0,children:[e("div",{className:g.mainCol,children:w?e(S,{children:[e("h2",{className:p.sectionTitle,children:["Results for “",w,"”"]}),be?e("p",{className:a.statusMsg,children:"Searching…"}):U.length===0?e("p",{className:a.statusMsg,children:"No tracks found."}):e("div",{className:p.stationList,children:U.map(t=>he(t,U))})]}):L?.authenticated?e(S,{children:[e("h2",{className:p.sectionTitle,children:"Your library"}),ve?e("p",{className:a.statusMsg,children:"Loading library…"}):Le.length===0&&P.length===0&&!F?e(S,{children:[e("p",{className:a.statusMsg,children:Se?"Library failed to load.":"Your library came back empty — YouTube sometimes drops the saved session."}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>{ke()},disabled:K,"aria-label":"Retry loading library",children:K?"Retrying…":"Retry"})}),e("p",{className:a.statusMsg,children:"If it keeps happening, sign out and paste a fresh cookie."})]}):e(S,{children:[Le.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:"Playlists"}),e("div",{className:p.stationList,children:Le.map(t=>Xe(t))})]}),P.length>0&&!F&&e(S,{children:[e("h3",{className:p.sectionTitle,children:["Liked songs (",P.length,")"]}),e("div",{style:{marginBottom:8},children:e("button",{className:g.btnGhost,onClick:()=>Ce(P[0],P),"aria-label":"Play all liked songs",children:[e(f,{name:"play"})," Play all"]})}),e("div",{className:p.stationList,children:P.map(t=>he(t,P))})]}),F?e(S,{children:[e("button",{className:g.btnGhost,onClick:()=>ae(null),style:{marginBottom:8},children:"← Back to library"}),e("h3",{className:p.sectionTitle,children:F.title}),xe?e("p",{className:a.statusMsg,children:"Loading playlist…"}):X.length===0?e("p",{className:a.statusMsg,children:"No tracks in this playlist."}):e("div",{className:p.stationList,children:X.map(t=>he(t,X))})]}):null]})]}):e("p",{className:a.statusMsg,children:"Search above, or sign in to see your library."})}),h&&e("aside",{className:g.upnextAside,"aria-label":"Up next",children:[e("div",{className:g.upnextHeader,children:e("span",{className:g.upnextTitle,children:[e(f,{name:"list-ul"})," Up Next"]})}),e("div",{className:g.nowPlayingWrap,children:[e("p",{className:g.nowPlayingLabel,children:"Now playing"}),he(h,V.length>0?V:[h])]}),e("div",{className:g.upnextActions,children:e("button",{className:g.btnGhost,onClick:Je,disabled:!T&&(r||M.length===0),"aria-pressed":T,title:T?"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:T?"Stop radio":"Start radio"})}),r?e("p",{className:a.statusMsg,children:"Loading suggestions…"}):M.length===0?e("p",{className:a.statusMsg,children:"No suggestions for this song."}):e("div",{className:p.stationList,children:M.map(t=>he(t,Fe,et))})]})]}),h&&e(ct,{track:h,queue:V,shuffle:O,onToggleShuffle:Ke,onTrackStep:Ze,onTrackFailed:We,onClose:()=>{v(null),ee(null)},liked:h?Me(h):!1,likeVisible:L?.authenticated===!0,likePending:I.isPending,onToggleLike:()=>Be(h)})]})};export{Yt 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-
|
|
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-Cr9n1euF.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-
|
|
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-Dk0ASzEz.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-VoOEtoX9.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Cn}from"./hls-Bej65gvf.js";import{u as Rn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as Mn}from"./QueueRail-CO2ocUNx.js";import{u as _n,Q as Nn}from"./QueueOptionsButton-CzzisJ3N.js";import{u as hr}from"./useProviders-fmZrOyDC.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-BZtjBWWq.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-B16FnAO_.js","assets/vendor-core-DfaOB3Rn.js","assets/vendor-icons-DrybRNxP.js","assets/OptionListMenu-Dlk9eHM7.js","assets/AvSyncCalibrator-Cr9n1euF.js","assets/index-CZW1But9.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-CZW1But9.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-Cr9n1euF.js";import{I as Z}from"./vendor-icons-DrybRNxP.js";import{l as Cn}from"./hls-E94cMCjR.js";import{u as Rn}from"./useIsMobile-Dvx1uJ82.js";import{s as ze,Q as Mn}from"./QueueRail-DcLtEU46.js";import{u as _n,Q as Nn}from"./QueueOptionsButton-DjBOibpt.js";import{u as hr}from"./useProviders-CqMq_6ue.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-B16FnAO_.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}}),[
|
|
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((
|
|
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-
|
|
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-Dlk9eHM7.js";import{u as re}from"./index-CZW1But9.js";import"./AvSyncCalibrator-Cr9n1euF.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-CZW1But9.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as s,u as n,a as Y}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{d as L,f as z}from"./index-
|
|
1
|
+
import{g as s,u as n,a as Y}from"./vendor-core-DfaOB3Rn.js";import{I as P}from"./vendor-icons-DrybRNxP.js";import{d as L,f as z}from"./index-CZW1But9.js";const F="_section_1pwqc_1",O="_header_1pwqc_10",j="_headerToggle_1pwqc_20",G="_headerActions_1pwqc_34",J="_title_1pwqc_40",K="_badge_1pwqc_50",V="_clearBtn_1pwqc_65",W="_nextBtn_1pwqc_83",Z="_list_1pwqc_101",ee="_item_1pwqc_114",ne="_active_1pwqc_134",te="_dragging_1pwqc_142",re="_dragHandle_1pwqc_149",ce="_thumbnail_1pwqc_167",ae="_meta_1pwqc_175",oe="_name_1pwqc_182",se="_episode_1pwqc_204",ie="_iconBtn_1pwqc_210",r={section:F,header:O,headerToggle:j,headerActions:G,title:J,badge:K,clearBtn:V,nextBtn:W,list:Z,item:ee,active:ne,dragging:te,dragHandle:re,thumbnail:ce,meta:ae,name:oe,episode:se,iconBtn:ie},le=({item:c,isActive:T,index:m,onRemove:D,onTouchPointerDown:v,onTouchPointerMove:x,onTouchPointerUp:q,onTouchPointerCancel:I,shouldIgnoreClick:_,onDragStart:B,onDragEnter:f,onDragEnd:o,isDragging:w})=>{const a=Y(),{titlePreference:i}=L(),l=c[i]||c.name||"Unknown show";return n("div",{"data-queue-index":m,className:`${r.item} ${T?r.active:""} ${w?r.dragging:""}`,draggable:!0,onDragStart:B,onDragEnter:f,onDragOver:u=>u.preventDefault(),onDragEnd:o,onPointerDown:u=>v(m,u),onPointerMove:x,onPointerUp:q,onPointerCancel:I,children:[n("button",{className:r.dragHandle,type:"button","aria-label":"Drag queue item",children:n(P,{name:"bars"})}),n("img",{className:r.thumbnail,src:z(c.thumbnail||"",72,96),alt:l,loading:"lazy",decoding:"async",onError:u=>{u.currentTarget.src="/placeholder.svg"}}),n("div",{className:r.meta,children:[n("button",{className:r.name,type:"button",onClick:()=>{_()||a(`/watch/${c.showId}/${c.episodeNumber}`)},children:l}),n("div",{className:r.episode,children:["Episode ",c.episodeNumber]})]}),n("button",{className:r.iconBtn,type:"button",onClick:()=>{_()||D(c)},"aria-label":`Remove ${l} episode ${c.episodeNumber} from queue`,children:n(P,{name:"times"})})]})},he=({title:c="Queue",eyebrow:T,items:m,currentShowId:D,currentEpisode:v,onRemove:x,onReorder:q,onNextQueue:I,onClear:_,showClearAll:B=!1,defaultExpanded:f=!0})=>{const[o,w]=s.useState([]),[a,i]=s.useState(null),[l,u]=s.useState(f),b=s.useRef(null),N=s.useRef(null),d=s.useRef(null),p=s.useRef(!1),R=s.useRef(!1);s.useEffect(()=>{w(m)},[m]),s.useEffect(()=>{u(f)},[f]);const E=e=>{i(e)},$=e=>{if(a===null||a===e)return;const t=[...o],h=t[a];t.splice(a,1),t.splice(e,0,h),i(e),w(t)},k=()=>{a!==null&&q(o.map(e=>({id:e.id,showId:e.showId,episodeNumber:e.episodeNumber}))),i(null)},C=(e=!1)=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),e&&p.current&&(q(o.map(t=>({id:t.id,showId:t.showId,episodeNumber:t.episodeNumber}))),R.current=!0,window.setTimeout(()=>{R.current=!1},0)),b.current=null,N.current=null,p.current=!1,i(null)},A=(e,t)=>{if(t.pointerType==="mouse")return;const h=t.currentTarget,g=t.pointerId;b.current=t.pointerId,N.current={x:t.clientX,y:t.clientY},d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{p.current=!0,i(e);try{h.setPointerCapture(g)}catch{}},220)},Q=e=>{if(e.pointerType==="mouse"||b.current!==e.pointerId)return;if(!p.current&&N.current){const H=Math.abs(e.clientX-N.current.x),X=Math.abs(e.clientY-N.current.y);(H>8||X>8)&&C(!1);return}if(!p.current)return;e.preventDefault();const h=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-queue-index]"),g=h?Number(h.dataset.queueIndex):NaN;if(Number.isNaN(g)||a===null||g===a)return;const y=[...o],U=y[a];y.splice(a,1),y.splice(g,0,U),i(g),w(y)},S=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(p.current)},M=e=>{e.pointerType!=="mouse"&&b.current===e.pointerId&&C(!1)};return o.length===0?null:n("section",{className:r.section,children:[n("div",{className:r.header,children:[n("button",{className:r.headerToggle,type:"button",onClick:()=>u(e=>!e),"aria-expanded":l,"aria-label":l?`Collapse ${c}`:`Expand ${c}`,children:[n("span",{className:r.title,children:[n("span",{className:"title-stack",children:[T&&n("div",{className:"section-eyebrow",children:T}),n("span",{children:c})]}),n("span",{className:r.badge,children:o.length})]}),l?n(P,{name:"chevron-up"}):n(P,{name:"chevron-down"})]}),B&&_&&n("div",{className:r.headerActions,children:[I&&o.length>1&&n("button",{className:r.nextBtn,type:"button",onClick:I,children:"Next"}),n("button",{className:r.clearBtn,type:"button",onClick:_,children:"Clear All"})]})]}),l&&n("div",{className:r.list,children:o.map((e,t)=>n(le,{item:e,isActive:e.showId===D&&e.episodeNumber===v,index:t,onRemove:x,onTouchPointerDown:A,onTouchPointerMove:Q,onTouchPointerUp:S,onTouchPointerCancel:M,shouldIgnoreClick:()=>R.current,onDragStart:()=>E(t),onDragEnter:()=>$(t),onDragEnd:k,isDragging:a===t},e.id))})]})};export{he as Q,r as s};
|