jukebox-media-server 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Watch-DE2orFm6.js","assets/Watch-BIOwxQGH.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Watch-Ja4PAA8Y.js","assets/Watch-BIOwxQGH.css"])))=>i.map(i=>d[i]);
2
2
  function nE(n,r){for(var o=0;o<r.length;o++){const l=r[o];if(typeof l!="string"&&!Array.isArray(l)){for(const s in l)if(s!=="default"&&!(s in n)){const c=Object.getOwnPropertyDescriptor(l,s);c&&Object.defineProperty(n,s,c.get?c:{enumerable:!0,get:()=>l[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))l(s);new MutationObserver(s=>{for(const c of s)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function o(s){const c={};return s.integrity&&(c.integrity=s.integrity),s.referrerPolicy&&(c.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?c.credentials="include":s.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(s){if(s.ep)return;s.ep=!0;const c=o(s);fetch(s.href,c)}})();const aE="modulepreload",rE=function(n){return"/"+n},Iv={},db=function(r,o,l){let s=Promise.resolve();if(o&&o.length>0){let y=function(g){return Promise.all(g.map(b=>Promise.resolve(b).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");s=y(o.map(g=>{if(g=rE(g),g in Iv)return;Iv[g]=!0;const b=g.endsWith(".css"),p=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${p}`))return;const w=document.createElement("link");if(w.rel=b?"stylesheet":aE,b||(w.as="script"),w.crossOrigin="",w.href=g,m&&w.setAttribute("nonce",m),document.head.appendChild(w),b)return new Promise((C,R)=>{w.addEventListener("load",C),w.addEventListener("error",()=>R(new Error(`Unable to preload CSS for ${g}`)))})}))}function c(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return s.then(d=>{for(const m of d||[])m.status==="rejected"&&c(m.reason);return r().catch(c)})};var r4=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function o4(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var r=n.default;if(typeof r=="function"){var o=function l(){var s=!1;try{s=this instanceof l}catch{}return s?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};o.prototype=r.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(n).forEach(function(l){var s=Object.getOwnPropertyDescriptor(n,l);Object.defineProperty(o,l,s.get?s:{enumerable:!0,get:function(){return n[l]}})}),o}var td={exports:{}},Gi={};var Qv;function oE(){if(Qv)return Gi;Qv=1;var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(l,s,c){var d=null;if(c!==void 0&&(d=""+c),s.key!==void 0&&(d=""+s.key),"key"in s){c={};for(var m in s)m!=="key"&&(c[m]=s[m])}else c=s;return s=c.ref,{$$typeof:n,type:l,key:d,ref:s!==void 0?s:null,props:c}}return Gi.Fragment=r,Gi.jsx=o,Gi.jsxs=o,Gi}var Kv;function iE(){return Kv||(Kv=1,td.exports=oE()),td.exports}var h=iE(),nd={exports:{}},Ee={};var Xv;function lE(){if(Xv)return Ee;Xv=1;var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),w=Symbol.iterator;function C(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var R={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,N={};function j(M,A,L){this.props=M,this.context=A,this.refs=N,this.updater=L||R}j.prototype.isReactComponent={},j.prototype.setState=function(M,A){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,A,"setState")},j.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function O(){}O.prototype=j.prototype;function k(M,A,L){this.props=M,this.context=A,this.refs=N,this.updater=L||R}var Q=k.prototype=new O;Q.constructor=k,S(Q,j.prototype),Q.isPureReactComponent=!0;var I=Array.isArray;function Z(){}var B={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function ue(M,A,L){var P=L.ref;return{$$typeof:n,type:M,key:A,ref:P!==void 0?P:null,props:L}}function ie(M,A){return ue(M.type,A,M.props)}function oe(M){return typeof M=="object"&&M!==null&&M.$$typeof===n}function fe(M){var A={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(L){return A[L]})}var ge=/\/+/g;function ae(M,A){return typeof M=="object"&&M!==null&&M.key!=null?fe(""+M.key):A.toString(36)}function W(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(Z,Z):(M.status="pending",M.then(function(A){M.status==="pending"&&(M.status="fulfilled",M.value=A)},function(A){M.status==="pending"&&(M.status="rejected",M.reason=A)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function T(M,A,L,P,K){var re=typeof M;(re==="undefined"||re==="boolean")&&(M=null);var Y=!1;if(M===null)Y=!0;else switch(re){case"bigint":case"string":case"number":Y=!0;break;case"object":switch(M.$$typeof){case n:case r:Y=!0;break;case b:return Y=M._init,T(Y(M._payload),A,L,P,K)}}if(Y)return K=K(M),Y=P===""?"."+ae(M,0):P,I(K)?(L="",Y!=null&&(L=Y.replace(ge,"$&/")+"/"),T(K,A,L,"",function(ve){return ve})):K!=null&&(oe(K)&&(K=ie(K,L+(K.key==null||M&&M.key===K.key?"":(""+K.key).replace(ge,"$&/")+"/")+Y)),A.push(K)),1;Y=0;var le=P===""?".":P+":";if(I(M))for(var ce=0;ce<M.length;ce++)P=M[ce],re=le+ae(P,ce),Y+=T(P,A,L,re,K);else if(ce=C(M),typeof ce=="function")for(M=ce.call(M),ce=0;!(P=M.next()).done;)P=P.value,re=le+ae(P,ce++),Y+=T(P,A,L,re,K);else if(re==="object"){if(typeof M.then=="function")return T(W(M),A,L,P,K);throw A=String(M),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.")}return Y}function U(M,A,L){if(M==null)return M;var P=[],K=0;return T(M,P,"","",function(re){return A.call(L,re,K++)}),P}function _(M){if(M._status===-1){var A=M._result;A=A(),A.then(function(L){(M._status===0||M._status===-1)&&(M._status=1,M._result=L)},function(L){(M._status===0||M._status===-1)&&(M._status=2,M._result=L)}),M._status===-1&&(M._status=0,M._result=A)}if(M._status===1)return M._result.default;throw M._result}var F=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var A=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(A))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ne={map:U,forEach:function(M,A,L){U(M,function(){A.apply(this,arguments)},L)},count:function(M){var A=0;return U(M,function(){A++}),A},toArray:function(M){return U(M,function(A){return A})||[]},only:function(M){if(!oe(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ee.Activity=p,Ee.Children=ne,Ee.Component=j,Ee.Fragment=o,Ee.Profiler=s,Ee.PureComponent=k,Ee.StrictMode=l,Ee.Suspense=y,Ee.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,Ee.__COMPILER_RUNTIME={__proto__:null,c:function(M){return B.H.useMemoCache(M)}},Ee.cache=function(M){return function(){return M.apply(null,arguments)}},Ee.cacheSignal=function(){return null},Ee.cloneElement=function(M,A,L){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var P=S({},M.props),K=M.key;if(A!=null)for(re in A.key!==void 0&&(K=""+A.key),A)!G.call(A,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&A.ref===void 0||(P[re]=A[re]);var re=arguments.length-2;if(re===1)P.children=L;else if(1<re){for(var Y=Array(re),le=0;le<re;le++)Y[le]=arguments[le+2];P.children=Y}return ue(M.type,K,P)},Ee.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},Ee.createElement=function(M,A,L){var P,K={},re=null;if(A!=null)for(P in A.key!==void 0&&(re=""+A.key),A)G.call(A,P)&&P!=="key"&&P!=="__self"&&P!=="__source"&&(K[P]=A[P]);var Y=arguments.length-2;if(Y===1)K.children=L;else if(1<Y){for(var le=Array(Y),ce=0;ce<Y;ce++)le[ce]=arguments[ce+2];K.children=le}if(M&&M.defaultProps)for(P in Y=M.defaultProps,Y)K[P]===void 0&&(K[P]=Y[P]);return ue(M,re,K)},Ee.createRef=function(){return{current:null}},Ee.forwardRef=function(M){return{$$typeof:m,render:M}},Ee.isValidElement=oe,Ee.lazy=function(M){return{$$typeof:b,_payload:{_status:-1,_result:M},_init:_}},Ee.memo=function(M,A){return{$$typeof:g,type:M,compare:A===void 0?null:A}},Ee.startTransition=function(M){var A=B.T,L={};B.T=L;try{var P=M(),K=B.S;K!==null&&K(L,P),typeof P=="object"&&P!==null&&typeof P.then=="function"&&P.then(Z,F)}catch(re){F(re)}finally{A!==null&&L.types!==null&&(A.types=L.types),B.T=A}},Ee.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},Ee.use=function(M){return B.H.use(M)},Ee.useActionState=function(M,A,L){return B.H.useActionState(M,A,L)},Ee.useCallback=function(M,A){return B.H.useCallback(M,A)},Ee.useContext=function(M){return B.H.useContext(M)},Ee.useDebugValue=function(){},Ee.useDeferredValue=function(M,A){return B.H.useDeferredValue(M,A)},Ee.useEffect=function(M,A){return B.H.useEffect(M,A)},Ee.useEffectEvent=function(M){return B.H.useEffectEvent(M)},Ee.useId=function(){return B.H.useId()},Ee.useImperativeHandle=function(M,A,L){return B.H.useImperativeHandle(M,A,L)},Ee.useInsertionEffect=function(M,A){return B.H.useInsertionEffect(M,A)},Ee.useLayoutEffect=function(M,A){return B.H.useLayoutEffect(M,A)},Ee.useMemo=function(M,A){return B.H.useMemo(M,A)},Ee.useOptimistic=function(M,A){return B.H.useOptimistic(M,A)},Ee.useReducer=function(M,A,L){return B.H.useReducer(M,A,L)},Ee.useRef=function(M){return B.H.useRef(M)},Ee.useState=function(M){return B.H.useState(M)},Ee.useSyncExternalStore=function(M,A,L){return B.H.useSyncExternalStore(M,A,L)},Ee.useTransition=function(){return B.H.useTransition()},Ee.version="19.2.3",Ee}var Zv;function Wd(){return Zv||(Zv=1,nd.exports=lE()),nd.exports}var v=Wd();const se=hu(v),eh=nE({__proto__:null,default:se},[v]);var ad={exports:{}},Yi={},rd={exports:{}},od={};var Jv;function sE(){return Jv||(Jv=1,(function(n){function r(T,U){var _=T.length;T.push(U);e:for(;0<_;){var F=_-1>>>1,ne=T[F];if(0<s(ne,U))T[F]=U,T[_]=ne,_=F;else break e}}function o(T){return T.length===0?null:T[0]}function l(T){if(T.length===0)return null;var U=T[0],_=T.pop();if(_!==U){T[0]=_;e:for(var F=0,ne=T.length,M=ne>>>1;F<M;){var A=2*(F+1)-1,L=T[A],P=A+1,K=T[P];if(0>s(L,_))P<ne&&0>s(K,L)?(T[F]=K,T[P]=_,F=P):(T[F]=L,T[A]=_,F=A);else if(P<ne&&0>s(K,_))T[F]=K,T[P]=_,F=P;else break e}}return U}function s(T,U){var _=T.sortIndex-U.sortIndex;return _!==0?_:T.id-U.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var d=Date,m=d.now();n.unstable_now=function(){return d.now()-m}}var y=[],g=[],b=1,p=null,w=3,C=!1,R=!1,S=!1,N=!1,j=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function Q(T){for(var U=o(g);U!==null;){if(U.callback===null)l(g);else if(U.startTime<=T)l(g),U.sortIndex=U.expirationTime,r(y,U);else break;U=o(g)}}function I(T){if(S=!1,Q(T),!R)if(o(y)!==null)R=!0,Z||(Z=!0,fe());else{var U=o(g);U!==null&&W(I,U.startTime-T)}}var Z=!1,B=-1,G=5,ue=-1;function ie(){return N?!0:!(n.unstable_now()-ue<G)}function oe(){if(N=!1,Z){var T=n.unstable_now();ue=T;var U=!0;try{e:{R=!1,S&&(S=!1,O(B),B=-1),C=!0;var _=w;try{t:{for(Q(T),p=o(y);p!==null&&!(p.expirationTime>T&&ie());){var F=p.callback;if(typeof F=="function"){p.callback=null,w=p.priorityLevel;var ne=F(p.expirationTime<=T);if(T=n.unstable_now(),typeof ne=="function"){p.callback=ne,Q(T),U=!0;break t}p===o(y)&&l(y),Q(T)}else l(y);p=o(y)}if(p!==null)U=!0;else{var M=o(g);M!==null&&W(I,M.startTime-T),U=!1}}break e}finally{p=null,w=_,C=!1}U=void 0}}finally{U?fe():Z=!1}}}var fe;if(typeof k=="function")fe=function(){k(oe)};else if(typeof MessageChannel<"u"){var ge=new MessageChannel,ae=ge.port2;ge.port1.onmessage=oe,fe=function(){ae.postMessage(null)}}else fe=function(){j(oe,0)};function W(T,U){B=j(function(){T(n.unstable_now())},U)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(T){T.callback=null},n.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<T?Math.floor(1e3/T):5},n.unstable_getCurrentPriorityLevel=function(){return w},n.unstable_next=function(T){switch(w){case 1:case 2:case 3:var U=3;break;default:U=w}var _=w;w=U;try{return T()}finally{w=_}},n.unstable_requestPaint=function(){N=!0},n.unstable_runWithPriority=function(T,U){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var _=w;w=T;try{return U()}finally{w=_}},n.unstable_scheduleCallback=function(T,U,_){var F=n.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?F+_:F):_=F,T){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=_+ne,T={id:b++,callback:U,priorityLevel:T,startTime:_,expirationTime:ne,sortIndex:-1},_>F?(T.sortIndex=_,r(g,T),o(y)===null&&T===o(g)&&(S?(O(B),B=-1):S=!0,W(I,_-F))):(T.sortIndex=ne,r(y,T),R||C||(R=!0,Z||(Z=!0,fe()))),T},n.unstable_shouldYield=ie,n.unstable_wrapCallback=function(T){var U=w;return function(){var _=w;w=U;try{return T.apply(this,arguments)}finally{w=_}}}})(od)),od}var Wv;function uE(){return Wv||(Wv=1,rd.exports=sE()),rd.exports}var id={exports:{}},Rt={};var ey;function cE(){if(ey)return Rt;ey=1;var n=Wd();function r(y){var g="https://react.dev/errors/"+y;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)g+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+y+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(){}var l={d:{f:o,r:function(){throw Error(r(522))},D:o,C:o,L:o,m:o,X:o,S:o,M:o},p:0,findDOMNode:null},s=Symbol.for("react.portal");function c(y,g,b){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:p==null?null:""+p,children:y,containerInfo:g,implementation:b}}var d=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(y,g){if(y==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Rt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,Rt.createPortal=function(y,g){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(r(299));return c(y,g,null,b)},Rt.flushSync=function(y){var g=d.T,b=l.p;try{if(d.T=null,l.p=2,y)return y()}finally{d.T=g,l.p=b,l.d.f()}},Rt.preconnect=function(y,g){typeof y=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,l.d.C(y,g))},Rt.prefetchDNS=function(y){typeof y=="string"&&l.d.D(y)},Rt.preinit=function(y,g){if(typeof y=="string"&&g&&typeof g.as=="string"){var b=g.as,p=m(b,g.crossOrigin),w=typeof g.integrity=="string"?g.integrity:void 0,C=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;b==="style"?l.d.S(y,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:p,integrity:w,fetchPriority:C}):b==="script"&&l.d.X(y,{crossOrigin:p,integrity:w,fetchPriority:C,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Rt.preinitModule=function(y,g){if(typeof y=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var b=m(g.as,g.crossOrigin);l.d.M(y,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&l.d.M(y)},Rt.preload=function(y,g){if(typeof y=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var b=g.as,p=m(b,g.crossOrigin);l.d.L(y,b,{crossOrigin:p,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Rt.preloadModule=function(y,g){if(typeof y=="string")if(g){var b=m(g.as,g.crossOrigin);l.d.m(y,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else l.d.m(y)},Rt.requestFormReset=function(y){l.d.r(y)},Rt.unstable_batchedUpdates=function(y,g){return y(g)},Rt.useFormState=function(y,g,b){return d.H.useFormState(y,g,b)},Rt.useFormStatus=function(){return d.H.useHostTransitionStatus()},Rt.version="19.2.3",Rt}var ty;function hb(){if(ty)return id.exports;ty=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}return n(),id.exports=cE(),id.exports}var ny;function fE(){if(ny)return Yi;ny=1;var n=uE(),r=Wd(),o=hb();function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function d(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function m(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function y(e){if(c(e)!==e)throw Error(l(188))}function g(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(l(188));return t!==e?null:e}for(var a=e,i=t;;){var u=a.return;if(u===null)break;var f=u.alternate;if(f===null){if(i=u.return,i!==null){a=i;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===a)return y(u),e;if(f===i)return y(u),t;f=f.sibling}throw Error(l(188))}if(a.return!==i.return)a=u,i=f;else{for(var x=!1,E=u.child;E;){if(E===a){x=!0,a=u,i=f;break}if(E===i){x=!0,i=u,a=f;break}E=E.sibling}if(!x){for(E=f.child;E;){if(E===a){x=!0,a=f,i=u;break}if(E===i){x=!0,i=f,a=u;break}E=E.sibling}if(!x)throw Error(l(189))}}if(a.alternate!==i)throw Error(l(190))}if(a.tag!==3)throw Error(l(188));return a.stateNode.current===a?e:t}function b(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=b(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,w=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),k=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),ie=Symbol.for("react.memo_cache_sentinel"),oe=Symbol.iterator;function fe(e){return e===null||typeof e!="object"?null:(e=oe&&e[oe]||e["@@iterator"],typeof e=="function"?e:null)}var ge=Symbol.for("react.client.reference");function ae(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ge?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case j:return"Profiler";case N:return"StrictMode";case I:return"Suspense";case Z:return"SuspenseList";case ue:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case R:return"Portal";case k:return e.displayName||"Context";case O:return(e._context.displayName||"Context")+".Consumer";case Q:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case B:return t=e.displayName||null,t!==null?t:ae(e.type)||"Memo";case G:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var W=Array.isArray,T=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_={pending:!1,data:null,method:null,action:null},F=[],ne=-1;function M(e){return{current:e}}function A(e){0>ne||(e.current=F[ne],F[ne]=null,ne--)}function L(e,t){ne++,F[ne]=e.current,e.current=t}var P=M(null),K=M(null),re=M(null),Y=M(null);function le(e,t){switch(L(re,t),L(K,e),L(P,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?gv(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=gv(t),e=vv(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}A(P),L(P,e)}function ce(){A(P),A(K),A(re)}function ve(e){e.memoizedState!==null&&L(Y,e);var t=P.current,a=vv(t,e.type);t!==a&&(L(K,e),L(P,a))}function we(e){K.current===e&&(A(P),A(K)),Y.current===e&&(A(Y),qi._currentValue=_)}var Ce,et;function ut(e){if(Ce===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||"",et=-1<a.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Ce+e+et}var Qn=!1;function Dn(e,t){if(!e||Qn)return"";Qn=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var te=function(){throw Error()};if(Object.defineProperty(te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(te,[])}catch(X){var V=X}Reflect.construct(e,[],te)}else{try{te.call()}catch(X){V=X}e.call(te.prototype)}}else{try{throw Error()}catch(X){V=X}(te=e())&&typeof te.catch=="function"&&te.catch(function(){})}}catch(X){if(X&&V&&typeof X.stack=="string")return[X.stack,V.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=i.DetermineComponentFrameRoot(),x=f[0],E=f[1];if(x&&E){var D=x.split(`
@@ -55,4 +55,4 @@ If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHid
55
55
 
56
56
  For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return v.useEffect(()=>{n&&(document.getElementById(n)||console.error(o))},[o,n]),null},zN="DialogDescriptionWarning",kN=({contentRef:n,descriptionId:r})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${v0(zN).contentName}}.`;return v.useEffect(()=>{const s=n.current?.getAttribute("aria-describedby");r&&s&&(document.getElementById(r)||console.warn(l))},[l,n,r]),null},wu=r0,Su=l0,Eu=s0,Cu=u0,vh=f0,LN=h0,y0=p0,Ly=1,UN=.9,HN=.8,BN=.17,vd=.1,yd=.999,PN=.9999,qN=.99,$N=/[\\\/_+.#"@\[\(\{&]/,VN=/[\\\/_+.#"@\[\(\{&]/g,FN=/[\s-]/,b0=/[\s-]/g;function Pd(n,r,o,l,s,c,d){if(c===r.length)return s===n.length?Ly:qN;var m=`${s},${c}`;if(d[m]!==void 0)return d[m];for(var y=l.charAt(c),g=o.indexOf(y,s),b=0,p,w,C,R;g>=0;)p=Pd(n,r,o,l,g+1,c+1,d),p>b&&(g===s?p*=Ly:$N.test(n.charAt(g-1))?(p*=HN,C=n.slice(s,g-1).match(VN),C&&s>0&&(p*=Math.pow(yd,C.length))):FN.test(n.charAt(g-1))?(p*=UN,R=n.slice(s,g-1).match(b0),R&&s>0&&(p*=Math.pow(yd,R.length))):(p*=BN,s>0&&(p*=Math.pow(yd,g-s))),n.charAt(g)!==r.charAt(c)&&(p*=PN)),(p<vd&&o.charAt(g-1)===l.charAt(c+1)||l.charAt(c+1)===l.charAt(c)&&o.charAt(g-1)!==l.charAt(c))&&(w=Pd(n,r,o,l,g+1,c+2,d),w*vd>p&&(p=w*vd)),p>b&&(b=p),g=o.indexOf(y,g+1);return d[m]=b,b}function Uy(n){return n.toLowerCase().replace(b0," ")}function GN(n,r,o){return n=o&&o.length>0?`${n+" "+o.join(" ")}`:n,Pd(n,r,Uy(n),Uy(r),0,0,{})}var YN=Symbol.for("react.lazy"),tu=eh[" use ".trim().toString()];function IN(n){return typeof n=="object"&&n!==null&&"then"in n}function x0(n){return n!=null&&typeof n=="object"&&"$$typeof"in n&&n.$$typeof===YN&&"_payload"in n&&IN(n._payload)}function yh(n){const r=KN(n),o=v.forwardRef((l,s)=>{let{children:c,...d}=l;x0(c)&&typeof tu=="function"&&(c=tu(c._payload));const m=v.Children.toArray(c),y=m.find(ZN);if(y){const g=y.props.children,b=m.map(p=>p===y?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:p);return h.jsx(r,{...d,ref:s,children:v.isValidElement(g)?v.cloneElement(g,void 0,b):null})}return h.jsx(r,{...d,ref:s,children:c})});return o.displayName=`${n}.Slot`,o}var QN=yh("Slot");function KN(n){const r=v.forwardRef((o,l)=>{let{children:s,...c}=o;if(x0(s)&&typeof tu=="function"&&(s=tu(s._payload)),v.isValidElement(s)){const d=WN(s),m=JN(c,s.props);return s.type!==v.Fragment&&(m.ref=l?It(l,d):d),v.cloneElement(s,m)}return v.Children.count(s)>1?v.Children.only(null):null});return r.displayName=`${n}.SlotClone`,r}var XN=Symbol("radix.slottable");function ZN(n){return v.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===XN}function JN(n,r){const o={...r};for(const l in r){const s=n[l],c=r[l];/^on[A-Z]/.test(l)?s&&c?o[l]=(...m)=>{const y=c(...m);return s(...m),y}:s&&(o[l]=s):l==="style"?o[l]={...s,...c}:l==="className"&&(o[l]=[s,c].filter(Boolean).join(" "))}return{...n,...o}}function WN(n){let r=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?n.ref:(r=Object.getOwnPropertyDescriptor(n,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?n.props.ref:n.props.ref||n.ref)}var eT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ar=eT.reduce((n,r)=>{const o=yh(`Primitive.${r}`),l=v.forwardRef((s,c)=>{const{asChild:d,...m}=s,y=d?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(y,{...m,ref:c})});return l.displayName=`Primitive.${r}`,{...n,[r]:l}},{}),Qi='[cmdk-group=""]',bd='[cmdk-group-items=""]',tT='[cmdk-group-heading=""]',w0='[cmdk-item=""]',Hy=`${w0}:not([aria-disabled="true"])`,qd="cmdk-item-select",_o="data-value",nT=(n,r,o)=>GN(n,r,o),S0=v.createContext(void 0),fl=()=>v.useContext(S0),E0=v.createContext(void 0),bh=()=>v.useContext(E0),C0=v.createContext(void 0),R0=v.forwardRef((n,r)=>{let o=Do(()=>{var A,L;return{search:"",value:(L=(A=n.value)!=null?A:n.defaultValue)!=null?L:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),l=Do(()=>new Set),s=Do(()=>new Map),c=Do(()=>new Map),d=Do(()=>new Set),m=N0(n),{label:y,children:g,value:b,onValueChange:p,filter:w,shouldFilter:C,loop:R,disablePointerSelection:S=!1,vimBindings:N=!0,...j}=n,O=_t(),k=_t(),Q=_t(),I=v.useRef(null),Z=hT();Dr(()=>{if(b!==void 0){let A=b.trim();o.current.value=A,B.emit()}},[b]),Dr(()=>{Z(6,ge)},[]);let B=v.useMemo(()=>({subscribe:A=>(d.current.add(A),()=>d.current.delete(A)),snapshot:()=>o.current,setState:(A,L,P)=>{var K,re,Y,le;if(!Object.is(o.current[A],L)){if(o.current[A]=L,A==="search")fe(),ie(),Z(1,oe);else if(A==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ce=document.getElementById(Q);ce?ce.focus():(K=document.getElementById(O))==null||K.focus()}if(Z(7,()=>{var ce;o.current.selectedItemId=(ce=ae())==null?void 0:ce.id,B.emit()}),P||Z(5,ge),((re=m.current)==null?void 0:re.value)!==void 0){let ce=L??"";(le=(Y=m.current).onValueChange)==null||le.call(Y,ce);return}}B.emit()}},emit:()=>{d.current.forEach(A=>A())}}),[]),G=v.useMemo(()=>({value:(A,L,P)=>{var K;L!==((K=c.current.get(A))==null?void 0:K.value)&&(c.current.set(A,{value:L,keywords:P}),o.current.filtered.items.set(A,ue(L,P)),Z(2,()=>{ie(),B.emit()}))},item:(A,L)=>(l.current.add(A),L&&(s.current.has(L)?s.current.get(L).add(A):s.current.set(L,new Set([A]))),Z(3,()=>{fe(),ie(),o.current.value||oe(),B.emit()}),()=>{c.current.delete(A),l.current.delete(A),o.current.filtered.items.delete(A);let P=ae();Z(4,()=>{fe(),P?.getAttribute("id")===A&&oe(),B.emit()})}),group:A=>(s.current.has(A)||s.current.set(A,new Set),()=>{c.current.delete(A),s.current.delete(A)}),filter:()=>m.current.shouldFilter,label:y||n["aria-label"],getDisablePointerSelection:()=>m.current.disablePointerSelection,listId:O,inputId:Q,labelId:k,listInnerRef:I}),[]);function ue(A,L){var P,K;let re=(K=(P=m.current)==null?void 0:P.filter)!=null?K:nT;return A?re(A,o.current.search,L):0}function ie(){if(!o.current.search||m.current.shouldFilter===!1)return;let A=o.current.filtered.items,L=[];o.current.filtered.groups.forEach(K=>{let re=s.current.get(K),Y=0;re.forEach(le=>{let ce=A.get(le);Y=Math.max(ce,Y)}),L.push([K,Y])});let P=I.current;W().sort((K,re)=>{var Y,le;let ce=K.getAttribute("id"),ve=re.getAttribute("id");return((Y=A.get(ve))!=null?Y:0)-((le=A.get(ce))!=null?le:0)}).forEach(K=>{let re=K.closest(bd);re?re.appendChild(K.parentElement===re?K:K.closest(`${bd} > *`)):P.appendChild(K.parentElement===P?K:K.closest(`${bd} > *`))}),L.sort((K,re)=>re[1]-K[1]).forEach(K=>{var re;let Y=(re=I.current)==null?void 0:re.querySelector(`${Qi}[${_o}="${encodeURIComponent(K[0])}"]`);Y?.parentElement.appendChild(Y)})}function oe(){let A=W().find(P=>P.getAttribute("aria-disabled")!=="true"),L=A?.getAttribute(_o);B.setState("value",L||void 0)}function fe(){var A,L,P,K;if(!o.current.search||m.current.shouldFilter===!1){o.current.filtered.count=l.current.size;return}o.current.filtered.groups=new Set;let re=0;for(let Y of l.current){let le=(L=(A=c.current.get(Y))==null?void 0:A.value)!=null?L:"",ce=(K=(P=c.current.get(Y))==null?void 0:P.keywords)!=null?K:[],ve=ue(le,ce);o.current.filtered.items.set(Y,ve),ve>0&&re++}for(let[Y,le]of s.current)for(let ce of le)if(o.current.filtered.items.get(ce)>0){o.current.filtered.groups.add(Y);break}o.current.filtered.count=re}function ge(){var A,L,P;let K=ae();K&&(((A=K.parentElement)==null?void 0:A.firstChild)===K&&((P=(L=K.closest(Qi))==null?void 0:L.querySelector(tT))==null||P.scrollIntoView({block:"nearest"})),K.scrollIntoView({block:"nearest"}))}function ae(){var A;return(A=I.current)==null?void 0:A.querySelector(`${w0}[aria-selected="true"]`)}function W(){var A;return Array.from(((A=I.current)==null?void 0:A.querySelectorAll(Hy))||[])}function T(A){let L=W()[A];L&&B.setState("value",L.getAttribute(_o))}function U(A){var L;let P=ae(),K=W(),re=K.findIndex(le=>le===P),Y=K[re+A];(L=m.current)!=null&&L.loop&&(Y=re+A<0?K[K.length-1]:re+A===K.length?K[0]:K[re+A]),Y&&B.setState("value",Y.getAttribute(_o))}function _(A){let L=ae(),P=L?.closest(Qi),K;for(;P&&!K;)P=A>0?fT(P,Qi):dT(P,Qi),K=P?.querySelector(Hy);K?B.setState("value",K.getAttribute(_o)):U(A)}let F=()=>T(W().length-1),ne=A=>{A.preventDefault(),A.metaKey?F():A.altKey?_(1):U(1)},M=A=>{A.preventDefault(),A.metaKey?T(0):A.altKey?_(-1):U(-1)};return v.createElement(ar.div,{ref:r,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:A=>{var L;(L=j.onKeyDown)==null||L.call(j,A);let P=A.nativeEvent.isComposing||A.keyCode===229;if(!(A.defaultPrevented||P))switch(A.key){case"n":case"j":{N&&A.ctrlKey&&ne(A);break}case"ArrowDown":{ne(A);break}case"p":case"k":{N&&A.ctrlKey&&M(A);break}case"ArrowUp":{M(A);break}case"Home":{A.preventDefault(),T(0);break}case"End":{A.preventDefault(),F();break}case"Enter":{A.preventDefault();let K=ae();if(K){let re=new Event(qd);K.dispatchEvent(re)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:G.inputId,id:G.labelId,style:pT},y),Ru(n,A=>v.createElement(E0.Provider,{value:B},v.createElement(S0.Provider,{value:G},A))))}),aT=v.forwardRef((n,r)=>{var o,l;let s=_t(),c=v.useRef(null),d=v.useContext(C0),m=fl(),y=N0(n),g=(l=(o=y.current)==null?void 0:o.forceMount)!=null?l:d?.forceMount;Dr(()=>{if(!g)return m.item(s,d?.id)},[g]);let b=T0(s,c,[n.value,n.children,c],n.keywords),p=bh(),w=Ja(Z=>Z.value&&Z.value===b.current),C=Ja(Z=>g||m.filter()===!1?!0:Z.search?Z.filtered.items.get(s)>0:!0);v.useEffect(()=>{let Z=c.current;if(!(!Z||n.disabled))return Z.addEventListener(qd,R),()=>Z.removeEventListener(qd,R)},[C,n.onSelect,n.disabled]);function R(){var Z,B;S(),(B=(Z=y.current).onSelect)==null||B.call(Z,b.current)}function S(){p.setState("value",b.current,!0)}if(!C)return null;let{disabled:N,value:j,onSelect:O,forceMount:k,keywords:Q,...I}=n;return v.createElement(ar.div,{ref:It(c,r),...I,id:s,"cmdk-item":"",role:"option","aria-disabled":!!N,"aria-selected":!!w,"data-disabled":!!N,"data-selected":!!w,onPointerMove:N||m.getDisablePointerSelection()?void 0:S,onClick:N?void 0:R},n.children)}),rT=v.forwardRef((n,r)=>{let{heading:o,children:l,forceMount:s,...c}=n,d=_t(),m=v.useRef(null),y=v.useRef(null),g=_t(),b=fl(),p=Ja(C=>s||b.filter()===!1?!0:C.search?C.filtered.groups.has(d):!0);Dr(()=>b.group(d),[]),T0(d,m,[n.value,n.heading,y]);let w=v.useMemo(()=>({id:d,forceMount:s}),[s]);return v.createElement(ar.div,{ref:It(m,r),...c,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},o&&v.createElement("div",{ref:y,"cmdk-group-heading":"","aria-hidden":!0,id:g},o),Ru(n,C=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":o?g:void 0},v.createElement(C0.Provider,{value:w},C))))}),oT=v.forwardRef((n,r)=>{let{alwaysRender:o,...l}=n,s=v.useRef(null),c=Ja(d=>!d.search);return!o&&!c?null:v.createElement(ar.div,{ref:It(s,r),...l,"cmdk-separator":"",role:"separator"})}),iT=v.forwardRef((n,r)=>{let{onValueChange:o,...l}=n,s=n.value!=null,c=bh(),d=Ja(g=>g.search),m=Ja(g=>g.selectedItemId),y=fl();return v.useEffect(()=>{n.value!=null&&c.setState("search",n.value)},[n.value]),v.createElement(ar.input,{ref:r,...l,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":y.listId,"aria-labelledby":y.labelId,"aria-activedescendant":m,id:y.inputId,type:"text",value:s?n.value:d,onChange:g=>{s||c.setState("search",g.target.value),o?.(g.target.value)}})}),lT=v.forwardRef((n,r)=>{let{children:o,label:l="Suggestions",...s}=n,c=v.useRef(null),d=v.useRef(null),m=Ja(g=>g.selectedItemId),y=fl();return v.useEffect(()=>{if(d.current&&c.current){let g=d.current,b=c.current,p,w=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let C=g.offsetHeight;b.style.setProperty("--cmdk-list-height",C.toFixed(1)+"px")})});return w.observe(g),()=>{cancelAnimationFrame(p),w.unobserve(g)}}},[]),v.createElement(ar.div,{ref:It(c,r),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":m,"aria-label":l,id:y.listId},Ru(n,g=>v.createElement("div",{ref:It(d,y.listInnerRef),"cmdk-list-sizer":""},g)))}),sT=v.forwardRef((n,r)=>{let{open:o,onOpenChange:l,overlayClassName:s,contentClassName:c,container:d,...m}=n;return v.createElement(wu,{open:o,onOpenChange:l},v.createElement(Su,{container:d},v.createElement(Eu,{"cmdk-overlay":"",className:s}),v.createElement(Cu,{"aria-label":n.label,"cmdk-dialog":"",className:c},v.createElement(R0,{ref:r,...m}))))}),uT=v.forwardRef((n,r)=>Ja(o=>o.filtered.count===0)?v.createElement(ar.div,{ref:r,...n,"cmdk-empty":"",role:"presentation"}):null),cT=v.forwardRef((n,r)=>{let{progress:o,children:l,label:s="Loading...",...c}=n;return v.createElement(ar.div,{ref:r,...c,"cmdk-loading":"",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},Ru(n,d=>v.createElement("div",{"aria-hidden":!0},d)))}),pa=Object.assign(R0,{List:lT,Item:aT,Input:iT,Group:rT,Separator:oT,Dialog:sT,Empty:uT,Loading:cT});function fT(n,r){let o=n.nextElementSibling;for(;o;){if(o.matches(r))return o;o=o.nextElementSibling}}function dT(n,r){let o=n.previousElementSibling;for(;o;){if(o.matches(r))return o;o=o.previousElementSibling}}function N0(n){let r=v.useRef(n);return Dr(()=>{r.current=n}),r}var Dr=typeof window>"u"?v.useEffect:v.useLayoutEffect;function Do(n){let r=v.useRef();return r.current===void 0&&(r.current=n()),r}function Ja(n){let r=bh(),o=()=>n(r.snapshot());return v.useSyncExternalStore(r.subscribe,o,o)}function T0(n,r,o,l=[]){let s=v.useRef(),c=fl();return Dr(()=>{var d;let m=(()=>{var g;for(let b of o){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(g=b.current.textContent)==null?void 0:g.trim():s.current}})(),y=l.map(g=>g.trim());c.value(n,m,y),(d=r.current)==null||d.setAttribute(_o,m),s.current=m}),s}var hT=()=>{let[n,r]=v.useState(),o=Do(()=>new Map);return Dr(()=>{o.current.forEach(l=>l()),o.current=new Map},[n]),(l,s)=>{o.current.set(l,s),r({})}};function mT(n){let r=n.type;return typeof r=="function"?r(n.props):"render"in r?r.render(n.props):n}function Ru({asChild:n,children:r},o){return n&&v.isValidElement(r)?v.cloneElement(mT(r),{ref:r.ref},o(r.props.children)):o(r)}var pT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gT=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),vT=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,o,l)=>l?l.toUpperCase():o.toLowerCase()),By=n=>{const r=vT(n);return r.charAt(0).toUpperCase()+r.slice(1)},j0=(...n)=>n.filter((r,o,l)=>!!r&&r.trim()!==""&&l.indexOf(r)===o).join(" ").trim(),yT=n=>{for(const r in n)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var bT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const xT=v.forwardRef(({color:n="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:s="",children:c,iconNode:d,...m},y)=>v.createElement("svg",{ref:y,...bT,width:r,height:r,stroke:n,strokeWidth:l?Number(o)*24/Number(r):o,className:j0("lucide",s),...!c&&!yT(m)&&{"aria-hidden":"true"},...m},[...d.map(([g,b])=>v.createElement(g,b)),...Array.isArray(c)?c:[c]]));const Qe=(n,r)=>{const o=v.forwardRef(({className:l,...s},c)=>v.createElement(xT,{ref:c,iconNode:r,className:j0(`lucide-${gT(By(n))}`,`lucide-${n}`,l),...s}));return o.displayName=By(n),o};const wT=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ST=Qe("arrow-left",wT);const ET=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],CT=Qe("arrow-up",ET);const RT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],M0=Qe("check",RT);const NT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],A0=Qe("chevron-down",NT);const TT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],jT=Qe("chevron-up",TT);const MT=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],AT=Qe("circle-check-big",MT);const OT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_T=Qe("circle-x",OT);const DT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],zT=Qe("circle",DT);const kT=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],LT=Qe("clock",kT);const UT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Nu=Qe("film",UT);const HT=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],O0=Qe("folder-open",HT);const BT=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],PT=Qe("folder",BT);const qT=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],$T=Qe("heart",qT);const VT=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Tu=Qe("loader-circle",VT);const FT=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],GT=Qe("pencil",FT);const YT=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],IT=Qe("play",YT);const QT=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],nu=Qe("plus",QT);const KT=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],XT=Qe("refresh-cw",KT);const ZT=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]],JT=Qe("scan-line",ZT);const WT=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_0=Qe("search",WT);const ej=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],tj=Qe("settings",ej);const nj=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],xh=Qe("trash-2",nj);const aj=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],rj=Qe("triangle-alert",aj);const oj=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],ij=Qe("users",oj);const lj=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],D0=Qe("x",lj);function z0(n){var r,o,l="";if(typeof n=="string"||typeof n=="number")l+=n;else if(typeof n=="object")if(Array.isArray(n)){var s=n.length;for(r=0;r<s;r++)n[r]&&(o=z0(n[r]))&&(l&&(l+=" "),l+=o)}else for(o in n)n[o]&&(l&&(l+=" "),l+=o);return l}function k0(){for(var n,r,o=0,l="",s=arguments.length;o<s;o++)(n=arguments[o])&&(r=z0(n))&&(l&&(l+=" "),l+=r);return l}const sj=(n,r)=>{const o=new Array(n.length+r.length);for(let l=0;l<n.length;l++)o[l]=n[l];for(let l=0;l<r.length;l++)o[n.length+l]=r[l];return o},uj=(n,r)=>({classGroupId:n,validator:r}),L0=(n=new Map,r=null,o)=>({nextPart:n,validators:r,classGroupId:o}),au="-",Py=[],cj="arbitrary..",fj=n=>{const r=hj(n),{conflictingClassGroups:o,conflictingClassGroupModifiers:l}=n;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return dj(d);const m=d.split(au),y=m[0]===""&&m.length>1?1:0;return U0(m,y,r)},getConflictingClassGroupIds:(d,m)=>{if(m){const y=l[d],g=o[d];return y?g?sj(g,y):y:g||Py}return o[d]||Py}}},U0=(n,r,o)=>{if(n.length-r===0)return o.classGroupId;const s=n[r],c=o.nextPart.get(s);if(c){const g=U0(n,r+1,c);if(g)return g}const d=o.validators;if(d===null)return;const m=r===0?n.join(au):n.slice(r).join(au),y=d.length;for(let g=0;g<y;g++){const b=d[g];if(b.validator(m))return b.classGroupId}},dj=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=n.slice(1,-1),o=r.indexOf(":"),l=r.slice(0,o);return l?cj+l:void 0})(),hj=n=>{const{theme:r,classGroups:o}=n;return mj(o,r)},mj=(n,r)=>{const o=L0();for(const l in n){const s=n[l];wh(s,o,l,r)}return o},wh=(n,r,o,l)=>{const s=n.length;for(let c=0;c<s;c++){const d=n[c];pj(d,r,o,l)}},pj=(n,r,o,l)=>{if(typeof n=="string"){gj(n,r,o);return}if(typeof n=="function"){vj(n,r,o,l);return}yj(n,r,o,l)},gj=(n,r,o)=>{const l=n===""?r:H0(r,n);l.classGroupId=o},vj=(n,r,o,l)=>{if(bj(n)){wh(n(l),r,o,l);return}r.validators===null&&(r.validators=[]),r.validators.push(uj(o,n))},yj=(n,r,o,l)=>{const s=Object.entries(n),c=s.length;for(let d=0;d<c;d++){const[m,y]=s[d];wh(y,H0(r,m),o,l)}},H0=(n,r)=>{let o=n;const l=r.split(au),s=l.length;for(let c=0;c<s;c++){const d=l[c];let m=o.nextPart.get(d);m||(m=L0(),o.nextPart.set(d,m)),o=m}return o},bj=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,xj=n=>{if(n<1)return{get:()=>{},set:()=>{}};let r=0,o=Object.create(null),l=Object.create(null);const s=(c,d)=>{o[c]=d,r++,r>n&&(r=0,l=o,o=Object.create(null))};return{get(c){let d=o[c];if(d!==void 0)return d;if((d=l[c])!==void 0)return s(c,d),d},set(c,d){c in o?o[c]=d:s(c,d)}}},$d="!",qy=":",wj=[],$y=(n,r,o,l,s)=>({modifiers:n,hasImportantModifier:r,baseClassName:o,maybePostfixModifierPosition:l,isExternal:s}),Sj=n=>{const{prefix:r,experimentalParseClassName:o}=n;let l=s=>{const c=[];let d=0,m=0,y=0,g;const b=s.length;for(let S=0;S<b;S++){const N=s[S];if(d===0&&m===0){if(N===qy){c.push(s.slice(y,S)),y=S+1;continue}if(N==="/"){g=S;continue}}N==="["?d++:N==="]"?d--:N==="("?m++:N===")"&&m--}const p=c.length===0?s:s.slice(y);let w=p,C=!1;p.endsWith($d)?(w=p.slice(0,-1),C=!0):p.startsWith($d)&&(w=p.slice(1),C=!0);const R=g&&g>y?g-y:void 0;return $y(c,C,w,R)};if(r){const s=r+qy,c=l;l=d=>d.startsWith(s)?c(d.slice(s.length)):$y(wj,!1,d,void 0,!0)}if(o){const s=l;l=c=>o({className:c,parseClassName:s})}return l},Ej=n=>{const r=new Map;return n.orderSensitiveModifiers.forEach((o,l)=>{r.set(o,1e6+l)}),o=>{const l=[];let s=[];for(let c=0;c<o.length;c++){const d=o[c],m=d[0]==="[",y=r.has(d);m||y?(s.length>0&&(s.sort(),l.push(...s),s=[]),l.push(d)):s.push(d)}return s.length>0&&(s.sort(),l.push(...s)),l}},Cj=n=>({cache:xj(n.cacheSize),parseClassName:Sj(n),sortModifiers:Ej(n),...fj(n)}),Rj=/\s+/,Nj=(n,r)=>{const{parseClassName:o,getClassGroupId:l,getConflictingClassGroupIds:s,sortModifiers:c}=r,d=[],m=n.trim().split(Rj);let y="";for(let g=m.length-1;g>=0;g-=1){const b=m[g],{isExternal:p,modifiers:w,hasImportantModifier:C,baseClassName:R,maybePostfixModifierPosition:S}=o(b);if(p){y=b+(y.length>0?" "+y:y);continue}let N=!!S,j=l(N?R.substring(0,S):R);if(!j){if(!N){y=b+(y.length>0?" "+y:y);continue}if(j=l(R),!j){y=b+(y.length>0?" "+y:y);continue}N=!1}const O=w.length===0?"":w.length===1?w[0]:c(w).join(":"),k=C?O+$d:O,Q=k+j;if(d.indexOf(Q)>-1)continue;d.push(Q);const I=s(j,N);for(let Z=0;Z<I.length;++Z){const B=I[Z];d.push(k+B)}y=b+(y.length>0?" "+y:y)}return y},Tj=(...n)=>{let r=0,o,l,s="";for(;r<n.length;)(o=n[r++])&&(l=B0(o))&&(s&&(s+=" "),s+=l);return s},B0=n=>{if(typeof n=="string")return n;let r,o="";for(let l=0;l<n.length;l++)n[l]&&(r=B0(n[l]))&&(o&&(o+=" "),o+=r);return o},jj=(n,...r)=>{let o,l,s,c;const d=y=>{const g=r.reduce((b,p)=>p(b),n());return o=Cj(g),l=o.cache.get,s=o.cache.set,c=m,m(y)},m=y=>{const g=l(y);if(g)return g;const b=Nj(y,o);return s(y,b),b};return c=d,(...y)=>c(Tj(...y))},Mj=[],ft=n=>{const r=o=>o[n]||Mj;return r.isThemeGetter=!0,r},P0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,q0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Aj=/^\d+\/\d+$/,Oj=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_j=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Dj=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,zj=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kj=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oo=n=>Aj.test(n),Te=n=>!!n&&!Number.isNaN(Number(n)),Qa=n=>!!n&&Number.isInteger(Number(n)),xd=n=>n.endsWith("%")&&Te(n.slice(0,-1)),ma=n=>Oj.test(n),Lj=()=>!0,Uj=n=>_j.test(n)&&!Dj.test(n),$0=()=>!1,Hj=n=>zj.test(n),Bj=n=>kj.test(n),Pj=n=>!me(n)&&!pe(n),qj=n=>Fo(n,G0,$0),me=n=>P0.test(n),jr=n=>Fo(n,Y0,Uj),wd=n=>Fo(n,Yj,Te),Vy=n=>Fo(n,V0,$0),$j=n=>Fo(n,F0,Bj),Bs=n=>Fo(n,I0,Hj),pe=n=>q0.test(n),Ki=n=>Go(n,Y0),Vj=n=>Go(n,Ij),Fy=n=>Go(n,V0),Fj=n=>Go(n,G0),Gj=n=>Go(n,F0),Ps=n=>Go(n,I0,!0),Fo=(n,r,o)=>{const l=P0.exec(n);return l?l[1]?r(l[1]):o(l[2]):!1},Go=(n,r,o=!1)=>{const l=q0.exec(n);return l?l[1]?r(l[1]):o:!1},V0=n=>n==="position"||n==="percentage",F0=n=>n==="image"||n==="url",G0=n=>n==="length"||n==="size"||n==="bg-size",Y0=n=>n==="length",Yj=n=>n==="number",Ij=n=>n==="family-name",I0=n=>n==="shadow",Qj=()=>{const n=ft("color"),r=ft("font"),o=ft("text"),l=ft("font-weight"),s=ft("tracking"),c=ft("leading"),d=ft("breakpoint"),m=ft("container"),y=ft("spacing"),g=ft("radius"),b=ft("shadow"),p=ft("inset-shadow"),w=ft("text-shadow"),C=ft("drop-shadow"),R=ft("blur"),S=ft("perspective"),N=ft("aspect"),j=ft("ease"),O=ft("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Q=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...Q(),pe,me],Z=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],G=()=>[pe,me,y],ue=()=>[Oo,"full","auto",...G()],ie=()=>[Qa,"none","subgrid",pe,me],oe=()=>["auto",{span:["full",Qa,pe,me]},Qa,pe,me],fe=()=>[Qa,"auto",pe,me],ge=()=>["auto","min","max","fr",pe,me],ae=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],W=()=>["start","end","center","stretch","center-safe","end-safe"],T=()=>["auto",...G()],U=()=>[Oo,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...G()],_=()=>[n,pe,me],F=()=>[...Q(),Fy,Vy,{position:[pe,me]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],M=()=>["auto","cover","contain",Fj,qj,{size:[pe,me]}],A=()=>[xd,Ki,jr],L=()=>["","none","full",g,pe,me],P=()=>["",Te,Ki,jr],K=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Y=()=>[Te,xd,Fy,Vy],le=()=>["","none",R,pe,me],ce=()=>["none",Te,pe,me],ve=()=>["none",Te,pe,me],we=()=>[Te,pe,me],Ce=()=>[Oo,"full",...G()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ma],breakpoint:[ma],color:[Lj],container:[ma],"drop-shadow":[ma],ease:["in","out","in-out"],font:[Pj],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ma],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ma],shadow:[ma],spacing:["px",Te],text:[ma],"text-shadow":[ma],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Oo,me,pe,N]}],container:["container"],columns:[{columns:[Te,me,pe,m]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:I()}],overflow:[{overflow:Z()}],"overflow-x":[{"overflow-x":Z()}],"overflow-y":[{"overflow-y":Z()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:ue()}],"inset-x":[{"inset-x":ue()}],"inset-y":[{"inset-y":ue()}],start:[{start:ue()}],end:[{end:ue()}],top:[{top:ue()}],right:[{right:ue()}],bottom:[{bottom:ue()}],left:[{left:ue()}],visibility:["visible","invisible","collapse"],z:[{z:[Qa,"auto",pe,me]}],basis:[{basis:[Oo,"full","auto",m,...G()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Te,Oo,"auto","initial","none",me]}],grow:[{grow:["",Te,pe,me]}],shrink:[{shrink:["",Te,pe,me]}],order:[{order:[Qa,"first","last","none",pe,me]}],"grid-cols":[{"grid-cols":ie()}],"col-start-end":[{col:oe()}],"col-start":[{"col-start":fe()}],"col-end":[{"col-end":fe()}],"grid-rows":[{"grid-rows":ie()}],"row-start-end":[{row:oe()}],"row-start":[{"row-start":fe()}],"row-end":[{"row-end":fe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ge()}],"auto-rows":[{"auto-rows":ge()}],gap:[{gap:G()}],"gap-x":[{"gap-x":G()}],"gap-y":[{"gap-y":G()}],"justify-content":[{justify:[...ae(),"normal"]}],"justify-items":[{"justify-items":[...W(),"normal"]}],"justify-self":[{"justify-self":["auto",...W()]}],"align-content":[{content:["normal",...ae()]}],"align-items":[{items:[...W(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...W(),{baseline:["","last"]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...W(),"baseline"]}],"place-self":[{"place-self":["auto",...W()]}],p:[{p:G()}],px:[{px:G()}],py:[{py:G()}],ps:[{ps:G()}],pe:[{pe:G()}],pt:[{pt:G()}],pr:[{pr:G()}],pb:[{pb:G()}],pl:[{pl:G()}],m:[{m:T()}],mx:[{mx:T()}],my:[{my:T()}],ms:[{ms:T()}],me:[{me:T()}],mt:[{mt:T()}],mr:[{mr:T()}],mb:[{mb:T()}],ml:[{ml:T()}],"space-x":[{"space-x":G()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":G()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],w:[{w:[m,"screen",...U()]}],"min-w":[{"min-w":[m,"screen","none",...U()]}],"max-w":[{"max-w":[m,"screen","none","prose",{screen:[d]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",o,Ki,jr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,pe,wd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xd,me]}],"font-family":[{font:[Vj,me,r]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,pe,me]}],"line-clamp":[{"line-clamp":[Te,"none",pe,wd]}],leading:[{leading:[c,...G()]}],"list-image":[{"list-image":["none",pe,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:_()}],"text-color":[{text:_()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:[Te,"from-font","auto",pe,jr]}],"text-decoration-color":[{decoration:_()}],"underline-offset":[{"underline-offset":[Te,"auto",pe,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:G()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:M()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qa,pe,me],radial:["",pe,me],conic:[Qa,pe,me]},Gj,$j]}],"bg-color":[{bg:_()}],"gradient-from-pos":[{from:A()}],"gradient-via-pos":[{via:A()}],"gradient-to-pos":[{to:A()}],"gradient-from":[{from:_()}],"gradient-via":[{via:_()}],"gradient-to":[{to:_()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...K(),"hidden","none"]}],"divide-style":[{divide:[...K(),"hidden","none"]}],"border-color":[{border:_()}],"border-color-x":[{"border-x":_()}],"border-color-y":[{"border-y":_()}],"border-color-s":[{"border-s":_()}],"border-color-e":[{"border-e":_()}],"border-color-t":[{"border-t":_()}],"border-color-r":[{"border-r":_()}],"border-color-b":[{"border-b":_()}],"border-color-l":[{"border-l":_()}],"divide-color":[{divide:_()}],"outline-style":[{outline:[...K(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Te,pe,me]}],"outline-w":[{outline:["",Te,Ki,jr]}],"outline-color":[{outline:_()}],shadow:[{shadow:["","none",b,Ps,Bs]}],"shadow-color":[{shadow:_()}],"inset-shadow":[{"inset-shadow":["none",p,Ps,Bs]}],"inset-shadow-color":[{"inset-shadow":_()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:_()}],"ring-offset-w":[{"ring-offset":[Te,jr]}],"ring-offset-color":[{"ring-offset":_()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":_()}],"text-shadow":[{"text-shadow":["none",w,Ps,Bs]}],"text-shadow-color":[{"text-shadow":_()}],opacity:[{opacity:[Te,pe,me]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Te]}],"mask-image-linear-from-pos":[{"mask-linear-from":Y()}],"mask-image-linear-to-pos":[{"mask-linear-to":Y()}],"mask-image-linear-from-color":[{"mask-linear-from":_()}],"mask-image-linear-to-color":[{"mask-linear-to":_()}],"mask-image-t-from-pos":[{"mask-t-from":Y()}],"mask-image-t-to-pos":[{"mask-t-to":Y()}],"mask-image-t-from-color":[{"mask-t-from":_()}],"mask-image-t-to-color":[{"mask-t-to":_()}],"mask-image-r-from-pos":[{"mask-r-from":Y()}],"mask-image-r-to-pos":[{"mask-r-to":Y()}],"mask-image-r-from-color":[{"mask-r-from":_()}],"mask-image-r-to-color":[{"mask-r-to":_()}],"mask-image-b-from-pos":[{"mask-b-from":Y()}],"mask-image-b-to-pos":[{"mask-b-to":Y()}],"mask-image-b-from-color":[{"mask-b-from":_()}],"mask-image-b-to-color":[{"mask-b-to":_()}],"mask-image-l-from-pos":[{"mask-l-from":Y()}],"mask-image-l-to-pos":[{"mask-l-to":Y()}],"mask-image-l-from-color":[{"mask-l-from":_()}],"mask-image-l-to-color":[{"mask-l-to":_()}],"mask-image-x-from-pos":[{"mask-x-from":Y()}],"mask-image-x-to-pos":[{"mask-x-to":Y()}],"mask-image-x-from-color":[{"mask-x-from":_()}],"mask-image-x-to-color":[{"mask-x-to":_()}],"mask-image-y-from-pos":[{"mask-y-from":Y()}],"mask-image-y-to-pos":[{"mask-y-to":Y()}],"mask-image-y-from-color":[{"mask-y-from":_()}],"mask-image-y-to-color":[{"mask-y-to":_()}],"mask-image-radial":[{"mask-radial":[pe,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":Y()}],"mask-image-radial-to-pos":[{"mask-radial-to":Y()}],"mask-image-radial-from-color":[{"mask-radial-from":_()}],"mask-image-radial-to-color":[{"mask-radial-to":_()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":Q()}],"mask-image-conic-pos":[{"mask-conic":[Te]}],"mask-image-conic-from-pos":[{"mask-conic-from":Y()}],"mask-image-conic-to-pos":[{"mask-conic-to":Y()}],"mask-image-conic-from-color":[{"mask-conic-from":_()}],"mask-image-conic-to-color":[{"mask-conic-to":_()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:M()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,me]}],filter:[{filter:["","none",pe,me]}],blur:[{blur:le()}],brightness:[{brightness:[Te,pe,me]}],contrast:[{contrast:[Te,pe,me]}],"drop-shadow":[{"drop-shadow":["","none",C,Ps,Bs]}],"drop-shadow-color":[{"drop-shadow":_()}],grayscale:[{grayscale:["",Te,pe,me]}],"hue-rotate":[{"hue-rotate":[Te,pe,me]}],invert:[{invert:["",Te,pe,me]}],saturate:[{saturate:[Te,pe,me]}],sepia:[{sepia:["",Te,pe,me]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,me]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Te,pe,me]}],"backdrop-contrast":[{"backdrop-contrast":[Te,pe,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Te,pe,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Te,pe,me]}],"backdrop-invert":[{"backdrop-invert":["",Te,pe,me]}],"backdrop-opacity":[{"backdrop-opacity":[Te,pe,me]}],"backdrop-saturate":[{"backdrop-saturate":[Te,pe,me]}],"backdrop-sepia":[{"backdrop-sepia":["",Te,pe,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":G()}],"border-spacing-x":[{"border-spacing-x":G()}],"border-spacing-y":[{"border-spacing-y":G()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Te,"initial",pe,me]}],ease:[{ease:["linear","initial",j,pe,me]}],delay:[{delay:[Te,pe,me]}],animate:[{animate:["none",O,pe,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,pe,me]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[pe,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ce()}],"translate-x":[{"translate-x":Ce()}],"translate-y":[{"translate-y":Ce()}],"translate-z":[{"translate-z":Ce()}],"translate-none":["translate-none"],accent:[{accent:_()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:_()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":G()}],"scroll-mx":[{"scroll-mx":G()}],"scroll-my":[{"scroll-my":G()}],"scroll-ms":[{"scroll-ms":G()}],"scroll-me":[{"scroll-me":G()}],"scroll-mt":[{"scroll-mt":G()}],"scroll-mr":[{"scroll-mr":G()}],"scroll-mb":[{"scroll-mb":G()}],"scroll-ml":[{"scroll-ml":G()}],"scroll-p":[{"scroll-p":G()}],"scroll-px":[{"scroll-px":G()}],"scroll-py":[{"scroll-py":G()}],"scroll-ps":[{"scroll-ps":G()}],"scroll-pe":[{"scroll-pe":G()}],"scroll-pt":[{"scroll-pt":G()}],"scroll-pr":[{"scroll-pr":G()}],"scroll-pb":[{"scroll-pb":G()}],"scroll-pl":[{"scroll-pl":G()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,me]}],fill:[{fill:["none",..._()]}],"stroke-w":[{stroke:[Te,Ki,jr,wd]}],stroke:[{stroke:["none",..._()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Kj=jj(Qj);function Fe(...n){return Kj(k0(n))}function Xj(n,r){const[o,l]=v.useState(n);return v.useEffect(()=>{const s=window.setTimeout(()=>{l(n)},r);return()=>{window.clearTimeout(s)}},[r,n]),o}async function Zj(n){try{return(await n.json()).error?.message??n.statusText}catch{return n.statusText}}async function Jj(n){const r=new URLSearchParams({q:n}),o=await fetch(`/api/search?${r.toString()}`);if(!o.ok)throw new Error(await Zj(o));return await o.json()}function Wj(n){return St({enabled:n.trim().length>0,queryKey:["search",n],queryFn:()=>Jj(n),staleTime:3e4})}function dl({url:n,alt:r,title:o,className:l}){return n?h.jsx("img",{alt:r,className:l,loading:"lazy",src:n}):h.jsxs("div",{className:Fe("bg-zinc-800 flex flex-col items-center justify-center aspect-[2/3] p-4 gap-3",l),children:[h.jsx(Nu,{className:"size-12 text-zinc-600"}),h.jsx("span",{className:"text-zinc-400 text-sm text-center line-clamp-3",children:o})]})}function eM({onOpenChange:n,open:r}){const[o,l]=v.useState(""),s=Xj(o,200),c=Vo(),d=s.trim(),{data:m,error:y,isFetching:g}=Wj(s);v.useEffect(function(){r||l("")},[r]);function b(){n(!1)}function p(N){b(),c(N)}const w=d.length>0,C=(m?.movies.length??0)+(m?.shows.length??0)+(m?.episodes.length??0),R=w&&!g&&!y&&(m?.indexEmpty??!1),S=w&&!g&&!y&&C===0&&!R;return h.jsx(wu,{onOpenChange:n,open:r,children:h.jsxs(Su,{children:[h.jsx(Eu,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),h.jsxs(Cu,{"aria-describedby":void 0,className:"fixed left-1/2 top-[12vh] z-50 w-[92vw] max-w-2xl -translate-x-1/2 overflow-hidden rounded-lg border bg-background shadow-2xl",children:[h.jsx(vh,{className:"sr-only",children:"Search your library"}),h.jsxs(pa,{label:"Search your library",shouldFilter:!1,children:[h.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[h.jsx(_0,{"aria-hidden":!0,className:"size-4 text-muted-foreground"}),h.jsx(pa.Input,{autoFocus:!0,className:"flex h-12 w-full bg-transparent text-base outline-none placeholder:text-muted-foreground",onValueChange:l,placeholder:"Search movies, shows, episodes…",value:o}),g?h.jsx(Tu,{"aria-label":"Searching",className:"size-4 animate-spin text-muted-foreground"}):null]}),h.jsxs(pa.List,{className:"max-h-[60vh] overflow-y-auto p-2",children:[w?null:h.jsx(qs,{children:"Start typing to search your library."}),y?h.jsx(qs,{tone:"error",children:y.message}):null,R?h.jsx(qs,{children:"Search index isn’t ready yet. Try again after the next scan completes."}):null,S?h.jsxs(qs,{children:["No matches for “",d,"”. Try a shorter term or check your library."]}):null,m&&m.movies.length>0?h.jsx(pa.Group,{className:"px-1 py-1 text-xs uppercase tracking-wide text-muted-foreground",heading:"Movies",children:m.movies.map(N=>h.jsx(tM,{movie:N,onSelect:()=>p(`/watch/${N.id}`)},N.id))}):null,m&&m.shows.length>0?h.jsx(pa.Group,{className:"px-1 py-1 text-xs uppercase tracking-wide text-muted-foreground",heading:"Shows",children:m.shows.map(N=>h.jsx(nM,{onSelect:()=>p(`/shows/${N.id}`),show:N},N.id))}):null,m&&m.episodes.length>0?h.jsx(pa.Group,{className:"px-1 py-1 text-xs uppercase tracking-wide text-muted-foreground",heading:"Episodes",children:m.episodes.map(N=>h.jsx(aM,{episode:N,onSelect:()=>p(`/watch/episode/${N.id}`)},N.id))}):null]})]})]})]})})}function qs({children:n,tone:r="default"}){return h.jsx("p",{className:Fe("px-3 py-6 text-center text-sm",r==="error"?"text-destructive":"text-muted-foreground"),children:n})}function tM({movie:n,onSelect:r}){return h.jsxs(pa.Item,{className:"flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-foreground data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground",onSelect:r,value:`movie-${n.id}-${n.title}`,children:[h.jsx(Sh,{url:n.posterUrl,title:n.title}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsx("span",{className:"truncate font-medium",children:n.title}),n.year!==null?h.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.year}):null]}),n.overview?h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.overview}):null]})]})}function nM({onSelect:n,show:r}){return h.jsxs(pa.Item,{className:"flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-foreground data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground",onSelect:n,value:`show-${r.id}-${r.title}`,children:[h.jsx(Sh,{url:r.posterUrl,title:r.title}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsx("span",{className:"truncate font-medium",children:r.title}),r.year!==null?h.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:r.year}):null]}),r.overview?h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:r.overview}):null]})]})}function aM({episode:n,onSelect:r}){const o=`S${String(n.seasonNumber).padStart(2,"0")}E${String(n.episodeNumber).padStart(2,"0")}`;return h.jsxs(pa.Item,{className:"flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-foreground data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground",onSelect:r,value:`episode-${n.id}-${n.title}`,children:[h.jsx(Sh,{url:n.stillUrl,title:n.title}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsx("span",{className:"truncate font-medium",children:n.title}),h.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[n.showTitle," · ",o]})]}),n.overview?h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.overview}):null]})]})}function Sh({url:n,title:r}){return h.jsx("div",{className:"h-12 w-9 shrink-0 overflow-hidden rounded",children:h.jsx(dl,{alt:"",className:"h-12 w-9 object-cover",url:n,title:r})})}const Q0=v.createContext(null);function rM({children:n}){const[r,o]=v.useState(!1),l=v.useCallback(()=>o(!0),[]),s=v.useCallback(()=>o(!1),[]),c=v.useCallback(()=>o(m=>!m),[]);v.useEffect(function(){function y(g){g.isComposing||g.keyCode===229||g.key==="/"&&(iM(g.target)||g.metaKey||g.ctrlKey||g.altKey||(g.preventDefault(),o(!0)))}return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}},[]);const d=v.useMemo(()=>({close:s,isOpen:r,open:l,toggle:c}),[s,r,l,c]);return h.jsxs(Q0.Provider,{value:d,children:[n,h.jsx(eM,{onOpenChange:o,open:r})]})}function oM(){const n=v.useContext(Q0);if(n===null)throw new Error("useSearchPalette must be used inside a <SearchPaletteProvider>.");return n}function iM(n){if(!(n instanceof HTMLElement))return!1;if(n.isContentEditable)return!0;const r=n.tagName;return r==="INPUT"||r==="TEXTAREA"||r==="SELECT"}async function ju(n){try{return(await n.json()).error?.message??n.statusText}catch{return n.statusText}}async function lM(){try{const n=await fetch("/api/auth/status");if(!n.ok)throw new Error(await ju(n));return await n.json()}catch{throw new Error("Couldn't reach server. Check your connection.")}}function Eh(){return St({queryKey:["auth-status"],queryFn:lM,staleTime:3e4})}function sM(){const n=Dt();return wn({mutationFn:async r=>{let o;try{o=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})})}catch{throw new Error("Couldn't reach server. Check your connection.")}if(!o.ok)throw new Error(await ju(o))},onSuccess:()=>{n.invalidateQueries({queryKey:["auth-status"]})}})}function uM(){const n=Dt();return wn({mutationFn:async()=>{let r;try{r=await fetch("/api/auth/logout",{method:"POST"})}catch{throw new Error("Couldn't reach server. Check your connection.")}if(!r.ok)throw new Error(await ju(r))},onSuccess:()=>{n.invalidateQueries({queryKey:["auth-status"]})}})}function cM(){const n=Dt();return wn({mutationFn:async r=>{let o;try{o=await fetch("/api/auth/password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch{throw new Error("Couldn't reach server. Check your connection.")}if(!o.ok)throw new Error(await ju(o));return await o.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["auth-status"]})}})}async function fM(){const n=await fetch("/api/setup");if(!n.ok)throw new Error("Failed to check setup status");return await n.json()}function dM(){return St({queryKey:["setupStatus"],queryFn:fM})}const Gy=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,Yy=k0,hM=(n,r)=>o=>{var l;if(r?.variants==null)return Yy(n,o?.class,o?.className);const{variants:s,defaultVariants:c}=r,d=Object.keys(s).map(g=>{const b=o?.[g],p=c?.[g];if(b===null)return null;const w=Gy(b)||Gy(p);return s[g][w]}),m=o&&Object.entries(o).reduce((g,b)=>{let[p,w]=b;return w===void 0||(g[p]=w),g},{}),y=r==null||(l=r.compoundVariants)===null||l===void 0?void 0:l.reduce((g,b)=>{let{class:p,className:w,...C}=b;return Object.entries(C).every(R=>{let[S,N]=R;return Array.isArray(N)?N.includes({...c,...m}[S]):{...c,...m}[S]===N})?[...g,p,w]:g},[]);return Yy(n,d,y,o?.class,o?.className)},mM=hM("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function Ie({className:n,variant:r,size:o,asChild:l=!1,...s}){const c=l?QN:"button";return h.jsx(c,{"data-slot":"button",className:Fe(mM({variant:r,size:o,className:n})),...s})}function pM({items:n}){return n.length===0?null:h.jsxs("section",{className:"px-4 py-4 sm:px-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-3",children:"Continue Watching"}),h.jsx("div",{className:"flex gap-2 overflow-x-auto scroll-smooth pb-2 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:n.map(r=>{const o=r.type==="movie",l=o?`movie-${r.movie.id}`:`episode-${r.episode.id}`,s=o?`/watch/${r.movie.id}`:`/watch/episode/${r.episode.id}`,c=o?r.movie.title:r.show.title,d=o?null:`S${r.episode.seasonNumber} E${r.episode.episodeNumber}`,m=o?r.movie.posterUrl:r.show.posterUrl,y=r.duration?Math.min(r.currentTime/r.duration*100,100):0;return h.jsxs(xn,{className:"flex-shrink-0 w-32 md:w-40 group",to:s,children:[h.jsxs("div",{className:"relative w-full overflow-hidden rounded-sm",children:[h.jsx(dl,{alt:c,className:"w-full transition-transform duration-200 group-hover:scale-105",url:m,title:c}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1 bg-muted/50",children:h.jsx("div",{className:"h-full bg-red-600 transition-all",style:{width:`${y}%`}})})]}),h.jsx("p",{className:"text-xs text-muted-foreground truncate mt-1.5 px-0.5",children:c}),d&&h.jsx("p",{className:"text-xs text-muted-foreground/70 truncate px-0.5",children:d})]},l)})})]})}async function Ch(n){try{return(await n.json()).error?.message??n.statusText}catch{return n.statusText}}async function gM(){const n=await fetch("/api/favorites");if(!n.ok)throw new Error(await Ch(n));return await n.json()}function vM(){return St({queryKey:["favorites"],queryFn:gM})}function yM(n){return n.kind==="movie"?`/api/favorites/status?movieId=${n.movieId}`:`/api/favorites/status?showId=${n.showId}`}function K0(n){return n.kind==="movie"?["favorite-status","movie",n.movieId]:["favorite-status","show",n.showId]}function bM(n){return St({queryKey:K0(n),queryFn:async()=>{const r=await fetch(yM(n));if(!r.ok)throw new Error(await Ch(r));return(await r.json()).favorite}})}function xM(){const n=Dt();return wn({mutationFn:async r=>{const o=r.target.kind==="movie"?{movieId:r.target.movieId}:{showId:r.target.showId},l=await fetch("/api/favorites",{method:r.favorite?"POST":"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok)throw new Error(await Ch(l))},onSuccess:(r,o)=>{n.invalidateQueries({queryKey:K0(o.target)}),n.invalidateQueries({queryKey:["favorites"]})}})}function wM({className:n,target:r}){const{data:o}=bM(r),l=xM();function s(d){d.preventDefault(),d.stopPropagation(),l.mutate({target:r,favorite:!o},{onError:m=>{Ze.error(m instanceof Error?m.message:"Failed to update favorite")}})}const c=!!o;return h.jsx("button",{"aria-label":c?"Remove from favorites":"Add to favorites","aria-pressed":c,className:Fe("flex size-8 items-center justify-center rounded-full bg-black/50 text-white opacity-0 transition-opacity hover:bg-black/70 group-hover:opacity-100 focus:opacity-100",c&&"opacity-100",n),onClick:s,type:"button",children:h.jsx($T,{className:Fe("size-4 transition-colors",c?"fill-red-500 stroke-red-500":"stroke-white")})})}function el({items:n,title:r}){return n.length===0?null:h.jsxs("section",{className:"px-4 py-4 sm:px-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-3",children:r}),h.jsx("div",{className:"flex gap-2 overflow-x-auto scroll-smooth pb-2 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:n.map(o=>{const l=o.type==="movie"?`movie-${o.item.id}`:`show-${o.item.id}`,s=o.type==="movie"?`/watch/${o.item.id}`:`/shows/${o.item.id}`;return h.jsxs(xn,{className:"flex-shrink-0 w-32 md:w-40 group",to:s,children:[h.jsxs("div",{className:"relative w-full overflow-hidden rounded-sm",children:[h.jsx(dl,{alt:o.item.title,className:"w-full transition-transform duration-200 group-hover:scale-105",url:o.item.posterUrl,title:o.item.title}),h.jsx(wM,{className:"absolute right-2 top-2",target:o.type==="movie"?{kind:"movie",movieId:o.item.id}:{kind:"show",showId:o.item.id}})]}),h.jsx("p",{className:"text-xs text-muted-foreground truncate mt-1.5 px-0.5",children:o.item.title})]},l)})})]})}function SM(){const{data:n}=vM(),r=v.useMemo(()=>n?n.map(o=>o.type==="movie"?{type:"movie",item:o.movie}:{type:"show",item:o.show}):[],[n]);return r.length===0?null:h.jsx(el,{items:r,title:"Favorites"})}function Iy(n){const r=EM(n),o=v.forwardRef((l,s)=>{const{children:c,...d}=l,m=v.Children.toArray(c),y=m.find(RM);if(y){const g=y.props.children,b=m.map(p=>p===y?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:p);return h.jsx(r,{...d,ref:s,children:v.isValidElement(g)?v.cloneElement(g,void 0,b):null})}return h.jsx(r,{...d,ref:s,children:c})});return o.displayName=`${n}.Slot`,o}function EM(n){const r=v.forwardRef((o,l)=>{const{children:s,...c}=o;if(v.isValidElement(s)){const d=TM(s),m=NM(c,s.props);return s.type!==v.Fragment&&(m.ref=l?It(l,d):d),v.cloneElement(s,m)}return v.Children.count(s)>1?v.Children.only(null):null});return r.displayName=`${n}.SlotClone`,r}var CM=Symbol("radix.slottable");function RM(n){return v.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===CM}function NM(n,r){const o={...r};for(const l in r){const s=n[l],c=r[l];/^on[A-Z]/.test(l)?s&&c?o[l]=(...m)=>{const y=c(...m);return s(...m),y}:s&&(o[l]=s):l==="style"?o[l]={...s,...c}:l==="className"&&(o[l]=[s,c].filter(Boolean).join(" "))}return{...n,...o}}function TM(n){let r=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?n.ref:(r=Object.getOwnPropertyDescriptor(n,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?n.props.ref:n.props.ref||n.ref)}function Rh(n){const r=n+"CollectionProvider",[o,l]=nr(r),[s,c]=o(r,{collectionRef:{current:null},itemMap:new Map}),d=S=>{const{scope:N,children:j}=S,O=se.useRef(null),k=se.useRef(new Map).current;return h.jsx(s,{scope:N,itemMap:k,collectionRef:O,children:j})};d.displayName=r;const m=n+"CollectionSlot",y=Iy(m),g=se.forwardRef((S,N)=>{const{scope:j,children:O}=S,k=c(m,j),Q=$e(N,k.collectionRef);return h.jsx(y,{ref:Q,children:O})});g.displayName=m;const b=n+"CollectionItemSlot",p="data-radix-collection-item",w=Iy(b),C=se.forwardRef((S,N)=>{const{scope:j,children:O,...k}=S,Q=se.useRef(null),I=$e(N,Q),Z=c(b,j);return se.useEffect(()=>(Z.itemMap.set(Q,{ref:Q,...k}),()=>{Z.itemMap.delete(Q)})),h.jsx(w,{[p]:"",ref:I,children:O})});C.displayName=b;function R(S){const N=c(n+"CollectionConsumer",S);return se.useCallback(()=>{const O=N.collectionRef.current;if(!O)return[];const k=Array.from(O.querySelectorAll(`[${p}]`));return Array.from(N.itemMap.values()).sort((Z,B)=>k.indexOf(Z.ref.current)-k.indexOf(B.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:d,Slot:g,ItemSlot:C},R,l]}var jM=v.createContext(void 0);function Nh(n){const r=v.useContext(jM);return n||r||"ltr"}const MM=["top","right","bottom","left"],Wa=Math.min,nn=Math.max,ru=Math.round,$s=Math.floor,Vn=n=>({x:n,y:n}),AM={left:"right",right:"left",bottom:"top",top:"bottom"},OM={start:"end",end:"start"};function Vd(n,r,o){return nn(n,Wa(r,o))}function ba(n,r){return typeof n=="function"?n(r):n}function xa(n){return n.split("-")[0]}function Yo(n){return n.split("-")[1]}function Th(n){return n==="x"?"y":"x"}function jh(n){return n==="y"?"height":"width"}const _M=new Set(["top","bottom"]);function $n(n){return _M.has(xa(n))?"y":"x"}function Mh(n){return Th($n(n))}function DM(n,r,o){o===void 0&&(o=!1);const l=Yo(n),s=Mh(n),c=jh(s);let d=s==="x"?l===(o?"end":"start")?"right":"left":l==="start"?"bottom":"top";return r.reference[c]>r.floating[c]&&(d=ou(d)),[d,ou(d)]}function zM(n){const r=ou(n);return[Fd(n),r,Fd(r)]}function Fd(n){return n.replace(/start|end/g,r=>OM[r])}const Qy=["left","right"],Ky=["right","left"],kM=["top","bottom"],LM=["bottom","top"];function UM(n,r,o){switch(n){case"top":case"bottom":return o?r?Ky:Qy:r?Qy:Ky;case"left":case"right":return r?kM:LM;default:return[]}}function HM(n,r,o,l){const s=Yo(n);let c=UM(xa(n),o==="start",l);return s&&(c=c.map(d=>d+"-"+s),r&&(c=c.concat(c.map(Fd)))),c}function ou(n){return n.replace(/left|right|bottom|top/g,r=>AM[r])}function BM(n){return{top:0,right:0,bottom:0,left:0,...n}}function X0(n){return typeof n!="number"?BM(n):{top:n,right:n,bottom:n,left:n}}function iu(n){const{x:r,y:o,width:l,height:s}=n;return{width:l,height:s,top:o,left:r,right:r+l,bottom:o+s,x:r,y:o}}function Xy(n,r,o){let{reference:l,floating:s}=n;const c=$n(r),d=Mh(r),m=jh(d),y=xa(r),g=c==="y",b=l.x+l.width/2-s.width/2,p=l.y+l.height/2-s.height/2,w=l[m]/2-s[m]/2;let C;switch(y){case"top":C={x:b,y:l.y-s.height};break;case"bottom":C={x:b,y:l.y+l.height};break;case"right":C={x:l.x+l.width,y:p};break;case"left":C={x:l.x-s.width,y:p};break;default:C={x:l.x,y:l.y}}switch(Yo(r)){case"start":C[d]-=w*(o&&g?-1:1);break;case"end":C[d]+=w*(o&&g?-1:1);break}return C}const PM=async(n,r,o)=>{const{placement:l="bottom",strategy:s="absolute",middleware:c=[],platform:d}=o,m=c.filter(Boolean),y=await(d.isRTL==null?void 0:d.isRTL(r));let g=await d.getElementRects({reference:n,floating:r,strategy:s}),{x:b,y:p}=Xy(g,l,y),w=l,C={},R=0;for(let S=0;S<m.length;S++){const{name:N,fn:j}=m[S],{x:O,y:k,data:Q,reset:I}=await j({x:b,y:p,initialPlacement:l,placement:w,strategy:s,middlewareData:C,rects:g,platform:d,elements:{reference:n,floating:r}});b=O??b,p=k??p,C={...C,[N]:{...C[N],...Q}},I&&R<=50&&(R++,typeof I=="object"&&(I.placement&&(w=I.placement),I.rects&&(g=I.rects===!0?await d.getElementRects({reference:n,floating:r,strategy:s}):I.rects),{x:b,y:p}=Xy(g,w,y)),S=-1)}return{x:b,y:p,placement:w,strategy:s,middlewareData:C}};async function tl(n,r){var o;r===void 0&&(r={});const{x:l,y:s,platform:c,rects:d,elements:m,strategy:y}=n,{boundary:g="clippingAncestors",rootBoundary:b="viewport",elementContext:p="floating",altBoundary:w=!1,padding:C=0}=ba(r,n),R=X0(C),N=m[w?p==="floating"?"reference":"floating":p],j=iu(await c.getClippingRect({element:(o=await(c.isElement==null?void 0:c.isElement(N)))==null||o?N:N.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(m.floating)),boundary:g,rootBoundary:b,strategy:y})),O=p==="floating"?{x:l,y:s,width:d.floating.width,height:d.floating.height}:d.reference,k=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m.floating)),Q=await(c.isElement==null?void 0:c.isElement(k))?await(c.getScale==null?void 0:c.getScale(k))||{x:1,y:1}:{x:1,y:1},I=iu(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:O,offsetParent:k,strategy:y}):O);return{top:(j.top-I.top+R.top)/Q.y,bottom:(I.bottom-j.bottom+R.bottom)/Q.y,left:(j.left-I.left+R.left)/Q.x,right:(I.right-j.right+R.right)/Q.x}}const qM=n=>({name:"arrow",options:n,async fn(r){const{x:o,y:l,placement:s,rects:c,platform:d,elements:m,middlewareData:y}=r,{element:g,padding:b=0}=ba(n,r)||{};if(g==null)return{};const p=X0(b),w={x:o,y:l},C=Mh(s),R=jh(C),S=await d.getDimensions(g),N=C==="y",j=N?"top":"left",O=N?"bottom":"right",k=N?"clientHeight":"clientWidth",Q=c.reference[R]+c.reference[C]-w[C]-c.floating[R],I=w[C]-c.reference[C],Z=await(d.getOffsetParent==null?void 0:d.getOffsetParent(g));let B=Z?Z[k]:0;(!B||!await(d.isElement==null?void 0:d.isElement(Z)))&&(B=m.floating[k]||c.floating[R]);const G=Q/2-I/2,ue=B/2-S[R]/2-1,ie=Wa(p[j],ue),oe=Wa(p[O],ue),fe=ie,ge=B-S[R]-oe,ae=B/2-S[R]/2+G,W=Vd(fe,ae,ge),T=!y.arrow&&Yo(s)!=null&&ae!==W&&c.reference[R]/2-(ae<fe?ie:oe)-S[R]/2<0,U=T?ae<fe?ae-fe:ae-ge:0;return{[C]:w[C]+U,data:{[C]:W,centerOffset:ae-W-U,...T&&{alignmentOffset:U}},reset:T}}}),$M=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(r){var o,l;const{placement:s,middlewareData:c,rects:d,initialPlacement:m,platform:y,elements:g}=r,{mainAxis:b=!0,crossAxis:p=!0,fallbackPlacements:w,fallbackStrategy:C="bestFit",fallbackAxisSideDirection:R="none",flipAlignment:S=!0,...N}=ba(n,r);if((o=c.arrow)!=null&&o.alignmentOffset)return{};const j=xa(s),O=$n(m),k=xa(m)===m,Q=await(y.isRTL==null?void 0:y.isRTL(g.floating)),I=w||(k||!S?[ou(m)]:zM(m)),Z=R!=="none";!w&&Z&&I.push(...HM(m,S,R,Q));const B=[m,...I],G=await tl(r,N),ue=[];let ie=((l=c.flip)==null?void 0:l.overflows)||[];if(b&&ue.push(G[j]),p){const ae=DM(s,d,Q);ue.push(G[ae[0]],G[ae[1]])}if(ie=[...ie,{placement:s,overflows:ue}],!ue.every(ae=>ae<=0)){var oe,fe;const ae=(((oe=c.flip)==null?void 0:oe.index)||0)+1,W=B[ae];if(W&&(!(p==="alignment"?O!==$n(W):!1)||ie.every(_=>$n(_.placement)===O?_.overflows[0]>0:!0)))return{data:{index:ae,overflows:ie},reset:{placement:W}};let T=(fe=ie.filter(U=>U.overflows[0]<=0).sort((U,_)=>U.overflows[1]-_.overflows[1])[0])==null?void 0:fe.placement;if(!T)switch(C){case"bestFit":{var ge;const U=(ge=ie.filter(_=>{if(Z){const F=$n(_.placement);return F===O||F==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(F=>F>0).reduce((F,ne)=>F+ne,0)]).sort((_,F)=>_[1]-F[1])[0])==null?void 0:ge[0];U&&(T=U);break}case"initialPlacement":T=m;break}if(s!==T)return{reset:{placement:T}}}return{}}}};function Zy(n,r){return{top:n.top-r.height,right:n.right-r.width,bottom:n.bottom-r.height,left:n.left-r.width}}function Jy(n){return MM.some(r=>n[r]>=0)}const VM=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(r){const{rects:o}=r,{strategy:l="referenceHidden",...s}=ba(n,r);switch(l){case"referenceHidden":{const c=await tl(r,{...s,elementContext:"reference"}),d=Zy(c,o.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:Jy(d)}}}case"escaped":{const c=await tl(r,{...s,altBoundary:!0}),d=Zy(c,o.floating);return{data:{escapedOffsets:d,escaped:Jy(d)}}}default:return{}}}}},Z0=new Set(["left","top"]);async function FM(n,r){const{placement:o,platform:l,elements:s}=n,c=await(l.isRTL==null?void 0:l.isRTL(s.floating)),d=xa(o),m=Yo(o),y=$n(o)==="y",g=Z0.has(d)?-1:1,b=c&&y?-1:1,p=ba(r,n);let{mainAxis:w,crossAxis:C,alignmentAxis:R}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return m&&typeof R=="number"&&(C=m==="end"?R*-1:R),y?{x:C*b,y:w*g}:{x:w*g,y:C*b}}const GM=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(r){var o,l;const{x:s,y:c,placement:d,middlewareData:m}=r,y=await FM(r,n);return d===((o=m.offset)==null?void 0:o.placement)&&(l=m.arrow)!=null&&l.alignmentOffset?{}:{x:s+y.x,y:c+y.y,data:{...y,placement:d}}}}},YM=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(r){const{x:o,y:l,placement:s}=r,{mainAxis:c=!0,crossAxis:d=!1,limiter:m={fn:N=>{let{x:j,y:O}=N;return{x:j,y:O}}},...y}=ba(n,r),g={x:o,y:l},b=await tl(r,y),p=$n(xa(s)),w=Th(p);let C=g[w],R=g[p];if(c){const N=w==="y"?"top":"left",j=w==="y"?"bottom":"right",O=C+b[N],k=C-b[j];C=Vd(O,C,k)}if(d){const N=p==="y"?"top":"left",j=p==="y"?"bottom":"right",O=R+b[N],k=R-b[j];R=Vd(O,R,k)}const S=m.fn({...r,[w]:C,[p]:R});return{...S,data:{x:S.x-o,y:S.y-l,enabled:{[w]:c,[p]:d}}}}}},IM=function(n){return n===void 0&&(n={}),{options:n,fn(r){const{x:o,y:l,placement:s,rects:c,middlewareData:d}=r,{offset:m=0,mainAxis:y=!0,crossAxis:g=!0}=ba(n,r),b={x:o,y:l},p=$n(s),w=Th(p);let C=b[w],R=b[p];const S=ba(m,r),N=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(y){const k=w==="y"?"height":"width",Q=c.reference[w]-c.floating[k]+N.mainAxis,I=c.reference[w]+c.reference[k]-N.mainAxis;C<Q?C=Q:C>I&&(C=I)}if(g){var j,O;const k=w==="y"?"width":"height",Q=Z0.has(xa(s)),I=c.reference[p]-c.floating[k]+(Q&&((j=d.offset)==null?void 0:j[p])||0)+(Q?0:N.crossAxis),Z=c.reference[p]+c.reference[k]+(Q?0:((O=d.offset)==null?void 0:O[p])||0)-(Q?N.crossAxis:0);R<I?R=I:R>Z&&(R=Z)}return{[w]:C,[p]:R}}}},QM=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(r){var o,l;const{placement:s,rects:c,platform:d,elements:m}=r,{apply:y=()=>{},...g}=ba(n,r),b=await tl(r,g),p=xa(s),w=Yo(s),C=$n(s)==="y",{width:R,height:S}=c.floating;let N,j;p==="top"||p==="bottom"?(N=p,j=w===(await(d.isRTL==null?void 0:d.isRTL(m.floating))?"start":"end")?"left":"right"):(j=p,N=w==="end"?"top":"bottom");const O=S-b.top-b.bottom,k=R-b.left-b.right,Q=Wa(S-b[N],O),I=Wa(R-b[j],k),Z=!r.middlewareData.shift;let B=Q,G=I;if((o=r.middlewareData.shift)!=null&&o.enabled.x&&(G=k),(l=r.middlewareData.shift)!=null&&l.enabled.y&&(B=O),Z&&!w){const ie=nn(b.left,0),oe=nn(b.right,0),fe=nn(b.top,0),ge=nn(b.bottom,0);C?G=R-2*(ie!==0||oe!==0?ie+oe:nn(b.left,b.right)):B=S-2*(fe!==0||ge!==0?fe+ge:nn(b.top,b.bottom))}await y({...r,availableWidth:G,availableHeight:B});const ue=await d.getDimensions(m.floating);return R!==ue.width||S!==ue.height?{reset:{rects:!0}}:{}}}};function Mu(){return typeof window<"u"}function Io(n){return J0(n)?(n.nodeName||"").toLowerCase():"#document"}function an(n){var r;return(n==null||(r=n.ownerDocument)==null?void 0:r.defaultView)||window}function In(n){var r;return(r=(J0(n)?n.ownerDocument:n.document)||window.document)==null?void 0:r.documentElement}function J0(n){return Mu()?n instanceof Node||n instanceof an(n).Node:!1}function An(n){return Mu()?n instanceof Element||n instanceof an(n).Element:!1}function Gn(n){return Mu()?n instanceof HTMLElement||n instanceof an(n).HTMLElement:!1}function Wy(n){return!Mu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof an(n).ShadowRoot}const KM=new Set(["inline","contents"]);function hl(n){const{overflow:r,overflowX:o,overflowY:l,display:s}=On(n);return/auto|scroll|overlay|hidden|clip/.test(r+l+o)&&!KM.has(s)}const XM=new Set(["table","td","th"]);function ZM(n){return XM.has(Io(n))}const JM=[":popover-open",":modal"];function Au(n){return JM.some(r=>{try{return n.matches(r)}catch{return!1}})}const WM=["transform","translate","scale","rotate","perspective"],eA=["transform","translate","scale","rotate","perspective","filter"],tA=["paint","layout","strict","content"];function Ah(n){const r=Oh(),o=An(n)?On(n):n;return WM.some(l=>o[l]?o[l]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!r&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!r&&(o.filter?o.filter!=="none":!1)||eA.some(l=>(o.willChange||"").includes(l))||tA.some(l=>(o.contain||"").includes(l))}function nA(n){let r=er(n);for(;Gn(r)&&!Uo(r);){if(Ah(r))return r;if(Au(r))return null;r=er(r)}return null}function Oh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const aA=new Set(["html","body","#document"]);function Uo(n){return aA.has(Io(n))}function On(n){return an(n).getComputedStyle(n)}function Ou(n){return An(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function er(n){if(Io(n)==="html")return n;const r=n.assignedSlot||n.parentNode||Wy(n)&&n.host||In(n);return Wy(r)?r.host:r}function W0(n){const r=er(n);return Uo(r)?n.ownerDocument?n.ownerDocument.body:n.body:Gn(r)&&hl(r)?r:W0(r)}function nl(n,r,o){var l;r===void 0&&(r=[]),o===void 0&&(o=!0);const s=W0(n),c=s===((l=n.ownerDocument)==null?void 0:l.body),d=an(s);if(c){const m=Gd(d);return r.concat(d,d.visualViewport||[],hl(s)?s:[],m&&o?nl(m):[])}return r.concat(s,nl(s,[],o))}function Gd(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function ex(n){const r=On(n);let o=parseFloat(r.width)||0,l=parseFloat(r.height)||0;const s=Gn(n),c=s?n.offsetWidth:o,d=s?n.offsetHeight:l,m=ru(o)!==c||ru(l)!==d;return m&&(o=c,l=d),{width:o,height:l,$:m}}function _h(n){return An(n)?n:n.contextElement}function ko(n){const r=_h(n);if(!Gn(r))return Vn(1);const o=r.getBoundingClientRect(),{width:l,height:s,$:c}=ex(r);let d=(c?ru(o.width):o.width)/l,m=(c?ru(o.height):o.height)/s;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const rA=Vn(0);function tx(n){const r=an(n);return!Oh()||!r.visualViewport?rA:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function oA(n,r,o){return r===void 0&&(r=!1),!o||r&&o!==an(n)?!1:r}function zr(n,r,o,l){r===void 0&&(r=!1),o===void 0&&(o=!1);const s=n.getBoundingClientRect(),c=_h(n);let d=Vn(1);r&&(l?An(l)&&(d=ko(l)):d=ko(n));const m=oA(c,o,l)?tx(c):Vn(0);let y=(s.left+m.x)/d.x,g=(s.top+m.y)/d.y,b=s.width/d.x,p=s.height/d.y;if(c){const w=an(c),C=l&&An(l)?an(l):l;let R=w,S=Gd(R);for(;S&&l&&C!==R;){const N=ko(S),j=S.getBoundingClientRect(),O=On(S),k=j.left+(S.clientLeft+parseFloat(O.paddingLeft))*N.x,Q=j.top+(S.clientTop+parseFloat(O.paddingTop))*N.y;y*=N.x,g*=N.y,b*=N.x,p*=N.y,y+=k,g+=Q,R=an(S),S=Gd(R)}}return iu({width:b,height:p,x:y,y:g})}function _u(n,r){const o=Ou(n).scrollLeft;return r?r.left+o:zr(In(n)).left+o}function nx(n,r){const o=n.getBoundingClientRect(),l=o.left+r.scrollLeft-_u(n,o),s=o.top+r.scrollTop;return{x:l,y:s}}function iA(n){let{elements:r,rect:o,offsetParent:l,strategy:s}=n;const c=s==="fixed",d=In(l),m=r?Au(r.floating):!1;if(l===d||m&&c)return o;let y={scrollLeft:0,scrollTop:0},g=Vn(1);const b=Vn(0),p=Gn(l);if((p||!p&&!c)&&((Io(l)!=="body"||hl(d))&&(y=Ou(l)),Gn(l))){const C=zr(l);g=ko(l),b.x=C.x+l.clientLeft,b.y=C.y+l.clientTop}const w=d&&!p&&!c?nx(d,y):Vn(0);return{width:o.width*g.x,height:o.height*g.y,x:o.x*g.x-y.scrollLeft*g.x+b.x+w.x,y:o.y*g.y-y.scrollTop*g.y+b.y+w.y}}function lA(n){return Array.from(n.getClientRects())}function sA(n){const r=In(n),o=Ou(n),l=n.ownerDocument.body,s=nn(r.scrollWidth,r.clientWidth,l.scrollWidth,l.clientWidth),c=nn(r.scrollHeight,r.clientHeight,l.scrollHeight,l.clientHeight);let d=-o.scrollLeft+_u(n);const m=-o.scrollTop;return On(l).direction==="rtl"&&(d+=nn(r.clientWidth,l.clientWidth)-s),{width:s,height:c,x:d,y:m}}const eb=25;function uA(n,r){const o=an(n),l=In(n),s=o.visualViewport;let c=l.clientWidth,d=l.clientHeight,m=0,y=0;if(s){c=s.width,d=s.height;const b=Oh();(!b||b&&r==="fixed")&&(m=s.offsetLeft,y=s.offsetTop)}const g=_u(l);if(g<=0){const b=l.ownerDocument,p=b.body,w=getComputedStyle(p),C=b.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,R=Math.abs(l.clientWidth-p.clientWidth-C);R<=eb&&(c-=R)}else g<=eb&&(c+=g);return{width:c,height:d,x:m,y}}const cA=new Set(["absolute","fixed"]);function fA(n,r){const o=zr(n,!0,r==="fixed"),l=o.top+n.clientTop,s=o.left+n.clientLeft,c=Gn(n)?ko(n):Vn(1),d=n.clientWidth*c.x,m=n.clientHeight*c.y,y=s*c.x,g=l*c.y;return{width:d,height:m,x:y,y:g}}function tb(n,r,o){let l;if(r==="viewport")l=uA(n,o);else if(r==="document")l=sA(In(n));else if(An(r))l=fA(r,o);else{const s=tx(n);l={x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}return iu(l)}function ax(n,r){const o=er(n);return o===r||!An(o)||Uo(o)?!1:On(o).position==="fixed"||ax(o,r)}function dA(n,r){const o=r.get(n);if(o)return o;let l=nl(n,[],!1).filter(m=>An(m)&&Io(m)!=="body"),s=null;const c=On(n).position==="fixed";let d=c?er(n):n;for(;An(d)&&!Uo(d);){const m=On(d),y=Ah(d);!y&&m.position==="fixed"&&(s=null),(c?!y&&!s:!y&&m.position==="static"&&!!s&&cA.has(s.position)||hl(d)&&!y&&ax(n,d))?l=l.filter(b=>b!==d):s=m,d=er(d)}return r.set(n,l),l}function hA(n){let{element:r,boundary:o,rootBoundary:l,strategy:s}=n;const d=[...o==="clippingAncestors"?Au(r)?[]:dA(r,this._c):[].concat(o),l],m=d[0],y=d.reduce((g,b)=>{const p=tb(r,b,s);return g.top=nn(p.top,g.top),g.right=Wa(p.right,g.right),g.bottom=Wa(p.bottom,g.bottom),g.left=nn(p.left,g.left),g},tb(r,m,s));return{width:y.right-y.left,height:y.bottom-y.top,x:y.left,y:y.top}}function mA(n){const{width:r,height:o}=ex(n);return{width:r,height:o}}function pA(n,r,o){const l=Gn(r),s=In(r),c=o==="fixed",d=zr(n,!0,c,r);let m={scrollLeft:0,scrollTop:0};const y=Vn(0);function g(){y.x=_u(s)}if(l||!l&&!c)if((Io(r)!=="body"||hl(s))&&(m=Ou(r)),l){const C=zr(r,!0,c,r);y.x=C.x+r.clientLeft,y.y=C.y+r.clientTop}else s&&g();c&&!l&&s&&g();const b=s&&!l&&!c?nx(s,m):Vn(0),p=d.left+m.scrollLeft-y.x-b.x,w=d.top+m.scrollTop-y.y-b.y;return{x:p,y:w,width:d.width,height:d.height}}function Sd(n){return On(n).position==="static"}function nb(n,r){if(!Gn(n)||On(n).position==="fixed")return null;if(r)return r(n);let o=n.offsetParent;return In(n)===o&&(o=o.ownerDocument.body),o}function rx(n,r){const o=an(n);if(Au(n))return o;if(!Gn(n)){let s=er(n);for(;s&&!Uo(s);){if(An(s)&&!Sd(s))return s;s=er(s)}return o}let l=nb(n,r);for(;l&&ZM(l)&&Sd(l);)l=nb(l,r);return l&&Uo(l)&&Sd(l)&&!Ah(l)?o:l||nA(n)||o}const gA=async function(n){const r=this.getOffsetParent||rx,o=this.getDimensions,l=await o(n.floating);return{reference:pA(n.reference,await r(n.floating),n.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function vA(n){return On(n).direction==="rtl"}const yA={convertOffsetParentRelativeRectToViewportRelativeRect:iA,getDocumentElement:In,getClippingRect:hA,getOffsetParent:rx,getElementRects:gA,getClientRects:lA,getDimensions:mA,getScale:ko,isElement:An,isRTL:vA};function ox(n,r){return n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}function bA(n,r){let o=null,l;const s=In(n);function c(){var m;clearTimeout(l),(m=o)==null||m.disconnect(),o=null}function d(m,y){m===void 0&&(m=!1),y===void 0&&(y=1),c();const g=n.getBoundingClientRect(),{left:b,top:p,width:w,height:C}=g;if(m||r(),!w||!C)return;const R=$s(p),S=$s(s.clientWidth-(b+w)),N=$s(s.clientHeight-(p+C)),j=$s(b),k={rootMargin:-R+"px "+-S+"px "+-N+"px "+-j+"px",threshold:nn(0,Wa(1,y))||1};let Q=!0;function I(Z){const B=Z[0].intersectionRatio;if(B!==y){if(!Q)return d();B?d(!1,B):l=setTimeout(()=>{d(!1,1e-7)},1e3)}B===1&&!ox(g,n.getBoundingClientRect())&&d(),Q=!1}try{o=new IntersectionObserver(I,{...k,root:s.ownerDocument})}catch{o=new IntersectionObserver(I,k)}o.observe(n)}return d(!0),c}function xA(n,r,o,l){l===void 0&&(l={});const{ancestorScroll:s=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:y=!1}=l,g=_h(n),b=s||c?[...g?nl(g):[],...nl(r)]:[];b.forEach(j=>{s&&j.addEventListener("scroll",o,{passive:!0}),c&&j.addEventListener("resize",o)});const p=g&&m?bA(g,o):null;let w=-1,C=null;d&&(C=new ResizeObserver(j=>{let[O]=j;O&&O.target===g&&C&&(C.unobserve(r),cancelAnimationFrame(w),w=requestAnimationFrame(()=>{var k;(k=C)==null||k.observe(r)})),o()}),g&&!y&&C.observe(g),C.observe(r));let R,S=y?zr(n):null;y&&N();function N(){const j=zr(n);S&&!ox(S,j)&&o(),S=j,R=requestAnimationFrame(N)}return o(),()=>{var j;b.forEach(O=>{s&&O.removeEventListener("scroll",o),c&&O.removeEventListener("resize",o)}),p?.(),(j=C)==null||j.disconnect(),C=null,y&&cancelAnimationFrame(R)}}const wA=GM,SA=YM,EA=$M,CA=QM,RA=VM,ab=qM,NA=IM,TA=(n,r,o)=>{const l=new Map,s={platform:yA,...o},c={...s.platform,_c:l};return PM(n,r,{...s,platform:c})};var jA=typeof document<"u",MA=function(){},Is=jA?v.useLayoutEffect:MA;function lu(n,r){if(n===r)return!0;if(typeof n!=typeof r)return!1;if(typeof n=="function"&&n.toString()===r.toString())return!0;let o,l,s;if(n&&r&&typeof n=="object"){if(Array.isArray(n)){if(o=n.length,o!==r.length)return!1;for(l=o;l--!==0;)if(!lu(n[l],r[l]))return!1;return!0}if(s=Object.keys(n),o=s.length,o!==Object.keys(r).length)return!1;for(l=o;l--!==0;)if(!{}.hasOwnProperty.call(r,s[l]))return!1;for(l=o;l--!==0;){const c=s[l];if(!(c==="_owner"&&n.$$typeof)&&!lu(n[c],r[c]))return!1}return!0}return n!==n&&r!==r}function ix(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function rb(n,r){const o=ix(n);return Math.round(r*o)/o}function Ed(n){const r=v.useRef(n);return Is(()=>{r.current=n}),r}function AA(n){n===void 0&&(n={});const{placement:r="bottom",strategy:o="absolute",middleware:l=[],platform:s,elements:{reference:c,floating:d}={},transform:m=!0,whileElementsMounted:y,open:g}=n,[b,p]=v.useState({x:0,y:0,strategy:o,placement:r,middlewareData:{},isPositioned:!1}),[w,C]=v.useState(l);lu(w,l)||C(l);const[R,S]=v.useState(null),[N,j]=v.useState(null),O=v.useCallback(_=>{_!==Z.current&&(Z.current=_,S(_))},[]),k=v.useCallback(_=>{_!==B.current&&(B.current=_,j(_))},[]),Q=c||R,I=d||N,Z=v.useRef(null),B=v.useRef(null),G=v.useRef(b),ue=y!=null,ie=Ed(y),oe=Ed(s),fe=Ed(g),ge=v.useCallback(()=>{if(!Z.current||!B.current)return;const _={placement:r,strategy:o,middleware:w};oe.current&&(_.platform=oe.current),TA(Z.current,B.current,_).then(F=>{const ne={...F,isPositioned:fe.current!==!1};ae.current&&!lu(G.current,ne)&&(G.current=ne,sl.flushSync(()=>{p(ne)}))})},[w,r,o,oe,fe]);Is(()=>{g===!1&&G.current.isPositioned&&(G.current.isPositioned=!1,p(_=>({..._,isPositioned:!1})))},[g]);const ae=v.useRef(!1);Is(()=>(ae.current=!0,()=>{ae.current=!1}),[]),Is(()=>{if(Q&&(Z.current=Q),I&&(B.current=I),Q&&I){if(ie.current)return ie.current(Q,I,ge);ge()}},[Q,I,ge,ie,ue]);const W=v.useMemo(()=>({reference:Z,floating:B,setReference:O,setFloating:k}),[O,k]),T=v.useMemo(()=>({reference:Q,floating:I}),[Q,I]),U=v.useMemo(()=>{const _={position:o,left:0,top:0};if(!T.floating)return _;const F=rb(T.floating,b.x),ne=rb(T.floating,b.y);return m?{..._,transform:"translate("+F+"px, "+ne+"px)",...ix(T.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:F,top:ne}},[o,m,T.floating,b.x,b.y]);return v.useMemo(()=>({...b,update:ge,refs:W,elements:T,floatingStyles:U}),[b,ge,W,T,U])}const OA=n=>{function r(o){return{}.hasOwnProperty.call(o,"current")}return{name:"arrow",options:n,fn(o){const{element:l,padding:s}=typeof n=="function"?n(o):n;return l&&r(l)?l.current!=null?ab({element:l.current,padding:s}).fn(o):{}:l?ab({element:l,padding:s}).fn(o):{}}}},_A=(n,r)=>({...wA(n),options:[n,r]}),DA=(n,r)=>({...SA(n),options:[n,r]}),zA=(n,r)=>({...NA(n),options:[n,r]}),kA=(n,r)=>({...EA(n),options:[n,r]}),LA=(n,r)=>({...CA(n),options:[n,r]}),UA=(n,r)=>({...RA(n),options:[n,r]}),HA=(n,r)=>({...OA(n),options:[n,r]});var BA="Arrow",lx=v.forwardRef((n,r)=>{const{children:o,width:l=10,height:s=5,...c}=n;return h.jsx(De.svg,{...c,ref:r,width:l,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?o:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});lx.displayName=BA;var PA=lx;function qA(n){const[r,o]=v.useState(void 0);return Nt(()=>{if(n){o({width:n.offsetWidth,height:n.offsetHeight});const l=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const c=s[0];let d,m;if("borderBoxSize"in c){const y=c.borderBoxSize,g=Array.isArray(y)?y[0]:y;d=g.inlineSize,m=g.blockSize}else d=n.offsetWidth,m=n.offsetHeight;o({width:d,height:m})});return l.observe(n,{box:"border-box"}),()=>l.unobserve(n)}else o(void 0)},[n]),r}var Dh="Popper",[sx,Qo]=nr(Dh),[$A,ux]=sx(Dh),cx=n=>{const{__scopePopper:r,children:o}=n,[l,s]=v.useState(null);return h.jsx($A,{scope:r,anchor:l,onAnchorChange:s,children:o})};cx.displayName=Dh;var fx="PopperAnchor",dx=v.forwardRef((n,r)=>{const{__scopePopper:o,virtualRef:l,...s}=n,c=ux(fx,o),d=v.useRef(null),m=$e(r,d),y=v.useRef(null);return v.useEffect(()=>{const g=y.current;y.current=l?.current||d.current,g!==y.current&&c.onAnchorChange(y.current)}),l?null:h.jsx(De.div,{...s,ref:m})});dx.displayName=fx;var zh="PopperContent",[VA,FA]=sx(zh),hx=v.forwardRef((n,r)=>{const{__scopePopper:o,side:l="bottom",sideOffset:s=0,align:c="center",alignOffset:d=0,arrowPadding:m=0,avoidCollisions:y=!0,collisionBoundary:g=[],collisionPadding:b=0,sticky:p="partial",hideWhenDetached:w=!1,updatePositionStrategy:C="optimized",onPlaced:R,...S}=n,N=ux(zh,o),[j,O]=v.useState(null),k=$e(r,Y=>O(Y)),[Q,I]=v.useState(null),Z=qA(Q),B=Z?.width??0,G=Z?.height??0,ue=l+(c!=="center"?"-"+c:""),ie=typeof b=="number"?b:{top:0,right:0,bottom:0,left:0,...b},oe=Array.isArray(g)?g:[g],fe=oe.length>0,ge={padding:ie,boundary:oe.filter(YA),altBoundary:fe},{refs:ae,floatingStyles:W,placement:T,isPositioned:U,middlewareData:_}=AA({strategy:"fixed",placement:ue,whileElementsMounted:(...Y)=>xA(...Y,{animationFrame:C==="always"}),elements:{reference:N.anchor},middleware:[_A({mainAxis:s+G,alignmentAxis:d}),y&&DA({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?zA():void 0,...ge}),y&&kA({...ge}),LA({...ge,apply:({elements:Y,rects:le,availableWidth:ce,availableHeight:ve})=>{const{width:we,height:Ce}=le.reference,et=Y.floating.style;et.setProperty("--radix-popper-available-width",`${ce}px`),et.setProperty("--radix-popper-available-height",`${ve}px`),et.setProperty("--radix-popper-anchor-width",`${we}px`),et.setProperty("--radix-popper-anchor-height",`${Ce}px`)}}),Q&&HA({element:Q,padding:m}),IA({arrowWidth:B,arrowHeight:G}),w&&UA({strategy:"referenceHidden",...ge})]}),[F,ne]=gx(T),M=Fn(R);Nt(()=>{U&&M?.()},[U,M]);const A=_.arrow?.x,L=_.arrow?.y,P=_.arrow?.centerOffset!==0,[K,re]=v.useState();return Nt(()=>{j&&re(window.getComputedStyle(j).zIndex)},[j]),h.jsx("div",{ref:ae.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:U?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:K,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:h.jsx(VA,{scope:o,placedSide:F,onArrowChange:I,arrowX:A,arrowY:L,shouldHideArrow:P,children:h.jsx(De.div,{"data-side":F,"data-align":ne,...S,ref:k,style:{...S.style,animation:U?void 0:"none"}})})})});hx.displayName=zh;var mx="PopperArrow",GA={top:"bottom",right:"left",bottom:"top",left:"right"},px=v.forwardRef(function(r,o){const{__scopePopper:l,...s}=r,c=FA(mx,l),d=GA[c.placedSide];return h.jsx("span",{ref:c.onArrowChange,style:{position:"absolute",left:c.arrowX,top:c.arrowY,[d]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[c.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[c.placedSide],visibility:c.shouldHideArrow?"hidden":void 0},children:h.jsx(PA,{...s,ref:o,style:{...s.style,display:"block"}})})});px.displayName=mx;function YA(n){return n!==null}var IA=n=>({name:"transformOrigin",options:n,fn(r){const{placement:o,rects:l,middlewareData:s}=r,d=s.arrow?.centerOffset!==0,m=d?0:n.arrowWidth,y=d?0:n.arrowHeight,[g,b]=gx(o),p={start:"0%",center:"50%",end:"100%"}[b],w=(s.arrow?.x??0)+m/2,C=(s.arrow?.y??0)+y/2;let R="",S="";return g==="bottom"?(R=d?p:`${w}px`,S=`${-y}px`):g==="top"?(R=d?p:`${w}px`,S=`${l.floating.height+y}px`):g==="right"?(R=`${-y}px`,S=d?p:`${C}px`):g==="left"&&(R=`${l.floating.width+y}px`,S=d?p:`${C}px`),{data:{x:R,y:S}}}});function gx(n){const[r,o="center"]=n.split("-");return[r,o]}var kh=cx,Lh=dx,Uh=hx,Hh=px,Cd="rovingFocusGroup.onEntryFocus",QA={bubbles:!1,cancelable:!0},ml="RovingFocusGroup",[Yd,vx,KA]=Rh(ml),[XA,yx]=nr(ml,[KA]),[ZA,JA]=XA(ml),bx=v.forwardRef((n,r)=>h.jsx(Yd.Provider,{scope:n.__scopeRovingFocusGroup,children:h.jsx(Yd.Slot,{scope:n.__scopeRovingFocusGroup,children:h.jsx(WA,{...n,ref:r})})}));bx.displayName=ml;var WA=v.forwardRef((n,r)=>{const{__scopeRovingFocusGroup:o,orientation:l,loop:s=!1,dir:c,currentTabStopId:d,defaultCurrentTabStopId:m,onCurrentTabStopIdChange:y,onEntryFocus:g,preventScrollOnEntryFocus:b=!1,...p}=n,w=v.useRef(null),C=$e(r,w),R=Nh(c),[S,N]=Lo({prop:d,defaultProp:m??null,onChange:y,caller:ml}),[j,O]=v.useState(!1),k=Fn(g),Q=vx(o),I=v.useRef(!1),[Z,B]=v.useState(0);return v.useEffect(()=>{const G=w.current;if(G)return G.addEventListener(Cd,k),()=>G.removeEventListener(Cd,k)},[k]),h.jsx(ZA,{scope:o,orientation:l,dir:R,loop:s,currentTabStopId:S,onItemFocus:v.useCallback(G=>N(G),[N]),onItemShiftTab:v.useCallback(()=>O(!0),[]),onFocusableItemAdd:v.useCallback(()=>B(G=>G+1),[]),onFocusableItemRemove:v.useCallback(()=>B(G=>G-1),[]),children:h.jsx(De.div,{tabIndex:j||Z===0?-1:0,"data-orientation":l,...p,ref:C,style:{outline:"none",...n.style},onMouseDown:he(n.onMouseDown,()=>{I.current=!0}),onFocus:he(n.onFocus,G=>{const ue=!I.current;if(G.target===G.currentTarget&&ue&&!j){const ie=new CustomEvent(Cd,QA);if(G.currentTarget.dispatchEvent(ie),!ie.defaultPrevented){const oe=Q().filter(T=>T.focusable),fe=oe.find(T=>T.active),ge=oe.find(T=>T.id===S),W=[fe,ge,...oe].filter(Boolean).map(T=>T.ref.current);Sx(W,b)}}I.current=!1}),onBlur:he(n.onBlur,()=>O(!1))})})}),xx="RovingFocusGroupItem",wx=v.forwardRef((n,r)=>{const{__scopeRovingFocusGroup:o,focusable:l=!0,active:s=!1,tabStopId:c,children:d,...m}=n,y=_t(),g=c||y,b=JA(xx,o),p=b.currentTabStopId===g,w=vx(o),{onFocusableItemAdd:C,onFocusableItemRemove:R,currentTabStopId:S}=b;return v.useEffect(()=>{if(l)return C(),()=>R()},[l,C,R]),h.jsx(Yd.ItemSlot,{scope:o,id:g,focusable:l,active:s,children:h.jsx(De.span,{tabIndex:p?0:-1,"data-orientation":b.orientation,...m,ref:r,onMouseDown:he(n.onMouseDown,N=>{l?b.onItemFocus(g):N.preventDefault()}),onFocus:he(n.onFocus,()=>b.onItemFocus(g)),onKeyDown:he(n.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){b.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const j=nO(N,b.orientation,b.dir);if(j!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let k=w().filter(Q=>Q.focusable).map(Q=>Q.ref.current);if(j==="last")k.reverse();else if(j==="prev"||j==="next"){j==="prev"&&k.reverse();const Q=k.indexOf(N.currentTarget);k=b.loop?aO(k,Q+1):k.slice(Q+1)}setTimeout(()=>Sx(k))}}),children:typeof d=="function"?d({isCurrentTabStop:p,hasTabStop:S!=null}):d})})});wx.displayName=xx;var eO={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function tO(n,r){return r!=="rtl"?n:n==="ArrowLeft"?"ArrowRight":n==="ArrowRight"?"ArrowLeft":n}function nO(n,r,o){const l=tO(n.key,o);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(l))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(l)))return eO[l]}function Sx(n,r=!1){const o=document.activeElement;for(const l of n)if(l===o||(l.focus({preventScroll:r}),document.activeElement!==o))return}function aO(n,r){return n.map((o,l)=>n[(r+l)%n.length])}var rO=bx,oO=wx;function iO(n){const r=lO(n),o=v.forwardRef((l,s)=>{const{children:c,...d}=l,m=v.Children.toArray(c),y=m.find(uO);if(y){const g=y.props.children,b=m.map(p=>p===y?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:p);return h.jsx(r,{...d,ref:s,children:v.isValidElement(g)?v.cloneElement(g,void 0,b):null})}return h.jsx(r,{...d,ref:s,children:c})});return o.displayName=`${n}.Slot`,o}function lO(n){const r=v.forwardRef((o,l)=>{const{children:s,...c}=o;if(v.isValidElement(s)){const d=fO(s),m=cO(c,s.props);return s.type!==v.Fragment&&(m.ref=l?It(l,d):d),v.cloneElement(s,m)}return v.Children.count(s)>1?v.Children.only(null):null});return r.displayName=`${n}.SlotClone`,r}var sO=Symbol("radix.slottable");function uO(n){return v.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===sO}function cO(n,r){const o={...r};for(const l in r){const s=n[l],c=r[l];/^on[A-Z]/.test(l)?s&&c?o[l]=(...m)=>{const y=c(...m);return s(...m),y}:s&&(o[l]=s):l==="style"?o[l]={...s,...c}:l==="className"&&(o[l]=[s,c].filter(Boolean).join(" "))}return{...n,...o}}function fO(n){let r=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?n.ref:(r=Object.getOwnPropertyDescriptor(n,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?n.props.ref:n.props.ref||n.ref)}var Id=["Enter"," "],dO=["ArrowDown","PageUp","Home"],Ex=["ArrowUp","PageDown","End"],hO=[...dO,...Ex],mO={ltr:[...Id,"ArrowRight"],rtl:[...Id,"ArrowLeft"]},pO={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pl="Menu",[al,gO,vO]=Rh(pl),[Hr,Cx]=nr(pl,[vO,Qo,yx]),Du=Qo(),Rx=yx(),[yO,Br]=Hr(pl),[bO,gl]=Hr(pl),Nx=n=>{const{__scopeMenu:r,open:o=!1,children:l,dir:s,onOpenChange:c,modal:d=!0}=n,m=Du(r),[y,g]=v.useState(null),b=v.useRef(!1),p=Fn(c),w=Nh(s);return v.useEffect(()=>{const C=()=>{b.current=!0,document.addEventListener("pointerdown",R,{capture:!0,once:!0}),document.addEventListener("pointermove",R,{capture:!0,once:!0})},R=()=>b.current=!1;return document.addEventListener("keydown",C,{capture:!0}),()=>{document.removeEventListener("keydown",C,{capture:!0}),document.removeEventListener("pointerdown",R,{capture:!0}),document.removeEventListener("pointermove",R,{capture:!0})}},[]),h.jsx(kh,{...m,children:h.jsx(yO,{scope:r,open:o,onOpenChange:p,content:y,onContentChange:g,children:h.jsx(bO,{scope:r,onClose:v.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:b,dir:w,modal:d,children:l})})})};Nx.displayName=pl;var xO="MenuAnchor",Bh=v.forwardRef((n,r)=>{const{__scopeMenu:o,...l}=n,s=Du(o);return h.jsx(Lh,{...s,...l,ref:r})});Bh.displayName=xO;var Ph="MenuPortal",[wO,Tx]=Hr(Ph,{forceMount:void 0}),jx=n=>{const{__scopeMenu:r,forceMount:o,children:l,container:s}=n,c=Br(Ph,r);return h.jsx(wO,{scope:r,forceMount:o,children:h.jsx(Yn,{present:o||c.open,children:h.jsx(cl,{asChild:!0,container:s,children:l})})})};jx.displayName=Ph;var yn="MenuContent",[SO,qh]=Hr(yn),Mx=v.forwardRef((n,r)=>{const o=Tx(yn,n.__scopeMenu),{forceMount:l=o.forceMount,...s}=n,c=Br(yn,n.__scopeMenu),d=gl(yn,n.__scopeMenu);return h.jsx(al.Provider,{scope:n.__scopeMenu,children:h.jsx(Yn,{present:l||c.open,children:h.jsx(al.Slot,{scope:n.__scopeMenu,children:d.modal?h.jsx(EO,{...s,ref:r}):h.jsx(CO,{...s,ref:r})})})})}),EO=v.forwardRef((n,r)=>{const o=Br(yn,n.__scopeMenu),l=v.useRef(null),s=$e(r,l);return v.useEffect(()=>{const c=l.current;if(c)return hh(c)},[]),h.jsx($h,{...n,ref:s,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:he(n.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})}),CO=v.forwardRef((n,r)=>{const o=Br(yn,n.__scopeMenu);return h.jsx($h,{...n,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})}),RO=iO("MenuContent.ScrollLock"),$h=v.forwardRef((n,r)=>{const{__scopeMenu:o,loop:l=!1,trapFocus:s,onOpenAutoFocus:c,onCloseAutoFocus:d,disableOutsidePointerEvents:m,onEntryFocus:y,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:p,onInteractOutside:w,onDismiss:C,disableOutsideScroll:R,...S}=n,N=Br(yn,o),j=gl(yn,o),O=Du(o),k=Rx(o),Q=gO(o),[I,Z]=v.useState(null),B=v.useRef(null),G=$e(r,B,N.onContentChange),ue=v.useRef(0),ie=v.useRef(""),oe=v.useRef(0),fe=v.useRef(null),ge=v.useRef("right"),ae=v.useRef(0),W=R?bu:v.Fragment,T=R?{as:RO,allowPinchZoom:!0}:void 0,U=F=>{const ne=ie.current+F,M=Q().filter(Y=>!Y.disabled),A=document.activeElement,L=M.find(Y=>Y.ref.current===A)?.textValue,P=M.map(Y=>Y.textValue),K=UO(P,ne,L),re=M.find(Y=>Y.textValue===K)?.ref.current;(function Y(le){ie.current=le,window.clearTimeout(ue.current),le!==""&&(ue.current=window.setTimeout(()=>Y(""),1e3))})(ne),re&&setTimeout(()=>re.focus())};v.useEffect(()=>()=>window.clearTimeout(ue.current),[]),dh();const _=v.useCallback(F=>ge.current===fe.current?.side&&BO(F,fe.current?.area),[]);return h.jsx(SO,{scope:o,searchRef:ie,onItemEnter:v.useCallback(F=>{_(F)&&F.preventDefault()},[_]),onItemLeave:v.useCallback(F=>{_(F)||(B.current?.focus(),Z(null))},[_]),onTriggerLeave:v.useCallback(F=>{_(F)&&F.preventDefault()},[_]),pointerGraceTimerRef:oe,onPointerGraceIntentChange:v.useCallback(F=>{fe.current=F},[]),children:h.jsx(W,{...T,children:h.jsx(vu,{asChild:!0,trapped:s,onMountAutoFocus:he(c,F=>{F.preventDefault(),B.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:d,children:h.jsx(ul,{asChild:!0,disableOutsidePointerEvents:m,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:p,onInteractOutside:w,onDismiss:C,children:h.jsx(rO,{asChild:!0,...k,dir:j.dir,orientation:"vertical",loop:l,currentTabStopId:I,onCurrentTabStopIdChange:Z,onEntryFocus:he(y,F=>{j.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(Uh,{role:"menu","aria-orientation":"vertical","data-state":Gx(N.open),"data-radix-menu-content":"",dir:j.dir,...O,...S,ref:G,style:{outline:"none",...S.style},onKeyDown:he(S.onKeyDown,F=>{const M=F.target.closest("[data-radix-menu-content]")===F.currentTarget,A=F.ctrlKey||F.altKey||F.metaKey,L=F.key.length===1;M&&(F.key==="Tab"&&F.preventDefault(),!A&&L&&U(F.key));const P=B.current;if(F.target!==P||!hO.includes(F.key))return;F.preventDefault();const re=Q().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);Ex.includes(F.key)&&re.reverse(),kO(re)}),onBlur:he(n.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(ue.current),ie.current="")}),onPointerMove:he(n.onPointerMove,rl(F=>{const ne=F.target,M=ae.current!==F.clientX;if(F.currentTarget.contains(ne)&&M){const A=F.clientX>ae.current?"right":"left";ge.current=A,ae.current=F.clientX}}))})})})})})})});Mx.displayName=yn;var NO="MenuGroup",Vh=v.forwardRef((n,r)=>{const{__scopeMenu:o,...l}=n;return h.jsx(De.div,{role:"group",...l,ref:r})});Vh.displayName=NO;var TO="MenuLabel",Ax=v.forwardRef((n,r)=>{const{__scopeMenu:o,...l}=n;return h.jsx(De.div,{...l,ref:r})});Ax.displayName=TO;var su="MenuItem",ob="menu.itemSelect",zu=v.forwardRef((n,r)=>{const{disabled:o=!1,onSelect:l,...s}=n,c=v.useRef(null),d=gl(su,n.__scopeMenu),m=qh(su,n.__scopeMenu),y=$e(r,c),g=v.useRef(!1),b=()=>{const p=c.current;if(!o&&p){const w=new CustomEvent(ob,{bubbles:!0,cancelable:!0});p.addEventListener(ob,C=>l?.(C),{once:!0}),Gb(p,w),w.defaultPrevented?g.current=!1:d.onClose()}};return h.jsx(Ox,{...s,ref:y,disabled:o,onClick:he(n.onClick,b),onPointerDown:p=>{n.onPointerDown?.(p),g.current=!0},onPointerUp:he(n.onPointerUp,p=>{g.current||p.currentTarget?.click()}),onKeyDown:he(n.onKeyDown,p=>{const w=m.searchRef.current!=="";o||w&&p.key===" "||Id.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});zu.displayName=su;var Ox=v.forwardRef((n,r)=>{const{__scopeMenu:o,disabled:l=!1,textValue:s,...c}=n,d=qh(su,o),m=Rx(o),y=v.useRef(null),g=$e(r,y),[b,p]=v.useState(!1),[w,C]=v.useState("");return v.useEffect(()=>{const R=y.current;R&&C((R.textContent??"").trim())},[c.children]),h.jsx(al.ItemSlot,{scope:o,disabled:l,textValue:s??w,children:h.jsx(oO,{asChild:!0,...m,focusable:!l,children:h.jsx(De.div,{role:"menuitem","data-highlighted":b?"":void 0,"aria-disabled":l||void 0,"data-disabled":l?"":void 0,...c,ref:g,onPointerMove:he(n.onPointerMove,rl(R=>{l?d.onItemLeave(R):(d.onItemEnter(R),R.defaultPrevented||R.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(n.onPointerLeave,rl(R=>d.onItemLeave(R))),onFocus:he(n.onFocus,()=>p(!0)),onBlur:he(n.onBlur,()=>p(!1))})})})}),jO="MenuCheckboxItem",_x=v.forwardRef((n,r)=>{const{checked:o=!1,onCheckedChange:l,...s}=n;return h.jsx(Ux,{scope:n.__scopeMenu,checked:o,children:h.jsx(zu,{role:"menuitemcheckbox","aria-checked":uu(o)?"mixed":o,...s,ref:r,"data-state":Gh(o),onSelect:he(s.onSelect,()=>l?.(uu(o)?!0:!o),{checkForDefaultPrevented:!1})})})});_x.displayName=jO;var Dx="MenuRadioGroup",[MO,AO]=Hr(Dx,{value:void 0,onValueChange:()=>{}}),zx=v.forwardRef((n,r)=>{const{value:o,onValueChange:l,...s}=n,c=Fn(l);return h.jsx(MO,{scope:n.__scopeMenu,value:o,onValueChange:c,children:h.jsx(Vh,{...s,ref:r})})});zx.displayName=Dx;var kx="MenuRadioItem",Lx=v.forwardRef((n,r)=>{const{value:o,...l}=n,s=AO(kx,n.__scopeMenu),c=o===s.value;return h.jsx(Ux,{scope:n.__scopeMenu,checked:c,children:h.jsx(zu,{role:"menuitemradio","aria-checked":c,...l,ref:r,"data-state":Gh(c),onSelect:he(l.onSelect,()=>s.onValueChange?.(o),{checkForDefaultPrevented:!1})})})});Lx.displayName=kx;var Fh="MenuItemIndicator",[Ux,OO]=Hr(Fh,{checked:!1}),Hx=v.forwardRef((n,r)=>{const{__scopeMenu:o,forceMount:l,...s}=n,c=OO(Fh,o);return h.jsx(Yn,{present:l||uu(c.checked)||c.checked===!0,children:h.jsx(De.span,{...s,ref:r,"data-state":Gh(c.checked)})})});Hx.displayName=Fh;var _O="MenuSeparator",Bx=v.forwardRef((n,r)=>{const{__scopeMenu:o,...l}=n;return h.jsx(De.div,{role:"separator","aria-orientation":"horizontal",...l,ref:r})});Bx.displayName=_O;var DO="MenuArrow",Px=v.forwardRef((n,r)=>{const{__scopeMenu:o,...l}=n,s=Du(o);return h.jsx(Hh,{...s,...l,ref:r})});Px.displayName=DO;var zO="MenuSub",[u4,qx]=Hr(zO),Xi="MenuSubTrigger",$x=v.forwardRef((n,r)=>{const o=Br(Xi,n.__scopeMenu),l=gl(Xi,n.__scopeMenu),s=qx(Xi,n.__scopeMenu),c=qh(Xi,n.__scopeMenu),d=v.useRef(null),{pointerGraceTimerRef:m,onPointerGraceIntentChange:y}=c,g={__scopeMenu:n.__scopeMenu},b=v.useCallback(()=>{d.current&&window.clearTimeout(d.current),d.current=null},[]);return v.useEffect(()=>b,[b]),v.useEffect(()=>{const p=m.current;return()=>{window.clearTimeout(p),y(null)}},[m,y]),h.jsx(Bh,{asChild:!0,...g,children:h.jsx(Ox,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":s.contentId,"data-state":Gx(o.open),...n,ref:It(r,s.onTriggerChange),onClick:p=>{n.onClick?.(p),!(n.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),o.open||o.onOpenChange(!0))},onPointerMove:he(n.onPointerMove,rl(p=>{c.onItemEnter(p),!p.defaultPrevented&&!n.disabled&&!o.open&&!d.current&&(c.onPointerGraceIntentChange(null),d.current=window.setTimeout(()=>{o.onOpenChange(!0),b()},100))})),onPointerLeave:he(n.onPointerLeave,rl(p=>{b();const w=o.content?.getBoundingClientRect();if(w){const C=o.content?.dataset.side,R=C==="right",S=R?-5:5,N=w[R?"left":"right"],j=w[R?"right":"left"];c.onPointerGraceIntentChange({area:[{x:p.clientX+S,y:p.clientY},{x:N,y:w.top},{x:j,y:w.top},{x:j,y:w.bottom},{x:N,y:w.bottom}],side:C}),window.clearTimeout(m.current),m.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(p),p.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:he(n.onKeyDown,p=>{const w=c.searchRef.current!=="";n.disabled||w&&p.key===" "||mO[l.dir].includes(p.key)&&(o.onOpenChange(!0),o.content?.focus(),p.preventDefault())})})})});$x.displayName=Xi;var Vx="MenuSubContent",Fx=v.forwardRef((n,r)=>{const o=Tx(yn,n.__scopeMenu),{forceMount:l=o.forceMount,...s}=n,c=Br(yn,n.__scopeMenu),d=gl(yn,n.__scopeMenu),m=qx(Vx,n.__scopeMenu),y=v.useRef(null),g=$e(r,y);return h.jsx(al.Provider,{scope:n.__scopeMenu,children:h.jsx(Yn,{present:l||c.open,children:h.jsx(al.Slot,{scope:n.__scopeMenu,children:h.jsx($h,{id:m.contentId,"aria-labelledby":m.triggerId,...s,ref:g,align:"start",side:d.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:b=>{d.isUsingKeyboardRef.current&&y.current?.focus(),b.preventDefault()},onCloseAutoFocus:b=>b.preventDefault(),onFocusOutside:he(n.onFocusOutside,b=>{b.target!==m.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:he(n.onEscapeKeyDown,b=>{d.onClose(),b.preventDefault()}),onKeyDown:he(n.onKeyDown,b=>{const p=b.currentTarget.contains(b.target),w=pO[d.dir].includes(b.key);p&&w&&(c.onOpenChange(!1),m.trigger?.focus(),b.preventDefault())})})})})})});Fx.displayName=Vx;function Gx(n){return n?"open":"closed"}function uu(n){return n==="indeterminate"}function Gh(n){return uu(n)?"indeterminate":n?"checked":"unchecked"}function kO(n){const r=document.activeElement;for(const o of n)if(o===r||(o.focus(),document.activeElement!==r))return}function LO(n,r){return n.map((o,l)=>n[(r+l)%n.length])}function UO(n,r,o){const s=r.length>1&&Array.from(r).every(g=>g===r[0])?r[0]:r,c=o?n.indexOf(o):-1;let d=LO(n,Math.max(c,0));s.length===1&&(d=d.filter(g=>g!==o));const y=d.find(g=>g.toLowerCase().startsWith(s.toLowerCase()));return y!==o?y:void 0}function HO(n,r){const{x:o,y:l}=n;let s=!1;for(let c=0,d=r.length-1;c<r.length;d=c++){const m=r[c],y=r[d],g=m.x,b=m.y,p=y.x,w=y.y;b>l!=w>l&&o<(p-g)*(l-b)/(w-b)+g&&(s=!s)}return s}function BO(n,r){if(!r)return!1;const o={x:n.clientX,y:n.clientY};return HO(o,r)}function rl(n){return r=>r.pointerType==="mouse"?n(r):void 0}var PO=Nx,qO=Bh,$O=jx,VO=Mx,FO=Vh,GO=Ax,YO=zu,IO=_x,QO=zx,KO=Lx,XO=Hx,ZO=Bx,JO=Px,WO=$x,e_=Fx,ku="DropdownMenu",[t_]=nr(ku,[Cx]),zt=Cx(),[n_,Yx]=t_(ku),Ix=n=>{const{__scopeDropdownMenu:r,children:o,dir:l,open:s,defaultOpen:c,onOpenChange:d,modal:m=!0}=n,y=zt(r),g=v.useRef(null),[b,p]=Lo({prop:s,defaultProp:c??!1,onChange:d,caller:ku});return h.jsx(n_,{scope:r,triggerId:_t(),triggerRef:g,contentId:_t(),open:b,onOpenChange:p,onOpenToggle:v.useCallback(()=>p(w=>!w),[p]),modal:m,children:h.jsx(PO,{...y,open:b,onOpenChange:p,dir:l,modal:m,children:o})})};Ix.displayName=ku;var Qx="DropdownMenuTrigger",Kx=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,disabled:l=!1,...s}=n,c=Yx(Qx,o),d=zt(o);return h.jsx(qO,{asChild:!0,...d,children:h.jsx(De.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":l?"":void 0,disabled:l,...s,ref:It(r,c.triggerRef),onPointerDown:he(n.onPointerDown,m=>{!l&&m.button===0&&m.ctrlKey===!1&&(c.onOpenToggle(),c.open||m.preventDefault())}),onKeyDown:he(n.onKeyDown,m=>{l||(["Enter"," "].includes(m.key)&&c.onOpenToggle(),m.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(m.key)&&m.preventDefault())})})})});Kx.displayName=Qx;var a_="DropdownMenuPortal",Xx=n=>{const{__scopeDropdownMenu:r,...o}=n,l=zt(r);return h.jsx($O,{...l,...o})};Xx.displayName=a_;var Zx="DropdownMenuContent",Jx=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=Yx(Zx,o),c=zt(o),d=v.useRef(!1);return h.jsx(VO,{id:s.contentId,"aria-labelledby":s.triggerId,...c,...l,ref:r,onCloseAutoFocus:he(n.onCloseAutoFocus,m=>{d.current||s.triggerRef.current?.focus(),d.current=!1,m.preventDefault()}),onInteractOutside:he(n.onInteractOutside,m=>{const y=m.detail.originalEvent,g=y.button===0&&y.ctrlKey===!0,b=y.button===2||g;(!s.modal||b)&&(d.current=!0)}),style:{...n.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Jx.displayName=Zx;var r_="DropdownMenuGroup",o_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(FO,{...s,...l,ref:r})});o_.displayName=r_;var i_="DropdownMenuLabel",l_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(GO,{...s,...l,ref:r})});l_.displayName=i_;var s_="DropdownMenuItem",Wx=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(YO,{...s,...l,ref:r})});Wx.displayName=s_;var u_="DropdownMenuCheckboxItem",c_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(IO,{...s,...l,ref:r})});c_.displayName=u_;var f_="DropdownMenuRadioGroup",d_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(QO,{...s,...l,ref:r})});d_.displayName=f_;var h_="DropdownMenuRadioItem",m_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(KO,{...s,...l,ref:r})});m_.displayName=h_;var p_="DropdownMenuItemIndicator",g_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(XO,{...s,...l,ref:r})});g_.displayName=p_;var v_="DropdownMenuSeparator",ew=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(ZO,{...s,...l,ref:r})});ew.displayName=v_;var y_="DropdownMenuArrow",b_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(JO,{...s,...l,ref:r})});b_.displayName=y_;var x_="DropdownMenuSubTrigger",w_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(WO,{...s,...l,ref:r})});w_.displayName=x_;var S_="DropdownMenuSubContent",E_=v.forwardRef((n,r)=>{const{__scopeDropdownMenu:o,...l}=n,s=zt(o);return h.jsx(e_,{...s,...l,ref:r,style:{...n.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});E_.displayName=S_;var C_=Ix,R_=Kx,N_=Xx,T_=Jx,Rd=Wx,j_=ew;async function Ko(n){try{return(await n.json()).error?.message??n.statusText}catch{return n.statusText}}async function M_(){const n=await fetch("/api/profiles");if(!n.ok)throw new Error(await Ko(n));return await n.json()}async function A_(){const n=await fetch("/api/profiles/active");if(!n.ok)throw new Error(await Ko(n));return await n.json()}function tw(){return St({queryKey:["profiles"],queryFn:M_})}function O_(){return St({queryKey:["active-profile"],queryFn:A_})}function nw(n){n.invalidateQueries({queryKey:["profiles"]}),n.invalidateQueries({queryKey:["active-profile"]}),n.invalidateQueries({queryKey:["continue-watching"]}),n.invalidateQueries({queryKey:["favorites"]}),n.invalidateQueries({queryKey:["favorite-status"]}),n.invalidateQueries({queryKey:["progress"]}),n.invalidateQueries({queryKey:["episode-progress"]})}function __(){const n=Dt();return wn({mutationFn:async r=>{const o=await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw new Error(await Ko(o));return await o.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["profiles"]})}})}function D_(){const n=Dt();return wn({mutationFn:async r=>{const{id:o,...l}=r,s=await fetch(`/api/profiles/${o}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!s.ok)throw new Error(await Ko(s));return await s.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["profiles"]}),n.invalidateQueries({queryKey:["active-profile"]})}})}function z_(){const n=Dt();return wn({mutationFn:async r=>{const o=await fetch(`/api/profiles/${r}`,{method:"DELETE"});if(!o.ok)throw new Error(await Ko(o))},onSuccess:()=>{nw(n)}})}function k_(){const n=Dt();return wn({mutationFn:async r=>{const o=await fetch(`/api/profiles/${r}/activate`,{method:"POST"});if(!o.ok)throw new Error(await Ko(o));return await o.json()},onSuccess:()=>{nw(n)}})}function L_(){const{data:n}=O_(),{data:r}=tw(),o=k_();return n?h.jsxs(C_,{children:[h.jsx(R_,{asChild:!0,children:h.jsx("button",{"aria-label":`Switch profile, current: ${n.name}`,className:"flex size-9 items-center justify-center rounded-full bg-muted text-lg transition-transform hover:scale-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary",type:"button",children:h.jsx("span",{"aria-hidden":!0,children:n.emoji})})}),h.jsx(N_,{children:h.jsxs(T_,{align:"end",className:"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",sideOffset:8,children:[r?.map(l=>{const s=l.id===n.id;return h.jsxs(Rd,{className:Fe("flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground",s&&"font-medium"),onSelect:c=>{s||(c.preventDefault(),o.mutate(l.id,{onError:d=>{Ze.error(d instanceof Error?d.message:"Failed to switch profile")}}))},children:[h.jsx("span",{"aria-hidden":!0,className:"text-base",children:l.emoji}),h.jsx("span",{className:"flex-1 truncate",children:l.name}),s?h.jsx(M0,{className:"size-4 text-muted-foreground"}):null]},l.id)}),h.jsx(j_,{className:"my-1 h-px bg-border"}),h.jsx(Rd,{asChild:!0,children:h.jsxs(xn,{className:"flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground",to:"/settings/profiles",children:[h.jsx(ij,{className:"size-4"}),"Manage profiles"]})}),h.jsx(Rd,{asChild:!0,children:h.jsxs(xn,{className:"flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground",to:"/settings",children:[h.jsx(tj,{className:"size-4"}),"Settings"]})})]})})]}):null}var Qs={exports:{}},U_=Qs.exports,ib;function H_(){return ib||(ib=1,(function(n,r){(function(o,l){n.exports=l()})(U_,(function(){var o=1e3,l=6e4,s=36e5,c="millisecond",d="second",m="minute",y="hour",g="day",b="week",p="month",w="quarter",C="year",R="date",S="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,j=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,O={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(ae){var W=["th","st","nd","rd"],T=ae%100;return"["+ae+(W[(T-20)%10]||W[T]||W[0])+"]"}},k=function(ae,W,T){var U=String(ae);return!U||U.length>=W?ae:""+Array(W+1-U.length).join(T)+ae},Q={s:k,z:function(ae){var W=-ae.utcOffset(),T=Math.abs(W),U=Math.floor(T/60),_=T%60;return(W<=0?"+":"-")+k(U,2,"0")+":"+k(_,2,"0")},m:function ae(W,T){if(W.date()<T.date())return-ae(T,W);var U=12*(T.year()-W.year())+(T.month()-W.month()),_=W.clone().add(U,p),F=T-_<0,ne=W.clone().add(U+(F?-1:1),p);return+(-(U+(T-_)/(F?_-ne:ne-_))||0)},a:function(ae){return ae<0?Math.ceil(ae)||0:Math.floor(ae)},p:function(ae){return{M:p,y:C,w:b,d:g,D:R,h:y,m,s:d,ms:c,Q:w}[ae]||String(ae||"").toLowerCase().replace(/s$/,"")},u:function(ae){return ae===void 0}},I="en",Z={};Z[I]=O;var B="$isDayjsObject",G=function(ae){return ae instanceof fe||!(!ae||!ae[B])},ue=function ae(W,T,U){var _;if(!W)return I;if(typeof W=="string"){var F=W.toLowerCase();Z[F]&&(_=F),T&&(Z[F]=T,_=F);var ne=W.split("-");if(!_&&ne.length>1)return ae(ne[0])}else{var M=W.name;Z[M]=W,_=M}return!U&&_&&(I=_),_||!U&&I},ie=function(ae,W){if(G(ae))return ae.clone();var T=typeof W=="object"?W:{};return T.date=ae,T.args=arguments,new fe(T)},oe=Q;oe.l=ue,oe.i=G,oe.w=function(ae,W){return ie(ae,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var fe=(function(){function ae(T){this.$L=ue(T.locale,null,!0),this.parse(T),this.$x=this.$x||T.x||{},this[B]=!0}var W=ae.prototype;return W.parse=function(T){this.$d=(function(U){var _=U.date,F=U.utc;if(_===null)return new Date(NaN);if(oe.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var ne=_.match(N);if(ne){var M=ne[2]-1||0,A=(ne[7]||"0").substring(0,3);return F?new Date(Date.UTC(ne[1],M,ne[3]||1,ne[4]||0,ne[5]||0,ne[6]||0,A)):new Date(ne[1],M,ne[3]||1,ne[4]||0,ne[5]||0,ne[6]||0,A)}}return new Date(_)})(T),this.init()},W.init=function(){var T=this.$d;this.$y=T.getFullYear(),this.$M=T.getMonth(),this.$D=T.getDate(),this.$W=T.getDay(),this.$H=T.getHours(),this.$m=T.getMinutes(),this.$s=T.getSeconds(),this.$ms=T.getMilliseconds()},W.$utils=function(){return oe},W.isValid=function(){return this.$d.toString()!==S},W.isSame=function(T,U){var _=ie(T);return this.startOf(U)<=_&&_<=this.endOf(U)},W.isAfter=function(T,U){return ie(T)<this.startOf(U)},W.isBefore=function(T,U){return this.endOf(U)<ie(T)},W.$g=function(T,U,_){return oe.u(T)?this[U]:this.set(_,T)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(T,U){var _=this,F=!!oe.u(U)||U,ne=oe.p(T),M=function(ce,ve){var we=oe.w(_.$u?Date.UTC(_.$y,ve,ce):new Date(_.$y,ve,ce),_);return F?we:we.endOf(g)},A=function(ce,ve){return oe.w(_.toDate()[ce].apply(_.toDate("s"),(F?[0,0,0,0]:[23,59,59,999]).slice(ve)),_)},L=this.$W,P=this.$M,K=this.$D,re="set"+(this.$u?"UTC":"");switch(ne){case C:return F?M(1,0):M(31,11);case p:return F?M(1,P):M(0,P+1);case b:var Y=this.$locale().weekStart||0,le=(L<Y?L+7:L)-Y;return M(F?K-le:K+(6-le),P);case g:case R:return A(re+"Hours",0);case y:return A(re+"Minutes",1);case m:return A(re+"Seconds",2);case d:return A(re+"Milliseconds",3);default:return this.clone()}},W.endOf=function(T){return this.startOf(T,!1)},W.$set=function(T,U){var _,F=oe.p(T),ne="set"+(this.$u?"UTC":""),M=(_={},_[g]=ne+"Date",_[R]=ne+"Date",_[p]=ne+"Month",_[C]=ne+"FullYear",_[y]=ne+"Hours",_[m]=ne+"Minutes",_[d]=ne+"Seconds",_[c]=ne+"Milliseconds",_)[F],A=F===g?this.$D+(U-this.$W):U;if(F===p||F===C){var L=this.clone().set(R,1);L.$d[M](A),L.init(),this.$d=L.set(R,Math.min(this.$D,L.daysInMonth())).$d}else M&&this.$d[M](A);return this.init(),this},W.set=function(T,U){return this.clone().$set(T,U)},W.get=function(T){return this[oe.p(T)]()},W.add=function(T,U){var _,F=this;T=Number(T);var ne=oe.p(U),M=function(P){var K=ie(F);return oe.w(K.date(K.date()+Math.round(P*T)),F)};if(ne===p)return this.set(p,this.$M+T);if(ne===C)return this.set(C,this.$y+T);if(ne===g)return M(1);if(ne===b)return M(7);var A=(_={},_[m]=l,_[y]=s,_[d]=o,_)[ne]||1,L=this.$d.getTime()+T*A;return oe.w(L,this)},W.subtract=function(T,U){return this.add(-1*T,U)},W.format=function(T){var U=this,_=this.$locale();if(!this.isValid())return _.invalidDate||S;var F=T||"YYYY-MM-DDTHH:mm:ssZ",ne=oe.z(this),M=this.$H,A=this.$m,L=this.$M,P=_.weekdays,K=_.months,re=_.meridiem,Y=function(ve,we,Ce,et){return ve&&(ve[we]||ve(U,F))||Ce[we].slice(0,et)},le=function(ve){return oe.s(M%12||12,ve,"0")},ce=re||function(ve,we,Ce){var et=ve<12?"AM":"PM";return Ce?et.toLowerCase():et};return F.replace(j,(function(ve,we){return we||(function(Ce){switch(Ce){case"YY":return String(U.$y).slice(-2);case"YYYY":return oe.s(U.$y,4,"0");case"M":return L+1;case"MM":return oe.s(L+1,2,"0");case"MMM":return Y(_.monthsShort,L,K,3);case"MMMM":return Y(K,L);case"D":return U.$D;case"DD":return oe.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return Y(_.weekdaysMin,U.$W,P,2);case"ddd":return Y(_.weekdaysShort,U.$W,P,3);case"dddd":return P[U.$W];case"H":return String(M);case"HH":return oe.s(M,2,"0");case"h":return le(1);case"hh":return le(2);case"a":return ce(M,A,!0);case"A":return ce(M,A,!1);case"m":return String(A);case"mm":return oe.s(A,2,"0");case"s":return String(U.$s);case"ss":return oe.s(U.$s,2,"0");case"SSS":return oe.s(U.$ms,3,"0");case"Z":return ne}return null})(ve)||ne.replace(":","")}))},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(T,U,_){var F,ne=this,M=oe.p(U),A=ie(T),L=(A.utcOffset()-this.utcOffset())*l,P=this-A,K=function(){return oe.m(ne,A)};switch(M){case C:F=K()/12;break;case p:F=K();break;case w:F=K()/3;break;case b:F=(P-L)/6048e5;break;case g:F=(P-L)/864e5;break;case y:F=P/s;break;case m:F=P/l;break;case d:F=P/o;break;default:F=P}return _?F:oe.a(F)},W.daysInMonth=function(){return this.endOf(p).$D},W.$locale=function(){return Z[this.$L]},W.locale=function(T,U){if(!T)return this.$L;var _=this.clone(),F=ue(T,U,!0);return F&&(_.$L=F),_},W.clone=function(){return oe.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},ae})(),ge=fe.prototype;return ie.prototype=ge,[["$ms",c],["$s",d],["$m",m],["$H",y],["$W",g],["$M",p],["$y",C],["$D",R]].forEach((function(ae){ge[ae[1]]=function(W){return this.$g(W,ae[0],ae[1])}})),ie.extend=function(ae,W){return ae.$i||(ae(W,fe,ie),ae.$i=!0),ie},ie.locale=ue,ie.isDayjs=G,ie.unix=function(ae){return ie(1e3*ae)},ie.en=Z[I],ie.Ls=Z,ie.p={},ie}))})(Qs)),Qs.exports}var B_=H_();const kr=hu(B_);var Ks={exports:{}},P_=Ks.exports,lb;function q_(){return lb||(lb=1,(function(n,r){(function(o,l){n.exports=l()})(P_,(function(){return function(o,l,s){o=o||{};var c=l.prototype,d={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function m(g,b,p,w){return c.fromToBase(g,b,p,w)}s.en.relativeTime=d,c.fromToBase=function(g,b,p,w,C){for(var R,S,N,j=p.$locale().relativeTime||d,O=o.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],k=O.length,Q=0;Q<k;Q+=1){var I=O[Q];I.d&&(R=w?s(g).diff(p,I.d,!0):p.diff(g,I.d,!0));var Z=(o.rounding||Math.round)(Math.abs(R));if(N=R>0,Z<=I.r||!I.r){Z<=1&&Q>0&&(I=O[Q-1]);var B=j[I.l];C&&(Z=C(""+Z)),S=typeof B=="string"?B.replace("%d",Z):B(Z,b,I.l,N);break}}if(b)return S;var G=N?j.future:j.past;return typeof G=="function"?G(S):G.replace("%s",S)},c.to=function(g,b){return m(g,b,this,!0)},c.from=function(g,b){return m(g,b,this)};var y=function(g){return g.$u?s.utc():s()};c.toNow=function(g){return this.to(y(this),g)},c.fromNow=function(g){return this.from(y(this),g)}}}))})(Ks)),Ks.exports}var $_=q_();const Yh=hu($_);var Nd,Lu="HoverCard",[aw]=nr(Lu,[Qo]),Uu=Qo(),[V_,Hu]=aw(Lu),rw=n=>{const{__scopeHoverCard:r,children:o,open:l,defaultOpen:s,onOpenChange:c,openDelay:d=700,closeDelay:m=300}=n,y=Uu(r),g=v.useRef(0),b=v.useRef(0),p=v.useRef(!1),w=v.useRef(!1),[C,R]=Lo({prop:l,defaultProp:s??!1,onChange:c,caller:Lu}),S=v.useCallback(()=>{clearTimeout(b.current),g.current=window.setTimeout(()=>R(!0),d)},[d,R]),N=v.useCallback(()=>{clearTimeout(g.current),!p.current&&!w.current&&(b.current=window.setTimeout(()=>R(!1),m))},[m,R]),j=v.useCallback(()=>R(!1),[R]);return v.useEffect(()=>()=>{clearTimeout(g.current),clearTimeout(b.current)},[]),h.jsx(V_,{scope:r,open:C,onOpenChange:R,onOpen:S,onClose:N,onDismiss:j,hasSelectionRef:p,isPointerDownOnContentRef:w,children:h.jsx(kh,{...y,children:o})})};rw.displayName=Lu;var ow="HoverCardTrigger",iw=v.forwardRef((n,r)=>{const{__scopeHoverCard:o,...l}=n,s=Hu(ow,o),c=Uu(o);return h.jsx(Lh,{asChild:!0,...c,children:h.jsx(De.a,{"data-state":s.open?"open":"closed",...l,ref:r,onPointerEnter:he(n.onPointerEnter,fu(s.onOpen)),onPointerLeave:he(n.onPointerLeave,fu(s.onClose)),onFocus:he(n.onFocus,s.onOpen),onBlur:he(n.onBlur,s.onClose),onTouchStart:he(n.onTouchStart,d=>d.preventDefault())})})});iw.displayName=ow;var Ih="HoverCardPortal",[F_,G_]=aw(Ih,{forceMount:void 0}),lw=n=>{const{__scopeHoverCard:r,forceMount:o,children:l,container:s}=n,c=Hu(Ih,r);return h.jsx(F_,{scope:r,forceMount:o,children:h.jsx(Yn,{present:o||c.open,children:h.jsx(cl,{asChild:!0,container:s,children:l})})})};lw.displayName=Ih;var cu="HoverCardContent",sw=v.forwardRef((n,r)=>{const o=G_(cu,n.__scopeHoverCard),{forceMount:l=o.forceMount,...s}=n,c=Hu(cu,n.__scopeHoverCard);return h.jsx(Yn,{present:l||c.open,children:h.jsx(Y_,{"data-state":c.open?"open":"closed",...s,onPointerEnter:he(n.onPointerEnter,fu(c.onOpen)),onPointerLeave:he(n.onPointerLeave,fu(c.onClose)),ref:r})})});sw.displayName=cu;var Y_=v.forwardRef((n,r)=>{const{__scopeHoverCard:o,onEscapeKeyDown:l,onPointerDownOutside:s,onFocusOutside:c,onInteractOutside:d,...m}=n,y=Hu(cu,o),g=Uu(o),b=v.useRef(null),p=$e(r,b),[w,C]=v.useState(!1);return v.useEffect(()=>{if(w){const R=document.body;return Nd=R.style.userSelect||R.style.webkitUserSelect,R.style.userSelect="none",R.style.webkitUserSelect="none",()=>{R.style.userSelect=Nd,R.style.webkitUserSelect=Nd}}},[w]),v.useEffect(()=>{if(b.current){const R=()=>{C(!1),y.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(y.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",R),()=>{document.removeEventListener("pointerup",R),y.hasSelectionRef.current=!1,y.isPointerDownOnContentRef.current=!1}}},[y.isPointerDownOnContentRef,y.hasSelectionRef]),v.useEffect(()=>{b.current&&K_(b.current).forEach(S=>S.setAttribute("tabindex","-1"))}),h.jsx(ul,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:s,onFocusOutside:he(c,R=>{R.preventDefault()}),onDismiss:y.onDismiss,children:h.jsx(Uh,{...g,...m,onPointerDown:he(m.onPointerDown,R=>{R.currentTarget.contains(R.target)&&C(!0),y.hasSelectionRef.current=!1,y.isPointerDownOnContentRef.current=!0}),ref:p,style:{...m.style,userSelect:w?"text":void 0,WebkitUserSelect:w?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),I_="HoverCardArrow",Q_=v.forwardRef((n,r)=>{const{__scopeHoverCard:o,...l}=n,s=Uu(o);return h.jsx(Hh,{...s,...l,ref:r})});Q_.displayName=I_;function fu(n){return r=>r.pointerType==="touch"?void 0:n()}function K_(n){const r=[],o=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:l=>l.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;o.nextNode();)r.push(o.currentNode);return r}var X_=rw,Z_=iw,J_=lw,W_=sw;function eD({...n}){return h.jsx(X_,{"data-slot":"hover-card",...n})}function tD({...n}){return h.jsx(Z_,{"data-slot":"hover-card-trigger",...n})}function nD({className:n,align:r="center",sideOffset:o=4,...l}){return h.jsx(J_,{"data-slot":"hover-card-portal",children:h.jsx(W_,{"data-slot":"hover-card-content",align:r,sideOffset:o,className:Fe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",n),...l})})}async function uw(n){try{return(await n.json()).error?.message??n.statusText}catch{return n.statusText}}async function aD(n){const r=await fetch(n);if(!r.ok)throw new Error(await uw(r));return await r.json()}const Qh=["scan","status"];function cw(){return St({queryKey:Qh,queryFn:()=>aD("/api/scan/status")})}function rD(){const n=Dt();return wn({mutationFn:async()=>{const r=await fetch("/api/scan/start",{method:"POST"});if(!r.ok)throw new Error(await uw(r));return await r.json()},onSuccess:()=>{n.invalidateQueries({queryKey:Qh})}})}function oD(){const n=Dt();v.useEffect(()=>{const r=new EventSource("/api/scan/stream");function o(){n.invalidateQueries({queryKey:Qh})}function l(){n.invalidateQueries({queryKey:["search"]})}const s=["library-start","file-scanned","library-complete","library-error","scan-complete"];for(const c of s)r.addEventListener(c,o);return r.addEventListener("scan-complete",l),()=>{for(const c of s)r.removeEventListener(c,o);r.removeEventListener("scan-complete",l),r.close()}},[n])}kr.extend(Yh);function fw(n){return kr(n).fromNow()}function iD({job:n}){const r=n.total>0?`Scanning ${n.added+n.updated}/${n.total}`:"Scanning…";return h.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[h.jsx(Tu,{className:"size-4 animate-spin","aria-hidden":"true"}),h.jsx("span",{className:"hidden text-xs sm:inline",children:r})]})}function lD({job:n}){if(!n)return h.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[h.jsx(JT,{className:"size-4","aria-hidden":"true"}),h.jsx("span",{className:"hidden text-xs sm:inline",children:"No scans yet"})]});const r=n.endedAt??n.startedAt;return h.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[h.jsx(LT,{className:"size-4","aria-hidden":"true"}),h.jsxs("span",{className:"hidden text-xs sm:inline",children:["Scanned ",fw(r)]})]})}function sD(){return h.jsxs("span",{className:"inline-flex items-center gap-1.5 text-destructive",children:[h.jsx(rj,{className:"size-4","aria-hidden":"true"}),h.jsx("span",{className:"hidden text-xs sm:inline",children:"Last scan failed"})]})}function uD(){oD();const{data:n,isLoading:r}=cw();if(r)return null;const o=n??{currentJob:null,isRunning:!1,lastJob:null},l=(()=>{if(o.isRunning&&o.currentJob){const c=o.currentJob,d=c.added+c.updated;return h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm font-medium",children:"Scanning"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:c.total>0?`${d} of ${c.total} files processed`:"Discovering files…"}),h.jsx("p",{className:"mt-2 text-xs",children:"Click for live progress."})]})}if(o.lastJob?.status==="error")return h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm font-medium text-destructive",children:"Last scan failed"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:o.lastJob.errorMessage??"Unknown error."}),h.jsx("p",{className:"mt-2 text-xs",children:"Click to retry."})]});if(o.lastJob){const c=o.lastJob.endedAt??o.lastJob.startedAt;return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:"text-sm font-medium",children:["Scanned ",fw(c)]}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:[o.lastJob.added," new, ",o.lastJob.updated," updated,"," ",o.lastJob.total," total"]}),h.jsx("p",{className:"mt-2 text-xs",children:"Click to run a scan."})]})}return h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm font-medium",children:"No scans yet"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Run your first scan to see your library."})]})})(),s=o.isRunning&&o.currentJob?h.jsx(iD,{job:o.currentJob}):o.lastJob?.status==="error"?h.jsx(sD,{}):h.jsx(lD,{job:o.lastJob});return h.jsxs(eD,{children:[h.jsx(tD,{asChild:!0,children:h.jsx(xn,{to:"/scan",className:Fe("inline-flex h-11 items-center gap-1 rounded-md px-2 text-sm transition-colors hover:text-foreground",o.isRunning||o.lastJob?.status==="error"?"text-foreground":"text-muted-foreground"),"aria-label":"Scan status",children:s})}),h.jsx(nD,{align:"end",className:"w-64",children:l})]})}function rn(){const[n,r]=v.useState(0),o=oM();v.useEffect(function(){function c(){r(window.scrollY)}return c(),window.addEventListener("scroll",c),()=>{window.removeEventListener("scroll",c)}},[]);const l=n>=16;return h.jsx("header",{className:Fe("sticky top-0 z-10 w-full transition-all duration-300",l?"bg-background/80 backdrop-blur-md shadow-sm":"bg-transparent"),children:h.jsxs("nav",{className:"flex items-center gap-3 px-4 py-2 sm:gap-6 sm:px-6 sm:py-4",children:[h.jsxs(xn,{className:"flex min-h-11 items-center gap-2 text-lg font-bold tracking-tight text-primary sm:text-xl",tabIndex:-1,to:"/",children:[h.jsx("img",{alt:"",className:"size-7",src:"/images/jukebox-icon-28.png"}),h.jsx("span",{className:"hidden xs:inline sm:inline",children:"Jukebox"})]}),h.jsxs("div",{className:"flex items-center gap-0.5 text-sm sm:gap-1",children:[h.jsx(Ws,{className:({isActive:s})=>Fe("flex min-h-11 items-center rounded-md px-3 transition-colors",s?"text-foreground":"text-muted-foreground hover:text-foreground"),to:"/movies",children:"Movies"}),h.jsxs(Ws,{className:({isActive:s})=>Fe("flex min-h-11 items-center rounded-md px-3 transition-colors",s?"text-foreground":"text-muted-foreground hover:text-foreground"),to:"/shows",children:[h.jsx("span",{className:"hidden sm:inline",children:"TV Shows"}),h.jsx("span",{className:"sm:hidden",children:"Shows"})]})]}),h.jsxs("div",{className:"ml-auto flex items-center gap-1 sm:gap-2",children:[h.jsxs("button",{"aria-label":"Search (press / to focus)",className:"inline-flex h-11 items-center gap-2 rounded-md px-2 text-sm text-muted-foreground transition-colors hover:text-foreground",onClick:()=>o.open(),type:"button",children:[h.jsx(_0,{"aria-hidden":!0,className:"size-4"}),h.jsx("kbd",{className:"hidden rounded border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-xs text-muted-foreground sm:inline",children:"/"})]}),h.jsx(uD,{}),h.jsx(L_,{})]})]})})}function Yt(){const n=Array.from({length:8},(r,o)=>o);return h.jsxs("div",{className:"px-6 py-4",children:[h.jsx("div",{className:"h-5 w-32 bg-muted rounded animate-pulse mb-3"}),h.jsx("div",{className:"flex gap-2 overflow-hidden",children:n.map(r=>h.jsxs("div",{className:"flex-shrink-0 w-32 md:w-40",children:[h.jsx("div",{className:"w-full aspect-[2/3] bg-muted rounded-sm animate-pulse"}),h.jsx("div",{className:"h-3 w-3/4 bg-muted rounded animate-pulse mt-1.5"})]},r))})]})}function cD({items:n}){return n.length===0?null:h.jsxs("section",{className:"px-6 py-4",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-3",children:"Up Next"}),h.jsx("div",{className:"flex gap-2 overflow-x-auto scroll-smooth pb-2 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:n.map(r=>{const o=`Next: S${r.episode.seasonNumber} E${r.episode.episodeNumber} — ${r.episode.title}`;return h.jsxs(xn,{className:"flex-shrink-0 w-32 md:w-40 group",to:`/watch/episode/${r.episode.id}`,children:[h.jsx("div",{className:"relative w-full overflow-hidden rounded-sm",children:h.jsx(dl,{alt:r.show.title,className:"w-full transition-transform duration-200 group-hover:scale-105",url:r.show.posterUrl,title:r.show.title})}),h.jsx("p",{className:"text-xs text-muted-foreground truncate mt-1.5 px-0.5",children:r.show.title}),h.jsx("p",{className:"text-xs text-muted-foreground/70 truncate px-0.5",children:o})]},`up-next-${r.show.id}-${r.episode.id}`)})})]})}async function fD(){const n=await fetch("/api/progress/continue-watching");if(!n.ok)throw new Error("Failed to fetch continue watching");return await n.json()}function dD(){return St({queryKey:["continue-watching"],queryFn:fD})}async function hD(){const n=await fetch("/api/library/movies");if(!n.ok)throw new Error("Failed to fetch movies");return await n.json()}function dw(){return St({queryKey:["movies"],queryFn:hD})}async function mD(){const n=await fetch("/api/library/shows");if(!n.ok)throw new Error("Failed to fetch shows");return await n.json()}function hw(){return St({queryKey:["shows"],queryFn:mD})}async function pD(){const n=await fetch("/api/library/up-next");if(!n.ok)throw new Error("Failed to fetch Up Next");return await n.json()}function gD(){return St({queryKey:["up-next"],queryFn:pD})}function Kh(n,r,o=2){const l=new Map;for(const c of n){const d=vD(c);for(const m of d){const y=l.get(m)??[];y.push(c),l.set(m,y)}}const s=Array.from(l.entries()).filter(([,c])=>c.length>=o).sort((c,d)=>d[1].length-c[1].length).map(([c,d])=>({genre:c,items:d}));return r?s.slice(0,r):s}function vD(n){const r=n.item.genres;return yD(r)}function yD(n){if(!n)return[];try{const r=JSON.parse(n);return Array.isArray(r)?r.filter(o=>typeof o=="string"):[]}catch{return[]}}function bD(n,r){return[...n.map(l=>({type:"movie",item:l})),...r.map(l=>({type:"show",item:l}))]}const xD=6,wD=20;function SD(){const{data:n,isLoading:r}=dw(),{data:o,isLoading:l}=hw(),{data:s,isLoading:c}=dD(),{data:d,isLoading:m}=gD(),y=r||l||c||m,g=v.useMemo(()=>bD(n??[],o??[]),[n,o]),b=v.useMemo(()=>g.length===0?[]:Kh(g,xD),[g]),p=v.useMemo(()=>g.length===0?[]:[...g].sort((w,C)=>new Date(C.item.createdAt).getTime()-new Date(w.item.createdAt).getTime()).slice(0,wD),[g]);return y?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"pt-4",children:[h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{})]})]}):g.length===0?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4 text-center px-6",children:[h.jsx(Nu,{className:"size-16 text-muted-foreground"}),h.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"No media in your library"}),h.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:"Your libraries are configured but no media was found. Check that your library paths are correct, or run a scan."}),h.jsx(Ie,{asChild:!0,variant:"outline",children:h.jsx(xn,{to:"/setup",children:"Go to Setup"})})]})]}):h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"pt-2 pb-8",children:[s&&s.length>0&&h.jsx(pM,{items:s}),d&&d.length>0&&h.jsx(cD,{items:d}),h.jsx(SM,{}),b.map(({genre:w,items:C})=>h.jsx(el,{items:C,title:w},w)),h.jsx(el,{items:p,title:"Recently Added"})]})]})}function va({className:n,type:r,...o}){return h.jsx("input",{type:r,"data-slot":"input",className:Fe("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",n),...o})}var ED=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],CD=ED.reduce((n,r)=>{const o=yh(`Primitive.${r}`),l=v.forwardRef((s,c)=>{const{asChild:d,...m}=s,y=d?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(y,{...m,ref:c})});return l.displayName=`Primitive.${r}`,{...n,[r]:l}},{}),RD="Label",mw=v.forwardRef((n,r)=>h.jsx(CD.label,{...n,ref:r,onMouseDown:o=>{o.target.closest("button, input, select, textarea")||(n.onMouseDown?.(o),!o.defaultPrevented&&o.detail>1&&o.preventDefault())}}));mw.displayName=RD;var ND=mw;function Za({className:n,...r}){return h.jsx(ND,{"data-slot":"label",className:Fe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",n),...r})}function TD(){const n=Vo(),{data:r,isLoading:o}=Eh(),l=sM(),[s,c]=v.useState(""),[d,m]=v.useState(null);if(o)return h.jsx("div",{className:"flex min-h-screen items-center justify-center text-muted-foreground",children:"Loading…"});if(r&&(!r.enabled||r.authenticated))return h.jsx(pu,{to:"/",replace:!0});async function y(g){g.preventDefault(),m(null);try{await l.mutateAsync(s),n("/",{replace:!0})}catch(b){m(b instanceof Error?b.message:"Something went wrong. Please try again.")}}return h.jsx("div",{className:"flex min-h-screen items-center justify-center px-6",children:h.jsxs("form",{className:"w-full max-w-sm rounded-lg border bg-card p-6 shadow-sm",onSubmit:g=>{y(g)},children:[h.jsx("h1",{className:"text-xl font-semibold",children:"Sign in to Jukebox"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Enter the shared password to continue."}),h.jsxs("div",{className:"mt-6 grid gap-2",children:[h.jsx(Za,{htmlFor:"password",children:"Password"}),h.jsx(va,{autoComplete:"current-password",autoFocus:!0,id:"password",onChange:g=>c(g.target.value),required:!0,type:"password",value:s})]}),d?h.jsx("p",{className:"mt-3 text-sm text-destructive",role:"alert",children:d}):null,h.jsx(Ie,{className:"mt-6 w-full",disabled:l.isPending||s.length===0,type:"submit",children:l.isPending?"Signing in…":"Sign in"})]})})}function jD(){const{data:n,isLoading:r}=dw(),o=v.useMemo(()=>n?n.map(s=>({type:"movie",item:s})):[],[n]),l=v.useMemo(()=>o.length===0?[]:Kh(o),[o]);return r?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"pt-4",children:[h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{})]})]}):o.length===0?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4 text-center px-6",children:[h.jsx(Nu,{className:"size-16 text-muted-foreground"}),h.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"No movies in your library"}),h.jsxs("p",{className:"text-sm text-muted-foreground max-w-md",children:["Run"," ",h.jsx("code",{className:"bg-muted px-2 py-1 rounded text-xs font-mono",children:"bun run scan /path/to/movies"})," ","to add your collection."]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsx("div",{className:"pt-2 pb-8",children:l.map(({genre:s,items:c})=>h.jsx(el,{items:c,title:s},s))})]})}function Td({className:n,...r}){return h.jsx("div",{"data-slot":"skeleton",className:Fe("bg-muted animate-pulse rounded-md",n),...r})}kr.extend(Yh);async function MD(){const n=await fetch("/api/scan/libraries");if(!n.ok)throw new Error("Failed to fetch libraries");return await n.json()}function AD(n){return{id:n.id,name:n.name,progress:{added:0,total:0,updated:0},status:"pending",type:n.type}}function OD(n){return n.reduce((r,o)=>({added:r.added+o.progress.added,found:r.found+o.progress.total,updated:r.updated+o.progress.updated}),{added:0,found:0,updated:0})}function _D(){const{data:n}=cw(),r=rD(),[o,l]=v.useState(null),[s,c]=v.useState(!1),d=v.useRef(!1),m=v.useMemo(()=>o?OD(o):{added:0,found:0,updated:0},[o]),y=v.useCallback(async()=>{const p=await MD();l(p.map(AD))},[]);v.useEffect(()=>{d.current||(d.current=!0,y())},[y]),v.useEffect(()=>{const p=new EventSource("/api/scan/stream");return p.addEventListener("library-start",w=>{const C=JSON.parse(w.data);c(!0),l(R=>R?.map(S=>S.id===C.libraryId?{...S,status:"scanning"}:S)??null)}),p.addEventListener("file-scanned",w=>{const C=JSON.parse(w.data);l(R=>R?.map(S=>S.id===C.libraryId?{...S,progress:{added:C.added,total:C.total,updated:C.updated}}:S)??null)}),p.addEventListener("library-complete",w=>{const C=JSON.parse(w.data);l(R=>R?.map(S=>S.id===C.libraryId?{...S,progress:{added:C.added,total:C.total,updated:C.updated},status:"complete"}:S)??null)}),p.addEventListener("library-error",w=>{const C=JSON.parse(w.data);l(R=>R?.map(S=>S.id===C.libraryId?{...S,error:C.error,status:"error"}:S)??null)}),p.addEventListener("scan-complete",()=>{c(!1)}),()=>{p.close()}},[]);const g=s||(n?.isRunning??!1);async function b(){try{if((await r.mutateAsync()).status==="already-running"){Ze.info("A scan is already running.");return}l(w=>w?.map(C=>({...C,progress:{added:0,total:0,updated:0},status:"pending",error:void 0}))??null)}catch(p){const w=p instanceof Error?p.message:"Couldn't start the scan.";Ze.error(w)}}return h.jsxs("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col px-6 py-16",children:[h.jsx("div",{className:"mb-6 animate-fade-up",children:h.jsxs(xn,{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",to:"/",children:[h.jsx(ST,{className:"size-4"}),"Back"]})}),h.jsxs("div",{className:"mb-8 animate-fade-up",children:[h.jsx("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:g?"Scanning your libraries…":"Library scan"}),h.jsx(DD,{status:n,totals:m,isRunning:g})]}),h.jsx("div",{className:"animate-fade-up animate-delay-1",children:o===null?h.jsx("div",{className:"space-y-4",children:[1,2].map(p=>h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(Td,{className:"size-4 rounded-full"}),h.jsxs("div",{className:"flex-1 space-y-1.5",children:[h.jsx(Td,{className:"h-3.5 w-32"}),h.jsx(Td,{className:"h-3 w-20"})]})]},p))}):o.length===0?h.jsx("p",{className:"text-sm text-muted-foreground",children:"No libraries configured. Add one from Settings before running a scan."}):h.jsx("div",{className:"space-y-4",children:o.map(p=>h.jsxs("div",{className:"flex items-center gap-3",children:[p.status==="pending"&&h.jsx(zT,{className:"size-4 shrink-0 text-muted-foreground/20"}),p.status==="scanning"&&h.jsx(Tu,{className:"size-4 shrink-0 animate-spin text-foreground"}),p.status==="complete"&&h.jsx(AT,{className:"size-4 shrink-0 text-foreground"}),p.status==="error"&&h.jsx(_T,{className:"size-4 shrink-0 text-destructive"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("p",{className:"text-sm text-foreground",children:p.name}),p.status==="pending"&&h.jsx("p",{className:"text-xs text-muted-foreground/50",children:"Waiting"}),(p.status==="scanning"||p.status==="complete")&&h.jsx("p",{className:"text-xs text-muted-foreground",children:p.progress.total>0?h.jsxs(h.Fragment,{children:[p.progress.total," files",p.progress.added>0&&` · ${p.progress.added} new`,p.progress.updated>0&&` · ${p.progress.updated} updated`]}):"Scanning…"}),p.status==="error"&&h.jsx("p",{className:"text-xs text-destructive",children:p.error})]})]},p.id))})}),h.jsx("div",{className:"mt-12 animate-fade-up animate-delay-2",children:h.jsx(Ie,{disabled:g||r.isPending,onClick:()=>{b()},size:"lg",type:"button",children:g?"Scan in progress…":r.isPending?"Starting…":"Start manual scan"})})]})}function DD({isRunning:n,status:r,totals:o}){if(n)return h.jsx("p",{className:"mt-2 text-muted-foreground",children:o.found>0?`${o.found} files scanned so far.`:"Discovering files…"});if(r?.lastJob){const l=r.lastJob,s=l.endedAt??l.startedAt;return l.status==="error"?h.jsxs("p",{className:"mt-2 text-destructive",children:["Last scan failed"," ",kr(s).fromNow()," — ",l.errorMessage??"Unknown error."]}):h.jsxs("p",{className:"mt-2 text-muted-foreground",children:["Scanned ",kr(s).fromNow()," · ",l.added," new, ",l.updated," ","updated, ",l.total," total."]})}return h.jsx("p",{className:"mt-2 text-muted-foreground",children:"No scans have run yet. Start one below."})}const zD=[{to:"/settings/profiles",label:"Profiles"},{to:"/settings/libraries",label:"Libraries"},{to:"/settings/scan-schedule",label:"Scan schedule"},{to:"/settings/auth",label:"Auth"}];function Ho({children:n}){return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"mx-auto grid w-full max-w-5xl gap-8 px-6 py-8 md:grid-cols-[12rem_1fr]",children:[h.jsxs("aside",{children:[h.jsx("h1",{className:"mb-4 text-lg font-semibold",children:"Settings"}),h.jsx("nav",{className:"flex flex-col gap-1 text-sm",children:zD.map(r=>h.jsx(Ws,{className:({isActive:o})=>Fe("rounded-md px-3 py-2 transition-colors",o?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"),to:r.to,children:r.label},r.to))})]}),h.jsx("main",{children:n})]})]})}function kD(){const{data:n,isLoading:r}=Eh(),o=cM(),l=uM(),[s,c]=v.useState(""),[d,m]=v.useState(""),[y,g]=v.useState(""),[b,p]=v.useState(null),w=n?.enabled??!1;async function C(N){if(N.preventDefault(),p(null),d!==y){p("Passwords do not match.");return}if(d.length<8){p("Choose a password of at least 8 characters.");return}try{const j=await o.mutateAsync({currentPassword:w?s:void 0,newPassword:d});Ze.success(j.enabled?"Password updated.":"Password disabled."),c(""),m(""),g("")}catch(j){p(j instanceof Error?j.message:"Something went wrong. Please try again.")}}async function R(){if(window.confirm("Disable the shared password? Anyone on your network will be able to use Jukebox.")){p(null);try{await o.mutateAsync({currentPassword:s,newPassword:""}),Ze.success("Password disabled."),c("")}catch(j){p(j instanceof Error?j.message:"Something went wrong. Please try again.")}}}async function S(){try{await l.mutateAsync(),Ze.success("Signed out.")}catch(N){Ze.error(N instanceof Error?N.message:"Failed to sign out.")}}return r?h.jsx(Ho,{children:h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})}):h.jsxs(Ho,{children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Authentication"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Protect Jukebox with a shared password. Everyone uses the same password to sign in."})]}),h.jsxs("div",{className:"mt-6 rounded-lg border bg-card p-4",children:[h.jsx("p",{className:"text-sm font-medium",children:w?"Auth is on":"Auth is off"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:w?"Visitors must sign in with the shared password.":"Anyone who can reach this server can use it."})]}),h.jsxs("form",{className:"mt-6 grid max-w-md gap-4",onSubmit:N=>{C(N)},children:[w?h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"current-password",children:"Current password"}),h.jsx(va,{autoComplete:"current-password",id:"current-password",onChange:N=>c(N.target.value),required:!0,type:"password",value:s})]}):null,h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"new-password",children:w?"New password":"Password"}),h.jsx(va,{autoComplete:"new-password",id:"new-password",minLength:8,onChange:N=>m(N.target.value),required:!0,type:"password",value:d}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters."})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"confirm-password",children:"Confirm password"}),h.jsx(va,{autoComplete:"new-password",id:"confirm-password",minLength:8,onChange:N=>g(N.target.value),required:!0,type:"password",value:y})]}),b?h.jsx("p",{className:"text-sm text-destructive",role:"alert",children:b}):null,h.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.jsx(Ie,{disabled:o.isPending,type:"submit",children:w?"Change password":"Enable and set password"}),w?h.jsxs(h.Fragment,{children:[h.jsx(Ie,{disabled:o.isPending||s.length===0,onClick:()=>{R()},type:"button",variant:"destructive",children:"Disable"}),h.jsx(Ie,{disabled:l.isPending,onClick:()=>{S()},type:"button",variant:"outline",children:"Sign out"})]}):null]})]})]})}function sb(n,[r,o]){return Math.min(o,Math.max(r,n))}function LD(n){const r=UD(n),o=v.forwardRef((l,s)=>{const{children:c,...d}=l,m=v.Children.toArray(c),y=m.find(BD);if(y){const g=y.props.children,b=m.map(p=>p===y?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:p);return h.jsx(r,{...d,ref:s,children:v.isValidElement(g)?v.cloneElement(g,void 0,b):null})}return h.jsx(r,{...d,ref:s,children:c})});return o.displayName=`${n}.Slot`,o}function UD(n){const r=v.forwardRef((o,l)=>{const{children:s,...c}=o;if(v.isValidElement(s)){const d=qD(s),m=PD(c,s.props);return s.type!==v.Fragment&&(m.ref=l?It(l,d):d),v.cloneElement(s,m)}return v.Children.count(s)>1?v.Children.only(null):null});return r.displayName=`${n}.SlotClone`,r}var HD=Symbol("radix.slottable");function BD(n){return v.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===HD}function PD(n,r){const o={...r};for(const l in r){const s=n[l],c=r[l];/^on[A-Z]/.test(l)?s&&c?o[l]=(...m)=>{const y=c(...m);return s(...m),y}:s&&(o[l]=s):l==="style"?o[l]={...s,...c}:l==="className"&&(o[l]=[s,c].filter(Boolean).join(" "))}return{...n,...o}}function qD(n){let r=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?n.ref:(r=Object.getOwnPropertyDescriptor(n,"ref")?.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?n.props.ref:n.props.ref||n.ref)}function $D(n){const r=v.useRef({value:n,previous:n});return v.useMemo(()=>(r.current.value!==n&&(r.current.previous=r.current.value,r.current.value=n),r.current.previous),[n])}var pw=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),VD="VisuallyHidden",FD=v.forwardRef((n,r)=>h.jsx(De.span,{...n,ref:r,style:{...pw,...n.style}}));FD.displayName=VD;var GD=[" ","Enter","ArrowUp","ArrowDown"],YD=[" ","Enter"],Lr="Select",[Bu,Pu,ID]=Rh(Lr),[Xo]=nr(Lr,[ID,Qo]),qu=Qo(),[QD,rr]=Xo(Lr),[KD,XD]=Xo(Lr),gw=n=>{const{__scopeSelect:r,children:o,open:l,defaultOpen:s,onOpenChange:c,value:d,defaultValue:m,onValueChange:y,dir:g,name:b,autoComplete:p,disabled:w,required:C,form:R}=n,S=qu(r),[N,j]=v.useState(null),[O,k]=v.useState(null),[Q,I]=v.useState(!1),Z=Nh(g),[B,G]=Lo({prop:l,defaultProp:s??!1,onChange:c,caller:Lr}),[ue,ie]=Lo({prop:d,defaultProp:m,onChange:y,caller:Lr}),oe=v.useRef(null),fe=N?R||!!N.closest("form"):!0,[ge,ae]=v.useState(new Set),W=Array.from(ge).map(T=>T.props.value).join(";");return h.jsx(kh,{...S,children:h.jsxs(QD,{required:C,scope:r,trigger:N,onTriggerChange:j,valueNode:O,onValueNodeChange:k,valueNodeHasChildren:Q,onValueNodeHasChildrenChange:I,contentId:_t(),value:ue,onValueChange:ie,open:B,onOpenChange:G,dir:Z,triggerPointerDownPosRef:oe,disabled:w,children:[h.jsx(Bu.Provider,{scope:r,children:h.jsx(KD,{scope:n.__scopeSelect,onNativeOptionAdd:v.useCallback(T=>{ae(U=>new Set(U).add(T))},[]),onNativeOptionRemove:v.useCallback(T=>{ae(U=>{const _=new Set(U);return _.delete(T),_})},[]),children:o})}),fe?h.jsxs(Hw,{"aria-hidden":!0,required:C,tabIndex:-1,name:b,autoComplete:p,value:ue,onChange:T=>ie(T.target.value),disabled:w,form:R,children:[ue===void 0?h.jsx("option",{value:""}):null,Array.from(ge)]},W):null]})})};gw.displayName=Lr;var vw="SelectTrigger",yw=v.forwardRef((n,r)=>{const{__scopeSelect:o,disabled:l=!1,...s}=n,c=qu(o),d=rr(vw,o),m=d.disabled||l,y=$e(r,d.onTriggerChange),g=Pu(o),b=v.useRef("touch"),[p,w,C]=Pw(S=>{const N=g().filter(k=>!k.disabled),j=N.find(k=>k.value===d.value),O=qw(N,S,j);O!==void 0&&d.onValueChange(O.value)}),R=S=>{m||(d.onOpenChange(!0),C()),S&&(d.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return h.jsx(Lh,{asChild:!0,...c,children:h.jsx(De.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:m,"data-disabled":m?"":void 0,"data-placeholder":Bw(d.value)?"":void 0,...s,ref:y,onClick:he(s.onClick,S=>{S.currentTarget.focus(),b.current!=="mouse"&&R(S)}),onPointerDown:he(s.onPointerDown,S=>{b.current=S.pointerType;const N=S.target;N.hasPointerCapture(S.pointerId)&&N.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(R(S),S.preventDefault())}),onKeyDown:he(s.onKeyDown,S=>{const N=p.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&w(S.key),!(N&&S.key===" ")&&GD.includes(S.key)&&(R(),S.preventDefault())})})})});yw.displayName=vw;var bw="SelectValue",xw=v.forwardRef((n,r)=>{const{__scopeSelect:o,className:l,style:s,children:c,placeholder:d="",...m}=n,y=rr(bw,o),{onValueNodeHasChildrenChange:g}=y,b=c!==void 0,p=$e(r,y.onValueNodeChange);return Nt(()=>{g(b)},[g,b]),h.jsx(De.span,{...m,ref:p,style:{pointerEvents:"none"},children:Bw(y.value)?h.jsx(h.Fragment,{children:d}):c})});xw.displayName=bw;var ZD="SelectIcon",ww=v.forwardRef((n,r)=>{const{__scopeSelect:o,children:l,...s}=n;return h.jsx(De.span,{"aria-hidden":!0,...s,ref:r,children:l||"▼"})});ww.displayName=ZD;var JD="SelectPortal",Sw=n=>h.jsx(cl,{asChild:!0,...n});Sw.displayName=JD;var Ur="SelectContent",Ew=v.forwardRef((n,r)=>{const o=rr(Ur,n.__scopeSelect),[l,s]=v.useState();if(Nt(()=>{s(new DocumentFragment)},[]),!o.open){const c=l;return c?sl.createPortal(h.jsx(Cw,{scope:n.__scopeSelect,children:h.jsx(Bu.Slot,{scope:n.__scopeSelect,children:h.jsx("div",{children:n.children})})}),c):null}return h.jsx(Rw,{...n,ref:r})});Ew.displayName=Ur;var Mn=10,[Cw,or]=Xo(Ur),WD="SelectContentImpl",e3=LD("SelectContent.RemoveScroll"),Rw=v.forwardRef((n,r)=>{const{__scopeSelect:o,position:l="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:c,onPointerDownOutside:d,side:m,sideOffset:y,align:g,alignOffset:b,arrowPadding:p,collisionBoundary:w,collisionPadding:C,sticky:R,hideWhenDetached:S,avoidCollisions:N,...j}=n,O=rr(Ur,o),[k,Q]=v.useState(null),[I,Z]=v.useState(null),B=$e(r,Y=>Q(Y)),[G,ue]=v.useState(null),[ie,oe]=v.useState(null),fe=Pu(o),[ge,ae]=v.useState(!1),W=v.useRef(!1);v.useEffect(()=>{if(k)return hh(k)},[k]),dh();const T=v.useCallback(Y=>{const[le,...ce]=fe().map(Ce=>Ce.ref.current),[ve]=ce.slice(-1),we=document.activeElement;for(const Ce of Y)if(Ce===we||(Ce?.scrollIntoView({block:"nearest"}),Ce===le&&I&&(I.scrollTop=0),Ce===ve&&I&&(I.scrollTop=I.scrollHeight),Ce?.focus(),document.activeElement!==we))return},[fe,I]),U=v.useCallback(()=>T([G,k]),[T,G,k]);v.useEffect(()=>{ge&&U()},[ge,U]);const{onOpenChange:_,triggerPointerDownPosRef:F}=O;v.useEffect(()=>{if(k){let Y={x:0,y:0};const le=ve=>{Y={x:Math.abs(Math.round(ve.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(ve.pageY)-(F.current?.y??0))}},ce=ve=>{Y.x<=10&&Y.y<=10?ve.preventDefault():k.contains(ve.target)||_(!1),document.removeEventListener("pointermove",le),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",ce,{capture:!0})}}},[k,_,F]),v.useEffect(()=>{const Y=()=>_(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[_]);const[ne,M]=Pw(Y=>{const le=fe().filter(we=>!we.disabled),ce=le.find(we=>we.ref.current===document.activeElement),ve=qw(le,Y,ce);ve&&setTimeout(()=>ve.ref.current.focus())}),A=v.useCallback((Y,le,ce)=>{const ve=!W.current&&!ce;(O.value!==void 0&&O.value===le||ve)&&(ue(Y),ve&&(W.current=!0))},[O.value]),L=v.useCallback(()=>k?.focus(),[k]),P=v.useCallback((Y,le,ce)=>{const ve=!W.current&&!ce;(O.value!==void 0&&O.value===le||ve)&&oe(Y)},[O.value]),K=l==="popper"?Qd:Nw,re=K===Qd?{side:m,sideOffset:y,align:g,alignOffset:b,arrowPadding:p,collisionBoundary:w,collisionPadding:C,sticky:R,hideWhenDetached:S,avoidCollisions:N}:{};return h.jsx(Cw,{scope:o,content:k,viewport:I,onViewportChange:Z,itemRefCallback:A,selectedItem:G,onItemLeave:L,itemTextRefCallback:P,focusSelectedItem:U,selectedItemText:ie,position:l,isPositioned:ge,searchRef:ne,children:h.jsx(bu,{as:e3,allowPinchZoom:!0,children:h.jsx(vu,{asChild:!0,trapped:O.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:he(s,Y=>{O.trigger?.focus({preventScroll:!0}),Y.preventDefault()}),children:h.jsx(ul,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>O.onOpenChange(!1),children:h.jsx(K,{role:"listbox",id:O.contentId,"data-state":O.open?"open":"closed",dir:O.dir,onContextMenu:Y=>Y.preventDefault(),...j,...re,onPlaced:()=>ae(!0),ref:B,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:he(j.onKeyDown,Y=>{const le=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!le&&Y.key.length===1&&M(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let ve=fe().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(ve=ve.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const we=Y.target,Ce=ve.indexOf(we);ve=ve.slice(Ce+1)}setTimeout(()=>T(ve)),Y.preventDefault()}})})})})})})});Rw.displayName=WD;var t3="SelectItemAlignedPosition",Nw=v.forwardRef((n,r)=>{const{__scopeSelect:o,onPlaced:l,...s}=n,c=rr(Ur,o),d=or(Ur,o),[m,y]=v.useState(null),[g,b]=v.useState(null),p=$e(r,B=>b(B)),w=Pu(o),C=v.useRef(!1),R=v.useRef(!0),{viewport:S,selectedItem:N,selectedItemText:j,focusSelectedItem:O}=d,k=v.useCallback(()=>{if(c.trigger&&c.valueNode&&m&&g&&S&&N&&j){const B=c.trigger.getBoundingClientRect(),G=g.getBoundingClientRect(),ue=c.valueNode.getBoundingClientRect(),ie=j.getBoundingClientRect();if(c.dir!=="rtl"){const we=ie.left-G.left,Ce=ue.left-we,et=B.left-Ce,ut=B.width+et,Qn=Math.max(ut,G.width),Dn=window.innerWidth-Mn,En=sb(Ce,[Mn,Math.max(Mn,Dn-Qn)]);m.style.minWidth=ut+"px",m.style.left=En+"px"}else{const we=G.right-ie.right,Ce=window.innerWidth-ue.right-we,et=window.innerWidth-B.right-Ce,ut=B.width+et,Qn=Math.max(ut,G.width),Dn=window.innerWidth-Mn,En=sb(Ce,[Mn,Math.max(Mn,Dn-Qn)]);m.style.minWidth=ut+"px",m.style.right=En+"px"}const oe=w(),fe=window.innerHeight-Mn*2,ge=S.scrollHeight,ae=window.getComputedStyle(g),W=parseInt(ae.borderTopWidth,10),T=parseInt(ae.paddingTop,10),U=parseInt(ae.borderBottomWidth,10),_=parseInt(ae.paddingBottom,10),F=W+T+ge+_+U,ne=Math.min(N.offsetHeight*5,F),M=window.getComputedStyle(S),A=parseInt(M.paddingTop,10),L=parseInt(M.paddingBottom,10),P=B.top+B.height/2-Mn,K=fe-P,re=N.offsetHeight/2,Y=N.offsetTop+re,le=W+T+Y,ce=F-le;if(le<=P){const we=oe.length>0&&N===oe[oe.length-1].ref.current;m.style.bottom="0px";const Ce=g.clientHeight-S.offsetTop-S.offsetHeight,et=Math.max(K,re+(we?L:0)+Ce+U),ut=le+et;m.style.height=ut+"px"}else{const we=oe.length>0&&N===oe[0].ref.current;m.style.top="0px";const et=Math.max(P,W+S.offsetTop+(we?A:0)+re)+ce;m.style.height=et+"px",S.scrollTop=le-P+S.offsetTop}m.style.margin=`${Mn}px 0`,m.style.minHeight=ne+"px",m.style.maxHeight=fe+"px",l?.(),requestAnimationFrame(()=>C.current=!0)}},[w,c.trigger,c.valueNode,m,g,S,N,j,c.dir,l]);Nt(()=>k(),[k]);const[Q,I]=v.useState();Nt(()=>{g&&I(window.getComputedStyle(g).zIndex)},[g]);const Z=v.useCallback(B=>{B&&R.current===!0&&(k(),O?.(),R.current=!1)},[k,O]);return h.jsx(a3,{scope:o,contentWrapper:m,shouldExpandOnScrollRef:C,onScrollButtonChange:Z,children:h.jsx("div",{ref:y,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:h.jsx(De.div,{...s,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Nw.displayName=t3;var n3="SelectPopperPosition",Qd=v.forwardRef((n,r)=>{const{__scopeSelect:o,align:l="start",collisionPadding:s=Mn,...c}=n,d=qu(o);return h.jsx(Uh,{...d,...c,ref:r,align:l,collisionPadding:s,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Qd.displayName=n3;var[a3,Xh]=Xo(Ur,{}),Kd="SelectViewport",Tw=v.forwardRef((n,r)=>{const{__scopeSelect:o,nonce:l,...s}=n,c=or(Kd,o),d=Xh(Kd,o),m=$e(r,c.onViewportChange),y=v.useRef(0);return h.jsxs(h.Fragment,{children:[h.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),h.jsx(Bu.Slot,{scope:o,children:h.jsx(De.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:m,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:he(s.onScroll,g=>{const b=g.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:w}=d;if(w?.current&&p){const C=Math.abs(y.current-b.scrollTop);if(C>0){const R=window.innerHeight-Mn*2,S=parseFloat(p.style.minHeight),N=parseFloat(p.style.height),j=Math.max(S,N);if(j<R){const O=j+C,k=Math.min(R,O),Q=O-k;p.style.height=k+"px",p.style.bottom==="0px"&&(b.scrollTop=Q>0?Q:0,p.style.justifyContent="flex-end")}}}y.current=b.scrollTop})})})]})});Tw.displayName=Kd;var jw="SelectGroup",[r3,o3]=Xo(jw),i3=v.forwardRef((n,r)=>{const{__scopeSelect:o,...l}=n,s=_t();return h.jsx(r3,{scope:o,id:s,children:h.jsx(De.div,{role:"group","aria-labelledby":s,...l,ref:r})})});i3.displayName=jw;var Mw="SelectLabel",l3=v.forwardRef((n,r)=>{const{__scopeSelect:o,...l}=n,s=o3(Mw,o);return h.jsx(De.div,{id:s.id,...l,ref:r})});l3.displayName=Mw;var du="SelectItem",[s3,Aw]=Xo(du),Ow=v.forwardRef((n,r)=>{const{__scopeSelect:o,value:l,disabled:s=!1,textValue:c,...d}=n,m=rr(du,o),y=or(du,o),g=m.value===l,[b,p]=v.useState(c??""),[w,C]=v.useState(!1),R=$e(r,O=>y.itemRefCallback?.(O,l,s)),S=_t(),N=v.useRef("touch"),j=()=>{s||(m.onValueChange(l),m.onOpenChange(!1))};if(l==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return h.jsx(s3,{scope:o,value:l,disabled:s,textId:S,isSelected:g,onItemTextChange:v.useCallback(O=>{p(k=>k||(O?.textContent??"").trim())},[]),children:h.jsx(Bu.ItemSlot,{scope:o,value:l,disabled:s,textValue:b,children:h.jsx(De.div,{role:"option","aria-labelledby":S,"data-highlighted":w?"":void 0,"aria-selected":g&&w,"data-state":g?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...d,ref:R,onFocus:he(d.onFocus,()=>C(!0)),onBlur:he(d.onBlur,()=>C(!1)),onClick:he(d.onClick,()=>{N.current!=="mouse"&&j()}),onPointerUp:he(d.onPointerUp,()=>{N.current==="mouse"&&j()}),onPointerDown:he(d.onPointerDown,O=>{N.current=O.pointerType}),onPointerMove:he(d.onPointerMove,O=>{N.current=O.pointerType,s?y.onItemLeave?.():N.current==="mouse"&&O.currentTarget.focus({preventScroll:!0})}),onPointerLeave:he(d.onPointerLeave,O=>{O.currentTarget===document.activeElement&&y.onItemLeave?.()}),onKeyDown:he(d.onKeyDown,O=>{y.searchRef?.current!==""&&O.key===" "||(YD.includes(O.key)&&j(),O.key===" "&&O.preventDefault())})})})})});Ow.displayName=du;var Zi="SelectItemText",_w=v.forwardRef((n,r)=>{const{__scopeSelect:o,className:l,style:s,...c}=n,d=rr(Zi,o),m=or(Zi,o),y=Aw(Zi,o),g=XD(Zi,o),[b,p]=v.useState(null),w=$e(r,j=>p(j),y.onItemTextChange,j=>m.itemTextRefCallback?.(j,y.value,y.disabled)),C=b?.textContent,R=v.useMemo(()=>h.jsx("option",{value:y.value,disabled:y.disabled,children:C},y.value),[y.disabled,y.value,C]),{onNativeOptionAdd:S,onNativeOptionRemove:N}=g;return Nt(()=>(S(R),()=>N(R)),[S,N,R]),h.jsxs(h.Fragment,{children:[h.jsx(De.span,{id:y.textId,...c,ref:w}),y.isSelected&&d.valueNode&&!d.valueNodeHasChildren?sl.createPortal(c.children,d.valueNode):null]})});_w.displayName=Zi;var Dw="SelectItemIndicator",zw=v.forwardRef((n,r)=>{const{__scopeSelect:o,...l}=n;return Aw(Dw,o).isSelected?h.jsx(De.span,{"aria-hidden":!0,...l,ref:r}):null});zw.displayName=Dw;var Xd="SelectScrollUpButton",kw=v.forwardRef((n,r)=>{const o=or(Xd,n.__scopeSelect),l=Xh(Xd,n.__scopeSelect),[s,c]=v.useState(!1),d=$e(r,l.onScrollButtonChange);return Nt(()=>{if(o.viewport&&o.isPositioned){let m=function(){const g=y.scrollTop>0;c(g)};const y=o.viewport;return m(),y.addEventListener("scroll",m),()=>y.removeEventListener("scroll",m)}},[o.viewport,o.isPositioned]),s?h.jsx(Uw,{...n,ref:d,onAutoScroll:()=>{const{viewport:m,selectedItem:y}=o;m&&y&&(m.scrollTop=m.scrollTop-y.offsetHeight)}}):null});kw.displayName=Xd;var Zd="SelectScrollDownButton",Lw=v.forwardRef((n,r)=>{const o=or(Zd,n.__scopeSelect),l=Xh(Zd,n.__scopeSelect),[s,c]=v.useState(!1),d=$e(r,l.onScrollButtonChange);return Nt(()=>{if(o.viewport&&o.isPositioned){let m=function(){const g=y.scrollHeight-y.clientHeight,b=Math.ceil(y.scrollTop)<g;c(b)};const y=o.viewport;return m(),y.addEventListener("scroll",m),()=>y.removeEventListener("scroll",m)}},[o.viewport,o.isPositioned]),s?h.jsx(Uw,{...n,ref:d,onAutoScroll:()=>{const{viewport:m,selectedItem:y}=o;m&&y&&(m.scrollTop=m.scrollTop+y.offsetHeight)}}):null});Lw.displayName=Zd;var Uw=v.forwardRef((n,r)=>{const{__scopeSelect:o,onAutoScroll:l,...s}=n,c=or("SelectScrollButton",o),d=v.useRef(null),m=Pu(o),y=v.useCallback(()=>{d.current!==null&&(window.clearInterval(d.current),d.current=null)},[]);return v.useEffect(()=>()=>y(),[y]),Nt(()=>{m().find(b=>b.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[m]),h.jsx(De.div,{"aria-hidden":!0,...s,ref:r,style:{flexShrink:0,...s.style},onPointerDown:he(s.onPointerDown,()=>{d.current===null&&(d.current=window.setInterval(l,50))}),onPointerMove:he(s.onPointerMove,()=>{c.onItemLeave?.(),d.current===null&&(d.current=window.setInterval(l,50))}),onPointerLeave:he(s.onPointerLeave,()=>{y()})})}),u3="SelectSeparator",c3=v.forwardRef((n,r)=>{const{__scopeSelect:o,...l}=n;return h.jsx(De.div,{"aria-hidden":!0,...l,ref:r})});c3.displayName=u3;var Jd="SelectArrow",f3=v.forwardRef((n,r)=>{const{__scopeSelect:o,...l}=n,s=qu(o),c=rr(Jd,o),d=or(Jd,o);return c.open&&d.position==="popper"?h.jsx(Hh,{...s,...l,ref:r}):null});f3.displayName=Jd;var d3="SelectBubbleInput",Hw=v.forwardRef(({__scopeSelect:n,value:r,...o},l)=>{const s=v.useRef(null),c=$e(l,s),d=$D(r);return v.useEffect(()=>{const m=s.current;if(!m)return;const y=window.HTMLSelectElement.prototype,b=Object.getOwnPropertyDescriptor(y,"value").set;if(d!==r&&b){const p=new Event("change",{bubbles:!0});b.call(m,r),m.dispatchEvent(p)}},[d,r]),h.jsx(De.select,{...o,style:{...pw,...o.style},ref:c,defaultValue:r})});Hw.displayName=d3;function Bw(n){return n===""||n===void 0}function Pw(n){const r=Fn(n),o=v.useRef(""),l=v.useRef(0),s=v.useCallback(d=>{const m=o.current+d;r(m),(function y(g){o.current=g,window.clearTimeout(l.current),g!==""&&(l.current=window.setTimeout(()=>y(""),1e3))})(m)},[r]),c=v.useCallback(()=>{o.current="",window.clearTimeout(l.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(l.current),[]),[o,s,c]}function qw(n,r,o){const s=r.length>1&&Array.from(r).every(g=>g===r[0])?r[0]:r,c=o?n.indexOf(o):-1;let d=h3(n,Math.max(c,0));s.length===1&&(d=d.filter(g=>g!==o));const y=d.find(g=>g.textValue.toLowerCase().startsWith(s.toLowerCase()));return y!==o?y:void 0}function h3(n,r){return n.map((o,l)=>n[(r+l)%n.length])}var m3=gw,p3=yw,g3=xw,v3=ww,y3=Sw,b3=Ew,x3=Tw,w3=Ow,S3=_w,E3=zw,C3=kw,R3=Lw;function Zh({...n}){return h.jsx(m3,{"data-slot":"select",...n})}function Jh({...n}){return h.jsx(g3,{"data-slot":"select-value",...n})}function Wh({className:n,size:r="default",children:o,...l}){return h.jsxs(p3,{"data-slot":"select-trigger","data-size":r,className:Fe("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...l,children:[o,h.jsx(v3,{asChild:!0,children:h.jsx(A0,{className:"size-4 opacity-50"})})]})}function em({className:n,children:r,position:o="popper",align:l="center",...s}){return h.jsx(y3,{children:h.jsxs(b3,{"data-slot":"select-content",className:Fe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:o,align:l,...s,children:[h.jsx(N3,{}),h.jsx(x3,{className:Fe("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),h.jsx(T3,{})]})})}function ol({className:n,children:r,...o}){return h.jsxs(w3,{"data-slot":"select-item",className:Fe("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",n),...o,children:[h.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:h.jsx(E3,{children:h.jsx(M0,{className:"size-4"})})}),h.jsx(S3,{children:r})]})}function N3({className:n,...r}){return h.jsx(C3,{"data-slot":"select-scroll-up-button",className:Fe("flex cursor-default items-center justify-center py-1",n),...r,children:h.jsx(jT,{className:"size-4"})})}function T3({className:n,...r}){return h.jsx(R3,{"data-slot":"select-scroll-down-button",className:Fe("flex cursor-default items-center justify-center py-1",n),...r,children:h.jsx(A0,{className:"size-4"})})}function j3({...n}){return h.jsx(wu,{"data-slot":"sheet",...n})}function M3({...n}){return h.jsx(Su,{"data-slot":"sheet-portal",...n})}function A3({className:n,...r}){return h.jsx(Eu,{className:Fe("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),"data-slot":"sheet-overlay",...r})}function O3({children:n,className:r,hideCloseButton:o,overlayClassName:l,side:s="right",...c}){const d={bottom:"inset-x-0 bottom-0 h-auto max-h-[90vh] border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom rounded-t-xl",left:"inset-y-0 left-0 h-full w-3/4 max-w-sm border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",right:"inset-y-0 right-0 h-full w-3/4 max-w-sm border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",top:"inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top"};return h.jsxs(M3,{children:[h.jsx(A3,{className:l}),h.jsxs(Cu,{className:Fe("fixed z-50 flex flex-col bg-background shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",d[s],r),"data-slot":"sheet-content",...c,children:[n,!o&&h.jsx(y0,{"aria-label":"Close",className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none min-h-11 min-w-11 flex items-center justify-center",children:h.jsx(D0,{className:"size-5"})})]})]})}function _3({className:n,...r}){return h.jsx(vh,{className:Fe("text-base font-semibold",n),"data-slot":"sheet-title",...r})}function D3({className:n,...r}){return h.jsx(LN,{className:Fe("text-sm text-muted-foreground",n),"data-slot":"sheet-description",...r})}async function z3(n){const r=n.length>0?`?path=${encodeURIComponent(n)}`:"",o=await fetch(`/api/filesystem/browse${r}`);if(!o.ok){let l=o.statusText;try{const s=await o.json();s.error?.message&&(l=s.error.message)}catch{}throw new Error(l)}return await o.json()}function $w({initialPath:n,onOpenChange:r,onSelect:o,open:l}){const[s,c]=v.useState(n??""),[d,m]=v.useState(n??"");v.useEffect(function(){if(l){const k=n??"";c(k),m(k)}},[n,l]);const{data:y,error:g,isLoading:b,isFetching:p,refetch:w}=St({enabled:l,queryKey:["filesystem","browse",s],queryFn:()=>z3(s)});v.useEffect(function(){y&&m(y.path)},[y]);function C(O){c(O),m(O)}function R(){s.length!==0&&(o(s),r(!1))}const S=!!(y&&y.parent!==null),N=s.length===0,j=g instanceof Error?g.message:g?String(g):null;return h.jsx(j3,{onOpenChange:r,open:l,children:h.jsxs(O3,{className:"flex w-full max-w-lg flex-col gap-0 p-0",side:"right",children:[h.jsxs("div",{className:"border-b p-4",children:[h.jsx(_3,{children:"Browse folders"}),h.jsx(D3,{children:"Pick a folder on the Jukebox server."})]}),h.jsxs("div",{className:"flex items-center gap-2 border-b p-4",children:[h.jsx(Ie,{"aria-label":"Go up one folder",disabled:!S,onClick:()=>{y?.parent?C(y.parent):N||C("")},size:"icon-sm",type:"button",variant:"outline",children:h.jsx(CT,{className:"size-4"})}),h.jsx(va,{className:"flex-1 font-mono text-sm",onChange:O=>m(O.target.value),onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),C(d.trim()))},placeholder:"Type a path and press Enter, or pick a root below",spellCheck:!1,value:d}),h.jsx(Ie,{"aria-label":"Refresh",onClick:()=>{w()},size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(XT,{className:`size-4 ${p?"animate-spin":""}`})})]}),h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:b?h.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:"Loading…"}):j?h.jsxs("div",{className:"flex flex-col items-start gap-2 p-3",children:[h.jsx("p",{className:"text-sm text-destructive",children:j}),h.jsx(Ie,{onClick:()=>{w()},size:"sm",type:"button",variant:"outline",children:"Try again"})]}):y&&y.entries.length===0?h.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:"No subfolders here."}):h.jsx("ul",{className:"space-y-0.5",children:y?.entries.map(O=>h.jsx("li",{children:h.jsxs("button",{className:"flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm hover:bg-accent",onClick:()=>C(O.path),type:"button",children:[h.jsx(PT,{className:"size-4 shrink-0 text-muted-foreground"}),h.jsx("span",{className:"truncate",children:O.name})]})},O.path))})}),h.jsxs("div",{className:"flex items-center justify-end gap-2 border-t p-4",children:[h.jsx(Ie,{onClick:()=>r(!1),type:"button",variant:"ghost",children:"Cancel"}),h.jsx(Ie,{disabled:N,onClick:R,type:"button",children:"Select this folder"})]})]})})}async function tm(n){try{return(await n.json()).error?.message??n.statusText}catch{return n.statusText}}async function Vw(n){const r=await fetch(n);if(!r.ok)throw new Error(await tm(r));return await r.json()}function k3(){return St({queryKey:["settings","libraries"],queryFn:()=>Vw("/api/settings/libraries")})}function L3(){const n=Dt();return wn({mutationFn:async r=>{const o=await fetch("/api/settings/libraries",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw new Error(await tm(o));return await o.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["settings","libraries"]})}})}function U3(){const n=Dt();return wn({mutationFn:async r=>{const o=r.force===!0?"?force=true":"",l=await fetch(`/api/settings/libraries/${r.id}${o}`,{method:"DELETE"});if(!l.ok){let s,c=l.statusText;try{const m=await l.json();c=m.error?.message??c,s=m.error?.referenceCount}catch{}throw Object.assign(new Error(c),{referenceCount:s,status:l.status})}},onSuccess:()=>{n.invalidateQueries({queryKey:["settings","libraries"]})}})}function H3(){return St({queryKey:["settings","scan-schedule"],queryFn:()=>Vw("/api/settings/scan-schedule")})}function B3(){const n=Dt();return wn({mutationFn:async r=>{const o=await fetch("/api/settings/scan-schedule",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({schedule:r})});if(!o.ok)throw new Error(await tm(o));return await o.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["settings","scan-schedule"]})}})}const ub={name:"",path:"",type:"movies"};function P3(){const{data:n,isLoading:r}=k3(),o=L3(),l=U3(),[s,c]=v.useState(ub),[d,m]=v.useState(!1);async function y(){const b=s.path.trim();if(b.length===0){Ze.error("Enter a folder path before adding a library.");return}const p={name:s.name.trim(),path:b,type:s.type};try{await o.mutateAsync(p),c(ub),Ze.success("Library added.")}catch(w){Ze.error(w instanceof Error?w.message:"Couldn't add library.")}}async function g(b){if(window.confirm(`Remove library "${b.name}" (${b.path})? Scanned items in this folder will be kept until you run a scan.`))try{await l.mutateAsync({id:b.id}),Ze.success(`Removed ${b.name}.`)}catch(w){const C=w;if(C.status===409){if(!window.confirm(`${C.message}
57
57
 
58
- Force remove will also delete all scanned items in this folder from Jukebox (files on disk are not touched). Continue?`))return;try{await l.mutateAsync({id:b.id,force:!0}),Ze.success(`Removed ${b.name} and its scanned items.`)}catch(S){Ze.error(S instanceof Error?S.message:"Couldn't force remove library.")}return}Ze.error(w instanceof Error?w.message:"Couldn't remove library.")}}return h.jsxs(Ho,{children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Libraries"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Folders Jukebox scans for movies and TV shows."})]}),h.jsx("div",{className:"mt-6 space-y-2",children:r?h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):n&&n.length>0?n.map(b=>h.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-4",children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate font-medium",children:b.name}),h.jsx("p",{className:"truncate text-sm text-muted-foreground",children:b.path})]}),h.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:b.type==="movies"?"Movies":"Shows"}),h.jsx(Ie,{"aria-label":`Remove ${b.name}`,disabled:l.isPending,onClick:()=>{g(b)},size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(xh,{className:"size-4"})})]},b.id)):h.jsx("p",{className:"text-sm text-muted-foreground",children:"No libraries yet. Add one below to start scanning."})}),h.jsxs("div",{className:"mt-8 rounded-lg border bg-card p-4",children:[h.jsx("h3",{className:"text-sm font-semibold",children:"Add a library"}),h.jsxs("div",{className:"mt-4 grid gap-3",children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"new-library-path",children:"Folder path"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(va,{className:"flex-1",id:"new-library-path",onChange:b=>c(p=>({...p,path:b.target.value})),placeholder:"/mnt/media/movies",spellCheck:!1,value:s.path}),h.jsxs(Ie,{onClick:()=>m(!0),type:"button",variant:"outline",children:[h.jsx(O0,{className:"size-4"}),"Browse"]})]})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsxs(Za,{htmlFor:"new-library-name",children:["Name"," ",h.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),h.jsx(va,{id:"new-library-name",onChange:b=>c(p=>({...p,name:b.target.value})),placeholder:"Leave blank to use the folder name",value:s.name})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"new-library-type",children:"Type"}),h.jsxs(Zh,{onValueChange:b=>c(p=>({...p,type:b==="shows"?"shows":"movies"})),value:s.type,children:[h.jsx(Wh,{className:"w-40",id:"new-library-type",children:h.jsx(Jh,{})}),h.jsxs(em,{children:[h.jsx(ol,{value:"movies",children:"Movies"}),h.jsx(ol,{value:"shows",children:"Shows"})]})]})]}),h.jsx("div",{children:h.jsxs(Ie,{disabled:o.isPending||s.path.trim().length===0,onClick:()=>{y()},type:"button",children:[h.jsx(nu,{className:"size-4"}),o.isPending?"Adding…":"Add library"]})})]})]}),d&&h.jsx($w,{initialPath:s.path.trim()||void 0,onOpenChange:m,onSelect:b=>c(p=>({...p,path:b})),open:d})]})}const jd=["🍿","🎬","🎥","📺","🎞️","🎭","🚀","🌟","🌈","🔥","🌙","🌊","🐱","🐶","🦊","🦁","🐼","🐧","🦄","🐙","🍕","🍣","🍩","🍔","🎮","🎸","⚽","🏀","⛺","🏝️"];function q3({initialValues:n,onOpenChange:r,onSubmit:o,open:l,submitting:s,title:c}){const[d,m]=v.useState(n?.name??""),[y,g]=v.useState(n?.emoji??jd[0]);v.useEffect(function(){l&&(m(n?.name??""),g(n?.emoji??jd[0]))},[n?.emoji,n?.name,l]);function b(p){p.preventDefault();const w=d.trim();w&&Promise.resolve(o({name:w,emoji:y}))}return h.jsx(wu,{onOpenChange:r,open:l,children:h.jsxs(Su,{children:[h.jsx(Eu,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),h.jsxs(Cu,{className:"fixed left-[50%] top-[50%] z-50 grid w-full max-w-md translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg",children:[h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsx(vh,{className:"text-lg font-semibold",children:c}),h.jsx(y0,{"aria-label":"Close",className:"rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none",children:h.jsx(D0,{className:"size-4"})})]}),h.jsxs("form",{className:"grid gap-4",onSubmit:b,children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsx("label",{className:"text-sm font-medium",htmlFor:"profile-name",children:"Name"}),h.jsx(va,{autoFocus:!0,id:"profile-name",maxLength:40,onChange:p=>m(p.target.value),placeholder:"e.g. Ada",value:d})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsx("span",{className:"text-sm font-medium",children:"Emoji"}),h.jsx("div",{className:"grid grid-cols-6 gap-2",children:jd.map(p=>{const w=p===y;return h.jsx("button",{"aria-pressed":w,className:Fe("flex size-10 items-center justify-center rounded-md border text-xl transition-colors",w?"border-primary bg-primary/10":"border-border hover:bg-accent"),onClick:()=>g(p),type:"button",children:h.jsx("span",{"aria-hidden":!0,children:p})},p)})})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[h.jsx(Ie,{onClick:()=>r(!1),type:"button",variant:"ghost",children:"Cancel"}),h.jsx(Ie,{disabled:(s??!1)||!d.trim(),type:"submit",children:"Save"})]})]})]})]})})}function $3(){const{data:n,isLoading:r}=tw(),o=__(),l=D_(),s=z_(),[c,d]=v.useState({kind:"closed"});function m(){d({kind:"closed"})}async function y(p){try{c.kind==="create"?(await o.mutateAsync(p),Ze.success(`Created ${p.name}`)):c.kind==="edit"&&(await l.mutateAsync({id:c.profile.id,...p}),Ze.success(`Updated ${p.name}`)),m()}catch(w){Ze.error(w instanceof Error?w.message:"Failed to save")}}async function g(p){if(window.confirm(`Delete profile "${p.name}"? Their watch progress and favorites will be removed.`))try{await s.mutateAsync(p.id),Ze.success(`Deleted ${p.name}`)}catch(C){Ze.error(C instanceof Error?C.message:"Failed to delete")}}const b=(n?.length??0)>1;return h.jsxs(Ho,{children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Profiles"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Each profile has its own watch progress and favorites."})]}),h.jsxs(Ie,{onClick:()=>d({kind:"create"}),type:"button",children:[h.jsx(nu,{className:"size-4"}),"Add profile"]})]}),h.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:r?h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):n?.map(p=>h.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-4",children:[h.jsx("span",{"aria-hidden":!0,className:"flex size-12 items-center justify-center rounded-full bg-muted text-2xl",children:p.emoji}),h.jsx("div",{className:"flex-1 truncate",children:h.jsx("p",{className:"truncate font-medium",children:p.name})}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Ie,{"aria-label":`Edit ${p.name}`,onClick:()=>d({kind:"edit",profile:p}),size:"icon",type:"button",variant:"ghost",children:h.jsx(GT,{className:"size-4"})}),h.jsx(Ie,{"aria-label":`Delete ${p.name}`,disabled:!b,onClick:()=>{g(p)},size:"icon",type:"button",variant:"ghost",children:h.jsx(xh,{className:"size-4"})})]})]},p.id))}),h.jsx(q3,{initialValues:c.kind==="edit"?{name:c.profile.name,emoji:c.profile.emoji}:void 0,onOpenChange:p=>{p||m()},onSubmit:y,open:c.kind!=="closed",submitting:o.isPending||l.isPending,title:c.kind==="edit"?"Edit profile":"New profile"})]})}kr.extend(Yh);const cb={off:"Off","6h":"Every 6 hours","12h":"Every 12 hours","24h":"Daily"};function V3(){const{data:n,isLoading:r}=H3(),o=B3(),[l,s]=v.useState("off"),[c,d]=v.useState(!1);v.useEffect(function(){!c&&n&&(s(n.schedule),d(!0))},[n,c]);async function m(){try{await o.mutateAsync(l),Ze.success("Scan schedule saved.")}catch(y){Ze.error(y instanceof Error?y.message:"Couldn't save scan schedule.")}}return r?h.jsx(Ho,{children:h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})}):h.jsxs(Ho,{children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Scan schedule"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"How often Jukebox should automatically scan your libraries for new files."})]}),h.jsxs("div",{className:"mt-6 grid max-w-md gap-4",children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"scan-schedule",children:"Frequency"}),h.jsxs(Zh,{onValueChange:y=>s(y),value:l,children:[h.jsx(Wh,{className:"w-full",id:"scan-schedule",children:h.jsx(Jh,{})}),h.jsx(em,{children:Object.keys(cb).map(y=>h.jsx(ol,{value:y,children:cb[y]},y))})]})]}),h.jsx("p",{className:"text-xs text-muted-foreground",children:l==="off"?"Automatic scans are off. Trigger scans manually from the Scan page.":n?.nextRunAt?`Next scheduled scan ${kr(n.nextRunAt).fromNow()}.`:"Schedule will start on the next server boot."}),h.jsx("div",{children:h.jsx(Ie,{disabled:o.isPending,onClick:()=>{m()},type:"button",children:o.isPending?"Saving…":"Save schedule"})})]})]})}function F3({addButtonLabel:n,emptyButtonLabel:r,onChange:o,value:l}){const[s,c]=v.useState(null),[d,m]=v.useState(null),y=v.useRef(null);v.useEffect(function(){s!==null&&y.current?.focus()},[s]);function g(){const C=l.length;o([...l,{name:"",path:"",type:"movies"}]),c(C)}function b(C){o(l.filter((R,S)=>S!==C)),s===C&&c(null)}function p(C,R,S){o(l.map((N,j)=>j===C?{...N,[R]:S}:N))}function w(C){const R=l[C];R&&R.path.trim()===""&&b(C),c(null)}return l.length===0?h.jsxs("button",{className:"flex w-full items-center justify-center rounded-lg border border-dashed border-border py-10 text-sm text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground",onClick:g,type:"button",children:[h.jsx(nu,{className:"mr-2 size-4"}),r??"Add a folder"]}):h.jsxs("div",{className:"space-y-2",children:[l.map((C,R)=>h.jsxs("div",{className:"flex items-center gap-3",children:[s===R?h.jsx(va,{ref:y,className:"flex-[2]",onBlur:()=>w(R),onChange:S=>p(R,"path",S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),y.current?.blur())},placeholder:"/mnt/media/movies",value:C.path}):h.jsx("button",{className:"flex-[2] cursor-pointer truncate rounded-md px-3 py-2 text-left text-sm text-foreground hover:bg-accent",onClick:()=>c(R),type:"button",children:C.path||h.jsx("span",{className:"text-muted-foreground",children:"/mnt/media/movies"})}),h.jsx(Ie,{"aria-label":"Browse folders",onClick:()=>m(R),size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(O0,{className:"size-4"})}),h.jsxs(Zh,{onValueChange:S=>p(R,"type",S),value:C.type,children:[h.jsx(Wh,{className:"w-28",children:h.jsx(Jh,{})}),h.jsxs(em,{children:[h.jsx(ol,{value:"movies",children:"Movies"}),h.jsx(ol,{value:"shows",children:"Shows"})]})]}),h.jsx(Ie,{"aria-label":"Remove library",onClick:()=>b(R),size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(xh,{className:"size-4"})})]},R)),h.jsxs(Ie,{className:"mt-1",onClick:g,size:"sm",type:"button",variant:"ghost",children:[h.jsx(nu,{className:"size-4"}),n??"Add another"]}),d!==null&&h.jsx($w,{initialPath:l[d]?.path,onOpenChange:C=>{C||m(null)},onSelect:C=>{p(d,"path",C)},open:d!==null})]})}function G3(){const n=Vo(),[r,o]=v.useState([]),[l,s]=v.useState(!1),[c,d]=v.useState(!1);v.useEffect(()=>{m()},[]);async function m(){try{const g=await fetch("/api/setup");if(!g.ok)return;const b=await g.json();b.libraries.length>0&&o(b.libraries.map(p=>({name:p.name,path:p.path,type:p.type})))}finally{s(!0)}}async function y(g){g.preventDefault();const b=r.filter(p=>p.path.trim()!=="");if(b.length===0){Ze.error("Please add at least one library.");return}d(!0);try{const p=b.map(C=>({name:C.name.trim()||(C.path.split(/[\\/]/).pop()??C.type),path:C.path.trim(),type:C.type})),w=await fetch("/api/setup/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({libraries:p})});if(!w.ok){const C=await w.json();throw new Error(C.error?.message??"Setup failed")}n("/scan")}catch(p){Ze.error(p instanceof Error?p.message:"Setup failed")}finally{d(!1)}}return l?h.jsx("div",{className:"flex min-h-screen items-start justify-center px-6 pt-[15vh] pb-16",children:h.jsxs("div",{className:"w-full max-w-lg",children:[h.jsxs("div",{className:"mb-16 animate-fade-up",children:[h.jsx("h1",{className:"text-4xl font-bold tracking-tight text-foreground",children:"Set up your library"}),h.jsx("p",{className:"mt-3 text-muted-foreground",children:"Add your media folders and we'll take care of the rest."})]}),h.jsx("form",{onSubmit:g=>{y(g)},children:h.jsxs("div",{className:"space-y-16",children:[h.jsxs("section",{className:"animate-fade-up animate-delay-1",children:[h.jsx("h2",{className:"text-sm font-medium uppercase tracking-widest text-muted-foreground",children:"Libraries"}),h.jsx("div",{className:"mt-6",children:h.jsx(F3,{onChange:o,value:r})})]}),h.jsx("div",{className:"animate-fade-up animate-delay-2",children:h.jsx("div",{className:"flex justify-end",children:h.jsx(Ie,{disabled:c,size:"lg",type:"submit",children:c?"Setting up...":"Complete Setup"})})})]})})]})}):null}async function Y3(n){const r=await fetch(`/api/library/shows/${n}`);if(!r.ok)throw new Error("Failed to fetch show");return await r.json()}function I3(n){return St({queryKey:["show",n],queryFn:()=>Y3(n??""),enabled:!!n})}async function Q3(n){const r=await fetch(`/api/progress/episode/show/${n}`);if(!r.ok)throw new Error("Failed to fetch show progress");return await r.json()}function K3(n){if(n===null)return"";if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;return o>0?`${r}h ${o}m`:`${r}h`}function X3(n){return!n||!n.duration?0:Math.min(n.currentTime/n.duration*100,100)}function Z3(n){return!n||!n.duration?!1:n.currentTime>=n.duration*.9}function J3(){const{id:n}=zC(),r=Vo(),{data:o,isLoading:l,error:s}=I3(n),c=o?.id,{data:d}=St({queryKey:["show-progress",c],queryFn:()=>Q3(c??0),enabled:!!c}),m=v.useMemo(()=>{if(!d||!o)return null;let R=null,S="";for(const[N,j]of Object.entries(d)){const O=parseInt(N,10);j.duration&&j.currentTime<j.duration*.9&&(!S||j.updatedAt>S)&&(S=j.updatedAt,R=O)}if(R===null)return null;for(const N of o.seasons)for(const j of N.episodes)if(j.id===R)return N.seasonNumber;return null},[d,o]),[y,g]=v.useState(null);v.useEffect(()=>{if(y!==null||!o)return;if(m!==null){g(m);return}const R=o.seasons[0]?.seasonNumber??1;g(R)},[o,m,y]);function b(R){r(`/watch/episode/${R.id}`)}if(l)return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:h.jsx(Tu,{className:"size-8 animate-spin text-muted-foreground"})})]});if(s||!o)return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4",children:[h.jsx("p",{className:"text-foreground",children:"Show not found"}),h.jsx(Ie,{asChild:!0,variant:"outline",children:h.jsx(xn,{to:"/shows",children:"Back to Shows"})})]})]});const p=o.seasons.find(R=>R.seasonNumber===y)??o.seasons[0],w=o.genres?o.genres.split(",").map(R=>R.trim()):[],C=o.seasons.length;return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"px-4 pt-4 pb-12 sm:px-6 sm:pt-6",children:[h.jsxs("div",{className:"flex flex-col gap-4 mb-8 sm:flex-row sm:gap-6",children:[h.jsx("div",{className:"flex-shrink-0 w-28 sm:w-40",children:h.jsx(dl,{alt:o.title,className:"w-full rounded-lg",url:o.posterUrl,title:o.title})}),h.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[h.jsx("h1",{className:"text-xl font-bold text-foreground sm:text-2xl",children:o.title}),h.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground",children:[o.year&&h.jsx("span",{children:o.year}),o.rating&&h.jsxs("span",{children:[o.rating.toFixed(1)," rating"]}),h.jsxs("span",{children:[C," ",C===1?"season":"seasons"]}),w.length>0&&h.jsx("span",{children:w.join(", ")})]}),o.overview&&h.jsx("p",{className:"text-sm text-muted-foreground max-w-2xl leading-relaxed",children:o.overview})]})]}),h.jsx("div",{className:"flex flex-wrap gap-2 mb-6",children:o.seasons.map(R=>h.jsx("button",{className:`cursor-pointer rounded-md px-4 min-h-11 text-sm font-medium transition-colors ${R.seasonNumber===y?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"}`,onClick:()=>g(R.seasonNumber),type:"button",children:R.name??`Season ${R.seasonNumber}`},R.id))}),p&&h.jsx("div",{className:"flex flex-col gap-1",children:p.episodes.map(R=>{const S=K3(R.runtime),N=d?.[R.id],j=X3(N),O=Z3(N),k=j>0&&!O;return h.jsxs("div",{className:"group flex items-start gap-4 rounded-lg px-3 py-3 cursor-pointer hover:bg-muted transition-colors",onClick:()=>b(R),children:[h.jsx("div",{className:"flex-shrink-0 w-10 text-right text-sm text-muted-foreground pt-0.5",children:R.episodeNumber}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`font-medium ${O?"text-muted-foreground":"text-foreground"}`,children:R.title}),S&&h.jsx("span",{className:"text-xs text-muted-foreground",children:S}),O&&h.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Watched"})]}),R.overview&&h.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:R.overview}),k&&h.jsx("div",{className:"mt-2 h-1 w-full max-w-xs rounded-full bg-muted",children:h.jsx("div",{className:"h-full rounded-full bg-red-600 transition-all",style:{width:`${j}%`}})})]}),h.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity pt-0.5",children:h.jsx(IT,{className:"size-4 text-foreground"})})]},R.id)})})]})]})}function W3(){const{data:n,isLoading:r}=hw(),o=v.useMemo(()=>n?n.map(s=>({type:"show",item:s})):[],[n]),l=v.useMemo(()=>o.length===0?[]:Kh(o),[o]);return r?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"pt-4",children:[h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{})]})]}):o.length===0?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4 text-center px-6",children:[h.jsx(Nu,{className:"size-16 text-muted-foreground"}),h.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"No shows in your library"}),h.jsxs("p",{className:"text-sm text-muted-foreground max-w-md",children:["Run"," ",h.jsx("code",{className:"bg-muted px-2 py-1 rounded text-xs font-mono",children:"bun run scan --shows /path/to/shows"})," ","to add your collection."]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsx("div",{className:"pt-2 pb-8",children:l.map(({genre:s,items:c})=>h.jsx(el,{items:c,title:s},s))})]})}const fb=v.lazy(()=>db(()=>import("./Watch-DE2orFm6.js"),__vite__mapDeps([0,1])).then(n=>({default:n.WatchPage}))),e4=new UE;tR({immediate:!0});function t4(){const{data:n,isLoading:r}=Eh();return r?null:n?.enabled&&!n.authenticated?h.jsx(pu,{to:"/login",replace:!0}):h.jsx(rM,{children:h.jsx(Bb,{})})}function n4(){const{data:n,isLoading:r}=dM();return r?null:n?.needsSetup?h.jsx(pu,{to:"/setup",replace:!0}):h.jsx(Bb,{})}const Fw=document.getElementById("root");if(!Fw)throw new Error("Root element not found");const a4=h.jsx(v.StrictMode,{children:h.jsxs(HE,{client:e4,children:[h.jsx(b2,{children:h.jsxs(KC,{children:[h.jsx(wt,{path:"/login",element:h.jsx(TD,{})}),h.jsxs(wt,{element:h.jsx(t4,{}),children:[h.jsx(wt,{path:"/scan",element:h.jsx(_D,{})}),h.jsx(wt,{path:"/setup",element:h.jsx(G3,{})}),h.jsxs(wt,{element:h.jsx(n4,{}),children:[h.jsx(wt,{path:"/",element:h.jsx(SD,{})}),h.jsx(wt,{path:"/movies",element:h.jsx(jD,{})}),h.jsx(wt,{path:"/shows",element:h.jsx(W3,{})}),h.jsx(wt,{path:"/shows/:id",element:h.jsx(J3,{})}),h.jsx(wt,{path:"/settings",element:h.jsx(pu,{to:"/settings/profiles",replace:!0})}),h.jsx(wt,{path:"/settings/profiles",element:h.jsx($3,{})}),h.jsx(wt,{path:"/settings/libraries",element:h.jsx(P3,{})}),h.jsx(wt,{path:"/settings/scan-schedule",element:h.jsx(V3,{})}),h.jsx(wt,{path:"/settings/auth",element:h.jsx(kD,{})}),h.jsx(wt,{path:"/watch/:id",element:h.jsx(v.Suspense,{children:h.jsx(fb,{})})}),h.jsx(wt,{path:"/watch/episode/:id",element:h.jsx(v.Suspense,{children:h.jsx(fb,{})})})]})]})]})}),h.jsx(eR,{position:"bottom-right",theme:"dark"})]})});hE.createRoot(Fw).render(a4);export{ST as A,Ie as B,T_ as C,Rd as I,Tu as L,IT as P,C_ as R,j3 as S,R_ as T,D0 as X,r4 as a,o4 as b,Qe as c,N_ as d,Fe as e,M0 as f,hu as g,dl as h,zC as i,h as j,tr as k,Vo as l,xn as m,O3 as n,_3 as o,i4 as p,v as r,Ze as t,St as u};
58
+ Force remove will also delete all scanned items in this folder from Jukebox (files on disk are not touched). Continue?`))return;try{await l.mutateAsync({id:b.id,force:!0}),Ze.success(`Removed ${b.name} and its scanned items.`)}catch(S){Ze.error(S instanceof Error?S.message:"Couldn't force remove library.")}return}Ze.error(w instanceof Error?w.message:"Couldn't remove library.")}}return h.jsxs(Ho,{children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Libraries"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Folders Jukebox scans for movies and TV shows."})]}),h.jsx("div",{className:"mt-6 space-y-2",children:r?h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):n&&n.length>0?n.map(b=>h.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-4",children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate font-medium",children:b.name}),h.jsx("p",{className:"truncate text-sm text-muted-foreground",children:b.path})]}),h.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:b.type==="movies"?"Movies":"Shows"}),h.jsx(Ie,{"aria-label":`Remove ${b.name}`,disabled:l.isPending,onClick:()=>{g(b)},size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(xh,{className:"size-4"})})]},b.id)):h.jsx("p",{className:"text-sm text-muted-foreground",children:"No libraries yet. Add one below to start scanning."})}),h.jsxs("div",{className:"mt-8 rounded-lg border bg-card p-4",children:[h.jsx("h3",{className:"text-sm font-semibold",children:"Add a library"}),h.jsxs("div",{className:"mt-4 grid gap-3",children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"new-library-path",children:"Folder path"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(va,{className:"flex-1",id:"new-library-path",onChange:b=>c(p=>({...p,path:b.target.value})),placeholder:"/mnt/media/movies",spellCheck:!1,value:s.path}),h.jsxs(Ie,{onClick:()=>m(!0),type:"button",variant:"outline",children:[h.jsx(O0,{className:"size-4"}),"Browse"]})]})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsxs(Za,{htmlFor:"new-library-name",children:["Name"," ",h.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),h.jsx(va,{id:"new-library-name",onChange:b=>c(p=>({...p,name:b.target.value})),placeholder:"Leave blank to use the folder name",value:s.name})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"new-library-type",children:"Type"}),h.jsxs(Zh,{onValueChange:b=>c(p=>({...p,type:b==="shows"?"shows":"movies"})),value:s.type,children:[h.jsx(Wh,{className:"w-40",id:"new-library-type",children:h.jsx(Jh,{})}),h.jsxs(em,{children:[h.jsx(ol,{value:"movies",children:"Movies"}),h.jsx(ol,{value:"shows",children:"Shows"})]})]})]}),h.jsx("div",{children:h.jsxs(Ie,{disabled:o.isPending||s.path.trim().length===0,onClick:()=>{y()},type:"button",children:[h.jsx(nu,{className:"size-4"}),o.isPending?"Adding…":"Add library"]})})]})]}),d&&h.jsx($w,{initialPath:s.path.trim()||void 0,onOpenChange:m,onSelect:b=>c(p=>({...p,path:b})),open:d})]})}const jd=["🍿","🎬","🎥","📺","🎞️","🎭","🚀","🌟","🌈","🔥","🌙","🌊","🐱","🐶","🦊","🦁","🐼","🐧","🦄","🐙","🍕","🍣","🍩","🍔","🎮","🎸","⚽","🏀","⛺","🏝️"];function q3({initialValues:n,onOpenChange:r,onSubmit:o,open:l,submitting:s,title:c}){const[d,m]=v.useState(n?.name??""),[y,g]=v.useState(n?.emoji??jd[0]);v.useEffect(function(){l&&(m(n?.name??""),g(n?.emoji??jd[0]))},[n?.emoji,n?.name,l]);function b(p){p.preventDefault();const w=d.trim();w&&Promise.resolve(o({name:w,emoji:y}))}return h.jsx(wu,{onOpenChange:r,open:l,children:h.jsxs(Su,{children:[h.jsx(Eu,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),h.jsxs(Cu,{className:"fixed left-[50%] top-[50%] z-50 grid w-full max-w-md translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg",children:[h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsx(vh,{className:"text-lg font-semibold",children:c}),h.jsx(y0,{"aria-label":"Close",className:"rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none",children:h.jsx(D0,{className:"size-4"})})]}),h.jsxs("form",{className:"grid gap-4",onSubmit:b,children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsx("label",{className:"text-sm font-medium",htmlFor:"profile-name",children:"Name"}),h.jsx(va,{autoFocus:!0,id:"profile-name",maxLength:40,onChange:p=>m(p.target.value),placeholder:"e.g. Ada",value:d})]}),h.jsxs("div",{className:"grid gap-2",children:[h.jsx("span",{className:"text-sm font-medium",children:"Emoji"}),h.jsx("div",{className:"grid grid-cols-6 gap-2",children:jd.map(p=>{const w=p===y;return h.jsx("button",{"aria-pressed":w,className:Fe("flex size-10 items-center justify-center rounded-md border text-xl transition-colors",w?"border-primary bg-primary/10":"border-border hover:bg-accent"),onClick:()=>g(p),type:"button",children:h.jsx("span",{"aria-hidden":!0,children:p})},p)})})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[h.jsx(Ie,{onClick:()=>r(!1),type:"button",variant:"ghost",children:"Cancel"}),h.jsx(Ie,{disabled:(s??!1)||!d.trim(),type:"submit",children:"Save"})]})]})]})]})})}function $3(){const{data:n,isLoading:r}=tw(),o=__(),l=D_(),s=z_(),[c,d]=v.useState({kind:"closed"});function m(){d({kind:"closed"})}async function y(p){try{c.kind==="create"?(await o.mutateAsync(p),Ze.success(`Created ${p.name}`)):c.kind==="edit"&&(await l.mutateAsync({id:c.profile.id,...p}),Ze.success(`Updated ${p.name}`)),m()}catch(w){Ze.error(w instanceof Error?w.message:"Failed to save")}}async function g(p){if(window.confirm(`Delete profile "${p.name}"? Their watch progress and favorites will be removed.`))try{await s.mutateAsync(p.id),Ze.success(`Deleted ${p.name}`)}catch(C){Ze.error(C instanceof Error?C.message:"Failed to delete")}}const b=(n?.length??0)>1;return h.jsxs(Ho,{children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Profiles"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Each profile has its own watch progress and favorites."})]}),h.jsxs(Ie,{onClick:()=>d({kind:"create"}),type:"button",children:[h.jsx(nu,{className:"size-4"}),"Add profile"]})]}),h.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:r?h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):n?.map(p=>h.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-4",children:[h.jsx("span",{"aria-hidden":!0,className:"flex size-12 items-center justify-center rounded-full bg-muted text-2xl",children:p.emoji}),h.jsx("div",{className:"flex-1 truncate",children:h.jsx("p",{className:"truncate font-medium",children:p.name})}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Ie,{"aria-label":`Edit ${p.name}`,onClick:()=>d({kind:"edit",profile:p}),size:"icon",type:"button",variant:"ghost",children:h.jsx(GT,{className:"size-4"})}),h.jsx(Ie,{"aria-label":`Delete ${p.name}`,disabled:!b,onClick:()=>{g(p)},size:"icon",type:"button",variant:"ghost",children:h.jsx(xh,{className:"size-4"})})]})]},p.id))}),h.jsx(q3,{initialValues:c.kind==="edit"?{name:c.profile.name,emoji:c.profile.emoji}:void 0,onOpenChange:p=>{p||m()},onSubmit:y,open:c.kind!=="closed",submitting:o.isPending||l.isPending,title:c.kind==="edit"?"Edit profile":"New profile"})]})}kr.extend(Yh);const cb={off:"Off","6h":"Every 6 hours","12h":"Every 12 hours","24h":"Daily"};function V3(){const{data:n,isLoading:r}=H3(),o=B3(),[l,s]=v.useState("off"),[c,d]=v.useState(!1);v.useEffect(function(){!c&&n&&(s(n.schedule),d(!0))},[n,c]);async function m(){try{await o.mutateAsync(l),Ze.success("Scan schedule saved.")}catch(y){Ze.error(y instanceof Error?y.message:"Couldn't save scan schedule.")}}return r?h.jsx(Ho,{children:h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})}):h.jsxs(Ho,{children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold",children:"Scan schedule"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"How often Jukebox should automatically scan your libraries for new files."})]}),h.jsxs("div",{className:"mt-6 grid max-w-md gap-4",children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsx(Za,{htmlFor:"scan-schedule",children:"Frequency"}),h.jsxs(Zh,{onValueChange:y=>s(y),value:l,children:[h.jsx(Wh,{className:"w-full",id:"scan-schedule",children:h.jsx(Jh,{})}),h.jsx(em,{children:Object.keys(cb).map(y=>h.jsx(ol,{value:y,children:cb[y]},y))})]})]}),h.jsx("p",{className:"text-xs text-muted-foreground",children:l==="off"?"Automatic scans are off. Trigger scans manually from the Scan page.":n?.nextRunAt?`Next scheduled scan ${kr(n.nextRunAt).fromNow()}.`:"Schedule will start on the next server boot."}),h.jsx("div",{children:h.jsx(Ie,{disabled:o.isPending,onClick:()=>{m()},type:"button",children:o.isPending?"Saving…":"Save schedule"})})]})]})}function F3({addButtonLabel:n,emptyButtonLabel:r,onChange:o,value:l}){const[s,c]=v.useState(null),[d,m]=v.useState(null),y=v.useRef(null);v.useEffect(function(){s!==null&&y.current?.focus()},[s]);function g(){const C=l.length;o([...l,{name:"",path:"",type:"movies"}]),c(C)}function b(C){o(l.filter((R,S)=>S!==C)),s===C&&c(null)}function p(C,R,S){o(l.map((N,j)=>j===C?{...N,[R]:S}:N))}function w(C){const R=l[C];R&&R.path.trim()===""&&b(C),c(null)}return l.length===0?h.jsxs("button",{className:"flex w-full items-center justify-center rounded-lg border border-dashed border-border py-10 text-sm text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground",onClick:g,type:"button",children:[h.jsx(nu,{className:"mr-2 size-4"}),r??"Add a folder"]}):h.jsxs("div",{className:"space-y-2",children:[l.map((C,R)=>h.jsxs("div",{className:"flex items-center gap-3",children:[s===R?h.jsx(va,{ref:y,className:"flex-[2]",onBlur:()=>w(R),onChange:S=>p(R,"path",S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),y.current?.blur())},placeholder:"/mnt/media/movies",value:C.path}):h.jsx("button",{className:"flex-[2] cursor-pointer truncate rounded-md px-3 py-2 text-left text-sm text-foreground hover:bg-accent",onClick:()=>c(R),type:"button",children:C.path||h.jsx("span",{className:"text-muted-foreground",children:"/mnt/media/movies"})}),h.jsx(Ie,{"aria-label":"Browse folders",onClick:()=>m(R),size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(O0,{className:"size-4"})}),h.jsxs(Zh,{onValueChange:S=>p(R,"type",S),value:C.type,children:[h.jsx(Wh,{className:"w-28",children:h.jsx(Jh,{})}),h.jsxs(em,{children:[h.jsx(ol,{value:"movies",children:"Movies"}),h.jsx(ol,{value:"shows",children:"Shows"})]})]}),h.jsx(Ie,{"aria-label":"Remove library",onClick:()=>b(R),size:"icon-sm",type:"button",variant:"ghost",children:h.jsx(xh,{className:"size-4"})})]},R)),h.jsxs(Ie,{className:"mt-1",onClick:g,size:"sm",type:"button",variant:"ghost",children:[h.jsx(nu,{className:"size-4"}),n??"Add another"]}),d!==null&&h.jsx($w,{initialPath:l[d]?.path,onOpenChange:C=>{C||m(null)},onSelect:C=>{p(d,"path",C)},open:d!==null})]})}function G3(){const n=Vo(),[r,o]=v.useState([]),[l,s]=v.useState(!1),[c,d]=v.useState(!1);v.useEffect(()=>{m()},[]);async function m(){try{const g=await fetch("/api/setup");if(!g.ok)return;const b=await g.json();b.libraries.length>0&&o(b.libraries.map(p=>({name:p.name,path:p.path,type:p.type})))}finally{s(!0)}}async function y(g){g.preventDefault();const b=r.filter(p=>p.path.trim()!=="");if(b.length===0){Ze.error("Please add at least one library.");return}d(!0);try{const p=b.map(C=>({name:C.name.trim()||(C.path.split(/[\\/]/).pop()??C.type),path:C.path.trim(),type:C.type})),w=await fetch("/api/setup/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({libraries:p})});if(!w.ok){const C=await w.json();throw new Error(C.error?.message??"Setup failed")}n("/scan")}catch(p){Ze.error(p instanceof Error?p.message:"Setup failed")}finally{d(!1)}}return l?h.jsx("div",{className:"flex min-h-screen items-start justify-center px-6 pt-[15vh] pb-16",children:h.jsxs("div",{className:"w-full max-w-lg",children:[h.jsxs("div",{className:"mb-16 animate-fade-up",children:[h.jsx("h1",{className:"text-4xl font-bold tracking-tight text-foreground",children:"Set up your library"}),h.jsx("p",{className:"mt-3 text-muted-foreground",children:"Add your media folders and we'll take care of the rest."})]}),h.jsx("form",{onSubmit:g=>{y(g)},children:h.jsxs("div",{className:"space-y-16",children:[h.jsxs("section",{className:"animate-fade-up animate-delay-1",children:[h.jsx("h2",{className:"text-sm font-medium uppercase tracking-widest text-muted-foreground",children:"Libraries"}),h.jsx("div",{className:"mt-6",children:h.jsx(F3,{onChange:o,value:r})})]}),h.jsx("div",{className:"animate-fade-up animate-delay-2",children:h.jsx("div",{className:"flex justify-end",children:h.jsx(Ie,{disabled:c,size:"lg",type:"submit",children:c?"Setting up...":"Complete Setup"})})})]})})]})}):null}async function Y3(n){const r=await fetch(`/api/library/shows/${n}`);if(!r.ok)throw new Error("Failed to fetch show");return await r.json()}function I3(n){return St({queryKey:["show",n],queryFn:()=>Y3(n??""),enabled:!!n})}async function Q3(n){const r=await fetch(`/api/progress/episode/show/${n}`);if(!r.ok)throw new Error("Failed to fetch show progress");return await r.json()}function K3(n){if(n===null)return"";if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;return o>0?`${r}h ${o}m`:`${r}h`}function X3(n){return!n||!n.duration?0:Math.min(n.currentTime/n.duration*100,100)}function Z3(n){return!n||!n.duration?!1:n.currentTime>=n.duration*.9}function J3(){const{id:n}=zC(),r=Vo(),{data:o,isLoading:l,error:s}=I3(n),c=o?.id,{data:d}=St({queryKey:["show-progress",c],queryFn:()=>Q3(c??0),enabled:!!c}),m=v.useMemo(()=>{if(!d||!o)return null;let R=null,S="";for(const[N,j]of Object.entries(d)){const O=parseInt(N,10);j.duration&&j.currentTime<j.duration*.9&&(!S||j.updatedAt>S)&&(S=j.updatedAt,R=O)}if(R===null)return null;for(const N of o.seasons)for(const j of N.episodes)if(j.id===R)return N.seasonNumber;return null},[d,o]),[y,g]=v.useState(null);v.useEffect(()=>{if(y!==null||!o)return;if(m!==null){g(m);return}const R=o.seasons[0]?.seasonNumber??1;g(R)},[o,m,y]);function b(R){r(`/watch/episode/${R.id}`)}if(l)return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:h.jsx(Tu,{className:"size-8 animate-spin text-muted-foreground"})})]});if(s||!o)return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4",children:[h.jsx("p",{className:"text-foreground",children:"Show not found"}),h.jsx(Ie,{asChild:!0,variant:"outline",children:h.jsx(xn,{to:"/shows",children:"Back to Shows"})})]})]});const p=o.seasons.find(R=>R.seasonNumber===y)??o.seasons[0],w=o.genres?o.genres.split(",").map(R=>R.trim()):[],C=o.seasons.length;return h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"px-4 pt-4 pb-12 sm:px-6 sm:pt-6",children:[h.jsxs("div",{className:"flex flex-col gap-4 mb-8 sm:flex-row sm:gap-6",children:[h.jsx("div",{className:"flex-shrink-0 w-28 sm:w-40",children:h.jsx(dl,{alt:o.title,className:"w-full rounded-lg",url:o.posterUrl,title:o.title})}),h.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[h.jsx("h1",{className:"text-xl font-bold text-foreground sm:text-2xl",children:o.title}),h.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground",children:[o.year&&h.jsx("span",{children:o.year}),o.rating&&h.jsxs("span",{children:[o.rating.toFixed(1)," rating"]}),h.jsxs("span",{children:[C," ",C===1?"season":"seasons"]}),w.length>0&&h.jsx("span",{children:w.join(", ")})]}),o.overview&&h.jsx("p",{className:"text-sm text-muted-foreground max-w-2xl leading-relaxed",children:o.overview})]})]}),h.jsx("div",{className:"flex flex-wrap gap-2 mb-6",children:o.seasons.map(R=>h.jsx("button",{className:`cursor-pointer rounded-md px-4 min-h-11 text-sm font-medium transition-colors ${R.seasonNumber===y?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"}`,onClick:()=>g(R.seasonNumber),type:"button",children:R.name??`Season ${R.seasonNumber}`},R.id))}),p&&h.jsx("div",{className:"flex flex-col gap-1",children:p.episodes.map(R=>{const S=K3(R.runtime),N=d?.[R.id],j=X3(N),O=Z3(N),k=j>0&&!O;return h.jsxs("div",{className:"group flex items-start gap-4 rounded-lg px-3 py-3 cursor-pointer hover:bg-muted transition-colors",onClick:()=>b(R),children:[h.jsx("div",{className:"flex-shrink-0 w-10 text-right text-sm text-muted-foreground pt-0.5",children:R.episodeNumber}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`font-medium ${O?"text-muted-foreground":"text-foreground"}`,children:R.title}),S&&h.jsx("span",{className:"text-xs text-muted-foreground",children:S}),O&&h.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Watched"})]}),R.overview&&h.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:R.overview}),k&&h.jsx("div",{className:"mt-2 h-1 w-full max-w-xs rounded-full bg-muted",children:h.jsx("div",{className:"h-full rounded-full bg-red-600 transition-all",style:{width:`${j}%`}})})]}),h.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity pt-0.5",children:h.jsx(IT,{className:"size-4 text-foreground"})})]},R.id)})})]})]})}function W3(){const{data:n,isLoading:r}=hw(),o=v.useMemo(()=>n?n.map(s=>({type:"show",item:s})):[],[n]),l=v.useMemo(()=>o.length===0?[]:Kh(o),[o]);return r?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"pt-4",children:[h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{}),h.jsx(Yt,{})]})]}):o.length===0?h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4 text-center px-6",children:[h.jsx(Nu,{className:"size-16 text-muted-foreground"}),h.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"No shows in your library"}),h.jsxs("p",{className:"text-sm text-muted-foreground max-w-md",children:["Run"," ",h.jsx("code",{className:"bg-muted px-2 py-1 rounded text-xs font-mono",children:"bun run scan --shows /path/to/shows"})," ","to add your collection."]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx(rn,{}),h.jsx("div",{className:"pt-2 pb-8",children:l.map(({genre:s,items:c})=>h.jsx(el,{items:c,title:s},s))})]})}const fb=v.lazy(()=>db(()=>import("./Watch-Ja4PAA8Y.js"),__vite__mapDeps([0,1])).then(n=>({default:n.WatchPage}))),e4=new UE;tR({immediate:!0});function t4(){const{data:n,isLoading:r}=Eh();return r?null:n?.enabled&&!n.authenticated?h.jsx(pu,{to:"/login",replace:!0}):h.jsx(rM,{children:h.jsx(Bb,{})})}function n4(){const{data:n,isLoading:r}=dM();return r?null:n?.needsSetup?h.jsx(pu,{to:"/setup",replace:!0}):h.jsx(Bb,{})}const Fw=document.getElementById("root");if(!Fw)throw new Error("Root element not found");const a4=h.jsx(v.StrictMode,{children:h.jsxs(HE,{client:e4,children:[h.jsx(b2,{children:h.jsxs(KC,{children:[h.jsx(wt,{path:"/login",element:h.jsx(TD,{})}),h.jsxs(wt,{element:h.jsx(t4,{}),children:[h.jsx(wt,{path:"/scan",element:h.jsx(_D,{})}),h.jsx(wt,{path:"/setup",element:h.jsx(G3,{})}),h.jsxs(wt,{element:h.jsx(n4,{}),children:[h.jsx(wt,{path:"/",element:h.jsx(SD,{})}),h.jsx(wt,{path:"/movies",element:h.jsx(jD,{})}),h.jsx(wt,{path:"/shows",element:h.jsx(W3,{})}),h.jsx(wt,{path:"/shows/:id",element:h.jsx(J3,{})}),h.jsx(wt,{path:"/settings",element:h.jsx(pu,{to:"/settings/profiles",replace:!0})}),h.jsx(wt,{path:"/settings/profiles",element:h.jsx($3,{})}),h.jsx(wt,{path:"/settings/libraries",element:h.jsx(P3,{})}),h.jsx(wt,{path:"/settings/scan-schedule",element:h.jsx(V3,{})}),h.jsx(wt,{path:"/settings/auth",element:h.jsx(kD,{})}),h.jsx(wt,{path:"/watch/:id",element:h.jsx(v.Suspense,{children:h.jsx(fb,{})})}),h.jsx(wt,{path:"/watch/episode/:id",element:h.jsx(v.Suspense,{children:h.jsx(fb,{})})})]})]})]})}),h.jsx(eR,{position:"bottom-right",theme:"dark"})]})});hE.createRoot(Fw).render(a4);export{ST as A,Ie as B,T_ as C,Rd as I,Tu as L,IT as P,C_ as R,j3 as S,R_ as T,D0 as X,r4 as a,o4 as b,Qe as c,N_ as d,Fe as e,M0 as f,hu as g,dl as h,zC as i,h as j,tr as k,Vo as l,xn as m,O3 as n,_3 as o,i4 as p,v as r,Ze as t,St as u};