Files
cdc-project-management/dist/assets/index-1r0QKSgX.js
T

487 lines
879 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function CR(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const i in s)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(s,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>s[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function J_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hm={exports:{}},pl={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Px;function NR(){if(Px)return pl;Px=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:e,type:s,key:c,ref:i!==void 0?i:null,props:l}}return pl.Fragment=t,pl.jsx=n,pl.jsxs=n,pl}var zx;function jR(){return zx||(zx=1,Hm.exports=NR()),Hm.exports}var f=jR(),qm={exports:{}},Ge={};/**
* @license React
* react.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Ix;function TR(){if(Ix)return Ge;Ix=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=x&&R[x]||R["@@iterator"],typeof R=="function"?R:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,N={};function C(R,k,I){this.props=R,this.context=k,this.refs=N,this.updater=I||E}C.prototype.isReactComponent={},C.prototype.setState=function(R,k){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,k,"setState")},C.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function A(){}A.prototype=C.prototype;function T(R,k,I){this.props=R,this.context=k,this.refs=N,this.updater=I||E}var M=T.prototype=new A;M.constructor=T,S(M,C.prototype),M.isPureReactComponent=!0;var U=Array.isArray;function z(){}var L={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function q(R,k,I){var X=I.ref;return{$$typeof:e,type:R,key:k,ref:X!==void 0?X:null,props:I}}function ue(R,k){return q(R.type,k,R.props)}function le(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function he(R){var k={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(I){return k[I]})}var de=/\/+/g;function ve(R,k){return typeof R=="object"&&R!==null&&R.key!=null?he(""+R.key):k.toString(36)}function pe(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(z,z):(R.status="pending",R.then(function(k){R.status==="pending"&&(R.status="fulfilled",R.value=k)},function(k){R.status==="pending"&&(R.status="rejected",R.reason=k)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function O(R,k,I,X,H){var te=typeof R;(te==="undefined"||te==="boolean")&&(R=null);var ee=!1;if(R===null)ee=!0;else switch(te){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(R.$$typeof){case e:case t:ee=!0;break;case b:return ee=R._init,O(ee(R._payload),k,I,X,H)}}if(ee)return H=H(R),ee=X===""?"."+ve(R,0):X,U(H)?(I="",ee!=null&&(I=ee.replace(de,"$&/")+"/"),O(H,k,I,"",function(Ne){return Ne})):H!=null&&(le(H)&&(H=ue(H,I+(H.key==null||R&&R.key===H.key?"":(""+H.key).replace(de,"$&/")+"/")+ee)),k.push(H)),1;ee=0;var Q=X===""?".":X+":";if(U(R))for(var re=0;re<R.length;re++)X=R[re],te=Q+ve(X,re),ee+=O(X,k,I,te,H);else if(re=w(R),typeof re=="function")for(R=re.call(R),re=0;!(X=R.next()).done;)X=X.value,te=Q+ve(X,re++),ee+=O(X,k,I,te,H);else if(te==="object"){if(typeof R.then=="function")return O(pe(R),k,I,X,H);throw k=String(R),Error("Objects are not valid as a React child (found: "+(k==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":k)+"). If you meant to render a collection of children, use an array instead.")}return ee}function K(R,k,I){if(R==null)return R;var X=[],H=0;return O(R,X,"","",function(te){return k.call(I,te,H++)}),X}function W(R){if(R._status===-1){var k=R._result;k=k(),k.then(function(I){(R._status===0||R._status===-1)&&(R._status=1,R._result=I)},function(I){(R._status===0||R._status===-1)&&(R._status=2,R._result=I)}),R._status===-1&&(R._status=0,R._result=k)}if(R._status===1)return R._result.default;throw R._result}var J=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var k=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(k))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},V={map:K,forEach:function(R,k,I){K(R,function(){k.apply(this,arguments)},I)},count:function(R){var k=0;return K(R,function(){k++}),k},toArray:function(R){return K(R,function(k){return k})||[]},only:function(R){if(!le(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ge.Activity=g,Ge.Children=V,Ge.Component=C,Ge.Fragment=n,Ge.Profiler=i,Ge.PureComponent=T,Ge.StrictMode=s,Ge.Suspense=h,Ge.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,Ge.__COMPILER_RUNTIME={__proto__:null,c:function(R){return L.H.useMemoCache(R)}},Ge.cache=function(R){return function(){return R.apply(null,arguments)}},Ge.cacheSignal=function(){return null},Ge.cloneElement=function(R,k,I){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var X=S({},R.props),H=R.key;if(k!=null)for(te in k.key!==void 0&&(H=""+k.key),k)!B.call(k,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&k.ref===void 0||(X[te]=k[te]);var te=arguments.length-2;if(te===1)X.children=I;else if(1<te){for(var ee=Array(te),Q=0;Q<te;Q++)ee[Q]=arguments[Q+2];X.children=ee}return q(R.type,H,X)},Ge.createContext=function(R){return R={$$typeof:c,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:l,_context:R},R},Ge.createElement=function(R,k,I){var X,H={},te=null;if(k!=null)for(X in k.key!==void 0&&(te=""+k.key),k)B.call(k,X)&&X!=="key"&&X!=="__self"&&X!=="__source"&&(H[X]=k[X]);var ee=arguments.length-2;if(ee===1)H.children=I;else if(1<ee){for(var Q=Array(ee),re=0;re<ee;re++)Q[re]=arguments[re+2];H.children=Q}if(R&&R.defaultProps)for(X in ee=R.defaultProps,ee)H[X]===void 0&&(H[X]=ee[X]);return q(R,te,H)},Ge.createRef=function(){return{current:null}},Ge.forwardRef=function(R){return{$$typeof:d,render:R}},Ge.isValidElement=le,Ge.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:W}},Ge.memo=function(R,k){return{$$typeof:m,type:R,compare:k===void 0?null:k}},Ge.startTransition=function(R){var k=L.T,I={};L.T=I;try{var X=R(),H=L.S;H!==null&&H(I,X),typeof X=="object"&&X!==null&&typeof X.then=="function"&&X.then(z,J)}catch(te){J(te)}finally{k!==null&&I.types!==null&&(k.types=I.types),L.T=k}},Ge.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},Ge.use=function(R){return L.H.use(R)},Ge.useActionState=function(R,k,I){return L.H.useActionState(R,k,I)},Ge.useCallback=function(R,k){return L.H.useCallback(R,k)},Ge.useContext=function(R){return L.H.useContext(R)},Ge.useDebugValue=function(){},Ge.useDeferredValue=function(R,k){return L.H.useDeferredValue(R,k)},Ge.useEffect=function(R,k){return L.H.useEffect(R,k)},Ge.useEffectEvent=function(R){return L.H.useEffectEvent(R)},Ge.useId=function(){return L.H.useId()},Ge.useImperativeHandle=function(R,k,I){return L.H.useImperativeHandle(R,k,I)},Ge.useInsertionEffect=function(R,k){return L.H.useInsertionEffect(R,k)},Ge.useLayoutEffect=function(R,k){return L.H.useLayoutEffect(R,k)},Ge.useMemo=function(R,k){return L.H.useMemo(R,k)},Ge.useOptimistic=function(R,k){return L.H.useOptimistic(R,k)},Ge.useReducer=function(R,k,I){return L.H.useReducer(R,k,I)},Ge.useRef=function(R){return L.H.useRef(R)},Ge.useState=function(R){return L.H.useState(R)},Ge.useSyncExternalStore=function(R,k,I){return L.H.useSyncExternalStore(R,k,I)},Ge.useTransition=function(){return L.H.useTransition()},Ge.version="19.2.6",Ge}var Ux;function Vd(){return Ux||(Ux=1,qm.exports=TR()),qm.exports}var v=Vd();const ge=J_(v),jg=CR({__proto__:null,default:ge},[v]);var Vm={exports:{}},gl={},Fm={exports:{}},Gm={};/**
* @license React
* scheduler.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var $x;function AR(){return $x||($x=1,(function(e){function t(O,K){var W=O.length;O.push(K);e:for(;0<W;){var J=W-1>>>1,V=O[J];if(0<i(V,K))O[J]=K,O[W]=V,W=J;else break e}}function n(O){return O.length===0?null:O[0]}function s(O){if(O.length===0)return null;var K=O[0],W=O.pop();if(W!==K){O[0]=W;e:for(var J=0,V=O.length,R=V>>>1;J<R;){var k=2*(J+1)-1,I=O[k],X=k+1,H=O[X];if(0>i(I,W))X<V&&0>i(H,I)?(O[J]=H,O[X]=W,J=X):(O[J]=I,O[k]=W,J=k);else if(X<V&&0>i(H,W))O[J]=H,O[X]=W,J=X;else break e}}return K}function i(O,K){var W=O.sortIndex-K.sortIndex;return W!==0?W:O.id-K.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var h=[],m=[],b=1,g=null,x=3,w=!1,E=!1,S=!1,N=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function M(O){for(var K=n(m);K!==null;){if(K.callback===null)s(m);else if(K.startTime<=O)s(m),K.sortIndex=K.expirationTime,t(h,K);else break;K=n(m)}}function U(O){if(S=!1,M(O),!E)if(n(h)!==null)E=!0,z||(z=!0,he());else{var K=n(m);K!==null&&pe(U,K.startTime-O)}}var z=!1,L=-1,B=5,q=-1;function ue(){return N?!0:!(e.unstable_now()-q<B)}function le(){if(N=!1,z){var O=e.unstable_now();q=O;var K=!0;try{e:{E=!1,S&&(S=!1,A(L),L=-1),w=!0;var W=x;try{t:{for(M(O),g=n(h);g!==null&&!(g.expirationTime>O&&ue());){var J=g.callback;if(typeof J=="function"){g.callback=null,x=g.priorityLevel;var V=J(g.expirationTime<=O);if(O=e.unstable_now(),typeof V=="function"){g.callback=V,M(O),K=!0;break t}g===n(h)&&s(h),M(O)}else s(h);g=n(h)}if(g!==null)K=!0;else{var R=n(m);R!==null&&pe(U,R.startTime-O),K=!1}}break e}finally{g=null,x=W,w=!1}K=void 0}}finally{K?he():z=!1}}}var he;if(typeof T=="function")he=function(){T(le)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,ve=de.port2;de.port1.onmessage=le,he=function(){ve.postMessage(null)}}else he=function(){C(le,0)};function pe(O,K){L=C(function(){O(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(O){switch(x){case 1:case 2:case 3:var K=3;break;default:K=x}var W=x;x=K;try{return O()}finally{x=W}},e.unstable_requestPaint=function(){N=!0},e.unstable_runWithPriority=function(O,K){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var W=x;x=O;try{return K()}finally{x=W}},e.unstable_scheduleCallback=function(O,K,W){var J=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?J+W:J):W=J,O){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=W+V,O={id:b++,callback:K,priorityLevel:O,startTime:W,expirationTime:V,sortIndex:-1},W>J?(O.sortIndex=W,t(m,O),n(h)===null&&O===n(m)&&(S?(A(L),L=-1):S=!0,pe(U,W-J))):(O.sortIndex=V,t(h,O),E||w||(E=!0,z||(z=!0,he()))),O},e.unstable_shouldYield=ue,e.unstable_wrapCallback=function(O){var K=x;return function(){var W=x;x=K;try{return O.apply(this,arguments)}finally{x=W}}}})(Gm)),Gm}var Bx;function RR(){return Bx||(Bx=1,Fm.exports=AR()),Fm.exports}var Km={exports:{}},mn={};/**
* @license React
* react-dom.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Hx;function kR(){if(Hx)return mn;Hx=1;var e=Vd();function t(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)m+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function l(h,m,b){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:g==null?null:""+g,children:h,containerInfo:m,implementation:b}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return mn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,mn.createPortal=function(h,m){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(t(299));return l(h,m,null,b)},mn.flushSync=function(h){var m=c.T,b=s.p;try{if(c.T=null,s.p=2,h)return h()}finally{c.T=m,s.p=b,s.d.f()}},mn.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,s.d.C(h,m))},mn.prefetchDNS=function(h){typeof h=="string"&&s.d.D(h)},mn.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var b=m.as,g=d(b,m.crossOrigin),x=typeof m.integrity=="string"?m.integrity:void 0,w=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;b==="style"?s.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:w}):b==="script"&&s.d.X(h,{crossOrigin:g,integrity:x,fetchPriority:w,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},mn.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var b=d(m.as,m.crossOrigin);s.d.M(h,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&s.d.M(h)},mn.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var b=m.as,g=d(b,m.crossOrigin);s.d.L(h,b,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},mn.preloadModule=function(h,m){if(typeof h=="string")if(m){var b=d(m.as,m.crossOrigin);s.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else s.d.m(h)},mn.requestFormReset=function(h){s.d.r(h)},mn.unstable_batchedUpdates=function(h,m){return h(m)},mn.useFormState=function(h,m,b){return c.H.useFormState(h,m,b)},mn.useFormStatus=function(){return c.H.useHostTransitionStatus()},mn.version="19.2.6",mn}var qx;function Q_(){if(qx)return Km.exports;qx=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Km.exports=kR(),Km.exports}/**
* @license React
* react-dom-client.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Vx;function OR(){if(Vx)return gl;Vx=1;var e=RR(),t=Vd(),n=Q_();function s(r){var a="https://react.dev/errors/"+r;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)a+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+r+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var a=r,o=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(o=a.return),r=a.return;while(r)}return a.tag===3?o:null}function c(r){if(r.tag===13){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function d(r){if(r.tag===31){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function h(r){if(l(r)!==r)throw Error(s(188))}function m(r){var a=r.alternate;if(!a){if(a=l(r),a===null)throw Error(s(188));return a!==r?null:r}for(var o=r,u=a;;){var p=o.return;if(p===null)break;var y=p.alternate;if(y===null){if(u=p.return,u!==null){o=u;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===o)return h(p),r;if(y===u)return h(p),a;y=y.sibling}throw Error(s(188))}if(o.return!==u.return)o=p,u=y;else{for(var _=!1,j=p.child;j;){if(j===o){_=!0,o=p,u=y;break}if(j===u){_=!0,u=p,o=y;break}j=j.sibling}if(!_){for(j=y.child;j;){if(j===o){_=!0,o=y,u=p;break}if(j===u){_=!0,u=y,o=p;break}j=j.sibling}if(!_)throw Error(s(189))}}if(o.alternate!==u)throw Error(s(190))}if(o.tag!==3)throw Error(s(188));return o.stateNode.current===o?r:a}function b(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r;for(r=r.child;r!==null;){if(a=b(r),a!==null)return a;r=r.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),T=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),ue=Symbol.for("react.memo_cache_sentinel"),le=Symbol.iterator;function he(r){return r===null||typeof r!="object"?null:(r=le&&r[le]||r["@@iterator"],typeof r=="function"?r:null)}var de=Symbol.for("react.client.reference");function ve(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===de?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case S:return"Fragment";case C:return"Profiler";case N:return"StrictMode";case U:return"Suspense";case z:return"SuspenseList";case q:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case E:return"Portal";case T:return r.displayName||"Context";case A:return(r._context.displayName||"Context")+".Consumer";case M:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case L:return a=r.displayName||null,a!==null?a:ve(r.type)||"Memo";case B:a=r._payload,r=r._init;try{return ve(r(a))}catch{}}return null}var pe=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},J=[],V=-1;function R(r){return{current:r}}function k(r){0>V||(r.current=J[V],J[V]=null,V--)}function I(r,a){V++,J[V]=r.current,r.current=a}var X=R(null),H=R(null),te=R(null),ee=R(null);function Q(r,a){switch(I(te,a),I(H,r),I(X,null),a.nodeType){case 9:case 11:r=(r=a.documentElement)&&(r=r.namespaceURI)?sx(r):0;break;default:if(r=a.tagName,a=a.namespaceURI)a=sx(a),r=ix(a,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}k(X),I(X,r)}function re(){k(X),k(H),k(te)}function Ne(r){r.memoizedState!==null&&I(ee,r);var a=X.current,o=ix(a,r.type);a!==o&&(I(H,r),I(X,o))}function ze(r){H.current===r&&(k(X),k(H)),ee.current===r&&(k(ee),dl._currentValue=W)}var Oe,Qe;function Ze(r){if(Oe===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);Oe=a&&a[1]||"",Qe=-1<o.stack.indexOf(`
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
`+Oe+r+Qe}var vt=!1;function oe(r,a){if(!r||vt)return"";vt=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(Z){var Y=Z}Reflect.construct(r,[],ie)}else{try{ie.call()}catch(Z){Y=Z}r.call(ie.prototype)}}else{try{throw Error()}catch(Z){Y=Z}(ie=r())&&typeof ie.catch=="function"&&ie.catch(function(){})}}catch(Z){if(Z&&Y&&typeof Z.stack=="string")return[Z.stack,Y.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=u.DetermineComponentFrameRoot(),_=y[0],j=y[1];if(_&&j){var D=_.split(`
`),G=j.split(`
`);for(p=u=0;u<D.length&&!D[u].includes("DetermineComponentFrameRoot");)u++;for(;p<G.length&&!G[p].includes("DetermineComponentFrameRoot");)p++;if(u===D.length||p===G.length)for(u=D.length-1,p=G.length-1;1<=u&&0<=p&&D[u]!==G[p];)p--;for(;1<=u&&0<=p;u--,p--)if(D[u]!==G[p]){if(u!==1||p!==1)do if(u--,p--,0>p||D[u]!==G[p]){var ne=`
`+D[u].replace(" at new "," at ");return r.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",r.displayName)),ne}while(1<=u&&0<=p);break}}}finally{vt=!1,Error.prepareStackTrace=o}return(o=r?r.displayName||r.name:"")?Ze(o):""}function se(r,a){switch(r.tag){case 26:case 27:case 5:return Ze(r.type);case 16:return Ze("Lazy");case 13:return r.child!==a&&a!==null?Ze("Suspense Fallback"):Ze("Suspense");case 19:return Ze("SuspenseList");case 0:case 15:return oe(r.type,!1);case 11:return oe(r.type.render,!1);case 1:return oe(r.type,!0);case 31:return Ze("Activity");default:return""}}function Re(r){try{var a="",o=null;do a+=se(r,o),o=r,r=r.return;while(r);return a}catch(u){return`
Error generating stack: `+u.message+`
`+u.stack}}var De=Object.prototype.hasOwnProperty,ht=e.unstable_scheduleCallback,Ye=e.unstable_cancelCallback,mt=e.unstable_shouldYield,zt=e.unstable_requestPaint,qe=e.unstable_now,ce=e.unstable_getCurrentPriorityLevel,Pe=e.unstable_ImmediatePriority,ct=e.unstable_UserBlockingPriority,tn=e.unstable_NormalPriority,Dt=e.unstable_LowPriority,Gt=e.unstable_IdlePriority,dn=e.log,gn=e.unstable_setDisableYieldValue,fn=null,Nt=null;function Kt(r){if(typeof dn=="function"&&gn(r),Nt&&typeof Nt.setStrictMode=="function")try{Nt.setStrictMode(fn,r)}catch{}}var Tt=Math.clz32?Math.clz32:It,cr=Math.log,ur=Math.LN2;function It(r){return r>>>=0,r===0?32:31-(cr(r)/ur|0)|0}var fe=256,Ue=262144,me=4194304;function $e(r){var a=r&42;if(a!==0)return a;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function Se(r,a,o){var u=r.pendingLanes;if(u===0)return 0;var p=0,y=r.suspendedLanes,_=r.pingedLanes;r=r.warmLanes;var j=u&134217727;return j!==0?(u=j&~y,u!==0?p=$e(u):(_&=j,_!==0?p=$e(_):o||(o=j&~r,o!==0&&(p=$e(o))))):(j=u&~y,j!==0?p=$e(j):_!==0?p=$e(_):o||(o=u&~r,o!==0&&(p=$e(o)))),p===0?0:a!==0&&a!==p&&(a&y)===0&&(y=p&-p,o=a&-a,y>=o||y===32&&(o&4194048)!==0)?a:p}function st(r,a){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&a)===0}function St(r,a){switch(r){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function hn(){var r=me;return me<<=1,(me&62914560)===0&&(me=4194304),r}function _a(r){for(var a=[],o=0;31>o;o++)a.push(r);return a}function At(r,a){r.pendingLanes|=a,a!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function wn(r,a,o,u,p,y){var _=r.pendingLanes;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=o,r.entangledLanes&=o,r.errorRecoveryDisabledLanes&=o,r.shellSuspendCounter=0;var j=r.entanglements,D=r.expirationTimes,G=r.hiddenUpdates;for(o=_&~o;0<o;){var ne=31-Tt(o),ie=1<<ne;j[ne]=0,D[ne]=-1;var Y=G[ne];if(Y!==null)for(G[ne]=null,ne=0;ne<Y.length;ne++){var Z=Y[ne];Z!==null&&(Z.lane&=-536870913)}o&=~ie}u!==0&&us(r,u,0),y!==0&&p===0&&r.tag!==0&&(r.suspendedLanes|=y&~(_&~a))}function us(r,a,o){r.pendingLanes|=a,r.suspendedLanes&=~a;var u=31-Tt(a);r.entangledLanes|=a,r.entanglements[u]=r.entanglements[u]|1073741824|o&261930}function _n(r,a){var o=r.entangledLanes|=a;for(r=r.entanglements;o;){var u=31-Tt(o),p=1<<u;p&a|r[u]&a&&(r[u]|=a),o&=~p}}function Sn(r,a){var o=a&-a;return o=(o&42)!==0?1:Zs(o),(o&(r.suspendedLanes|a))!==0?0:o}function Zs(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function dr(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function Of(){var r=K.p;return r!==0?r:(r=window.event,r===void 0?32:Ax(r.type))}function Fv(r,a){var o=K.p;try{return K.p=r,a()}finally{K.p=o}}var Sa=Math.random().toString(36).slice(2),nn="__reactFiber$"+Sa,En="__reactProps$"+Sa,ei="__reactContainer$"+Sa,Mf="__reactEvents$"+Sa,mT="__reactListeners$"+Sa,pT="__reactHandles$"+Sa,Gv="__reactResources$"+Sa,No="__reactMarker$"+Sa;function Df(r){delete r[nn],delete r[En],delete r[Mf],delete r[mT],delete r[pT]}function ti(r){var a=r[nn];if(a)return a;for(var o=r.parentNode;o;){if(a=o[ei]||o[nn]){if(o=a.alternate,a.child!==null||o!==null&&o.child!==null)for(r=hx(r);r!==null;){if(o=r[nn])return o;r=hx(r)}return a}r=o,o=r.parentNode}return null}function ni(r){if(r=r[nn]||r[ei]){var a=r.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return r}return null}function jo(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r.stateNode;throw Error(s(33))}function ri(r){var a=r[Gv];return a||(a=r[Gv]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function Jt(r){r[No]=!0}var Kv=new Set,Yv={};function ds(r,a){ai(r,a),ai(r+"Capture",a)}function ai(r,a){for(Yv[r]=a,r=0;r<a.length;r++)Kv.add(a[r])}var gT=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Wv={},Xv={};function vT(r){return De.call(Xv,r)?!0:De.call(Wv,r)?!1:gT.test(r)?Xv[r]=!0:(Wv[r]=!0,!1)}function mc(r,a,o){if(vT(a))if(o===null)r.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":r.removeAttribute(a);return;case"boolean":var u=a.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){r.removeAttribute(a);return}}r.setAttribute(a,""+o)}}function pc(r,a,o){if(o===null)r.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(a);return}r.setAttribute(a,""+o)}}function qr(r,a,o,u){if(u===null)r.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(o);return}r.setAttributeNS(a,o,""+u)}}function Kn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Jv(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function yT(r,a,o){var u=Object.getOwnPropertyDescriptor(r.constructor.prototype,a);if(!r.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var p=u.get,y=u.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return p.call(this)},set:function(_){o=""+_,y.call(this,_)}}),Object.defineProperty(r,a,{enumerable:u.enumerable}),{getValue:function(){return o},setValue:function(_){o=""+_},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function Lf(r){if(!r._valueTracker){var a=Jv(r)?"checked":"value";r._valueTracker=yT(r,a,""+r[a])}}function Qv(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var o=a.getValue(),u="";return r&&(u=Jv(r)?r.checked?"true":"false":r.value),r=u,r!==o?(a.setValue(r),!0):!1}function gc(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var bT=/[\n"\\]/g;function Yn(r){return r.replace(bT,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Pf(r,a,o,u,p,y,_,j){r.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?r.type=_:r.removeAttribute("type"),a!=null?_==="number"?(a===0&&r.value===""||r.value!=a)&&(r.value=""+Kn(a)):r.value!==""+Kn(a)&&(r.value=""+Kn(a)):_!=="submit"&&_!=="reset"||r.removeAttribute("value"),a!=null?zf(r,_,Kn(a)):o!=null?zf(r,_,Kn(o)):u!=null&&r.removeAttribute("value"),p==null&&y!=null&&(r.defaultChecked=!!y),p!=null&&(r.checked=p&&typeof p!="function"&&typeof p!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?r.name=""+Kn(j):r.removeAttribute("name")}function Zv(r,a,o,u,p,y,_,j){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(r.type=y),a!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||a!=null)){Lf(r);return}o=o!=null?""+Kn(o):"",a=a!=null?""+Kn(a):o,j||a===r.value||(r.value=a),r.defaultValue=a}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,r.checked=j?r.checked:!!u,r.defaultChecked=!!u,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(r.name=_),Lf(r)}function zf(r,a,o){a==="number"&&gc(r.ownerDocument)===r||r.defaultValue===""+o||(r.defaultValue=""+o)}function si(r,a,o,u){if(r=r.options,a){a={};for(var p=0;p<o.length;p++)a["$"+o[p]]=!0;for(o=0;o<r.length;o++)p=a.hasOwnProperty("$"+r[o].value),r[o].selected!==p&&(r[o].selected=p),p&&u&&(r[o].defaultSelected=!0)}else{for(o=""+Kn(o),a=null,p=0;p<r.length;p++){if(r[p].value===o){r[p].selected=!0,u&&(r[p].defaultSelected=!0);return}a!==null||r[p].disabled||(a=r[p])}a!==null&&(a.selected=!0)}}function ey(r,a,o){if(a!=null&&(a=""+Kn(a),a!==r.value&&(r.value=a),o==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=o!=null?""+Kn(o):""}function ty(r,a,o,u){if(a==null){if(u!=null){if(o!=null)throw Error(s(92));if(pe(u)){if(1<u.length)throw Error(s(93));u=u[0]}o=u}o==null&&(o=""),a=o}o=Kn(a),r.defaultValue=o,u=r.textContent,u===o&&u!==""&&u!==null&&(r.value=u),Lf(r)}function ii(r,a){if(a){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=a;return}}r.textContent=a}var xT=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function ny(r,a,o){var u=a.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?u?r.setProperty(a,""):a==="float"?r.cssFloat="":r[a]="":u?r.setProperty(a,o):typeof o!="number"||o===0||xT.has(a)?a==="float"?r.cssFloat=o:r[a]=(""+o).trim():r[a]=o+"px"}function ry(r,a,o){if(a!=null&&typeof a!="object")throw Error(s(62));if(r=r.style,o!=null){for(var u in o)!o.hasOwnProperty(u)||a!=null&&a.hasOwnProperty(u)||(u.indexOf("--")===0?r.setProperty(u,""):u==="float"?r.cssFloat="":r[u]="");for(var p in a)u=a[p],a.hasOwnProperty(p)&&o[p]!==u&&ny(r,p,u)}else for(var y in a)a.hasOwnProperty(y)&&ny(r,y,a[y])}function If(r){if(r.indexOf("-")===-1)return!1;switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var wT=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),_T=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function vc(r){return _T.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Vr(){}var Uf=null;function $f(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var oi=null,li=null;function ay(r){var a=ni(r);if(a&&(r=a.stateNode)){var o=r[En]||null;e:switch(r=a.stateNode,a.type){case"input":if(Pf(r,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),a=o.name,o.type==="radio"&&a!=null){for(o=r;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+Yn(""+a)+'"][type="radio"]'),a=0;a<o.length;a++){var u=o[a];if(u!==r&&u.form===r.form){var p=u[En]||null;if(!p)throw Error(s(90));Pf(u,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(a=0;a<o.length;a++)u=o[a],u.form===r.form&&Qv(u)}break e;case"textarea":ey(r,o.value,o.defaultValue);break e;case"select":a=o.value,a!=null&&si(r,!!o.multiple,a,!1)}}}var Bf=!1;function sy(r,a,o){if(Bf)return r(a,o);Bf=!0;try{var u=r(a);return u}finally{if(Bf=!1,(oi!==null||li!==null)&&(au(),oi&&(a=oi,r=li,li=oi=null,ay(a),r)))for(a=0;a<r.length;a++)ay(r[a])}}function To(r,a){var o=r.stateNode;if(o===null)return null;var u=o[En]||null;if(u===null)return null;o=u[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(r=r.type,u=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!u;break e;default:r=!1}if(r)return null;if(o&&typeof o!="function")throw Error(s(231,a,typeof o));return o}var Fr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hf=!1;if(Fr)try{var Ao={};Object.defineProperty(Ao,"passive",{get:function(){Hf=!0}}),window.addEventListener("test",Ao,Ao),window.removeEventListener("test",Ao,Ao)}catch{Hf=!1}var Ea=null,qf=null,yc=null;function iy(){if(yc)return yc;var r,a=qf,o=a.length,u,p="value"in Ea?Ea.value:Ea.textContent,y=p.length;for(r=0;r<o&&a[r]===p[r];r++);var _=o-r;for(u=1;u<=_&&a[o-u]===p[y-u];u++);return yc=p.slice(r,1<u?1-u:void 0)}function bc(r){var a=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&a===13&&(r=13)):r=a,r===10&&(r=13),32<=r||r===13?r:0}function xc(){return!0}function oy(){return!1}function Cn(r){function a(o,u,p,y,_){this._reactName=o,this._targetInst=p,this.type=u,this.nativeEvent=y,this.target=_,this.currentTarget=null;for(var j in r)r.hasOwnProperty(j)&&(o=r[j],this[j]=o?o(y):y[j]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?xc:oy,this.isPropagationStopped=oy,this}return g(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=xc)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=xc)},persist:function(){},isPersistent:xc}),a}var fs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wc=Cn(fs),Ro=g({},fs,{view:0,detail:0}),ST=Cn(Ro),Vf,Ff,ko,_c=g({},Ro,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Kf,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==ko&&(ko&&r.type==="mousemove"?(Vf=r.screenX-ko.screenX,Ff=r.screenY-ko.screenY):Ff=Vf=0,ko=r),Vf)},movementY:function(r){return"movementY"in r?r.movementY:Ff}}),ly=Cn(_c),ET=g({},_c,{dataTransfer:0}),CT=Cn(ET),NT=g({},Ro,{relatedTarget:0}),Gf=Cn(NT),jT=g({},fs,{animationName:0,elapsedTime:0,pseudoElement:0}),TT=Cn(jT),AT=g({},fs,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),RT=Cn(AT),kT=g({},fs,{data:0}),cy=Cn(kT),OT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},MT={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},DT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function LT(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=DT[r])?!!a[r]:!1}function Kf(){return LT}var PT=g({},Ro,{key:function(r){if(r.key){var a=OT[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=bc(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?MT[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Kf,charCode:function(r){return r.type==="keypress"?bc(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?bc(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),zT=Cn(PT),IT=g({},_c,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),uy=Cn(IT),UT=g({},Ro,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Kf}),$T=Cn(UT),BT=g({},fs,{propertyName:0,elapsedTime:0,pseudoElement:0}),HT=Cn(BT),qT=g({},_c,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),VT=Cn(qT),FT=g({},fs,{newState:0,oldState:0}),GT=Cn(FT),KT=[9,13,27,32],Yf=Fr&&"CompositionEvent"in window,Oo=null;Fr&&"documentMode"in document&&(Oo=document.documentMode);var YT=Fr&&"TextEvent"in window&&!Oo,dy=Fr&&(!Yf||Oo&&8<Oo&&11>=Oo),fy=" ",hy=!1;function my(r,a){switch(r){case"keyup":return KT.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function py(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var ci=!1;function WT(r,a){switch(r){case"compositionend":return py(a);case"keypress":return a.which!==32?null:(hy=!0,fy);case"textInput":return r=a.data,r===fy&&hy?null:r;default:return null}}function XT(r,a){if(ci)return r==="compositionend"||!Yf&&my(r,a)?(r=iy(),yc=qf=Ea=null,ci=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return dy&&a.locale!=="ko"?null:a.data;default:return null}}var JT={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function gy(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!JT[r.type]:a==="textarea"}function vy(r,a,o,u){oi?li?li.push(u):li=[u]:oi=u,a=du(a,"onChange"),0<a.length&&(o=new wc("onChange","change",null,o,u),r.push({event:o,listeners:a}))}var Mo=null,Do=null;function QT(r){Z0(r,0)}function Sc(r){var a=jo(r);if(Qv(a))return r}function yy(r,a){if(r==="change")return a}var by=!1;if(Fr){var Wf;if(Fr){var Xf="oninput"in document;if(!Xf){var xy=document.createElement("div");xy.setAttribute("oninput","return;"),Xf=typeof xy.oninput=="function"}Wf=Xf}else Wf=!1;by=Wf&&(!document.documentMode||9<document.documentMode)}function wy(){Mo&&(Mo.detachEvent("onpropertychange",_y),Do=Mo=null)}function _y(r){if(r.propertyName==="value"&&Sc(Do)){var a=[];vy(a,Do,r,$f(r)),sy(QT,a)}}function ZT(r,a,o){r==="focusin"?(wy(),Mo=a,Do=o,Mo.attachEvent("onpropertychange",_y)):r==="focusout"&&wy()}function eA(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Sc(Do)}function tA(r,a){if(r==="click")return Sc(a)}function nA(r,a){if(r==="input"||r==="change")return Sc(a)}function rA(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var zn=typeof Object.is=="function"?Object.is:rA;function Lo(r,a){if(zn(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var o=Object.keys(r),u=Object.keys(a);if(o.length!==u.length)return!1;for(u=0;u<o.length;u++){var p=o[u];if(!De.call(a,p)||!zn(r[p],a[p]))return!1}return!0}function Sy(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Ey(r,a){var o=Sy(r);r=0;for(var u;o;){if(o.nodeType===3){if(u=r+o.textContent.length,r<=a&&u>=a)return{node:o,offset:a-r};r=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Sy(o)}}function Cy(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?Cy(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function Ny(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=gc(r.document);a instanceof r.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)r=a.contentWindow;else break;a=gc(r.document)}return a}function Jf(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}var aA=Fr&&"documentMode"in document&&11>=document.documentMode,ui=null,Qf=null,Po=null,Zf=!1;function jy(r,a,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Zf||ui==null||ui!==gc(u)||(u=ui,"selectionStart"in u&&Jf(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Po&&Lo(Po,u)||(Po=u,u=du(Qf,"onSelect"),0<u.length&&(a=new wc("onSelect","select",null,a,o),r.push({event:a,listeners:u}),a.target=ui)))}function hs(r,a){var o={};return o[r.toLowerCase()]=a.toLowerCase(),o["Webkit"+r]="webkit"+a,o["Moz"+r]="moz"+a,o}var di={animationend:hs("Animation","AnimationEnd"),animationiteration:hs("Animation","AnimationIteration"),animationstart:hs("Animation","AnimationStart"),transitionrun:hs("Transition","TransitionRun"),transitionstart:hs("Transition","TransitionStart"),transitioncancel:hs("Transition","TransitionCancel"),transitionend:hs("Transition","TransitionEnd")},eh={},Ty={};Fr&&(Ty=document.createElement("div").style,"AnimationEvent"in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),"TransitionEvent"in window||delete di.transitionend.transition);function ms(r){if(eh[r])return eh[r];if(!di[r])return r;var a=di[r],o;for(o in a)if(a.hasOwnProperty(o)&&o in Ty)return eh[r]=a[o];return r}var Ay=ms("animationend"),Ry=ms("animationiteration"),ky=ms("animationstart"),sA=ms("transitionrun"),iA=ms("transitionstart"),oA=ms("transitioncancel"),Oy=ms("transitionend"),My=new Map,th="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");th.push("scrollEnd");function fr(r,a){My.set(r,a),ds(a,[r])}var Ec=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},Wn=[],fi=0,nh=0;function Cc(){for(var r=fi,a=nh=fi=0;a<r;){var o=Wn[a];Wn[a++]=null;var u=Wn[a];Wn[a++]=null;var p=Wn[a];Wn[a++]=null;var y=Wn[a];if(Wn[a++]=null,u!==null&&p!==null){var _=u.pending;_===null?p.next=p:(p.next=_.next,_.next=p),u.pending=p}y!==0&&Dy(o,p,y)}}function Nc(r,a,o,u){Wn[fi++]=r,Wn[fi++]=a,Wn[fi++]=o,Wn[fi++]=u,nh|=u,r.lanes|=u,r=r.alternate,r!==null&&(r.lanes|=u)}function rh(r,a,o,u){return Nc(r,a,o,u),jc(r)}function ps(r,a){return Nc(r,null,null,a),jc(r)}function Dy(r,a,o){r.lanes|=o;var u=r.alternate;u!==null&&(u.lanes|=o);for(var p=!1,y=r.return;y!==null;)y.childLanes|=o,u=y.alternate,u!==null&&(u.childLanes|=o),y.tag===22&&(r=y.stateNode,r===null||r._visibility&1||(p=!0)),r=y,y=y.return;return r.tag===3?(y=r.stateNode,p&&a!==null&&(p=31-Tt(o),r=y.hiddenUpdates,u=r[p],u===null?r[p]=[a]:u.push(a),a.lane=o|536870912),y):null}function jc(r){if(50<al)throw al=0,fm=null,Error(s(185));for(var a=r.return;a!==null;)r=a,a=r.return;return r.tag===3?r.stateNode:null}var hi={};function lA(r,a,o,u){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function In(r,a,o,u){return new lA(r,a,o,u)}function ah(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Gr(r,a){var o=r.alternate;return o===null?(o=In(r.tag,a,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=a,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&65011712,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,a=r.dependencies,o.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o.refCleanup=r.refCleanup,o}function Ly(r,a){r.flags&=65011714;var o=r.alternate;return o===null?(r.childLanes=0,r.lanes=a,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=o.childLanes,r.lanes=o.lanes,r.child=o.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=o.memoizedProps,r.memoizedState=o.memoizedState,r.updateQueue=o.updateQueue,r.type=o.type,a=o.dependencies,r.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),r}function Tc(r,a,o,u,p,y){var _=0;if(u=r,typeof r=="function")ah(r)&&(_=1);else if(typeof r=="string")_=hR(r,o,X.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case q:return r=In(31,o,a,p),r.elementType=q,r.lanes=y,r;case S:return gs(o.children,p,y,a);case N:_=8,p|=24;break;case C:return r=In(12,o,a,p|2),r.elementType=C,r.lanes=y,r;case U:return r=In(13,o,a,p),r.elementType=U,r.lanes=y,r;case z:return r=In(19,o,a,p),r.elementType=z,r.lanes=y,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case T:_=10;break e;case A:_=9;break e;case M:_=11;break e;case L:_=14;break e;case B:_=16,u=null;break e}_=29,o=Error(s(130,r===null?"null":typeof r,"")),u=null}return a=In(_,o,a,p),a.elementType=r,a.type=u,a.lanes=y,a}function gs(r,a,o,u){return r=In(7,r,u,a),r.lanes=o,r}function sh(r,a,o){return r=In(6,r,null,a),r.lanes=o,r}function Py(r){var a=In(18,null,null,0);return a.stateNode=r,a}function ih(r,a,o){return a=In(4,r.children!==null?r.children:[],r.key,a),a.lanes=o,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}var zy=new WeakMap;function Xn(r,a){if(typeof r=="object"&&r!==null){var o=zy.get(r);return o!==void 0?o:(a={value:r,source:a,stack:Re(a)},zy.set(r,a),a)}return{value:r,source:a,stack:Re(a)}}var mi=[],pi=0,Ac=null,zo=0,Jn=[],Qn=0,Ca=null,Cr=1,Nr="";function Kr(r,a){mi[pi++]=zo,mi[pi++]=Ac,Ac=r,zo=a}function Iy(r,a,o){Jn[Qn++]=Cr,Jn[Qn++]=Nr,Jn[Qn++]=Ca,Ca=r;var u=Cr;r=Nr;var p=32-Tt(u)-1;u&=~(1<<p),o+=1;var y=32-Tt(a)+p;if(30<y){var _=p-p%5;y=(u&(1<<_)-1).toString(32),u>>=_,p-=_,Cr=1<<32-Tt(a)+p|o<<p|u,Nr=y+r}else Cr=1<<y|o<<p|u,Nr=r}function oh(r){r.return!==null&&(Kr(r,1),Iy(r,1,0))}function lh(r){for(;r===Ac;)Ac=mi[--pi],mi[pi]=null,zo=mi[--pi],mi[pi]=null;for(;r===Ca;)Ca=Jn[--Qn],Jn[Qn]=null,Nr=Jn[--Qn],Jn[Qn]=null,Cr=Jn[--Qn],Jn[Qn]=null}function Uy(r,a){Jn[Qn++]=Cr,Jn[Qn++]=Nr,Jn[Qn++]=Ca,Cr=a.id,Nr=a.overflow,Ca=r}var rn=null,Et=null,it=!1,Na=null,Zn=!1,ch=Error(s(519));function ja(r){var a=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Io(Xn(a,r)),ch}function $y(r){var a=r.stateNode,o=r.type,u=r.memoizedProps;switch(a[nn]=r,a[En]=u,o){case"dialog":nt("cancel",a),nt("close",a);break;case"iframe":case"object":case"embed":nt("load",a);break;case"video":case"audio":for(o=0;o<il.length;o++)nt(il[o],a);break;case"source":nt("error",a);break;case"img":case"image":case"link":nt("error",a),nt("load",a);break;case"details":nt("toggle",a);break;case"input":nt("invalid",a),Zv(a,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":nt("invalid",a);break;case"textarea":nt("invalid",a),ty(a,u.value,u.defaultValue,u.children)}o=u.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||a.textContent===""+o||u.suppressHydrationWarning===!0||rx(a.textContent,o)?(u.popover!=null&&(nt("beforetoggle",a),nt("toggle",a)),u.onScroll!=null&&nt("scroll",a),u.onScrollEnd!=null&&nt("scrollend",a),u.onClick!=null&&(a.onclick=Vr),a=!0):a=!1,a||ja(r,!0)}function By(r){for(rn=r.return;rn;)switch(rn.tag){case 5:case 31:case 13:Zn=!1;return;case 27:case 3:Zn=!0;return;default:rn=rn.return}}function gi(r){if(r!==rn)return!1;if(!it)return By(r),it=!0,!1;var a=r.tag,o;if((o=a!==3&&a!==27)&&((o=a===5)&&(o=r.type,o=!(o!=="form"&&o!=="button")||jm(r.type,r.memoizedProps)),o=!o),o&&Et&&ja(r),By(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Et=fx(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Et=fx(r)}else a===27?(a=Et,Ba(r.type)?(r=Om,Om=null,Et=r):Et=a):Et=rn?tr(r.stateNode.nextSibling):null;return!0}function vs(){Et=rn=null,it=!1}function uh(){var r=Na;return r!==null&&(An===null?An=r:An.push.apply(An,r),Na=null),r}function Io(r){Na===null?Na=[r]:Na.push(r)}var dh=R(null),ys=null,Yr=null;function Ta(r,a,o){I(dh,a._currentValue),a._currentValue=o}function Wr(r){r._currentValue=dh.current,k(dh)}function fh(r,a,o){for(;r!==null;){var u=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,u!==null&&(u.childLanes|=a)):u!==null&&(u.childLanes&a)!==a&&(u.childLanes|=a),r===o)break;r=r.return}}function hh(r,a,o,u){var p=r.child;for(p!==null&&(p.return=r);p!==null;){var y=p.dependencies;if(y!==null){var _=p.child;y=y.firstContext;e:for(;y!==null;){var j=y;y=p;for(var D=0;D<a.length;D++)if(j.context===a[D]){y.lanes|=o,j=y.alternate,j!==null&&(j.lanes|=o),fh(y.return,o,r),u||(_=null);break e}y=j.next}}else if(p.tag===18){if(_=p.return,_===null)throw Error(s(341));_.lanes|=o,y=_.alternate,y!==null&&(y.lanes|=o),fh(_,o,r),_=null}else _=p.child;if(_!==null)_.return=p;else for(_=p;_!==null;){if(_===r){_=null;break}if(p=_.sibling,p!==null){p.return=_.return,_=p;break}_=_.return}p=_}}function vi(r,a,o,u){r=null;for(var p=a,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var _=p.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var j=p.type;zn(p.pendingProps.value,_.value)||(r!==null?r.push(j):r=[j])}}else if(p===ee.current){if(_=p.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(r!==null?r.push(dl):r=[dl])}p=p.return}r!==null&&hh(a,r,o,u),a.flags|=262144}function Rc(r){for(r=r.firstContext;r!==null;){if(!zn(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function bs(r){ys=r,Yr=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function an(r){return Hy(ys,r)}function kc(r,a){return ys===null&&bs(r),Hy(r,a)}function Hy(r,a){var o=a._currentValue;if(a={context:a,memoizedValue:o,next:null},Yr===null){if(r===null)throw Error(s(308));Yr=a,r.dependencies={lanes:0,firstContext:a},r.flags|=524288}else Yr=Yr.next=a;return o}var cA=typeof AbortController<"u"?AbortController:function(){var r=[],a=this.signal={aborted:!1,addEventListener:function(o,u){r.push(u)}};this.abort=function(){a.aborted=!0,r.forEach(function(o){return o()})}},uA=e.unstable_scheduleCallback,dA=e.unstable_NormalPriority,Ut={$$typeof:T,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function mh(){return{controller:new cA,data:new Map,refCount:0}}function Uo(r){r.refCount--,r.refCount===0&&uA(dA,function(){r.controller.abort()})}var $o=null,ph=0,yi=0,bi=null;function fA(r,a){if($o===null){var o=$o=[];ph=0,yi=ym(),bi={status:"pending",value:void 0,then:function(u){o.push(u)}}}return ph++,a.then(qy,qy),a}function qy(){if(--ph===0&&$o!==null){bi!==null&&(bi.status="fulfilled");var r=$o;$o=null,yi=0,bi=null;for(var a=0;a<r.length;a++)(0,r[a])()}}function hA(r,a){var o=[],u={status:"pending",value:null,reason:null,then:function(p){o.push(p)}};return r.then(function(){u.status="fulfilled",u.value=a;for(var p=0;p<o.length;p++)(0,o[p])(a)},function(p){for(u.status="rejected",u.reason=p,p=0;p<o.length;p++)(0,o[p])(void 0)}),u}var Vy=O.S;O.S=function(r,a){j0=qe(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&fA(r,a),Vy!==null&&Vy(r,a)};var xs=R(null);function gh(){var r=xs.current;return r!==null?r:wt.pooledCache}function Oc(r,a){a===null?I(xs,xs.current):I(xs,a.pool)}function Fy(){var r=gh();return r===null?null:{parent:Ut._currentValue,pool:r}}var xi=Error(s(460)),vh=Error(s(474)),Mc=Error(s(542)),Dc={then:function(){}};function Gy(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Ky(r,a,o){switch(o=r[o],o===void 0?r.push(a):o!==a&&(a.then(Vr,Vr),a=o),a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Wy(r),r;default:if(typeof a.status=="string")a.then(Vr,Vr);else{if(r=wt,r!==null&&100<r.shellSuspendCounter)throw Error(s(482));r=a,r.status="pending",r.then(function(u){if(a.status==="pending"){var p=a;p.status="fulfilled",p.value=u}},function(u){if(a.status==="pending"){var p=a;p.status="rejected",p.reason=u}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Wy(r),r}throw _s=a,xi}}function ws(r){try{var a=r._init;return a(r._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(_s=o,xi):o}}var _s=null;function Yy(){if(_s===null)throw Error(s(459));var r=_s;return _s=null,r}function Wy(r){if(r===xi||r===Mc)throw Error(s(483))}var wi=null,Bo=0;function Lc(r){var a=Bo;return Bo+=1,wi===null&&(wi=[]),Ky(wi,r,a)}function Ho(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function Pc(r,a){throw a.$$typeof===x?Error(s(525)):(r=Object.prototype.toString.call(a),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function Xy(r){function a($,P){if(r){var F=$.deletions;F===null?($.deletions=[P],$.flags|=16):F.push(P)}}function o($,P){if(!r)return null;for(;P!==null;)a($,P),P=P.sibling;return null}function u($){for(var P=new Map;$!==null;)$.key!==null?P.set($.key,$):P.set($.index,$),$=$.sibling;return P}function p($,P){return $=Gr($,P),$.index=0,$.sibling=null,$}function y($,P,F){return $.index=F,r?(F=$.alternate,F!==null?(F=F.index,F<P?($.flags|=67108866,P):F):($.flags|=67108866,P)):($.flags|=1048576,P)}function _($){return r&&$.alternate===null&&($.flags|=67108866),$}function j($,P,F,ae){return P===null||P.tag!==6?(P=sh(F,$.mode,ae),P.return=$,P):(P=p(P,F),P.return=$,P)}function D($,P,F,ae){var Ie=F.type;return Ie===S?ne($,P,F.props.children,ae,F.key):P!==null&&(P.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===B&&ws(Ie)===P.type)?(P=p(P,F.props),Ho(P,F),P.return=$,P):(P=Tc(F.type,F.key,F.props,null,$.mode,ae),Ho(P,F),P.return=$,P)}function G($,P,F,ae){return P===null||P.tag!==4||P.stateNode.containerInfo!==F.containerInfo||P.stateNode.implementation!==F.implementation?(P=ih(F,$.mode,ae),P.return=$,P):(P=p(P,F.children||[]),P.return=$,P)}function ne($,P,F,ae,Ie){return P===null||P.tag!==7?(P=gs(F,$.mode,ae,Ie),P.return=$,P):(P=p(P,F),P.return=$,P)}function ie($,P,F){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=sh(""+P,$.mode,F),P.return=$,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case w:return F=Tc(P.type,P.key,P.props,null,$.mode,F),Ho(F,P),F.return=$,F;case E:return P=ih(P,$.mode,F),P.return=$,P;case B:return P=ws(P),ie($,P,F)}if(pe(P)||he(P))return P=gs(P,$.mode,F,null),P.return=$,P;if(typeof P.then=="function")return ie($,Lc(P),F);if(P.$$typeof===T)return ie($,kc($,P),F);Pc($,P)}return null}function Y($,P,F,ae){var Ie=P!==null?P.key:null;if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return Ie!==null?null:j($,P,""+F,ae);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case w:return F.key===Ie?D($,P,F,ae):null;case E:return F.key===Ie?G($,P,F,ae):null;case B:return F=ws(F),Y($,P,F,ae)}if(pe(F)||he(F))return Ie!==null?null:ne($,P,F,ae,null);if(typeof F.then=="function")return Y($,P,Lc(F),ae);if(F.$$typeof===T)return Y($,P,kc($,F),ae);Pc($,F)}return null}function Z($,P,F,ae,Ie){if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return $=$.get(F)||null,j(P,$,""+ae,Ie);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case w:return $=$.get(ae.key===null?F:ae.key)||null,D(P,$,ae,Ie);case E:return $=$.get(ae.key===null?F:ae.key)||null,G(P,$,ae,Ie);case B:return ae=ws(ae),Z($,P,F,ae,Ie)}if(pe(ae)||he(ae))return $=$.get(F)||null,ne(P,$,ae,Ie,null);if(typeof ae.then=="function")return Z($,P,F,Lc(ae),Ie);if(ae.$$typeof===T)return Z($,P,F,kc(P,ae),Ie);Pc(P,ae)}return null}function je($,P,F,ae){for(var Ie=null,ut=null,Me=P,We=P=0,at=null;Me!==null&&We<F.length;We++){Me.index>We?(at=Me,Me=null):at=Me.sibling;var dt=Y($,Me,F[We],ae);if(dt===null){Me===null&&(Me=at);break}r&&Me&&dt.alternate===null&&a($,Me),P=y(dt,P,We),ut===null?Ie=dt:ut.sibling=dt,ut=dt,Me=at}if(We===F.length)return o($,Me),it&&Kr($,We),Ie;if(Me===null){for(;We<F.length;We++)Me=ie($,F[We],ae),Me!==null&&(P=y(Me,P,We),ut===null?Ie=Me:ut.sibling=Me,ut=Me);return it&&Kr($,We),Ie}for(Me=u(Me);We<F.length;We++)at=Z(Me,$,We,F[We],ae),at!==null&&(r&&at.alternate!==null&&Me.delete(at.key===null?We:at.key),P=y(at,P,We),ut===null?Ie=at:ut.sibling=at,ut=at);return r&&Me.forEach(function(Ga){return a($,Ga)}),it&&Kr($,We),Ie}function Be($,P,F,ae){if(F==null)throw Error(s(151));for(var Ie=null,ut=null,Me=P,We=P=0,at=null,dt=F.next();Me!==null&&!dt.done;We++,dt=F.next()){Me.index>We?(at=Me,Me=null):at=Me.sibling;var Ga=Y($,Me,dt.value,ae);if(Ga===null){Me===null&&(Me=at);break}r&&Me&&Ga.alternate===null&&a($,Me),P=y(Ga,P,We),ut===null?Ie=Ga:ut.sibling=Ga,ut=Ga,Me=at}if(dt.done)return o($,Me),it&&Kr($,We),Ie;if(Me===null){for(;!dt.done;We++,dt=F.next())dt=ie($,dt.value,ae),dt!==null&&(P=y(dt,P,We),ut===null?Ie=dt:ut.sibling=dt,ut=dt);return it&&Kr($,We),Ie}for(Me=u(Me);!dt.done;We++,dt=F.next())dt=Z(Me,$,We,dt.value,ae),dt!==null&&(r&&dt.alternate!==null&&Me.delete(dt.key===null?We:dt.key),P=y(dt,P,We),ut===null?Ie=dt:ut.sibling=dt,ut=dt);return r&&Me.forEach(function(ER){return a($,ER)}),it&&Kr($,We),Ie}function xt($,P,F,ae){if(typeof F=="object"&&F!==null&&F.type===S&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case w:e:{for(var Ie=F.key;P!==null;){if(P.key===Ie){if(Ie=F.type,Ie===S){if(P.tag===7){o($,P.sibling),ae=p(P,F.props.children),ae.return=$,$=ae;break e}}else if(P.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===B&&ws(Ie)===P.type){o($,P.sibling),ae=p(P,F.props),Ho(ae,F),ae.return=$,$=ae;break e}o($,P);break}else a($,P);P=P.sibling}F.type===S?(ae=gs(F.props.children,$.mode,ae,F.key),ae.return=$,$=ae):(ae=Tc(F.type,F.key,F.props,null,$.mode,ae),Ho(ae,F),ae.return=$,$=ae)}return _($);case E:e:{for(Ie=F.key;P!==null;){if(P.key===Ie)if(P.tag===4&&P.stateNode.containerInfo===F.containerInfo&&P.stateNode.implementation===F.implementation){o($,P.sibling),ae=p(P,F.children||[]),ae.return=$,$=ae;break e}else{o($,P);break}else a($,P);P=P.sibling}ae=ih(F,$.mode,ae),ae.return=$,$=ae}return _($);case B:return F=ws(F),xt($,P,F,ae)}if(pe(F))return je($,P,F,ae);if(he(F)){if(Ie=he(F),typeof Ie!="function")throw Error(s(150));return F=Ie.call(F),Be($,P,F,ae)}if(typeof F.then=="function")return xt($,P,Lc(F),ae);if(F.$$typeof===T)return xt($,P,kc($,F),ae);Pc($,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,P!==null&&P.tag===6?(o($,P.sibling),ae=p(P,F),ae.return=$,$=ae):(o($,P),ae=sh(F,$.mode,ae),ae.return=$,$=ae),_($)):o($,P)}return function($,P,F,ae){try{Bo=0;var Ie=xt($,P,F,ae);return wi=null,Ie}catch(Me){if(Me===xi||Me===Mc)throw Me;var ut=In(29,Me,null,$.mode);return ut.lanes=ae,ut.return=$,ut}finally{}}}var Ss=Xy(!0),Jy=Xy(!1),Aa=!1;function yh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bh(r,a){r=r.updateQueue,a.updateQueue===r&&(a.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Ra(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function ka(r,a,o){var u=r.updateQueue;if(u===null)return null;if(u=u.shared,(ft&2)!==0){var p=u.pending;return p===null?a.next=a:(a.next=p.next,p.next=a),u.pending=a,a=jc(r),Dy(r,null,o),a}return Nc(r,u,a,o),jc(r)}function qo(r,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194048)!==0)){var u=a.lanes;u&=r.pendingLanes,o|=u,a.lanes=o,_n(r,o)}}function xh(r,a){var o=r.updateQueue,u=r.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var p=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var _={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?p=y=_:y=y.next=_,o=o.next}while(o!==null);y===null?p=y=a:y=y.next=a}else p=y=a;o={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:u.shared,callbacks:u.callbacks},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=a:r.next=a,o.lastBaseUpdate=a}var wh=!1;function Vo(){if(wh){var r=bi;if(r!==null)throw r}}function Fo(r,a,o,u){wh=!1;var p=r.updateQueue;Aa=!1;var y=p.firstBaseUpdate,_=p.lastBaseUpdate,j=p.shared.pending;if(j!==null){p.shared.pending=null;var D=j,G=D.next;D.next=null,_===null?y=G:_.next=G,_=D;var ne=r.alternate;ne!==null&&(ne=ne.updateQueue,j=ne.lastBaseUpdate,j!==_&&(j===null?ne.firstBaseUpdate=G:j.next=G,ne.lastBaseUpdate=D))}if(y!==null){var ie=p.baseState;_=0,ne=G=D=null,j=y;do{var Y=j.lane&-536870913,Z=Y!==j.lane;if(Z?(rt&Y)===Y:(u&Y)===Y){Y!==0&&Y===yi&&(wh=!0),ne!==null&&(ne=ne.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var je=r,Be=j;Y=a;var xt=o;switch(Be.tag){case 1:if(je=Be.payload,typeof je=="function"){ie=je.call(xt,ie,Y);break e}ie=je;break e;case 3:je.flags=je.flags&-65537|128;case 0:if(je=Be.payload,Y=typeof je=="function"?je.call(xt,ie,Y):je,Y==null)break e;ie=g({},ie,Y);break e;case 2:Aa=!0}}Y=j.callback,Y!==null&&(r.flags|=64,Z&&(r.flags|=8192),Z=p.callbacks,Z===null?p.callbacks=[Y]:Z.push(Y))}else Z={lane:Y,tag:j.tag,payload:j.payload,callback:j.callback,next:null},ne===null?(G=ne=Z,D=ie):ne=ne.next=Z,_|=Y;if(j=j.next,j===null){if(j=p.shared.pending,j===null)break;Z=j,j=Z.next,Z.next=null,p.lastBaseUpdate=Z,p.shared.pending=null}}while(!0);ne===null&&(D=ie),p.baseState=D,p.firstBaseUpdate=G,p.lastBaseUpdate=ne,y===null&&(p.shared.lanes=0),Pa|=_,r.lanes=_,r.memoizedState=ie}}function Qy(r,a){if(typeof r!="function")throw Error(s(191,r));r.call(a)}function Zy(r,a){var o=r.callbacks;if(o!==null)for(r.callbacks=null,r=0;r<o.length;r++)Qy(o[r],a)}var _i=R(null),zc=R(0);function eb(r,a){r=aa,I(zc,r),I(_i,a),aa=r|a.baseLanes}function _h(){I(zc,aa),I(_i,_i.current)}function Sh(){aa=zc.current,k(_i),k(zc)}var Un=R(null),er=null;function Oa(r){var a=r.alternate;I(Lt,Lt.current&1),I(Un,r),er===null&&(a===null||_i.current!==null||a.memoizedState!==null)&&(er=r)}function Eh(r){I(Lt,Lt.current),I(Un,r),er===null&&(er=r)}function tb(r){r.tag===22?(I(Lt,Lt.current),I(Un,r),er===null&&(er=r)):Ma()}function Ma(){I(Lt,Lt.current),I(Un,Un.current)}function $n(r){k(Un),er===r&&(er=null),k(Lt)}var Lt=R(0);function Ic(r){for(var a=r;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||Rm(o)||km(o)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Xr=0,Ke=null,yt=null,$t=null,Uc=!1,Si=!1,Es=!1,$c=0,Go=0,Ei=null,mA=0;function kt(){throw Error(s(321))}function Ch(r,a){if(a===null)return!1;for(var o=0;o<a.length&&o<r.length;o++)if(!zn(r[o],a[o]))return!1;return!0}function Nh(r,a,o,u,p,y){return Xr=y,Ke=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,O.H=r===null||r.memoizedState===null?Ib:Bh,Es=!1,y=o(u,p),Es=!1,Si&&(y=rb(a,o,u,p)),nb(r),y}function nb(r){O.H=Wo;var a=yt!==null&&yt.next!==null;if(Xr=0,$t=yt=Ke=null,Uc=!1,Go=0,Ei=null,a)throw Error(s(300));r===null||Bt||(r=r.dependencies,r!==null&&Rc(r)&&(Bt=!0))}function rb(r,a,o,u){Ke=r;var p=0;do{if(Si&&(Ei=null),Go=0,Si=!1,25<=p)throw Error(s(301));if(p+=1,$t=yt=null,r.updateQueue!=null){var y=r.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}O.H=Ub,y=a(o,u)}while(Si);return y}function pA(){var r=O.H,a=r.useState()[0];return a=typeof a.then=="function"?Ko(a):a,r=r.useState()[0],(yt!==null?yt.memoizedState:null)!==r&&(Ke.flags|=1024),a}function jh(){var r=$c!==0;return $c=0,r}function Th(r,a,o){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~o}function Ah(r){if(Uc){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Uc=!1}Xr=0,$t=yt=Ke=null,Si=!1,Go=$c=0,Ei=null}function vn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?Ke.memoizedState=$t=r:$t=$t.next=r,$t}function Pt(){if(yt===null){var r=Ke.alternate;r=r!==null?r.memoizedState:null}else r=yt.next;var a=$t===null?Ke.memoizedState:$t.next;if(a!==null)$t=a,yt=r;else{if(r===null)throw Ke.alternate===null?Error(s(467)):Error(s(310));yt=r,r={memoizedState:yt.memoizedState,baseState:yt.baseState,baseQueue:yt.baseQueue,queue:yt.queue,next:null},$t===null?Ke.memoizedState=$t=r:$t=$t.next=r}return $t}function Bc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ko(r){var a=Go;return Go+=1,Ei===null&&(Ei=[]),r=Ky(Ei,r,a),a=Ke,($t===null?a.memoizedState:$t.next)===null&&(a=a.alternate,O.H=a===null||a.memoizedState===null?Ib:Bh),r}function Hc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Ko(r);if(r.$$typeof===T)return an(r)}throw Error(s(438,String(r)))}function Rh(r){var a=null,o=Ke.updateQueue;if(o!==null&&(a=o.memoCache),a==null){var u=Ke.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(a={data:u.data.map(function(p){return p.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),o===null&&(o=Bc(),Ke.updateQueue=o),o.memoCache=a,o=a.data[a.index],o===void 0)for(o=a.data[a.index]=Array(r),u=0;u<r;u++)o[u]=ue;return a.index++,o}function Jr(r,a){return typeof a=="function"?a(r):a}function qc(r){var a=Pt();return kh(a,yt,r)}function kh(r,a,o){var u=r.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=o;var p=r.baseQueue,y=u.pending;if(y!==null){if(p!==null){var _=p.next;p.next=y.next,y.next=_}a.baseQueue=p=y,u.pending=null}if(y=r.baseState,p===null)r.memoizedState=y;else{a=p.next;var j=_=null,D=null,G=a,ne=!1;do{var ie=G.lane&-536870913;if(ie!==G.lane?(rt&ie)===ie:(Xr&ie)===ie){var Y=G.revertLane;if(Y===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ie===yi&&(ne=!0);else if((Xr&Y)===Y){G=G.next,Y===yi&&(ne=!0);continue}else ie={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(j=D=ie,_=y):D=D.next=ie,Ke.lanes|=Y,Pa|=Y;ie=G.action,Es&&o(y,ie),y=G.hasEagerState?G.eagerState:o(y,ie)}else Y={lane:ie,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(j=D=Y,_=y):D=D.next=Y,Ke.lanes|=ie,Pa|=ie;G=G.next}while(G!==null&&G!==a);if(D===null?_=y:D.next=j,!zn(y,r.memoizedState)&&(Bt=!0,ne&&(o=bi,o!==null)))throw o;r.memoizedState=y,r.baseState=_,r.baseQueue=D,u.lastRenderedState=y}return p===null&&(u.lanes=0),[r.memoizedState,u.dispatch]}function Oh(r){var a=Pt(),o=a.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=r;var u=o.dispatch,p=o.pending,y=a.memoizedState;if(p!==null){o.pending=null;var _=p=p.next;do y=r(y,_.action),_=_.next;while(_!==p);zn(y,a.memoizedState)||(Bt=!0),a.memoizedState=y,a.baseQueue===null&&(a.baseState=y),o.lastRenderedState=y}return[y,u]}function ab(r,a,o){var u=Ke,p=Pt(),y=it;if(y){if(o===void 0)throw Error(s(407));o=o()}else o=a();var _=!zn((yt||p).memoizedState,o);if(_&&(p.memoizedState=o,Bt=!0),p=p.queue,Lh(ob.bind(null,u,p,r),[r]),p.getSnapshot!==a||_||$t!==null&&$t.memoizedState.tag&1){if(u.flags|=2048,Ci(9,{destroy:void 0},ib.bind(null,u,p,o,a),null),wt===null)throw Error(s(349));y||(Xr&127)!==0||sb(u,a,o)}return o}function sb(r,a,o){r.flags|=16384,r={getSnapshot:a,value:o},a=Ke.updateQueue,a===null?(a=Bc(),Ke.updateQueue=a,a.stores=[r]):(o=a.stores,o===null?a.stores=[r]:o.push(r))}function ib(r,a,o,u){a.value=o,a.getSnapshot=u,lb(a)&&cb(r)}function ob(r,a,o){return o(function(){lb(a)&&cb(r)})}function lb(r){var a=r.getSnapshot;r=r.value;try{var o=a();return!zn(r,o)}catch{return!0}}function cb(r){var a=ps(r,2);a!==null&&Rn(a,r,2)}function Mh(r){var a=vn();if(typeof r=="function"){var o=r;if(r=o(),Es){Kt(!0);try{o()}finally{Kt(!1)}}}return a.memoizedState=a.baseState=r,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jr,lastRenderedState:r},a}function ub(r,a,o,u){return r.baseState=o,kh(r,yt,typeof u=="function"?u:Jr)}function gA(r,a,o,u,p){if(Gc(r))throw Error(s(485));if(r=a.action,r!==null){var y={payload:p,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){y.listeners.push(_)}};O.T!==null?o(!0):y.isTransition=!1,u(y),o=a.pending,o===null?(y.next=a.pending=y,db(a,y)):(y.next=o.next,a.pending=o.next=y)}}function db(r,a){var o=a.action,u=a.payload,p=r.state;if(a.isTransition){var y=O.T,_={};O.T=_;try{var j=o(p,u),D=O.S;D!==null&&D(_,j),fb(r,a,j)}catch(G){Dh(r,a,G)}finally{y!==null&&_.types!==null&&(y.types=_.types),O.T=y}}else try{y=o(p,u),fb(r,a,y)}catch(G){Dh(r,a,G)}}function fb(r,a,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(u){hb(r,a,u)},function(u){return Dh(r,a,u)}):hb(r,a,o)}function hb(r,a,o){a.status="fulfilled",a.value=o,mb(a),r.state=o,a=r.pending,a!==null&&(o=a.next,o===a?r.pending=null:(o=o.next,a.next=o,db(r,o)))}function Dh(r,a,o){var u=r.pending;if(r.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=o,mb(a),a=a.next;while(a!==u)}r.action=null}function mb(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function pb(r,a){return a}function gb(r,a){if(it){var o=wt.formState;if(o!==null){e:{var u=Ke;if(it){if(Et){t:{for(var p=Et,y=Zn;p.nodeType!==8;){if(!y){p=null;break t}if(p=tr(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){Et=tr(p.nextSibling),u=p.data==="F!";break e}}ja(u)}u=!1}u&&(a=o[0])}}return o=vn(),o.memoizedState=o.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:pb,lastRenderedState:a},o.queue=u,o=Lb.bind(null,Ke,u),u.dispatch=o,u=Mh(!1),y=$h.bind(null,Ke,!1,u.queue),u=vn(),p={state:a,dispatch:null,action:r,pending:null},u.queue=p,o=gA.bind(null,Ke,p,y,o),p.dispatch=o,u.memoizedState=r,[a,o,!1]}function vb(r){var a=Pt();return yb(a,yt,r)}function yb(r,a,o){if(a=kh(r,a,pb)[0],r=qc(Jr)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var u=Ko(a)}catch(_){throw _===xi?Mc:_}else u=a;a=Pt();var p=a.queue,y=p.dispatch;return o!==a.memoizedState&&(Ke.flags|=2048,Ci(9,{destroy:void 0},vA.bind(null,p,o),null)),[u,y,r]}function vA(r,a){r.action=a}function bb(r){var a=Pt(),o=yt;if(o!==null)return yb(a,o,r);Pt(),a=a.memoizedState,o=Pt();var u=o.queue.dispatch;return o.memoizedState=r,[a,u,!1]}function Ci(r,a,o,u){return r={tag:r,create:o,deps:u,inst:a,next:null},a=Ke.updateQueue,a===null&&(a=Bc(),Ke.updateQueue=a),o=a.lastEffect,o===null?a.lastEffect=r.next=r:(u=o.next,o.next=r,r.next=u,a.lastEffect=r),r}function xb(){return Pt().memoizedState}function Vc(r,a,o,u){var p=vn();Ke.flags|=r,p.memoizedState=Ci(1|a,{destroy:void 0},o,u===void 0?null:u)}function Fc(r,a,o,u){var p=Pt();u=u===void 0?null:u;var y=p.memoizedState.inst;yt!==null&&u!==null&&Ch(u,yt.memoizedState.deps)?p.memoizedState=Ci(a,y,o,u):(Ke.flags|=r,p.memoizedState=Ci(1|a,y,o,u))}function wb(r,a){Vc(8390656,8,r,a)}function Lh(r,a){Fc(2048,8,r,a)}function yA(r){Ke.flags|=4;var a=Ke.updateQueue;if(a===null)a=Bc(),Ke.updateQueue=a,a.events=[r];else{var o=a.events;o===null?a.events=[r]:o.push(r)}}function _b(r){var a=Pt().memoizedState;return yA({ref:a,nextImpl:r}),function(){if((ft&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}function Sb(r,a){return Fc(4,2,r,a)}function Eb(r,a){return Fc(4,4,r,a)}function Cb(r,a){if(typeof a=="function"){r=r();var o=a(r);return function(){typeof o=="function"?o():a(null)}}if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function Nb(r,a,o){o=o!=null?o.concat([r]):null,Fc(4,4,Cb.bind(null,a,r),o)}function Ph(){}function jb(r,a){var o=Pt();a=a===void 0?null:a;var u=o.memoizedState;return a!==null&&Ch(a,u[1])?u[0]:(o.memoizedState=[r,a],r)}function Tb(r,a){var o=Pt();a=a===void 0?null:a;var u=o.memoizedState;if(a!==null&&Ch(a,u[1]))return u[0];if(u=r(),Es){Kt(!0);try{r()}finally{Kt(!1)}}return o.memoizedState=[u,a],u}function zh(r,a,o){return o===void 0||(Xr&1073741824)!==0&&(rt&261930)===0?r.memoizedState=a:(r.memoizedState=o,r=A0(),Ke.lanes|=r,Pa|=r,o)}function Ab(r,a,o,u){return zn(o,a)?o:_i.current!==null?(r=zh(r,o,u),zn(r,a)||(Bt=!0),r):(Xr&42)===0||(Xr&1073741824)!==0&&(rt&261930)===0?(Bt=!0,r.memoizedState=o):(r=A0(),Ke.lanes|=r,Pa|=r,a)}function Rb(r,a,o,u,p){var y=K.p;K.p=y!==0&&8>y?y:8;var _=O.T,j={};O.T=j,$h(r,!1,a,o);try{var D=p(),G=O.S;if(G!==null&&G(j,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var ne=hA(D,u);Yo(r,a,ne,qn(r))}else Yo(r,a,u,qn(r))}catch(ie){Yo(r,a,{then:function(){},status:"rejected",reason:ie},qn())}finally{K.p=y,_!==null&&j.types!==null&&(_.types=j.types),O.T=_}}function bA(){}function Ih(r,a,o,u){if(r.tag!==5)throw Error(s(476));var p=kb(r).queue;Rb(r,p,a,W,o===null?bA:function(){return Ob(r),o(u)})}function kb(r){var a=r.memoizedState;if(a!==null)return a;a={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jr,lastRenderedState:W},next:null};var o={};return a.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jr,lastRenderedState:o},next:null},r.memoizedState=a,r=r.alternate,r!==null&&(r.memoizedState=a),a}function Ob(r){var a=kb(r);a.next===null&&(a=r.alternate.memoizedState),Yo(r,a.next.queue,{},qn())}function Uh(){return an(dl)}function Mb(){return Pt().memoizedState}function Db(){return Pt().memoizedState}function xA(r){for(var a=r.return;a!==null;){switch(a.tag){case 24:case 3:var o=qn();r=Ra(o);var u=ka(a,r,o);u!==null&&(Rn(u,a,o),qo(u,a,o)),a={cache:mh()},r.payload=a;return}a=a.return}}function wA(r,a,o){var u=qn();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Gc(r)?Pb(a,o):(o=rh(r,a,o,u),o!==null&&(Rn(o,r,u),zb(o,a,u)))}function Lb(r,a,o){var u=qn();Yo(r,a,o,u)}function Yo(r,a,o,u){var p={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Gc(r))Pb(a,p);else{var y=r.alternate;if(r.lanes===0&&(y===null||y.lanes===0)&&(y=a.lastRenderedReducer,y!==null))try{var _=a.lastRenderedState,j=y(_,o);if(p.hasEagerState=!0,p.eagerState=j,zn(j,_))return Nc(r,a,p,0),wt===null&&Cc(),!1}catch{}finally{}if(o=rh(r,a,p,u),o!==null)return Rn(o,r,u),zb(o,a,u),!0}return!1}function $h(r,a,o,u){if(u={lane:2,revertLane:ym(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Gc(r)){if(a)throw Error(s(479))}else a=rh(r,o,u,2),a!==null&&Rn(a,r,2)}function Gc(r){var a=r.alternate;return r===Ke||a!==null&&a===Ke}function Pb(r,a){Si=Uc=!0;var o=r.pending;o===null?a.next=a:(a.next=o.next,o.next=a),r.pending=a}function zb(r,a,o){if((o&4194048)!==0){var u=a.lanes;u&=r.pendingLanes,o|=u,a.lanes=o,_n(r,o)}}var Wo={readContext:an,use:Hc,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useLayoutEffect:kt,useInsertionEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useSyncExternalStore:kt,useId:kt,useHostTransitionStatus:kt,useFormState:kt,useActionState:kt,useOptimistic:kt,useMemoCache:kt,useCacheRefresh:kt};Wo.useEffectEvent=kt;var Ib={readContext:an,use:Hc,useCallback:function(r,a){return vn().memoizedState=[r,a===void 0?null:a],r},useContext:an,useEffect:wb,useImperativeHandle:function(r,a,o){o=o!=null?o.concat([r]):null,Vc(4194308,4,Cb.bind(null,a,r),o)},useLayoutEffect:function(r,a){return Vc(4194308,4,r,a)},useInsertionEffect:function(r,a){Vc(4,2,r,a)},useMemo:function(r,a){var o=vn();a=a===void 0?null:a;var u=r();if(Es){Kt(!0);try{r()}finally{Kt(!1)}}return o.memoizedState=[u,a],u},useReducer:function(r,a,o){var u=vn();if(o!==void 0){var p=o(a);if(Es){Kt(!0);try{o(a)}finally{Kt(!1)}}}else p=a;return u.memoizedState=u.baseState=p,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:p},u.queue=r,r=r.dispatch=wA.bind(null,Ke,r),[u.memoizedState,r]},useRef:function(r){var a=vn();return r={current:r},a.memoizedState=r},useState:function(r){r=Mh(r);var a=r.queue,o=Lb.bind(null,Ke,a);return a.dispatch=o,[r.memoizedState,o]},useDebugValue:Ph,useDeferredValue:function(r,a){var o=vn();return zh(o,r,a)},useTransition:function(){var r=Mh(!1);return r=Rb.bind(null,Ke,r.queue,!0,!1),vn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,a,o){var u=Ke,p=vn();if(it){if(o===void 0)throw Error(s(407));o=o()}else{if(o=a(),wt===null)throw Error(s(349));(rt&127)!==0||sb(u,a,o)}p.memoizedState=o;var y={value:o,getSnapshot:a};return p.queue=y,wb(ob.bind(null,u,y,r),[r]),u.flags|=2048,Ci(9,{destroy:void 0},ib.bind(null,u,y,o,a),null),o},useId:function(){var r=vn(),a=wt.identifierPrefix;if(it){var o=Nr,u=Cr;o=(u&~(1<<32-Tt(u)-1)).toString(32)+o,a="_"+a+"R_"+o,o=$c++,0<o&&(a+="H"+o.toString(32)),a+="_"}else o=mA++,a="_"+a+"r_"+o.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:Uh,useFormState:gb,useActionState:gb,useOptimistic:function(r){var a=vn();a.memoizedState=a.baseState=r;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=o,a=$h.bind(null,Ke,!0,o),o.dispatch=a,[r,a]},useMemoCache:Rh,useCacheRefresh:function(){return vn().memoizedState=xA.bind(null,Ke)},useEffectEvent:function(r){var a=vn(),o={impl:r};return a.memoizedState=o,function(){if((ft&2)!==0)throw Error(s(440));return o.impl.apply(void 0,arguments)}}},Bh={readContext:an,use:Hc,useCallback:jb,useContext:an,useEffect:Lh,useImperativeHandle:Nb,useInsertionEffect:Sb,useLayoutEffect:Eb,useMemo:Tb,useReducer:qc,useRef:xb,useState:function(){return qc(Jr)},useDebugValue:Ph,useDeferredValue:function(r,a){var o=Pt();return Ab(o,yt.memoizedState,r,a)},useTransition:function(){var r=qc(Jr)[0],a=Pt().memoizedState;return[typeof r=="boolean"?r:Ko(r),a]},useSyncExternalStore:ab,useId:Mb,useHostTransitionStatus:Uh,useFormState:vb,useActionState:vb,useOptimistic:function(r,a){var o=Pt();return ub(o,yt,r,a)},useMemoCache:Rh,useCacheRefresh:Db};Bh.useEffectEvent=_b;var Ub={readContext:an,use:Hc,useCallback:jb,useContext:an,useEffect:Lh,useImperativeHandle:Nb,useInsertionEffect:Sb,useLayoutEffect:Eb,useMemo:Tb,useReducer:Oh,useRef:xb,useState:function(){return Oh(Jr)},useDebugValue:Ph,useDeferredValue:function(r,a){var o=Pt();return yt===null?zh(o,r,a):Ab(o,yt.memoizedState,r,a)},useTransition:function(){var r=Oh(Jr)[0],a=Pt().memoizedState;return[typeof r=="boolean"?r:Ko(r),a]},useSyncExternalStore:ab,useId:Mb,useHostTransitionStatus:Uh,useFormState:bb,useActionState:bb,useOptimistic:function(r,a){var o=Pt();return yt!==null?ub(o,yt,r,a):(o.baseState=r,[r,o.queue.dispatch])},useMemoCache:Rh,useCacheRefresh:Db};Ub.useEffectEvent=_b;function Hh(r,a,o,u){a=r.memoizedState,o=o(u,a),o=o==null?a:g({},a,o),r.memoizedState=o,r.lanes===0&&(r.updateQueue.baseState=o)}var qh={enqueueSetState:function(r,a,o){r=r._reactInternals;var u=qn(),p=Ra(u);p.payload=a,o!=null&&(p.callback=o),a=ka(r,p,u),a!==null&&(Rn(a,r,u),qo(a,r,u))},enqueueReplaceState:function(r,a,o){r=r._reactInternals;var u=qn(),p=Ra(u);p.tag=1,p.payload=a,o!=null&&(p.callback=o),a=ka(r,p,u),a!==null&&(Rn(a,r,u),qo(a,r,u))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var o=qn(),u=Ra(o);u.tag=2,a!=null&&(u.callback=a),a=ka(r,u,o),a!==null&&(Rn(a,r,o),qo(a,r,o))}};function $b(r,a,o,u,p,y,_){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(u,y,_):a.prototype&&a.prototype.isPureReactComponent?!Lo(o,u)||!Lo(p,y):!0}function Bb(r,a,o,u){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(o,u),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(o,u),a.state!==r&&qh.enqueueReplaceState(a,a.state,null)}function Cs(r,a){var o=a;if("ref"in a){o={};for(var u in a)u!=="ref"&&(o[u]=a[u])}if(r=r.defaultProps){o===a&&(o=g({},o));for(var p in r)o[p]===void 0&&(o[p]=r[p])}return o}function Hb(r){Ec(r)}function qb(r){console.error(r)}function Vb(r){Ec(r)}function Kc(r,a){try{var o=r.onUncaughtError;o(a.value,{componentStack:a.stack})}catch(u){setTimeout(function(){throw u})}}function Fb(r,a,o){try{var u=r.onCaughtError;u(o.value,{componentStack:o.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function Vh(r,a,o){return o=Ra(o),o.tag=3,o.payload={element:null},o.callback=function(){Kc(r,a)},o}function Gb(r){return r=Ra(r),r.tag=3,r}function Kb(r,a,o,u){var p=o.type.getDerivedStateFromError;if(typeof p=="function"){var y=u.value;r.payload=function(){return p(y)},r.callback=function(){Fb(a,o,u)}}var _=o.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(r.callback=function(){Fb(a,o,u),typeof p!="function"&&(za===null?za=new Set([this]):za.add(this));var j=u.stack;this.componentDidCatch(u.value,{componentStack:j!==null?j:""})})}function _A(r,a,o,u,p){if(o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(a=o.alternate,a!==null&&vi(a,o,p,!0),o=Un.current,o!==null){switch(o.tag){case 31:case 13:return er===null?su():o.alternate===null&&Ot===0&&(Ot=3),o.flags&=-257,o.flags|=65536,o.lanes=p,u===Dc?o.flags|=16384:(a=o.updateQueue,a===null?o.updateQueue=new Set([u]):a.add(u),pm(r,u,p)),!1;case 22:return o.flags|=65536,u===Dc?o.flags|=16384:(a=o.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([u])},o.updateQueue=a):(o=a.retryQueue,o===null?a.retryQueue=new Set([u]):o.add(u)),pm(r,u,p)),!1}throw Error(s(435,o.tag))}return pm(r,u,p),su(),!1}if(it)return a=Un.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=p,u!==ch&&(r=Error(s(422),{cause:u}),Io(Xn(r,o)))):(u!==ch&&(a=Error(s(423),{cause:u}),Io(Xn(a,o))),r=r.current.alternate,r.flags|=65536,p&=-p,r.lanes|=p,u=Xn(u,o),p=Vh(r.stateNode,u,p),xh(r,p),Ot!==4&&(Ot=2)),!1;var y=Error(s(520),{cause:u});if(y=Xn(y,o),rl===null?rl=[y]:rl.push(y),Ot!==4&&(Ot=2),a===null)return!0;u=Xn(u,o),o=a;do{switch(o.tag){case 3:return o.flags|=65536,r=p&-p,o.lanes|=r,r=Vh(o.stateNode,u,r),xh(o,r),!1;case 1:if(a=o.type,y=o.stateNode,(o.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(za===null||!za.has(y))))return o.flags|=65536,p&=-p,o.lanes|=p,p=Gb(p),Kb(p,r,o,u),xh(o,p),!1}o=o.return}while(o!==null);return!1}var Fh=Error(s(461)),Bt=!1;function sn(r,a,o,u){a.child=r===null?Jy(a,null,o,u):Ss(a,r.child,o,u)}function Yb(r,a,o,u,p){o=o.render;var y=a.ref;if("ref"in u){var _={};for(var j in u)j!=="ref"&&(_[j]=u[j])}else _=u;return bs(a),u=Nh(r,a,o,_,y,p),j=jh(),r!==null&&!Bt?(Th(r,a,p),Qr(r,a,p)):(it&&j&&oh(a),a.flags|=1,sn(r,a,u,p),a.child)}function Wb(r,a,o,u,p){if(r===null){var y=o.type;return typeof y=="function"&&!ah(y)&&y.defaultProps===void 0&&o.compare===null?(a.tag=15,a.type=y,Xb(r,a,y,u,p)):(r=Tc(o.type,null,u,a,a.mode,p),r.ref=a.ref,r.return=a,a.child=r)}if(y=r.child,!Zh(r,p)){var _=y.memoizedProps;if(o=o.compare,o=o!==null?o:Lo,o(_,u)&&r.ref===a.ref)return Qr(r,a,p)}return a.flags|=1,r=Gr(y,u),r.ref=a.ref,r.return=a,a.child=r}function Xb(r,a,o,u,p){if(r!==null){var y=r.memoizedProps;if(Lo(y,u)&&r.ref===a.ref)if(Bt=!1,a.pendingProps=u=y,Zh(r,p))(r.flags&131072)!==0&&(Bt=!0);else return a.lanes=r.lanes,Qr(r,a,p)}return Gh(r,a,o,u,p)}function Jb(r,a,o,u){var p=u.children,y=r!==null?r.memoizedState:null;if(r===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((a.flags&128)!==0){if(y=y!==null?y.baseLanes|o:o,r!==null){for(u=a.child=r.child,p=0;u!==null;)p=p|u.lanes|u.childLanes,u=u.sibling;u=p&~y}else u=0,a.child=null;return Qb(r,a,y,o,u)}if((o&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},r!==null&&Oc(a,y!==null?y.cachePool:null),y!==null?eb(a,y):_h(),tb(a);else return u=a.lanes=536870912,Qb(r,a,y!==null?y.baseLanes|o:o,o,u)}else y!==null?(Oc(a,y.cachePool),eb(a,y),Ma(),a.memoizedState=null):(r!==null&&Oc(a,null),_h(),Ma());return sn(r,a,p,o),a.child}function Xo(r,a){return r!==null&&r.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Qb(r,a,o,u,p){var y=gh();return y=y===null?null:{parent:Ut._currentValue,pool:y},a.memoizedState={baseLanes:o,cachePool:y},r!==null&&Oc(a,null),_h(),tb(a),r!==null&&vi(r,a,u,!0),a.childLanes=p,null}function Yc(r,a){return a=Xc({mode:a.mode,children:a.children},r.mode),a.ref=r.ref,r.child=a,a.return=r,a}function Zb(r,a,o){return Ss(a,r.child,null,o),r=Yc(a,a.pendingProps),r.flags|=2,$n(a),a.memoizedState=null,r}function SA(r,a,o){var u=a.pendingProps,p=(a.flags&128)!==0;if(a.flags&=-129,r===null){if(it){if(u.mode==="hidden")return r=Yc(a,u),a.lanes=536870912,Xo(null,r);if(Eh(a),(r=Et)?(r=dx(r,Zn),r=r!==null&&r.data==="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:Ca!==null?{id:Cr,overflow:Nr}:null,retryLane:536870912,hydrationErrors:null},o=Py(r),o.return=a,a.child=o,rn=a,Et=null)):r=null,r===null)throw ja(a);return a.lanes=536870912,null}return Yc(a,u)}var y=r.memoizedState;if(y!==null){var _=y.dehydrated;if(Eh(a),p)if(a.flags&256)a.flags&=-257,a=Zb(r,a,o);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(s(558));else if(Bt||vi(r,a,o,!1),p=(o&r.childLanes)!==0,Bt||p){if(u=wt,u!==null&&(_=Sn(u,o),_!==0&&_!==y.retryLane))throw y.retryLane=_,ps(r,_),Rn(u,r,_),Fh;su(),a=Zb(r,a,o)}else r=y.treeContext,Et=tr(_.nextSibling),rn=a,it=!0,Na=null,Zn=!1,r!==null&&Uy(a,r),a=Yc(a,u),a.flags|=4096;return a}return r=Gr(r.child,{mode:u.mode,children:u.children}),r.ref=a.ref,a.child=r,r.return=a,r}function Wc(r,a){var o=a.ref;if(o===null)r!==null&&r.ref!==null&&(a.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(s(284));(r===null||r.ref!==o)&&(a.flags|=4194816)}}function Gh(r,a,o,u,p){return bs(a),o=Nh(r,a,o,u,void 0,p),u=jh(),r!==null&&!Bt?(Th(r,a,p),Qr(r,a,p)):(it&&u&&oh(a),a.flags|=1,sn(r,a,o,p),a.child)}function e0(r,a,o,u,p,y){return bs(a),a.updateQueue=null,o=rb(a,u,o,p),nb(r),u=jh(),r!==null&&!Bt?(Th(r,a,y),Qr(r,a,y)):(it&&u&&oh(a),a.flags|=1,sn(r,a,o,y),a.child)}function t0(r,a,o,u,p){if(bs(a),a.stateNode===null){var y=hi,_=o.contextType;typeof _=="object"&&_!==null&&(y=an(_)),y=new o(u,y),a.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=qh,a.stateNode=y,y._reactInternals=a,y=a.stateNode,y.props=u,y.state=a.memoizedState,y.refs={},yh(a),_=o.contextType,y.context=typeof _=="object"&&_!==null?an(_):hi,y.state=a.memoizedState,_=o.getDerivedStateFromProps,typeof _=="function"&&(Hh(a,o,_,u),y.state=a.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(_=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),_!==y.state&&qh.enqueueReplaceState(y,y.state,null),Fo(a,u,y,p),Vo(),y.state=a.memoizedState),typeof y.componentDidMount=="function"&&(a.flags|=4194308),u=!0}else if(r===null){y=a.stateNode;var j=a.memoizedProps,D=Cs(o,j);y.props=D;var G=y.context,ne=o.contextType;_=hi,typeof ne=="object"&&ne!==null&&(_=an(ne));var ie=o.getDerivedStateFromProps;ne=typeof ie=="function"||typeof y.getSnapshotBeforeUpdate=="function",j=a.pendingProps!==j,ne||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(j||G!==_)&&Bb(a,y,u,_),Aa=!1;var Y=a.memoizedState;y.state=Y,Fo(a,u,y,p),Vo(),G=a.memoizedState,j||Y!==G||Aa?(typeof ie=="function"&&(Hh(a,o,ie,u),G=a.memoizedState),(D=Aa||$b(a,o,D,u,Y,G,_))?(ne||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(a.flags|=4194308)):(typeof y.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=u,a.memoizedState=G),y.props=u,y.state=G,y.context=_,u=D):(typeof y.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{y=a.stateNode,bh(r,a),_=a.memoizedProps,ne=Cs(o,_),y.props=ne,ie=a.pendingProps,Y=y.context,G=o.contextType,D=hi,typeof G=="object"&&G!==null&&(D=an(G)),j=o.getDerivedStateFromProps,(G=typeof j=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(_!==ie||Y!==D)&&Bb(a,y,u,D),Aa=!1,Y=a.memoizedState,y.state=Y,Fo(a,u,y,p),Vo();var Z=a.memoizedState;_!==ie||Y!==Z||Aa||r!==null&&r.dependencies!==null&&Rc(r.dependencies)?(typeof j=="function"&&(Hh(a,o,j,u),Z=a.memoizedState),(ne=Aa||$b(a,o,ne,u,Y,Z,D)||r!==null&&r.dependencies!==null&&Rc(r.dependencies))?(G||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,Z,D),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,Z,D)),typeof y.componentDidUpdate=="function"&&(a.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof y.componentDidUpdate!="function"||_===r.memoizedProps&&Y===r.memoizedState||(a.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||_===r.memoizedProps&&Y===r.memoizedState||(a.flags|=1024),a.memoizedProps=u,a.memoizedState=Z),y.props=u,y.state=Z,y.context=D,u=ne):(typeof y.componentDidUpdate!="function"||_===r.memoizedProps&&Y===r.memoizedState||(a.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||_===r.memoizedProps&&Y===r.memoizedState||(a.flags|=1024),u=!1)}return y=u,Wc(r,a),u=(a.flags&128)!==0,y||u?(y=a.stateNode,o=u&&typeof o.getDerivedStateFromError!="function"?null:y.render(),a.flags|=1,r!==null&&u?(a.child=Ss(a,r.child,null,p),a.child=Ss(a,null,o,p)):sn(r,a,o,p),a.memoizedState=y.state,r=a.child):r=Qr(r,a,p),r}function n0(r,a,o,u){return vs(),a.flags|=256,sn(r,a,o,u),a.child}var Kh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Yh(r){return{baseLanes:r,cachePool:Fy()}}function Wh(r,a,o){return r=r!==null?r.childLanes&~o:0,a&&(r|=Hn),r}function r0(r,a,o){var u=a.pendingProps,p=!1,y=(a.flags&128)!==0,_;if((_=y)||(_=r!==null&&r.memoizedState===null?!1:(Lt.current&2)!==0),_&&(p=!0,a.flags&=-129),_=(a.flags&32)!==0,a.flags&=-33,r===null){if(it){if(p?Oa(a):Ma(),(r=Et)?(r=dx(r,Zn),r=r!==null&&r.data!=="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:Ca!==null?{id:Cr,overflow:Nr}:null,retryLane:536870912,hydrationErrors:null},o=Py(r),o.return=a,a.child=o,rn=a,Et=null)):r=null,r===null)throw ja(a);return km(r)?a.lanes=32:a.lanes=536870912,null}var j=u.children;return u=u.fallback,p?(Ma(),p=a.mode,j=Xc({mode:"hidden",children:j},p),u=gs(u,p,o,null),j.return=a,u.return=a,j.sibling=u,a.child=j,u=a.child,u.memoizedState=Yh(o),u.childLanes=Wh(r,_,o),a.memoizedState=Kh,Xo(null,u)):(Oa(a),Xh(a,j))}var D=r.memoizedState;if(D!==null&&(j=D.dehydrated,j!==null)){if(y)a.flags&256?(Oa(a),a.flags&=-257,a=Jh(r,a,o)):a.memoizedState!==null?(Ma(),a.child=r.child,a.flags|=128,a=null):(Ma(),j=u.fallback,p=a.mode,u=Xc({mode:"visible",children:u.children},p),j=gs(j,p,o,null),j.flags|=2,u.return=a,j.return=a,u.sibling=j,a.child=u,Ss(a,r.child,null,o),u=a.child,u.memoizedState=Yh(o),u.childLanes=Wh(r,_,o),a.memoizedState=Kh,a=Xo(null,u));else if(Oa(a),km(j)){if(_=j.nextSibling&&j.nextSibling.dataset,_)var G=_.dgst;_=G,u=Error(s(419)),u.stack="",u.digest=_,Io({value:u,source:null,stack:null}),a=Jh(r,a,o)}else if(Bt||vi(r,a,o,!1),_=(o&r.childLanes)!==0,Bt||_){if(_=wt,_!==null&&(u=Sn(_,o),u!==0&&u!==D.retryLane))throw D.retryLane=u,ps(r,u),Rn(_,r,u),Fh;Rm(j)||su(),a=Jh(r,a,o)}else Rm(j)?(a.flags|=192,a.child=r.child,a=null):(r=D.treeContext,Et=tr(j.nextSibling),rn=a,it=!0,Na=null,Zn=!1,r!==null&&Uy(a,r),a=Xh(a,u.children),a.flags|=4096);return a}return p?(Ma(),j=u.fallback,p=a.mode,D=r.child,G=D.sibling,u=Gr(D,{mode:"hidden",children:u.children}),u.subtreeFlags=D.subtreeFlags&65011712,G!==null?j=Gr(G,j):(j=gs(j,p,o,null),j.flags|=2),j.return=a,u.return=a,u.sibling=j,a.child=u,Xo(null,u),u=a.child,j=r.child.memoizedState,j===null?j=Yh(o):(p=j.cachePool,p!==null?(D=Ut._currentValue,p=p.parent!==D?{parent:D,pool:D}:p):p=Fy(),j={baseLanes:j.baseLanes|o,cachePool:p}),u.memoizedState=j,u.childLanes=Wh(r,_,o),a.memoizedState=Kh,Xo(r.child,u)):(Oa(a),o=r.child,r=o.sibling,o=Gr(o,{mode:"visible",children:u.children}),o.return=a,o.sibling=null,r!==null&&(_=a.deletions,_===null?(a.deletions=[r],a.flags|=16):_.push(r)),a.child=o,a.memoizedState=null,o)}function Xh(r,a){return a=Xc({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function Xc(r,a){return r=In(22,r,null,a),r.lanes=0,r}function Jh(r,a,o){return Ss(a,r.child,null,o),r=Xh(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function a0(r,a,o){r.lanes|=a;var u=r.alternate;u!==null&&(u.lanes|=a),fh(r.return,a,o)}function Qh(r,a,o,u,p,y){var _=r.memoizedState;_===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:u,tail:o,tailMode:p,treeForkCount:y}:(_.isBackwards=a,_.rendering=null,_.renderingStartTime=0,_.last=u,_.tail=o,_.tailMode=p,_.treeForkCount=y)}function s0(r,a,o){var u=a.pendingProps,p=u.revealOrder,y=u.tail;u=u.children;var _=Lt.current,j=(_&2)!==0;if(j?(_=_&1|2,a.flags|=128):_&=1,I(Lt,_),sn(r,a,u,o),u=it?zo:0,!j&&r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&a0(r,o,a);else if(r.tag===19)a0(r,o,a);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===a)break e;for(;r.sibling===null;){if(r.return===null||r.return===a)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(p){case"forwards":for(o=a.child,p=null;o!==null;)r=o.alternate,r!==null&&Ic(r)===null&&(p=o),o=o.sibling;o=p,o===null?(p=a.child,a.child=null):(p=o.sibling,o.sibling=null),Qh(a,!1,p,o,y,u);break;case"backwards":case"unstable_legacy-backwards":for(o=null,p=a.child,a.child=null;p!==null;){if(r=p.alternate,r!==null&&Ic(r)===null){a.child=p;break}r=p.sibling,p.sibling=o,o=p,p=r}Qh(a,!0,o,null,y,u);break;case"together":Qh(a,!1,null,null,void 0,u);break;default:a.memoizedState=null}return a.child}function Qr(r,a,o){if(r!==null&&(a.dependencies=r.dependencies),Pa|=a.lanes,(o&a.childLanes)===0)if(r!==null){if(vi(r,a,o,!1),(o&a.childLanes)===0)return null}else return null;if(r!==null&&a.child!==r.child)throw Error(s(153));if(a.child!==null){for(r=a.child,o=Gr(r,r.pendingProps),a.child=o,o.return=a;r.sibling!==null;)r=r.sibling,o=o.sibling=Gr(r,r.pendingProps),o.return=a;o.sibling=null}return a.child}function Zh(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&Rc(r)))}function EA(r,a,o){switch(a.tag){case 3:Q(a,a.stateNode.containerInfo),Ta(a,Ut,r.memoizedState.cache),vs();break;case 27:case 5:Ne(a);break;case 4:Q(a,a.stateNode.containerInfo);break;case 10:Ta(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Eh(a),null;break;case 13:var u=a.memoizedState;if(u!==null)return u.dehydrated!==null?(Oa(a),a.flags|=128,null):(o&a.child.childLanes)!==0?r0(r,a,o):(Oa(a),r=Qr(r,a,o),r!==null?r.sibling:null);Oa(a);break;case 19:var p=(r.flags&128)!==0;if(u=(o&a.childLanes)!==0,u||(vi(r,a,o,!1),u=(o&a.childLanes)!==0),p){if(u)return s0(r,a,o);a.flags|=128}if(p=a.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),I(Lt,Lt.current),u)break;return null;case 22:return a.lanes=0,Jb(r,a,o,a.pendingProps);case 24:Ta(a,Ut,r.memoizedState.cache)}return Qr(r,a,o)}function i0(r,a,o){if(r!==null)if(r.memoizedProps!==a.pendingProps)Bt=!0;else{if(!Zh(r,o)&&(a.flags&128)===0)return Bt=!1,EA(r,a,o);Bt=(r.flags&131072)!==0}else Bt=!1,it&&(a.flags&1048576)!==0&&Iy(a,zo,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(r=ws(a.elementType),a.type=r,typeof r=="function")ah(r)?(u=Cs(r,u),a.tag=1,a=t0(null,a,r,u,o)):(a.tag=0,a=Gh(null,a,r,u,o));else{if(r!=null){var p=r.$$typeof;if(p===M){a.tag=11,a=Yb(null,a,r,u,o);break e}else if(p===L){a.tag=14,a=Wb(null,a,r,u,o);break e}}throw a=ve(r)||r,Error(s(306,a,""))}}return a;case 0:return Gh(r,a,a.type,a.pendingProps,o);case 1:return u=a.type,p=Cs(u,a.pendingProps),t0(r,a,u,p,o);case 3:e:{if(Q(a,a.stateNode.containerInfo),r===null)throw Error(s(387));u=a.pendingProps;var y=a.memoizedState;p=y.element,bh(r,a),Fo(a,u,null,o);var _=a.memoizedState;if(u=_.cache,Ta(a,Ut,u),u!==y.cache&&hh(a,[Ut],o,!0),Vo(),u=_.element,y.isDehydrated)if(y={element:u,isDehydrated:!1,cache:_.cache},a.updateQueue.baseState=y,a.memoizedState=y,a.flags&256){a=n0(r,a,u,o);break e}else if(u!==p){p=Xn(Error(s(424)),a),Io(p),a=n0(r,a,u,o);break e}else{switch(r=a.stateNode.containerInfo,r.nodeType){case 9:r=r.body;break;default:r=r.nodeName==="HTML"?r.ownerDocument.body:r}for(Et=tr(r.firstChild),rn=a,it=!0,Na=null,Zn=!0,o=Jy(a,null,u,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling}else{if(vs(),u===p){a=Qr(r,a,o);break e}sn(r,a,u,o)}a=a.child}return a;case 26:return Wc(r,a),r===null?(o=vx(a.type,null,a.pendingProps,null))?a.memoizedState=o:it||(o=a.type,r=a.pendingProps,u=fu(te.current).createElement(o),u[nn]=a,u[En]=r,on(u,o,r),Jt(u),a.stateNode=u):a.memoizedState=vx(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return Ne(a),r===null&&it&&(u=a.stateNode=mx(a.type,a.pendingProps,te.current),rn=a,Zn=!0,p=Et,Ba(a.type)?(Om=p,Et=tr(u.firstChild)):Et=p),sn(r,a,a.pendingProps.children,o),Wc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&it&&((p=u=Et)&&(u=eR(u,a.type,a.pendingProps,Zn),u!==null?(a.stateNode=u,rn=a,Et=tr(u.firstChild),Zn=!1,p=!0):p=!1),p||ja(a)),Ne(a),p=a.type,y=a.pendingProps,_=r!==null?r.memoizedProps:null,u=y.children,jm(p,y)?u=null:_!==null&&jm(p,_)&&(a.flags|=32),a.memoizedState!==null&&(p=Nh(r,a,pA,null,null,o),dl._currentValue=p),Wc(r,a),sn(r,a,u,o),a.child;case 6:return r===null&&it&&((r=o=Et)&&(o=tR(o,a.pendingProps,Zn),o!==null?(a.stateNode=o,rn=a,Et=null,r=!0):r=!1),r||ja(a)),null;case 13:return r0(r,a,o);case 4:return Q(a,a.stateNode.containerInfo),u=a.pendingProps,r===null?a.child=Ss(a,null,u,o):sn(r,a,u,o),a.child;case 11:return Yb(r,a,a.type,a.pendingProps,o);case 7:return sn(r,a,a.pendingProps,o),a.child;case 8:return sn(r,a,a.pendingProps.children,o),a.child;case 12:return sn(r,a,a.pendingProps.children,o),a.child;case 10:return u=a.pendingProps,Ta(a,a.type,u.value),sn(r,a,u.children,o),a.child;case 9:return p=a.type._context,u=a.pendingProps.children,bs(a),p=an(p),u=u(p),a.flags|=1,sn(r,a,u,o),a.child;case 14:return Wb(r,a,a.type,a.pendingProps,o);case 15:return Xb(r,a,a.type,a.pendingProps,o);case 19:return s0(r,a,o);case 31:return SA(r,a,o);case 22:return Jb(r,a,o,a.pendingProps);case 24:return bs(a),u=an(Ut),r===null?(p=gh(),p===null&&(p=wt,y=mh(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=o),p=y),a.memoizedState={parent:u,cache:p},yh(a),Ta(a,Ut,p)):((r.lanes&o)!==0&&(bh(r,a),Fo(a,null,null,o),Vo()),p=r.memoizedState,y=a.memoizedState,p.parent!==u?(p={parent:u,cache:u},a.memoizedState=p,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=p),Ta(a,Ut,u)):(u=y.cache,Ta(a,Ut,u),u!==p.cache&&hh(a,[Ut],o,!0))),sn(r,a,a.pendingProps.children,o),a.child;case 29:throw a.pendingProps}throw Error(s(156,a.tag))}function Zr(r){r.flags|=4}function em(r,a,o,u,p){if((a=(r.mode&32)!==0)&&(a=!1),a){if(r.flags|=16777216,(p&335544128)===p)if(r.stateNode.complete)r.flags|=8192;else if(M0())r.flags|=8192;else throw _s=Dc,vh}else r.flags&=-16777217}function o0(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!_x(a))if(M0())r.flags|=8192;else throw _s=Dc,vh}function Jc(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?hn():536870912,r.lanes|=a,Ai|=a)}function Jo(r,a){if(!it)switch(r.tailMode){case"hidden":a=r.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:u.sibling=null}}function Ct(r){var a=r.alternate!==null&&r.alternate.child===r.child,o=0,u=0;if(a)for(var p=r.child;p!==null;)o|=p.lanes|p.childLanes,u|=p.subtreeFlags&65011712,u|=p.flags&65011712,p.return=r,p=p.sibling;else for(p=r.child;p!==null;)o|=p.lanes|p.childLanes,u|=p.subtreeFlags,u|=p.flags,p.return=r,p=p.sibling;return r.subtreeFlags|=u,r.childLanes=o,a}function CA(r,a,o){var u=a.pendingProps;switch(lh(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ct(a),null;case 1:return Ct(a),null;case 3:return o=a.stateNode,u=null,r!==null&&(u=r.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),Wr(Ut),re(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(r===null||r.child===null)&&(gi(a)?Zr(a):r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,uh())),Ct(a),null;case 26:var p=a.type,y=a.memoizedState;return r===null?(Zr(a),y!==null?(Ct(a),o0(a,y)):(Ct(a),em(a,p,null,u,o))):y?y!==r.memoizedState?(Zr(a),Ct(a),o0(a,y)):(Ct(a),a.flags&=-16777217):(r=r.memoizedProps,r!==u&&Zr(a),Ct(a),em(a,p,r,u,o)),null;case 27:if(ze(a),o=te.current,p=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Zr(a);else{if(!u){if(a.stateNode===null)throw Error(s(166));return Ct(a),null}r=X.current,gi(a)?$y(a):(r=mx(p,u,o),a.stateNode=r,Zr(a))}return Ct(a),null;case 5:if(ze(a),p=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Zr(a);else{if(!u){if(a.stateNode===null)throw Error(s(166));return Ct(a),null}if(y=X.current,gi(a))$y(a);else{var _=fu(te.current);switch(y){case 1:y=_.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=_.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=_.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=_.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=_.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof u.is=="string"?_.createElement("select",{is:u.is}):_.createElement("select"),u.multiple?y.multiple=!0:u.size&&(y.size=u.size);break;default:y=typeof u.is=="string"?_.createElement(p,{is:u.is}):_.createElement(p)}}y[nn]=a,y[En]=u;e:for(_=a.child;_!==null;){if(_.tag===5||_.tag===6)y.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===a)break e;for(;_.sibling===null;){if(_.return===null||_.return===a)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}a.stateNode=y;e:switch(on(y,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Zr(a)}}return Ct(a),em(a,a.type,r===null?null:r.memoizedProps,a.pendingProps,o),null;case 6:if(r&&a.stateNode!=null)r.memoizedProps!==u&&Zr(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(s(166));if(r=te.current,gi(a)){if(r=a.stateNode,o=a.memoizedProps,u=null,p=rn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}r[nn]=a,r=!!(r.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||rx(r.nodeValue,o)),r||ja(a,!0)}else r=fu(r).createTextNode(u),r[nn]=a,a.stateNode=r}return Ct(a),null;case 31:if(o=a.memoizedState,r===null||r.memoizedState!==null){if(u=gi(a),o!==null){if(r===null){if(!u)throw Error(s(318));if(r=a.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(557));r[nn]=a}else vs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ct(a),r=!1}else o=uh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=o),r=!0;if(!r)return a.flags&256?($n(a),a):($n(a),null);if((a.flags&128)!==0)throw Error(s(558))}return Ct(a),null;case 13:if(u=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(p=gi(a),u!==null&&u.dehydrated!==null){if(r===null){if(!p)throw Error(s(318));if(p=a.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(s(317));p[nn]=a}else vs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ct(a),p=!1}else p=uh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return a.flags&256?($n(a),a):($n(a),null)}return $n(a),(a.flags&128)!==0?(a.lanes=o,a):(o=u!==null,r=r!==null&&r.memoizedState!==null,o&&(u=a.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),y=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),y!==p&&(u.flags|=2048)),o!==r&&o&&(a.child.flags|=8192),Jc(a,a.updateQueue),Ct(a),null);case 4:return re(),r===null&&_m(a.stateNode.containerInfo),Ct(a),null;case 10:return Wr(a.type),Ct(a),null;case 19:if(k(Lt),u=a.memoizedState,u===null)return Ct(a),null;if(p=(a.flags&128)!==0,y=u.rendering,y===null)if(p)Jo(u,!1);else{if(Ot!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(y=Ic(r),y!==null){for(a.flags|=128,Jo(u,!1),r=y.updateQueue,a.updateQueue=r,Jc(a,r),a.subtreeFlags=0,r=o,o=a.child;o!==null;)Ly(o,r),o=o.sibling;return I(Lt,Lt.current&1|2),it&&Kr(a,u.treeForkCount),a.child}r=r.sibling}u.tail!==null&&qe()>nu&&(a.flags|=128,p=!0,Jo(u,!1),a.lanes=4194304)}else{if(!p)if(r=Ic(y),r!==null){if(a.flags|=128,p=!0,r=r.updateQueue,a.updateQueue=r,Jc(a,r),Jo(u,!0),u.tail===null&&u.tailMode==="hidden"&&!y.alternate&&!it)return Ct(a),null}else 2*qe()-u.renderingStartTime>nu&&o!==536870912&&(a.flags|=128,p=!0,Jo(u,!1),a.lanes=4194304);u.isBackwards?(y.sibling=a.child,a.child=y):(r=u.last,r!==null?r.sibling=y:a.child=y,u.last=y)}return u.tail!==null?(r=u.tail,u.rendering=r,u.tail=r.sibling,u.renderingStartTime=qe(),r.sibling=null,o=Lt.current,I(Lt,p?o&1|2:o&1),it&&Kr(a,u.treeForkCount),r):(Ct(a),null);case 22:case 23:return $n(a),Sh(),u=a.memoizedState!==null,r!==null?r.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(o&536870912)!==0&&(a.flags&128)===0&&(Ct(a),a.subtreeFlags&6&&(a.flags|=8192)):Ct(a),o=a.updateQueue,o!==null&&Jc(a,o.retryQueue),o=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==o&&(a.flags|=2048),r!==null&&k(xs),null;case 24:return o=null,r!==null&&(o=r.memoizedState.cache),a.memoizedState.cache!==o&&(a.flags|=2048),Wr(Ut),Ct(a),null;case 25:return null;case 30:return null}throw Error(s(156,a.tag))}function NA(r,a){switch(lh(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return Wr(Ut),re(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 26:case 27:case 5:return ze(a),null;case 31:if(a.memoizedState!==null){if($n(a),a.alternate===null)throw Error(s(340));vs()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 13:if($n(a),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(s(340));vs()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return k(Lt),null;case 4:return re(),null;case 10:return Wr(a.type),null;case 22:case 23:return $n(a),Sh(),r!==null&&k(xs),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return Wr(Ut),null;case 25:return null;default:return null}}function l0(r,a){switch(lh(a),a.tag){case 3:Wr(Ut),re();break;case 26:case 27:case 5:ze(a);break;case 4:re();break;case 31:a.memoizedState!==null&&$n(a);break;case 13:$n(a);break;case 19:k(Lt);break;case 10:Wr(a.type);break;case 22:case 23:$n(a),Sh(),r!==null&&k(xs);break;case 24:Wr(Ut)}}function Qo(r,a){try{var o=a.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var p=u.next;o=p;do{if((o.tag&r)===r){u=void 0;var y=o.create,_=o.inst;u=y(),_.destroy=u}o=o.next}while(o!==p)}}catch(j){gt(a,a.return,j)}}function Da(r,a,o){try{var u=a.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var y=p.next;u=y;do{if((u.tag&r)===r){var _=u.inst,j=_.destroy;if(j!==void 0){_.destroy=void 0,p=a;var D=o,G=j;try{G()}catch(ne){gt(p,D,ne)}}}u=u.next}while(u!==y)}}catch(ne){gt(a,a.return,ne)}}function c0(r){var a=r.updateQueue;if(a!==null){var o=r.stateNode;try{Zy(a,o)}catch(u){gt(r,r.return,u)}}}function u0(r,a,o){o.props=Cs(r.type,r.memoizedProps),o.state=r.memoizedState;try{o.componentWillUnmount()}catch(u){gt(r,a,u)}}function Zo(r,a){try{var o=r.ref;if(o!==null){switch(r.tag){case 26:case 27:case 5:var u=r.stateNode;break;case 30:u=r.stateNode;break;default:u=r.stateNode}typeof o=="function"?r.refCleanup=o(u):o.current=u}}catch(p){gt(r,a,p)}}function jr(r,a){var o=r.ref,u=r.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(p){gt(r,a,p)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(p){gt(r,a,p)}else o.current=null}function d0(r){var a=r.type,o=r.memoizedProps,u=r.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(p){gt(r,r.return,p)}}function tm(r,a,o){try{var u=r.stateNode;YA(u,r.type,o,a),u[En]=a}catch(p){gt(r,r.return,p)}}function f0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&Ba(r.type)||r.tag===4}function nm(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||f0(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&Ba(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function rm(r,a,o){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(r,a):(a=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,a.appendChild(r),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=Vr));else if(u!==4&&(u===27&&Ba(r.type)&&(o=r.stateNode,a=null),r=r.child,r!==null))for(rm(r,a,o),r=r.sibling;r!==null;)rm(r,a,o),r=r.sibling}function Qc(r,a,o){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?o.insertBefore(r,a):o.appendChild(r);else if(u!==4&&(u===27&&Ba(r.type)&&(o=r.stateNode),r=r.child,r!==null))for(Qc(r,a,o),r=r.sibling;r!==null;)Qc(r,a,o),r=r.sibling}function h0(r){var a=r.stateNode,o=r.memoizedProps;try{for(var u=r.type,p=a.attributes;p.length;)a.removeAttributeNode(p[0]);on(a,u,o),a[nn]=r,a[En]=o}catch(y){gt(r,r.return,y)}}var ea=!1,Ht=!1,am=!1,m0=typeof WeakSet=="function"?WeakSet:Set,Qt=null;function jA(r,a){if(r=r.containerInfo,Cm=bu,r=Ny(r),Jf(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var p=u.anchorOffset,y=u.focusNode;u=u.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var _=0,j=-1,D=-1,G=0,ne=0,ie=r,Y=null;t:for(;;){for(var Z;ie!==o||p!==0&&ie.nodeType!==3||(j=_+p),ie!==y||u!==0&&ie.nodeType!==3||(D=_+u),ie.nodeType===3&&(_+=ie.nodeValue.length),(Z=ie.firstChild)!==null;)Y=ie,ie=Z;for(;;){if(ie===r)break t;if(Y===o&&++G===p&&(j=_),Y===y&&++ne===u&&(D=_),(Z=ie.nextSibling)!==null)break;ie=Y,Y=ie.parentNode}ie=Z}o=j===-1||D===-1?null:{start:j,end:D}}else o=null}o=o||{start:0,end:0}}else o=null;for(Nm={focusedElem:r,selectionRange:o},bu=!1,Qt=a;Qt!==null;)if(a=Qt,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,Qt=r;else for(;Qt!==null;){switch(a=Qt,y=a.alternate,r=a.flags,a.tag){case 0:if((r&4)!==0&&(r=a.updateQueue,r=r!==null?r.events:null,r!==null))for(o=0;o<r.length;o++)p=r[o],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&y!==null){r=void 0,o=a,p=y.memoizedProps,y=y.memoizedState,u=o.stateNode;try{var je=Cs(o.type,p);r=u.getSnapshotBeforeUpdate(je,y),u.__reactInternalSnapshotBeforeUpdate=r}catch(Be){gt(o,o.return,Be)}}break;case 3:if((r&1024)!==0){if(r=a.stateNode.containerInfo,o=r.nodeType,o===9)Am(r);else if(o===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":Am(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(s(163))}if(r=a.sibling,r!==null){r.return=a.return,Qt=r;break}Qt=a.return}}function p0(r,a,o){var u=o.flags;switch(o.tag){case 0:case 11:case 15:na(r,o),u&4&&Qo(5,o);break;case 1:if(na(r,o),u&4)if(r=o.stateNode,a===null)try{r.componentDidMount()}catch(_){gt(o,o.return,_)}else{var p=Cs(o.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(p,a,r.__reactInternalSnapshotBeforeUpdate)}catch(_){gt(o,o.return,_)}}u&64&&c0(o),u&512&&Zo(o,o.return);break;case 3:if(na(r,o),u&64&&(r=o.updateQueue,r!==null)){if(a=null,o.child!==null)switch(o.child.tag){case 27:case 5:a=o.child.stateNode;break;case 1:a=o.child.stateNode}try{Zy(r,a)}catch(_){gt(o,o.return,_)}}break;case 27:a===null&&u&4&&h0(o);case 26:case 5:na(r,o),a===null&&u&4&&d0(o),u&512&&Zo(o,o.return);break;case 12:na(r,o);break;case 31:na(r,o),u&4&&y0(r,o);break;case 13:na(r,o),u&4&&b0(r,o),u&64&&(r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(o=PA.bind(null,o),nR(r,o))));break;case 22:if(u=o.memoizedState!==null||ea,!u){a=a!==null&&a.memoizedState!==null||Ht,p=ea;var y=Ht;ea=u,(Ht=a)&&!y?ra(r,o,(o.subtreeFlags&8772)!==0):na(r,o),ea=p,Ht=y}break;case 30:break;default:na(r,o)}}function g0(r){var a=r.alternate;a!==null&&(r.alternate=null,g0(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&Df(a)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var jt=null,Nn=!1;function ta(r,a,o){for(o=o.child;o!==null;)v0(r,a,o),o=o.sibling}function v0(r,a,o){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(fn,o)}catch{}switch(o.tag){case 26:Ht||jr(o,a),ta(r,a,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:Ht||jr(o,a);var u=jt,p=Nn;Ba(o.type)&&(jt=o.stateNode,Nn=!1),ta(r,a,o),ll(o.stateNode),jt=u,Nn=p;break;case 5:Ht||jr(o,a);case 6:if(u=jt,p=Nn,jt=null,ta(r,a,o),jt=u,Nn=p,jt!==null)if(Nn)try{(jt.nodeType===9?jt.body:jt.nodeName==="HTML"?jt.ownerDocument.body:jt).removeChild(o.stateNode)}catch(y){gt(o,a,y)}else try{jt.removeChild(o.stateNode)}catch(y){gt(o,a,y)}break;case 18:jt!==null&&(Nn?(r=jt,cx(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.stateNode),zi(r)):cx(jt,o.stateNode));break;case 4:u=jt,p=Nn,jt=o.stateNode.containerInfo,Nn=!0,ta(r,a,o),jt=u,Nn=p;break;case 0:case 11:case 14:case 15:Da(2,o,a),Ht||Da(4,o,a),ta(r,a,o);break;case 1:Ht||(jr(o,a),u=o.stateNode,typeof u.componentWillUnmount=="function"&&u0(o,a,u)),ta(r,a,o);break;case 21:ta(r,a,o);break;case 22:Ht=(u=Ht)||o.memoizedState!==null,ta(r,a,o),Ht=u;break;default:ta(r,a,o)}}function y0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{zi(r)}catch(o){gt(a,a.return,o)}}}function b0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{zi(r)}catch(o){gt(a,a.return,o)}}function TA(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new m0),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new m0),a;default:throw Error(s(435,r.tag))}}function Zc(r,a){var o=TA(r);a.forEach(function(u){if(!o.has(u)){o.add(u);var p=zA.bind(null,r,u);u.then(p,p)}})}function jn(r,a){var o=a.deletions;if(o!==null)for(var u=0;u<o.length;u++){var p=o[u],y=r,_=a,j=_;e:for(;j!==null;){switch(j.tag){case 27:if(Ba(j.type)){jt=j.stateNode,Nn=!1;break e}break;case 5:jt=j.stateNode,Nn=!1;break e;case 3:case 4:jt=j.stateNode.containerInfo,Nn=!0;break e}j=j.return}if(jt===null)throw Error(s(160));v0(y,_,p),jt=null,Nn=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)x0(a,r),a=a.sibling}var hr=null;function x0(r,a){var o=r.alternate,u=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:jn(a,r),Tn(r),u&4&&(Da(3,r,r.return),Qo(3,r),Da(5,r,r.return));break;case 1:jn(a,r),Tn(r),u&512&&(Ht||o===null||jr(o,o.return)),u&64&&ea&&(r=r.updateQueue,r!==null&&(u=r.callbacks,u!==null&&(o=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=o===null?u:o.concat(u))));break;case 26:var p=hr;if(jn(a,r),Tn(r),u&512&&(Ht||o===null||jr(o,o.return)),u&4){var y=o!==null?o.memoizedState:null;if(u=r.memoizedState,o===null)if(u===null)if(r.stateNode===null){e:{u=r.type,o=r.memoizedProps,p=p.ownerDocument||p;t:switch(u){case"title":y=p.getElementsByTagName("title")[0],(!y||y[No]||y[nn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(u),p.head.insertBefore(y,p.querySelector("head > title"))),on(y,u,o),y[nn]=r,Jt(y),u=y;break e;case"link":var _=xx("link","href",p).get(u+(o.href||""));if(_){for(var j=0;j<_.length;j++)if(y=_[j],y.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&y.getAttribute("rel")===(o.rel==null?null:o.rel)&&y.getAttribute("title")===(o.title==null?null:o.title)&&y.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){_.splice(j,1);break t}}y=p.createElement(u),on(y,u,o),p.head.appendChild(y);break;case"meta":if(_=xx("meta","content",p).get(u+(o.content||""))){for(j=0;j<_.length;j++)if(y=_[j],y.getAttribute("content")===(o.content==null?null:""+o.content)&&y.getAttribute("name")===(o.name==null?null:o.name)&&y.getAttribute("property")===(o.property==null?null:o.property)&&y.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&y.getAttribute("charset")===(o.charSet==null?null:o.charSet)){_.splice(j,1);break t}}y=p.createElement(u),on(y,u,o),p.head.appendChild(y);break;default:throw Error(s(468,u))}y[nn]=r,Jt(y),u=y}r.stateNode=u}else wx(p,r.type,r.stateNode);else r.stateNode=bx(p,u,r.memoizedProps);else y!==u?(y===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):y.count--,u===null?wx(p,r.type,r.stateNode):bx(p,u,r.memoizedProps)):u===null&&r.stateNode!==null&&tm(r,r.memoizedProps,o.memoizedProps)}break;case 27:jn(a,r),Tn(r),u&512&&(Ht||o===null||jr(o,o.return)),o!==null&&u&4&&tm(r,r.memoizedProps,o.memoizedProps);break;case 5:if(jn(a,r),Tn(r),u&512&&(Ht||o===null||jr(o,o.return)),r.flags&32){p=r.stateNode;try{ii(p,"")}catch(je){gt(r,r.return,je)}}u&4&&r.stateNode!=null&&(p=r.memoizedProps,tm(r,p,o!==null?o.memoizedProps:p)),u&1024&&(am=!0);break;case 6:if(jn(a,r),Tn(r),u&4){if(r.stateNode===null)throw Error(s(162));u=r.memoizedProps,o=r.stateNode;try{o.nodeValue=u}catch(je){gt(r,r.return,je)}}break;case 3:if(pu=null,p=hr,hr=hu(a.containerInfo),jn(a,r),hr=p,Tn(r),u&4&&o!==null&&o.memoizedState.isDehydrated)try{zi(a.containerInfo)}catch(je){gt(r,r.return,je)}am&&(am=!1,w0(r));break;case 4:u=hr,hr=hu(r.stateNode.containerInfo),jn(a,r),Tn(r),hr=u;break;case 12:jn(a,r),Tn(r);break;case 31:jn(a,r),Tn(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Zc(r,u)));break;case 13:jn(a,r),Tn(r),r.child.flags&8192&&r.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(tu=qe()),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Zc(r,u)));break;case 22:p=r.memoizedState!==null;var D=o!==null&&o.memoizedState!==null,G=ea,ne=Ht;if(ea=G||p,Ht=ne||D,jn(a,r),Ht=ne,ea=G,Tn(r),u&8192)e:for(a=r.stateNode,a._visibility=p?a._visibility&-2:a._visibility|1,p&&(o===null||D||ea||Ht||Ns(r)),o=null,a=r;;){if(a.tag===5||a.tag===26){if(o===null){D=o=a;try{if(y=D.stateNode,p)_=y.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{j=D.stateNode;var ie=D.memoizedProps.style,Y=ie!=null&&ie.hasOwnProperty("display")?ie.display:null;j.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(je){gt(D,D.return,je)}}}else if(a.tag===6){if(o===null){D=a;try{D.stateNode.nodeValue=p?"":D.memoizedProps}catch(je){gt(D,D.return,je)}}}else if(a.tag===18){if(o===null){D=a;try{var Z=D.stateNode;p?ux(Z,!0):ux(D.stateNode,!1)}catch(je){gt(D,D.return,je)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===r)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break e;for(;a.sibling===null;){if(a.return===null||a.return===r)break e;o===a&&(o=null),a=a.return}o===a&&(o=null),a.sibling.return=a.return,a=a.sibling}u&4&&(u=r.updateQueue,u!==null&&(o=u.retryQueue,o!==null&&(u.retryQueue=null,Zc(r,o))));break;case 19:jn(a,r),Tn(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Zc(r,u)));break;case 30:break;case 21:break;default:jn(a,r),Tn(r)}}function Tn(r){var a=r.flags;if(a&2){try{for(var o,u=r.return;u!==null;){if(f0(u)){o=u;break}u=u.return}if(o==null)throw Error(s(160));switch(o.tag){case 27:var p=o.stateNode,y=nm(r);Qc(r,y,p);break;case 5:var _=o.stateNode;o.flags&32&&(ii(_,""),o.flags&=-33);var j=nm(r);Qc(r,j,_);break;case 3:case 4:var D=o.stateNode.containerInfo,G=nm(r);rm(r,G,D);break;default:throw Error(s(161))}}catch(ne){gt(r,r.return,ne)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function w0(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;w0(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),r=r.sibling}}function na(r,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)p0(r,a.alternate,a),a=a.sibling}function Ns(r){for(r=r.child;r!==null;){var a=r;switch(a.tag){case 0:case 11:case 14:case 15:Da(4,a,a.return),Ns(a);break;case 1:jr(a,a.return);var o=a.stateNode;typeof o.componentWillUnmount=="function"&&u0(a,a.return,o),Ns(a);break;case 27:ll(a.stateNode);case 26:case 5:jr(a,a.return),Ns(a);break;case 22:a.memoizedState===null&&Ns(a);break;case 30:Ns(a);break;default:Ns(a)}r=r.sibling}}function ra(r,a,o){for(o=o&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var u=a.alternate,p=r,y=a,_=y.flags;switch(y.tag){case 0:case 11:case 15:ra(p,y,o),Qo(4,y);break;case 1:if(ra(p,y,o),u=y,p=u.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(G){gt(u,u.return,G)}if(u=y,p=u.updateQueue,p!==null){var j=u.stateNode;try{var D=p.shared.hiddenCallbacks;if(D!==null)for(p.shared.hiddenCallbacks=null,p=0;p<D.length;p++)Qy(D[p],j)}catch(G){gt(u,u.return,G)}}o&&_&64&&c0(y),Zo(y,y.return);break;case 27:h0(y);case 26:case 5:ra(p,y,o),o&&u===null&&_&4&&d0(y),Zo(y,y.return);break;case 12:ra(p,y,o);break;case 31:ra(p,y,o),o&&_&4&&y0(p,y);break;case 13:ra(p,y,o),o&&_&4&&b0(p,y);break;case 22:y.memoizedState===null&&ra(p,y,o),Zo(y,y.return);break;case 30:break;default:ra(p,y,o)}a=a.sibling}}function sm(r,a){var o=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),r=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(r=a.memoizedState.cachePool.pool),r!==o&&(r!=null&&r.refCount++,o!=null&&Uo(o))}function im(r,a){r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Uo(r))}function mr(r,a,o,u){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)_0(r,a,o,u),a=a.sibling}function _0(r,a,o,u){var p=a.flags;switch(a.tag){case 0:case 11:case 15:mr(r,a,o,u),p&2048&&Qo(9,a);break;case 1:mr(r,a,o,u);break;case 3:mr(r,a,o,u),p&2048&&(r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Uo(r)));break;case 12:if(p&2048){mr(r,a,o,u),r=a.stateNode;try{var y=a.memoizedProps,_=y.id,j=y.onPostCommit;typeof j=="function"&&j(_,a.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(D){gt(a,a.return,D)}}else mr(r,a,o,u);break;case 31:mr(r,a,o,u);break;case 13:mr(r,a,o,u);break;case 23:break;case 22:y=a.stateNode,_=a.alternate,a.memoizedState!==null?y._visibility&2?mr(r,a,o,u):el(r,a):y._visibility&2?mr(r,a,o,u):(y._visibility|=2,Ni(r,a,o,u,(a.subtreeFlags&10256)!==0||!1)),p&2048&&sm(_,a);break;case 24:mr(r,a,o,u),p&2048&&im(a.alternate,a);break;default:mr(r,a,o,u)}}function Ni(r,a,o,u,p){for(p=p&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var y=r,_=a,j=o,D=u,G=_.flags;switch(_.tag){case 0:case 11:case 15:Ni(y,_,j,D,p),Qo(8,_);break;case 23:break;case 22:var ne=_.stateNode;_.memoizedState!==null?ne._visibility&2?Ni(y,_,j,D,p):el(y,_):(ne._visibility|=2,Ni(y,_,j,D,p)),p&&G&2048&&sm(_.alternate,_);break;case 24:Ni(y,_,j,D,p),p&&G&2048&&im(_.alternate,_);break;default:Ni(y,_,j,D,p)}a=a.sibling}}function el(r,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var o=r,u=a,p=u.flags;switch(u.tag){case 22:el(o,u),p&2048&&sm(u.alternate,u);break;case 24:el(o,u),p&2048&&im(u.alternate,u);break;default:el(o,u)}a=a.sibling}}var tl=8192;function ji(r,a,o){if(r.subtreeFlags&tl)for(r=r.child;r!==null;)S0(r,a,o),r=r.sibling}function S0(r,a,o){switch(r.tag){case 26:ji(r,a,o),r.flags&tl&&r.memoizedState!==null&&mR(o,hr,r.memoizedState,r.memoizedProps);break;case 5:ji(r,a,o);break;case 3:case 4:var u=hr;hr=hu(r.stateNode.containerInfo),ji(r,a,o),hr=u;break;case 22:r.memoizedState===null&&(u=r.alternate,u!==null&&u.memoizedState!==null?(u=tl,tl=16777216,ji(r,a,o),tl=u):ji(r,a,o));break;default:ji(r,a,o)}}function E0(r){var a=r.alternate;if(a!==null&&(r=a.child,r!==null)){a.child=null;do a=r.sibling,r.sibling=null,r=a;while(r!==null)}}function nl(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var o=0;o<a.length;o++){var u=a[o];Qt=u,N0(u,r)}E0(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)C0(r),r=r.sibling}function C0(r){switch(r.tag){case 0:case 11:case 15:nl(r),r.flags&2048&&Da(9,r,r.return);break;case 3:nl(r);break;case 12:nl(r);break;case 22:var a=r.stateNode;r.memoizedState!==null&&a._visibility&2&&(r.return===null||r.return.tag!==13)?(a._visibility&=-3,eu(r)):nl(r);break;default:nl(r)}}function eu(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var o=0;o<a.length;o++){var u=a[o];Qt=u,N0(u,r)}E0(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:Da(8,a,a.return),eu(a);break;case 22:o=a.stateNode,o._visibility&2&&(o._visibility&=-3,eu(a));break;default:eu(a)}r=r.sibling}}function N0(r,a){for(;Qt!==null;){var o=Qt;switch(o.tag){case 0:case 11:case 15:Da(8,o,a);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var u=o.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Uo(o.memoizedState.cache)}if(u=o.child,u!==null)u.return=o,Qt=u;else e:for(o=r;Qt!==null;){u=Qt;var p=u.sibling,y=u.return;if(g0(u),u===o){Qt=null;break e}if(p!==null){p.return=y,Qt=p;break e}Qt=y}}}var AA={getCacheForType:function(r){var a=an(Ut),o=a.data.get(r);return o===void 0&&(o=r(),a.data.set(r,o)),o},cacheSignal:function(){return an(Ut).controller.signal}},RA=typeof WeakMap=="function"?WeakMap:Map,ft=0,wt=null,tt=null,rt=0,pt=0,Bn=null,La=!1,Ti=!1,om=!1,aa=0,Ot=0,Pa=0,js=0,lm=0,Hn=0,Ai=0,rl=null,An=null,cm=!1,tu=0,j0=0,nu=1/0,ru=null,za=null,Yt=0,Ia=null,Ri=null,sa=0,um=0,dm=null,T0=null,al=0,fm=null;function qn(){return(ft&2)!==0&&rt!==0?rt&-rt:O.T!==null?ym():Of()}function A0(){if(Hn===0)if((rt&536870912)===0||it){var r=Ue;Ue<<=1,(Ue&3932160)===0&&(Ue=262144),Hn=r}else Hn=536870912;return r=Un.current,r!==null&&(r.flags|=32),Hn}function Rn(r,a,o){(r===wt&&(pt===2||pt===9)||r.cancelPendingCommit!==null)&&(ki(r,0),Ua(r,rt,Hn,!1)),At(r,o),((ft&2)===0||r!==wt)&&(r===wt&&((ft&2)===0&&(js|=o),Ot===4&&Ua(r,rt,Hn,!1)),Tr(r))}function R0(r,a,o){if((ft&6)!==0)throw Error(s(327));var u=!o&&(a&127)===0&&(a&r.expiredLanes)===0||st(r,a),p=u?MA(r,a):mm(r,a,!0),y=u;do{if(p===0){Ti&&!u&&Ua(r,a,0,!1);break}else{if(o=r.current.alternate,y&&!kA(o)){p=mm(r,a,!1),y=!1;continue}if(p===2){if(y=a,r.errorRecoveryDisabledLanes&y)var _=0;else _=r.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){a=_;e:{var j=r;p=rl;var D=j.current.memoizedState.isDehydrated;if(D&&(ki(j,_).flags|=256),_=mm(j,_,!1),_!==2){if(om&&!D){j.errorRecoveryDisabledLanes|=y,js|=y,p=4;break e}y=An,An=p,y!==null&&(An===null?An=y:An.push.apply(An,y))}p=_}if(y=!1,p!==2)continue}}if(p===1){ki(r,0),Ua(r,a,0,!0);break}e:{switch(u=r,y=p,y){case 0:case 1:throw Error(s(345));case 4:if((a&4194048)!==a)break;case 6:Ua(u,a,Hn,!La);break e;case 2:An=null;break;case 3:case 5:break;default:throw Error(s(329))}if((a&62914560)===a&&(p=tu+300-qe(),10<p)){if(Ua(u,a,Hn,!La),Se(u,0,!0)!==0)break e;sa=a,u.timeoutHandle=ox(k0.bind(null,u,o,An,ru,cm,a,Hn,js,Ai,La,y,"Throttled",-0,0),p);break e}k0(u,o,An,ru,cm,a,Hn,js,Ai,La,y,null,-0,0)}}break}while(!0);Tr(r)}function k0(r,a,o,u,p,y,_,j,D,G,ne,ie,Y,Z){if(r.timeoutHandle=-1,ie=a.subtreeFlags,ie&8192||(ie&16785408)===16785408){ie={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vr},S0(a,y,ie);var je=(y&62914560)===y?tu-qe():(y&4194048)===y?j0-qe():0;if(je=pR(ie,je),je!==null){sa=y,r.cancelPendingCommit=je(U0.bind(null,r,a,y,o,u,p,_,j,D,ne,ie,null,Y,Z)),Ua(r,y,_,!G);return}}U0(r,a,y,o,u,p,_,j,D)}function kA(r){for(var a=r;;){var o=a.tag;if((o===0||o===11||o===15)&&a.flags&16384&&(o=a.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var u=0;u<o.length;u++){var p=o[u],y=p.getSnapshot;p=p.value;try{if(!zn(y(),p))return!1}catch{return!1}}if(o=a.child,a.subtreeFlags&16384&&o!==null)o.return=a,a=o;else{if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ua(r,a,o,u){a&=~lm,a&=~js,r.suspendedLanes|=a,r.pingedLanes&=~a,u&&(r.warmLanes|=a),u=r.expirationTimes;for(var p=a;0<p;){var y=31-Tt(p),_=1<<y;u[y]=-1,p&=~_}o!==0&&us(r,o,a)}function au(){return(ft&6)===0?(sl(0),!1):!0}function hm(){if(tt!==null){if(pt===0)var r=tt.return;else r=tt,Yr=ys=null,Ah(r),wi=null,Bo=0,r=tt;for(;r!==null;)l0(r.alternate,r),r=r.return;tt=null}}function ki(r,a){var o=r.timeoutHandle;o!==-1&&(r.timeoutHandle=-1,JA(o)),o=r.cancelPendingCommit,o!==null&&(r.cancelPendingCommit=null,o()),sa=0,hm(),wt=r,tt=o=Gr(r.current,null),rt=a,pt=0,Bn=null,La=!1,Ti=st(r,a),om=!1,Ai=Hn=lm=js=Pa=Ot=0,An=rl=null,cm=!1,(a&8)!==0&&(a|=a&32);var u=r.entangledLanes;if(u!==0)for(r=r.entanglements,u&=a;0<u;){var p=31-Tt(u),y=1<<p;a|=r[p],u&=~y}return aa=a,Cc(),o}function O0(r,a){Ke=null,O.H=Wo,a===xi||a===Mc?(a=Yy(),pt=3):a===vh?(a=Yy(),pt=4):pt=a===Fh?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Bn=a,tt===null&&(Ot=1,Kc(r,Xn(a,r.current)))}function M0(){var r=Un.current;return r===null?!0:(rt&4194048)===rt?er===null:(rt&62914560)===rt||(rt&536870912)!==0?r===er:!1}function D0(){var r=O.H;return O.H=Wo,r===null?Wo:r}function L0(){var r=O.A;return O.A=AA,r}function su(){Ot=4,La||(rt&4194048)!==rt&&Un.current!==null||(Ti=!0),(Pa&134217727)===0&&(js&134217727)===0||wt===null||Ua(wt,rt,Hn,!1)}function mm(r,a,o){var u=ft;ft|=2;var p=D0(),y=L0();(wt!==r||rt!==a)&&(ru=null,ki(r,a)),a=!1;var _=Ot;e:do try{if(pt!==0&&tt!==null){var j=tt,D=Bn;switch(pt){case 8:hm(),_=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(a=!0);var G=pt;if(pt=0,Bn=null,Oi(r,j,D,G),o&&Ti){_=0;break e}break;default:G=pt,pt=0,Bn=null,Oi(r,j,D,G)}}OA(),_=Ot;break}catch(ne){O0(r,ne)}while(!0);return a&&r.shellSuspendCounter++,Yr=ys=null,ft=u,O.H=p,O.A=y,tt===null&&(wt=null,rt=0,Cc()),_}function OA(){for(;tt!==null;)P0(tt)}function MA(r,a){var o=ft;ft|=2;var u=D0(),p=L0();wt!==r||rt!==a?(ru=null,nu=qe()+500,ki(r,a)):Ti=st(r,a);e:do try{if(pt!==0&&tt!==null){a=tt;var y=Bn;t:switch(pt){case 1:pt=0,Bn=null,Oi(r,a,y,1);break;case 2:case 9:if(Gy(y)){pt=0,Bn=null,z0(a);break}a=function(){pt!==2&&pt!==9||wt!==r||(pt=7),Tr(r)},y.then(a,a);break e;case 3:pt=7;break e;case 4:pt=5;break e;case 7:Gy(y)?(pt=0,Bn=null,z0(a)):(pt=0,Bn=null,Oi(r,a,y,7));break;case 5:var _=null;switch(tt.tag){case 26:_=tt.memoizedState;case 5:case 27:var j=tt;if(_?_x(_):j.stateNode.complete){pt=0,Bn=null;var D=j.sibling;if(D!==null)tt=D;else{var G=j.return;G!==null?(tt=G,iu(G)):tt=null}break t}}pt=0,Bn=null,Oi(r,a,y,5);break;case 6:pt=0,Bn=null,Oi(r,a,y,6);break;case 8:hm(),Ot=6;break e;default:throw Error(s(462))}}DA();break}catch(ne){O0(r,ne)}while(!0);return Yr=ys=null,O.H=u,O.A=p,ft=o,tt!==null?0:(wt=null,rt=0,Cc(),Ot)}function DA(){for(;tt!==null&&!mt();)P0(tt)}function P0(r){var a=i0(r.alternate,r,aa);r.memoizedProps=r.pendingProps,a===null?iu(r):tt=a}function z0(r){var a=r,o=a.alternate;switch(a.tag){case 15:case 0:a=e0(o,a,a.pendingProps,a.type,void 0,rt);break;case 11:a=e0(o,a,a.pendingProps,a.type.render,a.ref,rt);break;case 5:Ah(a);default:l0(o,a),a=tt=Ly(a,aa),a=i0(o,a,aa)}r.memoizedProps=r.pendingProps,a===null?iu(r):tt=a}function Oi(r,a,o,u){Yr=ys=null,Ah(a),wi=null,Bo=0;var p=a.return;try{if(_A(r,p,a,o,rt)){Ot=1,Kc(r,Xn(o,r.current)),tt=null;return}}catch(y){if(p!==null)throw tt=p,y;Ot=1,Kc(r,Xn(o,r.current)),tt=null;return}a.flags&32768?(it||u===1?r=!0:Ti||(rt&536870912)!==0?r=!1:(La=r=!0,(u===2||u===9||u===3||u===6)&&(u=Un.current,u!==null&&u.tag===13&&(u.flags|=16384))),I0(a,r)):iu(a)}function iu(r){var a=r;do{if((a.flags&32768)!==0){I0(a,La);return}r=a.return;var o=CA(a.alternate,a,aa);if(o!==null){tt=o;return}if(a=a.sibling,a!==null){tt=a;return}tt=a=r}while(a!==null);Ot===0&&(Ot=5)}function I0(r,a){do{var o=NA(r.alternate,r);if(o!==null){o.flags&=32767,tt=o;return}if(o=r.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!a&&(r=r.sibling,r!==null)){tt=r;return}tt=r=o}while(r!==null);Ot=6,tt=null}function U0(r,a,o,u,p,y,_,j,D){r.cancelPendingCommit=null;do ou();while(Yt!==0);if((ft&6)!==0)throw Error(s(327));if(a!==null){if(a===r.current)throw Error(s(177));if(y=a.lanes|a.childLanes,y|=nh,wn(r,o,y,_,j,D),r===wt&&(tt=wt=null,rt=0),Ri=a,Ia=r,sa=o,um=y,dm=p,T0=u,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,IA(tn,function(){return V0(),null})):(r.callbackNode=null,r.callbackPriority=0),u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=O.T,O.T=null,p=K.p,K.p=2,_=ft,ft|=4;try{jA(r,a,o)}finally{ft=_,K.p=p,O.T=u}}Yt=1,$0(),B0(),H0()}}function $0(){if(Yt===1){Yt=0;var r=Ia,a=Ri,o=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||o){o=O.T,O.T=null;var u=K.p;K.p=2;var p=ft;ft|=4;try{x0(a,r);var y=Nm,_=Ny(r.containerInfo),j=y.focusedElem,D=y.selectionRange;if(_!==j&&j&&j.ownerDocument&&Cy(j.ownerDocument.documentElement,j)){if(D!==null&&Jf(j)){var G=D.start,ne=D.end;if(ne===void 0&&(ne=G),"selectionStart"in j)j.selectionStart=G,j.selectionEnd=Math.min(ne,j.value.length);else{var ie=j.ownerDocument||document,Y=ie&&ie.defaultView||window;if(Y.getSelection){var Z=Y.getSelection(),je=j.textContent.length,Be=Math.min(D.start,je),xt=D.end===void 0?Be:Math.min(D.end,je);!Z.extend&&Be>xt&&(_=xt,xt=Be,Be=_);var $=Ey(j,Be),P=Ey(j,xt);if($&&P&&(Z.rangeCount!==1||Z.anchorNode!==$.node||Z.anchorOffset!==$.offset||Z.focusNode!==P.node||Z.focusOffset!==P.offset)){var F=ie.createRange();F.setStart($.node,$.offset),Z.removeAllRanges(),Be>xt?(Z.addRange(F),Z.extend(P.node,P.offset)):(F.setEnd(P.node,P.offset),Z.addRange(F))}}}}for(ie=[],Z=j;Z=Z.parentNode;)Z.nodeType===1&&ie.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<ie.length;j++){var ae=ie[j];ae.element.scrollLeft=ae.left,ae.element.scrollTop=ae.top}}bu=!!Cm,Nm=Cm=null}finally{ft=p,K.p=u,O.T=o}}r.current=a,Yt=2}}function B0(){if(Yt===2){Yt=0;var r=Ia,a=Ri,o=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||o){o=O.T,O.T=null;var u=K.p;K.p=2;var p=ft;ft|=4;try{p0(r,a.alternate,a)}finally{ft=p,K.p=u,O.T=o}}Yt=3}}function H0(){if(Yt===4||Yt===3){Yt=0,zt();var r=Ia,a=Ri,o=sa,u=T0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Yt=5:(Yt=0,Ri=Ia=null,q0(r,r.pendingLanes));var p=r.pendingLanes;if(p===0&&(za=null),dr(o),a=a.stateNode,Nt&&typeof Nt.onCommitFiberRoot=="function")try{Nt.onCommitFiberRoot(fn,a,void 0,(a.current.flags&128)===128)}catch{}if(u!==null){a=O.T,p=K.p,K.p=2,O.T=null;try{for(var y=r.onRecoverableError,_=0;_<u.length;_++){var j=u[_];y(j.value,{componentStack:j.stack})}}finally{O.T=a,K.p=p}}(sa&3)!==0&&ou(),Tr(r),p=r.pendingLanes,(o&261930)!==0&&(p&42)!==0?r===fm?al++:(al=0,fm=r):al=0,sl(0)}}function q0(r,a){(r.pooledCacheLanes&=a)===0&&(a=r.pooledCache,a!=null&&(r.pooledCache=null,Uo(a)))}function ou(){return $0(),B0(),H0(),V0()}function V0(){if(Yt!==5)return!1;var r=Ia,a=um;um=0;var o=dr(sa),u=O.T,p=K.p;try{K.p=32>o?32:o,O.T=null,o=dm,dm=null;var y=Ia,_=sa;if(Yt=0,Ri=Ia=null,sa=0,(ft&6)!==0)throw Error(s(331));var j=ft;if(ft|=4,C0(y.current),_0(y,y.current,_,o),ft=j,sl(0,!1),Nt&&typeof Nt.onPostCommitFiberRoot=="function")try{Nt.onPostCommitFiberRoot(fn,y)}catch{}return!0}finally{K.p=p,O.T=u,q0(r,a)}}function F0(r,a,o){a=Xn(o,a),a=Vh(r.stateNode,a,2),r=ka(r,a,2),r!==null&&(At(r,2),Tr(r))}function gt(r,a,o){if(r.tag===3)F0(r,r,o);else for(;a!==null;){if(a.tag===3){F0(a,r,o);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(za===null||!za.has(u))){r=Xn(o,r),o=Gb(2),u=ka(a,o,2),u!==null&&(Kb(o,u,a,r),At(u,2),Tr(u));break}}a=a.return}}function pm(r,a,o){var u=r.pingCache;if(u===null){u=r.pingCache=new RA;var p=new Set;u.set(a,p)}else p=u.get(a),p===void 0&&(p=new Set,u.set(a,p));p.has(o)||(om=!0,p.add(o),r=LA.bind(null,r,a,o),a.then(r,r))}function LA(r,a,o){var u=r.pingCache;u!==null&&u.delete(a),r.pingedLanes|=r.suspendedLanes&o,r.warmLanes&=~o,wt===r&&(rt&o)===o&&(Ot===4||Ot===3&&(rt&62914560)===rt&&300>qe()-tu?(ft&2)===0&&ki(r,0):lm|=o,Ai===rt&&(Ai=0)),Tr(r)}function G0(r,a){a===0&&(a=hn()),r=ps(r,a),r!==null&&(At(r,a),Tr(r))}function PA(r){var a=r.memoizedState,o=0;a!==null&&(o=a.retryLane),G0(r,o)}function zA(r,a){var o=0;switch(r.tag){case 31:case 13:var u=r.stateNode,p=r.memoizedState;p!==null&&(o=p.retryLane);break;case 19:u=r.stateNode;break;case 22:u=r.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(a),G0(r,o)}function IA(r,a){return ht(r,a)}var lu=null,Mi=null,gm=!1,cu=!1,vm=!1,$a=0;function Tr(r){r!==Mi&&r.next===null&&(Mi===null?lu=Mi=r:Mi=Mi.next=r),cu=!0,gm||(gm=!0,$A())}function sl(r,a){if(!vm&&cu){vm=!0;do for(var o=!1,u=lu;u!==null;){if(r!==0){var p=u.pendingLanes;if(p===0)var y=0;else{var _=u.suspendedLanes,j=u.pingedLanes;y=(1<<31-Tt(42|r)+1)-1,y&=p&~(_&~j),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,X0(u,y))}else y=rt,y=Se(u,u===wt?y:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(y&3)===0||st(u,y)||(o=!0,X0(u,y));u=u.next}while(o);vm=!1}}function UA(){K0()}function K0(){cu=gm=!1;var r=0;$a!==0&&XA()&&(r=$a);for(var a=qe(),o=null,u=lu;u!==null;){var p=u.next,y=Y0(u,a);y===0?(u.next=null,o===null?lu=p:o.next=p,p===null&&(Mi=o)):(o=u,(r!==0||(y&3)!==0)&&(cu=!0)),u=p}Yt!==0&&Yt!==5||sl(r),$a!==0&&($a=0)}function Y0(r,a){for(var o=r.suspendedLanes,u=r.pingedLanes,p=r.expirationTimes,y=r.pendingLanes&-62914561;0<y;){var _=31-Tt(y),j=1<<_,D=p[_];D===-1?((j&o)===0||(j&u)!==0)&&(p[_]=St(j,a)):D<=a&&(r.expiredLanes|=j),y&=~j}if(a=wt,o=rt,o=Se(r,r===a?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u=r.callbackNode,o===0||r===a&&(pt===2||pt===9)||r.cancelPendingCommit!==null)return u!==null&&u!==null&&Ye(u),r.callbackNode=null,r.callbackPriority=0;if((o&3)===0||st(r,o)){if(a=o&-o,a===r.callbackPriority)return a;switch(u!==null&&Ye(u),dr(o)){case 2:case 8:o=ct;break;case 32:o=tn;break;case 268435456:o=Gt;break;default:o=tn}return u=W0.bind(null,r),o=ht(o,u),r.callbackPriority=a,r.callbackNode=o,a}return u!==null&&u!==null&&Ye(u),r.callbackPriority=2,r.callbackNode=null,2}function W0(r,a){if(Yt!==0&&Yt!==5)return r.callbackNode=null,r.callbackPriority=0,null;var o=r.callbackNode;if(ou()&&r.callbackNode!==o)return null;var u=rt;return u=Se(r,r===wt?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u===0?null:(R0(r,u,a),Y0(r,qe()),r.callbackNode!=null&&r.callbackNode===o?W0.bind(null,r):null)}function X0(r,a){if(ou())return null;R0(r,a,!0)}function $A(){QA(function(){(ft&6)!==0?ht(Pe,UA):K0()})}function ym(){if($a===0){var r=yi;r===0&&(r=fe,fe<<=1,(fe&261888)===0&&(fe=256)),$a=r}return $a}function J0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:vc(""+r)}function Q0(r,a){var o=a.ownerDocument.createElement("input");return o.name=a.name,o.value=a.value,r.id&&o.setAttribute("form",r.id),a.parentNode.insertBefore(o,a),r=new FormData(r),o.parentNode.removeChild(o),r}function BA(r,a,o,u,p){if(a==="submit"&&o&&o.stateNode===p){var y=J0((p[En]||null).action),_=u.submitter;_&&(a=(a=_[En]||null)?J0(a.formAction):_.getAttribute("formAction"),a!==null&&(y=a,_=null));var j=new wc("action","action",null,u,p);r.push({event:j,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if($a!==0){var D=_?Q0(p,_):new FormData(p);Ih(o,{pending:!0,data:D,method:p.method,action:y},null,D)}}else typeof y=="function"&&(j.preventDefault(),D=_?Q0(p,_):new FormData(p),Ih(o,{pending:!0,data:D,method:p.method,action:y},y,D))},currentTarget:p}]})}}for(var bm=0;bm<th.length;bm++){var xm=th[bm],HA=xm.toLowerCase(),qA=xm[0].toUpperCase()+xm.slice(1);fr(HA,"on"+qA)}fr(Ay,"onAnimationEnd"),fr(Ry,"onAnimationIteration"),fr(ky,"onAnimationStart"),fr("dblclick","onDoubleClick"),fr("focusin","onFocus"),fr("focusout","onBlur"),fr(sA,"onTransitionRun"),fr(iA,"onTransitionStart"),fr(oA,"onTransitionCancel"),fr(Oy,"onTransitionEnd"),ai("onMouseEnter",["mouseout","mouseover"]),ai("onMouseLeave",["mouseout","mouseover"]),ai("onPointerEnter",["pointerout","pointerover"]),ai("onPointerLeave",["pointerout","pointerover"]),ds("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ds("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ds("onBeforeInput",["compositionend","keypress","textInput","paste"]),ds("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ds("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ds("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var il="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),VA=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(il));function Z0(r,a){a=(a&4)!==0;for(var o=0;o<r.length;o++){var u=r[o],p=u.event;u=u.listeners;e:{var y=void 0;if(a)for(var _=u.length-1;0<=_;_--){var j=u[_],D=j.instance,G=j.currentTarget;if(j=j.listener,D!==y&&p.isPropagationStopped())break e;y=j,p.currentTarget=G;try{y(p)}catch(ne){Ec(ne)}p.currentTarget=null,y=D}else for(_=0;_<u.length;_++){if(j=u[_],D=j.instance,G=j.currentTarget,j=j.listener,D!==y&&p.isPropagationStopped())break e;y=j,p.currentTarget=G;try{y(p)}catch(ne){Ec(ne)}p.currentTarget=null,y=D}}}}function nt(r,a){var o=a[Mf];o===void 0&&(o=a[Mf]=new Set);var u=r+"__bubble";o.has(u)||(ex(a,r,2,!1),o.add(u))}function wm(r,a,o){var u=0;a&&(u|=4),ex(o,r,u,a)}var uu="_reactListening"+Math.random().toString(36).slice(2);function _m(r){if(!r[uu]){r[uu]=!0,Kv.forEach(function(o){o!=="selectionchange"&&(VA.has(o)||wm(o,!1,r),wm(o,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[uu]||(a[uu]=!0,wm("selectionchange",!1,a))}}function ex(r,a,o,u){switch(Ax(a)){case 2:var p=yR;break;case 8:p=bR;break;default:p=zm}o=p.bind(null,a,o,r),p=void 0,!Hf||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(p=!0),u?p!==void 0?r.addEventListener(a,o,{capture:!0,passive:p}):r.addEventListener(a,o,!0):p!==void 0?r.addEventListener(a,o,{passive:p}):r.addEventListener(a,o,!1)}function Sm(r,a,o,u,p){var y=u;if((a&1)===0&&(a&2)===0&&u!==null)e:for(;;){if(u===null)return;var _=u.tag;if(_===3||_===4){var j=u.stateNode.containerInfo;if(j===p)break;if(_===4)for(_=u.return;_!==null;){var D=_.tag;if((D===3||D===4)&&_.stateNode.containerInfo===p)return;_=_.return}for(;j!==null;){if(_=ti(j),_===null)return;if(D=_.tag,D===5||D===6||D===26||D===27){u=y=_;continue e}j=j.parentNode}}u=u.return}sy(function(){var G=y,ne=$f(o),ie=[];e:{var Y=My.get(r);if(Y!==void 0){var Z=wc,je=r;switch(r){case"keypress":if(bc(o)===0)break e;case"keydown":case"keyup":Z=zT;break;case"focusin":je="focus",Z=Gf;break;case"focusout":je="blur",Z=Gf;break;case"beforeblur":case"afterblur":Z=Gf;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=ly;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=CT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=$T;break;case Ay:case Ry:case ky:Z=TT;break;case Oy:Z=HT;break;case"scroll":case"scrollend":Z=ST;break;case"wheel":Z=VT;break;case"copy":case"cut":case"paste":Z=RT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=uy;break;case"toggle":case"beforetoggle":Z=GT}var Be=(a&4)!==0,xt=!Be&&(r==="scroll"||r==="scrollend"),$=Be?Y!==null?Y+"Capture":null:Y;Be=[];for(var P=G,F;P!==null;){var ae=P;if(F=ae.stateNode,ae=ae.tag,ae!==5&&ae!==26&&ae!==27||F===null||$===null||(ae=To(P,$),ae!=null&&Be.push(ol(P,ae,F))),xt)break;P=P.return}0<Be.length&&(Y=new Z(Y,je,null,o,ne),ie.push({event:Y,listeners:Be}))}}if((a&7)===0){e:{if(Y=r==="mouseover"||r==="pointerover",Z=r==="mouseout"||r==="pointerout",Y&&o!==Uf&&(je=o.relatedTarget||o.fromElement)&&(ti(je)||je[ei]))break e;if((Z||Y)&&(Y=ne.window===ne?ne:(Y=ne.ownerDocument)?Y.defaultView||Y.parentWindow:window,Z?(je=o.relatedTarget||o.toElement,Z=G,je=je?ti(je):null,je!==null&&(xt=l(je),Be=je.tag,je!==xt||Be!==5&&Be!==27&&Be!==6)&&(je=null)):(Z=null,je=G),Z!==je)){if(Be=ly,ae="onMouseLeave",$="onMouseEnter",P="mouse",(r==="pointerout"||r==="pointerover")&&(Be=uy,ae="onPointerLeave",$="onPointerEnter",P="pointer"),xt=Z==null?Y:jo(Z),F=je==null?Y:jo(je),Y=new Be(ae,P+"leave",Z,o,ne),Y.target=xt,Y.relatedTarget=F,ae=null,ti(ne)===G&&(Be=new Be($,P+"enter",je,o,ne),Be.target=F,Be.relatedTarget=xt,ae=Be),xt=ae,Z&&je)t:{for(Be=FA,$=Z,P=je,F=0,ae=$;ae;ae=Be(ae))F++;ae=0;for(var Ie=P;Ie;Ie=Be(Ie))ae++;for(;0<F-ae;)$=Be($),F--;for(;0<ae-F;)P=Be(P),ae--;for(;F--;){if($===P||P!==null&&$===P.alternate){Be=$;break t}$=Be($),P=Be(P)}Be=null}else Be=null;Z!==null&&tx(ie,Y,Z,Be,!1),je!==null&&xt!==null&&tx(ie,xt,je,Be,!0)}}e:{if(Y=G?jo(G):window,Z=Y.nodeName&&Y.nodeName.toLowerCase(),Z==="select"||Z==="input"&&Y.type==="file")var ut=yy;else if(gy(Y))if(by)ut=nA;else{ut=eA;var Me=ZT}else Z=Y.nodeName,!Z||Z.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?G&&If(G.elementType)&&(ut=yy):ut=tA;if(ut&&(ut=ut(r,G))){vy(ie,ut,o,ne);break e}Me&&Me(r,Y,G),r==="focusout"&&G&&Y.type==="number"&&G.memoizedProps.value!=null&&zf(Y,"number",Y.value)}switch(Me=G?jo(G):window,r){case"focusin":(gy(Me)||Me.contentEditable==="true")&&(ui=Me,Qf=G,Po=null);break;case"focusout":Po=Qf=ui=null;break;case"mousedown":Zf=!0;break;case"contextmenu":case"mouseup":case"dragend":Zf=!1,jy(ie,o,ne);break;case"selectionchange":if(aA)break;case"keydown":case"keyup":jy(ie,o,ne)}var We;if(Yf)e:{switch(r){case"compositionstart":var at="onCompositionStart";break e;case"compositionend":at="onCompositionEnd";break e;case"compositionupdate":at="onCompositionUpdate";break e}at=void 0}else ci?my(r,o)&&(at="onCompositionEnd"):r==="keydown"&&o.keyCode===229&&(at="onCompositionStart");at&&(dy&&o.locale!=="ko"&&(ci||at!=="onCompositionStart"?at==="onCompositionEnd"&&ci&&(We=iy()):(Ea=ne,qf="value"in Ea?Ea.value:Ea.textContent,ci=!0)),Me=du(G,at),0<Me.length&&(at=new cy(at,r,null,o,ne),ie.push({event:at,listeners:Me}),We?at.data=We:(We=py(o),We!==null&&(at.data=We)))),(We=YT?WT(r,o):XT(r,o))&&(at=du(G,"onBeforeInput"),0<at.length&&(Me=new cy("onBeforeInput","beforeinput",null,o,ne),ie.push({event:Me,listeners:at}),Me.data=We)),BA(ie,r,G,o,ne)}Z0(ie,a)})}function ol(r,a,o){return{instance:r,listener:a,currentTarget:o}}function du(r,a){for(var o=a+"Capture",u=[];r!==null;){var p=r,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=To(r,o),p!=null&&u.unshift(ol(r,p,y)),p=To(r,a),p!=null&&u.push(ol(r,p,y))),r.tag===3)return u;r=r.return}return[]}function FA(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function tx(r,a,o,u,p){for(var y=a._reactName,_=[];o!==null&&o!==u;){var j=o,D=j.alternate,G=j.stateNode;if(j=j.tag,D!==null&&D===u)break;j!==5&&j!==26&&j!==27||G===null||(D=G,p?(G=To(o,y),G!=null&&_.unshift(ol(o,G,D))):p||(G=To(o,y),G!=null&&_.push(ol(o,G,D)))),o=o.return}_.length!==0&&r.push({event:a,listeners:_})}var GA=/\r\n?/g,KA=/\u0000|\uFFFD/g;function nx(r){return(typeof r=="string"?r:""+r).replace(GA,`
`).replace(KA,"")}function rx(r,a){return a=nx(a),nx(r)===a}function bt(r,a,o,u,p,y){switch(o){case"children":typeof u=="string"?a==="body"||a==="textarea"&&u===""||ii(r,u):(typeof u=="number"||typeof u=="bigint")&&a!=="body"&&ii(r,""+u);break;case"className":pc(r,"class",u);break;case"tabIndex":pc(r,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":pc(r,o,u);break;case"style":ry(r,u,y);break;case"data":if(a!=="object"){pc(r,"data",u);break}case"src":case"href":if(u===""&&(a!=="a"||o!=="href")){r.removeAttribute(o);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(o);break}u=vc(""+u),r.setAttribute(o,u);break;case"action":case"formAction":if(typeof u=="function"){r.setAttribute(o,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(o==="formAction"?(a!=="input"&&bt(r,a,"name",p.name,p,null),bt(r,a,"formEncType",p.formEncType,p,null),bt(r,a,"formMethod",p.formMethod,p,null),bt(r,a,"formTarget",p.formTarget,p,null)):(bt(r,a,"encType",p.encType,p,null),bt(r,a,"method",p.method,p,null),bt(r,a,"target",p.target,p,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(o);break}u=vc(""+u),r.setAttribute(o,u);break;case"onClick":u!=null&&(r.onclick=Vr);break;case"onScroll":u!=null&&nt("scroll",r);break;case"onScrollEnd":u!=null&&nt("scrollend",r);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(o=u.__html,o!=null){if(p.children!=null)throw Error(s(60));r.innerHTML=o}}break;case"multiple":r.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":r.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){r.removeAttribute("xlink:href");break}o=vc(""+u),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,""+u):r.removeAttribute(o);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,""):r.removeAttribute(o);break;case"capture":case"download":u===!0?r.setAttribute(o,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,u):r.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?r.setAttribute(o,u):r.removeAttribute(o);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?r.removeAttribute(o):r.setAttribute(o,u);break;case"popover":nt("beforetoggle",r),nt("toggle",r),mc(r,"popover",u);break;case"xlinkActuate":qr(r,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":qr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":qr(r,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":qr(r,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":qr(r,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":qr(r,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":qr(r,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":qr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":qr(r,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":mc(r,"is",u);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=wT.get(o)||o,mc(r,o,u))}}function Em(r,a,o,u,p,y){switch(o){case"style":ry(r,u,y);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(o=u.__html,o!=null){if(p.children!=null)throw Error(s(60));r.innerHTML=o}}break;case"children":typeof u=="string"?ii(r,u):(typeof u=="number"||typeof u=="bigint")&&ii(r,""+u);break;case"onScroll":u!=null&&nt("scroll",r);break;case"onScrollEnd":u!=null&&nt("scrollend",r);break;case"onClick":u!=null&&(r.onclick=Vr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Yv.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(p=o.endsWith("Capture"),a=o.slice(2,p?o.length-7:void 0),y=r[En]||null,y=y!=null?y[o]:null,typeof y=="function"&&r.removeEventListener(a,y,p),typeof u=="function")){typeof y!="function"&&y!==null&&(o in r?r[o]=null:r.hasAttribute(o)&&r.removeAttribute(o)),r.addEventListener(a,u,p);break e}o in r?r[o]=u:u===!0?r.setAttribute(o,""):mc(r,o,u)}}}function on(r,a,o){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":nt("error",r),nt("load",r);var u=!1,p=!1,y;for(y in o)if(o.hasOwnProperty(y)){var _=o[y];if(_!=null)switch(y){case"src":u=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,a));default:bt(r,a,y,_,o,null)}}p&&bt(r,a,"srcSet",o.srcSet,o,null),u&&bt(r,a,"src",o.src,o,null);return;case"input":nt("invalid",r);var j=y=_=p=null,D=null,G=null;for(u in o)if(o.hasOwnProperty(u)){var ne=o[u];if(ne!=null)switch(u){case"name":p=ne;break;case"type":_=ne;break;case"checked":D=ne;break;case"defaultChecked":G=ne;break;case"value":y=ne;break;case"defaultValue":j=ne;break;case"children":case"dangerouslySetInnerHTML":if(ne!=null)throw Error(s(137,a));break;default:bt(r,a,u,ne,o,null)}}Zv(r,y,j,D,G,_,p,!1);return;case"select":nt("invalid",r),u=_=y=null;for(p in o)if(o.hasOwnProperty(p)&&(j=o[p],j!=null))switch(p){case"value":y=j;break;case"defaultValue":_=j;break;case"multiple":u=j;default:bt(r,a,p,j,o,null)}a=y,o=_,r.multiple=!!u,a!=null?si(r,!!u,a,!1):o!=null&&si(r,!!u,o,!0);return;case"textarea":nt("invalid",r),y=p=u=null;for(_ in o)if(o.hasOwnProperty(_)&&(j=o[_],j!=null))switch(_){case"value":u=j;break;case"defaultValue":p=j;break;case"children":y=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(s(91));break;default:bt(r,a,_,j,o,null)}ty(r,u,p,y);return;case"option":for(D in o)if(o.hasOwnProperty(D)&&(u=o[D],u!=null))switch(D){case"selected":r.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:bt(r,a,D,u,o,null)}return;case"dialog":nt("beforetoggle",r),nt("toggle",r),nt("cancel",r),nt("close",r);break;case"iframe":case"object":nt("load",r);break;case"video":case"audio":for(u=0;u<il.length;u++)nt(il[u],r);break;case"image":nt("error",r),nt("load",r);break;case"details":nt("toggle",r);break;case"embed":case"source":case"link":nt("error",r),nt("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in o)if(o.hasOwnProperty(G)&&(u=o[G],u!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,a));default:bt(r,a,G,u,o,null)}return;default:if(If(a)){for(ne in o)o.hasOwnProperty(ne)&&(u=o[ne],u!==void 0&&Em(r,a,ne,u,o,void 0));return}}for(j in o)o.hasOwnProperty(j)&&(u=o[j],u!=null&&bt(r,a,j,u,o,null))}function YA(r,a,o,u){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,y=null,_=null,j=null,D=null,G=null,ne=null;for(Z in o){var ie=o[Z];if(o.hasOwnProperty(Z)&&ie!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=ie;default:u.hasOwnProperty(Z)||bt(r,a,Z,null,u,ie)}}for(var Y in u){var Z=u[Y];if(ie=o[Y],u.hasOwnProperty(Y)&&(Z!=null||ie!=null))switch(Y){case"type":y=Z;break;case"name":p=Z;break;case"checked":G=Z;break;case"defaultChecked":ne=Z;break;case"value":_=Z;break;case"defaultValue":j=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(s(137,a));break;default:Z!==ie&&bt(r,a,Y,Z,u,ie)}}Pf(r,_,j,D,G,ne,y,p);return;case"select":Z=_=j=Y=null;for(y in o)if(D=o[y],o.hasOwnProperty(y)&&D!=null)switch(y){case"value":break;case"multiple":Z=D;default:u.hasOwnProperty(y)||bt(r,a,y,null,u,D)}for(p in u)if(y=u[p],D=o[p],u.hasOwnProperty(p)&&(y!=null||D!=null))switch(p){case"value":Y=y;break;case"defaultValue":j=y;break;case"multiple":_=y;default:y!==D&&bt(r,a,p,y,u,D)}a=j,o=_,u=Z,Y!=null?si(r,!!o,Y,!1):!!u!=!!o&&(a!=null?si(r,!!o,a,!0):si(r,!!o,o?[]:"",!1));return;case"textarea":Z=Y=null;for(j in o)if(p=o[j],o.hasOwnProperty(j)&&p!=null&&!u.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:bt(r,a,j,null,u,p)}for(_ in u)if(p=u[_],y=o[_],u.hasOwnProperty(_)&&(p!=null||y!=null))switch(_){case"value":Y=p;break;case"defaultValue":Z=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(s(91));break;default:p!==y&&bt(r,a,_,p,u,y)}ey(r,Y,Z);return;case"option":for(var je in o)if(Y=o[je],o.hasOwnProperty(je)&&Y!=null&&!u.hasOwnProperty(je))switch(je){case"selected":r.selected=!1;break;default:bt(r,a,je,null,u,Y)}for(D in u)if(Y=u[D],Z=o[D],u.hasOwnProperty(D)&&Y!==Z&&(Y!=null||Z!=null))switch(D){case"selected":r.selected=Y&&typeof Y!="function"&&typeof Y!="symbol";break;default:bt(r,a,D,Y,u,Z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Be in o)Y=o[Be],o.hasOwnProperty(Be)&&Y!=null&&!u.hasOwnProperty(Be)&&bt(r,a,Be,null,u,Y);for(G in u)if(Y=u[G],Z=o[G],u.hasOwnProperty(G)&&Y!==Z&&(Y!=null||Z!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(s(137,a));break;default:bt(r,a,G,Y,u,Z)}return;default:if(If(a)){for(var xt in o)Y=o[xt],o.hasOwnProperty(xt)&&Y!==void 0&&!u.hasOwnProperty(xt)&&Em(r,a,xt,void 0,u,Y);for(ne in u)Y=u[ne],Z=o[ne],!u.hasOwnProperty(ne)||Y===Z||Y===void 0&&Z===void 0||Em(r,a,ne,Y,u,Z);return}}for(var $ in o)Y=o[$],o.hasOwnProperty($)&&Y!=null&&!u.hasOwnProperty($)&&bt(r,a,$,null,u,Y);for(ie in u)Y=u[ie],Z=o[ie],!u.hasOwnProperty(ie)||Y===Z||Y==null&&Z==null||bt(r,a,ie,Y,u,Z)}function ax(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function WA(){if(typeof performance.getEntriesByType=="function"){for(var r=0,a=0,o=performance.getEntriesByType("resource"),u=0;u<o.length;u++){var p=o[u],y=p.transferSize,_=p.initiatorType,j=p.duration;if(y&&j&&ax(_)){for(_=0,j=p.responseEnd,u+=1;u<o.length;u++){var D=o[u],G=D.startTime;if(G>j)break;var ne=D.transferSize,ie=D.initiatorType;ne&&ax(ie)&&(D=D.responseEnd,_+=ne*(D<j?1:(j-G)/(D-G)))}if(--u,a+=8*(y+_)/(p.duration/1e3),r++,10<r)break}}if(0<r)return a/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var Cm=null,Nm=null;function fu(r){return r.nodeType===9?r:r.ownerDocument}function sx(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ix(r,a){if(r===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&a==="foreignObject"?0:r}function jm(r,a){return r==="textarea"||r==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Tm=null;function XA(){var r=window.event;return r&&r.type==="popstate"?r===Tm?!1:(Tm=r,!0):(Tm=null,!1)}var ox=typeof setTimeout=="function"?setTimeout:void 0,JA=typeof clearTimeout=="function"?clearTimeout:void 0,lx=typeof Promise=="function"?Promise:void 0,QA=typeof queueMicrotask=="function"?queueMicrotask:typeof lx<"u"?function(r){return lx.resolve(null).then(r).catch(ZA)}:ox;function ZA(r){setTimeout(function(){throw r})}function Ba(r){return r==="head"}function cx(r,a){var o=a,u=0;do{var p=o.nextSibling;if(r.removeChild(o),p&&p.nodeType===8)if(o=p.data,o==="/$"||o==="/&"){if(u===0){r.removeChild(p),zi(a);return}u--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")u++;else if(o==="html")ll(r.ownerDocument.documentElement);else if(o==="head"){o=r.ownerDocument.head,ll(o);for(var y=o.firstChild;y;){var _=y.nextSibling,j=y.nodeName;y[No]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&y.rel.toLowerCase()==="stylesheet"||o.removeChild(y),y=_}}else o==="body"&&ll(r.ownerDocument.body);o=p}while(o);zi(a)}function ux(r,a){var o=r;r=0;do{var u=o.nextSibling;if(o.nodeType===1?a?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(a?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),u&&u.nodeType===8)if(o=u.data,o==="/$"){if(r===0)break;r--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||r++;o=u}while(o)}function Am(r){var a=r.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var o=a;switch(a=a.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":Am(o),Df(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}r.removeChild(o)}}function eR(r,a,o,u){for(;r.nodeType===1;){var p=o;if(r.nodeName.toLowerCase()!==a.toLowerCase()){if(!u&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(u){if(!r[No])switch(a){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(y=r.getAttribute("rel"),y==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(y!==p.rel||r.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||r.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||r.getAttribute("title")!==(p.title==null?null:p.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(y=r.getAttribute("src"),(y!==(p.src==null?null:p.src)||r.getAttribute("type")!==(p.type==null?null:p.type)||r.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&y&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(a==="input"&&r.type==="hidden"){var y=p.name==null?null:""+p.name;if(p.type==="hidden"&&r.getAttribute("name")===y)return r}else return r;if(r=tr(r.nextSibling),r===null)break}return null}function tR(r,a,o){if(a==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!o||(r=tr(r.nextSibling),r===null))return null;return r}function dx(r,a){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!a||(r=tr(r.nextSibling),r===null))return null;return r}function Rm(r){return r.data==="$?"||r.data==="$~"}function km(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function nR(r,a){var o=r.ownerDocument;if(r.data==="$~")r._reactRetry=a;else if(r.data!=="$?"||o.readyState!=="loading")a();else{var u=function(){a(),o.removeEventListener("DOMContentLoaded",u)};o.addEventListener("DOMContentLoaded",u),r._reactRetry=u}}function tr(r){for(;r!=null;r=r.nextSibling){var a=r.nodeType;if(a===1||a===3)break;if(a===8){if(a=r.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return r}var Om=null;function fx(r){r=r.nextSibling;for(var a=0;r;){if(r.nodeType===8){var o=r.data;if(o==="/$"||o==="/&"){if(a===0)return tr(r.nextSibling);a--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||a++}r=r.nextSibling}return null}function hx(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var o=r.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(a===0)return r;a--}else o!=="/$"&&o!=="/&"||a++}r=r.previousSibling}return null}function mx(r,a,o){switch(a=fu(o),r){case"html":if(r=a.documentElement,!r)throw Error(s(452));return r;case"head":if(r=a.head,!r)throw Error(s(453));return r;case"body":if(r=a.body,!r)throw Error(s(454));return r;default:throw Error(s(451))}}function ll(r){for(var a=r.attributes;a.length;)r.removeAttributeNode(a[0]);Df(r)}var nr=new Map,px=new Set;function hu(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var ia=K.d;K.d={f:rR,r:aR,D:sR,C:iR,L:oR,m:lR,X:uR,S:cR,M:dR};function rR(){var r=ia.f(),a=au();return r||a}function aR(r){var a=ni(r);a!==null&&a.tag===5&&a.type==="form"?Ob(a):ia.r(r)}var Di=typeof document>"u"?null:document;function gx(r,a,o){var u=Di;if(u&&typeof a=="string"&&a){var p=Yn(a);p='link[rel="'+r+'"][href="'+p+'"]',typeof o=="string"&&(p+='[crossorigin="'+o+'"]'),px.has(p)||(px.add(p),r={rel:r,crossOrigin:o,href:a},u.querySelector(p)===null&&(a=u.createElement("link"),on(a,"link",r),Jt(a),u.head.appendChild(a)))}}function sR(r){ia.D(r),gx("dns-prefetch",r,null)}function iR(r,a){ia.C(r,a),gx("preconnect",r,a)}function oR(r,a,o){ia.L(r,a,o);var u=Di;if(u&&r&&a){var p='link[rel="preload"][as="'+Yn(a)+'"]';a==="image"&&o&&o.imageSrcSet?(p+='[imagesrcset="'+Yn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(p+='[imagesizes="'+Yn(o.imageSizes)+'"]')):p+='[href="'+Yn(r)+'"]';var y=p;switch(a){case"style":y=Li(r);break;case"script":y=Pi(r)}nr.has(y)||(r=g({rel:"preload",href:a==="image"&&o&&o.imageSrcSet?void 0:r,as:a},o),nr.set(y,r),u.querySelector(p)!==null||a==="style"&&u.querySelector(cl(y))||a==="script"&&u.querySelector(ul(y))||(a=u.createElement("link"),on(a,"link",r),Jt(a),u.head.appendChild(a)))}}function lR(r,a){ia.m(r,a);var o=Di;if(o&&r){var u=a&&typeof a.as=="string"?a.as:"script",p='link[rel="modulepreload"][as="'+Yn(u)+'"][href="'+Yn(r)+'"]',y=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Pi(r)}if(!nr.has(y)&&(r=g({rel:"modulepreload",href:r},a),nr.set(y,r),o.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(ul(y)))return}u=o.createElement("link"),on(u,"link",r),Jt(u),o.head.appendChild(u)}}}function cR(r,a,o){ia.S(r,a,o);var u=Di;if(u&&r){var p=ri(u).hoistableStyles,y=Li(r);a=a||"default";var _=p.get(y);if(!_){var j={loading:0,preload:null};if(_=u.querySelector(cl(y)))j.loading=5;else{r=g({rel:"stylesheet",href:r,"data-precedence":a},o),(o=nr.get(y))&&Mm(r,o);var D=_=u.createElement("link");Jt(D),on(D,"link",r),D._p=new Promise(function(G,ne){D.onload=G,D.onerror=ne}),D.addEventListener("load",function(){j.loading|=1}),D.addEventListener("error",function(){j.loading|=2}),j.loading|=4,mu(_,a,u)}_={type:"stylesheet",instance:_,count:1,state:j},p.set(y,_)}}}function uR(r,a){ia.X(r,a);var o=Di;if(o&&r){var u=ri(o).hoistableScripts,p=Pi(r),y=u.get(p);y||(y=o.querySelector(ul(p)),y||(r=g({src:r,async:!0},a),(a=nr.get(p))&&Dm(r,a),y=o.createElement("script"),Jt(y),on(y,"link",r),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(p,y))}}function dR(r,a){ia.M(r,a);var o=Di;if(o&&r){var u=ri(o).hoistableScripts,p=Pi(r),y=u.get(p);y||(y=o.querySelector(ul(p)),y||(r=g({src:r,async:!0,type:"module"},a),(a=nr.get(p))&&Dm(r,a),y=o.createElement("script"),Jt(y),on(y,"link",r),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(p,y))}}function vx(r,a,o,u){var p=(p=te.current)?hu(p):null;if(!p)throw Error(s(446));switch(r){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(a=Li(o.href),o=ri(p).hoistableStyles,u=o.get(a),u||(u={type:"style",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){r=Li(o.href);var y=ri(p).hoistableStyles,_=y.get(r);if(_||(p=p.ownerDocument||p,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(r,_),(y=p.querySelector(cl(r)))&&!y._p&&(_.instance=y,_.state.loading=5),nr.has(r)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},nr.set(r,o),y||fR(p,r,o,_.state))),a&&u===null)throw Error(s(528,""));return _}if(a&&u!==null)throw Error(s(529,""));return null;case"script":return a=o.async,o=o.src,typeof o=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Pi(o),o=ri(p).hoistableScripts,u=o.get(a),u||(u={type:"script",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,r))}}function Li(r){return'href="'+Yn(r)+'"'}function cl(r){return'link[rel="stylesheet"]['+r+"]"}function yx(r){return g({},r,{"data-precedence":r.precedence,precedence:null})}function fR(r,a,o,u){r.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=r.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),on(a,"link",o),Jt(a),r.head.appendChild(a))}function Pi(r){return'[src="'+Yn(r)+'"]'}function ul(r){return"script[async]"+r}function bx(r,a,o){if(a.count++,a.instance===null)switch(a.type){case"style":var u=r.querySelector('style[data-href~="'+Yn(o.href)+'"]');if(u)return a.instance=u,Jt(u),u;var p=g({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(r.ownerDocument||r).createElement("style"),Jt(u),on(u,"style",p),mu(u,o.precedence,r),a.instance=u;case"stylesheet":p=Li(o.href);var y=r.querySelector(cl(p));if(y)return a.state.loading|=4,a.instance=y,Jt(y),y;u=yx(o),(p=nr.get(p))&&Mm(u,p),y=(r.ownerDocument||r).createElement("link"),Jt(y);var _=y;return _._p=new Promise(function(j,D){_.onload=j,_.onerror=D}),on(y,"link",u),a.state.loading|=4,mu(y,o.precedence,r),a.instance=y;case"script":return y=Pi(o.src),(p=r.querySelector(ul(y)))?(a.instance=p,Jt(p),p):(u=o,(p=nr.get(y))&&(u=g({},o),Dm(u,p)),r=r.ownerDocument||r,p=r.createElement("script"),Jt(p),on(p,"link",u),r.head.appendChild(p),a.instance=p);case"void":return null;default:throw Error(s(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,mu(u,o.precedence,r));return a.instance}function mu(r,a,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,y=p,_=0;_<u.length;_++){var j=u[_];if(j.dataset.precedence===a)y=j;else if(y!==p)break}y?y.parentNode.insertBefore(r,y.nextSibling):(a=o.nodeType===9?o.head:o,a.insertBefore(r,a.firstChild))}function Mm(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function Dm(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.integrity==null&&(r.integrity=a.integrity)}var pu=null;function xx(r,a,o){if(pu===null){var u=new Map,p=pu=new Map;p.set(o,u)}else p=pu,u=p.get(o),u||(u=new Map,p.set(o,u));if(u.has(r))return u;for(u.set(r,null),o=o.getElementsByTagName(r),p=0;p<o.length;p++){var y=o[p];if(!(y[No]||y[nn]||r==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var _=y.getAttribute(a)||"";_=r+_;var j=u.get(_);j?j.push(y):u.set(_,[y])}}return u}function wx(r,a,o){r=r.ownerDocument||r,r.head.insertBefore(o,a==="title"?r.querySelector("head > title"):null)}function hR(r,a,o){if(o===1||a.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;switch(a.rel){case"stylesheet":return r=a.disabled,typeof a.precedence=="string"&&r==null;default:return!0}case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function _x(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function mR(r,a,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var p=Li(u.href),y=a.querySelector(cl(p));if(y){a=y._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(r.count++,r=gu.bind(r),a.then(r,r)),o.state.loading|=4,o.instance=y,Jt(y);return}y=a.ownerDocument||a,u=yx(u),(p=nr.get(p))&&Mm(u,p),y=y.createElement("link"),Jt(y);var _=y;_._p=new Promise(function(j,D){_.onload=j,_.onerror=D}),on(y,"link",u),o.instance=y}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(o,a),(a=o.state.preload)&&(o.state.loading&3)===0&&(r.count++,o=gu.bind(r),a.addEventListener("load",o),a.addEventListener("error",o))}}var Lm=0;function pR(r,a){return r.stylesheets&&r.count===0&&yu(r,r.stylesheets),0<r.count||0<r.imgCount?function(o){var u=setTimeout(function(){if(r.stylesheets&&yu(r,r.stylesheets),r.unsuspend){var y=r.unsuspend;r.unsuspend=null,y()}},6e4+a);0<r.imgBytes&&Lm===0&&(Lm=62500*WA());var p=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&yu(r,r.stylesheets),r.unsuspend)){var y=r.unsuspend;r.unsuspend=null,y()}},(r.imgBytes>Lm?50:800)+a);return r.unsuspend=o,function(){r.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function gu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yu(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var vu=null;function yu(r,a){r.stylesheets=null,r.unsuspend!==null&&(r.count++,vu=new Map,a.forEach(gR,r),vu=null,gu.call(r))}function gR(r,a){if(!(a.state.loading&4)){var o=vu.get(r);if(o)var u=o.get(null);else{o=new Map,vu.set(r,o);for(var p=r.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var _=p[y];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(o.set(_.dataset.precedence,_),u=_)}u&&o.set(null,u)}p=a.instance,_=p.getAttribute("data-precedence"),y=o.get(_)||u,y===u&&o.set(null,p),o.set(_,p),this.count++,u=gu.bind(this),p.addEventListener("load",u),p.addEventListener("error",u),y?y.parentNode.insertBefore(p,y.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(p,r.firstChild)),a.state.loading|=4}}var dl={$$typeof:T,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function vR(r,a,o,u,p,y,_,j,D){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=_a(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_a(0),this.hiddenUpdates=_a(null),this.identifierPrefix=u,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function Sx(r,a,o,u,p,y,_,j,D,G,ne,ie){return r=new vR(r,a,o,_,D,G,ne,ie,j),a=1,y===!0&&(a|=24),y=In(3,null,null,a),r.current=y,y.stateNode=r,a=mh(),a.refCount++,r.pooledCache=a,a.refCount++,y.memoizedState={element:u,isDehydrated:o,cache:a},yh(y),r}function Ex(r){return r?(r=hi,r):hi}function Cx(r,a,o,u,p,y){p=Ex(p),u.context===null?u.context=p:u.pendingContext=p,u=Ra(a),u.payload={element:o},y=y===void 0?null:y,y!==null&&(u.callback=y),o=ka(r,u,a),o!==null&&(Rn(o,r,a),qo(o,r,a))}function Nx(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var o=r.retryLane;r.retryLane=o!==0&&o<a?o:a}}function Pm(r,a){Nx(r,a),(r=r.alternate)&&Nx(r,a)}function jx(r){if(r.tag===13||r.tag===31){var a=ps(r,67108864);a!==null&&Rn(a,r,67108864),Pm(r,67108864)}}function Tx(r){if(r.tag===13||r.tag===31){var a=qn();a=Zs(a);var o=ps(r,a);o!==null&&Rn(o,r,a),Pm(r,a)}}var bu=!0;function yR(r,a,o,u){var p=O.T;O.T=null;var y=K.p;try{K.p=2,zm(r,a,o,u)}finally{K.p=y,O.T=p}}function bR(r,a,o,u){var p=O.T;O.T=null;var y=K.p;try{K.p=8,zm(r,a,o,u)}finally{K.p=y,O.T=p}}function zm(r,a,o,u){if(bu){var p=Im(u);if(p===null)Sm(r,a,u,xu,o),Rx(r,u);else if(wR(p,r,a,o,u))u.stopPropagation();else if(Rx(r,u),a&4&&-1<xR.indexOf(r)){for(;p!==null;){var y=ni(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var _=$e(y.pendingLanes);if(_!==0){var j=y;for(j.pendingLanes|=2,j.entangledLanes|=2;_;){var D=1<<31-Tt(_);j.entanglements[1]|=D,_&=~D}Tr(y),(ft&6)===0&&(nu=qe()+500,sl(0))}}break;case 31:case 13:j=ps(y,2),j!==null&&Rn(j,y,2),au(),Pm(y,2)}if(y=Im(u),y===null&&Sm(r,a,u,xu,o),y===p)break;p=y}p!==null&&u.stopPropagation()}else Sm(r,a,u,null,o)}}function Im(r){return r=$f(r),Um(r)}var xu=null;function Um(r){if(xu=null,r=ti(r),r!==null){var a=l(r);if(a===null)r=null;else{var o=a.tag;if(o===13){if(r=c(a),r!==null)return r;r=null}else if(o===31){if(r=d(a),r!==null)return r;r=null}else if(o===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null)}}return xu=r,null}function Ax(r){switch(r){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ce()){case Pe:return 2;case ct:return 8;case tn:case Dt:return 32;case Gt:return 268435456;default:return 32}default:return 32}}var $m=!1,Ha=null,qa=null,Va=null,fl=new Map,hl=new Map,Fa=[],xR="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Rx(r,a){switch(r){case"focusin":case"focusout":Ha=null;break;case"dragenter":case"dragleave":qa=null;break;case"mouseover":case"mouseout":Va=null;break;case"pointerover":case"pointerout":fl.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":hl.delete(a.pointerId)}}function ml(r,a,o,u,p,y){return r===null||r.nativeEvent!==y?(r={blockedOn:a,domEventName:o,eventSystemFlags:u,nativeEvent:y,targetContainers:[p]},a!==null&&(a=ni(a),a!==null&&jx(a)),r):(r.eventSystemFlags|=u,a=r.targetContainers,p!==null&&a.indexOf(p)===-1&&a.push(p),r)}function wR(r,a,o,u,p){switch(a){case"focusin":return Ha=ml(Ha,r,a,o,u,p),!0;case"dragenter":return qa=ml(qa,r,a,o,u,p),!0;case"mouseover":return Va=ml(Va,r,a,o,u,p),!0;case"pointerover":var y=p.pointerId;return fl.set(y,ml(fl.get(y)||null,r,a,o,u,p)),!0;case"gotpointercapture":return y=p.pointerId,hl.set(y,ml(hl.get(y)||null,r,a,o,u,p)),!0}return!1}function kx(r){var a=ti(r.target);if(a!==null){var o=l(a);if(o!==null){if(a=o.tag,a===13){if(a=c(o),a!==null){r.blockedOn=a,Fv(r.priority,function(){Tx(o)});return}}else if(a===31){if(a=d(o),a!==null){r.blockedOn=a,Fv(r.priority,function(){Tx(o)});return}}else if(a===3&&o.stateNode.current.memoizedState.isDehydrated){r.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}r.blockedOn=null}function wu(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var o=Im(r.nativeEvent);if(o===null){o=r.nativeEvent;var u=new o.constructor(o.type,o);Uf=u,o.target.dispatchEvent(u),Uf=null}else return a=ni(o),a!==null&&jx(a),r.blockedOn=o,!1;a.shift()}return!0}function Ox(r,a,o){wu(r)&&o.delete(a)}function _R(){$m=!1,Ha!==null&&wu(Ha)&&(Ha=null),qa!==null&&wu(qa)&&(qa=null),Va!==null&&wu(Va)&&(Va=null),fl.forEach(Ox),hl.forEach(Ox)}function _u(r,a){r.blockedOn===a&&(r.blockedOn=null,$m||($m=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,_R)))}var Su=null;function Mx(r){Su!==r&&(Su=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Su===r&&(Su=null);for(var a=0;a<r.length;a+=3){var o=r[a],u=r[a+1],p=r[a+2];if(typeof u!="function"){if(Um(u||o)===null)continue;break}var y=ni(o);y!==null&&(r.splice(a,3),a-=3,Ih(y,{pending:!0,data:p,method:o.method,action:u},u,p))}}))}function zi(r){function a(D){return _u(D,r)}Ha!==null&&_u(Ha,r),qa!==null&&_u(qa,r),Va!==null&&_u(Va,r),fl.forEach(a),hl.forEach(a);for(var o=0;o<Fa.length;o++){var u=Fa[o];u.blockedOn===r&&(u.blockedOn=null)}for(;0<Fa.length&&(o=Fa[0],o.blockedOn===null);)kx(o),o.blockedOn===null&&Fa.shift();if(o=(r.ownerDocument||r).$$reactFormReplay,o!=null)for(u=0;u<o.length;u+=3){var p=o[u],y=o[u+1],_=p[En]||null;if(typeof y=="function")_||Mx(o);else if(_){var j=null;if(y&&y.hasAttribute("formAction")){if(p=y,_=y[En]||null)j=_.formAction;else if(Um(p)!==null)continue}else j=_.action;typeof j=="function"?o[u+1]=j:(o.splice(u,3),u-=3),Mx(o)}}}function Dx(){function r(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(_){return p=_})},focusReset:"manual",scroll:"manual"})}function a(){p!==null&&(p(),p=null),u||setTimeout(o,20)}function o(){if(!u&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,p=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(o,100),function(){u=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),p!==null&&(p(),p=null)}}}function Bm(r){this._internalRoot=r}Eu.prototype.render=Bm.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(s(409));var o=a.current,u=qn();Cx(o,u,r,a,null,null)},Eu.prototype.unmount=Bm.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;Cx(r.current,2,null,r,null,null),au(),a[ei]=null}};function Eu(r){this._internalRoot=r}Eu.prototype.unstable_scheduleHydration=function(r){if(r){var a=Of();r={blockedOn:null,target:r,priority:a};for(var o=0;o<Fa.length&&a!==0&&a<Fa[o].priority;o++);Fa.splice(o,0,r),o===0&&kx(r)}};var Lx=t.version;if(Lx!=="19.2.6")throw Error(s(527,Lx,"19.2.6"));K.findDOMNode=function(r){var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=m(a),r=r!==null?b(r):null,r=r===null?null:r.stateNode,r};var SR={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Cu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Cu.isDisabled&&Cu.supportsFiber)try{fn=Cu.inject(SR),Nt=Cu}catch{}}return gl.createRoot=function(r,a){if(!i(r))throw Error(s(299));var o=!1,u="",p=Hb,y=qb,_=Vb;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(p=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(_=a.onRecoverableError)),a=Sx(r,1,!1,null,null,o,u,null,p,y,_,Dx),r[ei]=a.current,_m(r),new Bm(a)},gl.hydrateRoot=function(r,a,o){if(!i(r))throw Error(s(299));var u=!1,p="",y=Hb,_=qb,j=Vb,D=null;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(p=o.identifierPrefix),o.onUncaughtError!==void 0&&(y=o.onUncaughtError),o.onCaughtError!==void 0&&(_=o.onCaughtError),o.onRecoverableError!==void 0&&(j=o.onRecoverableError),o.formState!==void 0&&(D=o.formState)),a=Sx(r,1,!0,a,o??null,u,p,D,y,_,j,Dx),a.context=Ex(null),o=a.current,u=qn(),u=Zs(u),p=Ra(u),p.callback=null,ka(o,p,u),o=u,a.current.lanes=o,At(a,o),Tr(a),r[ei]=a.current,_m(r),new Eu(a)},gl.version="19.2.6",gl}var Fx;function MR(){if(Fx)return Vm.exports;Fx=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vm.exports=OR(),Vm.exports}var DR=MR();/**
* react-router v7.15.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/var Gx="popstate";function Kx(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function LR(e={}){function t(s,i){var m;let l=(m=i.state)==null?void 0:m.masked,{pathname:c,search:d,hash:h}=l||s.location;return Lp("",{pathname:c,search:d,hash:h},i.state&&i.state.usr||null,i.state&&i.state.key||"default",l?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function n(s,i){return typeof i=="string"?i:zl(i)}return zR(t,n,null,e)}function Rt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ur(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function PR(){return Math.random().toString(36).substring(2,10)}function Yx(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Lp(e,t,n=null,s,i){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?vo(t):t,state:n,key:t&&t.key||s||PR(),mask:i}}function zl({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function vo(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function zR(e,t,n,s={}){let{window:i=document.defaultView,v5Compat:l=!1}=s,c=i.history,d="POP",h=null,m=b();m==null&&(m=0,c.replaceState({...c.state,idx:m},""));function b(){return(c.state||{idx:null}).idx}function g(){d="POP";let N=b(),C=N==null?null:N-m;m=N,h&&h({action:d,location:S.location,delta:C})}function x(N,C){d="PUSH";let A=Kx(N)?N:Lp(S.location,N,C);m=b()+1;let T=Yx(A,m),M=S.createHref(A.mask||A);try{c.pushState(T,"",M)}catch(U){if(U instanceof DOMException&&U.name==="DataCloneError")throw U;i.location.assign(M)}l&&h&&h({action:d,location:S.location,delta:1})}function w(N,C){d="REPLACE";let A=Kx(N)?N:Lp(S.location,N,C);m=b();let T=Yx(A,m),M=S.createHref(A.mask||A);c.replaceState(T,"",M),l&&h&&h({action:d,location:S.location,delta:0})}function E(N){return IR(N)}let S={get action(){return d},get location(){return e(i,c)},listen(N){if(h)throw new Error("A history only accepts one active listener");return i.addEventListener(Gx,g),h=N,()=>{i.removeEventListener(Gx,g),h=null}},createHref(N){return t(i,N)},createURL:E,encodeLocation(N){let C=E(N);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:x,replace:w,go(N){return c.go(N)}};return S}function IR(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Rt(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:zl(e);return s=s.replace(/ $/,"%20"),!t&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function Z_(e,t,n="/"){return UR(e,t,n,!1)}function UR(e,t,n,s,i){let l=typeof t=="string"?vo(t):t,c=ha(l.pathname||"/",n);if(c==null)return null;let d=$R(e),h=null,m=QR(c);for(let b=0;h==null&&b<d.length;++b)h=XR(d[b],m,s);return h}function $R(e){let t=eS(e);return BR(t),t}function eS(e,t=[],n=[],s="",i=!1){let l=(c,d,h=i,m)=>{let b={relativePath:m===void 0?c.path||"":m,caseSensitive:c.caseSensitive===!0,childrenIndex:d,route:c};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(s)&&h)return;Rt(b.relativePath.startsWith(s),`Absolute route path "${b.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(s.length)}let g=wr([s,b.relativePath]),x=n.concat(b);c.children&&c.children.length>0&&(Rt(c.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${g}".`),eS(c.children,t,x,g,h)),!(c.path==null&&!c.index)&&t.push({path:g,score:YR(g,c.index),routesMeta:x})};return e.forEach((c,d)=>{var h;if(c.path===""||!((h=c.path)!=null&&h.includes("?")))l(c,d);else for(let m of tS(c.path))l(c,d,!0,m)}),t}function tS(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,i=n.endsWith("?"),l=n.replace(/\?$/,"");if(s.length===0)return i?[l,""]:[l];let c=tS(s.join("/")),d=[];return d.push(...c.map(h=>h===""?l:[l,h].join("/"))),i&&d.push(...c),d.map(h=>e.startsWith("/")&&h===""?"/":h)}function BR(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:WR(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var HR=/^:[\w-]+$/,qR=3,VR=2,FR=1,GR=10,KR=-2,Wx=e=>e==="*";function YR(e,t){let n=e.split("/"),s=n.length;return n.some(Wx)&&(s+=KR),t&&(s+=VR),n.filter(i=>!Wx(i)).reduce((i,l)=>i+(HR.test(l)?qR:l===""?FR:GR),s)}function WR(e,t){return e.length===t.length&&e.slice(0,-1).every((s,i)=>s===t[i])?e[e.length-1]-t[t.length-1]:0}function XR(e,t,n=!1){let{routesMeta:s}=e,i={},l="/",c=[];for(let d=0;d<s.length;++d){let h=s[d],m=d===s.length-1,b=l==="/"?t:t.slice(l.length)||"/",g=md({path:h.relativePath,caseSensitive:h.caseSensitive,end:m},b),x=h.route;if(!g&&m&&n&&!s[s.length-1].route.index&&(g=md({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},b)),!g)return null;Object.assign(i,g.params),c.push({params:i,pathname:wr([l,g.pathname]),pathnameBase:nk(wr([l,g.pathnameBase])),route:x}),g.pathnameBase!=="/"&&(l=wr([l,g.pathnameBase]))}return c}function md(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=JR(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let l=i[0],c=l.replace(/(.)\/+$/,"$1"),d=i.slice(1);return{params:s.reduce((m,{paramName:b,isOptional:g},x)=>{if(b==="*"){let E=d[x]||"";c=l.slice(0,l.length-E.length).replace(/(.)\/+$/,"$1")}const w=d[x];return g&&!w?m[b]=void 0:m[b]=(w||"").replace(/%2F/g,"/"),m},{}),pathname:l,pathnameBase:c,pattern:e}}function JR(e,t=!1,n=!0){Ur(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let s=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,d,h,m,b)=>{if(s.push({paramName:d,isOptional:h!=null}),h){let g=b.charAt(m+c.length);return g&&g!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),s]}function QR(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ur(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ha(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}var ZR=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ek(e,t="/"){let{pathname:n,search:s="",hash:i=""}=typeof e=="string"?vo(e):e,l;return n?(n=rS(n),n.startsWith("/")?l=Xx(n.substring(1),"/"):l=Xx(n,t)):l=t,{pathname:l,search:rk(s),hash:ak(i)}}function Xx(e,t){let n=pd(t).split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function Ym(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function tk(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function nS(e){let t=tk(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Tg(e,t,n,s=!1){let i;typeof e=="string"?i=vo(e):(i={...e},Rt(!i.pathname||!i.pathname.includes("?"),Ym("?","pathname","search",i)),Rt(!i.pathname||!i.pathname.includes("#"),Ym("#","pathname","hash",i)),Rt(!i.search||!i.search.includes("#"),Ym("#","search","hash",i)));let l=e===""||i.pathname==="",c=l?"/":i.pathname,d;if(c==null)d=n;else{let g=t.length-1;if(!s&&c.startsWith("..")){let x=c.split("/");for(;x[0]==="..";)x.shift(),g-=1;i.pathname=x.join("/")}d=g>=0?t[g]:"/"}let h=ek(i,d),m=c&&c!=="/"&&c.endsWith("/"),b=(l||c===".")&&n.endsWith("/");return!h.pathname.endsWith("/")&&(m||b)&&(h.pathname+="/"),h}var rS=e=>e.replace(/\/\/+/g,"/"),wr=e=>rS(e.join("/")),pd=e=>e.replace(/\/+$/,""),nk=e=>pd(e).replace(/^\/*/,"/"),rk=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ak=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,sk=class{constructor(e,t,n,s=!1){this.status=e,this.statusText=t||"",this.internal=s,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ik(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ok(e){let t=e.map(n=>n.route.path).filter(Boolean);return wr(t)||"/"}var aS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sS(e,t){let n=e;if(typeof n!="string"||!ZR.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,i=!1;if(aS)try{let l=new URL(window.location.href),c=n.startsWith("//")?new URL(l.protocol+n):new URL(n),d=ha(c.pathname,t);c.origin===l.origin&&d!=null?n=d+c.search+c.hash:i=!0}catch{Ur(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var iS=["POST","PUT","PATCH","DELETE"];new Set(iS);var lk=["GET",...iS];new Set(lk);var yo=v.createContext(null);yo.displayName="DataRouter";var Fd=v.createContext(null);Fd.displayName="DataRouterState";var oS=v.createContext(!1);function ck(){return v.useContext(oS)}var lS=v.createContext({isTransitioning:!1});lS.displayName="ViewTransition";var uk=v.createContext(new Map);uk.displayName="Fetchers";var dk=v.createContext(null);dk.displayName="Await";var ir=v.createContext(null);ir.displayName="Navigation";var Jl=v.createContext(null);Jl.displayName="Location";var ya=v.createContext({outlet:null,matches:[],isDataRoute:!1});ya.displayName="Route";var Ag=v.createContext(null);Ag.displayName="RouteError";var cS="REACT_ROUTER_ERROR",fk="REDIRECT",hk="ROUTE_ERROR_RESPONSE";function mk(e){if(e.startsWith(`${cS}:${fk}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function pk(e){if(e.startsWith(`${cS}:${hk}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new sk(t.status,t.statusText,t.data)}catch{}}function gk(e,{relative:t}={}){Rt(Ql(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=v.useContext(ir),{hash:i,pathname:l,search:c}=Zl(e,{relative:t}),d=l;return n!=="/"&&(d=l==="/"?n:wr([n,l])),s.createHref({pathname:d,search:c,hash:i})}function Ql(){return v.useContext(Jl)!=null}function ba(){return Rt(Ql(),"useLocation() may be used only in the context of a <Router> component."),v.useContext(Jl).location}var uS="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function dS(e){v.useContext(ir).static||v.useLayoutEffect(e)}function vk(){let{isDataRoute:e}=v.useContext(ya);return e?Rk():yk()}function yk(){Rt(Ql(),"useNavigate() may be used only in the context of a <Router> component.");let e=v.useContext(yo),{basename:t,navigator:n}=v.useContext(ir),{matches:s}=v.useContext(ya),{pathname:i}=ba(),l=JSON.stringify(nS(s)),c=v.useRef(!1);return dS(()=>{c.current=!0}),v.useCallback((h,m={})=>{if(Ur(c.current,uS),!c.current)return;if(typeof h=="number"){n.go(h);return}let b=Tg(h,JSON.parse(l),i,m.relative==="path");e==null&&t!=="/"&&(b.pathname=b.pathname==="/"?t:wr([t,b.pathname])),(m.replace?n.replace:n.push)(b,m.state,m)},[t,n,l,i,e])}v.createContext(null);function Zl(e,{relative:t}={}){let{matches:n}=v.useContext(ya),{pathname:s}=ba(),i=JSON.stringify(nS(n));return v.useMemo(()=>Tg(e,JSON.parse(i),s,t==="path"),[e,i,s,t])}function bk(e,t){return fS(e,t)}function fS(e,t,n){var N;Rt(Ql(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=v.useContext(ir),{matches:i}=v.useContext(ya),l=i[i.length-1],c=l?l.params:{},d=l?l.pathname:"/",h=l?l.pathnameBase:"/",m=l&&l.route;{let C=m&&m.path||"";mS(d,!m||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let b=ba(),g;if(t){let C=typeof t=="string"?vo(t):t;Rt(h==="/"||((N=C.pathname)==null?void 0:N.startsWith(h)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${C.pathname}" was given in the \`location\` prop.`),g=C}else g=b;let x=g.pathname||"/",w=x;if(h!=="/"){let C=h.replace(/^\//,"").split("/");w="/"+x.replace(/^\//,"").split("/").slice(C.length).join("/")}let E=n&&n.state.matches.length?n.state.matches.map(C=>Object.assign(C,{route:n.manifest[C.route.id]||C.route})):Z_(e,{pathname:w});Ur(m||E!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),Ur(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=Ek(E&&E.map(C=>Object.assign({},C,{params:Object.assign({},c,C.params),pathname:wr([h,s.encodeLocation?s.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?h:wr([h,s.encodeLocation?s.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),i,n);return t&&S?v.createElement(Jl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...g},navigationType:"POP"}},S):S}function xk(){let e=Ak(),t=ik(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:s},l={padding:"2px 4px",backgroundColor:s},c=null;return console.error("Error handled by React Router default ErrorBoundary:",e),c=v.createElement(v.Fragment,null,v.createElement("p",null,"💿 Hey developer 👋"),v.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",v.createElement("code",{style:l},"ErrorBoundary")," or"," ",v.createElement("code",{style:l},"errorElement")," prop on your route.")),v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},t),n?v.createElement("pre",{style:i},n):null,c)}var wk=v.createElement(xk,null),hS=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=pk(e.digest);n&&(e=n)}let t=e!==void 0?v.createElement(ya.Provider,{value:this.props.routeContext},v.createElement(Ag.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?v.createElement(_k,{error:e},t):t}};hS.contextType=oS;var Wm=new WeakMap;function _k({children:e,error:t}){let{basename:n}=v.useContext(ir);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=mk(t.digest);if(s){let i=Wm.get(t);if(i)throw i;let l=sS(s.location,n);if(aS&&!Wm.get(t))if(l.isExternal||s.reloadDocument)window.location.href=l.absoluteURL||l.to;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(l.to,{replace:s.replace}));throw Wm.set(t,c),c}return v.createElement("meta",{httpEquiv:"refresh",content:`0;url=${l.absoluteURL||l.to}`})}}return e}function Sk({routeContext:e,match:t,children:n}){let s=v.useContext(yo);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),v.createElement(ya.Provider,{value:e},n)}function Ek(e,t=[],n){let s=n==null?void 0:n.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let i=e,l=s==null?void 0:s.errors;if(l!=null){let b=i.findIndex(g=>g.route.id&&(l==null?void 0:l[g.route.id])!==void 0);Rt(b>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,b+1))}let c=!1,d=-1;if(n&&s){c=s.renderFallback;for(let b=0;b<i.length;b++){let g=i[b];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(d=b),g.route.id){let{loaderData:x,errors:w}=s,E=g.route.loader&&!x.hasOwnProperty(g.route.id)&&(!w||w[g.route.id]===void 0);if(g.route.lazy||E){n.isStatic&&(c=!0),d>=0?i=i.slice(0,d+1):i=[i[0]];break}}}}let h=n==null?void 0:n.onError,m=s&&h?(b,g)=>{var x,w;h(b,{location:s.location,params:((w=(x=s.matches)==null?void 0:x[0])==null?void 0:w.params)??{},pattern:ok(s.matches),errorInfo:g})}:void 0;return i.reduceRight((b,g,x)=>{let w,E=!1,S=null,N=null;s&&(w=l&&g.route.id?l[g.route.id]:void 0,S=g.route.errorElement||wk,c&&(d<0&&x===0?(mS("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,N=null):d===x&&(E=!0,N=g.route.hydrateFallbackElement||null)));let C=t.concat(i.slice(0,x+1)),A=()=>{let T;return w?T=S:E?T=N:g.route.Component?T=v.createElement(g.route.Component,null):g.route.element?T=g.route.element:T=b,v.createElement(Sk,{match:g,routeContext:{outlet:b,matches:C,isDataRoute:s!=null},children:T})};return s&&(g.route.ErrorBoundary||g.route.errorElement||x===0)?v.createElement(hS,{location:s.location,revalidation:s.revalidation,component:S,error:w,children:A(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:m}):A()},null)}function Rg(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ck(e){let t=v.useContext(yo);return Rt(t,Rg(e)),t}function Nk(e){let t=v.useContext(Fd);return Rt(t,Rg(e)),t}function jk(e){let t=v.useContext(ya);return Rt(t,Rg(e)),t}function kg(e){let t=jk(e),n=t.matches[t.matches.length-1];return Rt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Tk(){return kg("useRouteId")}function Ak(){var s;let e=v.useContext(Ag),t=Nk("useRouteError"),n=kg("useRouteError");return e!==void 0?e:(s=t.errors)==null?void 0:s[n]}function Rk(){let{router:e}=Ck("useNavigate"),t=kg("useNavigate"),n=v.useRef(!1);return dS(()=>{n.current=!0}),v.useCallback(async(i,l={})=>{Ur(n.current,uS),n.current&&(typeof i=="number"?await e.navigate(i):await e.navigate(i,{fromRouteId:t,...l}))},[e,t])}var Jx={};function mS(e,t,n){!t&&!Jx[e]&&(Jx[e]=!0,Ur(!1,n))}v.memo(kk);function kk({routes:e,manifest:t,future:n,state:s,isStatic:i,onError:l}){return fS(e,void 0,{manifest:t,state:s,isStatic:i,onError:l})}function pS(e){Rt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ok({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:i,static:l=!1,useTransitions:c}){Rt(!Ql(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let d=e.replace(/^\/*/,"/"),h=v.useMemo(()=>({basename:d,navigator:i,static:l,useTransitions:c,future:{}}),[d,i,l,c]);typeof n=="string"&&(n=vo(n));let{pathname:m="/",search:b="",hash:g="",state:x=null,key:w="default",mask:E}=n,S=v.useMemo(()=>{let N=ha(m,d);return N==null?null:{location:{pathname:N,search:b,hash:g,state:x,key:w,mask:E},navigationType:s}},[d,m,b,g,x,w,s,E]);return Ur(S!=null,`<Router basename="${d}"> is not able to match the URL "${m}${b}${g}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:v.createElement(ir.Provider,{value:h},v.createElement(Jl.Provider,{children:t,value:S}))}function Mk({children:e,location:t}){return bk(Pp(e),t)}function Pp(e,t=[]){let n=[];return v.Children.forEach(e,(s,i)=>{if(!v.isValidElement(s))return;let l=[...t,i];if(s.type===v.Fragment){n.push.apply(n,Pp(s.props.children,l));return}Rt(s.type===pS,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Rt(!s.props.index||!s.props.children,"An index route cannot have child routes.");let c={id:s.props.id||l.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(c.children=Pp(s.props.children,l)),n.push(c)}),n}var nd="get",rd="application/x-www-form-urlencoded";function Gd(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Dk(e){return Gd(e)&&e.tagName.toLowerCase()==="button"}function Lk(e){return Gd(e)&&e.tagName.toLowerCase()==="form"}function Pk(e){return Gd(e)&&e.tagName.toLowerCase()==="input"}function zk(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ik(e,t){return e.button===0&&(!t||t==="_self")&&!zk(e)}var Nu=null;function Uk(){if(Nu===null)try{new FormData(document.createElement("form"),0),Nu=!1}catch{Nu=!0}return Nu}var $k=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Xm(e){return e!=null&&!$k.has(e)?(Ur(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${rd}"`),null):e}function Bk(e,t){let n,s,i,l,c;if(Lk(e)){let d=e.getAttribute("action");s=d?ha(d,t):null,n=e.getAttribute("method")||nd,i=Xm(e.getAttribute("enctype"))||rd,l=new FormData(e)}else if(Dk(e)||Pk(e)&&(e.type==="submit"||e.type==="image")){let d=e.form;if(d==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=e.getAttribute("formaction")||d.getAttribute("action");if(s=h?ha(h,t):null,n=e.getAttribute("formmethod")||d.getAttribute("method")||nd,i=Xm(e.getAttribute("formenctype"))||Xm(d.getAttribute("enctype"))||rd,l=new FormData(d,e),!Uk()){let{name:m,type:b,value:g}=e;if(b==="image"){let x=m?`${m}.`:"";l.append(`${x}x`,"0"),l.append(`${x}y`,"0")}else m&&l.append(m,g)}}else{if(Gd(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=nd,s=null,i=rd,c=e}return l&&i==="text/plain"&&(c=l,l=void 0),{action:s,method:n.toLowerCase(),encType:i,formData:l,body:c}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Og(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function gS(e,t,n,s){let i=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${s}`:i.pathname=`${i.pathname}.${s}`:i.pathname==="/"?i.pathname=`_root.${s}`:t&&ha(i.pathname,t)==="/"?i.pathname=`${pd(t)}/_root.${s}`:i.pathname=`${pd(i.pathname)}.${s}`,i}async function Hk(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function qk(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Vk(e,t,n){let s=await Promise.all(e.map(async i=>{let l=t.routes[i.route.id];if(l){let c=await Hk(l,n);return c.links?c.links():[]}return[]}));return Yk(s.flat(1).filter(qk).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Qx(e,t,n,s,i,l){let c=(h,m)=>n[m]?h.route.id!==n[m].route.id:!0,d=(h,m)=>{var b;return n[m].pathname!==h.pathname||((b=n[m].route.path)==null?void 0:b.endsWith("*"))&&n[m].params["*"]!==h.params["*"]};return l==="assets"?t.filter((h,m)=>c(h,m)||d(h,m)):l==="data"?t.filter((h,m)=>{var g;let b=s.routes[h.route.id];if(!b||!b.hasLoader)return!1;if(c(h,m)||d(h,m))return!0;if(h.route.shouldRevalidate){let x=h.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((g=n[0])==null?void 0:g.params)||{},nextUrl:new URL(e,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function Fk(e,t,{includeHydrateFallback:n}={}){return Gk(e.map(s=>{let i=t.routes[s.route.id];if(!i)return[];let l=[i.module];return i.clientActionModule&&(l=l.concat(i.clientActionModule)),i.clientLoaderModule&&(l=l.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(l=l.concat(i.hydrateFallbackModule)),i.imports&&(l=l.concat(i.imports)),l}).flat(1))}function Gk(e){return[...new Set(e)]}function Kk(e){let t={},n=Object.keys(e).sort();for(let s of n)t[s]=e[s];return t}function Yk(e,t){let n=new Set;return new Set(t),e.reduce((s,i)=>{let l=JSON.stringify(Kk(i));return n.has(l)||(n.add(l),s.push({key:l,link:i})),s},[])}function Mg(){let e=v.useContext(yo);return Og(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Wk(){let e=v.useContext(Fd);return Og(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Dg=v.createContext(void 0);Dg.displayName="FrameworkContext";function Lg(){let e=v.useContext(Dg);return Og(e,"You must render this element inside a <HydratedRouter> element"),e}function Xk(e,t){let n=v.useContext(Dg),[s,i]=v.useState(!1),[l,c]=v.useState(!1),{onFocus:d,onBlur:h,onMouseEnter:m,onMouseLeave:b,onTouchStart:g}=t,x=v.useRef(null);v.useEffect(()=>{if(e==="render"&&c(!0),e==="viewport"){let S=C=>{C.forEach(A=>{c(A.isIntersecting)})},N=new IntersectionObserver(S,{threshold:.5});return x.current&&N.observe(x.current),()=>{N.disconnect()}}},[e]),v.useEffect(()=>{if(s){let S=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(S)}}},[s]);let w=()=>{i(!0)},E=()=>{i(!1),c(!1)};return n?e!=="intent"?[l,x,{}]:[l,x,{onFocus:vl(d,w),onBlur:vl(h,E),onMouseEnter:vl(m,w),onMouseLeave:vl(b,E),onTouchStart:vl(g,w)}]:[!1,x,{}]}function vl(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Jk({page:e,...t}){let n=ck(),{router:s}=Mg(),i=v.useMemo(()=>Z_(s.routes,e,s.basename),[s.routes,e,s.basename]);return i?n?v.createElement(Zk,{page:e,matches:i,...t}):v.createElement(e2,{page:e,matches:i,...t}):null}function Qk(e){let{manifest:t,routeModules:n}=Lg(),[s,i]=v.useState([]);return v.useEffect(()=>{let l=!1;return Vk(e,t,n).then(c=>{l||i(c)}),()=>{l=!0}},[e,t,n]),s}function Zk({page:e,matches:t,...n}){let s=ba(),{future:i}=Lg(),{basename:l}=Mg(),c=v.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let d=gS(e,l,i.unstable_trailingSlashAwareDataRequests,"rsc"),h=!1,m=[];for(let b of t)typeof b.route.shouldRevalidate=="function"?h=!0:m.push(b.route.id);return h&&m.length>0&&d.searchParams.set("_routes",m.join(",")),[d.pathname+d.search]},[l,i.unstable_trailingSlashAwareDataRequests,e,s,t]);return v.createElement(v.Fragment,null,c.map(d=>v.createElement("link",{key:d,rel:"prefetch",as:"fetch",href:d,...n})))}function e2({page:e,matches:t,...n}){let s=ba(),{future:i,manifest:l,routeModules:c}=Lg(),{basename:d}=Mg(),{loaderData:h,matches:m}=Wk(),b=v.useMemo(()=>Qx(e,t,m,l,s,"data"),[e,t,m,l,s]),g=v.useMemo(()=>Qx(e,t,m,l,s,"assets"),[e,t,m,l,s]),x=v.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let S=new Set,N=!1;if(t.forEach(A=>{var M;let T=l.routes[A.route.id];!T||!T.hasLoader||(!b.some(U=>U.route.id===A.route.id)&&A.route.id in h&&((M=c[A.route.id])!=null&&M.shouldRevalidate)||T.hasClientLoader?N=!0:S.add(A.route.id))}),S.size===0)return[];let C=gS(e,d,i.unstable_trailingSlashAwareDataRequests,"data");return N&&S.size>0&&C.searchParams.set("_routes",t.filter(A=>S.has(A.route.id)).map(A=>A.route.id).join(",")),[C.pathname+C.search]},[d,i.unstable_trailingSlashAwareDataRequests,h,s,l,b,t,e,c]),w=v.useMemo(()=>Fk(g,l),[g,l]),E=Qk(g);return v.createElement(v.Fragment,null,x.map(S=>v.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...n})),w.map(S=>v.createElement("link",{key:S,rel:"modulepreload",href:S,...n})),E.map(({key:S,link:N})=>v.createElement("link",{key:S,nonce:n.nonce,...N,crossOrigin:N.crossOrigin??n.crossOrigin})))}function t2(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var n2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{n2&&(window.__reactRouterVersion="7.15.1")}catch{}function r2({basename:e,children:t,useTransitions:n,window:s}){let i=v.useRef();i.current==null&&(i.current=LR({window:s,v5Compat:!0}));let l=i.current,[c,d]=v.useState({action:l.action,location:l.location}),h=v.useCallback(m=>{n===!1?d(m):v.startTransition(()=>d(m))},[n]);return v.useLayoutEffect(()=>l.listen(h),[l,h]),v.createElement(Ok,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:l,useTransitions:n})}var vS=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yS=v.forwardRef(function({onClick:t,discover:n="render",prefetch:s="none",relative:i,reloadDocument:l,replace:c,mask:d,state:h,target:m,to:b,preventScrollReset:g,viewTransition:x,defaultShouldRevalidate:w,...E},S){let{basename:N,navigator:C,useTransitions:A}=v.useContext(ir),T=typeof b=="string"&&vS.test(b),M=sS(b,N);b=M.to;let U=gk(b,{relative:i}),z=ba(),L=null;if(d){let pe=Tg(d,[],z.mask?z.mask.pathname:"/",!0);N!=="/"&&(pe.pathname=pe.pathname==="/"?N:wr([N,pe.pathname])),L=C.createHref(pe)}let[B,q,ue]=Xk(s,E),le=o2(b,{replace:c,mask:d,state:h,target:m,preventScrollReset:g,relative:i,viewTransition:x,defaultShouldRevalidate:w,useTransitions:A});function he(pe){t&&t(pe),pe.defaultPrevented||le(pe)}let de=!(M.isExternal||l),ve=v.createElement("a",{...E,...ue,href:(de?L:void 0)||M.absoluteURL||U,onClick:de?he:t,ref:t2(S,q),target:m,"data-discover":!T&&n==="render"?"true":void 0});return B&&!T?v.createElement(v.Fragment,null,ve,v.createElement(Jk,{page:U})):ve});yS.displayName="Link";var a2=v.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:s="",end:i=!1,style:l,to:c,viewTransition:d,children:h,...m},b){let g=Zl(c,{relative:m.relative}),x=ba(),w=v.useContext(Fd),{navigator:E,basename:S}=v.useContext(ir),N=w!=null&&f2(g)&&d===!0,C=E.encodeLocation?E.encodeLocation(g).pathname:g.pathname,A=x.pathname,T=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(A=A.toLowerCase(),T=T?T.toLowerCase():null,C=C.toLowerCase()),T&&S&&(T=ha(T,S)||T);const M=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let U=A===C||!i&&A.startsWith(C)&&A.charAt(M)==="/",z=T!=null&&(T===C||!i&&T.startsWith(C)&&T.charAt(C.length)==="/"),L={isActive:U,isPending:z,isTransitioning:N},B=U?t:void 0,q;typeof s=="function"?q=s(L):q=[s,U?"active":null,z?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let ue=typeof l=="function"?l(L):l;return v.createElement(yS,{...m,"aria-current":B,className:q,ref:b,style:ue,to:c,viewTransition:d},typeof h=="function"?h(L):h)});a2.displayName="NavLink";var s2=v.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:s,replace:i,state:l,method:c=nd,action:d,onSubmit:h,relative:m,preventScrollReset:b,viewTransition:g,defaultShouldRevalidate:x,...w},E)=>{let{useTransitions:S}=v.useContext(ir),N=u2(),C=d2(d,{relative:m}),A=c.toLowerCase()==="get"?"get":"post",T=typeof d=="string"&&vS.test(d),M=U=>{if(h&&h(U),U.defaultPrevented)return;U.preventDefault();let z=U.nativeEvent.submitter,L=(z==null?void 0:z.getAttribute("formmethod"))||c,B=()=>N(z||U.currentTarget,{fetcherKey:t,method:L,navigate:n,replace:i,state:l,relative:m,preventScrollReset:b,viewTransition:g,defaultShouldRevalidate:x});S&&n!==!1?v.startTransition(()=>B()):B()};return v.createElement("form",{ref:E,method:A,action:C,onSubmit:s?h:M,...w,"data-discover":!T&&e==="render"?"true":void 0})});s2.displayName="Form";function i2(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bS(e){let t=v.useContext(yo);return Rt(t,i2(e)),t}function o2(e,{target:t,replace:n,mask:s,state:i,preventScrollReset:l,relative:c,viewTransition:d,defaultShouldRevalidate:h,useTransitions:m}={}){let b=vk(),g=ba(),x=Zl(e,{relative:c});return v.useCallback(w=>{if(Ik(w,t)){w.preventDefault();let E=n!==void 0?n:zl(g)===zl(x),S=()=>b(e,{replace:E,mask:s,state:i,preventScrollReset:l,relative:c,viewTransition:d,defaultShouldRevalidate:h});m?v.startTransition(()=>S()):S()}},[g,b,x,n,s,i,t,e,l,c,d,h,m])}var l2=0,c2=()=>`__${String(++l2)}__`;function u2(){let{router:e}=bS("useSubmit"),{basename:t}=v.useContext(ir),n=Tk(),s=e.fetch,i=e.navigate;return v.useCallback(async(l,c={})=>{let{action:d,method:h,encType:m,formData:b,body:g}=Bk(l,t);if(c.navigate===!1){let x=c.fetcherKey||c2();await s(x,n,c.action||d,{defaultShouldRevalidate:c.defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:b,body:g,formMethod:c.method||h,formEncType:c.encType||m,flushSync:c.flushSync})}else await i(c.action||d,{defaultShouldRevalidate:c.defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:b,body:g,formMethod:c.method||h,formEncType:c.encType||m,replace:c.replace,state:c.state,fromRouteId:n,flushSync:c.flushSync,viewTransition:c.viewTransition})},[s,i,t,n])}function d2(e,{relative:t}={}){let{basename:n}=v.useContext(ir),s=v.useContext(ya);Rt(s,"useFormAction must be used inside a RouteContext");let[i]=s.matches.slice(-1),l={...Zl(e||".",{relative:t})},c=ba();if(e==null){l.search=c.search;let d=new URLSearchParams(l.search),h=d.getAll("index");if(h.some(b=>b==="")){d.delete("index"),h.filter(g=>g).forEach(g=>d.append("index",g));let b=d.toString();l.search=b?`?${b}`:""}}return(!e||e===".")&&i.route.index&&(l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(l.pathname=l.pathname==="/"?n:wr([n,l.pathname])),zl(l)}function f2(e,{relative:t}={}){let n=v.useContext(lS);Rt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=bS("useViewTransitionState"),i=Zl(e,{relative:t});if(!n.isTransitioning)return!1;let l=ha(n.currentLocation.pathname,s)||n.currentLocation.pathname,c=ha(n.nextLocation.pathname,s)||n.nextLocation.pathname;return md(i.pathname,c)!=null||md(i.pathname,l)!=null}var ec=Q_();const xS=J_(ec);var Dr=function(){return Dr=Object.assign||function(t){for(var n,s=1,i=arguments.length;s<i;s++){n=arguments[s];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])}return t},Dr.apply(this,arguments)};function bo(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(e);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(n[s[i]]=e[s[i]]);return n}function h2(e,t,n,s){function i(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function d(b){try{m(s.next(b))}catch(g){c(g)}}function h(b){try{m(s.throw(b))}catch(g){c(g)}}function m(b){b.done?l(b.value):i(b.value).then(d,h)}m((s=s.apply(e,t||[])).next())})}function m2(e,t,n){if(n||arguments.length===2)for(var s=0,i=t.length,l;s<i;s++)(l||!(s in t))&&(l||(l=Array.prototype.slice.call(t,0,s)),l[s]=t[s]);return e.concat(l||Array.prototype.slice.call(t))}const p2=e=>e?(...t)=>e(...t):(...t)=>fetch(...t);class Pg extends Error{constructor(t,n="FunctionsError",s){super(t),this.name=n,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class g2 extends Pg{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class Zx extends Pg{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class ew extends Pg{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var zp;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(zp||(zp={}));class v2{constructor(t,{headers:n={},customFetch:s,region:i=zp.Any}={}){this.url=t,this.headers=n,this.region=i,this.fetch=p2(s)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return h2(this,arguments,void 0,function*(n,s={}){var i;let l,c;try{const{headers:d,method:h,body:m,signal:b,timeout:g}=s;let x={},{region:w}=s;w||(w=this.region);const E=new URL(`${this.url}/${n}`);w&&w!=="any"&&(x["x-region"]=w,E.searchParams.set("forceFunctionRegion",w));let S;m&&(d&&!Object.prototype.hasOwnProperty.call(d,"Content-Type")||!d)?typeof Blob<"u"&&m instanceof Blob||m instanceof ArrayBuffer?(x["Content-Type"]="application/octet-stream",S=m):typeof m=="string"?(x["Content-Type"]="text/plain",S=m):typeof FormData<"u"&&m instanceof FormData?S=m:(x["Content-Type"]="application/json",S=JSON.stringify(m)):m&&typeof m!="string"&&!(typeof Blob<"u"&&m instanceof Blob)&&!(m instanceof ArrayBuffer)&&!(typeof FormData<"u"&&m instanceof FormData)?S=JSON.stringify(m):S=m;let N=b;g&&(c=new AbortController,l=setTimeout(()=>c.abort(),g),b?(N=c.signal,b.addEventListener("abort",()=>c.abort())):N=c.signal);const C=yield this.fetch(E.toString(),{method:h||"POST",headers:Object.assign(Object.assign(Object.assign({},x),this.headers),d),body:S,signal:N}).catch(U=>{throw new g2(U)}),A=C.headers.get("x-relay-error");if(A&&A==="true")throw new Zx(C);if(!C.ok)throw new ew(C);let T=((i=C.headers.get("Content-Type"))!==null&&i!==void 0?i:"text/plain").split(";")[0].trim(),M;return T==="application/json"?M=yield C.json():T==="application/octet-stream"||T==="application/pdf"?M=yield C.blob():T==="text/event-stream"?M=C:T==="multipart/form-data"?M=yield C.formData():M=yield C.text(),{data:M,error:null,response:C}}catch(d){return{data:null,error:d,response:d instanceof ew||d instanceof Zx?d.context:void 0}}finally{l&&clearTimeout(l)}})}}const wS=3,tw=e=>Math.min(1e3*2**e,3e4),y2=[520,503],_S=["GET","HEAD","OPTIONS"];var b2=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function nw(e,t){return new Promise(n=>{if(t!=null&&t.aborted){n();return}const s=setTimeout(()=>{t==null||t.removeEventListener("abort",i),n()},e);function i(){clearTimeout(s),n()}t==null||t.addEventListener("abort",i)})}function x2(e,t,n,s){return!(!s||n>=wS||!_S.includes(e)||!y2.includes(t))}var w2=class{constructor(e){var t,n,s,i,l;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,this.shouldStripNulls=(s=e.shouldStripNulls)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(i=e.urlLengthLimit)!==null&&i!==void 0?i:8e3,this.retryEnabled=(l=e.retry)!==null&&l!==void 0?l:!0,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var n=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const c=this.headers.get("Accept");c==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!c||c==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const s=this.fetch;let l=(async()=>{let c=0;for(;;){const m=new Headers(n.headers);c>0&&m.set("X-Retry-Count",String(c));let b;try{b=await s(n.url.toString(),{method:n.method,headers:m,body:JSON.stringify(n.body,(g,x)=>typeof x=="bigint"?x.toString():x),signal:n.signal})}catch(g){if((g==null?void 0:g.name)==="AbortError"||(g==null?void 0:g.code)==="ABORT_ERR"||!_S.includes(n.method))throw g;if(n.retryEnabled&&c<wS){const x=tw(c);c++,await nw(x,n.signal);continue}throw g}if(x2(n.method,b.status,c,n.retryEnabled)){var d,h;const g=(d=(h=b.headers)===null||h===void 0?void 0:h.get("Retry-After"))!==null&&d!==void 0?d:null,x=g!==null?Math.max(0,parseInt(g,10)||0)*1e3:tw(c);await b.text(),c++,await nw(x,n.signal);continue}return await n.processResponse(b)}})();return this.shouldThrowOnError||(l=l.catch(c=>{var d;let h="",m="",b="";const g=c==null?void 0:c.cause;if(g){var x,w,E,S;const A=(x=g==null?void 0:g.message)!==null&&x!==void 0?x:"",T=(w=g==null?void 0:g.code)!==null&&w!==void 0?w:"";h=`${(E=c==null?void 0:c.name)!==null&&E!==void 0?E:"FetchError"}: ${c==null?void 0:c.message}`,h+=`
Caused by: ${(S=g==null?void 0:g.name)!==null&&S!==void 0?S:"Error"}: ${A}`,T&&(h+=` (${T})`),g!=null&&g.stack&&(h+=`
${g.stack}`)}else{var N;h=(N=c==null?void 0:c.stack)!==null&&N!==void 0?N:""}const C=this.url.toString().length;return(c==null?void 0:c.name)==="AbortError"||(c==null?void 0:c.code)==="ABORT_ERR"?(b="",m="Request was aborted (timeout or manual cancellation)",C>this.urlLengthLimit&&(m+=`. Note: Your request URL is ${C} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((g==null?void 0:g.name)==="HeadersOverflowError"||(g==null?void 0:g.code)==="UND_ERR_HEADERS_OVERFLOW")&&(b="",m="HTTP headers exceeded server limits (typically 16KB)",C>this.urlLengthLimit&&(m+=`. Your request URL is ${C} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(d=c==null?void 0:c.name)!==null&&d!==void 0?d:"FetchError"}: ${c==null?void 0:c.message}`,details:h,hint:m,code:b},data:null,count:null,status:0,statusText:""}})),l.then(e,t)}async processResponse(e){var t=this;let n=null,s=null,i=null,l=e.status,c=e.statusText;if(e.ok){var d,h;if(t.method!=="HEAD"){var m;const x=await e.text();x===""||(t.headers.get("Accept")==="text/csv"||t.headers.get("Accept")&&(!((m=t.headers.get("Accept"))===null||m===void 0)&&m.includes("application/vnd.pgrst.plan+text"))?s=x:s=JSON.parse(x))}const b=(d=t.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),g=(h=e.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");b&&g&&g.length>1&&(i=parseInt(g[1])),t.isMaybeSingle&&Array.isArray(s)&&(s.length>1?(n={code:"PGRST116",details:`Results contain ${s.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},s=null,i=null,l=406,c="Not Acceptable"):s.length===1?s=s[0]:s=null)}else{const b=await e.text();try{n=JSON.parse(b),Array.isArray(n)&&e.status===404&&(s=[],n=null,l=200,c="OK")}catch{e.status===404&&b===""?(l=204,c="No Content"):n={message:b}}if(n&&t.shouldThrowOnError)throw new b2(n)}return{success:n===null,error:n,data:s,count:i,status:l,statusText:c}}returns(){return this}overrideTypes(){return this}},_2=class extends w2{select(e){let t=!1;const n=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:i=s}={}){const l=i?`${i}.order`:"order",c=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${c?`${c},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){const s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){const i=typeof s>"u"?"offset":`${s}.offset`,l=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(l,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:i=!1,format:l="text"}={}){var c;const d=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),h=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${h}"; options=${d};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};const rw=new RegExp("[,()]");var Wi=class extends _2{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){const n=Array.from(new Set(t)).map(s=>typeof s=="string"&&rw.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}notIn(e,t){const n=Array.from(new Set(t)).map(s=>typeof s=="string"&&rw.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`not.in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const l=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${i}fts${l}.${t}`),this}match(e){return Object.entries(e).filter(([t,n])=>n!==void 0).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){const s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}},S2=class{constructor(e,{headers:t={},schema:n,fetch:s,urlLengthLimit:i=8e3,retry:l}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=s,this.urlLengthLimit=i,this.retry=l}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){const{head:n=!1,count:s}=t??{},i=n?"HEAD":"GET";let l=!1;const c=(e??"*").split("").map(m=>/\s/.test(m)&&!l?"":(m==='"'&&(l=!l),m)).join(""),{url:d,headers:h}=this.cloneRequestState();return d.searchParams.set("select",c),s&&h.append("Prefer",`count=${s}`),new Wi({method:i,url:d,headers:h,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e,{count:t,defaultToNull:n=!0}={}){var s;const i="POST",{url:l,headers:c}=this.cloneRequestState();if(t&&c.append("Prefer",`count=${t}`),n||c.append("Prefer","missing=default"),Array.isArray(e)){const d=e.reduce((h,m)=>h.concat(Object.keys(m)),[]);if(d.length>0){const h=[...new Set(d)].map(m=>`"${m}"`);l.searchParams.set("columns",h.join(","))}}return new Wi({method:i,url:l,headers:c,schema:this.schema,body:e,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:i=!0}={}){var l;const c="POST",{url:d,headers:h}=this.cloneRequestState();if(h.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&d.searchParams.set("on_conflict",t),s&&h.append("Prefer",`count=${s}`),i||h.append("Prefer","missing=default"),Array.isArray(e)){const m=e.reduce((b,g)=>b.concat(Object.keys(g)),[]);if(m.length>0){const b=[...new Set(m)].map(g=>`"${g}"`);d.searchParams.set("columns",b.join(","))}}return new Wi({method:c,url:d,headers:h,schema:this.schema,body:e,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var n;const s="PATCH",{url:i,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new Wi({method:s,url:i,headers:l,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:e}={}){var t;const n="DELETE",{url:s,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new Wi({method:n,url:s,headers:i,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function Il(e){"@babel/helpers - typeof";return Il=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Il(e)}function E2(e,t){if(Il(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var s=n.call(e,t);if(Il(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function C2(e){var t=E2(e,"string");return Il(t)=="symbol"?t:t+""}function N2(e,t,n){return(t=C2(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,s)}return n}function ju(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?aw(Object(n),!0).forEach(function(s){N2(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aw(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}var j2=class SS{constructor(t,{headers:n={},schema:s,fetch:i,timeout:l,urlLengthLimit:c=8e3,retry:d}={}){this.url=t,this.headers=new Headers(n),this.schemaName=s,this.urlLengthLimit=c;const h=i??globalThis.fetch;l!==void 0&&l>0?this.fetch=(m,b)=>{const g=new AbortController,x=setTimeout(()=>g.abort(),l),w=b==null?void 0:b.signal;if(w){if(w.aborted)return clearTimeout(x),h(m,b);const E=()=>{clearTimeout(x),g.abort()};return w.addEventListener("abort",E,{once:!0}),h(m,ju(ju({},b),{},{signal:g.signal})).finally(()=>{clearTimeout(x),w.removeEventListener("abort",E)})}return h(m,ju(ju({},b),{},{signal:g.signal})).finally(()=>clearTimeout(x))}:this.fetch=h,this.retry=d}from(t){if(!t||typeof t!="string"||t.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new S2(new URL(`${this.url}/${t}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new SS(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(t,n={},{head:s=!1,get:i=!1,count:l}={}){var c;let d;const h=new URL(`${this.url}/rpc/${t}`);let m;const b=w=>w!==null&&typeof w=="object"&&(!Array.isArray(w)||w.some(b)),g=s&&Object.values(n).some(b);g?(d="POST",m=n):s||i?(d=s?"HEAD":"GET",Object.entries(n).filter(([w,E])=>E!==void 0).map(([w,E])=>[w,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([w,E])=>{h.searchParams.append(w,E)})):(d="POST",m=n);const x=new Headers(this.headers);return g?x.set("Prefer",l?`count=${l},return=minimal`:"return=minimal"):l&&x.set("Prefer",`count=${l}`),new Wi({method:d,url:h,headers:x,schema:this.schemaName,body:m,fetch:(c=this.fetch)!==null&&c!==void 0?c:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class T2{constructor(){}static detectEnvironment(){var t;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const n=globalThis;if(typeof globalThis<"u"&&typeof n.WebSocket<"u")return{type:"native",wsConstructor:n.WebSocket};const s=typeof global<"u"?global:void 0;if(s&&typeof s.WebSocket<"u")return{type:"native",wsConstructor:s.WebSocket};if(typeof globalThis<"u"&&typeof n.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&n.EdgeRuntime||typeof navigator<"u"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const i=globalThis.process;if(i){const l=i.versions;if(l&&l.node){const c=l.node,d=parseInt(c.replace(/^v/,"").split(".")[0]);return d>=22?typeof globalThis.WebSocket<"u"?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${d} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${d} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
import ws from "ws"
new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const t=this.detectEnvironment();if(t.wsConstructor)return t.wsConstructor;let n=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(n+=`
Suggested solution: ${t.workaround}`),new Error(n)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const A2="2.106.2",R2=`realtime-js/${A2}`,k2="1.0.0",ES="2.0.0",O2=ES,M2=1e4,D2=100,Za={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},CS={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},Ip={connecting:"connecting",closing:"closing",closed:"closed"};class L2{constructor(t){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=t??[]}encode(t,n){if(t.event===this.BROADCAST_EVENT&&!(t.payload instanceof ArrayBuffer)&&typeof t.payload.event=="string")return n(this._binaryEncodeUserBroadcastPush(t));let s=[t.join_ref,t.ref,t.topic,t.event,t.payload];return n(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(t){var n;return this._isArrayBuffer((n=t.payload)===null||n===void 0?void 0:n.payload)?this._encodeBinaryUserBroadcastPush(t):this._encodeJsonUserBroadcastPush(t)}_encodeBinaryUserBroadcastPush(t){var n,s;const i=(s=(n=t.payload)===null||n===void 0?void 0:n.payload)!==null&&s!==void 0?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(t,this.BINARY_ENCODING,i)}_encodeJsonUserBroadcastPush(t){var n,s;const i=(s=(n=t.payload)===null||n===void 0?void 0:n.payload)!==null&&s!==void 0?s:{},c=new TextEncoder().encode(JSON.stringify(i)).buffer;return this._encodeUserBroadcastPush(t,this.JSON_ENCODING,c)}_encodeUserBroadcastPush(t,n,s){var i,l;const c=t.topic,d=(i=t.ref)!==null&&i!==void 0?i:"",h=(l=t.join_ref)!==null&&l!==void 0?l:"",m=t.payload.event,b=this.allowedMetadataKeys?this._pick(t.payload,this.allowedMetadataKeys):{},g=Object.keys(b).length===0?"":JSON.stringify(b);if(h.length>255)throw new Error(`joinRef length ${h.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`ref length ${d.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`topic length ${c.length} exceeds maximum of 255`);if(m.length>255)throw new Error(`userEvent length ${m.length} exceeds maximum of 255`);if(g.length>255)throw new Error(`metadata length ${g.length} exceeds maximum of 255`);const x=this.USER_BROADCAST_PUSH_META_LENGTH+h.length+d.length+c.length+m.length+g.length,w=new ArrayBuffer(this.HEADER_LENGTH+x);let E=new DataView(w),S=0;E.setUint8(S++,this.KINDS.userBroadcastPush),E.setUint8(S++,h.length),E.setUint8(S++,d.length),E.setUint8(S++,c.length),E.setUint8(S++,m.length),E.setUint8(S++,g.length),E.setUint8(S++,n),Array.from(h,C=>E.setUint8(S++,C.charCodeAt(0))),Array.from(d,C=>E.setUint8(S++,C.charCodeAt(0))),Array.from(c,C=>E.setUint8(S++,C.charCodeAt(0))),Array.from(m,C=>E.setUint8(S++,C.charCodeAt(0))),Array.from(g,C=>E.setUint8(S++,C.charCodeAt(0)));var N=new Uint8Array(w.byteLength+s.byteLength);return N.set(new Uint8Array(w),0),N.set(new Uint8Array(s),w.byteLength),N.buffer}decode(t,n){if(this._isArrayBuffer(t)){let s=this._binaryDecode(t);return n(s)}if(typeof t=="string"){const s=JSON.parse(t),[i,l,c,d,h]=s;return n({join_ref:i,ref:l,topic:c,event:d,payload:h})}return n({})}_binaryDecode(t){const n=new DataView(t),s=n.getUint8(0),i=new TextDecoder;switch(s){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(t,n,i)}}_decodeUserBroadcast(t,n,s){const i=n.getUint8(1),l=n.getUint8(2),c=n.getUint8(3),d=n.getUint8(4);let h=this.HEADER_LENGTH+4;const m=s.decode(t.slice(h,h+i));h=h+i;const b=s.decode(t.slice(h,h+l));h=h+l;const g=s.decode(t.slice(h,h+c));h=h+c;const x=t.slice(h,t.byteLength),w=d===this.JSON_ENCODING?JSON.parse(s.decode(x)):x,E={type:this.BROADCAST_EVENT,event:b,payload:w};return c>0&&(E.meta=JSON.parse(g)),{join_ref:null,ref:null,topic:m,event:this.BROADCAST_EVENT,payload:E}}_isArrayBuffer(t){var n;return t instanceof ArrayBuffer||((n=t==null?void 0:t.constructor)===null||n===void 0?void 0:n.name)==="ArrayBuffer"}_pick(t,n){return!t||typeof t!="object"?{}:Object.fromEntries(Object.entries(t).filter(([s])=>n.includes(s)))}}var _t;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(_t||(_t={}));const sw=(e,t,n={})=>{var s;const i=(s=n.skipTypes)!==null&&s!==void 0?s:[];return t?Object.keys(t).reduce((l,c)=>(l[c]=P2(c,e,t,i),l),{}):{}},P2=(e,t,n,s)=>{const i=t.find(d=>d.name===e),l=i==null?void 0:i.type,c=n[e];return l&&!s.includes(l)?NS(l,c):Up(c)},NS=(e,t)=>{if(e.charAt(0)==="_"){const n=e.slice(1,e.length);return $2(t,n)}switch(e){case _t.bool:return z2(t);case _t.float4:case _t.float8:case _t.int2:case _t.int4:case _t.int8:case _t.numeric:case _t.oid:return I2(t);case _t.json:case _t.jsonb:return U2(t);case _t.timestamp:return B2(t);case _t.abstime:case _t.date:case _t.daterange:case _t.int4range:case _t.int8range:case _t.money:case _t.reltime:case _t.text:case _t.time:case _t.timestamptz:case _t.timetz:case _t.tsrange:case _t.tstzrange:return Up(t);default:return Up(t)}},Up=e=>e,z2=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},I2=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},U2=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e},$2=(e,t)=>{if(typeof e!="string")return e;const n=e.length-1,s=e[n];if(e[0]==="{"&&s==="}"){let l;const c=e.slice(1,n);try{l=JSON.parse("["+c+"]")}catch{l=c?c.split(","):[]}return l.map(d=>NS(t,d))}return e},B2=e=>typeof e=="string"?e.replace(" ","T"):e,jS=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),t.pathname===""||t.pathname==="/"?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var Al=e=>typeof e=="function"?e:function(){return e},H2=typeof self<"u"?self:null,Xi=typeof window<"u"?window:null,Or=H2||Xi||globalThis,q2="2.0.0",V2=1e4,F2=1e3,Mr={connecting:0,open:1,closing:2,closed:3},kn={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ua={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},$p={longpoll:"longpoll",websocket:"websocket"},G2={complete:4},Bp="base64url.bearer.phx.",Tu=class{constructor(e,t,n,s){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:n}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},TS=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},K2=class{constructor(e,t,n){this.state=kn.closed,this.topic=e,this.params=Al(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Tu(this,ua.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new TS(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=kn.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=kn.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=kn.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=kn.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new Tu(this,ua.leave,Al({}),this.timeout).send(),this.state=kn.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ua.reply,(s,i)=>{this.trigger(this.replyEventName(i),s)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=kn.closed,this.bindings=[]}onClose(e){this.on(ua.close,e)}onError(e){return this.on(ua.error,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>!(n.event===e&&(typeof t>"u"||t===n.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,n=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Tu(this,e,function(){return t},n);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=kn.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ua.close,"leave")},n=new Tu(this,ua.leave,Al({}),e);return n.receive("ok",()=>t()).receive("timeout",()=>t()),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(e,t,n){return t}filterBindings(e,t,n){return!0}isMember(e,t,n,s){return this.topic!==e?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:n,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=kn.joining,this.joinPush.resend(e))}trigger(e,t,n,s){let i=this.onMessage(e,t,n,s);if(t&&!i)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let l=this.bindings.filter(c=>c.event===e&&this.filterBindings(c,t,n));for(let c=0;c<l.length;c++)l[c].callback(i,n,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===kn.closed}isErrored(){return this.state===kn.errored}isJoined(){return this.state===kn.joined}isJoining(){return this.state===kn.joining}isLeaving(){return this.state===kn.leaving}},gd=class{static request(e,t,n,s,i,l,c){if(Or.XDomainRequest){let d=new Or.XDomainRequest;return this.xdomainRequest(d,e,t,s,i,l,c)}else if(Or.XMLHttpRequest){let d=new Or.XMLHttpRequest;return this.xhrRequest(d,e,t,n,s,i,l,c)}else{if(Or.fetch&&Or.AbortController)return this.fetchRequest(e,t,n,s,i,l,c);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(e,t,n,s,i,l,c){let d={method:e,headers:n,body:s},h=null;return i&&(h=new AbortController,setTimeout(()=>h.abort(),i),d.signal=h.signal),Or.fetch(t,d).then(m=>m.text()).then(m=>this.parseJSON(m)).then(m=>c&&c(m)).catch(m=>{m.name==="AbortError"&&l?l():c&&c(null)}),h}static xdomainRequest(e,t,n,s,i,l,c){return e.timeout=i,e.open(t,n),e.onload=()=>{let d=this.parseJSON(e.responseText);c&&c(d)},l&&(e.ontimeout=l),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,n,s,i,l,c,d){e.open(t,n,!0),e.timeout=l;for(let[h,m]of Object.entries(s))e.setRequestHeader(h,m);return e.onerror=()=>d&&d(null),e.onreadystatechange=()=>{if(e.readyState===G2.complete&&d){let h=this.parseJSON(e.responseText);d(h)}},c&&(e.ontimeout=c),e.send(i),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let n=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let i=t?`${t}[${s}]`:s,l=e[s];typeof l=="object"?n.push(this.serialize(l,i)):n.push(encodeURIComponent(i)+"="+encodeURIComponent(l))}return n.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let n=e.match(/\?/)?"&":"?";return`${e}${n}${this.serialize(t)}`}},Y2=e=>{let t="",n=new Uint8Array(e),s=n.byteLength;for(let i=0;i<s;i++)t+=String.fromCharCode(n[i]);return btoa(t)},Ii=class{constructor(e,t){t&&t.length===2&&t[1].startsWith(Bp)&&(this.authToken=atob(t[1].slice(Bp.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=Mr.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+$p.websocket),"$1/"+$p.longpoll)}endpointURL(){return gd.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n){this.close(e,t,n),this.readyState=Mr.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Mr.open||this.readyState===Mr.connecting}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),t=>{if(t){var{status:n,token:s,messages:i}=t;if(n===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else n=0;switch(n){case 200:i.forEach(l=>{setTimeout(()=>this.onmessage({data:l}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Mr.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${n}`)}})}send(e){typeof e!="string"&&(e=Y2(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join(`
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,n){for(let i of this.reqs)i.abort();this.readyState=Mr.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:n});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,n,s,i){let l,c=()=>{this.reqs.delete(l),s()};l=gd.request(e,this.endpointURL(),t,n,this.timeout,c,d=>{this.reqs.delete(l),this.isActive()&&i(d)}),this.reqs.add(l)}},W2=class El{constructor(t,n={}){let s=n.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,i=>{let{onJoin:l,onLeave:c,onSync:d}=this.caller;this.joinRef=this.channel.joinRef(),this.state=El.syncState(this.state,i,l,c),this.pendingDiffs.forEach(h=>{this.state=El.syncDiff(this.state,h,l,c)}),this.pendingDiffs=[],d()}),this.channel.on(s.diff,i=>{let{onJoin:l,onLeave:c,onSync:d}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(i):(this.state=El.syncDiff(this.state,i,l,c),d())})}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}list(t){return El.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(t,n,s,i){let l=this.clone(t),c={},d={};return this.map(l,(h,m)=>{n[h]||(d[h]=m)}),this.map(n,(h,m)=>{let b=l[h];if(b){let g=m.metas.map(S=>S.phx_ref),x=b.metas.map(S=>S.phx_ref),w=m.metas.filter(S=>x.indexOf(S.phx_ref)<0),E=b.metas.filter(S=>g.indexOf(S.phx_ref)<0);w.length>0&&(c[h]=m,c[h].metas=w),E.length>0&&(d[h]=this.clone(b),d[h].metas=E)}else c[h]=m}),this.syncDiff(l,{joins:c,leaves:d},s,i)}static syncDiff(t,n,s,i){let{joins:l,leaves:c}=this.clone(n);return s||(s=function(){}),i||(i=function(){}),this.map(l,(d,h)=>{let m=t[d];if(t[d]=this.clone(h),m){let b=t[d].metas.map(x=>x.phx_ref),g=m.metas.filter(x=>b.indexOf(x.phx_ref)<0);t[d].metas.unshift(...g)}s(d,m,h)}),this.map(c,(d,h)=>{let m=t[d];if(!m)return;let b=h.metas.map(g=>g.phx_ref);m.metas=m.metas.filter(g=>b.indexOf(g.phx_ref)<0),i(d,m,h),m.metas.length===0&&delete t[d]}),t}static list(t,n){return n||(n=function(s,i){return i}),this.map(t,(s,i)=>n(s,i))}static map(t,n){return Object.getOwnPropertyNames(t).map(s=>n(s,t[s]))}static clone(t){return JSON.parse(JSON.stringify(t))}},Au={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,s,i,l,c]=JSON.parse(e);return t({join_ref:n,ref:s,topic:i,event:l,payload:c})}},binaryEncode(e){let{join_ref:t,ref:n,event:s,topic:i,payload:l}=e,c=this.META_LENGTH+t.length+n.length+i.length+s.length,d=new ArrayBuffer(this.HEADER_LENGTH+c),h=new DataView(d),m=0;h.setUint8(m++,this.KINDS.push),h.setUint8(m++,t.length),h.setUint8(m++,n.length),h.setUint8(m++,i.length),h.setUint8(m++,s.length),Array.from(t,g=>h.setUint8(m++,g.charCodeAt(0))),Array.from(n,g=>h.setUint8(m++,g.charCodeAt(0))),Array.from(i,g=>h.setUint8(m++,g.charCodeAt(0))),Array.from(s,g=>h.setUint8(m++,g.charCodeAt(0)));var b=new Uint8Array(d.byteLength+l.byteLength);return b.set(new Uint8Array(d),0),b.set(new Uint8Array(l),d.byteLength),b.buffer},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),s=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,n){let s=t.getUint8(1),i=t.getUint8(2),l=t.getUint8(3),c=this.HEADER_LENGTH+this.META_LENGTH-1,d=n.decode(e.slice(c,c+s));c=c+s;let h=n.decode(e.slice(c,c+i));c=c+i;let m=n.decode(e.slice(c,c+l));c=c+l;let b=e.slice(c,e.byteLength);return{join_ref:d,ref:null,topic:h,event:m,payload:b}},decodeReply(e,t,n){let s=t.getUint8(1),i=t.getUint8(2),l=t.getUint8(3),c=t.getUint8(4),d=this.HEADER_LENGTH+this.META_LENGTH,h=n.decode(e.slice(d,d+s));d=d+s;let m=n.decode(e.slice(d,d+i));d=d+i;let b=n.decode(e.slice(d,d+l));d=d+l;let g=n.decode(e.slice(d,d+c));d=d+c;let x=e.slice(d,e.byteLength),w={status:g,response:x};return{join_ref:h,ref:m,topic:b,event:ua.reply,payload:w}},decodeBroadcast(e,t,n){let s=t.getUint8(1),i=t.getUint8(2),l=this.HEADER_LENGTH+2,c=n.decode(e.slice(l,l+s));l=l+s;let d=n.decode(e.slice(l,l+i));l=l+i;let h=e.slice(l,e.byteLength);return{join_ref:null,ref:null,topic:c,event:d,payload:h}}},X2=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||V2,this.transport=t.transport||Or.WebSocket||Ii,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let n=null;try{n=Or&&Or.sessionStorage}catch{}this.sessionStore=t.sessionStorage||n,this.establishedConnections=0,this.defaultEncoder=Au.encode.bind(Au),this.defaultDecoder=Au.decode.bind(Au),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==Ii?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;Xi&&Xi.addEventListener&&(Xi.addEventListener("pagehide",i=>{this.conn&&(this.disconnect(),s=this.connectClock)}),Xi.addEventListener("pageshow",i=>{s===this.connectClock&&(s=null,this.connect())}),Xi.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=i=>t.rejoinAfterMs?t.rejoinAfterMs(i):[1e3,2e3,5e3][i-1]||1e4,this.reconnectAfterMs=i=>t.reconnectAfterMs?t.reconnectAfterMs(i):[10,50,100,150,200,250,500,1e3,2e3][i-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(i,l,c)=>{console.log(`${i}: ${l}`,c)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=Al(t.params||{}),this.endPoint=`${e}/${$p.websocket}`,this.vsn=t.vsn||q2,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new TS(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken}getLongPollTransport(){return Ii}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=gd.appendParams(gd.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,n){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,n)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Al(e)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==Ii?this.connectWithFallback(Ii,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(i=>{i.ref===t&&(this.off([s]),e(Date.now()-n))});return!0}transportName(e){switch(e){case Ii:return"LongPoll";default:return e.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let e;this.authToken&&(e=["phoenix",`${Bp}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let n=!1,s=!0,i,l,c=this.transportName(e),d=h=>{this.log("transport",`falling back to ${c}...`,h),this.off([i,l]),s=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${c}`))return d("memorized");this.fallbackTimer=setTimeout(d,t),l=this.onError(h=>{this.log("transport","error",h),s&&!n&&(clearTimeout(this.fallbackTimer),d(h))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(n=!0,!s){let h=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${h}`,"true"),this.log("transport",`established ${h} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(d,t),this.ping(h=>{this.log("transport","connected to primary after",h),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),F2,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,n){if(!this.conn)return e&&e();const s=this.conn;this.waitForBufferDone(s,()=>{t?s.close(t,n||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,n=1){if(n===5||!e.bufferedAmount){t();return}setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n)}waitForSocketClosed(e,t,n=1){if(n===5||e.readyState===Mr.closed){t();return}setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n)}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,n=this.establishedConnections;this.triggerStateCallbacks("error",e,t,n),(t===this.transport||n>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(ua.error,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case Mr.connecting:return"connecting";case Mr.open:return"open";case Mr.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([n])=>e.indexOf(n)===-1)}channel(e,t={}){let n=new K2(e,t,this);return this.channels.push(n),n}push(e){if(this.hasLogger()){let{topic:t,event:n,payload:s,ref:i,join_ref:l}=e;this.log("push",`${t} ${n} (${l}, ${i})`,s)}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,t=>{let{topic:n,event:s,payload:i,ref:l,join_ref:c}=t;if(l&&l===this.pendingHeartbeatRef){const d=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(i.status==="ok"?"ok":"error",d)}catch(h){this.log("error","error in heartbeat callback",h)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${i.status||""} ${n} ${s} ${l&&"("+l+")"||""}`.trim(),i);for(let d=0;d<this.channels.length;d++){const h=this.channels[d];h.isMember(n,s,i,c)&&h.trigger(s,i,l,c)}this.triggerStateCallbacks("message",t)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([n,s])=>{try{s(...t)}catch(i){this.log("error",`error in ${e} callback`,i)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}leaveOpenTopic(e){let t=this.channels.find(n=>n.topic===e&&(n.isJoined()||n.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};class Rl{constructor(t,n){const s=Q2(n);this.presence=new W2(t.getChannel(),s),this.presence.onJoin((i,l,c)=>{const d=Rl.onJoinPayload(i,l,c);t.getChannel().trigger("presence",d)}),this.presence.onLeave((i,l,c)=>{const d=Rl.onLeavePayload(i,l,c);t.getChannel().trigger("presence",d)}),this.presence.onSync(()=>{t.getChannel().trigger("presence",{event:"sync"})})}get state(){return Rl.transformState(this.presence.state)}static transformState(t){return t=J2(t),Object.getOwnPropertyNames(t).reduce((n,s)=>{const i=t[s];return n[s]=ad(i),n},{})}static onJoinPayload(t,n,s){const i=iw(n),l=ad(s);return{event:"join",key:t,currentPresences:i,newPresences:l}}static onLeavePayload(t,n,s){const i=iw(n),l=ad(s);return{event:"leave",key:t,currentPresences:i,leftPresences:l}}}function ad(e){return e.metas.map(t=>(t.presence_ref=t.phx_ref,delete t.phx_ref,delete t.phx_ref_prev,t))}function J2(e){return JSON.parse(JSON.stringify(e))}function Q2(e){return(e==null?void 0:e.events)&&{events:e.events}}function iw(e){return e!=null&&e.metas?ad(e):[]}var ow;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(ow||(ow={}));class Z2{get state(){return this.presenceAdapter.state}constructor(t,n){this.channel=t,this.presenceAdapter=new Rl(this.channel.channelAdapter,n)}}function eO(e){if(e instanceof Error)return e;if(typeof e=="string")return new Error(e);if(e&&typeof e=="object"){const t=e;if(typeof t.code=="number"){const n=typeof t.reason=="string"&&t.reason?` (${t.reason})`:"";return new Error(`socket closed: ${t.code}${n}`,{cause:e})}return new Error("channel error: transport failure",{cause:e})}return new Error("channel error: connection lost")}class tO{constructor(t,n,s){const i=nO(s);this.channel=t.getSocket().channel(n,i),this.socket=t}get state(){return this.channel.state}set state(t){this.channel.state=t}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(t,n){return this.channel.on(t,n)}off(t,n){this.channel.off(t,n)}subscribe(t){return this.channel.join(t)}unsubscribe(t){return this.channel.leave(t)}teardown(){this.channel.teardown()}onClose(t){this.channel.onClose(t)}onError(t){return this.channel.onError(t)}push(t,n,s){let i;try{i=this.channel.push(t,n,s)}catch{throw new Error(`tried to push '${t}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>D2){const l=this.channel.pushBuffer.shift();l.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${l.event}`,l.payload())}return i}updateJoinPayload(t){const n=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},n),t)}canPush(){return this.socket.isConnected()&&this.state===Za.joined}isJoined(){return this.state===Za.joined}isJoining(){return this.state===Za.joining}isClosed(){return this.state===Za.closed}isLeaving(){return this.state===Za.leaving}updateFilterBindings(t){this.channel.filterBindings=t}updatePayloadTransform(t){this.channel.onMessage=t}getChannel(){return this.channel}}function nO(e){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},e.config)}}var lw;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(lw||(lw={}));var to;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(to||(to={}));var da;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(da||(da={}));class kl{get state(){return this.channelAdapter.state}set state(t){this.channelAdapter.state=t}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(t,n={config:{}},s){var i,l;if(this.topic=t,this.params=n,this.socket=s,this.bindings={},this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.channelAdapter=new tO(this.socket.socketAdapter,t,this.params),this.presence=new Z2(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=jS(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((l=(i=this.params.config)===null||i===void 0?void 0:i.broadcast)===null||l===void 0)&&l.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(t,n=this.timeout){var s,i,l;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:c,presence:d,private:h}}=this.params,m=(i=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(w=>w.filter))!==null&&i!==void 0?i:[],b=!!this.bindings[to.PRESENCE]&&this.bindings[to.PRESENCE].length>0||((l=this.params.config.presence)===null||l===void 0?void 0:l.enabled)===!0,g={},x={broadcast:c,presence:Object.assign(Object.assign({},d),{enabled:b}),postgres_changes:m,private:h};this.socket.accessTokenValue&&(g.access_token=this.socket.accessTokenValue),this._onError(w=>{t==null||t(da.CHANNEL_ERROR,eO(w))}),this._onClose(()=>t==null?void 0:t(da.CLOSED)),this.updateJoinPayload(Object.assign({config:x},g)),this._updateFilterMessage(),this.channelAdapter.subscribe(n).receive("ok",async({postgres_changes:w})=>{if(this.socket._isManualToken()||this.socket.setAuth(),w===void 0){t==null||t(da.SUBSCRIBED);return}this._updatePostgresBindings(w,t)}).receive("error",w=>{this.state=Za.errored;const E=Object.values(w).join(", ")||"error";t==null||t(da.CHANNEL_ERROR,new Error(E,{cause:w}))}).receive("timeout",()=>{t==null||t(da.TIMED_OUT)})}return this}_updatePostgresBindings(t,n){var s;const i=this.bindings.postgres_changes,l=(s=i==null?void 0:i.length)!==null&&s!==void 0?s:0,c=[];for(let d=0;d<l;d++){const h=i[d],{filter:{event:m,schema:b,table:g,filter:x}}=h,w=t&&t[d];if(w&&w.event===m&&kl.isFilterValueEqual(w.schema,b)&&kl.isFilterValueEqual(w.table,g)&&kl.isFilterValueEqual(w.filter,x))c.push(Object.assign(Object.assign({},h),{id:w.id}));else{this.unsubscribe(),this.state=Za.errored,n==null||n(da.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=c,this.state!=Za.errored&&n&&n(da.SUBSCRIBED)}presenceState(){return this.presence.state}async track(t,n={}){return await this.send({type:"presence",event:"track",payload:t},n.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,n,s){const i=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),l=t===to.PRESENCE||t===to.POSTGRES_CHANGES;if(i&&l)throw this.socket.log("channel",`cannot add \`${t}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${t}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(t,n,s)}async httpSend(t,n,s={}){var i;if(n==null)return Promise.reject(new Error("Payload is required for httpSend()"));const l={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(l.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:l,body:JSON.stringify({messages:[{topic:this.subTopic,event:t,payload:n,private:this.private}]})},d=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(i=s.timeout)!==null&&i!==void 0?i:this.timeout);if(d.status===202)return{success:!0};let h=d.statusText;try{const m=await d.json();h=m.error||m.message||h}catch{}return Promise.reject(new Error(h))}async send(t,n={}){var s,i;if(!this.channelAdapter.canPush()&&t.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:l,payload:c}=t,d={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(d.Authorization=`Bearer ${this.socket.accessTokenValue}`);const h={method:"POST",headers:d,body:JSON.stringify({messages:[{topic:this.subTopic,event:l,payload:c,private:this.private}]})};try{const m=await this._fetchWithTimeout(this.broadcastEndpointURL,h,(s=n.timeout)!==null&&s!==void 0?s:this.timeout);return await((i=m.body)===null||i===void 0?void 0:i.cancel()),m.ok?"ok":"error"}catch(m){return m instanceof Error&&m.name==="AbortError"?"timed out":"error"}}else return new Promise(l=>{var c,d,h;const m=this.channelAdapter.push(t.type,t,n.timeout||this.timeout);t.type==="broadcast"&&!(!((h=(d=(c=this.params)===null||c===void 0?void 0:c.config)===null||d===void 0?void 0:d.broadcast)===null||h===void 0)&&h.ack)&&l("ok"),m.receive("ok",()=>l("ok")),m.receive("error",()=>l("error")),m.receive("timeout",()=>l("timed out"))})}updateJoinPayload(t){this.channelAdapter.updateJoinPayload(t)}async unsubscribe(t=this.timeout){return new Promise(n=>{this.channelAdapter.unsubscribe(t).receive("ok",()=>n("ok")).receive("timeout",()=>n("timed out")).receive("error",()=>n("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(t,n,s){const i=new AbortController,l=setTimeout(()=>i.abort(),s),c=await this.socket.fetch(t,Object.assign(Object.assign({},n),{signal:i.signal}));return clearTimeout(l),c}_on(t,n,s){const i=t.toLocaleLowerCase(),l=this.channelAdapter.on(t,s),c={type:i,filter:n,callback:s,ref:l};return this.bindings[i]?this.bindings[i].push(c):this.bindings[i]=[c],this._updateFilterMessage(),this}_onClose(t){this.channelAdapter.onClose(t)}_onError(t){this.channelAdapter.onError(t)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((t,n,s)=>{var i,l,c,d,h,m,b;const g=t.event.toLocaleLowerCase();if(this._notThisChannelEvent(g,s))return!1;const x=(i=this.bindings[g])===null||i===void 0?void 0:i.find(w=>w.ref===t.ref);if(!x)return!0;if(["broadcast","presence","postgres_changes"].includes(g))if("id"in x){const w=x.id,E=(l=x.filter)===null||l===void 0?void 0:l.event;return w&&((c=n.ids)===null||c===void 0?void 0:c.includes(w))&&(E==="*"||(E==null?void 0:E.toLocaleLowerCase())===((d=n.data)===null||d===void 0?void 0:d.type.toLocaleLowerCase()))}else{const w=(m=(h=x==null?void 0:x.filter)===null||h===void 0?void 0:h.event)===null||m===void 0?void 0:m.toLocaleLowerCase();return w==="*"||w===((b=n==null?void 0:n.event)===null||b===void 0?void 0:b.toLocaleLowerCase())}else return x.type.toLocaleLowerCase()===g})}_notThisChannelEvent(t,n){const{close:s,error:i,leave:l,join:c}=CS;return n&&[s,i,l,c].includes(t)&&n!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((t,n,s)=>{if(typeof n=="object"&&"ids"in n){const i=n.data,{schema:l,table:c,commit_timestamp:d,type:h,errors:m}=i;return Object.assign(Object.assign({},{schema:l,table:c,commit_timestamp:d,eventType:h,new:{},old:{},errors:m}),this._getPayloadRecords(i))}return n})}copyBindings(t){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const n in t.bindings)for(const s of t.bindings[n])this._on(s.type,s.filter,s.callback)}static isFilterValueEqual(t,n){return(t??void 0)===(n??void 0)}_getPayloadRecords(t){const n={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(n.new=sw(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(n.old=sw(t.columns,t.old_record)),n}}class rO{constructor(t,n){this.socket=new X2(t,n)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(t){this.socket.heartbeatCallback=t}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(t,n,s,i=1e4){return new Promise(l=>{setTimeout(()=>l("timeout"),i),this.socket.disconnect(()=>{t(),l("ok")},n,s)})}push(t){this.socket.push(t)}log(t,n,s){this.socket.log(t,n,s)}makeRef(){return this.socket.makeRef()}onOpen(t){this.socket.onOpen(t)}onClose(t){this.socket.onClose(t)}onError(t){this.socket.onError(t)}onMessage(t){this.socket.onMessage(t)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==Ip.connecting}isDisconnecting(){return this.socket.connectionState()==Ip.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const cw={HEARTBEAT_INTERVAL:25e3},aO=[1e3,2e3,5e3,1e4],sO=1e4;function iO(){const e=new Map;return{get length(){return e.size},clear(){e.clear()},getItem(t){return e.has(t)?e.get(t):null},key(t){var n;return(n=Array.from(e.keys())[t])!==null&&n!==void 0?n:null},removeItem(t){e.delete(t)},setItem(t,n){e.set(t,String(n))}}}function oO(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return iO()}const lO=`
addEventListener("message", (e) => {
if (e.data.event === "start") {
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
}
});`;class cO{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(t,n){var s;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new L2,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=l=>l?(...c)=>l(...c):(...c)=>fetch(...c),!(!((s=n==null?void 0:n.params)===null||s===void 0)&&s.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey;const i=this._initializeOptions(n);this.socketAdapter=new rO(t,i),this.httpEndpoint=jS(t),this.fetch=this._resolveFetch(n==null?void 0:n.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(t){const n=t.message;throw n.includes("Node.js")?new Error(`${n}
To use Realtime in Node.js, you need to provide a WebSocket implementation:
Option 1: Use Node.js 22+ which has native WebSocket support
Option 2: Install and provide the "ws" package:
npm install ws
import ws from "ws"
const client = new RealtimeClient(url, {
...options,
transport: ws
})`):new Error(`WebSocket not available: ${n}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(t,n){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},t,n)}getChannels(){return this.channels}async removeChannel(t){const n=await t.unsubscribe();return n==="ok"&&t.teardown(),n}async removeAllChannels(){const t=this.channels.map(async s=>{const i=await s.unsubscribe();return s.teardown(),i}),n=await Promise.all(t);return await this.disconnect(),n}log(t,n,s){this.socketAdapter.log(t,n,s)}connectionState(){return this.socketAdapter.connectionState()||Ip.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(t,n={config:{}}){const s=`realtime:${t}`,i=this.getChannels().find(l=>l.topic===s);if(i)return i;{const l=new kl(`realtime:${t}`,n,this);return this._cancelPendingDisconnect(),this.channels.push(l),l}}push(t){this.socketAdapter.push(t)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(t){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(t)}_makeRef(){return this.socketAdapter.makeRef()}_remove(t){this.channels=this.channels.filter(n=>n.topic!==t.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(t=null){let n,s=!1;if(t)n=t,s=!0;else if(this.accessToken)try{n=await this.accessToken()}catch(i){this.log("error","Error fetching access token from callback",i),n=this.accessTokenValue}else n=this.accessTokenValue;s?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(i=>{const l={access_token:n,version:R2};n&&i.updateJoinPayload(l),i.joinedOnce&&i.channelAdapter.isJoined()&&i.channelAdapter.push(CS.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this._isManualToken()||this.setAuth().catch(n=>{this.log("error",`Error setting auth in ${t}`,n)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(n=>{this.log("error","error waiting for auth on connect",n)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(t=>{t.ref&&t.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(t){return(n,s)=>{n=="sent"&&this._setAuthSafely(),t&&t(n,s)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(t){let n;if(t)n=t;else{const s=new Blob([lO],{type:"application/javascript"});n=URL.createObjectURL(s)}return n}_initializeOptions(t){var n,s,i,l,c,d,h,m,b,g,x,w;this.worker=(n=t==null?void 0:t.worker)!==null&&n!==void 0?n:!1,this.accessToken=(s=t==null?void 0:t.accessToken)!==null&&s!==void 0?s:null;const E={};E.timeout=(i=t==null?void 0:t.timeout)!==null&&i!==void 0?i:M2,E.heartbeatIntervalMs=(l=t==null?void 0:t.heartbeatIntervalMs)!==null&&l!==void 0?l:cw.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(c=t==null?void 0:t.disconnectOnEmptyChannelsAfterMs)!==null&&c!==void 0?c:2*((d=t==null?void 0:t.heartbeatIntervalMs)!==null&&d!==void 0?d:cw.HEARTBEAT_INTERVAL),E.transport=(h=t==null?void 0:t.transport)!==null&&h!==void 0?h:T2.getWebSocketConstructor(),E.params=t==null?void 0:t.params,E.logger=t==null?void 0:t.logger,E.heartbeatCallback=this._wrapHeartbeatCallback(t==null?void 0:t.heartbeatCallback),E.sessionStorage=(m=t==null?void 0:t.sessionStorage)!==null&&m!==void 0?m:oO(),E.reconnectAfterMs=(b=t==null?void 0:t.reconnectAfterMs)!==null&&b!==void 0?b:(A=>aO[A-1]||sO);let S,N;const C=(g=t==null?void 0:t.vsn)!==null&&g!==void 0?g:O2;switch(C){case k2:S=(A,T)=>T(JSON.stringify(A)),N=(A,T)=>T(JSON.parse(A));break;case ES:S=this.serializer.encode.bind(this.serializer),N=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${E.vsn}`)}if(E.vsn=C,E.encode=(x=t==null?void 0:t.encode)!==null&&x!==void 0?x:S,E.decode=(w=t==null?void 0:t.decode)!==null&&w!==void 0?w:N,E.beforeReconnect=this._reconnectAuth.bind(this),(t!=null&&t.logLevel||t!=null&&t.log_level)&&(this.logLevel=t.logLevel||t.log_level,E.params=Object.assign(Object.assign({},E.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t==null?void 0:t.workerUrl,E.autoSendHeartbeat=!this.worker}return E}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var Ul=class extends Error{constructor(e,t){var n;super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown=t.icebergType==="CommitStateUnknownException"||[500,502,504].includes(t.status)&&((n=t.icebergType)==null?void 0:n.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function uO(e,t,n){const s=new URL(t,e);if(n)for(const[i,l]of Object.entries(n))l!==void 0&&s.searchParams.set(i,l);return s.toString()}async function dO(e){return!e||e.type==="none"?{}:e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:e.type==="header"?{[e.name]:e.value}:e.type==="custom"?await e.getHeaders():{}}function fO(e){const t=e.fetchImpl??globalThis.fetch;return{async request({method:n,path:s,query:i,body:l,headers:c}){const d=uO(e.baseUrl,s,i),h=await dO(e.auth),m=await t(d,{method:n,headers:{...l?{"Content-Type":"application/json"}:{},...h,...c},body:l?JSON.stringify(l):void 0}),b=await m.text(),g=(m.headers.get("content-type")||"").includes("application/json"),x=g&&b?JSON.parse(b):b;if(!m.ok){const w=g?x:void 0,E=w==null?void 0:w.error;throw new Ul((E==null?void 0:E.message)??`Request failed with status ${m.status}`,{status:m.status,icebergType:E==null?void 0:E.type,icebergCode:E==null?void 0:E.code,details:w})}return{status:m.status,headers:m.headers,data:x}}}}function Ru(e){return e.join("")}var hO=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){const t=e?{parent:Ru(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(s=>({namespace:s}))}async createNamespace(e,t){const n={namespace:e.namespace,properties:t==null?void 0:t.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ru(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ru(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ru(e.namespace)}`}),!0}catch(t){if(t instanceof Ul&&t.status===404)return!1;throw t}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(n){if(n instanceof Ul&&n.status===409)return;throw n}}};function Ui(e){return e.join("")}var mO=class{constructor(e,t="",n){this.client=e,this.prefix=t,this.accessDelegation=n}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ui(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){const n={};return this.accessDelegation&&(n["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Ui(e.namespace)}/tables`,body:t,headers:n})).data.metadata}async updateTable(e,t){const n=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Ui(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":n.data["metadata-location"],metadata:n.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ui(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String((t==null?void 0:t.purge)??!1)}})}async loadTable(e){const t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ui(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){const t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ui(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(n){if(n instanceof Ul&&n.status===404)return!1;throw n}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(n){if(n instanceof Ul&&n.status===409)return await this.loadTable({namespace:e.namespace,name:t.name});throw n}}},pO=class{constructor(e){var s;let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);const n=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=fO({baseUrl:n,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=(s=e.accessDelegation)==null?void 0:s.join(","),this.namespaceOps=new hO(this.client,t),this.tableOps=new mO(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}};function $l(e){"@babel/helpers - typeof";return $l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$l(e)}function gO(e,t){if($l(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var s=n.call(e,t);if($l(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function vO(e){var t=gO(e,"string");return $l(t)=="symbol"?t:t+""}function yO(e,t,n){return(t=vO(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,s)}return n}function Ve(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?uw(Object(n),!0).forEach(function(s){yO(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uw(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}var Kd=class extends Error{constructor(e,t="storage",n,s){super(e),this.__isStorageError=!0,this.namespace=t,this.name=t==="vectors"?"StorageVectorsError":"StorageError",this.status=n,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function Yd(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}var Hp=class extends Kd{constructor(e,t,n,s="storage"){super(e,s,t,n),this.name=s==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=n}toJSON(){return Ve({},super.toJSON())}},AS=class extends Kd{constructor(e,t,n="storage"){super(e,n),this.name=n==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function vd(e,t,n){const s=Ve({},e),i=t.toLowerCase();for(const l of Object.keys(s))l.toLowerCase()===i&&delete s[l];return s[i]=n,s}function bO(e){const t={};for(const[n,s]of Object.entries(e))t[n.toLowerCase()]=s;return t}const xO=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),wO=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},qp=e=>{if(Array.isArray(e))return e.map(n=>qp(n));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([n,s])=>{const i=n.replace(/([-_][a-z])/gi,l=>l.toUpperCase().replace(/[-_]/g,""));t[i]=qp(s)}),t},_O=e=>!e||typeof e!="string"||e.length===0||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(e),dw=e=>{if(typeof e=="object"&&e!==null){const t=e;if(typeof t.msg=="string")return t.msg;if(typeof t.message=="string")return t.message;if(typeof t.error_description=="string")return t.error_description;if(typeof t.error=="string")return t.error;if(typeof t.error=="object"&&t.error!==null){const n=t.error;if(typeof n.message=="string")return n.message}}return JSON.stringify(e)},SO=async(e,t,n,s)=>{if(e!==null&&typeof e=="object"&&"json"in e&&typeof e.json=="function"){const i=e;let l=parseInt(String(i.status),10);Number.isFinite(l)||(l=500),i.json().then(c=>{const d=(c==null?void 0:c.statusCode)||(c==null?void 0:c.code)||l+"";t(new Hp(dw(c),l,d,s))}).catch(()=>{const c=l+"";t(new Hp(i.statusText||`HTTP ${l} error`,l,c,s))})}else t(new AS(dw(e),e,s))},EO=(e,t,n,s)=>{const i={method:e,headers:(t==null?void 0:t.headers)||{}};if(e==="GET"||e==="HEAD"||!s)return Ve(Ve({},i),n);if(wO(s)){var l;const c=(t==null?void 0:t.headers)||{};let d;for(const[h,m]of Object.entries(c))h.toLowerCase()==="content-type"&&(d=m);i.headers=vd(c,"Content-Type",(l=d)!==null&&l!==void 0?l:"application/json"),i.body=JSON.stringify(s)}else i.body=s;return t!=null&&t.duplex&&(i.duplex=t.duplex),Ve(Ve({},i),n)};async function yl(e,t,n,s,i,l,c){return new Promise((d,h)=>{e(n,EO(t,s,i,l)).then(m=>{if(!m.ok)throw m;if(s!=null&&s.noResolveJson)return m;if(c==="vectors"){const b=m.headers.get("content-type");if(m.headers.get("content-length")==="0"||m.status===204)return{};if(!b||!b.includes("application/json"))return{}}return m.json()}).then(m=>d(m)).catch(m=>SO(m,h,s,c))})}function RS(e="storage"){return{get:async(t,n,s,i)=>yl(t,"GET",n,s,i,void 0,e),post:async(t,n,s,i,l)=>yl(t,"POST",n,i,l,s,e),put:async(t,n,s,i,l)=>yl(t,"PUT",n,i,l,s,e),head:async(t,n,s,i)=>yl(t,"HEAD",n,Ve(Ve({},s),{},{noResolveJson:!0}),i,void 0,e),remove:async(t,n,s,i,l)=>yl(t,"DELETE",n,i,l,s,e)}}const CO=RS("storage"),{get:Bl,post:vr,put:Vp,head:NO,remove:zg}=CO,Fn=RS("vectors");var xo=class{constructor(e,t={},n,s="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=bO(t),this.fetch=xO(n),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=vd(this.headers,e,t),this}async handleOperation(e){var t=this;try{return{data:await e(),error:null}}catch(n){if(t.shouldThrowOnError)throw n;if(Yd(n))return{data:null,error:n};throw n}}};let kS;kS=Symbol.toStringTag;var jO=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[kS]="StreamDownloadBuilder",this.promise=null}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var e=this;try{return{data:(await e.downloadFn()).body,error:null}}catch(t){if(e.shouldThrowOnError)throw t;if(Yd(t))return{data:null,error:t};throw t}}};let OS;OS=Symbol.toStringTag;var TO=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[OS]="BlobDownloadBuilder",this.promise=null}asStream(){return new jO(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var e=this;try{return{data:await(await e.downloadFn()).blob(),error:null}}catch(t){if(e.shouldThrowOnError)throw t;if(Yd(t))return{data:null,error:t};throw t}}};const AO={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},fw={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var RO=class extends xo{constructor(e,t={},n,s){super(e,t,s,"storage"),this.bucketId=n}async uploadOrUpdate(e,t,n,s){var i=this;return i.handleOperation(async()=>{let l;const c=Ve(Ve({},fw),s);let d=Ve(Ve({},i.headers),e==="POST"&&{"x-upsert":String(c.upsert)});const h=c.metadata;if(typeof Blob<"u"&&n instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),h&&l.append("metadata",i.encodeMetadata(h)),l.append("",n)):typeof FormData<"u"&&n instanceof FormData?(l=n,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),h&&!l.has("metadata")&&l.append("metadata",i.encodeMetadata(h))):(l=n,d["cache-control"]=`max-age=${c.cacheControl}`,d["content-type"]=c.contentType,h&&(d["x-metadata"]=i.toBase64(i.encodeMetadata(h))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),s!=null&&s.headers)for(const[x,w]of Object.entries(s.headers))d=vd(d,x,w);const m=i._removeEmptyFolders(t),b=i._getFinalPath(m),g=await(e=="PUT"?Vp:vr)(i.fetch,`${i.url}/object/${b}`,l,Ve({headers:d},c!=null&&c.duplex?{duplex:c.duplex}:{}));return{path:m,id:g.Id,fullPath:g.Key}})}async upload(e,t,n){return this.uploadOrUpdate("POST",e,t,n)}async uploadToSignedUrl(e,t,n,s){var i=this;const l=i._removeEmptyFolders(e),c=i._getFinalPath(l),d=new URL(i.url+`/object/upload/sign/${c}`);return d.searchParams.set("token",t),i.handleOperation(async()=>{let h;const m=Ve(Ve({},fw),s);let b=Ve(Ve({},i.headers),{"x-upsert":String(m.upsert)});const g=m.metadata;if(typeof Blob<"u"&&n instanceof Blob?(h=new FormData,h.append("cacheControl",m.cacheControl),g&&h.append("metadata",i.encodeMetadata(g)),h.append("",n)):typeof FormData<"u"&&n instanceof FormData?(h=n,h.has("cacheControl")||h.append("cacheControl",m.cacheControl),g&&!h.has("metadata")&&h.append("metadata",i.encodeMetadata(g))):(h=n,b["cache-control"]=`max-age=${m.cacheControl}`,b["content-type"]=m.contentType,g&&(b["x-metadata"]=i.toBase64(i.encodeMetadata(g))),(typeof ReadableStream<"u"&&h instanceof ReadableStream||h&&typeof h=="object"&&"pipe"in h&&typeof h.pipe=="function")&&!m.duplex&&(m.duplex="half")),s!=null&&s.headers)for(const[x,w]of Object.entries(s.headers))b=vd(b,x,w);return{path:l,fullPath:(await Vp(i.fetch,d.toString(),h,Ve({headers:b},m!=null&&m.duplex?{duplex:m.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var n=this;return n.handleOperation(async()=>{let s=n._getFinalPath(e);const i=Ve({},n.headers);t!=null&&t.upsert&&(i["x-upsert"]="true");const l=await vr(n.fetch,`${n.url}/object/upload/sign/${s}`,{},{headers:i}),c=new URL(n.url+l.url),d=c.searchParams.get("token");if(!d)throw new Kd("No token returned by API");return{signedUrl:c.toString(),path:e,token:d}})}async update(e,t,n){return this.uploadOrUpdate("PUT",e,t,n)}async move(e,t,n){var s=this;return s.handleOperation(async()=>await vr(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:s.headers}))}async copy(e,t,n){var s=this;return s.handleOperation(async()=>({path:(await vr(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(e,t,n){var s=this;return s.handleOperation(async()=>{let i=s._getFinalPath(e);const l=typeof(n==null?void 0:n.transform)=="object"&&n.transform!==null&&Object.keys(n.transform).length>0;let c=await vr(s.fetch,`${s.url}/object/sign/${i}`,Ve({expiresIn:t},l?{transform:n.transform}:{}),{headers:s.headers});const d=new URLSearchParams;n!=null&&n.download&&d.set("download",n.download===!0?"":n.download),(n==null?void 0:n.cacheNonce)!=null&&d.set("cacheNonce",String(n.cacheNonce));const h=d.toString();return{signedUrl:encodeURI(`${s.url}${c.signedURL}${h?`&${h}`:""}`)}})}async createSignedUrls(e,t,n){var s=this;return s.handleOperation(async()=>{const i=await vr(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:t,paths:e},{headers:s.headers}),l=new URLSearchParams;n!=null&&n.download&&l.set("download",n.download===!0?"":n.download),(n==null?void 0:n.cacheNonce)!=null&&l.set("cacheNonce",String(n.cacheNonce));const c=l.toString();return i.map(d=>Ve(Ve({},d),{},{signedUrl:d.signedURL?encodeURI(`${s.url}${d.signedURL}${c?`&${c}`:""}`):null}))})}download(e,t,n){const s=typeof(t==null?void 0:t.transform)=="object"&&t.transform!==null&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",i=new URLSearchParams;t!=null&&t.transform&&this.applyTransformOptsToQuery(i,t.transform),(t==null?void 0:t.cacheNonce)!=null&&i.set("cacheNonce",String(t.cacheNonce));const l=i.toString(),c=this._getFinalPath(e),d=()=>Bl(this.fetch,`${this.url}/${s}/${c}${l?`?${l}`:""}`,{headers:this.headers,noResolveJson:!0},n);return new TO(d,this.shouldThrowOnError)}async info(e){var t=this;const n=t._getFinalPath(e);return t.handleOperation(async()=>qp(await Bl(t.fetch,`${t.url}/object/info/${n}`,{headers:t.headers})))}async exists(e){var t=this;const n=t._getFinalPath(e);try{return await NO(t.fetch,`${t.url}/object/${n}`,{headers:t.headers}),{data:!0,error:null}}catch(i){if(t.shouldThrowOnError)throw i;if(Yd(i)){var s;const l=i instanceof Hp?i.status:i instanceof AS?(s=i.originalError)===null||s===void 0?void 0:s.status:void 0;if(l!==void 0&&[400,404].includes(l))return{data:!1,error:i}}throw i}}getPublicUrl(e,t){const n=this._getFinalPath(e),s=new URLSearchParams;t!=null&&t.download&&s.set("download",t.download===!0?"":t.download),t!=null&&t.transform&&this.applyTransformOptsToQuery(s,t.transform),(t==null?void 0:t.cacheNonce)!=null&&s.set("cacheNonce",String(t.cacheNonce));const i=s.toString(),l=typeof(t==null?void 0:t.transform)=="object"&&t.transform!==null&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${l}/public/${n}`)+(i?`?${i}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await zg(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async list(e,t,n){var s=this;return s.handleOperation(async()=>{const i=Ve(Ve(Ve({},AO),t),{},{prefix:e||""});return await vr(s.fetch,`${s.url}/object/list/${s.bucketId}`,i,{headers:s.headers},n)})}async listV2(e,t){var n=this;return n.handleOperation(async()=>{const s=Ve({},e);return await vr(n.fetch,`${n.url}/object/list-v2/${n.bucketId}`,s,{headers:n.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("quality",t.quality.toString()),e}};const kO="2.106.2",tc={"X-Client-Info":`storage-js/${kO}`};var OO=class extends xo{constructor(e,t={},n,s){const i=new URL(e);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase."));const l=i.href.replace(/\/$/,""),c=Ve(Ve({},tc),t);super(l,c,n,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=t.listBucketOptionsToQueryString(e);return await Bl(t.fetch,`${t.url}/bucket${n}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await Bl(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var n=this;return n.handleOperation(async()=>await vr(n.fetch,`${n.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async updateBucket(e,t){var n=this;return n.handleOperation(async()=>await Vp(n.fetch,`${n.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await vr(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await zg(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}listBucketOptionsToQueryString(e){const t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},MO=class extends xo{constructor(e,t={},n){const s=e.replace(/\/$/,""),i=Ve(Ve({},tc),t);super(s,i,n,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await vr(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=new URLSearchParams;(e==null?void 0:e.limit)!==void 0&&n.set("limit",e.limit.toString()),(e==null?void 0:e.offset)!==void 0&&n.set("offset",e.offset.toString()),e!=null&&e.sortColumn&&n.set("sortColumn",e.sortColumn),e!=null&&e.sortOrder&&n.set("sortOrder",e.sortOrder),e!=null&&e.search&&n.set("search",e.search);const s=n.toString(),i=s?`${t.url}/bucket?${s}`:`${t.url}/bucket`;return await Bl(t.fetch,i,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await zg(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(e){var t=this;if(!_O(e))throw new Kd("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const n=new pO({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(n,{get(i,l){const c=i[l];return typeof c!="function"?c:async(...d)=>{try{return{data:await c.apply(i,d),error:null}}catch(h){if(s)throw h;return{data:null,error:h}}}}})}},DO=class extends xo{constructor(e,t={},n){const s=e.replace(/\/$/,""),i=Ve(Ve({},tc),{},{"Content-Type":"application/json"},t);super(s,i,n,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var n=this;return n.handleOperation(async()=>await Fn.post(n.fetch,`${n.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:n.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var n=this;return n.handleOperation(async()=>await Fn.post(n.fetch,`${n.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:n.headers})||{})}},LO=class extends xo{constructor(e,t={},n){const s=e.replace(/\/$/,""),i=Ve(Ve({},tc),{},{"Content-Type":"application/json"},t);super(s,i,n,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(e.segmentCount!==void 0){if(e.segmentCount<1||e.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(e.segmentIndex!==void 0&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw new Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},PO=class extends xo{constructor(e,t={},n){const s=e.replace(/\/$/,""),i=Ve(Ve({},tc),{},{"Content-Type":"application/json"},t);super(s,i,n,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await Fn.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},zO=class extends PO{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new IO(this.url,this.headers,e,this.fetch)}async createBucket(e){var t=()=>super.createBucket,n=this;return t().call(n,e)}async getBucket(e){var t=()=>super.getBucket,n=this;return t().call(n,e)}async listBuckets(e={}){var t=()=>super.listBuckets,n=this;return t().call(n,e)}async deleteBucket(e){var t=()=>super.deleteBucket,n=this;return t().call(n,e)}},IO=class extends DO{constructor(e,t,n,s){super(e,t,s),this.vectorBucketName=n}async createIndex(e){var t=()=>super.createIndex,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName}))}async listIndexes(e={}){var t=()=>super.listIndexes,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName}))}async getIndex(e){var t=()=>super.getIndex,n=this;return t().call(n,n.vectorBucketName,e)}async deleteIndex(e){var t=()=>super.deleteIndex,n=this;return t().call(n,n.vectorBucketName,e)}index(e){return new UO(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},UO=class extends LO{constructor(e,t,n,s,i){super(e,t,i),this.vectorBucketName=n,this.indexName=s}async putVectors(e){var t=()=>super.putVectors,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async getVectors(e){var t=()=>super.getVectors,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async listVectors(e={}){var t=()=>super.listVectors,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async queryVectors(e){var t=()=>super.queryVectors,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async deleteVectors(e){var t=()=>super.deleteVectors,n=this;return t().call(n,Ve(Ve({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}},$O=class extends OO{constructor(e,t={},n,s){super(e,t,n,s)}from(e){return new RO(this.url,this.headers,e,this.fetch)}get vectors(){return new zO(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new MO(this.url+"/iceberg",this.headers,this.fetch)}};const MS="2.106.2",Ji=30*1e3,Fp=3,Jm=Fp*Ji,BO="http://localhost:9999",HO="supabase.auth.token",qO={"X-Client-Info":`gotrue-js/${MS}`},Gp="X-Supabase-Api-Version",DS={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},VO=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,FO=600*1e3;class lo extends Error{constructor(t,n,s){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=s}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function ye(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class GO extends lo{constructor(t,n,s){super(t,n,s),this.name="AuthApiError",this.status=n,this.code=s}}function KO(e){return ye(e)&&e.name==="AuthApiError"}class yr extends lo{constructor(t,n){super(t),this.name="AuthUnknownError",this.originalError=n}}class xa extends lo{constructor(t,n,s,i){super(t,s,i),this.name=n,this.status=s}}class Zt extends xa{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function ku(e){return ye(e)&&e.name==="AuthSessionMissingError"}class $i extends xa{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Ou extends xa{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class Mu extends xa{constructor(t,n=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function YO(e){return ye(e)&&e.name==="AuthImplicitGrantRedirectError"}class hw extends xa{constructor(t,n=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class WO extends xa{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class Kp extends xa{constructor(t,n){super(t,"AuthRetryableFetchError",n,void 0)}}function Qm(e){return ye(e)&&e.name==="AuthRetryableFetchError"}class mw extends xa{constructor(t,n,s){super(t,"AuthWeakPasswordError",n,"weak_password"),this.reasons=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class Yp extends xa{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const yd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),pw=`
\r=`.split(""),XO=(()=>{const e=new Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<pw.length;t+=1)e[pw[t].charCodeAt(0)]=-2;for(let t=0;t<yd.length;t+=1)e[yd[t].charCodeAt(0)]=t;return e})();function gw(e,t,n){if(e!==null)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;){const s=t.queue>>t.queuedBits-6&63;n(yd[s]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const s=t.queue>>t.queuedBits-6&63;n(yd[s]),t.queuedBits-=6}}function LS(e,t,n){const s=XO[e];if(s>-1)for(t.queue=t.queue<<6|s,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function vw(e){const t=[],n=c=>{t.push(String.fromCodePoint(c))},s={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},l=c=>{ZO(c,s,n)};for(let c=0;c<e.length;c+=1)LS(e.charCodeAt(c),i,l);return t.join("")}function JO(e,t){if(e<=127){t(e);return}else if(e<=2047){t(192|e>>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function QO(e,t){for(let n=0;n<e.length;n+=1){let s=e.charCodeAt(n);if(s>55295&&s<=56319){const i=(s-55296)*1024&65535;s=(e.charCodeAt(n+1)-56320&65535|i)+65536,n+=1}JO(s,t)}}function ZO(e,t,n){if(t.utf8seq===0){if(e<=127){n(e);return}for(let s=1;s<6;s+=1)if((e>>7-s&1)===0){t.utf8seq=s;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&n(t.codepoint)}}function ro(e){const t=[],n={queue:0,queuedBits:0},s=i=>{t.push(i)};for(let i=0;i<e.length;i+=1)LS(e.charCodeAt(i),n,s);return new Uint8Array(t)}function eM(e){const t=[];return QO(e,n=>t.push(n)),new Uint8Array(t)}function Ps(e){const t=[],n={queue:0,queuedBits:0},s=i=>{t.push(i)};return e.forEach(i=>gw(i,n,s)),gw(null,n,s),t.join("")}function tM(e){return Math.round(Date.now()/1e3)+e}function nM(){return Symbol("auth-callback")}const cn=()=>typeof window<"u"&&typeof document<"u",Ts={tested:!1,writable:!1},PS=()=>{if(!cn())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ts.tested)return Ts.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),Ts.tested=!0,Ts.writable=!0}catch{Ts.tested=!0,Ts.writable=!1}return Ts.writable};function rM(e){const t={},n=new URL(e);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((i,l)=>{t[l]=i})}catch{}return n.searchParams.forEach((s,i)=>{t[i]=s}),t}const zS=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),aM=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",Qi=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},As=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch{return null}},ln=async(e,t)=>{await e.removeItem(t)};class Wd{constructor(){this.promise=new Wd.promiseConstructor((t,n)=>{this.resolve=t,this.reject=n})}}Wd.promiseConstructor=Promise;function Du(e){const t=e.split(".");if(t.length!==3)throw new Yp("Invalid JWT structure");for(let s=0;s<t.length;s++)if(!VO.test(t[s]))throw new Yp("JWT not in base64url format");return{header:JSON.parse(vw(t[0])),payload:JSON.parse(vw(t[1])),signature:ro(t[2]),raw:{header:t[0],payload:t[1]}}}async function sM(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function iM(e,t){return new Promise((s,i)=>{(async()=>{for(let l=0;l<1/0;l++)try{const c=await e(l);if(!t(l,null,c)){s(c);return}}catch(c){if(!t(l,c)){i(c);return}}})()})}function oM(e){return("0"+e.toString(16)).substr(-2)}function lM(){const t=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=n.length;let i="";for(let l=0;l<56;l++)i+=n.charAt(Math.floor(Math.random()*s));return i}return crypto.getRandomValues(t),Array.from(t,oM).join("")}async function cM(e){const n=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",n),i=new Uint8Array(s);return Array.from(i).map(l=>String.fromCharCode(l)).join("")}async function uM(e){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e;const n=await cM(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Bi(e,t,n=!1){const s=lM();let i=s;n&&(i+="/recovery"),await Qi(e,`${t}-code-verifier`,i);const l=await uM(s);return[l,s===l?"plain":"s256"]}const dM=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function fM(e){const t=e.headers.get(Gp);if(!t||!t.match(dM))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function hM(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function mM(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const pM=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function oa(e){if(!pM.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function pr(e){if(!e.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function Zm(){const e={};return new Proxy(e,{get:(t,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const s=n.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function gM(e,t){return new Proxy(e,{get:(n,s,i)=>{if(s==="__isInsecureUserWarningProxy")return!0;if(typeof s=="symbol"){const l=s.toString();if(l==="Symbol(Symbol.toPrimitive)"||l==="Symbol(Symbol.toStringTag)"||l==="Symbol(util.inspect.custom)"||l==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(n,s,i)}return!t.value&&typeof s=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(n,s,i)}})}function yw(e){return JSON.parse(JSON.stringify(e))}const Ds=e=>{if(typeof e=="object"&&e!==null){const t=e;if(typeof t.msg=="string")return t.msg;if(typeof t.message=="string")return t.message;if(typeof t.error_description=="string")return t.error_description;if(typeof t.error=="string")return t.error}return JSON.stringify(e)},vM=[502,503,504,520,521,522,523,524,530];async function bw(e){var t;if(!aM(e))throw new Kp(Ds(e),0);if(vM.includes(e.status))throw new Kp(Ds(e),e.status);let n;try{n=await e.json()}catch(l){throw new yr(Ds(l),l)}let s;const i=fM(e);if(i&&i.getTime()>=DS["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?s=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(s=n.error_code),s){if(s==="weak_password")throw new mw(Ds(n),e.status,((t=n.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(s==="session_not_found")throw new Zt}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((l,c)=>l&&typeof c=="string",!0))throw new mw(Ds(n),e.status,n.weak_password.reasons);throw new GO(Ds(n),e.status||500,s)}const yM=(e,t,n,s)=>{const i={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t==null?void 0:t.headers),i.body=JSON.stringify(s),Object.assign(Object.assign({},i),n))};async function Ae(e,t,n,s){var i;const l=Object.assign({},s==null?void 0:s.headers);l[Gp]||(l[Gp]=DS["2024-01-01"].name),s!=null&&s.jwt&&(l.Authorization=`Bearer ${s.jwt}`);const c=(i=s==null?void 0:s.query)!==null&&i!==void 0?i:{};s!=null&&s.redirectTo&&(c.redirect_to=s.redirectTo);const d=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",h=await bM(e,t,n+d,{headers:l,noResolveJson:s==null?void 0:s.noResolveJson},{},s==null?void 0:s.body);return s!=null&&s.xform?s==null?void 0:s.xform(h):{data:Object.assign({},h),error:null}}async function bM(e,t,n,s,i,l){const c=yM(t,s,i,l);let d;try{d=await e(n,Object.assign({},c))}catch(h){throw console.error(h),new Kp(Ds(h),0)}if(d.ok||await bw(d),s!=null&&s.noResolveJson)return d;try{return await d.json()}catch(h){await bw(h)}}function ar(e){var t;let n=null;_M(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=tM(e.expires_in)));const s=(t=e.user)!==null&&t!==void 0?t:typeof(e==null?void 0:e.id)=="string"?e:null;return{data:{session:n,user:s},error:null}}function xw(e){const t=ar(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((n,s)=>n&&typeof s=="string",!0)&&(t.data.weak_password=e.weak_password),t}function es(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function xM(e){return{data:e,error:null}}function wM(e){const{action_link:t,email_otp:n,hashed_token:s,redirect_to:i,verification_type:l}=e,c=bo(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),d={action_link:t,email_otp:n,hashed_token:s,redirect_to:i,verification_type:l},h=Object.assign({},c);return{data:{properties:d,user:h},error:null}}function ww(e){return e}function _M(e){return!!e.access_token&&!!e.refresh_token&&!!e.expires_in}const ep=["global","local","others"];class SM{_encodePathSegment(t){if(t==="."||t==="..")throw new lo("Invalid path segment");return encodeURIComponent(t)}constructor({url:t="",headers:n={},fetch:s,experimental:i}){this.url=t,this.headers=n,this.fetch=zS(s),this.experimental=i??{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(t,n=ep[0]){if(ep.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${ep.join(", ")}`);try{return await Ae(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(s){if(ye(s))return{data:null,error:s};throw s}}async inviteUserByEmail(t,n={}){try{return await Ae(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:es})}catch(s){if(ye(s))return{data:{user:null},error:s};throw s}}async generateLink(t){try{const{options:n}=t,s=bo(t,["options"]),i=Object.assign(Object.assign({},s),n);return"newEmail"in s&&(i.new_email=s==null?void 0:s.newEmail,delete i.newEmail),await Ae(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:wM,redirectTo:n==null?void 0:n.redirectTo})}catch(n){if(ye(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(t){try{return await Ae(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:es})}catch(n){if(ye(n))return{data:{user:null},error:n};throw n}}async listUsers(t){var n,s,i,l,c,d,h;try{const m={nextPage:null,lastPage:0,total:0},b=await Ae(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&s!==void 0?s:"",per_page:(l=(i=t==null?void 0:t.perPage)===null||i===void 0?void 0:i.toString())!==null&&l!==void 0?l:""},xform:ww});if(b.error)throw b.error;const g=await b.json(),x=(c=b.headers.get("x-total-count"))!==null&&c!==void 0?c:0,w=(h=(d=b.headers.get("link"))===null||d===void 0?void 0:d.split(","))!==null&&h!==void 0?h:[];return w.length>0&&(w.forEach(E=>{const S=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),N=JSON.parse(E.split(";")[1].split("=")[1]);m[`${N}Page`]=S}),m.total=parseInt(x)),{data:Object.assign(Object.assign({},g),m),error:null}}catch(m){if(ye(m))return{data:{users:[]},error:m};throw m}}async getUserById(t){oa(t);try{return await Ae(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:es})}catch(n){if(ye(n))return{data:{user:null},error:n};throw n}}async updateUserById(t,n){oa(t);try{return await Ae(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:n,headers:this.headers,xform:es})}catch(s){if(ye(s))return{data:{user:null},error:s};throw s}}async deleteUser(t,n=!1){oa(t);try{return await Ae(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:n},xform:es})}catch(s){if(ye(s))return{data:{user:null},error:s};throw s}}async _listFactors(t){oa(t.userId);try{const{data:n,error:s}=await Ae(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:i=>({data:{factors:i},error:null})});return{data:n,error:s}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _deleteFactor(t){oa(t.userId),oa(t.id);try{return{data:await Ae(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _listOAuthClients(t){var n,s,i,l,c,d,h;try{const m={nextPage:null,lastPage:0,total:0},b=await Ae(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&s!==void 0?s:"",per_page:(l=(i=t==null?void 0:t.perPage)===null||i===void 0?void 0:i.toString())!==null&&l!==void 0?l:""},xform:ww});if(b.error)throw b.error;const g=await b.json(),x=(c=b.headers.get("x-total-count"))!==null&&c!==void 0?c:0,w=(h=(d=b.headers.get("link"))===null||d===void 0?void 0:d.split(","))!==null&&h!==void 0?h:[];return w.length>0&&(w.forEach(E=>{const S=parseInt(E.split(";")[0].split("=")[1].substring(0,1)),N=JSON.parse(E.split(";")[1].split("=")[1]);m[`${N}Page`]=S}),m.total=parseInt(x)),{data:Object.assign(Object.assign({},g),m),error:null}}catch(m){if(ye(m))return{data:{clients:[]},error:m};throw m}}async _createOAuthClient(t){try{return await Ae(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _getOAuthClient(t){try{const n=this._encodePathSegment(t);return await Ae(this.fetch,"GET",`${this.url}/admin/oauth/clients/${n}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _updateOAuthClient(t,n){try{const s=this._encodePathSegment(t);return await Ae(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:n,headers:this.headers,xform:i=>({data:i,error:null})})}catch(s){if(ye(s))return{data:null,error:s};throw s}}async _deleteOAuthClient(t){try{const n=this._encodePathSegment(t);return await Ae(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${n}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(t){try{const n=this._encodePathSegment(t);return await Ae(this.fetch,"POST",`${this.url}/admin/oauth/clients/${n}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _listCustomProviders(t){try{const n={};return t!=null&&t.type&&(n.type=t.type),await Ae(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:n,xform:s=>{var i;return{data:{providers:(i=s==null?void 0:s.providers)!==null&&i!==void 0?i:[]},error:null}}})}catch(n){if(ye(n))return{data:{providers:[]},error:n};throw n}}async _createCustomProvider(t){try{return await Ae(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _getCustomProvider(t){try{const n=this._encodePathSegment(t);return await Ae(this.fetch,"GET",`${this.url}/admin/custom-providers/${n}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _updateCustomProvider(t,n){try{const s=this._encodePathSegment(t);return await Ae(this.fetch,"PUT",`${this.url}/admin/custom-providers/${s}`,{body:n,headers:this.headers,xform:i=>({data:i,error:null})})}catch(s){if(ye(s))return{data:null,error:s};throw s}}async _deleteCustomProvider(t){try{const n=this._encodePathSegment(t);return await Ae(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${n}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _adminListPasskeys(t){pr(this.experimental),oa(t.userId);try{return await Ae(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/passkeys`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ye(n))return{data:null,error:n};throw n}}async _adminDeletePasskey(t){pr(this.experimental),oa(t.userId),oa(t.passkeyId);try{return await Ae(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/passkeys/${t.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ye(n))return{data:null,error:n};throw n}}}function _w(e={}){return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const Ar={debug:!!(globalThis&&PS()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class IS extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class Sw extends IS{}async function EM(e,t,n){Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const s=new globalThis.AbortController;let i;t>0&&(i=setTimeout(()=>{s.abort(),Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t)),await Promise.resolve();try{return await globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:s.signal},async l=>{if(l){clearTimeout(i),Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,l.name);try{return await n()}finally{Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,l.name)}}else{if(t===0)throw Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new Sw(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(Ar.debug)try{const c=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(c,null," "))}catch(c){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",c)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),clearTimeout(i),await n()}})}catch(l){if(t>0&&clearTimeout(i),l!==null&&typeof l=="object"&&"name"in l&&l.name==="AbortError"&&t>0){if(s.signal.aborted)return Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn(`@supabase/gotrue-js: Lock "${e}" was not released within ${t}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},async c=>{if(c){Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,c.name);try{return await n()}finally{Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,c.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await n()}));throw Ar.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",e),new Sw(`Lock "${e}" was released because another request stole it`)}throw l}}function CM(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function US(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function NM(e){return parseInt(e,16)}function jM(e){const t=new TextEncoder().encode(e);return"0x"+Array.from(t,s=>s.toString(16).padStart(2,"0")).join("")}function TM(e){var t;const{chainId:n,domain:s,expirationTime:i,issuedAt:l=new Date,nonce:c,notBefore:d,requestId:h,resources:m,scheme:b,uri:g,version:x}=e;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!s)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(c&&c.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${c}`);if(!g)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(x!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${x}`);if(!((t=e.statement)===null||t===void 0)&&t.includes(`
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`)}const w=US(e.address),E=b?`${b}://${s}`:s,S=e.statement?`${e.statement}
`:"",N=`${E} wants you to sign in with your Ethereum account:
${w}
${S}`;let C=`URI: ${g}
Version: ${x}
Chain ID: ${n}${c?`
Nonce: ${c}`:""}
Issued At: ${l.toISOString()}`;if(i&&(C+=`
Expiration Time: ${i.toISOString()}`),d&&(C+=`
Not Before: ${d.toISOString()}`),h&&(C+=`
Request ID: ${h}`),m){let A=`
Resources:`;for(const T of m){if(!T||typeof T!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${T}`);A+=`
- ${T}`}C+=A}return`${N}
${C}`}class qt extends Error{constructor({message:t,code:n,cause:s,name:i}){var l;super(t,{cause:s}),this.__isWebAuthnError=!0,this.name=(l=i??(s instanceof Error?s.name:void 0))!==null&&l!==void 0?l:"Unknown Error",this.code=n}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class bd extends qt{constructor(t,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:t}),this.name="WebAuthnUnknownError",this.originalError=n}}function AM({error:e,options:t}){var n,s,i;const{publicKey:l}=t;if(!l)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new qt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(((n=l.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new qt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&((s=l.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new qt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(((i=l.authenticatorSelection)===null||i===void 0?void 0:i.userVerification)==="required")return new qt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if(e.name==="InvalidStateError")return new qt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new qt({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return l.pubKeyCredParams.filter(d=>d.type==="public-key").length===0?new qt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new qt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){const c=window.location.hostname;if($S(c)){if(l.rp.id!==c)return new qt({message:`The RP ID "${l.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new qt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(l.user.id.byteLength<1||l.user.id.byteLength>64)return new qt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new qt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new qt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function RM({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new qt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new qt({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const s=window.location.hostname;if($S(s)){if(n.rpId!==s)return new qt({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new qt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new qt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new qt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}class kM{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const Wp=new kM;function Ew(e){if(!e)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:n,excludeCredentials:s}=e,i=bo(e,["challenge","user","excludeCredentials"]),l=ro(t).buffer,c=Object.assign(Object.assign({},n),{id:ro(n.id).buffer}),d=Object.assign(Object.assign({},i),{challenge:l,user:c});if(s&&s.length>0){d.excludeCredentials=new Array(s.length);for(let h=0;h<s.length;h++){const m=s[h];d.excludeCredentials[h]=Object.assign(Object.assign({},m),{id:ro(m.id).buffer,type:m.type||"public-key",transports:m.transports})}}return d}function Cw(e){if(!e)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(e);const{challenge:t,allowCredentials:n}=e,s=bo(e,["challenge","allowCredentials"]),i=ro(t).buffer,l=Object.assign(Object.assign({},s),{challenge:i});if(n&&n.length>0){l.allowCredentials=new Array(n.length);for(let c=0;c<n.length;c++){const d=n[c];l.allowCredentials[c]=Object.assign(Object.assign({},d),{id:ro(d.id).buffer,type:d.type||"public-key",transports:d.transports})}}return l}function Nw(e){var t;if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();const n=e;return{id:e.id,rawId:e.id,response:{attestationObject:Ps(new Uint8Array(e.response.attestationObject)),clientDataJSON:Ps(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:(t=n.authenticatorAttachment)!==null&&t!==void 0?t:void 0}}function jw(e){var t;if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();const n=e,s=e.getClientExtensionResults(),i=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:Ps(new Uint8Array(i.authenticatorData)),clientDataJSON:Ps(new Uint8Array(i.clientDataJSON)),signature:Ps(new Uint8Array(i.signature)),userHandle:i.userHandle?Ps(new Uint8Array(i.userHandle)):void 0},type:"public-key",clientExtensionResults:s,authenticatorAttachment:(t=n.authenticatorAttachment)!==null&&t!==void 0?t:void 0}}function $S(e){return e==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function xd(){var e,t;return!!(cn()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.create)=="function"&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.get)=="function")}async function BS(e){try{const t=await navigator.credentials.create(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new bd("Browser returned unexpected credential type",t)}:{data:null,error:new bd("Empty credential response",t)}}catch(t){return{data:null,error:AM({error:t,options:e})}}}async function HS(e){try{const t=await navigator.credentials.get(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new bd("Browser returned unexpected credential type",t)}:{data:null,error:new bd("Empty credential response",t)}}catch(t){return{data:null,error:RM({error:t,options:e})}}}const OM={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},MM={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function wd(...e){const t=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),n=i=>i instanceof ArrayBuffer||ArrayBuffer.isView(i),s={};for(const i of e)if(i)for(const l in i){const c=i[l];if(c!==void 0)if(Array.isArray(c))s[l]=c;else if(n(c))s[l]=c;else if(t(c)){const d=s[l];t(d)?s[l]=wd(d,c):s[l]=wd(c)}else s[l]=c}return s}function DM(e,t){return wd(OM,e,t||{})}function LM(e,t){return wd(MM,e,t||{})}class PM{constructor(t){this.client=t,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:"webauthn"}))}async _challenge({factorId:t,webauthn:n,friendlyName:s,signal:i},l){var c;try{const{data:d,error:h}=await this.client.mfa.challenge({factorId:t,webauthn:n});if(!d)return{data:null,error:h};const m=i??Wp.createNewAbortSignal();if(d.webauthn.type==="create"){const{user:b}=d.webauthn.credential_options.publicKey;if(!b.name){const g=s;if(g)b.name=`${b.id}:${g}`;else{const w=(await this.client.getUser()).data.user,E=((c=w==null?void 0:w.user_metadata)===null||c===void 0?void 0:c.name)||(w==null?void 0:w.email)||(w==null?void 0:w.id)||"User";b.name=`${b.id}:${E}`}}b.displayName||(b.displayName=b.name)}switch(d.webauthn.type){case"create":{const b=DM(d.webauthn.credential_options.publicKey,l==null?void 0:l.create),{data:g,error:x}=await BS({publicKey:b,signal:m});return g?{data:{factorId:t,challengeId:d.id,webauthn:{type:d.webauthn.type,credential_response:g}},error:null}:{data:null,error:x}}case"request":{const b=LM(d.webauthn.credential_options.publicKey,l==null?void 0:l.request),{data:g,error:x}=await HS(Object.assign(Object.assign({},d.webauthn.credential_options),{publicKey:b,signal:m}));return g?{data:{factorId:t,challengeId:d.id,webauthn:{type:d.webauthn.type,credential_response:g}},error:null}:{data:null,error:x}}}}catch(d){return ye(d)?{data:null,error:d}:{data:null,error:new yr("Unexpected error in challenge",d)}}}async _verify({challengeId:t,factorId:n,webauthn:s}){return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:s})}async _authenticate({factorId:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:i}={}},l){if(!n)return{data:null,error:new lo("rpId is required for WebAuthn authentication")};try{if(!xd())return{data:null,error:new yr("Browser does not support WebAuthn",null)};const{data:c,error:d}=await this.challenge({factorId:t,webauthn:{rpId:n,rpOrigins:s},signal:i},{request:l});if(!c)return{data:null,error:d};const{webauthn:h}=c;return this._verify({factorId:t,challengeId:c.challengeId,webauthn:{type:h.type,rpId:n,rpOrigins:s,credential_response:h.credential_response}})}catch(c){return ye(c)?{data:null,error:c}:{data:null,error:new yr("Unexpected error in authenticate",c)}}}async _register({friendlyName:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:i}={}},l){if(!n)return{data:null,error:new lo("rpId is required for WebAuthn registration")};try{if(!xd())return{data:null,error:new yr("Browser does not support WebAuthn",null)};const{data:c,error:d}=await this._enroll({friendlyName:t});if(!c)return await this.client.mfa.listFactors().then(b=>{var g;return(g=b.data)===null||g===void 0?void 0:g.all.find(x=>x.factor_type==="webauthn"&&x.friendly_name===t&&x.status!=="unverified")}).then(b=>b?this.client.mfa.unenroll({factorId:b==null?void 0:b.id}):void 0),{data:null,error:d};const{data:h,error:m}=await this._challenge({factorId:c.id,friendlyName:c.friendly_name,webauthn:{rpId:n,rpOrigins:s},signal:i},{create:l});return h?this._verify({factorId:c.id,challengeId:h.challengeId,webauthn:{rpId:n,rpOrigins:s,type:h.webauthn.type,credential_response:h.webauthn.credential_response}}):{data:null,error:m}}catch(c){return ye(c)?{data:null,error:c}:{data:null,error:new yr("Unexpected error in register",c)}}}}CM();const zM={url:BO,storageKey:HO,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:qO,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Tw(e,t,n){return await n()}const Hi={};class Hl{get jwks(){var t,n;return(n=(t=Hi[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(t){Hi[this.storageKey]=Object.assign(Object.assign({},Hi[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,n;return(n=(t=Hi[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){Hi[this.storageKey]=Object.assign(Object.assign({},Hi[this.storageKey]),{cachedAt:t})}constructor(t){var n,s,i,l;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const c=Object.assign(Object.assign({},zM),t);if(this.storageKey=c.storageKey,this.instanceID=(n=Hl.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,Hl.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!c.debug,typeof c.debug=="function"&&(this.logger=c.debug),this.instanceID>0&&cn()){const d=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(d),this.logDebugMessages&&console.trace(d)}if(this.persistSession=c.persistSession,this.autoRefreshToken=c.autoRefreshToken,this.experimental=(s=c.experimental)!==null&&s!==void 0?s:{},this.admin=new SM({url:c.url,headers:c.headers,fetch:c.fetch,experimental:this.experimental}),this.url=c.url,this.headers=c.headers,this.fetch=zS(c.fetch),this.lock=c.lock||Tw,this.detectSessionInUrl=c.detectSessionInUrl,this.flowType=c.flowType,this.hasCustomAuthorizationHeader=c.hasCustomAuthorizationHeader,this.throwOnError=c.throwOnError,this.lockAcquireTimeout=c.lockAcquireTimeout,c.lock?this.lock=c.lock:this.persistSession&&cn()&&(!((i=globalThis==null?void 0:globalThis.navigator)===null||i===void 0)&&i.locks)?this.lock=EM:this.lock=Tw,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new PM(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(c.storage?this.storage=c.storage:PS()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=_w(this.memoryStorage)),c.userStorage&&(this.userStorage=c.userStorage)):(this.memoryStorage={},this.storage=_w(this.memoryStorage)),cn()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(d){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",d)}(l=this.broadcastChannel)===null||l===void 0||l.addEventListener("message",async d=>{this._debug("received broadcast notification from other tab or client",d);try{await this._notifyAllSubscribers(d.data.event,d.data.session,!1)}catch(h){this._debug("#broadcastChannel","error",h)}})}c.skipAutoInitialize||this.initialize().catch(d=>{this._debug("#initialize()","error",d)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(t){if(this.throwOnError&&t&&t.error)throw t.error;return t}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${MS}) ${new Date().toISOString()}`}_debug(...t){return this.logDebugMessages&&this.logger(this._logPrefix(),...t),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var t;try{let n={},s="none";if(cn()&&(n=rM(window.location.href),this._isImplicitGrantCallback(n)?s="implicit":await this._isPKCECallback(n)&&(s="pkce")),cn()&&this.detectSessionInUrl&&s!=="none"){const{data:i,error:l}=await this._getSessionFromURL(n,s);if(l){if(this._debug("#_initialize()","error detecting session from URL",l),YO(l)){const h=(t=l.details)===null||t===void 0?void 0:t.code;if(h==="identity_already_exists"||h==="identity_not_found"||h==="single_identity_not_deletable")return{error:l}}return{error:l}}const{session:c,redirectType:d}=i;return this._debug("#_initialize()","detected session in URL",c,"redirect type",d),await this._saveSession(c),setTimeout(async()=>{d==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return ye(n)?this._returnResult({error:n}):this._returnResult({error:new yr("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var n,s,i;try{const l=await Ae(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(i=t==null?void 0:t.options)===null||i===void 0?void 0:i.captchaToken}},xform:ar}),{data:c,error:d}=l;if(d||!c)return this._returnResult({data:{user:null,session:null},error:d});const h=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",h)),this._returnResult({data:{user:m,session:h},error:null})}catch(l){if(ye(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signUp(t){var n,s,i;try{let l;if("email"in t){const{email:b,password:g,options:x}=t;let w=null,E=null;this.flowType==="pkce"&&([w,E]=await Bi(this.storage,this.storageKey)),l=await Ae(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:x==null?void 0:x.emailRedirectTo,body:{email:b,password:g,data:(n=x==null?void 0:x.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:x==null?void 0:x.captchaToken},code_challenge:w,code_challenge_method:E},xform:ar})}else if("phone"in t){const{phone:b,password:g,options:x}=t;l=await Ae(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:b,password:g,data:(s=x==null?void 0:x.data)!==null&&s!==void 0?s:{},channel:(i=x==null?void 0:x.channel)!==null&&i!==void 0?i:"sms",gotrue_meta_security:{captcha_token:x==null?void 0:x.captchaToken}},xform:ar})}else throw new Ou("You must provide either an email or phone number and a password");const{data:c,error:d}=l;if(d||!c)return await ln(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:d});const h=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",h)),this._returnResult({data:{user:m,session:h},error:null})}catch(l){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithPassword(t){try{let n;if("email"in t){const{email:l,password:c,options:d}=t;n=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:l,password:c,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:xw})}else if("phone"in t){const{phone:l,password:c,options:d}=t;n=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:l,password:c,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:xw})}else throw new Ou("You must provide either an email or phone number and a password");const{data:s,error:i}=n;if(i)return this._returnResult({data:{user:null,session:null},error:i});if(!s||!s.session||!s.user){const l=new $i;return this._returnResult({data:{user:null,session:null},error:l})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:i})}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOAuth(t){var n,s,i,l;return await this._handleProviderSignIn(t.provider,{redirectTo:(n=t.options)===null||n===void 0?void 0:n.redirectTo,scopes:(s=t.options)===null||s===void 0?void 0:s.scopes,queryParams:(i=t.options)===null||i===void 0?void 0:i.queryParams,skipBrowserRedirect:(l=t.options)===null||l===void 0?void 0:l.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:n}=t;switch(n){case"ethereum":return await this.signInWithEthereum(t);case"solana":return await this.signInWithSolana(t);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(t){var n,s,i,l,c,d,h,m,b,g,x;let w,E;if("message"in t)w=t.message,E=t.signature;else{const{chain:S,wallet:N,statement:C,options:A}=t;let T;if(cn())if(typeof N=="object")T=N;else{const q=window;if("ethereum"in q&&typeof q.ethereum=="object"&&"request"in q.ethereum&&typeof q.ethereum.request=="function")T=q.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof N!="object"||!(A!=null&&A.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");T=N}const M=new URL((n=A==null?void 0:A.url)!==null&&n!==void 0?n:window.location.href),U=await T.request({method:"eth_requestAccounts"}).then(q=>q).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!U||U.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const z=US(U[0]);let L=(s=A==null?void 0:A.signInWithEthereum)===null||s===void 0?void 0:s.chainId;if(!L){const q=await T.request({method:"eth_chainId"});L=NM(q)}const B={domain:M.host,address:z,statement:C,uri:M.href,version:"1",chainId:L,nonce:(i=A==null?void 0:A.signInWithEthereum)===null||i===void 0?void 0:i.nonce,issuedAt:(c=(l=A==null?void 0:A.signInWithEthereum)===null||l===void 0?void 0:l.issuedAt)!==null&&c!==void 0?c:new Date,expirationTime:(d=A==null?void 0:A.signInWithEthereum)===null||d===void 0?void 0:d.expirationTime,notBefore:(h=A==null?void 0:A.signInWithEthereum)===null||h===void 0?void 0:h.notBefore,requestId:(m=A==null?void 0:A.signInWithEthereum)===null||m===void 0?void 0:m.requestId,resources:(b=A==null?void 0:A.signInWithEthereum)===null||b===void 0?void 0:b.resources};w=TM(B),E=await T.request({method:"personal_sign",params:[jM(w),z]})}try{const{data:S,error:N}=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:w,signature:E},!((g=t.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(x=t.options)===null||x===void 0?void 0:x.captchaToken}}:null),xform:ar});if(N)throw N;if(!S||!S.session||!S.user){const C=new $i;return this._returnResult({data:{user:null,session:null},error:C})}return S.session&&(await this._saveSession(S.session),await this._notifyAllSubscribers("SIGNED_IN",S.session)),this._returnResult({data:Object.assign({},S),error:N})}catch(S){if(ye(S))return this._returnResult({data:{user:null,session:null},error:S});throw S}}async signInWithSolana(t){var n,s,i,l,c,d,h,m,b,g,x,w;let E,S;if("message"in t)E=t.message,S=t.signature;else{const{chain:N,wallet:C,statement:A,options:T}=t;let M;if(cn())if(typeof C=="object")M=C;else{const z=window;if("solana"in z&&typeof z.solana=="object"&&("signIn"in z.solana&&typeof z.solana.signIn=="function"||"signMessage"in z.solana&&typeof z.solana.signMessage=="function"))M=z.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof C!="object"||!(T!=null&&T.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=C}const U=new URL((n=T==null?void 0:T.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in M&&M.signIn){const z=await M.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},T==null?void 0:T.signInWithSolana),{version:"1",domain:U.host,uri:U.href}),A?{statement:A}:null));let L;if(Array.isArray(z)&&z[0]&&typeof z[0]=="object")L=z[0];else if(z&&typeof z=="object"&&"signedMessage"in z&&"signature"in z)L=z;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in L&&"signature"in L&&(typeof L.signedMessage=="string"||L.signedMessage instanceof Uint8Array)&&L.signature instanceof Uint8Array)E=typeof L.signedMessage=="string"?L.signedMessage:new TextDecoder().decode(L.signedMessage),S=L.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in M)||typeof M.signMessage!="function"||!("publicKey"in M)||typeof M!="object"||!M.publicKey||!("toBase58"in M.publicKey)||typeof M.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");E=[`${U.host} wants you to sign in with your Solana account:`,M.publicKey.toBase58(),...A?["",A,""]:[""],"Version: 1",`URI: ${U.href}`,`Issued At: ${(i=(s=T==null?void 0:T.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&i!==void 0?i:new Date().toISOString()}`,...!((l=T==null?void 0:T.signInWithSolana)===null||l===void 0)&&l.notBefore?[`Not Before: ${T.signInWithSolana.notBefore}`]:[],...!((c=T==null?void 0:T.signInWithSolana)===null||c===void 0)&&c.expirationTime?[`Expiration Time: ${T.signInWithSolana.expirationTime}`]:[],...!((d=T==null?void 0:T.signInWithSolana)===null||d===void 0)&&d.chainId?[`Chain ID: ${T.signInWithSolana.chainId}`]:[],...!((h=T==null?void 0:T.signInWithSolana)===null||h===void 0)&&h.nonce?[`Nonce: ${T.signInWithSolana.nonce}`]:[],...!((m=T==null?void 0:T.signInWithSolana)===null||m===void 0)&&m.requestId?[`Request ID: ${T.signInWithSolana.requestId}`]:[],...!((g=(b=T==null?void 0:T.signInWithSolana)===null||b===void 0?void 0:b.resources)===null||g===void 0)&&g.length?["Resources",...T.signInWithSolana.resources.map(L=>`- ${L}`)]:[]].join(`
`);const z=await M.signMessage(new TextEncoder().encode(E),"utf8");if(!z||!(z instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");S=z}}try{const{data:N,error:C}=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:E,signature:Ps(S)},!((x=t.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(w=t.options)===null||w===void 0?void 0:w.captchaToken}}:null),xform:ar});if(C)throw C;if(!N||!N.session||!N.user){const A=new $i;return this._returnResult({data:{user:null,session:null},error:A})}return N.session&&(await this._saveSession(N.session),await this._notifyAllSubscribers("SIGNED_IN",N.session)),this._returnResult({data:Object.assign({},N),error:C})}catch(N){if(ye(N))return this._returnResult({data:{user:null,session:null},error:N});throw N}}async _exchangeCodeForSession(t){const n=await As(this.storage,`${this.storageKey}-code-verifier`),[s,i]=(n??"").split("/");try{if(!s&&this.flowType==="pkce")throw new WO;const{data:l,error:c}=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:s},xform:ar});if(await ln(this.storage,`${this.storageKey}-code-verifier`),c)throw c;if(!l||!l.session||!l.user){const d=new $i;return this._returnResult({data:{user:null,session:null,redirectType:null},error:d})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers(i==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l.session)),this._returnResult({data:Object.assign(Object.assign({},l),{redirectType:i??null}),error:c})}catch(l){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(l))return this._returnResult({data:{user:null,session:null,redirectType:null},error:l});throw l}}async signInWithIdToken(t){try{const{options:n,provider:s,token:i,access_token:l,nonce:c}=t,d=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:i,access_token:l,nonce:c,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},xform:ar}),{data:h,error:m}=d;if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h||!h.session||!h.user){const b=new $i;return this._returnResult({data:{user:null,session:null},error:b})}return h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("SIGNED_IN",h.session)),this._returnResult({data:h,error:m})}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOtp(t){var n,s,i,l,c;try{if("email"in t){const{email:d,options:h}=t;let m=null,b=null;this.flowType==="pkce"&&([m,b]=await Bi(this.storage,this.storageKey));const{error:g}=await Ae(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:d,data:(n=h==null?void 0:h.data)!==null&&n!==void 0?n:{},create_user:(s=h==null?void 0:h.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},code_challenge:m,code_challenge_method:b},redirectTo:h==null?void 0:h.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:g})}if("phone"in t){const{phone:d,options:h}=t,{data:m,error:b}=await Ae(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:d,data:(i=h==null?void 0:h.data)!==null&&i!==void 0?i:{},create_user:(l=h==null?void 0:h.shouldCreateUser)!==null&&l!==void 0?l:!0,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},channel:(c=h==null?void 0:h.channel)!==null&&c!==void 0?c:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:b})}throw new Ou("You must provide either an email or phone number.")}catch(d){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(d))return this._returnResult({data:{user:null,session:null},error:d});throw d}}async verifyOtp(t){var n,s;try{let i,l;"options"in t&&(i=(n=t.options)===null||n===void 0?void 0:n.redirectTo,l=(s=t.options)===null||s===void 0?void 0:s.captchaToken);const{data:c,error:d}=await Ae(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:l}}),redirectTo:i,xform:ar});if(d)throw d;if(!c)throw new Error("An error occurred on token verification.");const h=c.session,m=c.user;return h!=null&&h.access_token&&(await this._saveSession(h),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",h)),this._returnResult({data:{user:m,session:h},error:null})}catch(i){if(ye(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithSSO(t){var n,s,i,l,c;try{let d=null,h=null;this.flowType==="pkce"&&([d,h]=await Bi(this.storage,this.storageKey));const m=await Ae(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(s=(n=t.options)===null||n===void 0?void 0:n.redirectTo)!==null&&s!==void 0?s:void 0}),!((i=t==null?void 0:t.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:d,code_challenge_method:h}),headers:this.headers,xform:xM});return!((l=m.data)===null||l===void 0)&&l.url&&cn()&&!(!((c=t.options)===null||c===void 0)&&c.skipBrowserRedirect)&&window.location.assign(m.data.url),this._returnResult(m)}catch(d){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(d))return this._returnResult({data:null,error:d});throw d}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async t=>{const{data:{session:n},error:s}=t;if(s)throw s;if(!n)throw new Zt;const{error:i}=await Ae(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return this._returnResult({data:{user:null,session:null},error:i})})}catch(t){if(ye(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async resend(t){try{const n=`${this.url}/resend`;if("email"in t){const{email:s,type:i,options:l}=t,{error:c}=await Ae(this.fetch,"POST",n,{headers:this.headers,body:{email:s,type:i,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:c})}else if("phone"in t){const{phone:s,type:i,options:l}=t,{data:c,error:d}=await Ae(this.fetch,"POST",n,{headers:this.headers,body:{phone:s,type:i,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:d})}throw new Ou("You must provide either an email or phone number and a type")}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async n=>n))}async _acquireLock(t,n){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await s,await n()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,t,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=n();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(t){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await t(n)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let t=null;const n=await As(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?t=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};const s=t.expires_at?t.expires_at*1e3-Date.now()<Jm:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",t.expires_at),!s){if(this.userStorage){const c=await As(this.userStorage,this.storageKey+"-user");c!=null&&c.user?t.user=c.user:t.user=Zm()}if(this.storage.isServer&&t.user&&!t.user.__isUserNotAvailableProxy){const c={value:this.suppressGetSessionWarning};t.user=gM(t.user,c),c.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:t},error:null}}const{data:i,error:l}=await this._callRefreshToken(t.refresh_token);return l?this._returnResult({data:{session:null},error:l}):this._returnResult({data:{session:i},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(t){if(t)return await this._getUser(t);await this.initializePromise;const n=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return n.data.user&&(this.suppressGetSessionWarning=!0),n}async _getUser(t){try{return t?await Ae(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:es}):await this._useSession(async n=>{var s,i,l;const{data:c,error:d}=n;if(d)throw d;return!(!((s=c.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Zt}:await Ae(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(l=(i=c.session)===null||i===void 0?void 0:i.access_token)!==null&&l!==void 0?l:void 0,xform:es})})}catch(n){if(ye(n))return ku(n)&&(await this._removeSession(),await ln(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:n});throw n}}async updateUser(t,n={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(t,n))}async _updateUser(t,n={}){try{return await this._useSession(async s=>{const{data:i,error:l}=s;if(l)throw l;if(!i.session)throw new Zt;const c=i.session;let d=null,h=null;this.flowType==="pkce"&&t.email!=null&&([d,h]=await Bi(this.storage,this.storageKey));const{data:m,error:b}=await Ae(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n==null?void 0:n.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:d,code_challenge_method:h}),jwt:c.access_token,xform:es});if(b)throw b;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),this._returnResult({data:{user:c.user},error:null})})}catch(s){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(s))return this._returnResult({data:{user:null},error:s});throw s}}async setSession(t){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new Zt;const n=Date.now()/1e3;let s=n,i=!0,l=null;const{payload:c}=Du(t.access_token);if(c.exp&&(s=c.exp,i=s<=n),i){const{data:d,error:h}=await this._callRefreshToken(t.refresh_token);if(h)return this._returnResult({data:{user:null,session:null},error:h});if(!d)return{data:{user:null,session:null},error:null};l=d}else{const{data:d,error:h}=await this._getUser(t.access_token);if(h)return this._returnResult({data:{user:null,session:null},error:h});l={access_token:t.access_token,refresh_token:t.refresh_token,user:d.user,token_type:"bearer",expires_in:s-n,expires_at:s},await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)}return this._returnResult({data:{user:l.user,session:l},error:null})}catch(n){if(ye(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async n=>{var s;if(!t){const{data:c,error:d}=n;if(d)throw d;t=(s=c.session)!==null&&s!==void 0?s:void 0}if(!(t!=null&&t.refresh_token))throw new Zt;const{data:i,error:l}=await this._callRefreshToken(t.refresh_token);return l?this._returnResult({data:{user:null,session:null},error:l}):i?this._returnResult({data:{user:i.user,session:i},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(n){if(ye(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(t,n){var s;try{if(!cn())throw new Mu("No browser detected.");if(t.error||t.error_description||t.error_code)throw new Mu(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new hw("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Mu("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new hw("No code detected.");const{data:T,error:M}=await this._exchangeCodeForSession(t.code);if(M)throw M;const U=new URL(window.location.href);return U.searchParams.delete("code"),window.history.replaceState(window.history.state,"",U.toString()),{data:{session:T.session,redirectType:(s=T.redirectType)!==null&&s!==void 0?s:null},error:null}}const{provider_token:i,provider_refresh_token:l,access_token:c,refresh_token:d,expires_in:h,expires_at:m,token_type:b}=t;if(!c||!h||!d||!b)throw new Mu("No session defined in URL");const g=Math.round(Date.now()/1e3),x=parseInt(h);let w=g+x;m&&(w=parseInt(m));const E=w-g;E*1e3<=Ji&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${E}s, should have been closer to ${x}s`);const S=w-x;g-S>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",S,w,g):g-S<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",S,w,g);const{data:N,error:C}=await this._getUser(c);if(C)throw C;const A={provider_token:i,provider_refresh_token:l,access_token:c,expires_in:x,expires_at:w,refresh_token:d,token_type:b,user:N.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:A,redirectType:t.type},error:null})}catch(i){if(ye(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(t){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),t):!!(t.access_token||t.error_description)}async _isPKCECallback(t){const n=await As(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&n)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async n=>{var s;const{data:i,error:l}=n;if(l&&!ku(l))return this._returnResult({error:l});const c=(s=i.session)===null||s===void 0?void 0:s.access_token;if(c){const{error:d}=await this.admin.signOut(c,t);if(d&&!(KO(d)&&(d.status===404||d.status===401||d.status===403)||ku(d)))return this._returnResult({error:d})}return t!=="others"&&(await this._removeSession(),await ln(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(t){const n=nM(),s={id:n,callback:t,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,s),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:s}}}async _emitInitialSession(t){return await this._useSession(async n=>{var s,i;try{const{data:{session:l},error:c}=n;if(c)throw c;await((s=this.stateChangeEmitters.get(t))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",l)),this._debug("INITIAL_SESSION","callback id",t,"session",l)}catch(l){await((i=this.stateChangeEmitters.get(t))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",l),ku(l)?console.warn(l):console.error(l)}})}async resetPasswordForEmail(t,n={}){let s=null,i=null;this.flowType==="pkce"&&([s,i]=await Bi(this.storage,this.storageKey,!0));try{return await Ae(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:s,code_challenge_method:i,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(l){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(l))return this._returnResult({data:null,error:l});throw l}}async getUserIdentities(){var t;try{const{data:n,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:(t=n.user.identities)!==null&&t!==void 0?t:[]},error:null})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async linkIdentity(t){return"token"in t?this.linkIdentityIdToken(t):this.linkIdentityOAuth(t)}async linkIdentityOAuth(t){var n;try{const{data:s,error:i}=await this._useSession(async l=>{var c,d,h,m,b;const{data:g,error:x}=l;if(x)throw x;const w=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(c=t.options)===null||c===void 0?void 0:c.redirectTo,scopes:(d=t.options)===null||d===void 0?void 0:d.scopes,queryParams:(h=t.options)===null||h===void 0?void 0:h.queryParams,skipBrowserRedirect:!0});return await Ae(this.fetch,"GET",w,{headers:this.headers,jwt:(b=(m=g.session)===null||m===void 0?void 0:m.access_token)!==null&&b!==void 0?b:void 0})});if(i)throw i;return cn()&&!(!((n=t.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(s==null?void 0:s.url),this._returnResult({data:{provider:t.provider,url:s==null?void 0:s.url},error:null})}catch(s){if(ye(s))return this._returnResult({data:{provider:t.provider,url:null},error:s});throw s}}async linkIdentityIdToken(t){return await this._useSession(async n=>{var s;try{const{error:i,data:{session:l}}=n;if(i)throw i;const{options:c,provider:d,token:h,access_token:m,nonce:b}=t,g=await Ae(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(s=l==null?void 0:l.access_token)!==null&&s!==void 0?s:void 0,body:{provider:d,id_token:h,access_token:m,nonce:b,link_identity:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:ar}),{data:x,error:w}=g;return w?this._returnResult({data:{user:null,session:null},error:w}):!x||!x.session||!x.user?this._returnResult({data:{user:null,session:null},error:new $i}):(x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("USER_UPDATED",x.session)),this._returnResult({data:x,error:w}))}catch(i){if(await ln(this.storage,`${this.storageKey}-code-verifier`),ye(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}})}async unlinkIdentity(t){try{return await this._useSession(async n=>{var s,i;const{data:l,error:c}=n;if(c)throw c;return await Ae(this.fetch,"DELETE",`${this.url}/user/identities/${t.identity_id}`,{headers:this.headers,jwt:(i=(s=l.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _refreshAccessToken(t){const n=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(n,"begin");try{const s=Date.now();return await iM(async i=>(i>0&&await sM(200*Math.pow(2,i-1)),this._debug(n,"refreshing attempt",i),await Ae(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:ar})),(i,l)=>{const c=200*Math.pow(2,i);return l&&Qm(l)&&Date.now()+c-s<Ji})}catch(s){if(this._debug(n,"error",s),ye(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}finally{this._debug(n,"end")}}_isValidSession(t){return typeof t=="object"&&t!==null&&"access_token"in t&&"refresh_token"in t&&"expires_at"in t}async _handleProviderSignIn(t,n){const s=await this._getUrlForProvider(`${this.url}/authorize`,t,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",t,"options",n,"url",s),cn()&&!n.skipBrowserRedirect&&window.location.assign(s),{data:{provider:t,url:s},error:null}}async _recoverAndRefresh(){var t,n;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const i=await As(this.storage,this.storageKey);if(i&&this.userStorage){let c=await As(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!c&&(c={user:i.user},await Qi(this.userStorage,this.storageKey+"-user",c)),i.user=(t=c==null?void 0:c.user)!==null&&t!==void 0?t:Zm()}else if(i&&!i.user&&!i.user){const c=await As(this.storage,this.storageKey+"-user");c&&(c!=null&&c.user)?(i.user=c.user,await ln(this.storage,this.storageKey+"-user"),await Qi(this.storage,this.storageKey,i)):i.user=Zm()}if(this._debug(s,"session from storage",i),!this._isValidSession(i)){this._debug(s,"session is not valid"),i!==null&&await this._removeSession();return}const l=((n=i.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<Jm;if(this._debug(s,`session has${l?"":" not"} expired with margin of ${Jm}s`),l){if(this.autoRefreshToken&&i.refresh_token){const{error:c}=await this._callRefreshToken(i.refresh_token);c&&(console.error(c),Qm(c)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",c),await this._removeSession()))}}else if(i.user&&i.user.__isUserNotAvailableProxy===!0)try{const{data:c,error:d}=await this._getUser(i.access_token);!d&&(c!=null&&c.user)?(i.user=c.user,await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(c){console.error("Error getting user data:",c),this._debug(s,"error getting user data, skipping SIGNED_IN notification",c)}else await this._notifyAllSubscribers("SIGNED_IN",i)}catch(i){this._debug(s,"error",i),console.error(i);return}finally{this._debug(s,"end")}}async _callRefreshToken(t){var n,s;if(!t)throw new Zt;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const i=`#_callRefreshToken(${t.substring(0,5)}...)`;this._debug(i,"begin");try{this.refreshingDeferred=new Wd;const{data:l,error:c}=await this._refreshAccessToken(t);if(c)throw c;if(!l.session)throw new Zt;await this._saveSession(l.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",l.session);const d={data:l.session,error:null};return this.refreshingDeferred.resolve(d),d}catch(l){if(this._debug(i,"error",l),ye(l)){const c={data:null,error:l};return Qm(l)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(c),c}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(l),l}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(t,n,s=!0){const i=`#_notifyAllSubscribers(${t})`;this._debug(i,"begin",n,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:t,session:n});const l=[],c=Array.from(this.stateChangeEmitters.values()).map(async d=>{try{await d.callback(t,n)}catch(h){l.push(h)}});if(await Promise.all(c),l.length>0){for(let d=0;d<l.length;d+=1)console.error(l[d]);throw l[0]}}finally{this._debug(i,"end")}}async _saveSession(t){this._debug("#_saveSession()",t),this.suppressGetSessionWarning=!0,await ln(this.storage,`${this.storageKey}-code-verifier`);const n=Object.assign({},t),s=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&n.user&&await Qi(this.userStorage,this.storageKey+"-user",{user:n.user});const i=Object.assign({},n);delete i.user;const l=yw(i);await Qi(this.storage,this.storageKey,l)}else{const i=yw(n);await Qi(this.storage,this.storageKey,i)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await ln(this.storage,this.storageKey),await ln(this.storage,this.storageKey+"-code-verifier"),await ln(this.storage,this.storageKey+"-user"),this.userStorage&&await ln(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const t=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{t&&cn()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",t)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const t=setInterval(()=>this._autoRefreshTokenTick(),Ji);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t);const n=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=n,n&&typeof n=="object"&&typeof n.unref=="function"?n.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(n)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t);const n=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,n&&clearTimeout(n)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const t=Date.now();try{return await this._useSession(async n=>{const{data:{session:s}}=n;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((s.expires_at*1e3-t)/Ji);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${Ji}ms, refresh threshold is ${Fp} ticks`),i<=Fp&&await this._callRefreshToken(s.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(t){if(t instanceof IS)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!cn()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(t){this._debug("#visibilityChangedCallback","error",t)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const n=`#_onVisibilityChanged(${t})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(n,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(t,n,s){const i=[`provider=${encodeURIComponent(n)}`];if(s!=null&&s.redirectTo&&i.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),s!=null&&s.scopes&&i.push(`scopes=${encodeURIComponent(s.scopes)}`),this.flowType==="pkce"){const[l,c]=await Bi(this.storage,this.storageKey),d=new URLSearchParams({code_challenge:`${encodeURIComponent(l)}`,code_challenge_method:`${encodeURIComponent(c)}`});i.push(d.toString())}if(s!=null&&s.queryParams){const l=new URLSearchParams(s.queryParams);i.push(l.toString())}return s!=null&&s.skipBrowserRedirect&&i.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${t}?${i.join("&")}`}async _unenroll(t){try{return await this._useSession(async n=>{var s;const{data:i,error:l}=n;return l?this._returnResult({data:null,error:l}):await Ae(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(s=i==null?void 0:i.session)===null||s===void 0?void 0:s.access_token})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _enroll(t){try{return await this._useSession(async n=>{var s,i;const{data:l,error:c}=n;if(c)return this._returnResult({data:null,error:c});const d=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:t.factorType==="totp"?{issuer:t.issuer}:{}),{data:h,error:m}=await Ae(this.fetch,"POST",`${this.url}/factors`,{body:d,headers:this.headers,jwt:(s=l==null?void 0:l.session)===null||s===void 0?void 0:s.access_token});return m?this._returnResult({data:null,error:m}):(t.factorType==="totp"&&h.type==="totp"&&(!((i=h==null?void 0:h.totp)===null||i===void 0)&&i.qr_code)&&(h.totp.qr_code=`data:image/svg+xml;utf-8,${h.totp.qr_code}`),this._returnResult({data:h,error:null}))})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _verify(t){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var s;const{data:i,error:l}=n;if(l)return this._returnResult({data:null,error:l});const c=Object.assign({challenge_id:t.challengeId},"webauthn"in t?{webauthn:Object.assign(Object.assign({},t.webauthn),{credential_response:t.webauthn.type==="create"?Nw(t.webauthn.credential_response):jw(t.webauthn.credential_response)})}:{code:t.code}),{data:d,error:h}=await Ae(this.fetch,"POST",`${this.url}/factors/${t.factorId}/verify`,{body:c,headers:this.headers,jwt:(s=i==null?void 0:i.session)===null||s===void 0?void 0:s.access_token});return h?this._returnResult({data:null,error:h}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+d.expires_in},d)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",d),this._returnResult({data:d,error:h}))})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}})}async _challenge(t){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var s;const{data:i,error:l}=n;if(l)return this._returnResult({data:null,error:l});const c=await Ae(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:t,headers:this.headers,jwt:(s=i==null?void 0:i.session)===null||s===void 0?void 0:s.access_token});if(c.error)return c;const{data:d}=c;if(d.type!=="webauthn")return{data:d,error:null};switch(d.webauthn.type){case"create":return{data:Object.assign(Object.assign({},d),{webauthn:Object.assign(Object.assign({},d.webauthn),{credential_options:Object.assign(Object.assign({},d.webauthn.credential_options),{publicKey:Ew(d.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},d),{webauthn:Object.assign(Object.assign({},d.webauthn),{credential_options:Object.assign(Object.assign({},d.webauthn.credential_options),{publicKey:Cw(d.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}})}async _challengeAndVerify(t){const{data:n,error:s}=await this._challenge({factorId:t.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:t.factorId,challengeId:n.id,code:t.code})}async _listFactors(){var t;const{data:{user:n},error:s}=await this.getUser();if(s)return{data:null,error:s};const i={all:[],phone:[],totp:[],webauthn:[]};for(const l of(t=n==null?void 0:n.factors)!==null&&t!==void 0?t:[])i.all.push(l),l.status==="verified"&&i[l.factor_type].push(l);return{data:i,error:null}}async _getAuthenticatorAssuranceLevel(t){var n,s,i,l;if(t)try{const{payload:w}=Du(t);let E=null;w.aal&&(E=w.aal);let S=E;const{data:{user:N},error:C}=await this.getUser(t);if(C)return this._returnResult({data:null,error:C});((s=(n=N==null?void 0:N.factors)===null||n===void 0?void 0:n.filter(M=>M.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(S="aal2");const T=w.amr||[];return{data:{currentLevel:E,nextLevel:S,currentAuthenticationMethods:T},error:null}}catch(w){if(ye(w))return this._returnResult({data:null,error:w});throw w}const{data:{session:c},error:d}=await this.getSession();if(d)return this._returnResult({data:null,error:d});if(!c)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:h}=Du(c.access_token);let m=null;h.aal&&(m=h.aal);let b=m;((l=(i=c.user.factors)===null||i===void 0?void 0:i.filter(w=>w.status==="verified"))!==null&&l!==void 0?l:[]).length>0&&(b="aal2");const x=h.amr||[];return{data:{currentLevel:m,nextLevel:b,currentAuthenticationMethods:x},error:null}}async _getAuthorizationDetails(t){try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;return i?this._returnResult({data:null,error:i}):s?await Ae(this.fetch,"GET",`${this.url}/oauth/authorizations/${t}`,{headers:this.headers,jwt:s.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new Zt})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _approveAuthorization(t,n){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;if(l)return this._returnResult({data:null,error:l});if(!i)return this._returnResult({data:null,error:new Zt});const c=await Ae(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"approve"},xform:d=>({data:d,error:null})});return c.data&&c.data.redirect_url&&cn()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(c.data.redirect_url),c})}catch(s){if(ye(s))return this._returnResult({data:null,error:s});throw s}}async _denyAuthorization(t,n){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;if(l)return this._returnResult({data:null,error:l});if(!i)return this._returnResult({data:null,error:new Zt});const c=await Ae(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"deny"},xform:d=>({data:d,error:null})});return c.data&&c.data.redirect_url&&cn()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(c.data.redirect_url),c})}catch(s){if(ye(s))return this._returnResult({data:null,error:s});throw s}}async _listOAuthGrants(){try{return await this._useSession(async t=>{const{data:{session:n},error:s}=t;return s?this._returnResult({data:null,error:s}):n?await Ae(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new Zt})})}catch(t){if(ye(t))return this._returnResult({data:null,error:t});throw t}}async _revokeOAuthGrant(t){try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;return i?this._returnResult({data:null,error:i}):s?(await Ae(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:t.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Zt})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async fetchJwk(t,n={keys:[]}){let s=n.keys.find(d=>d.kid===t);if(s)return s;const i=Date.now();if(s=this.jwks.keys.find(d=>d.kid===t),s&&this.jwks_cached_at+FO>i)return s;const{data:l,error:c}=await Ae(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(c)throw c;return!l.keys||l.keys.length===0||(this.jwks=l,this.jwks_cached_at=i,s=l.keys.find(d=>d.kid===t),!s)?null:s}async getClaims(t,n={}){try{let s=t;if(!s){const{data:w,error:E}=await this.getSession();if(E||!w.session)return this._returnResult({data:null,error:E});s=w.session.access_token}const{header:i,payload:l,signature:c,raw:{header:d,payload:h}}=Du(s);n!=null&&n.allowExpired||hM(l.exp);const m=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,n!=null&&n.keys?{keys:n.keys}:n==null?void 0:n.jwks);if(!m){const{error:w}=await this.getUser(s);if(w)throw w;return{data:{claims:l,header:i,signature:c},error:null}}const b=mM(i.alg),g=await crypto.subtle.importKey("jwk",m,b,!0,["verify"]);if(!await crypto.subtle.verify(b,g,c,eM(`${d}.${h}`)))throw new Yp("Invalid JWT signature");return{data:{claims:l,header:i,signature:c},error:null}}catch(s){if(ye(s))return this._returnResult({data:null,error:s});throw s}}async signInWithPasskey(t){var n,s,i;pr(this.experimental);try{if(!xd())return this._returnResult({data:null,error:new yr("Browser does not support WebAuthn",null)});const{data:l,error:c}=await this._startPasskeyAuthentication({options:{captchaToken:(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.captchaToken}});if(c||!l)return this._returnResult({data:null,error:c});const d=Cw(l.options),h=(i=(s=t==null?void 0:t.options)===null||s===void 0?void 0:s.signal)!==null&&i!==void 0?i:Wp.createNewAbortSignal(),{data:m,error:b}=await HS({publicKey:d,signal:h});if(b||!m)return this._returnResult({data:null,error:b??new yr("WebAuthn ceremony failed",null)});const g=jw(m);return this._verifyPasskeyAuthentication({challengeId:l.challenge_id,credential:g})}catch(l){if(ye(l))return this._returnResult({data:null,error:l});throw l}}async registerPasskey(t){var n,s;pr(this.experimental);try{if(!xd())return this._returnResult({data:null,error:new yr("Browser does not support WebAuthn",null)});const{data:i,error:l}=await this._startPasskeyRegistration();if(l||!i)return this._returnResult({data:null,error:l});const c=Ew(i.options),d=(s=(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.signal)!==null&&s!==void 0?s:Wp.createNewAbortSignal(),{data:h,error:m}=await BS({publicKey:c,signal:d});if(m||!h)return this._returnResult({data:null,error:m??new yr("WebAuthn ceremony failed",null)});const b=Nw(h);return this._verifyPasskeyRegistration({challengeId:i.challenge_id,credential:b})}catch(i){if(ye(i))return this._returnResult({data:null,error:i});throw i}}async _startPasskeyRegistration(){pr(this.experimental);try{return await this._useSession(async t=>{const{data:{session:n},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!n)return this._returnResult({data:null,error:new Zt});const{data:i,error:l}=await Ae(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:n.access_token,body:{}});return l?this._returnResult({data:null,error:l}):this._returnResult({data:i,error:null})})}catch(t){if(ye(t))return this._returnResult({data:null,error:t});throw t}}async _verifyPasskeyRegistration(t){pr(this.experimental);try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Zt});const{data:l,error:c}=await Ae(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:s.access_token,body:{challenge_id:t.challengeId,credential:t.credential}});return c?this._returnResult({data:null,error:c}):this._returnResult({data:l,error:null})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyAuthentication(t){var n;pr(this.experimental);try{const{data:s,error:i}=await Ae(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.captchaToken}}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:s,error:null})}catch(s){if(ye(s))return this._returnResult({data:null,error:s});throw s}}async _verifyPasskeyAuthentication(t){pr(this.experimental);try{const{data:n,error:s}=await Ae(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:t.challengeId,credential:t.credential},xform:ar});return s?this._returnResult({data:null,error:s}):(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:n,error:null}))}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _listPasskeys(){pr(this.experimental);try{return await this._useSession(async t=>{const{data:{session:n},error:s}=t;if(s)return this._returnResult({data:null,error:s});if(!n)return this._returnResult({data:null,error:new Zt});const{data:i,error:l}=await Ae(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:n.access_token,xform:c=>({data:c,error:null})});return l?this._returnResult({data:null,error:l}):this._returnResult({data:i,error:null})})}catch(t){if(ye(t))return this._returnResult({data:null,error:t});throw t}}async _updatePasskey(t){pr(this.experimental);try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Zt});const{data:l,error:c}=await Ae(this.fetch,"PATCH",`${this.url}/passkeys/${t.passkeyId}`,{headers:this.headers,jwt:s.access_token,body:{friendly_name:t.friendlyName}});return c?this._returnResult({data:null,error:c}):this._returnResult({data:l,error:null})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}async _deletePasskey(t){pr(this.experimental);try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Zt});const{error:l}=await Ae(this.fetch,"DELETE",`${this.url}/passkeys/${t.passkeyId}`,{headers:this.headers,jwt:s.access_token,noResolveJson:!0});return l?this._returnResult({data:null,error:l}):this._returnResult({data:null,error:null})})}catch(n){if(ye(n))return this._returnResult({data:null,error:n});throw n}}}Hl.nextInstanceID={};const IM=Hl,UM="2.106.2";let Cl="";typeof Deno<"u"?Cl="deno":typeof document<"u"?Cl="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Cl="react-native":Cl="node";const $M={"X-Client-Info":`supabase-js-${Cl}/${UM}`},BM={headers:$M},HM={schema:"public"},qM={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},VM={},FM={enabled:!1,respectSamplingDecision:!0};function GM(e,t,n,s){function i(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function d(b){try{m(s.next(b))}catch(g){c(g)}}function h(b){try{m(s.throw(b))}catch(g){c(g)}}function m(b){b.done?l(b.value):i(b.value).then(d,h)}m((s=s.apply(e,[])).next())})}let tp=null;const KM="@opentelemetry/api";function YM(){return tp===null&&(tp=import(KM).catch(()=>null)),tp}function WM(){return GM(this,void 0,void 0,function*(){try{const e=yield YM();if(!e||!e.propagation||!e.context)return null;const t={};e.propagation.inject(e.context.active(),t);const n=t.traceparent;return n?{traceparent:n,tracestate:t.tracestate,baggage:t.baggage}:null}catch{return null}})}function XM(e){if(!e||typeof e!="string")return null;const t=e.split("-");if(t.length!==4)return null;const[n,s,i,l]=t;if(n.length!==2||s.length!==32||i.length!==16||l.length!==2)return null;const c=/^[0-9a-f]+$/i;return!c.test(n)||!c.test(s)||!c.test(i)||!c.test(l)||s==="00000000000000000000000000000000"||i==="0000000000000000"?null:{version:n,traceId:s,parentId:i,traceFlags:l,isSampled:(parseInt(l,16)&1)===1}}function JM(e,t){if(!e||!t||t.length===0)return!1;let n;if(e instanceof URL)n=e;else try{n=new URL(e)}catch{return!1}for(const s of t)try{if(typeof s=="string"){if(QM(n.hostname,s))return!0}else if(s instanceof RegExp){if(s.test(n.hostname))return!0}else if(typeof s=="function"&&s(n))return!0}catch{continue}return!1}function QM(e,t){if(t===e)return!0;if(t.startsWith("*.")){const n=t.slice(2);if(e.endsWith(n)&&(e===n||e.endsWith("."+n)))return!0}return!1}function ZM(e){const t=[];try{const n=new URL(e);t.push(n.hostname)}catch{}return t.push("*.supabase.co","*.supabase.in"),t.push("localhost","127.0.0.1","[::1]"),t}function ql(e){"@babel/helpers - typeof";return ql=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ql(e)}function eD(e,t){if(ql(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var s=n.call(e,t);if(ql(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function tD(e){var t=eD(e,"string");return ql(t)=="symbol"?t:t+""}function nD(e,t,n){return(t=tD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Aw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,s)}return n}function Mt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Aw(Object(n),!0).forEach(function(s){nD(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Aw(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}const rD=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),aD=()=>Headers,sD=(e,t,n,s,i)=>{const l=rD(s),c=aD(),d=(i==null?void 0:i.enabled)===!0,h=(i==null?void 0:i.respectSamplingDecision)!==!1,m=d?ZM(t):null;return async(b,g)=>{var x;const w=(x=await n())!==null&&x!==void 0?x:e;let E=new c(g==null?void 0:g.headers);if(E.has("apikey")||E.set("apikey",e),E.has("Authorization")||E.set("Authorization",`Bearer ${w}`),m){const S=await iD(b,m,h);S&&(S.traceparent&&!E.has("traceparent")&&E.set("traceparent",S.traceparent),S.tracestate&&!E.has("tracestate")&&E.set("tracestate",S.tracestate),S.baggage&&!E.has("baggage")&&E.set("baggage",S.baggage))}return l(b,Mt(Mt({},g),{},{headers:E}))}};async function iD(e,t,n){if(!JM(typeof e=="string"||e instanceof URL?e:e.url,t))return null;const s=await WM();if(!s||!s.traceparent)return null;if(n){const i=XM(s.traceparent);if(i&&!i.isSampled)return null}return s}function Rw(e){return typeof e=="boolean"?{enabled:e}:e}function oD(e){return e.endsWith("/")?e:e+"/"}function lD(e,t){var n,s,i,l,c,d;const{db:h,auth:m,realtime:b,global:g}=e,{db:x,auth:w,realtime:E,global:S}=t,N=Rw(e.tracePropagation),C=Rw(t.tracePropagation),A={db:Mt(Mt({},x),h),auth:Mt(Mt({},w),m),realtime:Mt(Mt({},E),b),storage:{},global:Mt(Mt(Mt({},S),g),{},{headers:Mt(Mt({},(n=S==null?void 0:S.headers)!==null&&n!==void 0?n:{}),(s=g==null?void 0:g.headers)!==null&&s!==void 0?s:{})}),tracePropagation:{enabled:(i=(l=N==null?void 0:N.enabled)!==null&&l!==void 0?l:C==null?void 0:C.enabled)!==null&&i!==void 0?i:!1,respectSamplingDecision:(c=(d=N==null?void 0:N.respectSamplingDecision)!==null&&d!==void 0?d:C==null?void 0:C.respectSamplingDecision)!==null&&c!==void 0?c:!0},accessToken:async()=>""};return e.accessToken?A.accessToken=e.accessToken:delete A.accessToken,A}function cD(e){const t=e==null?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(oD(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var uD=class extends IM{constructor(e){super(e)}},dD=class{constructor(e,t,n){var s,i;this.supabaseUrl=e,this.supabaseKey=t;const l=cD(e);if(!t)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const c=`sb-${l.hostname.split(".")[0]}-auth-token`,d={db:HM,realtime:VM,auth:Mt(Mt({},qM),{},{storageKey:c}),global:BM,tracePropagation:FM},h=lD(n??{},d);if(this.settings=h,this.storageKey=(s=h.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=h.global.headers)!==null&&i!==void 0?i:{},h.accessToken)this.accessToken=h.accessToken,this.auth=new Proxy({},{get:(b,g)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(g)} is not possible`)}});else{var m;this.auth=this._initSupabaseAuthClient((m=h.auth)!==null&&m!==void 0?m:{},this.headers,h.global.fetch)}this.fetch=sD(t,e,this._getAccessToken.bind(this),h.global.fetch,h.tracePropagation),this.realtime=this._initRealtimeClient(Mt({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},h.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(b=>this.realtime.setAuth(b)).catch(b=>console.warn("Failed to set initial Realtime auth token:",b)),this.rest=new j2(new URL("rest/v1",l).href,{headers:this.headers,schema:h.db.schema,fetch:this.fetch,timeout:h.db.timeout,urlLengthLimit:h.db.urlLengthLimit}),this.storage=new $O(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),h.accessToken||this._listenForAuthEvents()}get functions(){return new v2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,n)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e=this,t,n;if(e.accessToken)return await e.accessToken();const{data:s}=await e.auth.getSession();return(t=(n=s.session)===null||n===void 0?void 0:n.access_token)!==null&&t!==void 0?t:e.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,userStorage:i,storageKey:l,flowType:c,lock:d,debug:h,throwOnError:m,experimental:b,lockAcquireTimeout:g,skipAutoInitialize:x},w,E){const S={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new uD({url:this.authUrl.href,headers:Mt(Mt({},S),w),storageKey:l,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,userStorage:i,flowType:c,lock:d,debug:h,throwOnError:m,experimental:b,fetch:E,lockAcquireTimeout:g,skipAutoInitialize:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(N=>N.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new cO(this.realtimeUrl.href,Mt(Mt({},e),{},{params:Mt(Mt({},{apikey:this.supabaseKey}),e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",t==null?void 0:t.access_token)})}_handleTokenChanged(e,t,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const fD=(e,t,n)=>new dD(e,t,n);function hD(){if(typeof window<"u")return!1;const e=globalThis.process;if(!e)return!1;const t=e.version;if(t==null)return!1;const n=t.match(/^v(\d+)\./);return n?parseInt(n[1],10)<=18:!1}hD()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const mD={BASE_URL:"/tablero-cdc/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_LISTS_WEBHOOK_URL:"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-listas-admin",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE",VITE_SUPABASE_URL:"https://dbit.digitalcompass.agency",VITE_WEBHOOK_URL:"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-proyecto"},pD=["VITE_SUPABASE_URL","VITE_SUPABASE_ANON_KEY"],kw=pD.filter(e=>!mD[e]);if(kw.length>0)throw new Error(`Faltan variables de entorno de Supabase. Revisa tu archivo .env.
Variables faltantes: ${kw.join(", ")}`);const Ce=fD("https://dbit.digitalcompass.agency","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE",{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0}});function qS(e){return String(e??"").trim().toLowerCase()}function Ow(e){return!(e!=null&&e.email)||e.is_active!==!0?null:{email:qS(e.email),fullName:e.full_name??null,role:String(e.role||"user").trim()||"user",isActive:!0,canDeleteProjects:e.can_delete_projects===!0,canManageInternalPricing:e.can_manage_internal_pricing===!0,canControlPricingSummary:e.can_control_pricing_summary===!0,canManageTariffCatalog:e.can_manage_tariff_catalog===!0}}async function VS(e){const t=qS(e);if(!t)return null;const n=await Ce.from("tablero_cdc_allowed_users").select("email, full_name, role, is_active, can_delete_projects, can_manage_internal_pricing, can_control_pricing_summary, can_manage_tariff_catalog").eq("email",t).eq("is_active",!0).maybeSingle();if(!n.error)return Ow(n.data);const s=n.error.message||"";if(!(s.includes("can_manage_tariff_catalog")||s.includes("column")||s.includes("schema cache")))throw n.error;const l=await Ce.from("tablero_cdc_allowed_users").select("email, full_name, role, is_active, can_delete_projects, can_manage_internal_pricing, can_control_pricing_summary").eq("email",t).eq("is_active",!0).maybeSingle();if(l.error)throw l.error;return Ow(l.data)}async function Ig(){const{data:e,error:t}=await Ce.auth.getUser();if(t||!e.user)throw new Error("No hay una sesión activa de Supabase.");const n=await VS(e.user.email);if(!n)throw new Error("Tu correo no está autorizado para acceder al Tablero CDC.");return n}const Mw="tablero_cdc_metrics_session_id",Dw="tablero_cdc_metrics_open_recorded";function gD(){if(typeof window>"u")return crypto.randomUUID();const e=window.sessionStorage.getItem(Mw);if(e)return e;const t=crypto.randomUUID();return window.sessionStorage.setItem(Mw,t),t}async function vD(){if(typeof window<"u"&&window.sessionStorage.getItem(Dw)==="1")return;const e=gD(),{error:t}=await Ce.rpc("tablero_cdc_track_app_open",{p_session_id:e});if(t){const n=String(t.message||"").toLowerCase();n.includes("tablero_cdc_track_app_open")||n.includes("could not find the function")||n.includes("schema cache")||console.warn("No se pudo registrar la métrica de apertura del Tablero CDC:",t);return}typeof window<"u"&&window.sessionStorage.setItem(Dw,"1")}function yD(){return typeof window>"u"?"/tablero-cdc/":new URL("/tablero-cdc/",window.location.origin).toString()}function bD(e){var i;const t=e.user_metadata||{},n=t.full_name||t.name||t.display_name||((i=e.email)==null?void 0:i.split("@")[0])||null,s=t.avatar_url||t.picture||null;return{id:e.id,uid:e.id,email:e.email??null,displayName:n,photoURL:s,raw:e}}const FS=v.createContext(null);function xD({children:e}){const[t,n]=v.useState(null),[s,i]=v.useState(null),[l,c]=v.useState(!0),[d,h]=v.useState(null),m=v.useCallback(async C=>{if(!C){n(null),i(null);return}let A=null;try{A=await VS(C.email)}catch(T){console.error("Error al validar acceso al Tablero CDC:",T),await Ce.auth.signOut(),n(null),i(null),h("No se pudo validar tu acceso al Tablero CDC. Verifica que el SQL de accesos esté ejecutado o contacta a IT.");return}if(!A){await Ce.auth.signOut(),n(null),i(null),h("Tu correo no está autorizado para acceder al Tablero CDC. Solicita acceso a IT o al equipo CDC.");return}n(bD(C)),i(A),h(null),vD()},[]);v.useEffect(()=>{let C=!0;Ce.auth.getSession().then(async({data:T,error:M})=>{var U;if(C){if(M){console.error("Error al recuperar sesión de Supabase:",M),n(null),h("No se pudo recuperar la sesión. Intenta iniciar sesión de nuevo.");return}await m(((U=T.session)==null?void 0:U.user)??null)}}).catch(T=>{C&&(console.error("Error inesperado al recuperar sesión:",T),n(null),h("No se pudo recuperar la sesión. Intenta iniciar sesión de nuevo."))}).finally(()=>{C&&c(!1)});const{data:A}=Ce.auth.onAuthStateChange((T,M)=>{c(!0),m((M==null?void 0:M.user)??null).finally(()=>{C&&c(!1)})});return()=>{C=!1,A.subscription.unsubscribe()}},[m]);const b=v.useCallback(async()=>{h(null);const{error:C}=await Ce.auth.signInWithOAuth({provider:"google",options:{redirectTo:yD(),queryParams:{prompt:"select_account"}}});C&&(console.error("Error al iniciar sesión con Google:",C),h("No se pudo iniciar sesión. Intenta de nuevo."))},[]),g=v.useCallback(async()=>{const{error:C}=await Ce.auth.signOut();if(C){console.error("Error al cerrar sesión:",C),h("No se pudo cerrar sesión. Intenta de nuevo.");return}n(null),i(null),h(null)},[]),x=v.useMemo(()=>(s==null?void 0:s.role)==="director_creativo",[s==null?void 0:s.role]),w=v.useMemo(()=>(s==null?void 0:s.canManageInternalPricing)===!0,[s==null?void 0:s.canManageInternalPricing]),E=v.useMemo(()=>(s==null?void 0:s.canDeleteProjects)===!0,[s==null?void 0:s.canDeleteProjects]),S=v.useMemo(()=>(s==null?void 0:s.canControlPricingSummary)===!0,[s==null?void 0:s.canControlPricingSummary]),N=v.useMemo(()=>(s==null?void 0:s.canManageTariffCatalog)===!0,[s==null?void 0:s.canManageTariffCatalog]);return f.jsx(FS.Provider,{value:{user:t,loading:l,error:d,isGerardo:x,canDeleteProjects:E,canManageInternalPricing:w,canControlPricingSummary:S,canManageTariffCatalog:N,loginWithGoogle:b,logout:g},children:e})}function Xd(){const e=v.useContext(FS);if(!e)throw new Error("useAuth debe usarse dentro de <AuthProvider>");return e}function Lw(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function bn(...e){return t=>{let n=!1;const s=e.map(i=>{const l=Lw(i,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let i=0;i<s.length;i++){const l=s[i];typeof l=="function"?l():Lw(e[i],null)}}}}function Je(...e){return v.useCallback(bn(...e),e)}var wD=Symbol.for("react.lazy"),_d=jg[" use ".trim().toString()];function _D(e){return typeof e=="object"&&e!==null&&"then"in e}function GS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===wD&&"_payload"in e&&_D(e._payload)}function Jd(e){const t=ED(e),n=v.forwardRef((s,i)=>{let{children:l,...c}=s;GS(l)&&typeof _d=="function"&&(l=_d(l._payload));const d=v.Children.toArray(l),h=d.find(ND);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}var SD=Jd("Slot");function ED(e){const t=v.forwardRef((n,s)=>{let{children:i,...l}=n;if(GS(i)&&typeof _d=="function"&&(i=_d(i._payload)),v.isValidElement(i)){const c=TD(i),d=jD(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var CD=Symbol("radix.slottable");function ND(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===CD}function jD(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function TD(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function KS(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=KS(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function YS(){for(var e,t,n=0,s="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=KS(e))&&(s&&(s+=" "),s+=t);return s}const Pw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,zw=YS,Ug=(e,t)=>n=>{var s;if((t==null?void 0:t.variants)==null)return zw(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:l}=t,c=Object.keys(i).map(m=>{const b=n==null?void 0:n[m],g=l==null?void 0:l[m];if(b===null)return null;const x=Pw(b)||Pw(g);return i[m][x]}),d=n&&Object.entries(n).reduce((m,b)=>{let[g,x]=b;return x===void 0||(m[g]=x),m},{}),h=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((m,b)=>{let{class:g,className:x,...w}=b;return Object.entries(w).every(E=>{let[S,N]=E;return Array.isArray(N)?N.includes({...l,...d}[S]):{...l,...d}[S]===N})?[...m,g,x]:m},[]);return zw(e,c,h,n==null?void 0:n.class,n==null?void 0:n.className)},AD=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s<e.length;s++)n[s]=e[s];for(let s=0;s<t.length;s++)n[e.length+s]=t[s];return n},RD=(e,t)=>({classGroupId:e,validator:t}),WS=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Sd="-",Iw=[],kD="arbitrary..",OD=e=>{const t=DD(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return MD(c);const d=c.split(Sd),h=d[0]===""&&d.length>1?1:0;return XS(d,h,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const h=s[c],m=n[c];return h?m?AD(m,h):h:m||Iw}return n[c]||Iw}}},XS=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],l=n.nextPart.get(i);if(l){const m=XS(e,t+1,l);if(m)return m}const c=n.validators;if(c===null)return;const d=t===0?e.join(Sd):e.slice(t).join(Sd),h=c.length;for(let m=0;m<h;m++){const b=c[m];if(b.validator(d))return b.classGroupId}},MD=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?kD+s:void 0})(),DD=e=>{const{theme:t,classGroups:n}=e;return LD(n,t)},LD=(e,t)=>{const n=WS();for(const s in e){const i=e[s];$g(i,n,s,t)}return n},$g=(e,t,n,s)=>{const i=e.length;for(let l=0;l<i;l++){const c=e[l];PD(c,t,n,s)}},PD=(e,t,n,s)=>{if(typeof e=="string"){zD(e,t,n);return}if(typeof e=="function"){ID(e,t,n,s);return}UD(e,t,n,s)},zD=(e,t,n)=>{const s=e===""?t:JS(t,e);s.classGroupId=n},ID=(e,t,n,s)=>{if($D(e)){$g(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(RD(n,e))},UD=(e,t,n,s)=>{const i=Object.entries(e),l=i.length;for(let c=0;c<l;c++){const[d,h]=i[c];$g(h,JS(t,d),n,s)}},JS=(e,t)=>{let n=e;const s=t.split(Sd),i=s.length;for(let l=0;l<i;l++){const c=s[l];let d=n.nextPart.get(c);d||(d=WS(),n.nextPart.set(c,d)),n=d}return n},$D=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,BD=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const i=(l,c)=>{n[l]=c,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(l){let c=n[l];if(c!==void 0)return c;if((c=s[l])!==void 0)return i(l,c),c},set(l,c){l in n?n[l]=c:i(l,c)}}},Xp="!",Uw=":",HD=[],$w=(e,t,n,s,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:i}),qD=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=i=>{const l=[];let c=0,d=0,h=0,m;const b=i.length;for(let S=0;S<b;S++){const N=i[S];if(c===0&&d===0){if(N===Uw){l.push(i.slice(h,S)),h=S+1;continue}if(N==="/"){m=S;continue}}N==="["?c++:N==="]"?c--:N==="("?d++:N===")"&&d--}const g=l.length===0?i:i.slice(h);let x=g,w=!1;g.endsWith(Xp)?(x=g.slice(0,-1),w=!0):g.startsWith(Xp)&&(x=g.slice(1),w=!0);const E=m&&m>h?m-h:void 0;return $w(l,w,x,E)};if(t){const i=t+Uw,l=s;s=c=>c.startsWith(i)?l(c.slice(i.length)):$w(HD,!1,c,void 0,!0)}if(n){const i=s;s=l=>n({className:l,parseClassName:i})}return s},VD=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];let i=[];for(let l=0;l<n.length;l++){const c=n[l],d=c[0]==="[",h=t.has(c);d||h?(i.length>0&&(i.sort(),s.push(...i),i=[]),s.push(c)):i.push(c)}return i.length>0&&(i.sort(),s.push(...i)),s}},FD=e=>({cache:BD(e.cacheSize),parseClassName:qD(e),sortModifiers:VD(e),postfixLookupClassGroupIds:GD(e),...OD(e)}),GD=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let s=0;s<n.length;s++)t[n[s]]=!0;return t},KD=/\s+/,YD=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:i,sortModifiers:l,postfixLookupClassGroupIds:c}=t,d=[],h=e.trim().split(KD);let m="";for(let b=h.length-1;b>=0;b-=1){const g=h[b],{isExternal:x,modifiers:w,hasImportantModifier:E,baseClassName:S,maybePostfixModifierPosition:N}=n(g);if(x){m=g+(m.length>0?" "+m:m);continue}let C=!!N,A;if(C){const L=S.substring(0,N);A=s(L);const B=A&&c[A]?s(S):void 0;B&&B!==A&&(A=B,C=!1)}else A=s(S);if(!A){if(!C){m=g+(m.length>0?" "+m:m);continue}if(A=s(S),!A){m=g+(m.length>0?" "+m:m);continue}C=!1}const T=w.length===0?"":w.length===1?w[0]:l(w).join(":"),M=E?T+Xp:T,U=M+A;if(d.indexOf(U)>-1)continue;d.push(U);const z=i(A,C);for(let L=0;L<z.length;++L){const B=z[L];d.push(M+B)}m=g+(m.length>0?" "+m:m)}return m},WD=(...e)=>{let t=0,n,s,i="";for(;t<e.length;)(n=e[t++])&&(s=QS(n))&&(i&&(i+=" "),i+=s);return i},QS=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=QS(e[s]))&&(n&&(n+=" "),n+=t);return n},XD=(e,...t)=>{let n,s,i,l;const c=h=>{const m=t.reduce((b,g)=>g(b),e());return n=FD(m),s=n.cache.get,i=n.cache.set,l=d,d(h)},d=h=>{const m=s(h);if(m)return m;const b=YD(h,n);return i(h,b),b};return l=c,(...h)=>l(WD(...h))},JD=[],Wt=e=>{const t=n=>n[e]||JD;return t.isThemeGetter=!0,t},ZS=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,e1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,QD=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ZD=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,e5=/\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$/,t5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,n5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,r5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ka=e=>QD.test(e),Xe=e=>!!e&&!Number.isNaN(Number(e)),Rr=e=>!!e&&Number.isInteger(Number(e)),np=e=>e.endsWith("%")&&Xe(e.slice(0,-1)),la=e=>ZD.test(e),t1=()=>!0,a5=e=>e5.test(e)&&!t5.test(e),Bg=()=>!1,s5=e=>n5.test(e),i5=e=>r5.test(e),o5=e=>!_e(e)&&!Ee(e),l5=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),c5=e=>is(e,a1,Bg),_e=e=>ZS.test(e),Rs=e=>is(e,s1,a5),Bw=e=>is(e,v5,Xe),u5=e=>is(e,o1,t1),d5=e=>is(e,i1,Bg),Hw=e=>is(e,n1,Bg),f5=e=>is(e,r1,i5),Lu=e=>is(e,l1,s5),Ee=e=>e1.test(e),bl=e=>Gs(e,s1),h5=e=>Gs(e,i1),qw=e=>Gs(e,n1),m5=e=>Gs(e,a1),p5=e=>Gs(e,r1),Pu=e=>Gs(e,l1,!0),g5=e=>Gs(e,o1,!0),is=(e,t,n)=>{const s=ZS.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},Gs=(e,t,n=!1)=>{const s=e1.exec(e);return s?s[1]?t(s[1]):n:!1},n1=e=>e==="position"||e==="percentage",r1=e=>e==="image"||e==="url",a1=e=>e==="length"||e==="size"||e==="bg-size",s1=e=>e==="length",v5=e=>e==="number",i1=e=>e==="family-name",o1=e=>e==="number"||e==="weight",l1=e=>e==="shadow",y5=()=>{const e=Wt("color"),t=Wt("font"),n=Wt("text"),s=Wt("font-weight"),i=Wt("tracking"),l=Wt("leading"),c=Wt("breakpoint"),d=Wt("container"),h=Wt("spacing"),m=Wt("radius"),b=Wt("shadow"),g=Wt("inset-shadow"),x=Wt("text-shadow"),w=Wt("drop-shadow"),E=Wt("blur"),S=Wt("perspective"),N=Wt("aspect"),C=Wt("ease"),A=Wt("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],U=()=>[...M(),Ee,_e],z=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],B=()=>[Ee,_e,h],q=()=>[Ka,"full","auto",...B()],ue=()=>[Rr,"none","subgrid",Ee,_e],le=()=>["auto",{span:["full",Rr,Ee,_e]},Rr,Ee,_e],he=()=>[Rr,"auto",Ee,_e],de=()=>["auto","min","max","fr",Ee,_e],ve=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],pe=()=>["start","end","center","stretch","center-safe","end-safe"],O=()=>["auto",...B()],K=()=>[Ka,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],W=()=>[Ka,"screen","full","dvw","lvw","svw","min","max","fit",...B()],J=()=>[Ka,"screen","full","lh","dvh","lvh","svh","min","max","fit",...B()],V=()=>[e,Ee,_e],R=()=>[...M(),qw,Hw,{position:[Ee,_e]}],k=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",m5,c5,{size:[Ee,_e]}],X=()=>[np,bl,Rs],H=()=>["","none","full",m,Ee,_e],te=()=>["",Xe,bl,Rs],ee=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Xe,np,qw,Hw],Ne=()=>["","none",E,Ee,_e],ze=()=>["none",Xe,Ee,_e],Oe=()=>["none",Xe,Ee,_e],Qe=()=>[Xe,Ee,_e],Ze=()=>[Ka,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[la],breakpoint:[la],color:[t1],container:[la],"drop-shadow":[la],ease:["in","out","in-out"],font:[o5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[la],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[la],shadow:[la],spacing:["px",Xe],text:[la],"text-shadow":[la],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ka,_e,Ee,N]}],container:["container"],"container-type":[{"@container":["","normal","size",Ee,_e]}],"container-named":[l5],columns:[{columns:[Xe,_e,Ee,d]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"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:U()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:q()}],"inset-x":[{"inset-x":q()}],"inset-y":[{"inset-y":q()}],start:[{"inset-s":q(),start:q()}],end:[{"inset-e":q(),end:q()}],"inset-bs":[{"inset-bs":q()}],"inset-be":[{"inset-be":q()}],top:[{top:q()}],right:[{right:q()}],bottom:[{bottom:q()}],left:[{left:q()}],visibility:["visible","invisible","collapse"],z:[{z:[Rr,"auto",Ee,_e]}],basis:[{basis:[Ka,"full","auto",d,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Xe,Ka,"auto","initial","none",_e]}],grow:[{grow:["",Xe,Ee,_e]}],shrink:[{shrink:["",Xe,Ee,_e]}],order:[{order:[Rr,"first","last","none",Ee,_e]}],"grid-cols":[{"grid-cols":ue()}],"col-start-end":[{col:le()}],"col-start":[{"col-start":he()}],"col-end":[{"col-end":he()}],"grid-rows":[{"grid-rows":ue()}],"row-start-end":[{row:le()}],"row-start":[{"row-start":he()}],"row-end":[{"row-end":he()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":de()}],"auto-rows":[{"auto-rows":de()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...ve(),"normal"]}],"justify-items":[{"justify-items":[...pe(),"normal"]}],"justify-self":[{"justify-self":["auto",...pe()]}],"align-content":[{content:["normal",...ve()]}],"align-items":[{items:[...pe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...pe(),{baseline:["","last"]}]}],"place-content":[{"place-content":ve()}],"place-items":[{"place-items":[...pe(),"baseline"]}],"place-self":[{"place-self":["auto",...pe()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pbs:[{pbs:B()}],pbe:[{pbe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mbs:[{mbs:O()}],mbe:[{mbe:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],"inline-size":[{inline:["auto",...W()]}],"min-inline-size":[{"min-inline":["auto",...W()]}],"max-inline-size":[{"max-inline":["none",...W()]}],"block-size":[{block:["auto",...J()]}],"min-block-size":[{"min-block":["auto",...J()]}],"max-block-size":[{"max-block":["none",...J()]}],w:[{w:[d,"screen",...K()]}],"min-w":[{"min-w":[d,"screen","none",...K()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[c]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",n,bl,Rs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,g5,u5]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",np,_e]}],"font-family":[{font:[h5,d5,t]}],"font-features":[{"font-features":[_e]}],"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:[i,Ee,_e]}],"line-clamp":[{"line-clamp":[Xe,"none",Ee,Bw]}],leading:[{leading:[l,...B()]}],"list-image":[{"list-image":["none",Ee,_e]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ee,_e]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[Xe,"from-font","auto",Ee,Rs]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[Xe,"auto",Ee,_e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"tab-size":[{tab:[Rr,Ee,_e]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ee,_e]}],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",Ee,_e]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:R()}],"bg-repeat":[{bg:k()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Rr,Ee,_e],radial:["",Ee,_e],conic:[Rr,Ee,_e]},p5,f5]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-bs":[{"border-bs":te()}],"border-w-be":[{"border-be":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Xe,Ee,_e]}],"outline-w":[{outline:["",Xe,bl,Rs]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",b,Pu,Lu]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",g,Pu,Lu]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[Xe,Rs]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",x,Pu,Lu]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[Xe,Ee,_e]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"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":[Xe]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Ee,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"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":M()}],"mask-image-conic-pos":[{"mask-conic":[Xe]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:R()}],"mask-repeat":[{mask:k()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ee,_e]}],filter:[{filter:["","none",Ee,_e]}],blur:[{blur:Ne()}],brightness:[{brightness:[Xe,Ee,_e]}],contrast:[{contrast:[Xe,Ee,_e]}],"drop-shadow":[{"drop-shadow":["","none",w,Pu,Lu]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",Xe,Ee,_e]}],"hue-rotate":[{"hue-rotate":[Xe,Ee,_e]}],invert:[{invert:["",Xe,Ee,_e]}],saturate:[{saturate:[Xe,Ee,_e]}],sepia:[{sepia:["",Xe,Ee,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",Ee,_e]}],"backdrop-blur":[{"backdrop-blur":Ne()}],"backdrop-brightness":[{"backdrop-brightness":[Xe,Ee,_e]}],"backdrop-contrast":[{"backdrop-contrast":[Xe,Ee,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Xe,Ee,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Xe,Ee,_e]}],"backdrop-invert":[{"backdrop-invert":["",Xe,Ee,_e]}],"backdrop-opacity":[{"backdrop-opacity":[Xe,Ee,_e]}],"backdrop-saturate":[{"backdrop-saturate":[Xe,Ee,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",Xe,Ee,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ee,_e]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Xe,"initial",Ee,_e]}],ease:[{ease:["linear","initial",C,Ee,_e]}],delay:[{delay:[Xe,Ee,_e]}],animate:[{animate:["none",A,Ee,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,Ee,_e]}],"perspective-origin":[{"perspective-origin":U()}],rotate:[{rotate:ze()}],"rotate-x":[{"rotate-x":ze()}],"rotate-y":[{"rotate-y":ze()}],"rotate-z":[{"rotate-z":ze()}],scale:[{scale:Oe()}],"scale-x":[{"scale-x":Oe()}],"scale-y":[{"scale-y":Oe()}],"scale-z":[{"scale-z":Oe()}],"scale-3d":["scale-3d"],skew:[{skew:Qe()}],"skew-x":[{"skew-x":Qe()}],"skew-y":[{"skew-y":Qe()}],transform:[{transform:[Ee,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:U()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ze()}],"translate-x":[{"translate-x":Ze()}],"translate-y":[{"translate-y":Ze()}],"translate-z":[{"translate-z":Ze()}],"translate-none":["translate-none"],zoom:[{zoom:[Rr,Ee,_e]}],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"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",Ee,_e]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":V()}],"scrollbar-track-color":[{"scrollbar-track":V()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mbs":[{"scroll-mbs":B()}],"scroll-mbe":[{"scroll-mbe":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pbs":[{"scroll-pbs":B()}],"scroll-pbe":[{"scroll-pbe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"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",Ee,_e]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[Xe,bl,Rs,Bw]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","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","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","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-bs","border-w-be","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-bs","border-color-be","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-mbs","scroll-mbe","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-pbs","scroll-pbe","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"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},b5=XD(y5);function xe(...e){return b5(YS(e))}const x5=Ug("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ke=v.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...i},l)=>{const c=s?SD:"button";return f.jsx(c,{className:xe(x5({variant:t,size:n,className:e})),ref:l,...i})});ke.displayName="Button";function Hg({size:e="sm",className:t}){const n=e==="lg"?"h-auto w-[168px]":"h-auto w-[104px]",s=e==="lg"?"-translate-x-1":"";return f.jsx("div",{className:xe("inline-flex items-center",t),"aria-label":"GLM",children:f.jsx("img",{src:"/tablero-cdc/glm-logo.png",alt:"GLM",className:xe(n,s),loading:"eager",decoding:"async"})})}function w5(){const{loginWithGoogle:e,error:t,loading:n}=Xd();return f.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-4",children:f.jsxs("div",{className:"w-full max-w-sm",children:[f.jsxs("div",{className:"flex flex-col items-center mb-8 gap-3",children:[f.jsx(Hg,{size:"lg"}),f.jsx("h1",{className:"text-2xl font-bold tracking-tight text-[#4F758B] text-center",children:"CDC Project Management"})]}),f.jsxs("div",{className:"bg-card border border-border rounded-2xl p-8 shadow-sm",children:[f.jsxs(ke,{onClick:e,disabled:n,className:"w-full gap-2.5 h-10 rounded-full font-medium",children:[f.jsxs("svg",{"aria-hidden":"true",className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),f.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),f.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),f.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Entrar con Google"]}),t&&f.jsx("div",{className:"mt-4 rounded-lg bg-destructive/10 border border-destructive/20 px-4 py-3",children:f.jsx("p",{className:"text-sm text-destructive text-center leading-snug",children:t})})]}),f.jsx("p",{className:"text-center text-xs text-muted-foreground mt-6",children:"Acceso restringido a usuarios autorizados"})]})})}/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const c1=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _5=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S5=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vw=e=>{const t=S5(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var E5={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"};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C5=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N5=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:l,iconNode:c,...d},h)=>v.createElement("svg",{ref:h,...E5,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:c1("lucide",i),...!l&&!C5(d)&&{"aria-hidden":"true"},...d},[...c.map(([m,b])=>v.createElement(m,b)),...Array.isArray(l)?l:[l]]));/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const He=(e,t)=>{const n=v.forwardRef(({className:s,...i},l)=>v.createElement(N5,{ref:l,iconNode:t,className:c1(`lucide-${_5(Vw(e))}`,`lucide-${e}`,s),...i}));return n.displayName=Vw(e),n};/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j5=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],Fw=He("archive-restore",j5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const T5=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]],u1=He("badge-dollar-sign",T5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A5=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],Gw=He("building-2",A5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const R5=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],k5=He("calculator",R5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const O5=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],M5=He("calendar-clock",O5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D5=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],L5=He("calendar-days",D5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const P5=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],z5=He("calendar",P5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const I5=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],$r=He("check",I5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const U5=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],qg=He("chevron-down",U5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $5=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vg=He("chevron-left",$5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const B5=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Qd=He("chevron-right",B5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const H5=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],q5=He("chevron-up",H5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const V5=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],d1=He("chevrons-up-down",V5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const F5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Ed=He("circle-alert",F5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const G5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],f1=He("circle-check",G5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const K5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]],Kw=He("circle-dollar-sign",K5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y5=[["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"}]],W5=He("circle-x",Y5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const X5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],J5=He("circle",X5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Q5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],Ol=He("clock-3",Q5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z5=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Jp=He("dollar-sign",Z5);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const e3=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Fg=He("external-link",e3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const t3=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],n3=He("eye-off",t3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const r3=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],a3=He("eye",r3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const s3=[["path",{d:"M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6",key:"g5mvt7"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14 20 2 2 4-4",key:"15kota"}]],i3=He("file-check-corner",s3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const o3=[["path",{d:"M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5",key:"1jo35a"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m15 17 5 5",key:"36xl1x"}],["path",{d:"m20 17-5 5",key:"vdz27y"}]],l3=He("file-x-corner",o3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const c3=[["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"}]],u3=He("folder-open",c3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const d3=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],f3=He("history",d3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const h3=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],m3=He("inbox",h3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const p3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],g3=He("info",p3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const v3=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],y3=He("layers",v3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const b3=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],x3=He("layout-grid",b3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const w3=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],_3=He("link-2",w3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S3=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],E3=He("link",S3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C3=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],Cd=He("list-checks",C3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N3=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Xt=He("loader-circle",N3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j3=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],T3=He("lock",j3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A3=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],R3=He("log-out",A3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const k3=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Nd=He("map-pin",k3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const O3=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],M3=He("message-square-plus",O3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D3=[["path",{d:"M13 21h8",key:"1jsn5i"}],["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"}]],L3=He("pen-line",D3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const P3=[["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"}]],Gg=He("pencil",P3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const z3=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Pr=He("plus",z3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const I3=[["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"}]],Zd=He("refresh-cw",I3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const U3=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],co=He("search",U3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $3=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],B3=He("settings-2",$3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const H3=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],q3=He("sliders-horizontal",H3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const V3=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],jd=He("tag",V3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const F3=[["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"}]],ef=He("trash-2",F3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const G3=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],K3=He("user-round",G3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y3=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],h1=He("user",Y3);/**
* @license lucide-react v0.575.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const W3=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],uo=He("x",W3),lt=v.forwardRef(({className:e,type:t,...n},s)=>f.jsx("input",{type:t,className:xe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...n}));lt.displayName="Input";function be(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function X3(e,t){const n=v.createContext(t),s=l=>{const{children:c,...d}=l,h=v.useMemo(()=>d,Object.values(d));return f.jsx(n.Provider,{value:h,children:c})};s.displayName=e+"Provider";function i(l){const c=v.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${l}\` must be used within \`${e}\``)}return[s,i]}function or(e,t=[]){let n=[];function s(l,c){const d=v.createContext(c),h=n.length;n=[...n,c];const m=g=>{var C;const{scope:x,children:w,...E}=g,S=((C=x==null?void 0:x[e])==null?void 0:C[h])||d,N=v.useMemo(()=>E,Object.values(E));return f.jsx(S.Provider,{value:N,children:w})};m.displayName=l+"Provider";function b(g,x){var S;const w=((S=x==null?void 0:x[e])==null?void 0:S[h])||d,E=v.useContext(w);if(E)return E;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[m,b]}const i=()=>{const l=n.map(c=>v.createContext(c));return function(d){const h=(d==null?void 0:d[e])||l;return v.useMemo(()=>({[`__scope${e}`]:{...d,[e]:h}}),[d,h])}};return i.scopeName=e,[s,J3(i,...t)]}function J3(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(l){const c=s.reduce((d,{useScope:h,scopeName:m})=>{const g=h(l)[`__scope${m}`];return{...d,...g}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var Ft=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},Q3=jg[" useInsertionEffect ".trim().toString()]||Ft;function ma({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[i,l,c]=Z3({defaultProp:t,onChange:n}),d=e!==void 0,h=d?e:i;{const b=v.useRef(e!==void 0);v.useEffect(()=>{const g=b.current;g!==d&&console.warn(`${s} is changing from ${g?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),b.current=d},[d,s])}const m=v.useCallback(b=>{var g;if(d){const x=eL(b)?b(e):b;x!==e&&((g=c.current)==null||g.call(c,x))}else l(b)},[d,e,l,c]);return[h,m]}function Z3({defaultProp:e,onChange:t}){const[n,s]=v.useState(e),i=v.useRef(n),l=v.useRef(t);return Q3(()=>{l.current=t},[t]),v.useEffect(()=>{var c;i.current!==n&&((c=l.current)==null||c.call(l,n),i.current=n)},[n,i]),[n,s,l]}function eL(e){return typeof e=="function"}function tL(e){const t=nL(e),n=v.forwardRef((s,i)=>{const{children:l,...c}=s,d=v.Children.toArray(l),h=d.find(aL);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function nL(e){const t=v.forwardRef((n,s)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=iL(i),d=sL(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rL=Symbol("radix.slottable");function aL(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rL}function sL(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function iL(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var oL=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Le=oL.reduce((e,t)=>{const n=tL(`Primitive.${t}`),s=v.forwardRef((i,l)=>{const{asChild:c,...d}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(h,{...d,ref:l})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function m1(e,t){e&&ec.flushSync(()=>e.dispatchEvent(t))}function Yw(e){const t=lL(e),n=v.forwardRef((s,i)=>{const{children:l,...c}=s,d=v.Children.toArray(l),h=d.find(uL);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function lL(e){const t=v.forwardRef((n,s)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=fL(i),d=dL(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var cL=Symbol("radix.slottable");function uL(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cL}function dL(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function fL(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Kg(e){const t=e+"CollectionProvider",[n,s]=or(t),[i,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=S=>{const{scope:N,children:C}=S,A=ge.useRef(null),T=ge.useRef(new Map).current;return f.jsx(i,{scope:N,itemMap:T,collectionRef:A,children:C})};c.displayName=t;const d=e+"CollectionSlot",h=Yw(d),m=ge.forwardRef((S,N)=>{const{scope:C,children:A}=S,T=l(d,C),M=Je(N,T.collectionRef);return f.jsx(h,{ref:M,children:A})});m.displayName=d;const b=e+"CollectionItemSlot",g="data-radix-collection-item",x=Yw(b),w=ge.forwardRef((S,N)=>{const{scope:C,children:A,...T}=S,M=ge.useRef(null),U=Je(N,M),z=l(b,C);return ge.useEffect(()=>(z.itemMap.set(M,{ref:M,...T}),()=>void z.itemMap.delete(M))),f.jsx(x,{[g]:"",ref:U,children:A})});w.displayName=b;function E(S){const N=l(e+"CollectionConsumer",S);return ge.useCallback(()=>{const A=N.collectionRef.current;if(!A)return[];const T=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(N.itemMap.values()).sort((z,L)=>T.indexOf(z.ref.current)-T.indexOf(L.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:c,Slot:m,ItemSlot:w},E,s]}var hL=v.createContext(void 0);function nc(e){const t=v.useContext(hL);return e||t||"ltr"}function en(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function mL(e,t=globalThis==null?void 0:globalThis.document){const n=en(e);v.useEffect(()=>{const s=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var pL="DismissableLayer",Qp="dismissableLayer.update",gL="dismissableLayer.pointerDownOutside",vL="dismissableLayer.focusOutside",Ww,p1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),rc=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...h}=e,m=v.useContext(p1),[b,g]=v.useState(null),x=(b==null?void 0:b.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=v.useState({}),E=Je(t,L=>g(L)),S=Array.from(m.layers),[N]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),C=S.indexOf(N),A=b?S.indexOf(b):-1,T=m.layersWithOutsidePointerEventsDisabled.size>0,M=A>=C,U=xL(L=>{const B=L.target,q=[...m.branches].some(ue=>ue.contains(B));!M||q||(i==null||i(L),c==null||c(L),L.defaultPrevented||d==null||d())},x),z=wL(L=>{const B=L.target;[...m.branches].some(ue=>ue.contains(B))||(l==null||l(L),c==null||c(L),L.defaultPrevented||d==null||d())},x);return mL(L=>{A===m.layers.size-1&&(s==null||s(L),!L.defaultPrevented&&d&&(L.preventDefault(),d()))},x),v.useEffect(()=>{if(b)return n&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(Ww=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(b)),m.layers.add(b),Xw(),()=>{n&&m.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=Ww)}},[b,x,n,m]),v.useEffect(()=>()=>{b&&(m.layers.delete(b),m.layersWithOutsidePointerEventsDisabled.delete(b),Xw())},[b,m]),v.useEffect(()=>{const L=()=>w({});return document.addEventListener(Qp,L),()=>document.removeEventListener(Qp,L)},[]),f.jsx(Le.div,{...h,ref:E,style:{pointerEvents:T?M?"auto":"none":void 0,...e.style},onFocusCapture:be(e.onFocusCapture,z.onFocusCapture),onBlurCapture:be(e.onBlurCapture,z.onBlurCapture),onPointerDownCapture:be(e.onPointerDownCapture,U.onPointerDownCapture)})});rc.displayName=pL;var yL="DismissableLayerBranch",bL=v.forwardRef((e,t)=>{const n=v.useContext(p1),s=v.useRef(null),i=Je(t,s);return v.useEffect(()=>{const l=s.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),f.jsx(Le.div,{...e,ref:i})});bL.displayName=yL;function xL(e,t=globalThis==null?void 0:globalThis.document){const n=en(e),s=v.useRef(!1),i=v.useRef(()=>{});return v.useEffect(()=>{const l=d=>{if(d.target&&!s.current){let h=function(){g1(gL,n,m,{discrete:!0})};const m={originalEvent:d};d.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=h,t.addEventListener("click",i.current,{once:!0})):h()}else t.removeEventListener("click",i.current);s.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",l),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function wL(e,t=globalThis==null?void 0:globalThis.document){const n=en(e),s=v.useRef(!1);return v.useEffect(()=>{const i=l=>{l.target&&!s.current&&g1(vL,n,{originalEvent:l},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Xw(){const e=new CustomEvent(Qp);document.dispatchEvent(e)}function g1(e,t,n,{discrete:s}){const i=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),s?m1(i,l):i.dispatchEvent(l)}var rp=0;function tf(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Jw()),document.body.insertAdjacentElement("beforeend",e[1]??Jw()),rp++,()=>{rp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),rp--}},[])}function Jw(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ap="focusScope.autoFocusOnMount",sp="focusScope.autoFocusOnUnmount",Qw={bubbles:!1,cancelable:!0},_L="FocusScope",ac=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:i,onUnmountAutoFocus:l,...c}=e,[d,h]=v.useState(null),m=en(i),b=en(l),g=v.useRef(null),x=Je(t,S=>h(S)),w=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(s){let S=function(T){if(w.paused||!d)return;const M=T.target;d.contains(M)?g.current=M:Wa(g.current,{select:!0})},N=function(T){if(w.paused||!d)return;const M=T.relatedTarget;M!==null&&(d.contains(M)||Wa(g.current,{select:!0}))},C=function(T){if(document.activeElement===document.body)for(const U of T)U.removedNodes.length>0&&Wa(d)};document.addEventListener("focusin",S),document.addEventListener("focusout",N);const A=new MutationObserver(C);return d&&A.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",S),document.removeEventListener("focusout",N),A.disconnect()}}},[s,d,w.paused]),v.useEffect(()=>{if(d){e_.add(w);const S=document.activeElement;if(!d.contains(S)){const C=new CustomEvent(ap,Qw);d.addEventListener(ap,m),d.dispatchEvent(C),C.defaultPrevented||(SL(TL(v1(d)),{select:!0}),document.activeElement===S&&Wa(d))}return()=>{d.removeEventListener(ap,m),setTimeout(()=>{const C=new CustomEvent(sp,Qw);d.addEventListener(sp,b),d.dispatchEvent(C),C.defaultPrevented||Wa(S??document.body,{select:!0}),d.removeEventListener(sp,b),e_.remove(w)},0)}}},[d,m,b,w]);const E=v.useCallback(S=>{if(!n&&!s||w.paused)return;const N=S.key==="Tab"&&!S.altKey&&!S.ctrlKey&&!S.metaKey,C=document.activeElement;if(N&&C){const A=S.currentTarget,[T,M]=EL(A);T&&M?!S.shiftKey&&C===M?(S.preventDefault(),n&&Wa(T,{select:!0})):S.shiftKey&&C===T&&(S.preventDefault(),n&&Wa(M,{select:!0})):C===A&&S.preventDefault()}},[n,s,w.paused]);return f.jsx(Le.div,{tabIndex:-1,...c,ref:x,onKeyDown:E})});ac.displayName=_L;function SL(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Wa(s,{select:t}),document.activeElement!==n)return}function EL(e){const t=v1(e),n=Zw(t,e),s=Zw(t.reverse(),e);return[n,s]}function v1(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const i=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||i?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zw(e,t){for(const n of e)if(!CL(n,{upTo:t}))return n}function CL(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function NL(e){return e instanceof HTMLInputElement&&"select"in e}function Wa(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&NL(e)&&t&&e.select()}}var e_=jL();function jL(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=t_(e,t),e.unshift(t)},remove(t){var n;e=t_(e,t),(n=e[0])==null||n.resume()}}}function t_(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function TL(e){return e.filter(t=>t.tagName!=="A")}var AL=jg[" useId ".trim().toString()]||(()=>{}),RL=0;function un(e){const[t,n]=v.useState(AL());return Ft(()=>{n(s=>s??String(RL++))},[e]),t?`radix-${t}`:""}const kL=["top","right","bottom","left"],rs=Math.min,Vn=Math.max,Td=Math.round,zu=Math.floor,zr=e=>({x:e,y:e}),OL={left:"right",right:"left",bottom:"top",top:"bottom"};function Zp(e,t,n){return Vn(e,rs(t,n))}function pa(e,t){return typeof e=="function"?e(t):e}function ga(e){return e.split("-")[0]}function wo(e){return e.split("-")[1]}function Yg(e){return e==="x"?"y":"x"}function Wg(e){return e==="y"?"height":"width"}function Lr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Xg(e){return Yg(Lr(e))}function ML(e,t,n){n===void 0&&(n=!1);const s=wo(e),i=Xg(e),l=Wg(i);let c=i==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=Ad(c)),[c,Ad(c)]}function DL(e){const t=Ad(e);return[eg(e),t,eg(t)]}function eg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const n_=["left","right"],r_=["right","left"],LL=["top","bottom"],PL=["bottom","top"];function zL(e,t,n){switch(e){case"top":case"bottom":return n?t?r_:n_:t?n_:r_;case"left":case"right":return t?LL:PL;default:return[]}}function IL(e,t,n,s){const i=wo(e);let l=zL(ga(e),n==="start",s);return i&&(l=l.map(c=>c+"-"+i),t&&(l=l.concat(l.map(eg)))),l}function Ad(e){const t=ga(e);return OL[t]+e.slice(t.length)}function UL(e){return{top:0,right:0,bottom:0,left:0,...e}}function y1(e){return typeof e!="number"?UL(e):{top:e,right:e,bottom:e,left:e}}function Rd(e){const{x:t,y:n,width:s,height:i}=e;return{width:s,height:i,top:n,left:t,right:t+s,bottom:n+i,x:t,y:n}}function a_(e,t,n){let{reference:s,floating:i}=e;const l=Lr(t),c=Xg(t),d=Wg(c),h=ga(t),m=l==="y",b=s.x+s.width/2-i.width/2,g=s.y+s.height/2-i.height/2,x=s[d]/2-i[d]/2;let w;switch(h){case"top":w={x:b,y:s.y-i.height};break;case"bottom":w={x:b,y:s.y+s.height};break;case"right":w={x:s.x+s.width,y:g};break;case"left":w={x:s.x-i.width,y:g};break;default:w={x:s.x,y:s.y}}switch(wo(t)){case"start":w[c]-=x*(n&&m?-1:1);break;case"end":w[c]+=x*(n&&m?-1:1);break}return w}async function $L(e,t){var n;t===void 0&&(t={});const{x:s,y:i,platform:l,rects:c,elements:d,strategy:h}=e,{boundary:m="clippingAncestors",rootBoundary:b="viewport",elementContext:g="floating",altBoundary:x=!1,padding:w=0}=pa(t,e),E=y1(w),N=d[x?g==="floating"?"reference":"floating":g],C=Rd(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(N)))==null||n?N:N.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(d.floating)),boundary:m,rootBoundary:b,strategy:h})),A=g==="floating"?{x:s,y:i,width:c.floating.width,height:c.floating.height}:c.reference,T=await(l.getOffsetParent==null?void 0:l.getOffsetParent(d.floating)),M=await(l.isElement==null?void 0:l.isElement(T))?await(l.getScale==null?void 0:l.getScale(T))||{x:1,y:1}:{x:1,y:1},U=Rd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:A,offsetParent:T,strategy:h}):A);return{top:(C.top-U.top+E.top)/M.y,bottom:(U.bottom-C.bottom+E.bottom)/M.y,left:(C.left-U.left+E.left)/M.x,right:(U.right-C.right+E.right)/M.x}}const BL=50,HL=async(e,t,n)=>{const{placement:s="bottom",strategy:i="absolute",middleware:l=[],platform:c}=n,d=c.detectOverflow?c:{...c,detectOverflow:$L},h=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:i}),{x:b,y:g}=a_(m,s,h),x=s,w=0;const E={};for(let S=0;S<l.length;S++){const N=l[S];if(!N)continue;const{name:C,fn:A}=N,{x:T,y:M,data:U,reset:z}=await A({x:b,y:g,initialPlacement:s,placement:x,strategy:i,middlewareData:E,rects:m,platform:d,elements:{reference:e,floating:t}});b=T??b,g=M??g,E[C]={...E[C],...U},z&&w<BL&&(w++,typeof z=="object"&&(z.placement&&(x=z.placement),z.rects&&(m=z.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:i}):z.rects),{x:b,y:g}=a_(m,x,h)),S=-1)}return{x:b,y:g,placement:x,strategy:i,middlewareData:E}},qL=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:i,rects:l,platform:c,elements:d,middlewareData:h}=t,{element:m,padding:b=0}=pa(e,t)||{};if(m==null)return{};const g=y1(b),x={x:n,y:s},w=Xg(i),E=Wg(w),S=await c.getDimensions(m),N=w==="y",C=N?"top":"left",A=N?"bottom":"right",T=N?"clientHeight":"clientWidth",M=l.reference[E]+l.reference[w]-x[w]-l.floating[E],U=x[w]-l.reference[w],z=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let L=z?z[T]:0;(!L||!await(c.isElement==null?void 0:c.isElement(z)))&&(L=d.floating[T]||l.floating[E]);const B=M/2-U/2,q=L/2-S[E]/2-1,ue=rs(g[C],q),le=rs(g[A],q),he=ue,de=L-S[E]-le,ve=L/2-S[E]/2+B,pe=Zp(he,ve,de),O=!h.arrow&&wo(i)!=null&&ve!==pe&&l.reference[E]/2-(ve<he?ue:le)-S[E]/2<0,K=O?ve<he?ve-he:ve-de:0;return{[w]:x[w]+K,data:{[w]:pe,centerOffset:ve-pe-K,...O&&{alignmentOffset:K}},reset:O}}}),VL=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:i,middlewareData:l,rects:c,initialPlacement:d,platform:h,elements:m}=t,{mainAxis:b=!0,crossAxis:g=!0,fallbackPlacements:x,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:S=!0,...N}=pa(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const C=ga(i),A=Lr(d),T=ga(d)===d,M=await(h.isRTL==null?void 0:h.isRTL(m.floating)),U=x||(T||!S?[Ad(d)]:DL(d)),z=E!=="none";!x&&z&&U.push(...IL(d,S,E,M));const L=[d,...U],B=await h.detectOverflow(t,N),q=[];let ue=((s=l.flip)==null?void 0:s.overflows)||[];if(b&&q.push(B[C]),g){const ve=ML(i,c,M);q.push(B[ve[0]],B[ve[1]])}if(ue=[...ue,{placement:i,overflows:q}],!q.every(ve=>ve<=0)){var le,he;const ve=(((le=l.flip)==null?void 0:le.index)||0)+1,pe=L[ve];if(pe&&(!(g==="alignment"?A!==Lr(pe):!1)||ue.every(W=>Lr(W.placement)===A?W.overflows[0]>0:!0)))return{data:{index:ve,overflows:ue},reset:{placement:pe}};let O=(he=ue.filter(K=>K.overflows[0]<=0).sort((K,W)=>K.overflows[1]-W.overflows[1])[0])==null?void 0:he.placement;if(!O)switch(w){case"bestFit":{var de;const K=(de=ue.filter(W=>{if(z){const J=Lr(W.placement);return J===A||J==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(J=>J>0).reduce((J,V)=>J+V,0)]).sort((W,J)=>W[1]-J[1])[0])==null?void 0:de[0];K&&(O=K);break}case"initialPlacement":O=d;break}if(i!==O)return{reset:{placement:O}}}return{}}}};function s_(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function i_(e){return kL.some(t=>e[t]>=0)}const FL=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:i="referenceHidden",...l}=pa(e,t);switch(i){case"referenceHidden":{const c=await s.detectOverflow(t,{...l,elementContext:"reference"}),d=s_(c,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:i_(d)}}}case"escaped":{const c=await s.detectOverflow(t,{...l,altBoundary:!0}),d=s_(c,n.floating);return{data:{escapedOffsets:d,escaped:i_(d)}}}default:return{}}}}},b1=new Set(["left","top"]);async function GL(e,t){const{placement:n,platform:s,elements:i}=e,l=await(s.isRTL==null?void 0:s.isRTL(i.floating)),c=ga(n),d=wo(n),h=Lr(n)==="y",m=b1.has(c)?-1:1,b=l&&h?-1:1,g=pa(t,e);let{mainAxis:x,crossAxis:w,alignmentAxis:E}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return d&&typeof E=="number"&&(w=d==="end"?E*-1:E),h?{x:w*b,y:x*m}:{x:x*m,y:w*b}}const KL=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:i,y:l,placement:c,middlewareData:d}=t,h=await GL(t,e);return c===((n=d.offset)==null?void 0:n.placement)&&(s=d.arrow)!=null&&s.alignmentOffset?{}:{x:i+h.x,y:l+h.y,data:{...h,placement:c}}}}},YL=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:i,platform:l}=t,{mainAxis:c=!0,crossAxis:d=!1,limiter:h={fn:C=>{let{x:A,y:T}=C;return{x:A,y:T}}},...m}=pa(e,t),b={x:n,y:s},g=await l.detectOverflow(t,m),x=Lr(ga(i)),w=Yg(x);let E=b[w],S=b[x];if(c){const C=w==="y"?"top":"left",A=w==="y"?"bottom":"right",T=E+g[C],M=E-g[A];E=Zp(T,E,M)}if(d){const C=x==="y"?"top":"left",A=x==="y"?"bottom":"right",T=S+g[C],M=S-g[A];S=Zp(T,S,M)}const N=h.fn({...t,[w]:E,[x]:S});return{...N,data:{x:N.x-n,y:N.y-s,enabled:{[w]:c,[x]:d}}}}}},WL=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:i,rects:l,middlewareData:c}=t,{offset:d=0,mainAxis:h=!0,crossAxis:m=!0}=pa(e,t),b={x:n,y:s},g=Lr(i),x=Yg(g);let w=b[x],E=b[g];const S=pa(d,t),N=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(h){const T=x==="y"?"height":"width",M=l.reference[x]-l.floating[T]+N.mainAxis,U=l.reference[x]+l.reference[T]-N.mainAxis;w<M?w=M:w>U&&(w=U)}if(m){var C,A;const T=x==="y"?"width":"height",M=b1.has(ga(i)),U=l.reference[g]-l.floating[T]+(M&&((C=c.offset)==null?void 0:C[g])||0)+(M?0:N.crossAxis),z=l.reference[g]+l.reference[T]+(M?0:((A=c.offset)==null?void 0:A[g])||0)-(M?N.crossAxis:0);E<U?E=U:E>z&&(E=z)}return{[x]:w,[g]:E}}}},XL=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:i,rects:l,platform:c,elements:d}=t,{apply:h=()=>{},...m}=pa(e,t),b=await c.detectOverflow(t,m),g=ga(i),x=wo(i),w=Lr(i)==="y",{width:E,height:S}=l.floating;let N,C;g==="top"||g==="bottom"?(N=g,C=x===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(C=g,N=x==="end"?"top":"bottom");const A=S-b.top-b.bottom,T=E-b.left-b.right,M=rs(S-b[N],A),U=rs(E-b[C],T),z=!t.middlewareData.shift;let L=M,B=U;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(B=T),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(L=A),z&&!x){const ue=Vn(b.left,0),le=Vn(b.right,0),he=Vn(b.top,0),de=Vn(b.bottom,0);w?B=E-2*(ue!==0||le!==0?ue+le:Vn(b.left,b.right)):L=S-2*(he!==0||de!==0?he+de:Vn(b.top,b.bottom))}await h({...t,availableWidth:B,availableHeight:L});const q=await c.getDimensions(d.floating);return E!==q.width||S!==q.height?{reset:{rects:!0}}:{}}}};function nf(){return typeof window<"u"}function _o(e){return x1(e)?(e.nodeName||"").toLowerCase():"#document"}function Gn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Br(e){var t;return(t=(x1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function x1(e){return nf()?e instanceof Node||e instanceof Gn(e).Node:!1}function _r(e){return nf()?e instanceof Element||e instanceof Gn(e).Element:!1}function wa(e){return nf()?e instanceof HTMLElement||e instanceof Gn(e).HTMLElement:!1}function o_(e){return!nf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Gn(e).ShadowRoot}function sc(e){const{overflow:t,overflowX:n,overflowY:s,display:i}=Sr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&i!=="inline"&&i!=="contents"}function JL(e){return/^(table|td|th)$/.test(_o(e))}function rf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const QL=/transform|translate|scale|rotate|perspective|filter/,ZL=/paint|layout|strict|content/,ks=e=>!!e&&e!=="none";let ip;function Jg(e){const t=_r(e)?Sr(e):e;return ks(t.transform)||ks(t.translate)||ks(t.scale)||ks(t.rotate)||ks(t.perspective)||!Qg()&&(ks(t.backdropFilter)||ks(t.filter))||QL.test(t.willChange||"")||ZL.test(t.contain||"")}function eP(e){let t=as(e);for(;wa(t)&&!fo(t);){if(Jg(t))return t;if(rf(t))return null;t=as(t)}return null}function Qg(){return ip==null&&(ip=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ip}function fo(e){return/^(html|body|#document)$/.test(_o(e))}function Sr(e){return Gn(e).getComputedStyle(e)}function af(e){return _r(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function as(e){if(_o(e)==="html")return e;const t=e.assignedSlot||e.parentNode||o_(e)&&e.host||Br(e);return o_(t)?t.host:t}function w1(e){const t=as(e);return fo(t)?e.ownerDocument?e.ownerDocument.body:e.body:wa(t)&&sc(t)?t:w1(t)}function Vl(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=w1(e),l=i===((s=e.ownerDocument)==null?void 0:s.body),c=Gn(i);if(l){const d=tg(c);return t.concat(c,c.visualViewport||[],sc(i)?i:[],d&&n?Vl(d):[])}else return t.concat(i,Vl(i,[],n))}function tg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _1(e){const t=Sr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=wa(e),l=i?e.offsetWidth:n,c=i?e.offsetHeight:s,d=Td(n)!==l||Td(s)!==c;return d&&(n=l,s=c),{width:n,height:s,$:d}}function Zg(e){return _r(e)?e:e.contextElement}function ao(e){const t=Zg(e);if(!wa(t))return zr(1);const n=t.getBoundingClientRect(),{width:s,height:i,$:l}=_1(t);let c=(l?Td(n.width):n.width)/s,d=(l?Td(n.height):n.height)/i;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const tP=zr(0);function S1(e){const t=Gn(e);return!Qg()||!t.visualViewport?tP:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function nP(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Gn(e)?!1:t}function Bs(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),l=Zg(e);let c=zr(1);t&&(s?_r(s)&&(c=ao(s)):c=ao(e));const d=nP(l,n,s)?S1(l):zr(0);let h=(i.left+d.x)/c.x,m=(i.top+d.y)/c.y,b=i.width/c.x,g=i.height/c.y;if(l){const x=Gn(l),w=s&&_r(s)?Gn(s):s;let E=x,S=tg(E);for(;S&&s&&w!==E;){const N=ao(S),C=S.getBoundingClientRect(),A=Sr(S),T=C.left+(S.clientLeft+parseFloat(A.paddingLeft))*N.x,M=C.top+(S.clientTop+parseFloat(A.paddingTop))*N.y;h*=N.x,m*=N.y,b*=N.x,g*=N.y,h+=T,m+=M,E=Gn(S),S=tg(E)}}return Rd({width:b,height:g,x:h,y:m})}function sf(e,t){const n=af(e).scrollLeft;return t?t.left+n:Bs(Br(e)).left+n}function E1(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-sf(e,n),i=n.top+t.scrollTop;return{x:s,y:i}}function rP(e){let{elements:t,rect:n,offsetParent:s,strategy:i}=e;const l=i==="fixed",c=Br(s),d=t?rf(t.floating):!1;if(s===c||d&&l)return n;let h={scrollLeft:0,scrollTop:0},m=zr(1);const b=zr(0),g=wa(s);if((g||!g&&!l)&&((_o(s)!=="body"||sc(c))&&(h=af(s)),g)){const w=Bs(s);m=ao(s),b.x=w.x+s.clientLeft,b.y=w.y+s.clientTop}const x=c&&!g&&!l?E1(c,h):zr(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-h.scrollLeft*m.x+b.x+x.x,y:n.y*m.y-h.scrollTop*m.y+b.y+x.y}}function aP(e){return Array.from(e.getClientRects())}function sP(e){const t=Br(e),n=af(e),s=e.ownerDocument.body,i=Vn(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=Vn(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+sf(e);const d=-n.scrollTop;return Sr(s).direction==="rtl"&&(c+=Vn(t.clientWidth,s.clientWidth)-i),{width:i,height:l,x:c,y:d}}const l_=25;function iP(e,t){const n=Gn(e),s=Br(e),i=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,d=0,h=0;if(i){l=i.width,c=i.height;const b=Qg();(!b||b&&t==="fixed")&&(d=i.offsetLeft,h=i.offsetTop)}const m=sf(s);if(m<=0){const b=s.ownerDocument,g=b.body,x=getComputedStyle(g),w=b.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,E=Math.abs(s.clientWidth-g.clientWidth-w);E<=l_&&(l-=E)}else m<=l_&&(l+=m);return{width:l,height:c,x:d,y:h}}function oP(e,t){const n=Bs(e,!0,t==="fixed"),s=n.top+e.clientTop,i=n.left+e.clientLeft,l=wa(e)?ao(e):zr(1),c=e.clientWidth*l.x,d=e.clientHeight*l.y,h=i*l.x,m=s*l.y;return{width:c,height:d,x:h,y:m}}function c_(e,t,n){let s;if(t==="viewport")s=iP(e,n);else if(t==="document")s=sP(Br(e));else if(_r(t))s=oP(t,n);else{const i=S1(e);s={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Rd(s)}function C1(e,t){const n=as(e);return n===t||!_r(n)||fo(n)?!1:Sr(n).position==="fixed"||C1(n,t)}function lP(e,t){const n=t.get(e);if(n)return n;let s=Vl(e,[],!1).filter(d=>_r(d)&&_o(d)!=="body"),i=null;const l=Sr(e).position==="fixed";let c=l?as(e):e;for(;_r(c)&&!fo(c);){const d=Sr(c),h=Jg(c);!h&&d.position==="fixed"&&(i=null),(l?!h&&!i:!h&&d.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||sc(c)&&!h&&C1(e,c))?s=s.filter(b=>b!==c):i=d,c=as(c)}return t.set(e,s),s}function cP(e){let{element:t,boundary:n,rootBoundary:s,strategy:i}=e;const c=[...n==="clippingAncestors"?rf(t)?[]:lP(t,this._c):[].concat(n),s],d=c_(t,c[0],i);let h=d.top,m=d.right,b=d.bottom,g=d.left;for(let x=1;x<c.length;x++){const w=c_(t,c[x],i);h=Vn(w.top,h),m=rs(w.right,m),b=rs(w.bottom,b),g=Vn(w.left,g)}return{width:m-g,height:b-h,x:g,y:h}}function uP(e){const{width:t,height:n}=_1(e);return{width:t,height:n}}function dP(e,t,n){const s=wa(t),i=Br(t),l=n==="fixed",c=Bs(e,!0,l,t);let d={scrollLeft:0,scrollTop:0};const h=zr(0);function m(){h.x=sf(i)}if(s||!s&&!l)if((_o(t)!=="body"||sc(i))&&(d=af(t)),s){const w=Bs(t,!0,l,t);h.x=w.x+t.clientLeft,h.y=w.y+t.clientTop}else i&&m();l&&!s&&i&&m();const b=i&&!s&&!l?E1(i,d):zr(0),g=c.left+d.scrollLeft-h.x-b.x,x=c.top+d.scrollTop-h.y-b.y;return{x:g,y:x,width:c.width,height:c.height}}function op(e){return Sr(e).position==="static"}function u_(e,t){if(!wa(e)||Sr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Br(e)===n&&(n=n.ownerDocument.body),n}function N1(e,t){const n=Gn(e);if(rf(e))return n;if(!wa(e)){let i=as(e);for(;i&&!fo(i);){if(_r(i)&&!op(i))return i;i=as(i)}return n}let s=u_(e,t);for(;s&&JL(s)&&op(s);)s=u_(s,t);return s&&fo(s)&&op(s)&&!Jg(s)?n:s||eP(e)||n}const fP=async function(e){const t=this.getOffsetParent||N1,n=this.getDimensions,s=await n(e.floating);return{reference:dP(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function hP(e){return Sr(e).direction==="rtl"}const mP={convertOffsetParentRelativeRectToViewportRelativeRect:rP,getDocumentElement:Br,getClippingRect:cP,getOffsetParent:N1,getElementRects:fP,getClientRects:aP,getDimensions:uP,getScale:ao,isElement:_r,isRTL:hP};function j1(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function pP(e,t){let n=null,s;const i=Br(e);function l(){var d;clearTimeout(s),(d=n)==null||d.disconnect(),n=null}function c(d,h){d===void 0&&(d=!1),h===void 0&&(h=1),l();const m=e.getBoundingClientRect(),{left:b,top:g,width:x,height:w}=m;if(d||t(),!x||!w)return;const E=zu(g),S=zu(i.clientWidth-(b+x)),N=zu(i.clientHeight-(g+w)),C=zu(b),T={rootMargin:-E+"px "+-S+"px "+-N+"px "+-C+"px",threshold:Vn(0,rs(1,h))||1};let M=!0;function U(z){const L=z[0].intersectionRatio;if(L!==h){if(!M)return c();L?c(!1,L):s=setTimeout(()=>{c(!1,1e-7)},1e3)}L===1&&!j1(m,e.getBoundingClientRect())&&c(),M=!1}try{n=new IntersectionObserver(U,{...T,root:i.ownerDocument})}catch{n=new IntersectionObserver(U,T)}n.observe(e)}return c(!0),l}function gP(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:h=!1}=s,m=Zg(e),b=i||l?[...m?Vl(m):[],...t?Vl(t):[]]:[];b.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),l&&C.addEventListener("resize",n)});const g=m&&d?pP(m,n):null;let x=-1,w=null;c&&(w=new ResizeObserver(C=>{let[A]=C;A&&A.target===m&&w&&t&&(w.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var T;(T=w)==null||T.observe(t)})),n()}),m&&!h&&w.observe(m),t&&w.observe(t));let E,S=h?Bs(e):null;h&&N();function N(){const C=Bs(e);S&&!j1(S,C)&&n(),S=C,E=requestAnimationFrame(N)}return n(),()=>{var C;b.forEach(A=>{i&&A.removeEventListener("scroll",n),l&&A.removeEventListener("resize",n)}),g==null||g(),(C=w)==null||C.disconnect(),w=null,h&&cancelAnimationFrame(E)}}const vP=KL,yP=YL,bP=VL,xP=XL,wP=FL,d_=qL,_P=WL,SP=(e,t,n)=>{const s=new Map,i={platform:mP,...n},l={...i.platform,_c:s};return HL(e,t,{...i,platform:l})};var EP=typeof document<"u",CP=function(){},sd=EP?v.useLayoutEffect:CP;function kd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!kd(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){const l=i[s];if(!(l==="_owner"&&e.$$typeof)&&!kd(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function T1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function f_(e,t){const n=T1(e);return Math.round(t*n)/n}function lp(e){const t=v.useRef(e);return sd(()=>{t.current=e}),t}function NP(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:i,elements:{reference:l,floating:c}={},transform:d=!0,whileElementsMounted:h,open:m}=e,[b,g]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[x,w]=v.useState(s);kd(x,s)||w(s);const[E,S]=v.useState(null),[N,C]=v.useState(null),A=v.useCallback(W=>{W!==z.current&&(z.current=W,S(W))},[]),T=v.useCallback(W=>{W!==L.current&&(L.current=W,C(W))},[]),M=l||E,U=c||N,z=v.useRef(null),L=v.useRef(null),B=v.useRef(b),q=h!=null,ue=lp(h),le=lp(i),he=lp(m),de=v.useCallback(()=>{if(!z.current||!L.current)return;const W={placement:t,strategy:n,middleware:x};le.current&&(W.platform=le.current),SP(z.current,L.current,W).then(J=>{const V={...J,isPositioned:he.current!==!1};ve.current&&!kd(B.current,V)&&(B.current=V,ec.flushSync(()=>{g(V)}))})},[x,t,n,le,he]);sd(()=>{m===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,g(W=>({...W,isPositioned:!1})))},[m]);const ve=v.useRef(!1);sd(()=>(ve.current=!0,()=>{ve.current=!1}),[]),sd(()=>{if(M&&(z.current=M),U&&(L.current=U),M&&U){if(ue.current)return ue.current(M,U,de);de()}},[M,U,de,ue,q]);const pe=v.useMemo(()=>({reference:z,floating:L,setReference:A,setFloating:T}),[A,T]),O=v.useMemo(()=>({reference:M,floating:U}),[M,U]),K=v.useMemo(()=>{const W={position:n,left:0,top:0};if(!O.floating)return W;const J=f_(O.floating,b.x),V=f_(O.floating,b.y);return d?{...W,transform:"translate("+J+"px, "+V+"px)",...T1(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:J,top:V}},[n,d,O.floating,b.x,b.y]);return v.useMemo(()=>({...b,update:de,refs:pe,elements:O,floatingStyles:K}),[b,de,pe,O,K])}const jP=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:i}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?d_({element:s.current,padding:i}).fn(n):{}:s?d_({element:s,padding:i}).fn(n):{}}}},TP=(e,t)=>{const n=vP(e);return{name:n.name,fn:n.fn,options:[e,t]}},AP=(e,t)=>{const n=yP(e);return{name:n.name,fn:n.fn,options:[e,t]}},RP=(e,t)=>({fn:_P(e).fn,options:[e,t]}),kP=(e,t)=>{const n=bP(e);return{name:n.name,fn:n.fn,options:[e,t]}},OP=(e,t)=>{const n=xP(e);return{name:n.name,fn:n.fn,options:[e,t]}},MP=(e,t)=>{const n=wP(e);return{name:n.name,fn:n.fn,options:[e,t]}},DP=(e,t)=>{const n=jP(e);return{name:n.name,fn:n.fn,options:[e,t]}};var LP="Arrow",A1=v.forwardRef((e,t)=>{const{children:n,width:s=10,height:i=5,...l}=e;return f.jsx(Le.svg,{...l,ref:t,width:s,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});A1.displayName=LP;var PP=A1;function ev(e){const[t,n]=v.useState(void 0);return Ft(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const l=i[0];let c,d;if("borderBoxSize"in l){const h=l.borderBoxSize,m=Array.isArray(h)?h[0]:h;c=m.inlineSize,d=m.blockSize}else c=e.offsetWidth,d=e.offsetHeight;n({width:c,height:d})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var tv="Popper",[R1,So]=or(tv),[zP,k1]=R1(tv),O1=e=>{const{__scopePopper:t,children:n}=e,[s,i]=v.useState(null);return f.jsx(zP,{scope:t,anchor:s,onAnchorChange:i,children:n})};O1.displayName=tv;var M1="PopperAnchor",D1=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...i}=e,l=k1(M1,n),c=v.useRef(null),d=Je(t,c),h=v.useRef(null);return v.useEffect(()=>{const m=h.current;h.current=(s==null?void 0:s.current)||c.current,m!==h.current&&l.onAnchorChange(h.current)}),s?null:f.jsx(Le.div,{...i,ref:d})});D1.displayName=M1;var nv="PopperContent",[IP,UP]=R1(nv),L1=v.forwardRef((e,t)=>{var ee,Q,re,Ne,ze,Oe;const{__scopePopper:n,side:s="bottom",sideOffset:i=0,align:l="center",alignOffset:c=0,arrowPadding:d=0,avoidCollisions:h=!0,collisionBoundary:m=[],collisionPadding:b=0,sticky:g="partial",hideWhenDetached:x=!1,updatePositionStrategy:w="optimized",onPlaced:E,...S}=e,N=k1(nv,n),[C,A]=v.useState(null),T=Je(t,Qe=>A(Qe)),[M,U]=v.useState(null),z=ev(M),L=(z==null?void 0:z.width)??0,B=(z==null?void 0:z.height)??0,q=s+(l!=="center"?"-"+l:""),ue=typeof b=="number"?b:{top:0,right:0,bottom:0,left:0,...b},le=Array.isArray(m)?m:[m],he=le.length>0,de={padding:ue,boundary:le.filter(BP),altBoundary:he},{refs:ve,floatingStyles:pe,placement:O,isPositioned:K,middlewareData:W}=NP({strategy:"fixed",placement:q,whileElementsMounted:(...Qe)=>gP(...Qe,{animationFrame:w==="always"}),elements:{reference:N.anchor},middleware:[TP({mainAxis:i+B,alignmentAxis:c}),h&&AP({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?RP():void 0,...de}),h&&kP({...de}),OP({...de,apply:({elements:Qe,rects:Ze,availableWidth:vt,availableHeight:oe})=>{const{width:se,height:Re}=Ze.reference,De=Qe.floating.style;De.setProperty("--radix-popper-available-width",`${vt}px`),De.setProperty("--radix-popper-available-height",`${oe}px`),De.setProperty("--radix-popper-anchor-width",`${se}px`),De.setProperty("--radix-popper-anchor-height",`${Re}px`)}}),M&&DP({element:M,padding:d}),HP({arrowWidth:L,arrowHeight:B}),x&&MP({strategy:"referenceHidden",...de})]}),[J,V]=I1(O),R=en(E);Ft(()=>{K&&(R==null||R())},[K,R]);const k=(ee=W.arrow)==null?void 0:ee.x,I=(Q=W.arrow)==null?void 0:Q.y,X=((re=W.arrow)==null?void 0:re.centerOffset)!==0,[H,te]=v.useState();return Ft(()=>{C&&te(window.getComputedStyle(C).zIndex)},[C]),f.jsx("div",{ref:ve.setFloating,"data-radix-popper-content-wrapper":"",style:{...pe,transform:K?pe.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(Ne=W.transformOrigin)==null?void 0:Ne.x,(ze=W.transformOrigin)==null?void 0:ze.y].join(" "),...((Oe=W.hide)==null?void 0:Oe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(IP,{scope:n,placedSide:J,onArrowChange:U,arrowX:k,arrowY:I,shouldHideArrow:X,children:f.jsx(Le.div,{"data-side":J,"data-align":V,...S,ref:T,style:{...S.style,animation:K?void 0:"none"}})})})});L1.displayName=nv;var P1="PopperArrow",$P={top:"bottom",right:"left",bottom:"top",left:"right"},z1=v.forwardRef(function(t,n){const{__scopePopper:s,...i}=t,l=UP(P1,s),c=$P[l.placedSide];return f.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:f.jsx(PP,{...i,ref:n,style:{...i.style,display:"block"}})})});z1.displayName=P1;function BP(e){return e!==null}var HP=e=>({name:"transformOrigin",options:e,fn(t){var N,C,A;const{placement:n,rects:s,middlewareData:i}=t,c=((N=i.arrow)==null?void 0:N.centerOffset)!==0,d=c?0:e.arrowWidth,h=c?0:e.arrowHeight,[m,b]=I1(n),g={start:"0%",center:"50%",end:"100%"}[b],x=(((C=i.arrow)==null?void 0:C.x)??0)+d/2,w=(((A=i.arrow)==null?void 0:A.y)??0)+h/2;let E="",S="";return m==="bottom"?(E=c?g:`${x}px`,S=`${-h}px`):m==="top"?(E=c?g:`${x}px`,S=`${s.floating.height+h}px`):m==="right"?(E=`${-h}px`,S=c?g:`${w}px`):m==="left"&&(E=`${s.floating.width+h}px`,S=c?g:`${w}px`),{data:{x:E,y:S}}}});function I1(e){const[t,n="center"]=e.split("-");return[t,n]}var rv=O1,of=D1,av=L1,sv=z1,qP="Portal",ic=v.forwardRef((e,t)=>{var d;const{container:n,...s}=e,[i,l]=v.useState(!1);Ft(()=>l(!0),[]);const c=n||i&&((d=globalThis==null?void 0:globalThis.document)==null?void 0:d.body);return c?xS.createPortal(f.jsx(Le.div,{...s,ref:t}),c):null});ic.displayName=qP;function VP(e,t){return v.useReducer((n,s)=>t[n][s]??n,e)}var pn=e=>{const{present:t,children:n}=e,s=FP(t),i=typeof n=="function"?n({present:s.isPresent}):v.Children.only(n),l=Je(s.ref,GP(i));return typeof n=="function"||s.isPresent?v.cloneElement(i,{ref:l}):null};pn.displayName="Presence";function FP(e){const[t,n]=v.useState(),s=v.useRef(null),i=v.useRef(e),l=v.useRef("none"),c=e?"mounted":"unmounted",[d,h]=VP(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const m=Iu(s.current);l.current=d==="mounted"?m:"none"},[d]),Ft(()=>{const m=s.current,b=i.current;if(b!==e){const x=l.current,w=Iu(m);e?h("MOUNT"):w==="none"||(m==null?void 0:m.display)==="none"?h("UNMOUNT"):h(b&&x!==w?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,h]),Ft(()=>{if(t){let m;const b=t.ownerDocument.defaultView??window,g=w=>{const S=Iu(s.current).includes(CSS.escape(w.animationName));if(w.target===t&&S&&(h("ANIMATION_END"),!i.current)){const N=t.style.animationFillMode;t.style.animationFillMode="forwards",m=b.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=N)})}},x=w=>{w.target===t&&(l.current=Iu(s.current))};return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{b.clearTimeout(m),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:v.useCallback(m=>{s.current=m?getComputedStyle(m):null,n(m)},[])}}function Iu(e){return(e==null?void 0:e.animationName)||"none"}function GP(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var cp="rovingFocusGroup.onEntryFocus",KP={bubbles:!1,cancelable:!0},oc="RovingFocusGroup",[ng,U1,YP]=Kg(oc),[WP,lf]=or(oc,[YP]),[XP,JP]=WP(oc),$1=v.forwardRef((e,t)=>f.jsx(ng.Provider,{scope:e.__scopeRovingFocusGroup,children:f.jsx(ng.Slot,{scope:e.__scopeRovingFocusGroup,children:f.jsx(QP,{...e,ref:t})})}));$1.displayName=oc;var QP=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:i=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:h,onEntryFocus:m,preventScrollOnEntryFocus:b=!1,...g}=e,x=v.useRef(null),w=Je(t,x),E=nc(l),[S,N]=ma({prop:c,defaultProp:d??null,onChange:h,caller:oc}),[C,A]=v.useState(!1),T=en(m),M=U1(n),U=v.useRef(!1),[z,L]=v.useState(0);return v.useEffect(()=>{const B=x.current;if(B)return B.addEventListener(cp,T),()=>B.removeEventListener(cp,T)},[T]),f.jsx(XP,{scope:n,orientation:s,dir:E,loop:i,currentTabStopId:S,onItemFocus:v.useCallback(B=>N(B),[N]),onItemShiftTab:v.useCallback(()=>A(!0),[]),onFocusableItemAdd:v.useCallback(()=>L(B=>B+1),[]),onFocusableItemRemove:v.useCallback(()=>L(B=>B-1),[]),children:f.jsx(Le.div,{tabIndex:C||z===0?-1:0,"data-orientation":s,...g,ref:w,style:{outline:"none",...e.style},onMouseDown:be(e.onMouseDown,()=>{U.current=!0}),onFocus:be(e.onFocus,B=>{const q=!U.current;if(B.target===B.currentTarget&&q&&!C){const ue=new CustomEvent(cp,KP);if(B.currentTarget.dispatchEvent(ue),!ue.defaultPrevented){const le=M().filter(O=>O.focusable),he=le.find(O=>O.active),de=le.find(O=>O.id===S),pe=[he,de,...le].filter(Boolean).map(O=>O.ref.current);q1(pe,b)}}U.current=!1}),onBlur:be(e.onBlur,()=>A(!1))})})}),B1="RovingFocusGroupItem",H1=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:i=!1,tabStopId:l,children:c,...d}=e,h=un(),m=l||h,b=JP(B1,n),g=b.currentTabStopId===m,x=U1(n),{onFocusableItemAdd:w,onFocusableItemRemove:E,currentTabStopId:S}=b;return v.useEffect(()=>{if(s)return w(),()=>E()},[s,w,E]),f.jsx(ng.ItemSlot,{scope:n,id:m,focusable:s,active:i,children:f.jsx(Le.span,{tabIndex:g?0:-1,"data-orientation":b.orientation,...d,ref:t,onMouseDown:be(e.onMouseDown,N=>{s?b.onItemFocus(m):N.preventDefault()}),onFocus:be(e.onFocus,()=>b.onItemFocus(m)),onKeyDown:be(e.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){b.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const C=t4(N,b.orientation,b.dir);if(C!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let T=x().filter(M=>M.focusable).map(M=>M.ref.current);if(C==="last")T.reverse();else if(C==="prev"||C==="next"){C==="prev"&&T.reverse();const M=T.indexOf(N.currentTarget);T=b.loop?n4(T,M+1):T.slice(M+1)}setTimeout(()=>q1(T))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:S!=null}):c})})});H1.displayName=B1;var ZP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function e4(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function t4(e,t,n){const s=e4(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return ZP[s]}function q1(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function n4(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var V1=$1,F1=H1;function r4(e){const t=a4(e),n=v.forwardRef((s,i)=>{const{children:l,...c}=s,d=v.Children.toArray(l),h=d.find(i4);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function a4(e){const t=v.forwardRef((n,s)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=l4(i),d=o4(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var s4=Symbol("radix.slottable");function i4(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===s4}function o4(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function l4(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var c4=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},qi=new WeakMap,Uu=new WeakMap,$u={},up=0,G1=function(e){return e&&(e.host||G1(e.parentNode))},u4=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=G1(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},d4=function(e,t,n,s){var i=u4(t,Array.isArray(e)?e:[e]);$u[n]||($u[n]=new WeakMap);var l=$u[n],c=[],d=new Set,h=new Set(i),m=function(g){!g||d.has(g)||(d.add(g),m(g.parentNode))};i.forEach(m);var b=function(g){!g||h.has(g)||Array.prototype.forEach.call(g.children,function(x){if(d.has(x))b(x);else try{var w=x.getAttribute(s),E=w!==null&&w!=="false",S=(qi.get(x)||0)+1,N=(l.get(x)||0)+1;qi.set(x,S),l.set(x,N),c.push(x),S===1&&E&&Uu.set(x,!0),N===1&&x.setAttribute(n,"true"),E||x.setAttribute(s,"true")}catch(C){console.error("aria-hidden: cannot operate on ",x,C)}})};return b(t),d.clear(),up++,function(){c.forEach(function(g){var x=qi.get(g)-1,w=l.get(g)-1;qi.set(g,x),l.set(g,w),x||(Uu.has(g)||g.removeAttribute(s),Uu.delete(g)),w||g.removeAttribute(n)}),up--,up||(qi=new WeakMap,qi=new WeakMap,Uu=new WeakMap,$u={})}},cf=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),i=c4(e);return i?(s.push.apply(s,Array.from(i.querySelectorAll("[aria-live], script"))),d4(s,i,n,"aria-hidden")):function(){return null}},id="right-scroll-bar-position",od="width-before-scroll-bar",f4="with-scroll-bars-hidden",h4="--removed-body-scroll-bar-size";function dp(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function m4(e,t){var n=v.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var i=n.value;i!==s&&(n.value=s,n.callback(s,i))}}}})[0];return n.callback=t,n.facade}var p4=typeof window<"u"?v.useLayoutEffect:v.useEffect,h_=new WeakMap;function g4(e,t){var n=m4(null,function(s){return e.forEach(function(i){return dp(i,s)})});return p4(function(){var s=h_.get(n);if(s){var i=new Set(s),l=new Set(e),c=n.current;i.forEach(function(d){l.has(d)||dp(d,null)}),l.forEach(function(d){i.has(d)||dp(d,c)})}h_.set(n,e)},[e]),n}function v4(e){return e}function y4(e,t){t===void 0&&(t=v4);var n=[],s=!1,i={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(l){var c=t(l,s);return n.push(c),function(){n=n.filter(function(d){return d!==c})}},assignSyncMedium:function(l){for(s=!0;n.length;){var c=n;n=[],c.forEach(l)}n={push:function(d){return l(d)},filter:function(){return n}}},assignMedium:function(l){s=!0;var c=[];if(n.length){var d=n;n=[],d.forEach(l),c=n}var h=function(){var b=c;c=[],b.forEach(l)},m=function(){return Promise.resolve().then(h)};m(),n={push:function(b){c.push(b),m()},filter:function(b){return c=c.filter(b),n}}}};return i}function b4(e){e===void 0&&(e={});var t=y4(null);return t.options=Dr({async:!0,ssr:!1},e),t}var K1=function(e){var t=e.sideCar,n=bo(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return v.createElement(s,Dr({},n))};K1.isSideCarExport=!0;function x4(e,t){return e.useMedium(t),K1}var Y1=b4(),fp=function(){},uf=v.forwardRef(function(e,t){var n=v.useRef(null),s=v.useState({onScrollCapture:fp,onWheelCapture:fp,onTouchMoveCapture:fp}),i=s[0],l=s[1],c=e.forwardProps,d=e.children,h=e.className,m=e.removeScrollBar,b=e.enabled,g=e.shards,x=e.sideCar,w=e.noRelative,E=e.noIsolation,S=e.inert,N=e.allowPinchZoom,C=e.as,A=C===void 0?"div":C,T=e.gapMode,M=bo(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),U=x,z=g4([n,t]),L=Dr(Dr({},M),i);return v.createElement(v.Fragment,null,b&&v.createElement(U,{sideCar:Y1,removeScrollBar:m,shards:g,noRelative:w,noIsolation:E,inert:S,setCallbacks:l,allowPinchZoom:!!N,lockRef:n,gapMode:T}),c?v.cloneElement(v.Children.only(d),Dr(Dr({},L),{ref:z})):v.createElement(A,Dr({},L,{className:h,ref:z}),d))});uf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};uf.classNames={fullWidth:od,zeroRight:id};var w4=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function _4(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=w4();return t&&e.setAttribute("nonce",t),e}function S4(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function E4(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var C4=function(){var e=0,t=null;return{add:function(n){e==0&&(t=_4())&&(S4(t,n),E4(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},N4=function(){var e=C4();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},W1=function(){var e=N4(),t=function(n){var s=n.styles,i=n.dynamic;return e(s,i),null};return t},j4={left:0,top:0,right:0,gap:0},hp=function(e){return parseInt(e||"",10)||0},T4=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[hp(n),hp(s),hp(i)]},A4=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return j4;var t=T4(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},R4=W1(),so="data-scroll-locked",k4=function(e,t,n,s){var i=e.left,l=e.top,c=e.right,d=e.gap;return n===void 0&&(n="margin"),`
.`.concat(f4,` {
overflow: hidden `).concat(s,`;
padding-right: `).concat(d,"px ").concat(s,`;
}
body[`).concat(so,`] {
overflow: hidden `).concat(s,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
padding-left: `.concat(i,`px;
padding-top: `).concat(l,`px;
padding-right: `).concat(c,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(d,"px ").concat(s,`;
`),n==="padding"&&"padding-right: ".concat(d,"px ").concat(s,";")].filter(Boolean).join(""),`
}
.`).concat(id,` {
right: `).concat(d,"px ").concat(s,`;
}
.`).concat(od,` {
margin-right: `).concat(d,"px ").concat(s,`;
}
.`).concat(id," .").concat(id,` {
right: 0 `).concat(s,`;
}
.`).concat(od," .").concat(od,` {
margin-right: 0 `).concat(s,`;
}
body[`).concat(so,`] {
`).concat(h4,": ").concat(d,`px;
}
`)},m_=function(){var e=parseInt(document.body.getAttribute(so)||"0",10);return isFinite(e)?e:0},O4=function(){v.useEffect(function(){return document.body.setAttribute(so,(m_()+1).toString()),function(){var e=m_()-1;e<=0?document.body.removeAttribute(so):document.body.setAttribute(so,e.toString())}},[])},M4=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,i=s===void 0?"margin":s;O4();var l=v.useMemo(function(){return A4(i)},[i]);return v.createElement(R4,{styles:k4(l,!t,i,n?"":"!important")})},rg=!1;if(typeof window<"u")try{var Bu=Object.defineProperty({},"passive",{get:function(){return rg=!0,!0}});window.addEventListener("test",Bu,Bu),window.removeEventListener("test",Bu,Bu)}catch{rg=!1}var Vi=rg?{passive:!1}:!1,D4=function(e){return e.tagName==="TEXTAREA"},X1=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!D4(e)&&n[t]==="visible")},L4=function(e){return X1(e,"overflowY")},P4=function(e){return X1(e,"overflowX")},p_=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var i=J1(e,s);if(i){var l=Q1(e,s),c=l[1],d=l[2];if(c>d)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},z4=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},I4=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},J1=function(e,t){return e==="v"?L4(t):P4(t)},Q1=function(e,t){return e==="v"?z4(t):I4(t)},U4=function(e,t){return e==="h"&&t==="rtl"?-1:1},$4=function(e,t,n,s,i){var l=U4(e,window.getComputedStyle(t).direction),c=l*s,d=n.target,h=t.contains(d),m=!1,b=c>0,g=0,x=0;do{if(!d)break;var w=Q1(e,d),E=w[0],S=w[1],N=w[2],C=S-N-l*E;(E||C)&&J1(e,d)&&(g+=C,x+=E);var A=d.parentNode;d=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!h&&d!==document.body||h&&(t.contains(d)||t===d));return(b&&Math.abs(g)<1||!b&&Math.abs(x)<1)&&(m=!0),m},Hu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},g_=function(e){return[e.deltaX,e.deltaY]},v_=function(e){return e&&"current"in e?e.current:e},B4=function(e,t){return e[0]===t[0]&&e[1]===t[1]},H4=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},q4=0,Fi=[];function V4(e){var t=v.useRef([]),n=v.useRef([0,0]),s=v.useRef(),i=v.useState(q4++)[0],l=v.useState(W1)[0],c=v.useRef(e);v.useEffect(function(){c.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var S=m2([e.lockRef.current],(e.shards||[]).map(v_),!0).filter(Boolean);return S.forEach(function(N){return N.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),S.forEach(function(N){return N.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var d=v.useCallback(function(S,N){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!c.current.allowPinchZoom;var C=Hu(S),A=n.current,T="deltaX"in S?S.deltaX:A[0]-C[0],M="deltaY"in S?S.deltaY:A[1]-C[1],U,z=S.target,L=Math.abs(T)>Math.abs(M)?"h":"v";if("touches"in S&&L==="h"&&z.type==="range")return!1;var B=window.getSelection(),q=B&&B.anchorNode,ue=q?q===z||q.contains(z):!1;if(ue)return!1;var le=p_(L,z);if(!le)return!0;if(le?U=L:(U=L==="v"?"h":"v",le=p_(L,z)),!le)return!1;if(!s.current&&"changedTouches"in S&&(T||M)&&(s.current=U),!U)return!0;var he=s.current||U;return $4(he,N,S,he==="h"?T:M)},[]),h=v.useCallback(function(S){var N=S;if(!(!Fi.length||Fi[Fi.length-1]!==l)){var C="deltaY"in N?g_(N):Hu(N),A=t.current.filter(function(U){return U.name===N.type&&(U.target===N.target||N.target===U.shadowParent)&&B4(U.delta,C)})[0];if(A&&A.should){N.cancelable&&N.preventDefault();return}if(!A){var T=(c.current.shards||[]).map(v_).filter(Boolean).filter(function(U){return U.contains(N.target)}),M=T.length>0?d(N,T[0]):!c.current.noIsolation;M&&N.cancelable&&N.preventDefault()}}},[]),m=v.useCallback(function(S,N,C,A){var T={name:S,delta:N,target:C,should:A,shadowParent:F4(C)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(M){return M!==T})},1)},[]),b=v.useCallback(function(S){n.current=Hu(S),s.current=void 0},[]),g=v.useCallback(function(S){m(S.type,g_(S),S.target,d(S,e.lockRef.current))},[]),x=v.useCallback(function(S){m(S.type,Hu(S),S.target,d(S,e.lockRef.current))},[]);v.useEffect(function(){return Fi.push(l),e.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:x}),document.addEventListener("wheel",h,Vi),document.addEventListener("touchmove",h,Vi),document.addEventListener("touchstart",b,Vi),function(){Fi=Fi.filter(function(S){return S!==l}),document.removeEventListener("wheel",h,Vi),document.removeEventListener("touchmove",h,Vi),document.removeEventListener("touchstart",b,Vi)}},[]);var w=e.removeScrollBar,E=e.inert;return v.createElement(v.Fragment,null,E?v.createElement(l,{styles:H4(i)}):null,w?v.createElement(M4,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function F4(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const G4=x4(Y1,V4);var lc=v.forwardRef(function(e,t){return v.createElement(uf,Dr({},e,{ref:t,sideCar:G4}))});lc.classNames=uf.classNames;var ag=["Enter"," "],K4=["ArrowDown","PageUp","Home"],Z1=["ArrowUp","PageDown","End"],Y4=[...K4,...Z1],W4={ltr:[...ag,"ArrowRight"],rtl:[...ag,"ArrowLeft"]},X4={ltr:["ArrowLeft"],rtl:["ArrowRight"]},cc="Menu",[Fl,J4,Q4]=Kg(cc),[Ks,eE]=or(cc,[Q4,So,lf]),df=So(),tE=lf(),[Z4,Ys]=Ks(cc),[ez,uc]=Ks(cc),nE=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:i,onOpenChange:l,modal:c=!0}=e,d=df(t),[h,m]=v.useState(null),b=v.useRef(!1),g=en(l),x=nc(i);return v.useEffect(()=>{const w=()=>{b.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},E=()=>b.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),f.jsx(rv,{...d,children:f.jsx(Z4,{scope:t,open:n,onOpenChange:g,content:h,onContentChange:m,children:f.jsx(ez,{scope:t,onClose:v.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:b,dir:x,modal:c,children:s})})})};nE.displayName=cc;var tz="MenuAnchor",iv=v.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,i=df(n);return f.jsx(of,{...i,...s,ref:t})});iv.displayName=tz;var ov="MenuPortal",[nz,rE]=Ks(ov,{forceMount:void 0}),aE=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:i}=e,l=Ys(ov,t);return f.jsx(nz,{scope:t,forceMount:n,children:f.jsx(pn,{present:n||l.open,children:f.jsx(ic,{asChild:!0,container:i,children:s})})})};aE.displayName=ov;var sr="MenuContent",[rz,lv]=Ks(sr),sE=v.forwardRef((e,t)=>{const n=rE(sr,e.__scopeMenu),{forceMount:s=n.forceMount,...i}=e,l=Ys(sr,e.__scopeMenu),c=uc(sr,e.__scopeMenu);return f.jsx(Fl.Provider,{scope:e.__scopeMenu,children:f.jsx(pn,{present:s||l.open,children:f.jsx(Fl.Slot,{scope:e.__scopeMenu,children:c.modal?f.jsx(az,{...i,ref:t}):f.jsx(sz,{...i,ref:t})})})})}),az=v.forwardRef((e,t)=>{const n=Ys(sr,e.__scopeMenu),s=v.useRef(null),i=Je(t,s);return v.useEffect(()=>{const l=s.current;if(l)return cf(l)},[]),f.jsx(cv,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:be(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),sz=v.forwardRef((e,t)=>{const n=Ys(sr,e.__scopeMenu);return f.jsx(cv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),iz=r4("MenuContent.ScrollLock"),cv=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:i,onOpenAutoFocus:l,onCloseAutoFocus:c,disableOutsidePointerEvents:d,onEntryFocus:h,onEscapeKeyDown:m,onPointerDownOutside:b,onFocusOutside:g,onInteractOutside:x,onDismiss:w,disableOutsideScroll:E,...S}=e,N=Ys(sr,n),C=uc(sr,n),A=df(n),T=tE(n),M=J4(n),[U,z]=v.useState(null),L=v.useRef(null),B=Je(t,L,N.onContentChange),q=v.useRef(0),ue=v.useRef(""),le=v.useRef(0),he=v.useRef(null),de=v.useRef("right"),ve=v.useRef(0),pe=E?lc:v.Fragment,O=E?{as:iz,allowPinchZoom:!0}:void 0,K=J=>{var ee,Q;const V=ue.current+J,R=M().filter(re=>!re.disabled),k=document.activeElement,I=(ee=R.find(re=>re.ref.current===k))==null?void 0:ee.textValue,X=R.map(re=>re.textValue),H=yz(X,V,I),te=(Q=R.find(re=>re.textValue===H))==null?void 0:Q.ref.current;(function re(Ne){ue.current=Ne,window.clearTimeout(q.current),Ne!==""&&(q.current=window.setTimeout(()=>re(""),1e3))})(V),te&&setTimeout(()=>te.focus())};v.useEffect(()=>()=>window.clearTimeout(q.current),[]),tf();const W=v.useCallback(J=>{var R,k;return de.current===((R=he.current)==null?void 0:R.side)&&xz(J,(k=he.current)==null?void 0:k.area)},[]);return f.jsx(rz,{scope:n,searchRef:ue,onItemEnter:v.useCallback(J=>{W(J)&&J.preventDefault()},[W]),onItemLeave:v.useCallback(J=>{var V;W(J)||((V=L.current)==null||V.focus(),z(null))},[W]),onTriggerLeave:v.useCallback(J=>{W(J)&&J.preventDefault()},[W]),pointerGraceTimerRef:le,onPointerGraceIntentChange:v.useCallback(J=>{he.current=J},[]),children:f.jsx(pe,{...O,children:f.jsx(ac,{asChild:!0,trapped:i,onMountAutoFocus:be(l,J=>{var V;J.preventDefault(),(V=L.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:f.jsx(rc,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:m,onPointerDownOutside:b,onFocusOutside:g,onInteractOutside:x,onDismiss:w,children:f.jsx(V1,{asChild:!0,...T,dir:C.dir,orientation:"vertical",loop:s,currentTabStopId:U,onCurrentTabStopIdChange:z,onEntryFocus:be(h,J=>{C.isUsingKeyboardRef.current||J.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(av,{role:"menu","aria-orientation":"vertical","data-state":wE(N.open),"data-radix-menu-content":"",dir:C.dir,...A,...S,ref:B,style:{outline:"none",...S.style},onKeyDown:be(S.onKeyDown,J=>{const R=J.target.closest("[data-radix-menu-content]")===J.currentTarget,k=J.ctrlKey||J.altKey||J.metaKey,I=J.key.length===1;R&&(J.key==="Tab"&&J.preventDefault(),!k&&I&&K(J.key));const X=L.current;if(J.target!==X||!Y4.includes(J.key))return;J.preventDefault();const te=M().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);Z1.includes(J.key)&&te.reverse(),gz(te)}),onBlur:be(e.onBlur,J=>{J.currentTarget.contains(J.target)||(window.clearTimeout(q.current),ue.current="")}),onPointerMove:be(e.onPointerMove,Gl(J=>{const V=J.target,R=ve.current!==J.clientX;if(J.currentTarget.contains(V)&&R){const k=J.clientX>ve.current?"right":"left";de.current=k,ve.current=J.clientX}}))})})})})})})});sE.displayName=sr;var oz="MenuGroup",uv=v.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return f.jsx(Le.div,{role:"group",...s,ref:t})});uv.displayName=oz;var lz="MenuLabel",iE=v.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return f.jsx(Le.div,{...s,ref:t})});iE.displayName=lz;var Od="MenuItem",y_="menu.itemSelect",ff=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...i}=e,l=v.useRef(null),c=uc(Od,e.__scopeMenu),d=lv(Od,e.__scopeMenu),h=Je(t,l),m=v.useRef(!1),b=()=>{const g=l.current;if(!n&&g){const x=new CustomEvent(y_,{bubbles:!0,cancelable:!0});g.addEventListener(y_,w=>s==null?void 0:s(w),{once:!0}),m1(g,x),x.defaultPrevented?m.current=!1:c.onClose()}};return f.jsx(oE,{...i,ref:h,disabled:n,onClick:be(e.onClick,b),onPointerDown:g=>{var x;(x=e.onPointerDown)==null||x.call(e,g),m.current=!0},onPointerUp:be(e.onPointerUp,g=>{var x;m.current||(x=g.currentTarget)==null||x.click()}),onKeyDown:be(e.onKeyDown,g=>{const x=d.searchRef.current!=="";n||x&&g.key===" "||ag.includes(g.key)&&(g.currentTarget.click(),g.preventDefault())})})});ff.displayName=Od;var oE=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:i,...l}=e,c=lv(Od,n),d=tE(n),h=v.useRef(null),m=Je(t,h),[b,g]=v.useState(!1),[x,w]=v.useState("");return v.useEffect(()=>{const E=h.current;E&&w((E.textContent??"").trim())},[l.children]),f.jsx(Fl.ItemSlot,{scope:n,disabled:s,textValue:i??x,children:f.jsx(F1,{asChild:!0,...d,focusable:!s,children:f.jsx(Le.div,{role:"menuitem","data-highlighted":b?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...l,ref:m,onPointerMove:be(e.onPointerMove,Gl(E=>{s?c.onItemLeave(E):(c.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:be(e.onPointerLeave,Gl(E=>c.onItemLeave(E))),onFocus:be(e.onFocus,()=>g(!0)),onBlur:be(e.onBlur,()=>g(!1))})})})}),cz="MenuCheckboxItem",lE=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...i}=e;return f.jsx(hE,{scope:e.__scopeMenu,checked:n,children:f.jsx(ff,{role:"menuitemcheckbox","aria-checked":Md(n)?"mixed":n,...i,ref:t,"data-state":fv(n),onSelect:be(i.onSelect,()=>s==null?void 0:s(Md(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lE.displayName=cz;var cE="MenuRadioGroup",[uz,dz]=Ks(cE,{value:void 0,onValueChange:()=>{}}),uE=v.forwardRef((e,t)=>{const{value:n,onValueChange:s,...i}=e,l=en(s);return f.jsx(uz,{scope:e.__scopeMenu,value:n,onValueChange:l,children:f.jsx(uv,{...i,ref:t})})});uE.displayName=cE;var dE="MenuRadioItem",fE=v.forwardRef((e,t)=>{const{value:n,...s}=e,i=dz(dE,e.__scopeMenu),l=n===i.value;return f.jsx(hE,{scope:e.__scopeMenu,checked:l,children:f.jsx(ff,{role:"menuitemradio","aria-checked":l,...s,ref:t,"data-state":fv(l),onSelect:be(s.onSelect,()=>{var c;return(c=i.onValueChange)==null?void 0:c.call(i,n)},{checkForDefaultPrevented:!1})})})});fE.displayName=dE;var dv="MenuItemIndicator",[hE,fz]=Ks(dv,{checked:!1}),mE=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...i}=e,l=fz(dv,n);return f.jsx(pn,{present:s||Md(l.checked)||l.checked===!0,children:f.jsx(Le.span,{...i,ref:t,"data-state":fv(l.checked)})})});mE.displayName=dv;var hz="MenuSeparator",pE=v.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return f.jsx(Le.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});pE.displayName=hz;var mz="MenuArrow",gE=v.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,i=df(n);return f.jsx(sv,{...i,...s,ref:t})});gE.displayName=mz;var pz="MenuSub",[K6,vE]=Ks(pz),Nl="MenuSubTrigger",yE=v.forwardRef((e,t)=>{const n=Ys(Nl,e.__scopeMenu),s=uc(Nl,e.__scopeMenu),i=vE(Nl,e.__scopeMenu),l=lv(Nl,e.__scopeMenu),c=v.useRef(null),{pointerGraceTimerRef:d,onPointerGraceIntentChange:h}=l,m={__scopeMenu:e.__scopeMenu},b=v.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return v.useEffect(()=>b,[b]),v.useEffect(()=>{const g=d.current;return()=>{window.clearTimeout(g),h(null)}},[d,h]),f.jsx(iv,{asChild:!0,...m,children:f.jsx(oE,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":wE(n.open),...e,ref:bn(t,i.onTriggerChange),onClick:g=>{var x;(x=e.onClick)==null||x.call(e,g),!(e.disabled||g.defaultPrevented)&&(g.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:be(e.onPointerMove,Gl(g=>{l.onItemEnter(g),!g.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(l.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),b()},100))})),onPointerLeave:be(e.onPointerLeave,Gl(g=>{var w,E;b();const x=(w=n.content)==null?void 0:w.getBoundingClientRect();if(x){const S=(E=n.content)==null?void 0:E.dataset.side,N=S==="right",C=N?-5:5,A=x[N?"left":"right"],T=x[N?"right":"left"];l.onPointerGraceIntentChange({area:[{x:g.clientX+C,y:g.clientY},{x:A,y:x.top},{x:T,y:x.top},{x:T,y:x.bottom},{x:A,y:x.bottom}],side:S}),window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(g),g.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:be(e.onKeyDown,g=>{var w;const x=l.searchRef.current!=="";e.disabled||x&&g.key===" "||W4[s.dir].includes(g.key)&&(n.onOpenChange(!0),(w=n.content)==null||w.focus(),g.preventDefault())})})})});yE.displayName=Nl;var bE="MenuSubContent",xE=v.forwardRef((e,t)=>{const n=rE(sr,e.__scopeMenu),{forceMount:s=n.forceMount,...i}=e,l=Ys(sr,e.__scopeMenu),c=uc(sr,e.__scopeMenu),d=vE(bE,e.__scopeMenu),h=v.useRef(null),m=Je(t,h);return f.jsx(Fl.Provider,{scope:e.__scopeMenu,children:f.jsx(pn,{present:s||l.open,children:f.jsx(Fl.Slot,{scope:e.__scopeMenu,children:f.jsx(cv,{id:d.contentId,"aria-labelledby":d.triggerId,...i,ref:m,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:b=>{var g;c.isUsingKeyboardRef.current&&((g=h.current)==null||g.focus()),b.preventDefault()},onCloseAutoFocus:b=>b.preventDefault(),onFocusOutside:be(e.onFocusOutside,b=>{b.target!==d.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:be(e.onEscapeKeyDown,b=>{c.onClose(),b.preventDefault()}),onKeyDown:be(e.onKeyDown,b=>{var w;const g=b.currentTarget.contains(b.target),x=X4[c.dir].includes(b.key);g&&x&&(l.onOpenChange(!1),(w=d.trigger)==null||w.focus(),b.preventDefault())})})})})})});xE.displayName=bE;function wE(e){return e?"open":"closed"}function Md(e){return e==="indeterminate"}function fv(e){return Md(e)?"indeterminate":e?"checked":"unchecked"}function gz(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vz(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function yz(e,t,n){const i=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let c=vz(e,Math.max(l,0));i.length===1&&(c=c.filter(m=>m!==n));const h=c.find(m=>m.toLowerCase().startsWith(i.toLowerCase()));return h!==n?h:void 0}function bz(e,t){const{x:n,y:s}=e;let i=!1;for(let l=0,c=t.length-1;l<t.length;c=l++){const d=t[l],h=t[c],m=d.x,b=d.y,g=h.x,x=h.y;b>s!=x>s&&n<(g-m)*(s-b)/(x-b)+m&&(i=!i)}return i}function xz(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return bz(n,t)}function Gl(e){return t=>t.pointerType==="mouse"?e(t):void 0}var wz=nE,_z=iv,Sz=aE,Ez=sE,Cz=uv,Nz=iE,jz=ff,Tz=lE,Az=uE,Rz=fE,kz=mE,Oz=pE,Mz=gE,Dz=yE,Lz=xE,hf="DropdownMenu",[Pz]=or(hf,[eE]),xn=eE(),[zz,_E]=Pz(hf),SE=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:i,defaultOpen:l,onOpenChange:c,modal:d=!0}=e,h=xn(t),m=v.useRef(null),[b,g]=ma({prop:i,defaultProp:l??!1,onChange:c,caller:hf});return f.jsx(zz,{scope:t,triggerId:un(),triggerRef:m,contentId:un(),open:b,onOpenChange:g,onOpenToggle:v.useCallback(()=>g(x=>!x),[g]),modal:d,children:f.jsx(wz,{...h,open:b,onOpenChange:g,dir:s,modal:d,children:n})})};SE.displayName=hf;var EE="DropdownMenuTrigger",CE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...i}=e,l=_E(EE,n),c=xn(n);return f.jsx(_z,{asChild:!0,...c,children:f.jsx(Le.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...i,ref:bn(t,l.triggerRef),onPointerDown:be(e.onPointerDown,d=>{!s&&d.button===0&&d.ctrlKey===!1&&(l.onOpenToggle(),l.open||d.preventDefault())}),onKeyDown:be(e.onKeyDown,d=>{s||(["Enter"," "].includes(d.key)&&l.onOpenToggle(),d.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})});CE.displayName=EE;var Iz="DropdownMenuPortal",NE=e=>{const{__scopeDropdownMenu:t,...n}=e,s=xn(t);return f.jsx(Sz,{...s,...n})};NE.displayName=Iz;var jE="DropdownMenuContent",TE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=_E(jE,n),l=xn(n),c=v.useRef(!1);return f.jsx(Ez,{id:i.contentId,"aria-labelledby":i.triggerId,...l,...s,ref:t,onCloseAutoFocus:be(e.onCloseAutoFocus,d=>{var h;c.current||(h=i.triggerRef.current)==null||h.focus(),c.current=!1,d.preventDefault()}),onInteractOutside:be(e.onInteractOutside,d=>{const h=d.detail.originalEvent,m=h.button===0&&h.ctrlKey===!0,b=h.button===2||m;(!i.modal||b)&&(c.current=!0)}),style:{...e.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)"}})});TE.displayName=jE;var Uz="DropdownMenuGroup",$z=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Cz,{...i,...s,ref:t})});$z.displayName=Uz;var Bz="DropdownMenuLabel",AE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Nz,{...i,...s,ref:t})});AE.displayName=Bz;var Hz="DropdownMenuItem",RE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(jz,{...i,...s,ref:t})});RE.displayName=Hz;var qz="DropdownMenuCheckboxItem",kE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Tz,{...i,...s,ref:t})});kE.displayName=qz;var Vz="DropdownMenuRadioGroup",Fz=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Az,{...i,...s,ref:t})});Fz.displayName=Vz;var Gz="DropdownMenuRadioItem",OE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Rz,{...i,...s,ref:t})});OE.displayName=Gz;var Kz="DropdownMenuItemIndicator",ME=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(kz,{...i,...s,ref:t})});ME.displayName=Kz;var Yz="DropdownMenuSeparator",DE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Oz,{...i,...s,ref:t})});DE.displayName=Yz;var Wz="DropdownMenuArrow",Xz=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Mz,{...i,...s,ref:t})});Xz.displayName=Wz;var Jz="DropdownMenuSubTrigger",LE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Dz,{...i,...s,ref:t})});LE.displayName=Jz;var Qz="DropdownMenuSubContent",PE=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=xn(n);return f.jsx(Lz,{...i,...s,ref:t,style:{...e.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)"}})});PE.displayName=Qz;var Zz=SE,eI=CE,tI=NE,zE=TE,IE=AE,UE=RE,$E=kE,BE=OE,HE=ME,qE=DE,VE=LE,FE=PE;const nI=Zz,rI=eI,aI=v.forwardRef(({className:e,inset:t,children:n,...s},i)=>f.jsxs(VE,{ref:i,className:xe("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...s,children:[n,f.jsx(Qd,{className:"ml-auto"})]}));aI.displayName=VE.displayName;const sI=v.forwardRef(({className:e,...t},n)=>f.jsx(FE,{ref:n,className:xe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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 origin-(--radix-dropdown-menu-content-transform-origin)",e),...t}));sI.displayName=FE.displayName;const GE=v.forwardRef(({className:e,sideOffset:t=4,...n},s)=>f.jsx(tI,{children:f.jsx(zE,{ref:s,sideOffset:t,className:xe("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","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 origin-(--radix-dropdown-menu-content-transform-origin)",e),...n})}));GE.displayName=zE.displayName;const KE=v.forwardRef(({className:e,inset:t,...n},s)=>f.jsx(UE,{ref:s,className:xe("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));KE.displayName=UE.displayName;const iI=v.forwardRef(({className:e,children:t,checked:n,...s},i)=>f.jsxs($E,{ref:i,className:xe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...s,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(HE,{children:f.jsx($r,{className:"h-4 w-4"})})}),t]}));iI.displayName=$E.displayName;const oI=v.forwardRef(({className:e,children:t,...n},s)=>f.jsxs(BE,{ref:s,className:xe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(HE,{children:f.jsx(J5,{className:"h-2 w-2 fill-current"})})}),t]}));oI.displayName=BE.displayName;const lI=v.forwardRef(({className:e,inset:t,...n},s)=>f.jsx(IE,{ref:s,className:xe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));lI.displayName=IE.displayName;const YE=v.forwardRef(({className:e,...t},n)=>f.jsx(qE,{ref:n,className:xe("-mx-1 my-1 h-px bg-muted",e),...t}));YE.displayName=qE.displayName;function cI(e,t=[]){let n=[];function s(l,c){const d=v.createContext(c);d.displayName=l+"Context";const h=n.length;n=[...n,c];const m=g=>{var C;const{scope:x,children:w,...E}=g,S=((C=x==null?void 0:x[e])==null?void 0:C[h])||d,N=v.useMemo(()=>E,Object.values(E));return f.jsx(S.Provider,{value:N,children:w})};m.displayName=l+"Provider";function b(g,x){var S;const w=((S=x==null?void 0:x[e])==null?void 0:S[h])||d,E=v.useContext(w);if(E)return E;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[m,b]}const i=()=>{const l=n.map(c=>v.createContext(c));return function(d){const h=(d==null?void 0:d[e])||l;return v.useMemo(()=>({[`__scope${e}`]:{...d,[e]:h}}),[d,h])}};return i.scopeName=e,[s,uI(i,...t)]}function uI(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(l){const c=s.reduce((d,{useScope:h,scopeName:m})=>{const g=h(l)[`__scope${m}`];return{...d,...g}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var dI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],hv=dI.reduce((e,t)=>{const n=Jd(`Primitive.${t}`),s=v.forwardRef((i,l)=>{const{asChild:c,...d}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(h,{...d,ref:l})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),mp={exports:{}},pp={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var b_;function fI(){if(b_)return pp;b_=1;var e=Vd();function t(g,x){return g===x&&(g!==0||1/g===1/x)||g!==g&&x!==x}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,i=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function d(g,x){var w=x(),E=s({inst:{value:w,getSnapshot:x}}),S=E[0].inst,N=E[1];return l(function(){S.value=w,S.getSnapshot=x,h(S)&&N({inst:S})},[g,w,x]),i(function(){return h(S)&&N({inst:S}),g(function(){h(S)&&N({inst:S})})},[g]),c(w),w}function h(g){var x=g.getSnapshot;g=g.value;try{var w=x();return!n(g,w)}catch{return!0}}function m(g,x){return x()}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:d;return pp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:b,pp}var x_;function hI(){return x_||(x_=1,mp.exports=fI()),mp.exports}var mI=hI();function pI(){return mI.useSyncExternalStore(gI,()=>!0,()=>!1)}function gI(){return()=>{}}var mv="Avatar",[vI]=cI(mv),[yI,WE]=vI(mv),XE=v.forwardRef((e,t)=>{const{__scopeAvatar:n,...s}=e,[i,l]=v.useState("idle");return f.jsx(yI,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:l,children:f.jsx(hv.span,{...s,ref:t})})});XE.displayName=mv;var JE="AvatarImage",QE=v.forwardRef((e,t)=>{const{__scopeAvatar:n,src:s,onLoadingStatusChange:i=()=>{},...l}=e,c=WE(JE,n),d=bI(s,l),h=en(m=>{i(m),c.onImageLoadingStatusChange(m)});return Ft(()=>{d!=="idle"&&h(d)},[d,h]),d==="loaded"?f.jsx(hv.img,{...l,ref:t,src:s}):null});QE.displayName=JE;var ZE="AvatarFallback",eC=v.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:s,...i}=e,l=WE(ZE,n),[c,d]=v.useState(s===void 0);return v.useEffect(()=>{if(s!==void 0){const h=window.setTimeout(()=>d(!0),s);return()=>window.clearTimeout(h)}},[s]),c&&l.imageLoadingStatus!=="loaded"?f.jsx(hv.span,{...i,ref:t}):null});eC.displayName=ZE;function w_(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function bI(e,{referrerPolicy:t,crossOrigin:n}){const s=pI(),i=v.useRef(null),l=s?(i.current||(i.current=new window.Image),i.current):null,[c,d]=v.useState(()=>w_(l,e));return Ft(()=>{d(w_(l,e))},[l,e]),Ft(()=>{const h=g=>()=>{d(g)};if(!l)return;const m=h("loaded"),b=h("error");return l.addEventListener("load",m),l.addEventListener("error",b),t&&(l.referrerPolicy=t),typeof n=="string"&&(l.crossOrigin=n),()=>{l.removeEventListener("load",m),l.removeEventListener("error",b)}},[l,n,t]),c}var tC=XE,nC=QE,rC=eC;const aC=v.forwardRef(({className:e,...t},n)=>f.jsx(tC,{ref:n,className:xe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));aC.displayName=tC.displayName;const sC=v.forwardRef(({className:e,...t},n)=>f.jsx(nC,{ref:n,className:xe("aspect-square h-full w-full",e),...t}));sC.displayName=nC.displayName;const iC=v.forwardRef(({className:e,...t},n)=>f.jsx(rC,{ref:n,className:xe("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));iC.displayName=rC.displayName;const xI=Ug("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function yn({className:e,variant:t,...n}){return f.jsx("div",{className:xe(xI({variant:t}),e),...n})}const wI=["Ascenda","Bacardí","Bayer","Benedicto Wong","Big Cola","BMI","Casio","CDC","Colgate","Cordiflex","Diageo","Estelar","Estrella Azul","GLM","In Drive","Mars","Microsoft","Molino Criollo","Naicom","Nestlé","P&G","Pepsico","RRHH","Taco Bell","Us Meat","Vozez","Whirlpool","Little Caesars","Intcomex","Cemix","Súper Xtra","Grupo AJE","Varios","KitchenAid","Maytag","Across","Claro","Bruni","Volt","InDrive","TrueShore","Coca Cola","Más Móvil","US Rice","Café Indio","Café Maya","Jack Daniels","GLM Digital","Compass","Starbucks","Skechers","Ron Bermudez","Nature´s Heart","Larimart","Motorola","Bajaj - Pulsar","Xelet Media","Philip Morris","Malher","Carnation","La Lechera"].sort(),oC={CDC:"Marrero",Colombia:"J. Fernando","Costa Rica":"Poul","El Salvador":"Christian",Estelar:"Pablo",Guatemala:"Gerardo",Honduras:"Lucy",Jamaica:"Liz",Latam:"JL",Mexico:"Poul",Nicaragua:"Poul",OCI:"Liz",Panama:"Gabriel","Puerto Rico":"Liz","Republica Dominicana":"Liz",RRHH:"Maximo",Trinidad:"Liz",Venezuela:"Jose Fer",Vozez:"Nathalia","GLM Digital":"Lil",IQM:"Lil",WMC:"Willy"},lC=Object.keys(oC).sort(),_I=["Carnation","GLM RRHH","La Lechera","Malher","US Meat","Coffee Mate y Nescafé","Nestum y Nido","Whirlpool","Motorola","Philip Morris","US Meat Guatemala","KitKat, Crunch, Choco Trío","Colgate","Kit Kat","UMA","Purina","Maggi e Ideal","Nestlé","Jimador","Multimarcas","Maggi","Covo","El Machetazo","Grupo Bocel","Supply Chain","Carnation y La Lechera","GLM Administración","Nestlé Bice","GLM","Nescafé","Idea, Qué Rico y Maggi","EY","Nesquik","Maggi, Ketchup, Qué Rico","Ideal","Claro Empresas","Nido","Presto","Nestlé RD","GLM Colombia","Motorola RD","GLM Caribe","Mandino","Coffee Mate","GLM Latam","RRHH RD","Philip Morris TT","GLM RD","Smirnoff","Kaspersky","US Pork","Qué Rico y Maggi","Claro y Motorola","Sedal","Maytag","Qué Rico, Maggi y Ketchup","Multimarca","Aviva y Princesa","KitchenAid","Enredé","Ascenda","Lipton Té","Heiniken","Oral B","Aafresh","IQOS","Natures Heart"],SI=["Aprobado","No aprobado","Stand by","Aprobado /no ejecutado","Pre aprobado","On going","Sin respuesta"],sg=[{id:"blue",name:"Azul",hex:"#4285F4"},{id:"red",name:"Rojo",hex:"#EA4335"},{id:"yellow",name:"Amarillo",hex:"#FBBC04"},{id:"green",name:"Verde",hex:"#34A853"},{id:"purple",name:"Morado",hex:"#A142F4"},{id:"teal",name:"Turquesa",hex:"#00ACC1"},{id:"orange",name:"Naranja",hex:"#FB8C00"},{id:"pink",name:"Rosa",hex:"#E91E63"},{id:"indigo",name:"Índigo",hex:"#3F51B5"},{id:"gray",name:"Gris",hex:"#5F6368"}],EI=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];function cC(e){var t;return((t=sg.find(n=>n.id===e))==null?void 0:t.hex)??sg[0].hex}function CI({project:e,onClick:t,onTimeClick:n,showInternalAmount:s=!1}){const i=!!e.status,l=Number(e.monto),c=s&&e.monto!==null&&Number.isFinite(l)&&l>0,d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),t())};return f.jsxs("div",{"data-cdc-project-id":e.id,"data-cdc-project-country":e.bu,"data-cdc-project-name":e.nombre||"Sin título",role:"button",tabIndex:0,onClick:t,onKeyDown:d,className:xe("group block text-left w-full rounded-2xl bg-card overflow-hidden p-0 ring-1 ring-border cursor-pointer","transition-all duration-200 hover:-translate-y-0.5","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",i&&"opacity-65 hover:opacity-90"),style:{boxShadow:i?"0 1px 2px oklch(0.5 0.02 280 / 0.04)":"var(--shadow-soft)"},onMouseEnter:h=>{i||(h.currentTarget.style.boxShadow="var(--shadow-hover)")},onMouseLeave:h=>{h.currentTarget.style.boxShadow=i?"0 1px 2px oklch(0.5 0.02 280 / 0.04)":"var(--shadow-soft)"},children:[f.jsx("div",{className:"min-h-14 rounded-t-2xl px-4 py-3",style:{backgroundColor:i?"#9AA0A6":cC(e.color)},children:f.jsx("h3",{className:"text-white font-semibold text-sm leading-snug line-clamp-2 drop-shadow-sm",children:e.nombre||"Sin título"})}),f.jsxs("div",{className:"p-4 space-y-2.5",children:[f.jsx(qu,{icon:f.jsx(jd,{className:"w-3.5 h-3.5"}),label:"Cliente",value:e.cliente}),f.jsx(qu,{icon:f.jsx(jd,{className:"w-3.5 h-3.5"}),label:"Marca",value:e.marca}),f.jsx(qu,{icon:f.jsx(Nd,{className:"w-3.5 h-3.5"}),label:"País",value:e.bu}),f.jsx(qu,{icon:f.jsx(h1,{className:"w-3.5 h-3.5"}),label:"Solicita",value:e.solicitante}),f.jsxs("div",{className:"flex items-center justify-between pt-2 mt-2 border-t border-border/70",children:[f.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[n&&f.jsxs("button",{type:"button",onClick:h=>{h.stopPropagation(),n()},onKeyDown:h=>h.stopPropagation(),className:"inline-flex h-7 items-center gap-1 rounded-full border border-border bg-card px-2.5 font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Agregar o ver tiempo dedicado",children:[f.jsx(Ol,{className:"h-3.5 w-3.5"}),"Tiempo"]}),e.propuestaLinks.length>0&&f.jsxs("span",{className:"flex items-center gap-1",title:"Propuestas",children:[f.jsx(_3,{className:"w-3 h-3"})," ",e.propuestaLinks.length]}),e.afLinks.length>0&&f.jsxs("span",{className:"flex items-center gap-1",title:"Artes finales",children:[f.jsx(i3,{className:"w-3 h-3"})," AF·",e.afLinks.length]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[c&&f.jsx("span",{className:"text-sm font-semibold tabular-nums text-foreground",title:"Monto interno del proyecto",children:NI(l)}),e.status&&f.jsxs(yn,{variant:"secondary",className:xe("text-[10px] px-1.5 py-0 h-5 font-medium",e.status==="Aprobado"&&"bg-emerald-100 text-emerald-800 hover:bg-emerald-100",e.status==="No aprobado"&&"bg-red-100 text-red-800 hover:bg-red-100"),children:[e.status==="Aprobado"&&f.jsx(f1,{className:"w-2.5 h-2.5 mr-0.5"}),e.status]})]})]})]})]})}function NI(e){return`$${e.toLocaleString("en-US",{minimumFractionDigits:Number.isInteger(e)?0:2,maximumFractionDigits:2})}`}function qu({icon:e,label:t,value:n}){return f.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[f.jsx("span",{className:"text-muted-foreground mt-0.5 flex-shrink-0",children:e}),f.jsx("span",{className:"text-muted-foreground w-14 flex-shrink-0",children:t}),f.jsx("span",{className:"text-foreground font-medium truncate",children:n||"—"})]})}function jI(e){const t=TI(e),n=v.forwardRef((s,i)=>{const{children:l,...c}=s,d=v.Children.toArray(l),h=d.find(RI);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function TI(e){const t=v.forwardRef((n,s)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=OI(i),d=kI(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var AI=Symbol("radix.slottable");function RI(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===AI}function kI(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function OI(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var mf="Dialog",[uC]=or(mf),[MI,Er]=uC(mf),dC=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:i,onOpenChange:l,modal:c=!0}=e,d=v.useRef(null),h=v.useRef(null),[m,b]=ma({prop:s,defaultProp:i??!1,onChange:l,caller:mf});return f.jsx(MI,{scope:t,triggerRef:d,contentRef:h,contentId:un(),titleId:un(),descriptionId:un(),open:m,onOpenChange:b,onOpenToggle:v.useCallback(()=>b(g=>!g),[b]),modal:c,children:n})};dC.displayName=mf;var fC="DialogTrigger",DI=v.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=Er(fC,n),l=Je(t,i.triggerRef);return f.jsx(Le.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":vv(i.open),...s,ref:l,onClick:be(e.onClick,i.onOpenToggle)})});DI.displayName=fC;var pv="DialogPortal",[LI,hC]=uC(pv,{forceMount:void 0}),mC=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:i}=e,l=Er(pv,t);return f.jsx(LI,{scope:t,forceMount:n,children:v.Children.map(s,c=>f.jsx(pn,{present:n||l.open,children:f.jsx(ic,{asChild:!0,container:i,children:c})}))})};mC.displayName=pv;var Dd="DialogOverlay",pC=v.forwardRef((e,t)=>{const n=hC(Dd,e.__scopeDialog),{forceMount:s=n.forceMount,...i}=e,l=Er(Dd,e.__scopeDialog);return l.modal?f.jsx(pn,{present:s||l.open,children:f.jsx(zI,{...i,ref:t})}):null});pC.displayName=Dd;var PI=jI("DialogOverlay.RemoveScroll"),zI=v.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=Er(Dd,n);return f.jsx(lc,{as:PI,allowPinchZoom:!0,shards:[i.contentRef],children:f.jsx(Le.div,{"data-state":vv(i.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),Hs="DialogContent",gC=v.forwardRef((e,t)=>{const n=hC(Hs,e.__scopeDialog),{forceMount:s=n.forceMount,...i}=e,l=Er(Hs,e.__scopeDialog);return f.jsx(pn,{present:s||l.open,children:l.modal?f.jsx(II,{...i,ref:t}):f.jsx(UI,{...i,ref:t})})});gC.displayName=Hs;var II=v.forwardRef((e,t)=>{const n=Er(Hs,e.__scopeDialog),s=v.useRef(null),i=Je(t,n.contentRef,s);return v.useEffect(()=>{const l=s.current;if(l)return cf(l)},[]),f.jsx(vC,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(e.onCloseAutoFocus,l=>{var c;l.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&l.preventDefault()}),onFocusOutside:be(e.onFocusOutside,l=>l.preventDefault())})}),UI=v.forwardRef((e,t)=>{const n=Er(Hs,e.__scopeDialog),s=v.useRef(!1),i=v.useRef(!1);return f.jsx(vC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var c,d;(c=e.onCloseAutoFocus)==null||c.call(e,l),l.defaultPrevented||(s.current||(d=n.triggerRef.current)==null||d.focus(),l.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:l=>{var h,m;(h=e.onInteractOutside)==null||h.call(e,l),l.defaultPrevented||(s.current=!0,l.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const c=l.target;((m=n.triggerRef.current)==null?void 0:m.contains(c))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&i.current&&l.preventDefault()}})}),vC=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:l,...c}=e,d=Er(Hs,n),h=v.useRef(null),m=Je(t,h);return tf(),f.jsxs(f.Fragment,{children:[f.jsx(ac,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:l,children:f.jsx(rc,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":vv(d.open),...c,ref:m,onDismiss:()=>d.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx($I,{titleId:d.titleId}),f.jsx(HI,{contentRef:h,descriptionId:d.descriptionId})]})]})}),gv="DialogTitle",yC=v.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=Er(gv,n);return f.jsx(Le.h2,{id:i.titleId,...s,ref:t})});yC.displayName=gv;var bC="DialogDescription",xC=v.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=Er(bC,n);return f.jsx(Le.p,{id:i.descriptionId,...s,ref:t})});xC.displayName=bC;var wC="DialogClose",_C=v.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=Er(wC,n);return f.jsx(Le.button,{type:"button",...s,ref:t,onClick:be(e.onClick,()=>i.onOpenChange(!1))})});_C.displayName=wC;function vv(e){return e?"open":"closed"}var SC="DialogTitleWarning",[Y6,EC]=X3(SC,{contentName:Hs,titleName:gv,docsSlug:"dialog"}),$I=({titleId:e})=>{const t=EC(SC),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},BI="DialogDescriptionWarning",HI=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${EC(BI).contentName}}.`;return v.useEffect(()=>{var l;const i=(l=e.current)==null?void 0:l.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},CC=dC,NC=mC,yv=pC,bv=gC,jC=yC,TC=xC,qI=_C;const Eo=CC,VI=NC,AC=v.forwardRef(({className:e,...t},n)=>f.jsx(yv,{ref:n,className:xe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));AC.displayName=yv.displayName;const Ws=v.forwardRef(({className:e,children:t,...n},s)=>f.jsxs(VI,{children:[f.jsx(AC,{}),f.jsxs(bv,{ref:s,className:xe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 sm:rounded-lg",e),...n,children:[t,f.jsxs(qI,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background cursor-pointer transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[f.jsx(uo,{className:"h-4 w-4"}),f.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ws.displayName=bv.displayName;const Xs=({className:e,...t})=>f.jsx("div",{className:xe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Xs.displayName="DialogHeader";const pf=({className:e,...t})=>f.jsx("div",{className:xe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});pf.displayName="DialogFooter";const Js=v.forwardRef(({className:e,...t},n)=>f.jsx(jC,{ref:n,className:xe("text-lg font-semibold leading-none tracking-tight",e),...t}));Js.displayName=jC.displayName;const Qs=v.forwardRef(({className:e,...t},n)=>f.jsx(TC,{ref:n,className:xe("text-sm text-muted-foreground",e),...t}));Qs.displayName=TC.displayName;var FI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],GI=FI.reduce((e,t)=>{const n=Jd(`Primitive.${t}`),s=v.forwardRef((i,l)=>{const{asChild:c,...d}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(h,{...d,ref:l})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),KI="Label",RC=v.forwardRef((e,t)=>f.jsx(GI.label,{...e,ref:t,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));RC.displayName=KI;var kC=RC;const YI=Ug("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Fe=v.forwardRef(({className:e,...t},n)=>f.jsx(kC,{ref:n,className:xe(YI(),e),...t}));Fe.displayName=kC.displayName;const fa=v.forwardRef(({className:e,...t},n)=>f.jsx("textarea",{className:xe("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));fa.displayName="Textarea";function xv(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var gf="Checkbox",[WI]=or(gf),[XI,wv]=WI(gf);function JI(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:i,disabled:l,form:c,name:d,onCheckedChange:h,required:m,value:b="on",internal_do_not_use_render:g}=e,[x,w]=ma({prop:n,defaultProp:i??!1,onChange:h,caller:gf}),[E,S]=v.useState(null),[N,C]=v.useState(null),A=v.useRef(!1),T=E?!!c||!!E.closest("form"):!0,M={checked:x,disabled:l,setChecked:w,control:E,setControl:S,name:d,form:c,value:b,hasConsumerStoppedPropagationRef:A,required:m,defaultChecked:ns(i)?!1:i,isFormControl:T,bubbleInput:N,setBubbleInput:C};return f.jsx(XI,{scope:t,...M,children:QI(g)?g(M):s})}var OC="CheckboxTrigger",MC=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},i)=>{const{control:l,value:c,disabled:d,checked:h,required:m,setControl:b,setChecked:g,hasConsumerStoppedPropagationRef:x,isFormControl:w,bubbleInput:E}=wv(OC,e),S=Je(i,b),N=v.useRef(h);return v.useEffect(()=>{const C=l==null?void 0:l.form;if(C){const A=()=>g(N.current);return C.addEventListener("reset",A),()=>C.removeEventListener("reset",A)}},[l,g]),f.jsx(Le.button,{type:"button",role:"checkbox","aria-checked":ns(h)?"mixed":h,"aria-required":m,"data-state":IC(h),"data-disabled":d?"":void 0,disabled:d,value:c,...s,ref:S,onKeyDown:be(t,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:be(n,C=>{g(A=>ns(A)?!0:!A),E&&w&&(x.current=C.isPropagationStopped(),x.current||C.stopPropagation())})})});MC.displayName=OC;var _v=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:i,defaultChecked:l,required:c,disabled:d,value:h,onCheckedChange:m,form:b,...g}=e;return f.jsx(JI,{__scopeCheckbox:n,checked:i,defaultChecked:l,disabled:d,required:c,onCheckedChange:m,name:s,form:b,value:h,internal_do_not_use_render:({isFormControl:x})=>f.jsxs(f.Fragment,{children:[f.jsx(MC,{...g,ref:t,__scopeCheckbox:n}),x&&f.jsx(zC,{__scopeCheckbox:n})]})})});_v.displayName=gf;var DC="CheckboxIndicator",LC=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...i}=e,l=wv(DC,n);return f.jsx(pn,{present:s||ns(l.checked)||l.checked===!0,children:f.jsx(Le.span,{"data-state":IC(l.checked),"data-disabled":l.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});LC.displayName=DC;var PC="CheckboxBubbleInput",zC=v.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:i,checked:l,defaultChecked:c,required:d,disabled:h,name:m,value:b,form:g,bubbleInput:x,setBubbleInput:w}=wv(PC,e),E=Je(n,w),S=xv(l),N=ev(s);v.useEffect(()=>{const A=x;if(!A)return;const T=window.HTMLInputElement.prototype,U=Object.getOwnPropertyDescriptor(T,"checked").set,z=!i.current;if(S!==l&&U){const L=new Event("click",{bubbles:z});A.indeterminate=ns(l),U.call(A,ns(l)?!1:l),A.dispatchEvent(L)}},[x,S,l,i]);const C=v.useRef(ns(l)?!1:l);return f.jsx(Le.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??C.current,required:d,disabled:h,name:m,value:b,form:g,...t,tabIndex:-1,ref:E,style:{...t.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});zC.displayName=PC;function QI(e){return typeof e=="function"}function ns(e){return e==="indeterminate"}function IC(e){return ns(e)?"indeterminate":e?"checked":"unchecked"}const UC=v.forwardRef(({className:e,...t},n)=>f.jsx(_v,{ref:n,className:xe("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:f.jsx(LC,{className:xe("grid place-content-center text-current"),children:f.jsx($r,{className:"h-4 w-4"})})}));UC.displayName=_v.displayName;function ig(e,[t,n]){return Math.min(n,Math.max(t,e))}function ZI(e){const t=eU(e),n=v.forwardRef((s,i)=>{const{children:l,...c}=s,d=v.Children.toArray(l),h=d.find(nU);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function eU(e){const t=v.forwardRef((n,s)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=aU(i),d=rU(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tU=Symbol("radix.slottable");function nU(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tU}function rU(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function aU(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var $C=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"}),sU="VisuallyHidden",iU=v.forwardRef((e,t)=>f.jsx(Le.span,{...e,ref:t,style:{...$C,...e.style}}));iU.displayName=sU;var oU=[" ","Enter","ArrowUp","ArrowDown"],lU=[" ","Enter"],qs="Select",[vf,yf,cU]=Kg(qs),[Co]=or(qs,[cU,So]),bf=So(),[uU,os]=Co(qs),[dU,fU]=Co(qs),BC=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:i,onOpenChange:l,value:c,defaultValue:d,onValueChange:h,dir:m,name:b,autoComplete:g,disabled:x,required:w,form:E}=e,S=bf(t),[N,C]=v.useState(null),[A,T]=v.useState(null),[M,U]=v.useState(!1),z=nc(m),[L,B]=ma({prop:s,defaultProp:i??!1,onChange:l,caller:qs}),[q,ue]=ma({prop:c,defaultProp:d,onChange:h,caller:qs}),le=v.useRef(null),he=N?E||!!N.closest("form"):!0,[de,ve]=v.useState(new Set),pe=Array.from(de).map(O=>O.props.value).join(";");return f.jsx(rv,{...S,children:f.jsxs(uU,{required:w,scope:t,trigger:N,onTriggerChange:C,valueNode:A,onValueNodeChange:T,valueNodeHasChildren:M,onValueNodeHasChildrenChange:U,contentId:un(),value:q,onValueChange:ue,open:L,onOpenChange:B,dir:z,triggerPointerDownPosRef:le,disabled:x,children:[f.jsx(vf.Provider,{scope:t,children:f.jsx(dU,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(O=>{ve(K=>new Set(K).add(O))},[]),onNativeOptionRemove:v.useCallback(O=>{ve(K=>{const W=new Set(K);return W.delete(O),W})},[]),children:n})}),he?f.jsxs(dN,{"aria-hidden":!0,required:w,tabIndex:-1,name:b,autoComplete:g,value:q,onChange:O=>ue(O.target.value),disabled:x,form:E,children:[q===void 0?f.jsx("option",{value:""}):null,Array.from(de)]},pe):null]})})};BC.displayName=qs;var HC="SelectTrigger",qC=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...i}=e,l=bf(n),c=os(HC,n),d=c.disabled||s,h=Je(t,c.onTriggerChange),m=yf(n),b=v.useRef("touch"),[g,x,w]=hN(S=>{const N=m().filter(T=>!T.disabled),C=N.find(T=>T.value===c.value),A=mN(N,S,C);A!==void 0&&c.onValueChange(A.value)}),E=S=>{d||(c.onOpenChange(!0),w()),S&&(c.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return f.jsx(of,{asChild:!0,...l,children:f.jsx(Le.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":fN(c.value)?"":void 0,...i,ref:h,onClick:be(i.onClick,S=>{S.currentTarget.focus(),b.current!=="mouse"&&E(S)}),onPointerDown:be(i.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"&&(E(S),S.preventDefault())}),onKeyDown:be(i.onKeyDown,S=>{const N=g.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&x(S.key),!(N&&S.key===" ")&&oU.includes(S.key)&&(E(),S.preventDefault())})})})});qC.displayName=HC;var VC="SelectValue",FC=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:i,children:l,placeholder:c="",...d}=e,h=os(VC,n),{onValueNodeHasChildrenChange:m}=h,b=l!==void 0,g=Je(t,h.onValueNodeChange);return Ft(()=>{m(b)},[m,b]),f.jsx(Le.span,{...d,ref:g,style:{pointerEvents:"none"},children:fN(h.value)?f.jsx(f.Fragment,{children:c}):l})});FC.displayName=VC;var hU="SelectIcon",GC=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...i}=e;return f.jsx(Le.span,{"aria-hidden":!0,...i,ref:t,children:s||"▼"})});GC.displayName=hU;var mU="SelectPortal",KC=e=>f.jsx(ic,{asChild:!0,...e});KC.displayName=mU;var Vs="SelectContent",YC=v.forwardRef((e,t)=>{const n=os(Vs,e.__scopeSelect),[s,i]=v.useState();if(Ft(()=>{i(new DocumentFragment)},[]),!n.open){const l=s;return l?ec.createPortal(f.jsx(WC,{scope:e.__scopeSelect,children:f.jsx(vf.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),l):null}return f.jsx(XC,{...e,ref:t})});YC.displayName=Vs;var gr=10,[WC,ls]=Co(Vs),pU="SelectContentImpl",gU=ZI("SelectContent.RemoveScroll"),XC=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:l,onPointerDownOutside:c,side:d,sideOffset:h,align:m,alignOffset:b,arrowPadding:g,collisionBoundary:x,collisionPadding:w,sticky:E,hideWhenDetached:S,avoidCollisions:N,...C}=e,A=os(Vs,n),[T,M]=v.useState(null),[U,z]=v.useState(null),L=Je(t,ee=>M(ee)),[B,q]=v.useState(null),[ue,le]=v.useState(null),he=yf(n),[de,ve]=v.useState(!1),pe=v.useRef(!1);v.useEffect(()=>{if(T)return cf(T)},[T]),tf();const O=v.useCallback(ee=>{const[Q,...re]=he().map(Oe=>Oe.ref.current),[Ne]=re.slice(-1),ze=document.activeElement;for(const Oe of ee)if(Oe===ze||(Oe==null||Oe.scrollIntoView({block:"nearest"}),Oe===Q&&U&&(U.scrollTop=0),Oe===Ne&&U&&(U.scrollTop=U.scrollHeight),Oe==null||Oe.focus(),document.activeElement!==ze))return},[he,U]),K=v.useCallback(()=>O([B,T]),[O,B,T]);v.useEffect(()=>{de&&K()},[de,K]);const{onOpenChange:W,triggerPointerDownPosRef:J}=A;v.useEffect(()=>{if(T){let ee={x:0,y:0};const Q=Ne=>{var ze,Oe;ee={x:Math.abs(Math.round(Ne.pageX)-(((ze=J.current)==null?void 0:ze.x)??0)),y:Math.abs(Math.round(Ne.pageY)-(((Oe=J.current)==null?void 0:Oe.y)??0))}},re=Ne=>{ee.x<=10&&ee.y<=10?Ne.preventDefault():T.contains(Ne.target)||W(!1),document.removeEventListener("pointermove",Q),J.current=null};return J.current!==null&&(document.addEventListener("pointermove",Q),document.addEventListener("pointerup",re,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Q),document.removeEventListener("pointerup",re,{capture:!0})}}},[T,W,J]),v.useEffect(()=>{const ee=()=>W(!1);return window.addEventListener("blur",ee),window.addEventListener("resize",ee),()=>{window.removeEventListener("blur",ee),window.removeEventListener("resize",ee)}},[W]);const[V,R]=hN(ee=>{const Q=he().filter(ze=>!ze.disabled),re=Q.find(ze=>ze.ref.current===document.activeElement),Ne=mN(Q,ee,re);Ne&&setTimeout(()=>Ne.ref.current.focus())}),k=v.useCallback((ee,Q,re)=>{const Ne=!pe.current&&!re;(A.value!==void 0&&A.value===Q||Ne)&&(q(ee),Ne&&(pe.current=!0))},[A.value]),I=v.useCallback(()=>T==null?void 0:T.focus(),[T]),X=v.useCallback((ee,Q,re)=>{const Ne=!pe.current&&!re;(A.value!==void 0&&A.value===Q||Ne)&&le(ee)},[A.value]),H=s==="popper"?og:JC,te=H===og?{side:d,sideOffset:h,align:m,alignOffset:b,arrowPadding:g,collisionBoundary:x,collisionPadding:w,sticky:E,hideWhenDetached:S,avoidCollisions:N}:{};return f.jsx(WC,{scope:n,content:T,viewport:U,onViewportChange:z,itemRefCallback:k,selectedItem:B,onItemLeave:I,itemTextRefCallback:X,focusSelectedItem:K,selectedItemText:ue,position:s,isPositioned:de,searchRef:V,children:f.jsx(lc,{as:gU,allowPinchZoom:!0,children:f.jsx(ac,{asChild:!0,trapped:A.open,onMountAutoFocus:ee=>{ee.preventDefault()},onUnmountAutoFocus:be(i,ee=>{var Q;(Q=A.trigger)==null||Q.focus({preventScroll:!0}),ee.preventDefault()}),children:f.jsx(rc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:ee=>ee.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:f.jsx(H,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:ee=>ee.preventDefault(),...C,...te,onPlaced:()=>ve(!0),ref:L,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:be(C.onKeyDown,ee=>{const Q=ee.ctrlKey||ee.altKey||ee.metaKey;if(ee.key==="Tab"&&ee.preventDefault(),!Q&&ee.key.length===1&&R(ee.key),["ArrowUp","ArrowDown","Home","End"].includes(ee.key)){let Ne=he().filter(ze=>!ze.disabled).map(ze=>ze.ref.current);if(["ArrowUp","End"].includes(ee.key)&&(Ne=Ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(ee.key)){const ze=ee.target,Oe=Ne.indexOf(ze);Ne=Ne.slice(Oe+1)}setTimeout(()=>O(Ne)),ee.preventDefault()}})})})})})})});XC.displayName=pU;var vU="SelectItemAlignedPosition",JC=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...i}=e,l=os(Vs,n),c=ls(Vs,n),[d,h]=v.useState(null),[m,b]=v.useState(null),g=Je(t,L=>b(L)),x=yf(n),w=v.useRef(!1),E=v.useRef(!0),{viewport:S,selectedItem:N,selectedItemText:C,focusSelectedItem:A}=c,T=v.useCallback(()=>{if(l.trigger&&l.valueNode&&d&&m&&S&&N&&C){const L=l.trigger.getBoundingClientRect(),B=m.getBoundingClientRect(),q=l.valueNode.getBoundingClientRect(),ue=C.getBoundingClientRect();if(l.dir!=="rtl"){const ze=ue.left-B.left,Oe=q.left-ze,Qe=L.left-Oe,Ze=L.width+Qe,vt=Math.max(Ze,B.width),oe=window.innerWidth-gr,se=ig(Oe,[gr,Math.max(gr,oe-vt)]);d.style.minWidth=Ze+"px",d.style.left=se+"px"}else{const ze=B.right-ue.right,Oe=window.innerWidth-q.right-ze,Qe=window.innerWidth-L.right-Oe,Ze=L.width+Qe,vt=Math.max(Ze,B.width),oe=window.innerWidth-gr,se=ig(Oe,[gr,Math.max(gr,oe-vt)]);d.style.minWidth=Ze+"px",d.style.right=se+"px"}const le=x(),he=window.innerHeight-gr*2,de=S.scrollHeight,ve=window.getComputedStyle(m),pe=parseInt(ve.borderTopWidth,10),O=parseInt(ve.paddingTop,10),K=parseInt(ve.borderBottomWidth,10),W=parseInt(ve.paddingBottom,10),J=pe+O+de+W+K,V=Math.min(N.offsetHeight*5,J),R=window.getComputedStyle(S),k=parseInt(R.paddingTop,10),I=parseInt(R.paddingBottom,10),X=L.top+L.height/2-gr,H=he-X,te=N.offsetHeight/2,ee=N.offsetTop+te,Q=pe+O+ee,re=J-Q;if(Q<=X){const ze=le.length>0&&N===le[le.length-1].ref.current;d.style.bottom="0px";const Oe=m.clientHeight-S.offsetTop-S.offsetHeight,Qe=Math.max(H,te+(ze?I:0)+Oe+K),Ze=Q+Qe;d.style.height=Ze+"px"}else{const ze=le.length>0&&N===le[0].ref.current;d.style.top="0px";const Qe=Math.max(X,pe+S.offsetTop+(ze?k:0)+te)+re;d.style.height=Qe+"px",S.scrollTop=Q-X+S.offsetTop}d.style.margin=`${gr}px 0`,d.style.minHeight=V+"px",d.style.maxHeight=he+"px",s==null||s(),requestAnimationFrame(()=>w.current=!0)}},[x,l.trigger,l.valueNode,d,m,S,N,C,l.dir,s]);Ft(()=>T(),[T]);const[M,U]=v.useState();Ft(()=>{m&&U(window.getComputedStyle(m).zIndex)},[m]);const z=v.useCallback(L=>{L&&E.current===!0&&(T(),A==null||A(),E.current=!1)},[T,A]);return f.jsx(bU,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:w,onScrollButtonChange:z,children:f.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:f.jsx(Le.div,{...i,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});JC.displayName=vU;var yU="SelectPopperPosition",og=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:i=gr,...l}=e,c=bf(n);return f.jsx(av,{...c,...l,ref:t,align:s,collisionPadding:i,style:{boxSizing:"border-box",...l.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)"}})});og.displayName=yU;var[bU,Sv]=Co(Vs,{}),lg="SelectViewport",QC=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...i}=e,l=ls(lg,n),c=Sv(lg,n),d=Je(t,l.onViewportChange),h=v.useRef(0);return f.jsxs(f.Fragment,{children:[f.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:s}),f.jsx(vf.Slot,{scope:n,children:f.jsx(Le.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:be(i.onScroll,m=>{const b=m.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:x}=c;if(x!=null&&x.current&&g){const w=Math.abs(h.current-b.scrollTop);if(w>0){const E=window.innerHeight-gr*2,S=parseFloat(g.style.minHeight),N=parseFloat(g.style.height),C=Math.max(S,N);if(C<E){const A=C+w,T=Math.min(E,A),M=A-T;g.style.height=T+"px",g.style.bottom==="0px"&&(b.scrollTop=M>0?M:0,g.style.justifyContent="flex-end")}}}h.current=b.scrollTop})})})]})});QC.displayName=lg;var ZC="SelectGroup",[xU,wU]=Co(ZC),_U=v.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=un();return f.jsx(xU,{scope:n,id:i,children:f.jsx(Le.div,{role:"group","aria-labelledby":i,...s,ref:t})})});_U.displayName=ZC;var eN="SelectLabel",tN=v.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=wU(eN,n);return f.jsx(Le.div,{id:i.id,...s,ref:t})});tN.displayName=eN;var Ld="SelectItem",[SU,nN]=Co(Ld),rN=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:i=!1,textValue:l,...c}=e,d=os(Ld,n),h=ls(Ld,n),m=d.value===s,[b,g]=v.useState(l??""),[x,w]=v.useState(!1),E=Je(t,A=>{var T;return(T=h.itemRefCallback)==null?void 0:T.call(h,A,s,i)}),S=un(),N=v.useRef("touch"),C=()=>{i||(d.onValueChange(s),d.onOpenChange(!1))};if(s==="")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 f.jsx(SU,{scope:n,value:s,disabled:i,textId:S,isSelected:m,onItemTextChange:v.useCallback(A=>{g(T=>T||((A==null?void 0:A.textContent)??"").trim())},[]),children:f.jsx(vf.ItemSlot,{scope:n,value:s,disabled:i,textValue:b,children:f.jsx(Le.div,{role:"option","aria-labelledby":S,"data-highlighted":x?"":void 0,"aria-selected":m&&x,"data-state":m?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...c,ref:E,onFocus:be(c.onFocus,()=>w(!0)),onBlur:be(c.onBlur,()=>w(!1)),onClick:be(c.onClick,()=>{N.current!=="mouse"&&C()}),onPointerUp:be(c.onPointerUp,()=>{N.current==="mouse"&&C()}),onPointerDown:be(c.onPointerDown,A=>{N.current=A.pointerType}),onPointerMove:be(c.onPointerMove,A=>{var T;N.current=A.pointerType,i?(T=h.onItemLeave)==null||T.call(h):N.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:be(c.onPointerLeave,A=>{var T;A.currentTarget===document.activeElement&&((T=h.onItemLeave)==null||T.call(h))}),onKeyDown:be(c.onKeyDown,A=>{var M;((M=h.searchRef)==null?void 0:M.current)!==""&&A.key===" "||(lU.includes(A.key)&&C(),A.key===" "&&A.preventDefault())})})})})});rN.displayName=Ld;var jl="SelectItemText",aN=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:i,...l}=e,c=os(jl,n),d=ls(jl,n),h=nN(jl,n),m=fU(jl,n),[b,g]=v.useState(null),x=Je(t,C=>g(C),h.onItemTextChange,C=>{var A;return(A=d.itemTextRefCallback)==null?void 0:A.call(d,C,h.value,h.disabled)}),w=b==null?void 0:b.textContent,E=v.useMemo(()=>f.jsx("option",{value:h.value,disabled:h.disabled,children:w},h.value),[h.disabled,h.value,w]),{onNativeOptionAdd:S,onNativeOptionRemove:N}=m;return Ft(()=>(S(E),()=>N(E)),[S,N,E]),f.jsxs(f.Fragment,{children:[f.jsx(Le.span,{id:h.textId,...l,ref:x}),h.isSelected&&c.valueNode&&!c.valueNodeHasChildren?ec.createPortal(l.children,c.valueNode):null]})});aN.displayName=jl;var sN="SelectItemIndicator",iN=v.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return nN(sN,n).isSelected?f.jsx(Le.span,{"aria-hidden":!0,...s,ref:t}):null});iN.displayName=sN;var cg="SelectScrollUpButton",oN=v.forwardRef((e,t)=>{const n=ls(cg,e.__scopeSelect),s=Sv(cg,e.__scopeSelect),[i,l]=v.useState(!1),c=Je(t,s.onScrollButtonChange);return Ft(()=>{if(n.viewport&&n.isPositioned){let d=function(){const m=h.scrollTop>0;l(m)};const h=n.viewport;return d(),h.addEventListener("scroll",d),()=>h.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),i?f.jsx(cN,{...e,ref:c,onAutoScroll:()=>{const{viewport:d,selectedItem:h}=n;d&&h&&(d.scrollTop=d.scrollTop-h.offsetHeight)}}):null});oN.displayName=cg;var ug="SelectScrollDownButton",lN=v.forwardRef((e,t)=>{const n=ls(ug,e.__scopeSelect),s=Sv(ug,e.__scopeSelect),[i,l]=v.useState(!1),c=Je(t,s.onScrollButtonChange);return Ft(()=>{if(n.viewport&&n.isPositioned){let d=function(){const m=h.scrollHeight-h.clientHeight,b=Math.ceil(h.scrollTop)<m;l(b)};const h=n.viewport;return d(),h.addEventListener("scroll",d),()=>h.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),i?f.jsx(cN,{...e,ref:c,onAutoScroll:()=>{const{viewport:d,selectedItem:h}=n;d&&h&&(d.scrollTop=d.scrollTop+h.offsetHeight)}}):null});lN.displayName=ug;var cN=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...i}=e,l=ls("SelectScrollButton",n),c=v.useRef(null),d=yf(n),h=v.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return v.useEffect(()=>()=>h(),[h]),Ft(()=>{var b;const m=d().find(g=>g.ref.current===document.activeElement);(b=m==null?void 0:m.ref.current)==null||b.scrollIntoView({block:"nearest"})},[d]),f.jsx(Le.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:be(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:be(i.onPointerMove,()=>{var m;(m=l.onItemLeave)==null||m.call(l),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:be(i.onPointerLeave,()=>{h()})})}),EU="SelectSeparator",uN=v.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return f.jsx(Le.div,{"aria-hidden":!0,...s,ref:t})});uN.displayName=EU;var dg="SelectArrow",CU=v.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=bf(n),l=os(dg,n),c=ls(dg,n);return l.open&&c.position==="popper"?f.jsx(sv,{...i,...s,ref:t}):null});CU.displayName=dg;var NU="SelectBubbleInput",dN=v.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const i=v.useRef(null),l=Je(s,i),c=xv(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLSelectElement.prototype,b=Object.getOwnPropertyDescriptor(h,"value").set;if(c!==t&&b){const g=new Event("change",{bubbles:!0});b.call(d,t),d.dispatchEvent(g)}},[c,t]),f.jsx(Le.select,{...n,style:{...$C,...n.style},ref:l,defaultValue:t})});dN.displayName=NU;function fN(e){return e===""||e===void 0}function hN(e){const t=en(e),n=v.useRef(""),s=v.useRef(0),i=v.useCallback(c=>{const d=n.current+c;t(d),(function h(m){n.current=m,window.clearTimeout(s.current),m!==""&&(s.current=window.setTimeout(()=>h(""),1e3))})(d)},[t]),l=v.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,i,l]}function mN(e,t,n){const i=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let c=jU(e,Math.max(l,0));i.length===1&&(c=c.filter(m=>m!==n));const h=c.find(m=>m.textValue.toLowerCase().startsWith(i.toLowerCase()));return h!==n?h:void 0}function jU(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var TU=BC,pN=qC,AU=FC,RU=GC,kU=KC,gN=YC,OU=QC,vN=tN,yN=rN,MU=aN,DU=iN,bN=oN,xN=lN,wN=uN;const LU=TU,PU=AU,_N=v.forwardRef(({className:e,children:t,...n},s)=>f.jsxs(pN,{ref:s,className:xe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background cursor-pointer data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,f.jsx(RU,{asChild:!0,children:f.jsx(qg,{className:"h-4 w-4 opacity-50"})})]}));_N.displayName=pN.displayName;const SN=v.forwardRef(({className:e,...t},n)=>f.jsx(bN,{ref:n,className:xe("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(q5,{className:"h-4 w-4"})}));SN.displayName=bN.displayName;const EN=v.forwardRef(({className:e,...t},n)=>f.jsx(xN,{ref:n,className:xe("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(qg,{className:"h-4 w-4"})}));EN.displayName=xN.displayName;const CN=v.forwardRef(({className:e,children:t,position:n="popper",...s},i)=>f.jsx(kU,{children:f.jsxs(gN,{ref:i,className:xe("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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 origin-(--radix-select-content-transform-origin)",n==="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",e),position:n,...s,children:[f.jsx(SN,{}),f.jsx(OU,{className:xe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(EN,{})]})}));CN.displayName=gN.displayName;const zU=v.forwardRef(({className:e,...t},n)=>f.jsx(vN,{ref:n,className:xe("px-2 py-1.5 text-sm font-semibold",e),...t}));zU.displayName=vN.displayName;const fg=v.forwardRef(({className:e,children:t,...n},s)=>f.jsxs(yN,{ref:s,className:xe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[f.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(DU,{children:f.jsx($r,{className:"h-4 w-4"})})}),f.jsx(MU,{children:t})]}));fg.displayName=yN.displayName;const IU=v.forwardRef(({className:e,...t},n)=>f.jsx(wN,{ref:n,className:xe("-mx-1 my-1 h-px bg-muted",e),...t}));IU.displayName=wN.displayName;var UU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$U=UU.reduce((e,t)=>{const n=Jd(`Primitive.${t}`),s=v.forwardRef((i,l)=>{const{asChild:c,...d}=i,h=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(h,{...d,ref:l})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),BU="Separator",__="horizontal",HU=["horizontal","vertical"],NN=v.forwardRef((e,t)=>{const{decorative:n,orientation:s=__,...i}=e,l=qU(s)?s:__,d=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return f.jsx($U.div,{"data-orientation":l,...d,...i,ref:t})});NN.displayName=BU;function qU(e){return HU.includes(e)}var jN=NN;const zs=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...s},i)=>f.jsx(jN,{ref:i,decorative:n,orientation:t,className:xe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...s}));zs.displayName=jN.displayName;function VU({value:e,onChange:t}){return f.jsx("div",{className:"flex flex-wrap gap-2",children:sg.map(n=>f.jsx("button",{type:"button",onClick:()=>t(n.id),title:n.name,className:xe("w-9 h-9 rounded-full flex items-center justify-center transition-all ring-offset-2 ring-offset-background hover:scale-110",e===n.id&&"ring-2 ring-foreground/40 scale-110"),style:{backgroundColor:n.hex},children:e===n.id&&f.jsx($r,{className:"w-4 h-4 text-white drop-shadow"})},n.id))})}function S_({label:e,prefix:t,links:n,onChange:s,readOnly:i,emptyText:l}){const[c,d]=v.useState(""),h=()=>{const g=c.trim();g&&(s([...n,g]),d(""))},m=(g,x)=>s(n.map((w,E)=>E===g?x:w)),b=g=>s(n.filter((x,w)=>w!==g));return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("span",{className:"text-sm font-medium text-foreground",children:[e," ",t&&f.jsxs("span",{className:"text-xs text-muted-foreground font-normal",children:["(",t,")"]})]}),f.jsx("span",{className:"text-xs text-muted-foreground",children:n.length})]}),n.length===0&&f.jsx("p",{className:"text-xs text-muted-foreground italic px-1",children:l??"Sin links aún"}),f.jsx("div",{className:"space-y-1.5",children:n.map((g,x)=>f.jsxs("div",{className:"group flex items-center gap-1.5",children:[f.jsxs("div",{className:"flex-shrink-0 w-7 h-7 rounded-md bg-accent flex items-center justify-center text-[10px] font-semibold text-accent-foreground",children:[t??"·",x+1]}),i?f.jsxs("a",{href:g,target:"_blank",rel:"noreferrer",className:"flex-1 text-sm text-primary hover:underline truncate flex items-center gap-1.5 py-1.5 px-2 rounded-md hover:bg-accent/60 transition-colors",children:[f.jsx(E3,{className:"w-3.5 h-3.5 flex-shrink-0"}),f.jsx("span",{className:"truncate",children:g}),f.jsx(Fg,{className:"w-3 h-3 flex-shrink-0 opacity-60"})]}):f.jsxs(f.Fragment,{children:[f.jsx(lt,{value:g,onChange:w=>m(x,w.target.value),placeholder:"https://…",className:"h-9 text-sm"}),f.jsx(ke,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>b(x),children:f.jsx(uo,{className:"w-4 h-4"})})]})]},x))}),!i&&f.jsxs("div",{className:"flex gap-1.5 pt-1",children:[f.jsx(lt,{value:c,onChange:g=>d(g.target.value),onKeyDown:g=>g.key==="Enter"&&(g.preventDefault(),h()),placeholder:"Pegar link y Enter",className:"h-9 text-sm"}),f.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:h,className:"h-9",children:[f.jsx(Pr,{className:"w-4 h-4 mr-1"})," Añadir"]})]})]})}var E_=1,FU=.9,GU=.8,KU=.17,gp=.1,vp=.999,YU=.9999,WU=.99,XU=/[\\\/_+.#"@\[\(\{&]/,JU=/[\\\/_+.#"@\[\(\{&]/g,QU=/[\s-]/,TN=/[\s-]/g;function hg(e,t,n,s,i,l,c){if(l===t.length)return i===e.length?E_:WU;var d=`${i},${l}`;if(c[d]!==void 0)return c[d];for(var h=s.charAt(l),m=n.indexOf(h,i),b=0,g,x,w,E;m>=0;)g=hg(e,t,n,s,m+1,l+1,c),g>b&&(m===i?g*=E_:XU.test(e.charAt(m-1))?(g*=GU,w=e.slice(i,m-1).match(JU),w&&i>0&&(g*=Math.pow(vp,w.length))):QU.test(e.charAt(m-1))?(g*=FU,E=e.slice(i,m-1).match(TN),E&&i>0&&(g*=Math.pow(vp,E.length))):(g*=KU,i>0&&(g*=Math.pow(vp,m-i))),e.charAt(m)!==t.charAt(l)&&(g*=YU)),(g<gp&&n.charAt(m-1)===s.charAt(l+1)||s.charAt(l+1)===s.charAt(l)&&n.charAt(m-1)!==s.charAt(l))&&(x=hg(e,t,n,s,m+1,l+2,c),x*gp>g&&(g=x*gp)),g>b&&(b=g),m=n.indexOf(h,m+1);return c[d]=b,b}function C_(e){return e.toLowerCase().replace(TN," ")}function ZU(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,hg(e,t,C_(e),C_(t),0,0,{})}var xl='[cmdk-group=""]',yp='[cmdk-group-items=""]',e$='[cmdk-group-heading=""]',AN='[cmdk-item=""]',N_=`${AN}:not([aria-disabled="true"])`,mg="cmdk-item-select",Zi="data-value",t$=(e,t,n)=>ZU(e,t,n),RN=v.createContext(void 0),dc=()=>v.useContext(RN),kN=v.createContext(void 0),Ev=()=>v.useContext(kN),ON=v.createContext(void 0),MN=v.forwardRef((e,t)=>{let n=eo(()=>{var k,I;return{search:"",value:(I=(k=e.value)!=null?k:e.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=eo(()=>new Set),i=eo(()=>new Map),l=eo(()=>new Map),c=eo(()=>new Set),d=DN(e),{label:h,children:m,value:b,onValueChange:g,filter:x,shouldFilter:w,loop:E,disablePointerSelection:S=!1,vimBindings:N=!0,...C}=e,A=un(),T=un(),M=un(),U=v.useRef(null),z=f$();Fs(()=>{if(b!==void 0){let k=b.trim();n.current.value=k,L.emit()}},[b]),Fs(()=>{z(6,de)},[]);let L=v.useMemo(()=>({subscribe:k=>(c.current.add(k),()=>c.current.delete(k)),snapshot:()=>n.current,setState:(k,I,X)=>{var H,te,ee,Q;if(!Object.is(n.current[k],I)){if(n.current[k]=I,k==="search")he(),ue(),z(1,le);else if(k==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let re=document.getElementById(M);re?re.focus():(H=document.getElementById(A))==null||H.focus()}if(z(7,()=>{var re;n.current.selectedItemId=(re=ve())==null?void 0:re.id,L.emit()}),X||z(5,de),((te=d.current)==null?void 0:te.value)!==void 0){let re=I??"";(Q=(ee=d.current).onValueChange)==null||Q.call(ee,re);return}}L.emit()}},emit:()=>{c.current.forEach(k=>k())}}),[]),B=v.useMemo(()=>({value:(k,I,X)=>{var H;I!==((H=l.current.get(k))==null?void 0:H.value)&&(l.current.set(k,{value:I,keywords:X}),n.current.filtered.items.set(k,q(I,X)),z(2,()=>{ue(),L.emit()}))},item:(k,I)=>(s.current.add(k),I&&(i.current.has(I)?i.current.get(I).add(k):i.current.set(I,new Set([k]))),z(3,()=>{he(),ue(),n.current.value||le(),L.emit()}),()=>{l.current.delete(k),s.current.delete(k),n.current.filtered.items.delete(k);let X=ve();z(4,()=>{he(),(X==null?void 0:X.getAttribute("id"))===k&&le(),L.emit()})}),group:k=>(i.current.has(k)||i.current.set(k,new Set),()=>{l.current.delete(k),i.current.delete(k)}),filter:()=>d.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:A,inputId:M,labelId:T,listInnerRef:U}),[]);function q(k,I){var X,H;let te=(H=(X=d.current)==null?void 0:X.filter)!=null?H:t$;return k?te(k,n.current.search,I):0}function ue(){if(!n.current.search||d.current.shouldFilter===!1)return;let k=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(H=>{let te=i.current.get(H),ee=0;te.forEach(Q=>{let re=k.get(Q);ee=Math.max(re,ee)}),I.push([H,ee])});let X=U.current;pe().sort((H,te)=>{var ee,Q;let re=H.getAttribute("id"),Ne=te.getAttribute("id");return((ee=k.get(Ne))!=null?ee:0)-((Q=k.get(re))!=null?Q:0)}).forEach(H=>{let te=H.closest(yp);te?te.appendChild(H.parentElement===te?H:H.closest(`${yp} > *`)):X.appendChild(H.parentElement===X?H:H.closest(`${yp} > *`))}),I.sort((H,te)=>te[1]-H[1]).forEach(H=>{var te;let ee=(te=U.current)==null?void 0:te.querySelector(`${xl}[${Zi}="${encodeURIComponent(H[0])}"]`);ee==null||ee.parentElement.appendChild(ee)})}function le(){let k=pe().find(X=>X.getAttribute("aria-disabled")!=="true"),I=k==null?void 0:k.getAttribute(Zi);L.setState("value",I||void 0)}function he(){var k,I,X,H;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let te=0;for(let ee of s.current){let Q=(I=(k=l.current.get(ee))==null?void 0:k.value)!=null?I:"",re=(H=(X=l.current.get(ee))==null?void 0:X.keywords)!=null?H:[],Ne=q(Q,re);n.current.filtered.items.set(ee,Ne),Ne>0&&te++}for(let[ee,Q]of i.current)for(let re of Q)if(n.current.filtered.items.get(re)>0){n.current.filtered.groups.add(ee);break}n.current.filtered.count=te}function de(){var k,I,X;let H=ve();H&&(((k=H.parentElement)==null?void 0:k.firstChild)===H&&((X=(I=H.closest(xl))==null?void 0:I.querySelector(e$))==null||X.scrollIntoView({block:"nearest"})),H.scrollIntoView({block:"nearest"}))}function ve(){var k;return(k=U.current)==null?void 0:k.querySelector(`${AN}[aria-selected="true"]`)}function pe(){var k;return Array.from(((k=U.current)==null?void 0:k.querySelectorAll(N_))||[])}function O(k){let I=pe()[k];I&&L.setState("value",I.getAttribute(Zi))}function K(k){var I;let X=ve(),H=pe(),te=H.findIndex(Q=>Q===X),ee=H[te+k];(I=d.current)!=null&&I.loop&&(ee=te+k<0?H[H.length-1]:te+k===H.length?H[0]:H[te+k]),ee&&L.setState("value",ee.getAttribute(Zi))}function W(k){let I=ve(),X=I==null?void 0:I.closest(xl),H;for(;X&&!H;)X=k>0?u$(X,xl):d$(X,xl),H=X==null?void 0:X.querySelector(N_);H?L.setState("value",H.getAttribute(Zi)):K(k)}let J=()=>O(pe().length-1),V=k=>{k.preventDefault(),k.metaKey?J():k.altKey?W(1):K(1)},R=k=>{k.preventDefault(),k.metaKey?O(0):k.altKey?W(-1):K(-1)};return v.createElement(Le.div,{ref:t,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:k=>{var I;(I=C.onKeyDown)==null||I.call(C,k);let X=k.nativeEvent.isComposing||k.keyCode===229;if(!(k.defaultPrevented||X))switch(k.key){case"n":case"j":{N&&k.ctrlKey&&V(k);break}case"ArrowDown":{V(k);break}case"p":case"k":{N&&k.ctrlKey&&R(k);break}case"ArrowUp":{R(k);break}case"Home":{k.preventDefault(),O(0);break}case"End":{k.preventDefault(),J();break}case"Enter":{k.preventDefault();let H=ve();if(H){let te=new Event(mg);H.dispatchEvent(te)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:B.inputId,id:B.labelId,style:m$},h),xf(e,k=>v.createElement(kN.Provider,{value:L},v.createElement(RN.Provider,{value:B},k))))}),n$=v.forwardRef((e,t)=>{var n,s;let i=un(),l=v.useRef(null),c=v.useContext(ON),d=dc(),h=DN(e),m=(s=(n=h.current)==null?void 0:n.forceMount)!=null?s:c==null?void 0:c.forceMount;Fs(()=>{if(!m)return d.item(i,c==null?void 0:c.id)},[m]);let b=LN(i,l,[e.value,e.children,l],e.keywords),g=Ev(),x=ss(z=>z.value&&z.value===b.current),w=ss(z=>m||d.filter()===!1?!0:z.search?z.filtered.items.get(i)>0:!0);v.useEffect(()=>{let z=l.current;if(!(!z||e.disabled))return z.addEventListener(mg,E),()=>z.removeEventListener(mg,E)},[w,e.onSelect,e.disabled]);function E(){var z,L;S(),(L=(z=h.current).onSelect)==null||L.call(z,b.current)}function S(){g.setState("value",b.current,!0)}if(!w)return null;let{disabled:N,value:C,onSelect:A,forceMount:T,keywords:M,...U}=e;return v.createElement(Le.div,{ref:bn(l,t),...U,id:i,"cmdk-item":"",role:"option","aria-disabled":!!N,"aria-selected":!!x,"data-disabled":!!N,"data-selected":!!x,onPointerMove:N||d.getDisablePointerSelection()?void 0:S,onClick:N?void 0:E},e.children)}),r$=v.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:i,...l}=e,c=un(),d=v.useRef(null),h=v.useRef(null),m=un(),b=dc(),g=ss(w=>i||b.filter()===!1?!0:w.search?w.filtered.groups.has(c):!0);Fs(()=>b.group(c),[]),LN(c,d,[e.value,e.heading,h]);let x=v.useMemo(()=>({id:c,forceMount:i}),[i]);return v.createElement(Le.div,{ref:bn(d,t),...l,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},n&&v.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:m},n),xf(e,w=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},v.createElement(ON.Provider,{value:x},w))))}),a$=v.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,i=v.useRef(null),l=ss(c=>!c.search);return!n&&!l?null:v.createElement(Le.div,{ref:bn(i,t),...s,"cmdk-separator":"",role:"separator"})}),s$=v.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,i=e.value!=null,l=Ev(),c=ss(m=>m.search),d=ss(m=>m.selectedItemId),h=dc();return v.useEffect(()=>{e.value!=null&&l.setState("search",e.value)},[e.value]),v.createElement(Le.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":d,id:h.inputId,type:"text",value:i?e.value:c,onChange:m=>{i||l.setState("search",m.target.value),n==null||n(m.target.value)}})}),i$=v.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...i}=e,l=v.useRef(null),c=v.useRef(null),d=ss(m=>m.selectedItemId),h=dc();return v.useEffect(()=>{if(c.current&&l.current){let m=c.current,b=l.current,g,x=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let w=m.offsetHeight;b.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return x.observe(m),()=>{cancelAnimationFrame(g),x.unobserve(m)}}},[]),v.createElement(Le.div,{ref:bn(l,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":s,id:h.listId},xf(e,m=>v.createElement("div",{ref:bn(c,h.listInnerRef),"cmdk-list-sizer":""},m)))}),o$=v.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:i,contentClassName:l,container:c,...d}=e;return v.createElement(CC,{open:n,onOpenChange:s},v.createElement(NC,{container:c},v.createElement(yv,{"cmdk-overlay":"",className:i}),v.createElement(bv,{"aria-label":e.label,"cmdk-dialog":"",className:l},v.createElement(MN,{ref:t,...d}))))}),l$=v.forwardRef((e,t)=>ss(n=>n.filtered.count===0)?v.createElement(Le.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),c$=v.forwardRef((e,t)=>{let{progress:n,children:s,label:i="Loading...",...l}=e;return v.createElement(Le.div,{ref:t,...l,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},xf(e,c=>v.createElement("div",{"aria-hidden":!0},c)))}),Pn=Object.assign(MN,{List:i$,Item:n$,Input:s$,Group:r$,Separator:a$,Dialog:o$,Empty:l$,Loading:c$});function u$(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function d$(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function DN(e){let t=v.useRef(e);return Fs(()=>{t.current=e}),t}var Fs=typeof window>"u"?v.useEffect:v.useLayoutEffect;function eo(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function ss(e){let t=Ev(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function LN(e,t,n,s=[]){let i=v.useRef(),l=dc();return Fs(()=>{var c;let d=(()=>{var m;for(let b of n){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(m=b.current.textContent)==null?void 0:m.trim():i.current}})(),h=s.map(m=>m.trim());l.value(e,d,h),(c=t.current)==null||c.setAttribute(Zi,d),i.current=d}),i}var f$=()=>{let[e,t]=v.useState(),n=eo(()=>new Map);return Fs(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,i)=>{n.current.set(s,i),t({})}};function h$(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function xf({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(h$(t),{ref:t.ref},n(t.props.children)):n(t)}var m$={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Cv=v.forwardRef(({className:e,...t},n)=>f.jsx(Pn,{ref:n,className:xe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Cv.displayName=Pn.displayName;const Nv=v.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(co,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Pn.Input,{ref:n,className:xe("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Nv.displayName=Pn.Input.displayName;const jv=v.forwardRef(({className:e,...t},n)=>f.jsx(Pn.List,{ref:n,className:xe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));jv.displayName=Pn.List.displayName;const Tv=v.forwardRef((e,t)=>f.jsx(Pn.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tv.displayName=Pn.Empty.displayName;const Av=v.forwardRef(({className:e,...t},n)=>f.jsx(Pn.Group,{ref:n,className:xe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Av.displayName=Pn.Group.displayName;const PN=v.forwardRef(({className:e,...t},n)=>f.jsx(Pn.Separator,{ref:n,className:xe("-mx-1 h-px bg-border",e),...t}));PN.displayName=Pn.Separator.displayName;const Pd=v.forwardRef(({className:e,...t},n)=>f.jsx(Pn.Item,{ref:n,className:xe("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));Pd.displayName=Pn.Item.displayName;function p$(e){const t=g$(e),n=v.forwardRef((s,i)=>{const{children:l,...c}=s,d=v.Children.toArray(l),h=d.find(y$);if(h){const m=h.props.children,b=d.map(g=>g===h?v.Children.count(m)>1?v.Children.only(null):v.isValidElement(m)?m.props.children:null:g);return f.jsx(t,{...c,ref:i,children:v.isValidElement(m)?v.cloneElement(m,void 0,b):null})}return f.jsx(t,{...c,ref:i,children:l})});return n.displayName=`${e}.Slot`,n}function g$(e){const t=v.forwardRef((n,s)=>{const{children:i,...l}=n;if(v.isValidElement(i)){const c=x$(i),d=b$(l,i.props);return i.type!==v.Fragment&&(d.ref=s?bn(s,c):c),v.cloneElement(i,d)}return v.Children.count(i)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var v$=Symbol("radix.slottable");function y$(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===v$}function b$(e,t){const n={...t};for(const s in t){const i=e[s],l=t[s];/^on[A-Z]/.test(s)?i&&l?n[s]=(...d)=>{const h=l(...d);return i(...d),h}:i&&(n[s]=i):s==="style"?n[s]={...i,...l}:s==="className"&&(n[s]=[i,l].filter(Boolean).join(" "))}return{...e,...n}}function x$(e){var s,i;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var wf="Popover",[zN]=or(wf,[So]),fc=So(),[w$,cs]=zN(wf),IN=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:i,onOpenChange:l,modal:c=!1}=e,d=fc(t),h=v.useRef(null),[m,b]=v.useState(!1),[g,x]=ma({prop:s,defaultProp:i??!1,onChange:l,caller:wf});return f.jsx(rv,{...d,children:f.jsx(w$,{scope:t,contentId:un(),triggerRef:h,open:g,onOpenChange:x,onOpenToggle:v.useCallback(()=>x(w=>!w),[x]),hasCustomAnchor:m,onCustomAnchorAdd:v.useCallback(()=>b(!0),[]),onCustomAnchorRemove:v.useCallback(()=>b(!1),[]),modal:c,children:n})})};IN.displayName=wf;var UN="PopoverAnchor",_$=v.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=cs(UN,n),l=fc(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:d}=i;return v.useEffect(()=>(c(),()=>d()),[c,d]),f.jsx(of,{...l,...s,ref:t})});_$.displayName=UN;var $N="PopoverTrigger",BN=v.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=cs($N,n),l=fc(n),c=Je(t,i.triggerRef),d=f.jsx(Le.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":GN(i.open),...s,ref:c,onClick:be(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?d:f.jsx(of,{asChild:!0,...l,children:d})});BN.displayName=$N;var Rv="PopoverPortal",[S$,E$]=zN(Rv,{forceMount:void 0}),HN=e=>{const{__scopePopover:t,forceMount:n,children:s,container:i}=e,l=cs(Rv,t);return f.jsx(S$,{scope:t,forceMount:n,children:f.jsx(pn,{present:n||l.open,children:f.jsx(ic,{asChild:!0,container:i,children:s})})})};HN.displayName=Rv;var ho="PopoverContent",qN=v.forwardRef((e,t)=>{const n=E$(ho,e.__scopePopover),{forceMount:s=n.forceMount,...i}=e,l=cs(ho,e.__scopePopover);return f.jsx(pn,{present:s||l.open,children:l.modal?f.jsx(N$,{...i,ref:t}):f.jsx(j$,{...i,ref:t})})});qN.displayName=ho;var C$=p$("PopoverContent.RemoveScroll"),N$=v.forwardRef((e,t)=>{const n=cs(ho,e.__scopePopover),s=v.useRef(null),i=Je(t,s),l=v.useRef(!1);return v.useEffect(()=>{const c=s.current;if(c)return cf(c)},[]),f.jsx(lc,{as:C$,allowPinchZoom:!0,children:f.jsx(VN,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(e.onCloseAutoFocus,c=>{var d;c.preventDefault(),l.current||(d=n.triggerRef.current)==null||d.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,c=>{const d=c.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0,m=d.button===2||h;l.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:be(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),j$=v.forwardRef((e,t)=>{const n=cs(ho,e.__scopePopover),s=v.useRef(!1),i=v.useRef(!1);return f.jsx(VN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var c,d;(c=e.onCloseAutoFocus)==null||c.call(e,l),l.defaultPrevented||(s.current||(d=n.triggerRef.current)==null||d.focus(),l.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:l=>{var h,m;(h=e.onInteractOutside)==null||h.call(e,l),l.defaultPrevented||(s.current=!0,l.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const c=l.target;((m=n.triggerRef.current)==null?void 0:m.contains(c))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&i.current&&l.preventDefault()}})}),VN=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:m,onInteractOutside:b,...g}=e,x=cs(ho,n),w=fc(n);return tf(),f.jsx(ac,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:l,children:f.jsx(rc,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:b,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:m,onDismiss:()=>x.onOpenChange(!1),children:f.jsx(av,{"data-state":GN(x.open),role:"dialog",id:x.contentId,...w,...g,ref:t,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),FN="PopoverClose",T$=v.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=cs(FN,n);return f.jsx(Le.button,{type:"button",...s,ref:t,onClick:be(e.onClick,()=>i.onOpenChange(!1))})});T$.displayName=FN;var A$="PopoverArrow",R$=v.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,i=fc(n);return f.jsx(sv,{...i,...s,ref:t})});R$.displayName=A$;function GN(e){return e?"open":"closed"}var k$=IN,O$=BN,M$=HN,KN=qN;const YN=k$,WN=O$,kv=v.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},i)=>f.jsx(M$,{children:f.jsx(KN,{ref:i,align:t,sideOffset:n,className:xe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 origin-(--radix-popover-content-transform-origin)",e),...s})}));kv.displayName=KN.displayName;const D$=new RegExp("[\\u0000-\\u001F\\u007F-\\u009F\\u00AD\\u061C\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u206F\\uFEFF]","g");function XN(e){return String(e||"").replace(D$,"").replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Te(e){return XN(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function Vt(e){const t=XN(e),n=Te(t);return["republica dominicana","rep dominicana","rep dom","rep dom lizbeth","dominicana"].includes(n)?"Republica Dominicana":t}function et(e){const t=new Map;for(const n of e){const s=Vt(n);if(!s)continue;const i=Te(s);i&&(t.has(i)||t.set(i,s))}return Array.from(t.values())}function j_(e,t){const n=et(e),s=Vt(t);if(!s)return n;const i=Te(s);return n.some(c=>Te(c)===i)?n:[s,...n]}function L$(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.scrollTop+=e.deltaY}function xr({value:e,options:t,onValueChange:n,placeholder:s="Seleccionar…",searchPlaceholder:i="Buscar…",emptyText:l="No hay resultados.",disabled:c=!1,clearLabel:d}){const[h,m]=v.useState(!1),b=v.useMemo(()=>{const x=new Map;for(const w of et(t)){const E=Vt(w),S=Te(E);!S||x.has(S)||x.set(S,E)}return Array.from(x.values())},[t]),g=v.useMemo(()=>{const x=Te(e);return b.find(w=>Te(w)===x)??e},[b,e]);return f.jsxs(YN,{open:h,onOpenChange:m,children:[f.jsx(WN,{asChild:!0,children:f.jsxs(ke,{type:"button",variant:"outline",role:"combobox","aria-expanded":h,disabled:c,className:xe("h-10 w-full justify-between rounded-md border-border bg-background px-3 font-normal hover:bg-background",!g&&"text-muted-foreground"),children:[f.jsx("span",{className:"truncate",children:g||s}),f.jsx(d1,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(kv,{align:"start",className:"w-[min(92vw,560px)] min-w-[var(--radix-popover-trigger-width)] p-0",children:f.jsxs(Cv,{children:[f.jsx(Nv,{placeholder:i}),f.jsxs(jv,{className:"overscroll-contain",onWheel:L$,children:[f.jsx(Tv,{children:l}),f.jsxs(Av,{children:[d&&f.jsxs(f.Fragment,{children:[f.jsxs(Pd,{value:`__clear_${d}`,onSelect:()=>{n(""),m(!1)},children:[f.jsx($r,{className:xe("mr-2 h-4 w-4",e?"opacity-0":"opacity-100")}),f.jsx("span",{className:"whitespace-normal break-words font-medium",children:d})]},"__clear__"),b.length>0&&f.jsx(PN,{className:"my-1"})]}),b.map(x=>f.jsxs(Pd,{value:`${Te(x)} ${x}`,onSelect:()=>{n(x),m(!1)},children:[f.jsx($r,{className:xe("mr-2 h-4 w-4",Te(e)===Te(x)?"opacity-100":"opacity-0")}),f.jsx("span",{className:"whitespace-normal break-words leading-snug",children:x})]},Te(x)))]})]})]})})]})}function P$(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.scrollTop+=e.deltaY}function T_(e){return et(e.map(t=>Vt(t)).filter(Boolean))}function pg({values:e,options:t,onValuesChange:n,placeholder:s="Seleccionar…",searchPlaceholder:i="Buscar…",emptyText:l="No hay resultados.",disabled:c=!1,summaryLabel:d="opciones seleccionadas"}){const[h,m]=v.useState(!1),b=v.useMemo(()=>T_(e),[e]),g=v.useMemo(()=>new Set(b.map(C=>Te(C))),[b]),x=v.useMemo(()=>et([...t,...b].map(C=>Vt(C))),[t,b]),w=v.useMemo(()=>b.length===0?"":b.length<=2?b.join(", "):`${b.length} ${d}`,[b,d]),E=C=>{n(T_(C))},S=C=>{const A=Vt(C),T=Te(A);if(g.has(T)){E(b.filter(M=>Te(M)!==T));return}E([...b,A])},N=C=>{const A=Te(C);E(b.filter(T=>Te(T)!==A))};return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(YN,{open:h,onOpenChange:m,children:[f.jsx(WN,{asChild:!0,children:f.jsxs(ke,{type:"button",variant:"outline",role:"combobox","aria-expanded":h,disabled:c,className:xe("min-h-10 w-full justify-between rounded-md border-border bg-background px-3 font-normal hover:bg-background",!w&&"text-muted-foreground"),children:[f.jsx("span",{className:"truncate text-left",children:w||s}),f.jsx(d1,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(kv,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:f.jsxs(Cv,{children:[f.jsx(Nv,{placeholder:i}),f.jsxs(jv,{className:"overscroll-contain",onWheel:P$,children:[f.jsx(Tv,{children:l}),f.jsx(Av,{children:x.map(C=>{const A=g.has(Te(C));return f.jsxs(Pd,{value:C,onSelect:()=>S(C),children:[f.jsx($r,{className:xe("mr-2 h-4 w-4",A?"opacity-100":"opacity-0")}),f.jsx("span",{className:"truncate",children:C})]},C)})})]})]})})]}),b.length>0&&f.jsx("div",{className:"flex flex-wrap gap-1.5",children:b.map(C=>f.jsxs(yn,{variant:"secondary",className:"gap-1 rounded-full px-2 py-0.5",children:[f.jsx("span",{className:"max-w-[190px] truncate",children:C}),f.jsx("button",{type:"button",onClick:()=>N(C),className:"rounded-full text-muted-foreground transition-colors hover:text-foreground","aria-label":`Quitar ${C}`,children:f.jsx(uo,{className:"h-3 w-3"})})]},C))})]})}const z$="design_final_art",I$="adaptation_final_art",Mn="reference",U$="wmc",$$="wmc_fixed",B$="fixed";function we(e,t,n,s,i,l){return{id:e,label:t,reference:n,min:s,max:i,hint:l}}function On({designHour:e="35 - 50",adaptationHour:t="30",design:n,adaptation:s}){const i=[{id:z$,label:"Diseño + Entregable Arte Final",shortLabel:"Diseño + AF",hourReference:e,levels:n}];return s!=null&&s.length&&i.push({id:I$,label:"Adaptación Arte Final",shortLabel:"Adaptación AF",hourReference:t,levels:s}),i}function rr({id:e,service:t,amount:n,description:s,equivalent:i,observations:l}){const c=[s,i?`Equivalencia CDC: ${i}.`:"",l].filter(Boolean).join(" ");return{id:e,section:U$,category:"Walmart Connect",service:t,notes:c,workTypes:[{id:$$,label:"Tarifa fija WMC",shortLabel:"WMC",hourReference:"35 - 80",levels:[we(B$,"Precio fijo",`${n} USD`,n,n,l)]}]}}const Ml=[{id:"pdv-materiales-basicos",section:"grafico",category:"Materiales de PDV estándar",service:"Cenefas, habladores, danglers, rompetráficos, afiches, backings, rollups, uniformes, piezas WhatsApp/web",notes:"Incluye diseño en alta resolución, troqueles y 3 rondas de cambios. Cambios adicionales pueden agregarse como Otros.",workTypes:On({design:[we("basic","Básico","50 - 80",50,80),we("intermediate","Intermedio","100 - 150",100,150),we("advanced","Avanzado","150 - 300",150,300)],adaptation:[we("basic","Básico","30 - 50",30,50),we("intermediate","Intermedio","60 - 80",60,80),we("advanced","Avanzado","100 - 150",100,150)]})},{id:"pdv-promocion-pack",section:"grafico",category:"Promoción en PDV",service:"Quick counter + roll up + mecánica de canje + uniforme (pack 3 a 5 piezas o más)",notes:"Montos por paquete de 3 a 5 piezas. Piezas o solicitudes extra deben agregarse como Otros.",workTypes:On({design:[we("basic","Básico","320 - 500",320,500),we("intermediate","Intermedio","500 - 700",500,700),we("advanced","Avanzado","800 - 1000",800,1e3)],adaptation:[we("basic","Básico","200 - 350",200,350),we("intermediate","Intermedio","350 - 550",350,550),we("advanced","Avanzado","600 - 800+",600,800,"Puede superar el rango si el caso lo requiere.")]})},{id:"ooh-gigantografias",section:"grafico",category:"OOH y gigantografías",service:"Vallas, mupies y gigantografías",notes:"Los niveles están asociados a tamaño aproximado: 6m², más de 10m² y más de 20m².",workTypes:On({design:[we("basic","6m² aprox","250 - 350",250,350),we("intermediate","Más 10m²","400 - 650",400,650),we("advanced","Más de 20m²","700 - 1100",700,1100)],adaptation:[we("basic","6m² aprox","100 - 150",100,150),we("intermediate","Más 10m²","200 - 300",200,300),we("advanced","Más de 20m²","400 - 600",400,600)]})},{id:"stands-muebles-exhibidores",section:"grafico",category:"Stands, muebles y exhibidores",service:"One Way, cabeceras de góndola, revestimiento de islas y displays básicos",notes:"Incluye diseño en alta resolución, troqueles y 3 rondas de cambios.",workTypes:On({design:[we("basic","Básico","300 - 400",300,400),we("intermediate","Intermedio","450 - 650",450,650),we("advanced","Avanzado","700 - 1000",700,1e3)],adaptation:[we("basic","Básico","200 - 300",200,300),we("intermediate","Intermedio","300 - 400",300,400),we("advanced","Avanzado","450 - 600",450,600)]})},{id:"proyectos-especiales-muebles",section:"grafico",category:"Proyectos especiales",service:"Diseño de muebles u otros proyectos especiales con planos estructurales y troqueles desde cero",notes:"Precio por proyecto. Incluye diseño gráfico/estructural, planos, troqueles, conceptualización y 4 rondas de cambios.",workTypes:On({design:[we("project","Precio único","1000 - 1500",1e3,1500)],adaptation:[we("project","Precio único","600 - 850",600,850)]})},{id:"stands-creativos-eventos",section:"grafico",category:"Proyectos especiales",service:"Stands creativos para ferias/eventos, montaje de eventos especiales y diseños de espacios especiales",notes:"Precio por proyecto. Incluye stand creativo, planos estructurales, visualizaciones 3D y 4 rondas de cambios.",workTypes:On({design:[we("project","Precio único","1500 - 3000",1500,3e3)],adaptation:[we("project","Precio único","800 - 1200",800,1200)]})},{id:"empaque-simple",section:"grafico",category:"Diseño de empaques",service:"Empaque simple",notes:"Diseño gráfico original para empaques simples sin troqueles complejos.",workTypes:On({design:[we("project","Precio único","700 - 1000",700,1e3)],adaptation:[we("project","Adaptación / SKU","100 - 300",100,300)]})},{id:"empaque-complejo",section:"grafico",category:"Diseño de empaques",service:"Empaque complejo",notes:"Diseño gráfico y estructural para empaques con troqueles personalizados o formas no convencionales.",workTypes:On({design:[we("project","Precio único","1000 - 1500",1e3,1500)],adaptation:[we("project","Adaptación / SKU","100 - 300",100,300)]})},{id:"brochures",section:"grafico",category:"Catálogos, brochures y folletos",service:"Brochures",notes:"Incluye diseño y 3 rondas de cambios.",workTypes:On({design:[we("basic","Básico","200 - 400",200,400),we("intermediate","Intermedio","400 - 600",400,600),we("advanced","Avanzado","600 - 800",600,800)],adaptation:[we("basic","Básico","50 - 100",50,100),we("intermediate","Intermedio","100 - 150",100,150),we("advanced","Avanzado","150 - 350",150,350)]})},{id:"catalogos-folletos-pagina",section:"grafico",category:"Catálogos, brochures y folletos",service:"Catálogos y folletos (costo por página)",notes:"Costo por página. Incluye diseño y 3 rondas de cambios.",workTypes:On({design:[we("basic","Básico","30 - 60",30,60),we("intermediate","Intermedio","60 - 90",60,90),we("advanced","Avanzado","90 - 120",90,120)],adaptation:[we("basic","Básico","15 - 30",15,30),we("intermediate","Intermedio","30 - 60",30,60),we("advanced","Avanzado","60 - 100",60,100)]})},{id:"web-landing",section:"grafico",category:"Páginas web",service:"Landing page o sitio simple hasta 5 páginas",notes:"Sitio web básico con diseño estático, contenido del cliente y hasta 2 rondas de cambios.",workTypes:[{id:Mn,label:"Diseño web",shortLabel:"Web",hourReference:"35 - 50",levels:[we("project","Precio único","800 - 1500",800,1500)]}]},{id:"web-intermedio",section:"grafico",category:"Páginas web",service:"Sitio corporativo intermedio de 6 a 15 páginas",notes:"Sitio mediano con páginas adicionales y diseño más personalizado. Hasta 3 rondas de cambios.",workTypes:[{id:Mn,label:"Diseño web",shortLabel:"Web",hourReference:"35 - 50",levels:[we("project","Precio único","2000 - 5000",2e3,5e3)]}]},{id:"web-avanzado",section:"grafico",category:"Páginas web",service:"Sitio avanzado: más de 15 páginas, interactividad o integraciones complejas",notes:"Incluye desarrollo a medida y hasta 5 rondas de cambios.",workTypes:[{id:Mn,label:"Diseño web",shortLabel:"Web",hourReference:"36 - 50",levels:[we("project","Precio único","4000 - 8000",4e3,8e3)]}]},{id:"retoques-fotograficos",section:"grafico",category:"Otros servicios",service:"Retoques fotográficos",notes:"Incluye 2 rondas de ajustes.",workTypes:On({design:[we("basic","Básico","20 - 40",20,40),we("intermediate","Intermedio","50 - 100",50,100),we("advanced","Avanzado","150 - 300",150,300)],adaptation:void 0})},{id:"videos",section:"grafico",category:"Otros servicios",service:"Videos",notes:"Referencia por complejidad del video.",workTypes:On({designHour:"35 - 50",design:[we("basic","Básico","100 - 250",100,250),we("intermediate","Intermedio","250 - 500",250,500),we("advanced","Avanzado","500 - 1200",500,1200)]})},{id:"copy-puntual",section:"grafico",category:"Otros servicios",service:"Copy puntual para ADS, tarjetas o comunicaciones sueltas",notes:"Solo copy puntual. Si requiere concepto, presupuestar según proyecto/hora hombre.",workTypes:On({designHour:"1 - 25",design:[we("basic","Básico","100",100,100),we("intermediate","Intermedio","100 - 200",100,200),we("advanced","Avanzado","200 - 500",200,500)]})},{id:"render-sencillo",section:"grafico",category:"Otros servicios",service:"Render sencillo de 1 solo plano por unidad",notes:"No aplica para eventos donde hay que conceptualizar el ambiente total.",workTypes:On({designHour:"1 - 50",design:[we("basic","Básico","100",100,100),we("intermediate","Intermedio","100 - 150",100,150),we("advanced","Avanzado","150 - 300",150,300)]})},{id:"carnets",section:"grafico",category:"Otros servicios",service:"Carnets",notes:"Referencia especial: diseño base + réplicas. El Director Creativo calcula y escribe el monto final manualmente.",workTypes:[{id:Mn,label:"Referencia manual",shortLabel:"Manual",levels:[we("base","Diseño base","20 base",20,20),we("replica","Réplicas","5 por réplica",5,5)]}]},{id:"identidad-basica",section:"estrategia",category:"Desarrollo de Identidad Gráfica para Marca",service:"Desarrollo básico para pequeñas marcas o emprendimientos",notes:"Incluye logo, paleta, tipografía, identidad visual básica, hasta 2 conceptos y 3 rondas de cambios.",workTypes:[{id:Mn,label:"Tarifa fija",shortLabel:"Fija",levels:[we("project","Básico","2000 - 4000",2e3,4e3)]}]},{id:"identidad-intermedia",section:"estrategia",category:"Desarrollo de Identidad Gráfica para Marca",service:"Desarrollo intermedio para marcas medianas",notes:"Incluye nombre si aplica, logotipo, paleta, tipografía, key visuals y manual de marca detallado.",workTypes:[{id:Mn,label:"Tarifa fija",shortLabel:"Fija",levels:[we("project","Intermedio","4000 - 8000",4e3,8e3)]}]},{id:"identidad-avanzada",section:"estrategia",category:"Desarrollo de Identidad Gráfica para Marca",service:"Desarrollo avanzado para grandes marcas o redes",notes:"Identidad visual robusta con aplicaciones de marca, investigación, key visuals y manual exhaustivo.",workTypes:[{id:Mn,label:"Tarifa fija",shortLabel:"Fija",levels:[we("project","Avanzado","8000 - 15000 o más",8e3,15e3)]}]},{id:"campana-key-visual-basica",section:"estrategia",category:"Desarrollo de Campaña Creativa",service:"Concepto y Key Visual básico para campañas pequeñas",notes:"Concepto creativo básico, key visual, línea gráfica y eslogan con aplicaciones limitadas.",workTypes:[{id:Mn,label:"Tarifa fija",shortLabel:"Fija",levels:[we("project","Básico","2000 - 3000",2e3,3e3)]}]},{id:"campana-creativa-intermedia",section:"estrategia",category:"Desarrollo de Campaña Creativa",service:"Campaña creativa intermedia para lanzamientos medianos",notes:"Concepto creativo completo, key visuals, eslogan y piezas para distintos medios.",workTypes:[{id:Mn,label:"Tarifa fija",shortLabel:"Fija",levels:[we("project","Intermedio","3000 - 5000",3e3,5e3)]}]},{id:"campana-creativa-avanzada",section:"estrategia",category:"Desarrollo de Campaña Creativa",service:"Campaña creativa avanzada para lanzamientos grandes",notes:"Desarrollo estratégico y creativo de campaña grande con insights, key visuals y múltiples piezas.",workTypes:[{id:Mn,label:"Tarifa fija",shortLabel:"Fija",levels:[we("project","Avanzado","5000 - 8000 o más",5e3,8e3)]}]},{id:"consultoria-estrategica",section:"estrategia",category:"Desarrollo Estratégico y Conceptual",service:"Consultoría estratégica y desarrollo de concepto",notes:"Investigación de mercado, análisis de competencia, concepto estratégico y alineación con objetivos del cliente.",workTypes:[{id:Mn,label:"Tarifa fija o por hora",shortLabel:"Referencia",levels:[we("project","Por proyecto","1500 - 3000",1500,3e3),we("hour","Por hora","100 - 200 por hora",100,200)]}]},{id:"rondas-adicionales-estrategia",section:"estrategia",category:"Adicionales estratégicos",service:"Rondas adicionales de cambios",notes:"Referencia para trabajo adicional en estrategia o creatividad.",workTypes:[{id:Mn,label:"Por hora",shortLabel:"Hora",levels:[we("hour","Por hora","50 - 150 por hora",50,150)]}]},rr({id:"wmc-uniformes",service:"Uniformes",amount:80,description:"Uniforme completo para personal de impulso en piso (playera/top, jogger, falda, chaleco), con 4 variantes de diseño exploradas.",equivalent:"Materiales de PDV estándar y otros materiales básicos > Uniformes",observations:"Incluye diseño en alta resolución y 3 rondas de cambios."}),rr({id:"wmc-uniformes-supervisor",service:"Uniformes Supervisor",amount:100,description:"Uniforme para supervisor de piso (polo, chumpa/track jacket, camisa formal), con 3 variantes de diseño exploradas.",equivalent:"Materiales de PDV estándar y otros materiales básicos > Uniformes",observations:"Incluye diseño en alta resolución y 3 rondas de cambios."}),rr({id:"wmc-glorificador-mano",service:"Glorificador de mano",amount:150,description:"Exhibidor portátil pequeño para presentar el producto: bandeja iluminada, aro LED, estuche o base acrílica.",equivalent:"Stands, Muebles y Exhibidores > Estándar (Displays básicos)",observations:"Incluye diseño 3D, troqueles y 3 rondas de cambios."}),rr({id:"wmc-carritos-intervenidos",service:"Carritos intervenidos",amount:200,description:"Vinil o calcomanía de marca aplicada a la canasta y al mango del carrito de compras.",equivalent:"Materiales de PDV estándar y otros materiales básicos (análogo a Backings/Rompetráficos)",observations:"Pieza análoga a material gráfico estándar aplicado sobre una superficie existente."}),rr({id:"wmc-dummies-exhibicion",service:"Dummies de exhibición",amount:200,description:"Réplica escultórica a gran escala de pasta y cepillo dental como punto focal decorativo o táctil.",equivalent:"Proyectos especiales > Diseño de muebles / proyectos con planos y troqueles desde cero",observations:"Requiere diseño estructural y visualización 3D; no es solo arte de impresión."}),rr({id:"wmc-photobooth",service:"Photobooth",amount:200,description:"Estructura tipo arco con iluminación LED y espacio fotográfico de marca para activaciones.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"Estructura autoportante con iluminación, ambientación y 4 rondas de cambios."}),rr({id:"wmc-play-station",service:"Play Station",amount:200,description:"Kiosco interactivo con pantalla táctil y mecánica de juego.",equivalent:"Proyectos especiales > Diseño de muebles / proyectos especiales",observations:"Incluye diseño de mueble e interfaz gráfica; el desarrollo funcional del juego se cotiza aparte."}),rr({id:"wmc-isla-wm",service:"Isla WM",amount:150,description:"Mueble isla completo multinivel con iluminación, gráficos y espacio de exhibición de la línea completa de producto.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"Mayor escala y complejidad estructural dentro del set de piezas."}),rr({id:"wmc-exhibicion-especial",service:"Exhibición Especial",amount:250,description:"Propuesta de muebles de exhibición.",equivalent:"Proyectos especiales > Diseño de muebles con planos y troqueles desde cero",observations:"Costo de referencia por concepto; las variantes adicionales se cobran como adicionales."}),rr({id:"wmc-punta-gondola",service:"Punta de góndola",amount:250,description:"Cabecera de góndola personalizada con iluminación, gráficos y espacio para producto.",equivalent:"Proyectos especiales > Diseño de muebles con planos y troqueles desde cero",observations:"Costo de referencia por concepto; las variantes adicionales se cobran como adicionales."}),rr({id:"wmc-estacion-prueba-producto",service:"Estación para prueba de producto",amount:200,description:"Carrito móvil con lavamanos funcional, grifo y desagüe para pruebas de producto en piso.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"La complejidad funcional puede requerir una cotización especial fuera del tarifario estándar."}),rr({id:"wmc-arco-entrada",service:"Arco de entrada",amount:200,description:"Estructura de entrada de tienda a gran formato con iluminación, efecto de niebla y gráficos de marca.",equivalent:"Proyectos especiales > Diseño de Stands Creativos para ferias o eventos",observations:"La instalación en sitio se cotiza aparte."})];function gg(e){return e?e.reference:""}function Vu(e){return e&&typeof e.min=="number"&&typeof e.max=="number"?String((e.min===e.max,e.min)):""}const mo="tablero_cdc_tariff_catalog",vg="Referencia",JN="Precio único";let Ja={rows:yg(Ml),catalog:Ml,source:"fallback",loading:!1,error:null},io=!1,ld=[],bp=0;function xp(){ld.forEach(e=>e())}function A_(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=Number(e.trim());if(Number.isFinite(t))return t}return null}function Dl(e){return String(e||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function Ov(e,t,n){return[e,t,n].map(Dl).filter(Boolean).join("__")}function QN(e){const t=String(e.section||"grafico").trim().toLowerCase()||"grafico",n=String(e.category||"").trim(),s=String(e.service||"").trim(),i=String(e.catalog_item_id||Dl(`${t}-${n}-${s}`)).trim(),l=String(e.work_type_label||vg).trim(),c=String(e.level_label||JN).trim(),d=String(e.work_type_id||Dl(l)||Mn).trim(),h=String(e.level_id||Dl(c)||"project").trim();return{id:String(e.id||Ov(i,d,h)).trim(),catalog_item_id:i,section:t,category:n,service:s,notes:String(e.notes||"").trim(),work_type_id:d,work_type_label:l,work_type_short_label:String(e.work_type_short_label||l).trim(),hour_reference:String(e.hour_reference||"").trim(),level_id:h,level_label:c,reference:String(e.reference||"").trim(),reference_min:A_(e.reference_min),reference_max:A_(e.reference_max),level_hint:String(e.level_hint||"").trim(),sort_order:Number(e.sort_order||0),is_active:e.is_active!==!1,managed_by:String(e.managed_by||"sheet").trim()||"sheet",created_at:typeof e.created_at=="string"?e.created_at:null,updated_at:typeof e.updated_at=="string"?e.updated_at:null}}function H$(e){const t=new Map,n=new Map,s=e.filter(i=>i.is_active).sort((i,l)=>i.sort_order-l.sort_order||i.category.localeCompare(l.category));for(const i of s){const l=i.catalog_item_id||Dl(`${i.section}-${i.category}-${i.service}`);let c=t.get(l);c||(c={id:l,section:i.section,category:i.category,service:i.service,notes:i.notes,workTypes:[]},t.set(l,c),n.set(l,new Map));const d=i.work_type_id||Mn,h=n.get(l);let m=h.get(d);m||(m={id:d,label:i.work_type_label||vg,shortLabel:i.work_type_short_label||i.work_type_label||vg,hourReference:i.hour_reference||void 0,levels:[]},h.set(d,m),c.workTypes.push(m));const b={id:i.level_id||"project",label:i.level_label||JN,reference:i.reference||"",min:i.reference_min??void 0,max:i.reference_max??void 0,hint:i.level_hint||void 0};m.levels.some(g=>g.id===b.id)||m.levels.push(b)}return Array.from(t.values())}function yg(e){const t=[];return e.forEach((n,s)=>{n.workTypes.forEach((i,l)=>{i.levels.forEach((c,d)=>{t.push({id:Ov(n.id,i.id,c.id),catalog_item_id:n.id,section:n.section,category:n.category,service:n.service,notes:n.notes||"",work_type_id:i.id,work_type_label:i.label,work_type_short_label:i.shortLabel,hour_reference:i.hourReference||"",level_id:c.id,level_label:c.label,reference:c.reference,reference_min:c.min??null,reference_max:c.max??null,level_hint:c.hint||"",sort_order:s*1e3+l*100+d,is_active:!0,managed_by:"system"})})})}),t}function ZN(e){return Ov(e.catalog_item_id,e.work_type_id,e.level_id)}function q$(e){const t=e instanceof Error?e.message:String(e||"");return t.includes(mo)||t.includes("Could not find the table")||t.includes("relation")||t.includes("does not exist")}async function zd(e=!1){if(io&&!e)return Ja;const t=bp+=1;Ja={...Ja,loading:!0,error:null},xp();try{const n=await Ce.from(mo).select("id, catalog_item_id, section, category, service, notes, work_type_id, work_type_label, work_type_short_label, hour_reference, level_id, level_label, reference, reference_min, reference_max, level_hint, sort_order, is_active, managed_by, created_at, updated_at").order("sort_order",{ascending:!0}).order("category",{ascending:!0});let s=n.data,i=n.error;if(i&&String(i.message||"").includes("managed_by")){const b=await Ce.from(mo).select("id, catalog_item_id, section, category, service, notes, work_type_id, work_type_label, work_type_short_label, hour_reference, level_id, level_label, reference, reference_min, reference_max, level_hint, sort_order, is_active, created_at, updated_at").order("sort_order",{ascending:!0}).order("category",{ascending:!0});s=b.data,i=b.error}if(i)throw i;const l=(s||[]).map(b=>QN(b)),c=yg(Ml),d=new Map;c.forEach(b=>d.set(b.id,b)),l.forEach(b=>d.set(b.id,b));const h=Array.from(d.values()).sort((b,g)=>b.sort_order-g.sort_order||b.category.localeCompare(g.category)),m=H$(h);t===bp&&(Ja={rows:h,catalog:m,source:l.length?"supabase":"fallback",loading:!1,error:l.length?null:"La tabla del tarifario está vacía. Se está usando el tarifario base de la app como respaldo."},io=!0,xp())}catch(n){const s=n instanceof Error?n.message:String(n||""),i=q$(n)?"Falta crear la tabla tablero_cdc_tariff_catalog en Supabase. Se está usando el tarifario base de la app como respaldo.":s||"No se pudo cargar el tarifario dinámico.";t===bp&&(Ja={rows:yg(Ml),catalog:Ml,source:"fallback",loading:!1,error:i},io=!0,xp())}return Ja}async function V$(e,t){const n=QN(e),s=n.id||ZN(n);if(t!=null&&t.catalog_item_id&&(t.category!==n.category||t.service!==n.service||t.notes!==n.notes)){const{error:c}=await Ce.from(mo).update({category:n.category,service:n.service,notes:n.notes,managed_by:"app"}).eq("catalog_item_id",t.catalog_item_id);if(c)throw c}const{error:i}=await Ce.from(mo).upsert({id:s,catalog_item_id:n.catalog_item_id,section:n.section,category:n.category,service:n.service,notes:n.notes,work_type_id:n.work_type_id,work_type_label:n.work_type_label,work_type_short_label:n.work_type_short_label,hour_reference:n.hour_reference,level_id:n.level_id,level_label:n.level_label,reference:n.reference,reference_min:n.reference_min,reference_max:n.reference_max,level_hint:n.level_hint,sort_order:n.sort_order,is_active:n.is_active,managed_by:"app"},{onConflict:"id"});if(i)throw i;return io=!1,zd(!0)}async function F$(e,t){const{error:n}=await Ce.from(mo).update({is_active:t,managed_by:"app"}).eq("id",e.id);if(n)throw n;io=!1,await zd(!0)}function ej(){const[,e]=v.useState(0);return v.useEffect(()=>{const t=()=>e(n=>n+1);return ld.push(t),!io&&!Ja.loading&&zd(),()=>{ld=ld.filter(n=>n!==t)}},[]),{...Ja,refresh:zd}}const _f="tablero_cdc_tariff_sections",bg=[{id:"grafico",name:"Tarifario Gráfico CDC",scope:"general",clientName:"",pricingMode:"guided",allowManual:!0,description:"Diseño gráfico, artes finales, adaptaciones y materiales de punto de venta.",sortOrder:10,isActive:!0},{id:"estrategia",name:"Estrategia y Creatividad",scope:"general",clientName:"",pricingMode:"guided",allowManual:!0,description:"Servicios de estrategia, conceptualización y creatividad.",sortOrder:20,isActive:!0},{id:"wmc",name:"Tarifario Walmart Connect",scope:"client",clientName:"Walmart Connect WMC",pricingMode:"fixed_multi",allowManual:!0,description:"Piezas de precio fijo que aparecen únicamente para Walmart Connect WMC.",sortOrder:100,isActive:!0}];let Qa={sections:bg,loading:!1,error:null,source:"fallback"},oo=!1,cd=[],wp=0;function _p(){cd.forEach(e=>e())}function Xa(e){return String(e||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,70)}function tj(e,t,n=""){const s=Xa(e==="client"&&n||t)||"seccion",i=Date.now().toString(36).slice(-5);return`${e==="client"?"cliente":"general"}-${s}-${i}`}function G$(e){const t=e.scope==="client"?"client":"general",n=e.pricing_mode==="fixed_multi"?"fixed_multi":"guided";return{id:String(e.id||"").trim(),name:String(e.name||"Sección sin nombre").trim(),scope:t,clientName:String(e.client_name||"").trim(),pricingMode:n,allowManual:e.allow_manual!==!1,description:String(e.description||"").trim(),sortOrder:Number(e.sort_order||0),isActive:e.is_active!==!1,createdAt:e.created_at||null,updatedAt:e.updated_at||null}}function K$(e){const t=e instanceof Error?e.message:String(e||"");return t.includes(_f)||t.includes("Could not find the table")||t.includes("does not exist")||t.includes("relation")}async function Id(e=!1){if(oo&&!e)return Qa;const t=wp+=1;Qa={...Qa,loading:!0,error:null},_p();try{const{data:n,error:s}=await Ce.from(_f).select("id, name, scope, client_name, pricing_mode, allow_manual, description, sort_order, is_active, created_at, updated_at").order("sort_order",{ascending:!0}).order("name",{ascending:!0});if(s)throw s;const i=(n||[]).map(G$),l=new Map(bg.map(d=>[d.id,d]));i.forEach(d=>l.set(d.id,d));const c=Array.from(l.values()).sort((d,h)=>d.sortOrder-h.sortOrder||d.name.localeCompare(h.name));t===wp&&(Qa={sections:c,loading:!1,error:i.length?null:"La tabla de secciones está vacía. Se muestran las secciones base como respaldo.",source:i.length?"supabase":"fallback"},oo=!0,_p())}catch(n){const s=n instanceof Error?n.message:String(n||"");t===wp&&(Qa={sections:bg,loading:!1,error:K$(n)?"Falta ejecutar el SQL del módulo de tarifario. Se muestran las secciones base como respaldo.":s||"No se pudieron cargar las secciones del tarifario.",source:"fallback"},oo=!0,_p())}return Qa}async function Y$(e){const t=e.name.trim(),n=e.scope==="client"?e.clientName.trim():"";if(!t)throw new Error("Escribe el nombre de la sección.");if(e.scope==="client"&&!n)throw new Error("Selecciona el cliente del tarifario especial.");const{error:s}=await Ce.from(_f).upsert({id:e.id,name:t,scope:e.scope,client_name:n,pricing_mode:e.scope==="client"?"fixed_multi":"guided",allow_manual:e.allowManual,description:e.description.trim(),sort_order:Number(e.sortOrder||0),is_active:e.isActive},{onConflict:"id"});if(s)throw s;return oo=!1,Id(!0)}async function W$(e,t){const{error:n}=await Ce.from(_f).update({is_active:t}).eq("id",e.id);if(n)throw n;return oo=!1,Id(!0)}function nj(){const[,e]=v.useState(0);return v.useEffect(()=>{const t=()=>e(n=>n+1);return cd.push(t),!oo&&!Qa.loading&&Id(),()=>{cd=cd.filter(n=>n!==t)}},[]),{...Qa,refresh:Id}}function Fu(e){const t=Number(e.replace(/,/g,"").trim());return Number.isFinite(t)?t:0}function wl(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e||0)}function X$(e){return(e==null?void 0:e.workTypes[0])||null}function R_(e){return(e==null?void 0:e.levels[0])||null}function Sp(e){return e.trim()}function rj(e){const t=e.workTypes[0]||null,n=(t==null?void 0:t.levels[0])||null;return{workType:t,level:n}}function ud(e){const{level:t}=rj(e),n=Number((t==null?void 0:t.min)??(t==null?void 0:t.max)??0);return Number.isFinite(n)?n:0}function aj(e,t){return t.id==="wmc"&&e.source==="tariff"&&(Te(e.workType)===Te("Tarifa fija WMC")||Te(e.category)===Te("Walmart Connect"))}function Ep(e,t){return e.source!=="tariff"?!1:e.tariffSectionId?e.tariffSectionId===t.id:aj(e,t)}function J$(e,t){const{workType:n,level:s}=rj(e),i=ud(e);return!n||!s||i<=0?null:{source:"tariff",category:t.name,serviceName:e.service,workType:`Tarifa fija · ${t.name}`,complexityLevel:"Precio fijo",referenceLabel:gg(s),referenceMin:i,referenceMax:i,amount:i,description:e.notes||"",tariffSectionId:t.id,tariffCatalogId:e.id}}function Q$({client:e,items:t,onChange:n,loading:s,error:i}){const[l,c]=v.useState("grafico"),[d,h]=v.useState(""),[m,b]=v.useState(""),[g,x]=v.useState(""),[w,E]=v.useState(""),[S,N]=v.useState(""),[C,A]=v.useState(""),[T,M]=v.useState(""),[U,z]=v.useState(""),{catalog:L,loading:B,error:q}=ej(),{sections:ue,loading:le,error:he}=nj(),de=v.useMemo(()=>ue.filter(oe=>oe.isActive&&oe.scope==="general"&&oe.pricingMode==="guided"),[ue]),ve=v.useMemo(()=>{const oe=Te(e);return oe?ue.filter(se=>se.isActive&&se.scope==="client"&&se.pricingMode==="fixed_multi"&&Te(se.clientName)===oe):[]},[e,ue]),pe=ve.length>0,O=de.find(oe=>oe.id===l)||de[0]||null;v.useEffect(()=>{!O&&de.length?c(de[0].id):O&&O.id!==l&&c(O.id)},[O,de,l]);const K=v.useMemo(()=>L.filter(oe=>oe.section===(O==null?void 0:O.id)).map(oe=>`${oe.category} · ${oe.service}`),[O==null?void 0:O.id,L]),W=v.useMemo(()=>L.find(oe=>oe.section===(O==null?void 0:O.id)&&`${oe.category} · ${oe.service}`===d)||null,[O==null?void 0:O.id,d,L]),J=v.useMemo(()=>W&&W.workTypes.find(oe=>oe.id===m)||null,[W,m]),V=v.useMemo(()=>J&&J.levels.find(oe=>oe.id===g)||null,[J,g]),R=t.reduce((oe,se)=>oe+Number(se.amount||0),0),k=()=>{h(""),b(""),x(""),E(""),N("")},I=oe=>{var Re;const se=de.find(De=>De.name===oe);c((se==null?void 0:se.id)||((Re=de[0])==null?void 0:Re.id)||""),k()},X=oe=>{h(oe);const se=L.find(ht=>ht.section===(O==null?void 0:O.id)&&`${ht.category} · ${ht.service}`===oe),Re=X$(se),De=R_(Re);b((Re==null?void 0:Re.id)||""),x((De==null?void 0:De.id)||""),E(Vu(De)),N("")},H=oe=>{if(!W)return;const se=W.workTypes.find(De=>De.label===oe),Re=R_(se);b((se==null?void 0:se.id)||""),x((Re==null?void 0:Re.id)||""),E(Vu(Re))},te=oe=>{if(!J)return;const se=J.levels.find(Re=>Re.label===oe);x((se==null?void 0:se.id)||""),E(Vu(se))},ee=()=>{if(!W||!J||!V||!O)return;const oe=Fu(w);oe<=0||(n([...t,{source:"tariff",category:W.category,serviceName:W.service,workType:J.label,complexityLevel:V.label,referenceLabel:gg(V),referenceMin:V.min??null,referenceMax:V.max??null,amount:oe,description:Sp(S),tariffSectionId:O.id,tariffCatalogId:W.id}]),N(""),E(Vu(V)))},Q=(oe,se)=>{const Re=L.filter(qe=>qe.section===oe.id&&ud(qe)>0),De=t.filter(qe=>Ep(qe,oe)),ht=new Map(De.map(qe=>[Te(qe.serviceName),qe])),Ye=new Map(Re.map(qe=>[Te(qe.service),qe])),mt=se.map(qe=>{const ce=Te(qe);return ht.get(ce)||(Ye.get(ce)?J$(Ye.get(ce),oe):null)}).filter(qe=>!!qe),zt=t.filter(qe=>!Ep(qe,oe));n([...zt,...mt])},re=ve[0]||null,Ne=!pe||ve.some(oe=>oe.allowManual),ze=()=>{const oe=Fu(U),se=(re==null?void 0:re.name)||"Otros",Re=Sp(C)||(re?`Propuesta general ${re.clientName}`:"Otros / costo manual");oe<=0||(n([...t,{source:"manual",category:se,serviceName:Re,workType:"Manual",complexityLevel:"",referenceLabel:"Monto manual",referenceMin:null,referenceMax:null,amount:oe,description:Sp(T),tariffSectionId:re==null?void 0:re.id}]),A(""),M(""),z(""))},Oe=oe=>{n(t.filter((se,Re)=>Re!==oe))},Qe=(J==null?void 0:J.label)||"",Ze=(V==null?void 0:V.label)||"",vt=i||q||he;return f.jsxs("div",{className:"md:col-span-2 rounded-2xl border border-border bg-muted/20 p-4",children:[f.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{className:"flex items-start gap-2.5",children:[f.jsx("span",{className:"mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary",children:f.jsx(k5,{className:"h-4 w-4"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-semibold",children:"Tarifario / Estimación interna"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:pe?`Este cliente tiene ${ve.length===1?"un tarifario especial":"tarifarios especiales"}. Selecciona piezas o agrega un costo manual.`:"Agrega costos del tarifario general o montos manuales. El total se guarda automáticamente como monto interno del proyecto."})]})]}),f.jsxs("div",{className:"flex w-full flex-shrink-0 items-center justify-between gap-3 rounded-xl border border-primary/20 bg-card px-3 py-2 shadow-sm sm:w-auto",children:[f.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:f.jsx(Jp,{className:"h-4 w-4"})}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Total estimado"}),f.jsx("p",{className:"mt-1 whitespace-nowrap text-lg font-semibold leading-none tabular-nums text-primary",children:wl(R)})]})]})]}),vt&&f.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-xl border border-amber-300/50 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:[f.jsx(g3,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0"}),f.jsx("span",{children:vt})]}),(s||B||le)&&f.jsx("div",{className:"mb-3 rounded-xl border border-border bg-card px-3 py-2 text-xs text-muted-foreground",children:s?"Cargando costos guardados…":"Cargando tarifario…"}),f.jsxs("div",{className:"space-y-4",children:[pe?ve.map(oe=>{const se=L.filter(Ye=>Ye.section===oe.id&&ud(Ye)>0),Re=t.filter(Ye=>Ep(Ye,oe)),De=Re.map(Ye=>Ye.serviceName),ht=Re.reduce((Ye,mt)=>Ye+Number(mt.amount||0),0);return f.jsxs("div",{className:"space-y-4 rounded-xl border border-primary/20 bg-card p-4",children:[f.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium",children:oe.name}),f.jsx("p",{className:"text-xs text-muted-foreground",children:oe.description||"Selecciona una o varias piezas. Cada pieza se carga una sola vez con su monto fijo."})]}),f.jsx(yn,{className:"w-fit",children:oe.clientName})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Piezas a cotizar"}),f.jsx(pg,{values:De,options:se.map(Ye=>Ye.service),onValuesChange:Ye=>Q(oe,Ye),placeholder:"Seleccionar una o varias piezas…",searchPlaceholder:"Buscar pieza…",emptyText:"No se encontró esa pieza en este tarifario.",disabled:B||se.length===0,summaryLabel:"piezas seleccionadas"})]}),f.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-3",children:[f.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[f.jsx("p",{className:"text-xs font-medium text-foreground",children:"Piezas y montos fijos"}),f.jsxs("p",{className:"text-xs font-semibold text-primary",children:["Subtotal: ",wl(ht)]})]}),se.length===0?f.jsx("p",{className:"text-xs text-muted-foreground",children:"Este tarifario todavía no tiene piezas activas. Agrégalas desde el módulo Tarifario."}):f.jsx("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:se.map(Ye=>{const mt=De.some(zt=>Te(zt)===Te(Ye.service));return f.jsxs("div",{className:xe("flex items-center justify-between gap-3 rounded-lg border px-2.5 py-2 text-xs",mt?"border-primary/30 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground"),children:[f.jsx("span",{className:"min-w-0 truncate",children:Ye.service}),f.jsx("span",{className:"flex-shrink-0 font-semibold text-foreground",children:wl(ud(Ye))})]},Ye.id)})})]})]},oe.id)}):f.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium",children:"Agregar desde tarifario general"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Referencia flexible. El usuario autorizado decide el monto final."})]}),f.jsx(yn,{variant:"secondary",children:"Tarifario"})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Sección"}),f.jsx(xr,{value:(O==null?void 0:O.name)||"",options:de.map(oe=>oe.name),onValueChange:I,placeholder:"Seleccionar sección…",searchPlaceholder:"Buscar sección…",emptyText:"No hay secciones generales activas."})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Ítem a cobrar"}),f.jsx(xr,{value:d,options:K,onValueChange:X,placeholder:"Seleccionar ítem…",searchPlaceholder:"Buscar ítem…",emptyText:"No se encontró ese ítem.",disabled:!O})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Tipo de trabajo"}),f.jsx(xr,{value:Qe,options:(W==null?void 0:W.workTypes.map(oe=>oe.label))||[],onValueChange:H,placeholder:"Seleccionar tipo…",searchPlaceholder:"Buscar tipo…",disabled:!W})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Nivel / referencia"}),f.jsx(xr,{value:Ze,options:(J==null?void 0:J.levels.map(oe=>oe.label))||[],onValueChange:te,placeholder:"Seleccionar nivel…",searchPlaceholder:"Buscar nivel…",disabled:!J})]})]}),W&&J&&V&&f.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[f.jsxs("p",{children:[f.jsx("span",{className:"font-medium text-foreground",children:"Referencia:"})," ",gg(V)," USD",J.hourReference?` · Hora hombre ref.: ${J.hourReference}`:""]}),W.notes&&f.jsx("p",{className:"mt-1",children:W.notes}),V.hint&&f.jsx("p",{className:"mt-1",children:V.hint})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-[220px_minmax(0,1fr)]",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Monto final"}),f.jsx(lt,{type:"number",min:"0",step:"0.01",value:w,onChange:oe=>E(oe.target.value),placeholder:"0.00",disabled:!V})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Observación"}),f.jsx(fa,{value:S,onChange:oe=>N(oe.target.value),placeholder:"Ej: más rondas de cambios, piezas adicionales, complejidad especial…",disabled:!V,rows:5,className:"min-h-[132px] resize-y"})]})]}),f.jsx("div",{className:"flex justify-end",children:f.jsxs(ke,{type:"button",onClick:ee,disabled:!W||!J||!V||Fu(w)<=0,className:"gap-1.5 rounded-full",children:[f.jsx(Pr,{className:"h-4 w-4"}),"Agregar tarifa"]})})]}),Ne&&f.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium",children:re?`Agregar propuesta o costo manual para ${re.clientName}`:"Agregar costo manual"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:re?"Para propuestas generales, proyectos por concepto o casos no contemplados por pieza.":"Para otros, adicionales o casos fuera del tarifario."})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-[minmax(0,1fr)_220px]",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Nombre"}),f.jsx(lt,{value:C,onChange:oe=>A(oe.target.value),placeholder:re?`Ej: Propuesta general ${re.clientName}`:"Ej: Piezas adicionales"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Monto"}),f.jsx(lt,{type:"number",min:"0",step:"0.01",value:U,onChange:oe=>z(oe.target.value),placeholder:"0.00"})]})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Descripción"}),f.jsx(fa,{value:T,onChange:oe=>M(oe.target.value),placeholder:re?"Ej: Compendio cotizado por proyecto, no por piezas.":"Ej: Cliente pidió piezas adicionales fuera del paquete.",rows:4,className:"min-h-[110px] resize-y"})]}),f.jsx("div",{className:"flex justify-end",children:f.jsxs(ke,{type:"button",variant:"outline",onClick:ze,disabled:Fu(U)<=0,className:"w-full gap-1.5 rounded-full sm:w-auto sm:min-w-[240px]",children:[f.jsx(Pr,{className:"h-4 w-4"}),"Agregar costo manual"]})})]})]}),f.jsx(zs,{className:"my-4"}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("p",{className:"text-sm font-medium",children:"Costos agregados"}),f.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.length," línea(s)"]})]}),t.length===0?f.jsx("div",{className:"rounded-xl border border-dashed border-border bg-card/70 px-3 py-3 text-sm text-muted-foreground",children:"Aún no hay costos agregados. Usa el tarifario disponible o agrega un monto manual."}):f.jsxs("div",{className:"space-y-2",children:[t.map((oe,se)=>{const Re=ue.find(Ye=>Ye.id===oe.tariffSectionId&&Ye.scope==="client"),De=!Re&&ve.find(Ye=>aj(oe,Ye)),ht=Re||De;return f.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card px-3 py-3 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx(yn,{variant:oe.source==="manual"?"outline":"secondary",children:oe.source==="manual"?"Manual":ht?ht.clientName:"Tarifario"}),f.jsx("p",{className:"text-sm font-medium",children:oe.serviceName})]}),f.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[oe.category&&f.jsx("span",{children:oe.category}),oe.workType&&f.jsx("span",{children:oe.workType}),oe.complexityLevel&&f.jsx("span",{children:oe.complexityLevel}),oe.referenceLabel&&f.jsxs("span",{children:["Ref.: ",oe.referenceLabel]})]}),oe.description&&f.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:oe.description})]}),f.jsxs("div",{className:"flex items-center justify-between gap-3 sm:flex-col sm:items-end",children:[f.jsx("p",{className:"text-sm font-semibold text-foreground",children:wl(Number(oe.amount||0))}),f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",onClick:()=>Oe(se),className:xe("h-8 rounded-full px-2 text-muted-foreground hover:text-destructive"),children:[f.jsx(ef,{className:"mr-1 h-3.5 w-3.5"}),"Quitar"]})]})]},`${oe.source}-${oe.serviceName}-${se}`)}),f.jsxs("div",{className:"flex items-center justify-end gap-2 rounded-xl bg-primary/10 px-3 py-2 text-primary",children:[f.jsx(Jp,{className:"h-4 w-4"}),f.jsxs("span",{className:"text-sm font-semibold",children:["Total interno estimado: ",wl(R)]})]})]})]})]})}const Ls={clientes:wI,marcas:_I,bus:lC,buCm:oC,status:[...SI]};let dd=[],xg=Ls,Kl=!1,sj=!1,Mv=null,Ll=null,Is=null,Gu=0;function wg(){dd.forEach(e=>e())}function Os(e){return et(e)}function Z$(e){const t=new Map(lC.map(n=>[Te(n),n]));return et(e).map(n=>t.get(Te(n))||Vt(n)).filter(n=>!!n)}function eB(e){return String(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function tB(e){const t=eB(e);return["client","clients","cliente","clientes"].includes(t)?"client":["brand","brands","marca","marcas"].includes(t)?"brand":["country","countries","pais","paises","bu","business_unit","business unit"].includes(t)?"country":["status","estatus","estado","estados"].includes(t)?"status":["country_manager","country manager","cm","bu_cm","bu cm","manager","managers"].includes(t)?"country_manager":t}function nB(e){return Vt(String(e.label||e.value||""))}function rB(e){const t=[],n=[],s=[],i=[],l={};for(const c of e){if(c.is_active===!1)continue;const d=tB(c.category),h=nB(c),m=Vt(String(c.value||""));if(!(!h&&!m)&&(d==="client"&&t.push(h||m),d==="brand"&&n.push(h||m),d==="country"&&s.push(h||m),d==="status"&&i.push(h||m),d==="country_manager"&&m)){const b=h||m;b&&b!==m&&(l[m]=b)}}return{clientes:t.length?Os(t):Os(Ls.clientes),marcas:n.length?Os(n):Os(Ls.marcas),bus:s.length?Z$(s):Os(Ls.bus),buCm:s.length?l:{...Ls.buCm},status:i.length?Os(i):Os(Ls.status)}}function aB(e){Mv=e,wg()}async function _g(){Kl=!0,aB(null),wg();try{const{data:e,error:t}=await Ce.from("tablero_cdc_app_lists").select("category, value, label, sort_order, is_active").eq("is_active",!0).order("category",{ascending:!0}).order("sort_order",{ascending:!0}).order("label",{ascending:!0});if(t)throw t;xg=rB(e||[]),sj=!0}catch(e){console.error("Error cargando listas desde Supabase:",e),Mv=e instanceof Error?e.message:"No se pudieron cargar los desplegables desde Supabase.",xg=Ls}finally{Kl=!1,wg()}}function sB(){Is&&clearTimeout(Is),Is=setTimeout(()=>{Is=null,Kl||_g()},350)}function iB(){Ll||(Ll=Ce.channel("tablero-cdc-app-lists").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_app_lists"},()=>sB()).subscribe(e=>{(e==="CHANNEL_ERROR"||e==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo suscribirse a tablero_cdc_app_lists:",e)}))}function oB(){Is&&(clearTimeout(Is),Is=null),Ll&&(Ce.removeChannel(Ll),Ll=null)}function hc(){const[,e]=v.useState(0);return v.useEffect(()=>{const t=()=>e(n=>n+1);return dd.push(t),Gu+=1,iB(),!sj&&!Kl&&_g(),()=>{dd=dd.filter(n=>n!==t),Gu=Math.max(0,Gu-1),Gu===0&&oB()}},[]),{lists:xg,loading:Kl,error:Mv,refresh:_g}}const lB={cr:"Costa Rica","costa rica":"Costa Rica",costarica:"Costa Rica",gt:"Guatemala",gua:"Guatemala",guate:"Guatemala",guatemala:"Guatemala",hn:"Honduras",honduras:"Honduras",ni:"Nicaragua",nicaragua:"Nicaragua",sv:"El Salvador",es:"El Salvador","el salvador":"El Salvador",elsalvador:"El Salvador",pa:"Panama",pty:"Panama",panama:"Panama",rd:"Republica Dominicana",repdom:"Republica Dominicana","republica dominicana":"Republica Dominicana",republicadominicana:"Republica Dominicana",do:"Republica Dominicana",mx:"Mexico",mexico:"Mexico",pr:"Puerto Rico","puerto rico":"Puerto Rico",puertorico:"Puerto Rico",co:"Colombia",colombia:"Colombia",jm:"Jamaica",jamaica:"Jamaica",tt:"Trinidad",trinidad:"Trinidad",ve:"Venezuela",venezuela:"Venezuela",latam:"Latam",wmc:"WMC"},cB=[[/(^|[_\-\s])cr([_\-\s]|$)/i,"Costa Rica"],[/(^|[_\-\s])(gt|gua|guate)([_\-\s]|$)/i,"Guatemala"],[/(^|[_\-\s])hn([_\-\s]|$)/i,"Honduras"],[/(^|[_\-\s])ni([_\-\s]|$)/i,"Nicaragua"],[/(^|[_\-\s])(sv|es)([_\-\s]|$)/i,"El Salvador"],[/(^|[_\-\s])(pa|pty|panama)([_\-\s]|$)/i,"Panama"],[/(^|[_\-\s])(rd|repdom|do)([_\-\s]|$)/i,"Republica Dominicana"],[/(^|[_\-\s])mx([_\-\s]|$)/i,"Mexico"],[/(^|[_\-\s])pr([_\-\s]|$)/i,"Puerto Rico"],[/(^|[_\-\s])co([_\-\s]|$)/i,"Colombia"],[/(^|[_\-\s])jm([_\-\s]|$)/i,"Jamaica"],[/(^|[_\-\s])tt([_\-\s]|$)/i,"Trinidad"],[/(^|[_\-\s])ve([_\-\s]|$)/i,"Venezuela"],[/(^|[_\-\s])latam([_\-\s]|$)/i,"Latam"],[/(^|[_\-\s])wmc([_\-\s]|$)/i,"WMC"]];function po(e){return Vt(String(e??""))}function k_(e,t,n=[]){const s=po(t);if(!s)return;const i=n.find(l=>Te(l)===Te(s));e.push(i||s)}function ij(e,t,n){const s=po(t),i=Te(s);i&&n.forEach(l=>{const c=Te(l);c&&(i===c||i.includes(c))&&e.push(l)})}function Sf(e,t=[]){const n=po(e);if(!n)return[];const s=[];return ij(s,n,t),n.split(/[,;|/]+/).map(i=>po(i)).filter(Boolean).forEach(i=>k_(s,i,t)),s.length===0&&k_(s,n,t),et(s)}function Sg(e,t=[]){const n=po(e);if(!n)return[];const s=[];return ij(s,n,t),n.split(/[,;|/]+/).map(i=>po(i)).filter(Boolean).forEach(i=>{const l=lB[Te(i)],c=t.find(d=>Te(d)===Te(i));l?s.push(l):c&&s.push(c)}),cB.forEach(([i,l])=>{i.test(n)&&s.push(l)}),et(s)}function oj(e,t=[]){const n=[...Sg(e.bu,t),...Sg(e.nombre,t)],s=Te(e.cliente),i=Te(e.nombre);return(s.includes("walmartconnect")||s.includes("wmc")||i.includes("wmc"))&&n.push("WMC"),et(n)}function lj(e,t=[]){return Sf(e.marca,t)}function cj(e,t=[]){return Sf(e.cliente,t)}function uj(e,t=[]){return Sf(e.cm,t)}function Ku(e,t){const n=Te(t);return n?e.some(s=>{const i=Te(s);return i===n||i.includes(n)||n.includes(i)}):!0}function dj(e,t,n={}){if(t.country){const s=oj(e,n.countries||[]);if(!Ku(s,t.country))return!1}if(t.brand){const s=lj(e,n.brands||[]);if(!Ku(s,t.brand))return!1}if(t.client){const s=cj(e,n.clients||[]);if(!Ku(s,t.client))return!1}if(t.cm){const s=uj(e,n.cms||[]);if(!Ku(s,t.cm))return!1}return!0}function uB(e,t=[]){return et(e.flatMap(n=>Sg(n,t)))}function Cp(e,t=[]){return et(e.flatMap(n=>Sf(n,t)))}function fj(e,t={}){return{countries:et(e.flatMap(n=>oj(n,t.countries||[]))),brands:et(e.flatMap(n=>lj(n,t.brands||[]))),clients:et(e.flatMap(n=>cj(n,t.clients||[]))),cms:et(e.flatMap(n=>uj(n,t.cms||[])))}}function hj(e){return!!(e.country||e.brand||e.client||e.cm)}const mj="blue",Ef="Activo",ca={tab:"todos",search:"",page:1,pageSize:24,country:"",brand:"",client:"",cm:""};let fd=[],va=[],Ud=0,pj={countries:[],brands:[],clients:[],cms:[]},Yl=!1,gj=!1,Dv=null,Pl=null,Us=null,Yu=0,Ln={...ca},Ir=0,Wu=0;function Wl(){fd.forEach(e=>e())}function $d(e,t=""){return typeof e=="string"?e:t}function dB(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function fB(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=Number(e.trim());if(Number.isFinite(n))return n}return t}function hB(e,t){return $d(e.legacy_month,"")||$d(e.mes,"")||t.toLocaleString("es-DO",{month:"long"})}function mB(e,t){return fB(e.legacy_year,dB(e.anio,t.getFullYear()))}function pB(e){return!e||e===Ef?"":e}function gB(e){return e&&e.trim()?e:Ef}function vj(e){return{tab:(e==null?void 0:e.tab)??Ln.tab??ca.tab,search:String((e==null?void 0:e.search)??Ln.search??ca.search).trim(),page:Math.max(1,Math.floor(Number((e==null?void 0:e.page)??Ln.page??ca.page))),pageSize:Math.max(1,Math.min(100,Math.floor(Number((e==null?void 0:e.pageSize)??Ln.pageSize??ca.pageSize)))),country:String((e==null?void 0:e.country)??Ln.country??ca.country).trim(),brand:String((e==null?void 0:e.brand)??Ln.brand??ca.brand).trim(),client:String((e==null?void 0:e.client)??Ln.client??ca.client).trim(),cm:String((e==null?void 0:e.cm)??Ln.cm??ca.cm).trim()}}function Cf(e){const t=e.extra_data||{},n=e.project_links||[],s=n.filter(d=>d.link_type==="proposal").map(d=>d.url||"").filter(Boolean),i=n.filter(d=>d.link_type==="final_art").map(d=>d.url||"").filter(Boolean),l=e.created_at?new Date(e.created_at).getTime():Date.now(),c=Number.isFinite(l)?new Date(l):new Date;return{id:e.id,nombre:e.title||"",color:$d(t.color,mj),cliente:e.client||"",bu:e.country||"",cm:e.country_manager||"",marca:e.brand||"",solicitante:e.requested_by||"",comentarios:e.description||"",briefLink:e.brief_link||"",propuestaLinks:s,afLinks:i,status:pB(e.status),monto:e.internal_amount==null?null:Number(e.internal_amount),mes:hB(t,c),anio:mB(t,c),createdAt:Number.isFinite(l)?l:Date.now(),extraData:t}}function vB(e){const t=e.created_at?new Date(e.created_at).getTime():Date.now();return{id:e.id,projectId:e.project_id,type:e.activity_type||"note",title:e.title||"Actividad registrada",description:e.description||"",actorName:e.actor_name||e.actor_email||"Usuario CDC",actorEmail:e.actor_email||"",createdAt:Number.isFinite(t)?t:Date.now()}}function Lv(e){const t=e.created_at?new Date(e.created_at).getTime():Date.now(),n=e.updated_at?new Date(e.updated_at).getTime():t,s=Number(e.duration_minutes??0);return{id:e.id,projectId:e.project_id,country:e.country||"",taskName:e.task_name||"",durationMinutes:Number.isFinite(s)?Math.max(0,s):0,workDate:e.work_date||new Date().toISOString().slice(0,10),notes:e.notes||"",actorName:e.created_by_name||e.created_by_email||"Usuario CDC",actorEmail:e.created_by_email||"",createdAt:Number.isFinite(t)?t:Date.now(),updatedAt:Number.isFinite(n)?n:Date.now()}}function O_(e){const t=e.created_at?new Date(e.created_at).getTime():Date.now(),n=Number(e.amount??0),s=e.reference_min==null?null:Number(e.reference_min),i=e.reference_max==null?null:Number(e.reference_max);return{id:e.id,projectId:e.project_id,source:e.source==="manual"?"manual":"tariff",category:e.category||"",serviceName:e.service_name||"",workType:e.work_type||"",complexityLevel:e.complexity_level||"",referenceLabel:e.reference_label||"",referenceMin:Number.isFinite(s)?s:null,referenceMax:Number.isFinite(i)?i:null,amount:Number.isFinite(n)?n:0,description:e.description||"",tariffSectionId:e.tariff_section_id||"",tariffCatalogId:e.tariff_catalog_id||"",createdAt:Number.isFinite(t)?t:Date.now()}}function Pv(e){var n;const t=e.user_metadata||{};return t.full_name||t.name||t.display_name||((n=e.email)==null?void 0:n.split("@")[0])||"Usuario CDC"}function M_(e){return e&&e.trim()?e:Ef}function Xu(e,t,n){return`${e} ${e===1?t:n}`}function D_(e){return Array.isArray(e)?e.map(t=>String(t||"").trim()).filter(Boolean).join(" | "):String(e??"").trim()}function Ya(e,t,n,s,i){const l=D_(n),c=D_(s);if(l!==c){if(i!=null&&i.privateValue){e.push(`${t} actualizado.`);return}e.push(`${t}: ${l||"—"}${c||"—"}`)}}function yB(e,t,n){const s=[];return Ya(s,"Nombre",e.nombre,t.nombre),Ya(s,"Cliente",e.cliente,t.cliente),Ya(s,"Marca",e.marca,t.marca),Ya(s,"País/BU",e.bu,t.bu),Ya(s,"CM",e.cm,t.cm),Ya(s,"Solicitado por",e.solicitante,t.solicitante),Ya(s,"Estatus",M_(e.status),M_(t.status)),e.color!==t.color&&s.push("Etiqueta de color actualizada."),(e.comentarios||"").trim()!==(t.comentarios||"").trim()&&s.push("Comentarios actualizados."),(e.briefLink||"").trim()!==(t.briefLink||"").trim()&&s.push("Link del brief actualizado."),e.propuestaLinks.join("|")!==t.propuestaLinks.join("|")&&s.push(`Links de propuestas: ${Xu(e.propuestaLinks.length,"link","links")}${Xu(t.propuestaLinks.length,"link","links")}.`),e.afLinks.join("|")!==t.afLinks.join("|")&&s.push(`Links de artes finales: ${Xu(e.afLinks.length,"link","links")}${Xu(t.afLinks.length,"link","links")}.`),n&&Number(e.monto??0)!==Number(t.monto??0)&&Ya(s,"Monto interno",e.monto,t.monto,{privateValue:!0}),s}async function Nf(){const{data:e,error:t}=await Ce.auth.getUser();if(t||!e.user)throw new Error("No hay una sesión activa de Supabase.");return e.user}async function yj(){return(await Nf()).id}async function bB(){return(await Ig()).role==="director_creativo"}async function bj(){return(await Ig()).canManageInternalPricing}async function xB(){return(await Ig()).canDeleteProjects}function xj(e){const t=e.extraData&&typeof e.extraData=="object"&&!Array.isArray(e.extraData)?e.extraData:{};return{title:e.nombre,client:e.cliente,brand:e.marca,country:e.bu,requested_by:e.solicitante,country_manager:e.cm,description:e.comentarios,status:gB(e.status),internal_amount:e.monto??null,brief_link:e.briefLink,extra_data:{...t,color:e.color??$d(t.color,mj),mes:e.mes,anio:e.anio}}}function wB(e,t){const n=t.propuestaLinks.map(i=>i.trim()).filter(Boolean).map((i,l)=>({project_id:e,link_type:"proposal",url:i,label:`Propuesta ${l+1}`})),s=t.afLinks.map(i=>i.trim()).filter(Boolean).map((i,l)=>({project_id:e,link_type:"final_art",url:i,label:`AF ${l+1}`}));return[...n,...s]}function wj(e){va=e,Wl()}function ts(e){return Array.isArray(e)?Array.from(new Set(e.map(t=>String(t??"").trim()).filter(Boolean))).sort((t,n)=>t.localeCompare(n,"es",{sensitivity:"base"})):[]}function _B(e){return{countries:ts(e.map(t=>t.bu)),brands:ts(e.map(t=>t.marca)),clients:ts(e.map(t=>t.cliente)),cms:ts(e.map(t=>t.cm))}}function br(e){Dv=e,Wl()}function _j(e){va.some(n=>n.id===e.id)&&wj(va.map(n=>n.id===e.id?e:n))}function SB(e){va.some(t=>t.id===e)&&(wj(va.filter(t=>t.id!==e)),Ud=Math.max(0,Ud-1),Wl())}function EB(){return"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-proyecto".trim()||""}async function jf(e,t){const n=EB();if(!n)return console.info("No se configuró VITE_WEBHOOK_URL; se omite sincronización con Google Sheet."),{sheetSyncStatus:"skipped",sheetSyncMessage:t==="delete"?"No hay webhook configurado para eliminar el proyecto del Google Sheet.":"Proyecto guardado. No hay webhook configurado para sincronizar el Sheet."};const s=new AbortController,i=window.setTimeout(()=>s.abort(),15e3);try{const l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:e,action:t,source:"tablero-cdc",sent_at:new Date().toISOString()}),signal:s.signal});if(!l.ok){const c=await l.text().catch(()=>""),d=c||`${l.status} ${l.statusText}`.trim();return console.warn("El proyecto se guardó en Supabase, pero n8n no respondió correctamente.",{status:l.status,statusText:l.statusText,errorText:c}),{sheetSyncStatus:"failed",sheetSyncMessage:t==="delete"?`No se pudo eliminar el proyecto del Google Sheet: ${d}`:`Proyecto guardado, pero el Sheet no se pudo sincronizar: ${d}`}}return{sheetSyncStatus:"synced",sheetSyncMessage:t==="delete"?"Proyecto eliminado del Google Sheet.":"Proyecto guardado y sincronizado con el Google Sheet."}}catch(l){const c=l instanceof DOMException&&l.name==="AbortError";return console.warn("El proyecto se guardó en Supabase, pero no se pudo sincronizar con Google Sheet.",l),{sheetSyncStatus:c?"timeout":"failed",sheetSyncMessage:c?t==="delete"?"n8n tardó demasiado en responder. No se eliminó el proyecto para evitar inconsistencias.":"Proyecto guardado, pero n8n tardó demasiado en responder. Revisa el workflow si el Sheet no se actualizó.":t==="delete"?"No se pudo eliminar el proyecto del Google Sheet. No se eliminó el proyecto para evitar inconsistencias.":"Proyecto guardado, pero no se pudo sincronizar con Google Sheet."}}finally{window.clearTimeout(i)}}function L_(){Us&&clearTimeout(Us),Us=setTimeout(()=>{Us=null,!Yl&&Ir===0&&$s(Ln)},350)}function CB(){Pl||(Pl=Ce.channel("tablero-cdc-projects").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_projects"},()=>L_()).on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_project_links"},()=>L_()).subscribe(e=>{(e==="CHANNEL_ERROR"||e==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo suscribirse a proyectos:",e)}))}function NB(){Us&&(clearTimeout(Us),Us=null),Pl&&(Ce.removeChannel(Pl),Pl=null)}async function Sj(e,t){const n=wB(e,t);try{const{error:l}=await Ce.rpc("tablero_cdc_replace_project_links",{p_project_id:e,p_links:n.map(({link_type:c,url:d,label:h})=>({link_type:c,url:d,label:h}))});if(l)throw l;return}catch(l){if(!PB(l))throw l;console.warn("RPC tablero_cdc_replace_project_links no existe todavía. Usando reemplazo de links por delete+insert.",l)}const{error:s}=await Ce.from("tablero_cdc_project_links").delete().eq("project_id",e);if(s)throw s;if(n.length===0)return;const{error:i}=await Ce.from("tablero_cdc_project_links").insert(n);if(i)throw i}function Ej(e){const t=String((e==null?void 0:e.message)||"");return t.includes("tariff_section_id")||t.includes("tariff_catalog_id")||t.includes("schema cache")}async function Cj(e,t){if(!Array.isArray(t))return;const{error:n}=await Ce.from("tablero_cdc_project_pricing_items").delete().eq("project_id",e);if(n)throw n;const s=t.map((d,h)=>({item:d,index:h})).filter(({item:d})=>Number.isFinite(Number(d.amount))&&Number(d.amount)>0).map(({item:d,index:h})=>({project_id:e,source:d.source,category:d.category||"",service_name:d.serviceName||"Costo manual",work_type:d.workType||"",complexity_level:d.complexityLevel||"",reference_label:d.referenceLabel||"",reference_min:d.referenceMin??null,reference_max:d.referenceMax??null,amount:Number(d.amount),description:d.description||"",tariff_section_id:d.tariffSectionId||null,tariff_catalog_id:d.tariffCatalogId||null,sort_order:h}));if(s.length===0)return;const i=await Ce.from("tablero_cdc_project_pricing_items").insert(s);if(!i.error)return;if(!Ej(i.error))throw i.error;const l=s.map(({tariff_section_id:d,tariff_catalog_id:h,...m})=>m),c=await Ce.from("tablero_cdc_project_pricing_items").insert(l);if(c.error)throw c.error}async function jB(e){const n=await Ce.from("tablero_cdc_project_pricing_items").select("id, project_id, source, category, service_name, work_type, complexity_level, reference_label, reference_min, reference_max, amount, description, tariff_section_id, tariff_catalog_id, created_at").eq("project_id",e).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(!n.error)return(n.data||[]).map(O_);if(!Ej(n.error))throw n.error;const s=await Ce.from("tablero_cdc_project_pricing_items").select("id, project_id, source, category, service_name, work_type, complexity_level, reference_label, reference_min, reference_max, amount, description, created_at").eq("project_id",e).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(s.error)throw s.error;return(s.data||[]).map(O_)}async function P_(e,t=20,n=0){const s=Math.max(1,Math.min(50,Math.floor(t))),i=Math.max(0,Math.floor(n)),{data:l,error:c}=await Ce.from("tablero_cdc_project_activity").select("id, project_id, activity_type, title, description, actor_name, actor_email, created_at").eq("project_id",e).order("created_at",{ascending:!1}).range(i,i+s-1);if(c)throw c;return(l||[]).map(vB)}const Np=500;async function TB(e){const t=String(e||"").trim();if(!t)return[];const n=[];let s=0;for(;;){const{data:i,error:l}=await Ce.from("tablero_cdc_project_time_entries").select("id, project_id, country, task_name, duration_minutes, work_date, notes, created_by_name, created_by_email, created_at, updated_at").eq("project_id",t).order("work_date",{ascending:!1}).order("created_at",{ascending:!1}).range(s,s+Np-1);if(l)throw l;const c=i||[];if(n.push(...c),c.length<Np)break;s+=Np}return n.map(Lv)}async function AB(e,t){const n=String(e||"").trim(),s=String(t.country||"").trim(),i=String(t.taskName||"").trim(),l=Math.round(Number(t.durationMinutes||0)),c=String(t.workDate||"").trim(),d=String(t.notes||"").trim();if(!n)throw new Error("No se encontró el proyecto.");if(!s)throw new Error("Selecciona el país.");if(!i)throw new Error("Escribe la tarea realizada.");if(!Number.isFinite(l)||l<=0)throw new Error("La duración debe ser mayor que 0 minutos.");if(!/^\d{4}-\d{2}-\d{2}$/.test(c))throw new Error("Selecciona una fecha válida.");const h=await Nf(),m=Pv(h),b=h.email||"",{data:g,error:x}=await Ce.from("tablero_cdc_project_time_entries").insert({project_id:n,country:s,task_name:i,duration_minutes:l,work_date:c,notes:d,created_by:h.id,created_by_email:b||null,created_by_name:m}).select("id, project_id, country, task_name, duration_minutes, work_date, notes, created_by_name, created_by_email, created_at, updated_at").single();if(x)throw x;return Lv(g)}async function RB(e,t){const n=String(e||"").trim(),s=String(t.country||"").trim(),i=String(t.taskName||"").trim(),l=Math.round(Number(t.durationMinutes||0)),c=String(t.workDate||"").trim(),d=String(t.notes||"").trim();if(!n)throw new Error("No se encontró el registro de tiempo.");if(!s)throw new Error("Selecciona el país.");if(!i)throw new Error("Escribe la tarea realizada.");if(!Number.isFinite(l)||l<=0)throw new Error("La duración debe ser mayor que 0 minutos.");if(!/^\d{4}-\d{2}-\d{2}$/.test(c))throw new Error("Selecciona una fecha válida.");const{data:h,error:m}=await Ce.from("tablero_cdc_project_time_entries").update({country:s,task_name:i,duration_minutes:l,work_date:c,notes:d}).eq("id",n).select("id, project_id, country, task_name, duration_minutes, work_date, notes, created_by_name, created_by_email, created_at, updated_at").single();if(m)throw m;return Lv(h)}async function kB(e){const t=String(e||"").trim();if(!t)throw new Error("No se encontró el registro de tiempo.");const{error:n}=await Ce.from("tablero_cdc_project_time_entries").delete().eq("id",t);if(n)throw n}function OB(e,t,n,s){const i=new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(s),l=n?`${t} (${n})`:t;return`[${i}] ${l}:
${e}`}async function MB(e,t,n,s,i,l){const{data:c,error:d}=await Ce.from("tablero_cdc_projects").select("description").eq("id",e).single();if(d)throw d;const h=String((c==null?void 0:c.description)||"").trim(),m=OB(t,n,s,l),b=h?`${h}
${m}`:m,{error:g}=await Ce.from("tablero_cdc_projects").update({description:b,updated_by:i}).eq("id",e);if(g)throw g;const x=va.find(w=>w.id===e);return x&&_j({...x,comentarios:b}),b}async function DB(e,t){const n=t.trim();if(!n)throw new Error("Escribe una nota antes de agregarla al historial.");const s=await Nf(),i=Pv(s),l=s.email||"",c=new Date,{error:d}=await Ce.from("tablero_cdc_project_activity").insert({project_id:e,activity_type:"note",title:"Comentario agregado",description:n,actor_id:s.id,actor_email:l||null,actor_name:i});if(d)throw d;const h=await MB(e,n,i,l,s.id,c),m=await jf(e,"update");return{comments:h,...m}}async function Nj(e,t,n,s="",i=!1){try{const l=await Nf(),c=Pv(l),{error:d}=await Ce.from("tablero_cdc_project_activity").insert({project_id:e,activity_type:t,title:n,description:s,actor_id:l.id,actor_email:l.email||null,actor_name:c});if(d)throw d}catch(l){if(console.warn("No se pudo registrar la actividad del proyecto:",l),i)throw l instanceof Error?l:new Error("No se pudo registrar la actividad del proyecto.")}}function jj(e){return`
id,
title,
client,
brand,
country,
requested_by,
country_manager,
description,
status,
${e?"internal_amount,":""}
brief_link,
created_at,
extra_data,
project_links:tablero_cdc_project_links (
id,
link_type,
url,
label
)
`}function zv(e){return e instanceof Error?e.message:e&&typeof e=="object"&&"message"in e?String(e.message||""):String(e||"")}function LB(e){const t=zv(e);return t.includes("tablero_cdc_get_projects_paginated")||t.includes("Could not find the function")}function PB(e){const t=zv(e);return t.includes("tablero_cdc_replace_project_links")||t.includes("Could not find the function")}function zB(e){const t=zv(e);return t.includes("tablero_cdc_get_pricing_summary")||t.includes("Could not find the function")}function Tl(e){return e.replace(/[%_]/g,"\\$&").replace(/,/g," ")}function Iv(e,t){let n=e;t.tab==="abiertos"&&(n=n.or("status.is.null,status.eq.,status.eq.Activo")),t.tab==="cerrados"&&(n=n.not("status","is",null).neq("status","").neq("status",Ef));const s=t.search.trim();if(s){const l=`%${Tl(s)}%`;n=n.or(`title.ilike.${l},client.ilike.${l},brand.ilike.${l},country.ilike.${l},requested_by.ilike.${l},country_manager.ilike.${l},description.ilike.${l}`)}return n}function Tj(e,t){let n=Iv(e,t);if(t.country){const s=`%${Tl(t.country)}%`;n=n.or(`country.ilike.${s}`)}if(t.brand){const s=`%${Tl(t.brand)}%`;n=n.or(`brand.ilike.${s}`)}if(t.client){const s=`%${Tl(t.client)}%`;n=n.or(`client.ilike.${s}`)}if(t.cm){const s=`%${Tl(t.cm)}%`;n=n.or(`country_manager.ilike.${s}`)}return n}async function IB(e,t){const n=(e.page-1)*e.pageSize,s=n+e.pageSize-1;let i=Ce.from("tablero_cdc_projects").select(jj(t),{count:"exact"}).order("created_at",{ascending:!1});i=Tj(i,e);const{data:l,error:c,count:d}=await i.range(n,s);if(c)throw c;const h=(l||[]).map(m=>Cf(m));return{projects:h,totalProjects:d??0,filterOptions:_B(h)}}async function UB(e,t){let s=0,i=null;const l=[];for(;i===null||s<i;){let b=Ce.from("tablero_cdc_projects").select(jj(t),{count:"exact"}).order("created_at",{ascending:!1});b=Iv(b,e);const{data:g,error:x,count:w}=await b.range(s,s+1e3-1);if(x)throw x;i===null&&(i=w??(g||[]).length);const E=(g||[]).map(S=>Cf(S));if(l.push(...E),E.length<1e3)break;s+=1e3}const c=fj(l),d=l.filter(b=>dj(b,e,c)),h=(e.page-1)*e.pageSize,m=h+e.pageSize;return{projects:d.slice(h,m),totalProjects:d.length,filterOptions:c}}async function $B(e){var l,c,d,h;const{data:t,error:n}=await Ce.rpc("tablero_cdc_get_projects_paginated",{p_tab:e.tab,p_search:e.search,p_page:e.page,p_page_size:e.pageSize,p_country:e.country||"",p_brand:e.brand||"",p_client:e.client||"",p_cm:e.cm||""});if(n)throw n;const s=t||{},i=Array.isArray(s.projects)?s.projects:[];return{totalProjects:Number(s.total_count||0),projects:i.map(m=>Cf(m)),filterOptions:{countries:ts((l=s.filter_options)==null?void 0:l.countries),brands:ts((c=s.filter_options)==null?void 0:c.brands),clients:ts((d=s.filter_options)==null?void 0:d.clients),cms:ts((h=s.filter_options)==null?void 0:h.cms)}}}async function $s(e){const t=vj(e),n=Wu+=1;Ln=t,Yl=!0,br(null),Wl();try{const s=await bj();let i;if(hj(t)||s)i=await UB(t,s);else try{i=await $B(t)}catch(l){if(!LB(l))throw l;console.warn("RPC tablero_cdc_get_projects_paginated no existe todavía. Usando consulta directa como respaldo temporal.",l),i=await IB(t,s)}if(n!==Wu)return;Ud=i.totalProjects,va=i.projects,pj=i.filterOptions,gj=!0}catch(s){if(n!==Wu)return;console.error("Error cargando proyectos desde Supabase:",s),Dv=s instanceof Error?s.message:"No se pudieron cargar los proyectos desde Supabase."}finally{n===Wu&&(Yl=!1,Wl())}}async function BB(e){br(null),Ir+=1;try{const t=await yj(),n={...xj(e),created_by:t,updated_by:t},{data:s,error:i}=await Ce.from("tablero_cdc_projects").insert(n).select("id").single();if(i)throw br(i.message),i;await Sj(s.id,e),await Cj(s.id,e.pricingItems),await Nj(s.id,"created","Proyecto creado",`${e.nombre||"Proyecto sin título"} quedó registrado en el tablero.`);const l=await jf(s.id,"create");return await $s(Ln),{projectId:s.id,...l}}finally{Ir=Math.max(0,Ir-1)}}async function HB(e,t){br(null),Ir+=1;try{const n=await yj(),s=await bB(),i=await bj(),l=va.find(x=>x.id===e);if(!l){const x="No se encontró el proyecto en la página actual. Recarga el tablero antes de guardar para evitar sobrescribir datos.";throw br(x),new Error(x)}const c={...l,...t},d=xj(c),h=s?{...d,updated_by:n}:i?{title:d.title,client:d.client,brand:d.brand,country:d.country,requested_by:d.requested_by,country_manager:d.country_manager,description:d.description,status:l.status,internal_amount:d.internal_amount,brief_link:d.brief_link,extra_data:d.extra_data,updated_by:n}:{title:d.title,client:d.client,brand:d.brand,country:d.country,requested_by:d.requested_by,country_manager:d.country_manager,description:d.description,status:d.status,brief_link:d.brief_link,extra_data:d.extra_data,updated_by:n},{error:m}=await Ce.from("tablero_cdc_projects").update(h).eq("id",e);if(m)throw br(m.message),m;_j(c),await Sj(e,c),i&&await Cj(e,t.pricingItems);const b=yB(l,c,i);b.length>0&&await Nj(e,"updated","Proyecto actualizado",b.slice(0,8).join(`
`));const g=await jf(e,"update");return await $s(Ln),{projectId:e,...g}}finally{Ir=Math.max(0,Ir-1)}}async function qB(e){br(null),Ir+=1;try{if(!await xB()){const l="No tienes permiso para eliminar proyectos.";throw br(l),new Error(l)}const n=await jf(e,"delete");if(n.sheetSyncStatus!=="synced"){const l=n.sheetSyncMessage||"No se pudo eliminar el proyecto del Google Sheet.";throw br(l),new Error(l)}const{error:s}=await Ce.from("tablero_cdc_project_links").delete().eq("project_id",e);if(s)throw br(s.message),s;const{error:i}=await Ce.from("tablero_cdc_projects").delete().eq("id",e);if(i)throw br(i.message),i;SB(e),await $s(Ln)}finally{Ir=Math.max(0,Ir-1)}}async function VB(e){const{data:t,error:n}=await Ce.rpc("tablero_cdc_get_pricing_summary",{p_tab:e.tab,p_search:e.search,p_country:e.country||"",p_brand:e.brand||"",p_client:e.client||"",p_cm:e.cm||""});if(n)throw n;const s=t||{},i=Number(s.total_amount||0),l=Number(s.project_count||0);return{totalAmount:Number.isFinite(i)?i:0,projectCount:Number.isFinite(l)?l:0,loadedAt:Date.now()}}async function FB(e){let n=0,s=null,i=0;for(;s===null||n<s;){let l=Ce.from("tablero_cdc_projects").select("id, internal_amount",{count:"exact"}).order("created_at",{ascending:!1});l=Tj(l,e);const{data:c,error:d,count:h}=await l.range(n,n+1e3-1);if(d)throw d;s===null&&(s=h??(c||[]).length);const m=c||[];if(m.forEach(b=>{const g=Number(b.internal_amount??0);Number.isFinite(g)&&g>0&&(i+=g)}),m.length<1e3)break;n+=1e3}return{totalAmount:i,projectCount:s??0,loadedAt:Date.now()}}async function GB(e){let n=0,s=null;const i=[];for(;s===null||n<s;){let h=Ce.from("tablero_cdc_projects").select("id, title, client, brand, country, requested_by, country_manager, description, status, internal_amount, brief_link, created_at, extra_data",{count:"exact"}).order("created_at",{ascending:!1});h=Iv(h,e);const{data:m,error:b,count:g}=await h.range(n,n+1e3-1);if(b)throw b;s===null&&(s=g??(m||[]).length);const x=(m||[]).map(w=>Cf(w));if(i.push(...x),x.length<1e3)break;n+=1e3}const l=fj(i),c=i.filter(h=>dj(h,e,l));return{totalAmount:c.reduce((h,m)=>{const b=Number(m.monto??0);return Number.isFinite(b)&&b>0?h+b:h},0),projectCount:c.length,loadedAt:Date.now()}}async function z_(e){const t=vj({...e,page:1,pageSize:1e3});if(hj(t))return GB(t);try{return await VB(t)}catch(n){if(!zB(n))throw n;return console.warn("RPC tablero_cdc_get_pricing_summary no existe todavía. Usando suma directa como respaldo temporal.",n),FB(t)}}function KB(e,t){const[n,s]=v.useState({totalAmount:0,projectCount:0,loadedAt:null}),[i,l]=v.useState(!1),[c,d]=v.useState(null),h=e.tab,m=e.search,b=e.country,g=e.brand,x=e.client,w=e.cm;return v.useEffect(()=>{if(!t){s({totalAmount:0,projectCount:0,loadedAt:null}),d(null),l(!1);return}let E=!1;return l(!0),d(null),z_({tab:h,search:m,country:b,brand:g,client:x,cm:w,page:1,pageSize:1e3}).then(S=>{E||s(S)}).catch(S=>{E||(console.error("No se pudo calcular el total tarifado filtrado:",S),d(S instanceof Error?S.message:"No se pudo calcular el total tarifado filtrado."))}).finally(()=>{E||l(!1)}),()=>{E=!0}},[t,h,m,b,g,x,w]),{summary:n,loading:i,error:c,refresh:()=>z_(e).then(E=>(s(E),E))}}function Aj(e){const[,t]=v.useState(0),n=e==null?void 0:e.tab,s=e==null?void 0:e.search,i=e==null?void 0:e.page,l=e==null?void 0:e.pageSize,c=e==null?void 0:e.country,d=e==null?void 0:e.brand,h=e==null?void 0:e.client,m=e==null?void 0:e.cm;return v.useEffect(()=>{const b=()=>t(g=>g+1);return fd.push(b),Yu+=1,CB(),()=>{fd=fd.filter(g=>g!==b),Yu=Math.max(0,Yu-1),Yu===0&&NB()}},[]),v.useEffect(()=>{if(n&&i&&l){$s({tab:n,search:s??"",page:i,pageSize:l,country:c??"",brand:d??"",client:h??"",cm:m??""});return}!gj&&!Yl&&$s()},[n,s,i,l,c,d,h,m]),{projects:va,totalProjects:Ud,filterOptions:pj,loading:Yl,error:Dv,refresh:()=>$s(e??Ln),add:BB,update:HB,remove:qB}}function YB(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const WB=e=>{switch(e){case"success":return QB;case"info":return e8;case"warning":return ZB;case"error":return t8;default:return null}},XB=Array(12).fill(0),JB=({visible:e,className:t})=>ge.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ge.createElement("div",{className:"sonner-spinner"},XB.map((n,s)=>ge.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),QB=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ge.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),ZB=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ge.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),e8=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ge.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),t8=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ge.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),n8=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ge.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ge.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),r8=()=>{const[e,t]=ge.useState(document.hidden);return ge.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Eg=1;class a8{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:s,...i}=t,l=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Eg++,c=this.toasts.find(h=>h.id===l),d=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(l)&&this.dismissedToasts.delete(l),c?this.toasts=this.toasts.map(h=>h.id===l?(this.publish({...h,...t,id:l,title:s}),{...h,...t,id:l,dismissible:d,title:s}):h):this.addToast({title:s,...i,dismissible:d,id:l}),l},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(s=>s({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let s;n.loading!==void 0&&(s=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let l=s!==void 0,c;const d=i.then(async m=>{if(c=["resolve",m],ge.isValidElement(m))l=!1,this.create({id:s,type:"default",message:m});else if(i8(m)&&!m.ok){l=!1;const g=typeof n.error=="function"?await n.error(`HTTP error! status: ${m.status}`):n.error,x=typeof n.description=="function"?await n.description(`HTTP error! status: ${m.status}`):n.description,E=typeof g=="object"&&!ge.isValidElement(g)?g:{message:g};this.create({id:s,type:"error",description:x,...E})}else if(m instanceof Error){l=!1;const g=typeof n.error=="function"?await n.error(m):n.error,x=typeof n.description=="function"?await n.description(m):n.description,E=typeof g=="object"&&!ge.isValidElement(g)?g:{message:g};this.create({id:s,type:"error",description:x,...E})}else if(n.success!==void 0){l=!1;const g=typeof n.success=="function"?await n.success(m):n.success,x=typeof n.description=="function"?await n.description(m):n.description,E=typeof g=="object"&&!ge.isValidElement(g)?g:{message:g};this.create({id:s,type:"success",description:x,...E})}}).catch(async m=>{if(c=["reject",m],n.error!==void 0){l=!1;const b=typeof n.error=="function"?await n.error(m):n.error,g=typeof n.description=="function"?await n.description(m):n.description,w=typeof b=="object"&&!ge.isValidElement(b)?b:{message:b};this.create({id:s,type:"error",description:g,...w})}}).finally(()=>{l&&(this.dismiss(s),s=void 0),n.finally==null||n.finally.call(n)}),h=()=>new Promise((m,b)=>d.then(()=>c[0]==="reject"?b(c[1]):m(c[1])).catch(b));return typeof s!="string"&&typeof s!="number"?{unwrap:h}:Object.assign(s,{unwrap:h})},this.custom=(t,n)=>{const s=(n==null?void 0:n.id)||Eg++;return this.create({jsx:t(s),id:s,...n}),s},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Dn=new a8,s8=(e,t)=>{const n=(t==null?void 0:t.id)||Eg++;return Dn.addToast({title:e,...t,id:n}),n},i8=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",o8=s8,l8=()=>Dn.toasts,c8=()=>Dn.getActiveToasts(),ot=Object.assign(o8,{success:Dn.success,info:Dn.info,warning:Dn.warning,error:Dn.error,custom:Dn.custom,message:Dn.message,promise:Dn.promise,dismiss:Dn.dismiss,loading:Dn.loading},{getHistory:l8,getToasts:c8});YB("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Ju(e){return e.label!==void 0}const u8=3,d8="24px",f8="16px",I_=4e3,h8=356,m8=14,p8=45,g8=200;function kr(...e){return e.filter(Boolean).join(" ")}function v8(e){const[t,n]=e.split("-"),s=[];return t&&s.push(t),n&&s.push(n),s}const y8=e=>{var t,n,s,i,l,c,d,h,m;const{invert:b,toast:g,unstyled:x,interacting:w,setHeights:E,visibleToasts:S,heights:N,index:C,toasts:A,expanded:T,removeToast:M,defaultRichColors:U,closeButton:z,style:L,cancelButtonStyle:B,actionButtonStyle:q,className:ue="",descriptionClassName:le="",duration:he,position:de,gap:ve,expandByDefault:pe,classNames:O,icons:K,closeButtonAriaLabel:W="Close toast"}=e,[J,V]=ge.useState(null),[R,k]=ge.useState(null),[I,X]=ge.useState(!1),[H,te]=ge.useState(!1),[ee,Q]=ge.useState(!1),[re,Ne]=ge.useState(!1),[ze,Oe]=ge.useState(!1),[Qe,Ze]=ge.useState(0),[vt,oe]=ge.useState(0),se=ge.useRef(g.duration||he||I_),Re=ge.useRef(null),De=ge.useRef(null),ht=C===0,Ye=C+1<=S,mt=g.type,zt=g.dismissible!==!1,qe=g.className||"",ce=g.descriptionClassName||"",Pe=ge.useMemo(()=>N.findIndex(Se=>Se.toastId===g.id)||0,[N,g.id]),ct=ge.useMemo(()=>{var Se;return(Se=g.closeButton)!=null?Se:z},[g.closeButton,z]),tn=ge.useMemo(()=>g.duration||he||I_,[g.duration,he]),Dt=ge.useRef(0),Gt=ge.useRef(0),dn=ge.useRef(0),gn=ge.useRef(null),[fn,Nt]=de.split("-"),Kt=ge.useMemo(()=>N.reduce((Se,st,St)=>St>=Pe?Se:Se+st.height,0),[N,Pe]),Tt=r8(),cr=g.invert||b,ur=mt==="loading";Gt.current=ge.useMemo(()=>Pe*ve+Kt,[Pe,Kt]),ge.useEffect(()=>{se.current=tn},[tn]),ge.useEffect(()=>{X(!0)},[]),ge.useEffect(()=>{const Se=De.current;if(Se){const st=Se.getBoundingClientRect().height;return oe(st),E(St=>[{toastId:g.id,height:st,position:g.position},...St]),()=>E(St=>St.filter(hn=>hn.toastId!==g.id))}},[E,g.id]),ge.useLayoutEffect(()=>{if(!I)return;const Se=De.current,st=Se.style.height;Se.style.height="auto";const St=Se.getBoundingClientRect().height;Se.style.height=st,oe(St),E(hn=>hn.find(At=>At.toastId===g.id)?hn.map(At=>At.toastId===g.id?{...At,height:St}:At):[{toastId:g.id,height:St,position:g.position},...hn])},[I,g.title,g.description,E,g.id,g.jsx,g.action,g.cancel]);const It=ge.useCallback(()=>{te(!0),Ze(Gt.current),E(Se=>Se.filter(st=>st.toastId!==g.id)),setTimeout(()=>{M(g)},g8)},[g,M,E,Gt]);ge.useEffect(()=>{if(g.promise&&mt==="loading"||g.duration===1/0||g.type==="loading")return;let Se;return T||w||Tt?(()=>{if(dn.current<Dt.current){const hn=new Date().getTime()-Dt.current;se.current=se.current-hn}dn.current=new Date().getTime()})():(()=>{se.current!==1/0&&(Dt.current=new Date().getTime(),Se=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),It()},se.current))})(),()=>clearTimeout(Se)},[T,w,g,mt,Tt,It]),ge.useEffect(()=>{g.delete&&(It(),g.onDismiss==null||g.onDismiss.call(g,g))},[It,g.delete]);function fe(){var Se;if(K!=null&&K.loading){var st;return ge.createElement("div",{className:kr(O==null?void 0:O.loader,g==null||(st=g.classNames)==null?void 0:st.loader,"sonner-loader"),"data-visible":mt==="loading"},K.loading)}return ge.createElement(JB,{className:kr(O==null?void 0:O.loader,g==null||(Se=g.classNames)==null?void 0:Se.loader),visible:mt==="loading"})}const Ue=g.icon||(K==null?void 0:K[mt])||WB(mt);var me,$e;return ge.createElement("li",{tabIndex:0,ref:De,className:kr(ue,qe,O==null?void 0:O.toast,g==null||(t=g.classNames)==null?void 0:t.toast,O==null?void 0:O.default,O==null?void 0:O[mt],g==null||(n=g.classNames)==null?void 0:n[mt]),"data-sonner-toast":"","data-rich-colors":(me=g.richColors)!=null?me:U,"data-styled":!(g.jsx||g.unstyled||x),"data-mounted":I,"data-promise":!!g.promise,"data-swiped":ze,"data-removed":H,"data-visible":Ye,"data-y-position":fn,"data-x-position":Nt,"data-index":C,"data-front":ht,"data-swiping":ee,"data-dismissible":zt,"data-type":mt,"data-invert":cr,"data-swipe-out":re,"data-swipe-direction":R,"data-expanded":!!(T||pe&&I),"data-testid":g.testId,style:{"--index":C,"--toasts-before":C,"--z-index":A.length-C,"--offset":`${H?Qe:Gt.current}px`,"--initial-height":pe?"auto":`${vt}px`,...L,...g.style},onDragEnd:()=>{Q(!1),V(null),gn.current=null},onPointerDown:Se=>{Se.button!==2&&(ur||!zt||(Re.current=new Date,Ze(Gt.current),Se.target.setPointerCapture(Se.pointerId),Se.target.tagName!=="BUTTON"&&(Q(!0),gn.current={x:Se.clientX,y:Se.clientY})))},onPointerUp:()=>{var Se,st,St;if(re||!zt)return;gn.current=null;const hn=Number(((Se=De.current)==null?void 0:Se.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),_a=Number(((st=De.current)==null?void 0:st.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),At=new Date().getTime()-((St=Re.current)==null?void 0:St.getTime()),wn=J==="x"?hn:_a,us=Math.abs(wn)/At;if(Math.abs(wn)>=p8||us>.11){Ze(Gt.current),g.onDismiss==null||g.onDismiss.call(g,g),k(J==="x"?hn>0?"right":"left":_a>0?"down":"up"),It(),Ne(!0);return}else{var _n,Sn;(_n=De.current)==null||_n.style.setProperty("--swipe-amount-x","0px"),(Sn=De.current)==null||Sn.style.setProperty("--swipe-amount-y","0px")}Oe(!1),Q(!1),V(null)},onPointerMove:Se=>{var st,St,hn;if(!gn.current||!zt||((st=window.getSelection())==null?void 0:st.toString().length)>0)return;const At=Se.clientY-gn.current.y,wn=Se.clientX-gn.current.x;var us;const _n=(us=e.swipeDirections)!=null?us:v8(de);!J&&(Math.abs(wn)>1||Math.abs(At)>1)&&V(Math.abs(wn)>Math.abs(At)?"x":"y");let Sn={x:0,y:0};const Zs=dr=>1/(1.5+Math.abs(dr)/20);if(J==="y"){if(_n.includes("top")||_n.includes("bottom"))if(_n.includes("top")&&At<0||_n.includes("bottom")&&At>0)Sn.y=At;else{const dr=At*Zs(At);Sn.y=Math.abs(dr)<Math.abs(At)?dr:At}}else if(J==="x"&&(_n.includes("left")||_n.includes("right")))if(_n.includes("left")&&wn<0||_n.includes("right")&&wn>0)Sn.x=wn;else{const dr=wn*Zs(wn);Sn.x=Math.abs(dr)<Math.abs(wn)?dr:wn}(Math.abs(Sn.x)>0||Math.abs(Sn.y)>0)&&Oe(!0),(St=De.current)==null||St.style.setProperty("--swipe-amount-x",`${Sn.x}px`),(hn=De.current)==null||hn.style.setProperty("--swipe-amount-y",`${Sn.y}px`)}},ct&&!g.jsx&&mt!=="loading"?ge.createElement("button",{"aria-label":W,"data-disabled":ur,"data-close-button":!0,onClick:ur||!zt?()=>{}:()=>{It(),g.onDismiss==null||g.onDismiss.call(g,g)},className:kr(O==null?void 0:O.closeButton,g==null||(s=g.classNames)==null?void 0:s.closeButton)},($e=K==null?void 0:K.close)!=null?$e:n8):null,(mt||g.icon||g.promise)&&g.icon!==null&&((K==null?void 0:K[mt])!==null||g.icon)?ge.createElement("div",{"data-icon":"",className:kr(O==null?void 0:O.icon,g==null||(i=g.classNames)==null?void 0:i.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||fe():null,g.type!=="loading"?Ue:null):null,ge.createElement("div",{"data-content":"",className:kr(O==null?void 0:O.content,g==null||(l=g.classNames)==null?void 0:l.content)},ge.createElement("div",{"data-title":"",className:kr(O==null?void 0:O.title,g==null||(c=g.classNames)==null?void 0:c.title)},g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title),g.description?ge.createElement("div",{"data-description":"",className:kr(le,ce,O==null?void 0:O.description,g==null||(d=g.classNames)==null?void 0:d.description)},typeof g.description=="function"?g.description():g.description):null),ge.isValidElement(g.cancel)?g.cancel:g.cancel&&Ju(g.cancel)?ge.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||B,onClick:Se=>{Ju(g.cancel)&&zt&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,Se),It())},className:kr(O==null?void 0:O.cancelButton,g==null||(h=g.classNames)==null?void 0:h.cancelButton)},g.cancel.label):null,ge.isValidElement(g.action)?g.action:g.action&&Ju(g.action)?ge.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||q,onClick:Se=>{Ju(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,Se),!Se.defaultPrevented&&It())},className:kr(O==null?void 0:O.actionButton,g==null||(m=g.classNames)==null?void 0:m.actionButton)},g.action.label):null)};function U_(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function b8(e,t){const n={};return[e,t].forEach((s,i)=>{const l=i===1,c=l?"--mobile-offset":"--offset",d=l?f8:d8;function h(m){["top","right","bottom","left"].forEach(b=>{n[`${c}-${b}`]=typeof m=="number"?`${m}px`:m})}typeof s=="number"||typeof s=="string"?h(s):typeof s=="object"?["top","right","bottom","left"].forEach(m=>{s[m]===void 0?n[`${c}-${m}`]=d:n[`${c}-${m}`]=typeof s[m]=="number"?`${s[m]}px`:s[m]}):h(d)}),n}const x8=ge.forwardRef(function(t,n){const{id:s,invert:i,position:l="bottom-right",hotkey:c=["altKey","KeyT"],expand:d,closeButton:h,className:m,offset:b,mobileOffset:g,theme:x="light",richColors:w,duration:E,style:S,visibleToasts:N=u8,toastOptions:C,dir:A=U_(),gap:T=m8,icons:M,containerAriaLabel:U="Notifications"}=t,[z,L]=ge.useState([]),B=ge.useMemo(()=>s?z.filter(I=>I.toasterId===s):z.filter(I=>!I.toasterId),[z,s]),q=ge.useMemo(()=>Array.from(new Set([l].concat(B.filter(I=>I.position).map(I=>I.position)))),[B,l]),[ue,le]=ge.useState([]),[he,de]=ge.useState(!1),[ve,pe]=ge.useState(!1),[O,K]=ge.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=ge.useRef(null),J=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=ge.useRef(null),R=ge.useRef(!1),k=ge.useCallback(I=>{L(X=>{var H;return(H=X.find(te=>te.id===I.id))!=null&&H.delete||Dn.dismiss(I.id),X.filter(({id:te})=>te!==I.id)})},[]);return ge.useEffect(()=>Dn.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{L(X=>X.map(H=>H.id===I.id?{...H,delete:!0}:H))});return}setTimeout(()=>{xS.flushSync(()=>{L(X=>{const H=X.findIndex(te=>te.id===I.id);return H!==-1?[...X.slice(0,H),{...X[H],...I},...X.slice(H+1)]:[I,...X]})})})}),[z]),ge.useEffect(()=>{if(x!=="system"){K(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:X})=>{K(X?"dark":"light")})}catch{I.addListener(({matches:H})=>{try{K(H?"dark":"light")}catch(te){console.error(te)}})}},[x]),ge.useEffect(()=>{z.length<=1&&de(!1)},[z]),ge.useEffect(()=>{const I=X=>{var H;if(c.every(Q=>X[Q]||X.code===Q)){var ee;de(!0),(ee=W.current)==null||ee.focus()}X.code==="Escape"&&(document.activeElement===W.current||(H=W.current)!=null&&H.contains(document.activeElement))&&de(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[c]),ge.useEffect(()=>{if(W.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,R.current=!1)}},[W.current]),ge.createElement("section",{ref:n,"aria-label":`${U} ${J}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((I,X)=>{var H;const[te,ee]=I.split("-");return B.length?ge.createElement("ol",{key:I,dir:A==="auto"?U_():A,tabIndex:-1,ref:W,className:m,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":te,"data-x-position":ee,style:{"--front-toast-height":`${((H=ue[0])==null?void 0:H.height)||0}px`,"--width":`${h8}px`,"--gap":`${T}px`,...S,...b8(b,g)},onBlur:Q=>{R.current&&!Q.currentTarget.contains(Q.relatedTarget)&&(R.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:Q=>{Q.target instanceof HTMLElement&&Q.target.dataset.dismissible==="false"||R.current||(R.current=!0,V.current=Q.relatedTarget)},onMouseEnter:()=>de(!0),onMouseMove:()=>de(!0),onMouseLeave:()=>{ve||de(!1)},onDragEnd:()=>de(!1),onPointerDown:Q=>{Q.target instanceof HTMLElement&&Q.target.dataset.dismissible==="false"||pe(!0)},onPointerUp:()=>pe(!1)},B.filter(Q=>!Q.position&&X===0||Q.position===I).map((Q,re)=>{var Ne,ze;return ge.createElement(y8,{key:Q.id,icons:M,index:re,toast:Q,defaultRichColors:w,duration:(Ne=C==null?void 0:C.duration)!=null?Ne:E,className:C==null?void 0:C.className,descriptionClassName:C==null?void 0:C.descriptionClassName,invert:i,visibleToasts:N,closeButton:(ze=C==null?void 0:C.closeButton)!=null?ze:h,interacting:ve,position:I,style:C==null?void 0:C.style,unstyled:C==null?void 0:C.unstyled,classNames:C==null?void 0:C.classNames,cancelButtonStyle:C==null?void 0:C.cancelButtonStyle,actionButtonStyle:C==null?void 0:C.actionButtonStyle,closeButtonAriaLabel:C==null?void 0:C.closeButtonAriaLabel,removeToast:k,toasts:B.filter(Oe=>Oe.position==Q.position),heights:ue.filter(Oe=>Oe.position==Q.position),setHeights:le,expandByDefault:d,gap:T,expanded:he,swipeDirections:t.swipeDirections})})):null}))}),w8="Walmart Connect WMC",_8=new Set(["wmc"]),Gi=15;function S8(e){return new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",year:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(e))}function E8(e){return e.split(`
`).map(t=>t.trim()).filter(Boolean)}function Cg(e){return e.reduce((t,n)=>t+Number(n.amount||0),0)}function C8(e){return e.map(t=>({id:t.id,source:t.source,category:t.category,serviceName:t.serviceName,workType:t.workType,complexityLevel:t.complexityLevel,referenceLabel:t.referenceLabel,referenceMin:t.referenceMin,referenceMax:t.referenceMax,amount:t.amount,description:t.description,tariffSectionId:t.tariffSectionId,tariffCatalogId:t.tariffCatalogId}))}function N8(e,t){if(!t.length||e==null)return!1;const n=Number(e);if(!Number.isFinite(n)||n<=0)return!1;const s=Cg(t);return Math.abs(n-s)>.01}function j8(e,t=[]){const n=Vt(e);if(!n)return[];const s=new Map(et(t).map(h=>[Te(h),h])),i=s.get(Te(n));if(i)return[i];const l=n.split(/[,;]/).map(h=>Vt(h)).filter(Boolean);if(l.length<=1)return et([i||n]);const c=[];let d=0;for(;d<l.length;){let h="",m=d+1;for(let b=l.length;b>d;b-=1){const g=l.slice(d,b).join(", "),x=s.get(Te(g));if(x){h=x,m=b;break}}c.push(h||l[d]),d=m}return et(c)}function T8(e){return et(e.map(t=>Vt(t)).filter(Boolean)).join(", ")}function A8(e,t=[]){const n=Vt(e);if(!n)return[];const s=new Map(et(t).map(c=>[Te(c),c])),i=s.get(Te(n));if(i)return[i];const l=n.split(/[,;]/).map(c=>Vt(c)).filter(Boolean);return l.length<=1?et([i||n]):et(l.map(c=>s.get(Te(c))||c))}function $_(e){return et(e.map(t=>Vt(t)).filter(Boolean)).join(", ")}function Qu(e){return Te(e)===Te(w8)}const B_=()=>{const e=new Date;return{nombre:"",color:"blue",cliente:"",bu:"",cm:"",marca:"",solicitante:"",comentarios:"",briefLink:"",propuestaLinks:[],afLinks:[],status:"",monto:null,mes:EI[e.getMonth()],anio:e.getFullYear()}};function R8({open:e,onOpenChange:t,project:n,onDelete:s,deleting:i=!1}){const{add:l,update:c}=Aj(),{lists:d,loading:h,error:m,refresh:b}=hc(),{isGerardo:g,canDeleteProjects:x,canManageInternalPricing:w}=Xd(),E=!!n,[S,N]=v.useState(B_()),[C,A]=v.useState([]),[T,M]=v.useState(!1),[U,z]=v.useState(""),[L,B]=v.useState(null),[q,ue]=v.useState(null),[le,he]=v.useState([]),[de,ve]=v.useState(!1),[pe,O]=v.useState(null),[K,W]=v.useState(""),[J,V]=v.useState(!1),[R,k]=v.useState(!1),[I,X]=v.useState(!1),[H,te]=v.useState([]),[ee,Q]=v.useState(!1),[re,Ne]=v.useState(null),[ze,Oe]=v.useState(!1),Qe=v.useRef(!1),Ze=j8(S.marca,d.marcas),vt=A8(S.bu,d.bus),oe=et(j_(d.clientes,S.cliente)),se=et([...d.marcas,...Ze]),Re=et([...d.bus,...vt]),De=et(j_(d.status,S.status)),ht=Re.filter(fe=>{const Ue=Te(fe);return!_8.has(Ue)&&Ue.includes(Te(U))}),Ye=Cg(H);v.useEffect(()=>{if(ue(null),B(null),n){const{id:fe,createdAt:Ue,...me}=n,$e=Vt(me.bu);N({...me,bu:$e}),A($e?[$e]:[]),z(""),he([]),V(!1),O(null),W(""),te([]),Ne(null),Oe(!1)}else e&&(N(B_()),A([]),z(""),he([]),V(!1),O(null),W(""),te([]),Ne(null),Oe(!1))},[n,e]);const mt=v.useCallback(async()=>{if(n!=null&&n.id)try{ve(!0),O(null);const fe=await P_(n.id,Gi+1);he(fe.slice(0,Gi)),V(fe.length>Gi)}catch(fe){console.warn("No se pudo cargar el historial del proyecto:",fe),O("No se pudo cargar el historial. Revisa que el SQL de actividad esté ejecutado en Supabase."),he([]),V(!1)}finally{ve(!1)}},[n==null?void 0:n.id]),zt=v.useCallback(async()=>{if(!(!(n!=null&&n.id)||R||!J))try{k(!0),O(null);const fe=await P_(n.id,Gi+1,le.length);he(Ue=>[...Ue,...fe.slice(0,Gi)]),V(fe.length>Gi)}catch(fe){console.warn("No se pudo cargar más historial del proyecto:",fe),O("No se pudo cargar más actividad. Inténtalo nuevamente.")}finally{k(!1)}},[J,le.length,R,n==null?void 0:n.id]);v.useEffect(()=>{!e||!(n!=null&&n.id)||mt()},[e,n==null?void 0:n.id,mt]),v.useEffect(()=>{if(!e||!(n!=null&&n.id)||!w)return;let fe=!1;return(async()=>{try{Q(!0),Ne(null);const me=await jB(n.id),$e=C8(me);fe||(Oe(N8(n.monto,$e)),te($e))}catch(me){console.warn("No se pudo cargar el tarifario del proyecto:",me),fe||(te([]),Ne("No se pudieron cargar los costos guardados. Revisa que el SQL del tarifario esté ejecutado en Supabase."))}finally{fe||Q(!1)}})(),()=>{fe=!0}},[w,e,n==null?void 0:n.id,n==null?void 0:n.monto]);const qe=(fe,Ue)=>N(me=>({...me,[fe]:Ue})),ce=fe=>{Oe(!1),te(fe);const Ue=Number(Cg(fe).toFixed(2));N(me=>me.monto===Ue?me:{...me,monto:Ue})};v.useEffect(()=>{if(!w||!H.length||ze)return;const fe=Number(Ye.toFixed(2));N(Ue=>Ue.monto===fe?Ue:{...Ue,monto:fe})},[w,ze,H.length,Ye]);const Pe=fe=>{const Ue=d.buCm[fe];if(Ue)return Ue;const me=Te(fe),$e=Object.entries(d.buCm).find(([Se])=>Te(Se)===me);return($e==null?void 0:$e[1])??""},ct=fe=>{const Ue=et(fe.map($e=>Vt($e)).filter(Boolean)),me=et(Ue.map(Pe).filter(Boolean));N($e=>({...$e,bu:$_(Ue),cm:me.join(", ")}))},tn=fe=>{const Ue=Vt(fe);N(me=>({...me,cliente:Ue,...Qu(Ue)&&!E?{bu:"",cm:""}:me.cliente&&Qu(me.cliente)?{bu:"",cm:""}:{}})),Qu(Ue)||(A([]),z(""))},Dt=!E&&Qu(S.cliente),Gt=Dt?C:vt,dn=!E&&Gt.length>1,gn=(fe,Ue)=>{const me=Vt(fe);A($e=>Ue?et([...$e,me]):$e.filter(Se=>Te(Se)!==Te(me)))},fn=C.map(fe=>({country:fe,manager:Pe(fe)})),Nt=vt.map(fe=>({country:fe,manager:Pe(fe)})),Kt=S.nombre.trim()&&S.cliente&&S.marca&&S.solicitante.trim()&&(Dt?C.length>0:vt.length>0),Tt=fe=>{if(fe.sheetSyncStatus==="synced"){ot.success(E?"Proyecto actualizado":"Proyecto creado",{description:"Se guardó y se sincronizó con el Google Sheet."});return}if(fe.sheetSyncStatus==="skipped"){ot.success(E?"Proyecto actualizado":"Proyecto creado",{description:"Se guardó. La sincronización con Google Sheet no está configurada."});return}ot.warning("Proyecto guardado con aviso",{description:fe.sheetSyncMessage})},cr=async()=>{if(!(!(n!=null&&n.id)||!K.trim()||I))try{X(!0);const fe=await DB(n.id,K);qe("comentarios",fe.comments),W(""),await mt(),fe.sheetSyncStatus==="synced"?ot.success("Comentario agregado al historial",{description:"También se actualizó la columna Comentarios del Google Sheet."}):fe.sheetSyncStatus==="skipped"?ot.success("Comentario agregado al historial",{description:"Se guardó como comentario interno. La sincronización con Sheet no está configurada."}):ot.warning("Comentario agregado con aviso",{description:fe.sheetSyncMessage})}catch(fe){console.error("Error agregando comentario al historial:",fe);const Ue=fe instanceof Error?fe.message:"No se pudo agregar el comentario al historial.";ot.error("No se pudo agregar el comentario",{description:Ue})}finally{X(!1)}},ur=async()=>{if(!Kt||T||Qe.current)return;Qe.current=!0;const fe=g?S:w?{...S,status:(n==null?void 0:n.status)??""}:{...S,status:(n==null?void 0:n.status)??"",monto:(n==null?void 0:n.monto)??null};try{M(!0),ue(null),B("Guardando y sincronizando con Google Sheet…");const Ue=Gt,me=et(Ue.map(Pe).filter(Boolean)),$e=E&&n?await c(n.id,{...fe,pricingItems:w?H:void 0}):await l({...fe,bu:$_(Ue),cm:me.join(", "),id:crypto.randomUUID(),createdAt:Date.now(),pricingItems:w?H:void 0});Tt($e),t(!1)}catch(Ue){console.error("Error guardando proyecto:",Ue);const me=Ue instanceof Error?Ue.message:"No se pudo guardar el proyecto. Revisa los permisos o intenta de nuevo.";ue(me),ot.error("No se pudo guardar el proyecto",{description:me})}finally{Qe.current=!1,M(!1),B(null)}},It=!!S.status;return f.jsx(Eo,{open:e,onOpenChange:fe=>{T||Qe.current||t(fe)},children:f.jsxs(Ws,{className:"max-w-3xl max-h-[92vh] overflow-y-auto p-0 gap-0",children:[f.jsx("div",{className:"h-2.5 w-full rounded-t-lg",style:{backgroundColor:cC(S.color)}}),f.jsxs("div",{className:"px-7 pt-6 pb-7",children:[f.jsx(Xs,{className:"space-y-3",children:f.jsx("div",{className:"flex items-start justify-between gap-4",children:f.jsxs("div",{className:"flex-1",children:[f.jsx(Js,{className:"text-2xl tracking-tight",children:E?S.nombre||"Sin título":"Nuevo proyecto"}),f.jsxs(Qs,{className:"mt-1 flex items-center gap-2 text-xs",children:[f.jsx(z5,{className:"w-3.5 h-3.5"}),S.mes," · ",S.anio,It&&f.jsx(yn,{variant:"secondary",className:"ml-2",children:"Cerrado"})]})]})})}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 mt-6",children:[f.jsxs("div",{className:"md:col-span-2 space-y-1.5",children:[f.jsxs(Fe,{children:["Nombre del proyecto ",f.jsx("span",{className:"text-destructive",children:"*"})]}),f.jsx(lt,{value:S.nombre,onChange:fe=>qe("nombre",fe.target.value),placeholder:"Ej: Promoción Día de las Madres",className:"h-10"})]}),f.jsxs("div",{className:"md:col-span-2 space-y-2",children:[f.jsx(Fe,{children:"Etiqueta de color"}),f.jsx(VU,{value:S.color,onChange:fe=>qe("color",fe)})]}),f.jsx(zs,{className:"md:col-span-2 my-1"}),(h||m)&&f.jsxs("div",{className:xe("md:col-span-2 flex items-center justify-between gap-3 rounded-xl border px-3 py-2 text-xs",m?"border-amber-300/50 bg-amber-50 text-amber-900":"border-border bg-muted/30 text-muted-foreground"),children:[f.jsx("span",{className:"flex items-center gap-2",children:h?f.jsxs(f.Fragment,{children:[f.jsx(Xt,{className:"h-3.5 w-3.5 animate-spin"}),"Cargando listas…"]}):f.jsxs(f.Fragment,{children:[f.jsx(Ed,{className:"h-3.5 w-3.5"}),"No se pudieron cargar las listas. Se usaron opciones locales."]})}),m&&f.jsx("button",{type:"button",onClick:()=>void b(),className:"font-medium text-amber-950 underline-offset-4 hover:underline",children:"Reintentar"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs(Fe,{children:["Cliente ",f.jsx("span",{className:"text-destructive",children:"*"})]}),f.jsx(xr,{value:S.cliente,options:oe,onValueChange:tn,placeholder:"Seleccionar…",searchPlaceholder:"Buscar cliente…",emptyText:"No se encontró ese cliente."})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs(Fe,{children:["Marca ",f.jsx("span",{className:"text-destructive",children:"*"})]}),f.jsx(pg,{values:Ze,options:se,onValuesChange:fe=>qe("marca",T8(fe)),placeholder:"Seleccionar una o varias marcas…",searchPlaceholder:"Buscar marca…",emptyText:"No se encontró esa marca.",summaryLabel:"marcas seleccionadas"})]}),Dt?f.jsxs("div",{className:"md:col-span-2 space-y-2 rounded-xl border border-primary/20 bg-primary/5 p-3",children:[f.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs(Fe,{children:["BU Solicita (Países) ",f.jsx("span",{className:"text-destructive",children:"*"})]}),f.jsxs("span",{className:"text-xs font-medium text-primary",children:[C.length," seleccionado(s)"]})]}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Para Walmart Connect WMC puedes seleccionar varios países. Todos quedarán asociados a un solo proyecto y una sola fila del Sheet."}),f.jsxs("div",{className:"relative",children:[f.jsx(co,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),f.jsx(lt,{value:U,onChange:fe=>z(fe.target.value),placeholder:"Buscar país…",className:"h-9 pl-9 bg-card"})]}),f.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:ht.map(fe=>{const Ue=C.some($e=>Te($e)===Te(fe)),me=Pe(fe);return f.jsxs("label",{className:xe("flex cursor-pointer items-start gap-2 rounded-lg border bg-card px-3 py-2 text-sm transition-colors",Ue?"border-primary/50 bg-primary/10":"border-border hover:bg-muted/40"),children:[f.jsx(UC,{checked:Ue,onCheckedChange:$e=>gn(fe,$e===!0),className:"mt-0.5"}),f.jsxs("span",{className:"leading-tight",children:[f.jsx("span",{className:"block font-medium",children:fe}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["CM: ",me||"—"]})]})]},fe)})})]}):f.jsxs("div",{className:"md:col-span-2 space-y-1.5",children:[f.jsxs(Fe,{children:["BU Solicita (Países) ",f.jsx("span",{className:"text-destructive",children:"*"})]}),f.jsx(pg,{values:vt,options:Re,onValuesChange:ct,placeholder:"Seleccionar uno o varios países…",searchPlaceholder:"Buscar país…",emptyText:"No se encontró ese país.",summaryLabel:"países seleccionados"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Si seleccionas varios países, todos quedarán asociados a un solo proyecto y una sola fila del Sheet."})]}),f.jsxs("div",{className:xe("space-y-1.5",Dt&&"md:col-span-2"),children:[f.jsxs(Fe,{className:"flex items-center gap-1.5",children:["Country Manager ",f.jsx("span",{className:"text-xs text-muted-foreground",children:"(automático)"})]}),Dt?f.jsx("div",{className:"min-h-10 rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:fn.length===0?f.jsx("span",{className:"text-muted-foreground",children:"Selecciona uno o más países."}):f.jsx("div",{className:"flex flex-wrap gap-1.5",children:fn.map(({country:fe,manager:Ue})=>f.jsxs(yn,{variant:"secondary",className:"font-normal",children:[fe,": ",Ue||"—"]},fe))})}):f.jsx("div",{className:"min-h-10 rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:Nt.length===0?f.jsx("span",{className:"text-muted-foreground",children:"Selecciona uno o más países."}):f.jsx("div",{className:"flex flex-wrap gap-1.5",children:Nt.map(({country:fe,manager:Ue})=>f.jsxs(yn,{variant:"secondary",className:"font-normal",children:[fe,": ",Ue||"—"]},fe))})})]}),dn&&w&&f.jsx("div",{className:"md:col-span-2 rounded-xl border border-amber-300/50 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:"Si seleccionas varios países, el total de la estimación interna corresponde al proyecto completo y no se multiplica por país."}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs(Fe,{children:["Solicitado por ",f.jsx("span",{className:"text-destructive",children:"*"})]}),f.jsx(lt,{value:S.solicitante,onChange:fe=>qe("solicitante",fe.target.value),placeholder:"Nombre de quien solicita",className:"h-10"})]}),f.jsx(k8,{isEdit:E,items:le,loading:de,error:pe,note:K,hasMore:J,loadingMore:R,addingNote:I,onNoteChange:W,onAddNote:cr,onRefresh:mt,onLoadMore:zt}),f.jsx(zs,{className:"md:col-span-2 my-1"}),f.jsxs("div",{className:"md:col-span-2 space-y-1.5",children:[f.jsxs(Fe,{children:["Link del Brief"," ",f.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(carpeta de Fulgencio)"})]}),f.jsx(lt,{value:S.briefLink,onChange:fe=>qe("briefLink",fe.target.value),placeholder:"https://drive.google.com/…",className:"h-10"})]}),f.jsx("div",{className:"md:col-span-2",children:f.jsx(S_,{label:"Links de Propuestas",links:S.propuestaLinks,onChange:fe=>qe("propuestaLinks",fe),emptyText:"Aún no hay propuestas. Pega tantos links como necesites."})}),f.jsx("div",{className:"md:col-span-2",children:f.jsx(S_,{label:"Links de Artes Finales",prefix:"AF",links:S.afLinks,onChange:fe=>qe("afLinks",fe),emptyText:"Aún no hay artes finales."})}),f.jsx(zs,{className:"md:col-span-2 my-1"}),w&&f.jsx(Q$,{client:S.cliente,items:H,onChange:ce,loading:ee,error:re}),f.jsx(zs,{className:"md:col-span-2 my-1"}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs(Fe,{className:"flex items-center gap-1.5 pl-1",children:["Estatus",!g&&f.jsx(T3,{className:"w-3 h-3 text-muted-foreground"})]}),g?f.jsxs(LU,{value:S.status||"_none",onValueChange:fe=>qe("status",fe==="_none"?"":fe),children:[f.jsx(_N,{className:"h-10",children:f.jsx(PU,{placeholder:"Sin estatus"})}),f.jsxs(CN,{children:[f.jsx(fg,{value:"_none",children:"Sin estatus"}),De.map(fe=>f.jsx(fg,{value:fe,children:fe},fe))]})]}):f.jsx("div",{className:"h-10 px-3 flex items-center rounded-md border border-border bg-muted/30 text-sm text-foreground",children:S.status||"Sin estatus"}),!g&&f.jsx("p",{className:"pl-1 text-[11px] text-muted-foreground",children:"Solo el Director Creativo puede cambiar el estatus."})]})]}),(q||L)&&f.jsxs("div",{className:xe("mt-5 flex items-start gap-2 rounded-xl border px-3 py-2 text-sm",q?"border-destructive/30 bg-destructive/5 text-destructive":"border-primary/20 bg-primary/5 text-primary"),children:[q?f.jsx(Ed,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}):f.jsx(Xt,{className:"mt-0.5 h-4 w-4 flex-shrink-0 animate-spin"}),f.jsx("span",{children:q||L})]})]}),f.jsx(pf,{className:"px-7 py-4 border-t bg-muted/30 rounded-b-lg sm:justify-between",children:f.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[f.jsx("div",{children:E&&n&&x&&s&&f.jsxs(ke,{type:"button",variant:"destructive",onClick:()=>s(n),disabled:T||i,className:"gap-1.5 rounded-full",children:[i?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):f.jsx(ef,{className:"h-4 w-4"}),i?"Eliminando…":"Eliminar proyecto"]})}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ke,{variant:"ghost",onClick:()=>{T||Qe.current||t(!1)},disabled:T||i,children:"Cancelar"}),f.jsxs(ke,{onClick:ur,disabled:!Kt||T||i,children:[T&&f.jsx(Xt,{className:"mr-1.5 h-4 w-4 animate-spin"}),T?"Guardando…":E?"Guardar cambios":"Crear proyecto"]})]})]})})]})})}function k8({isEdit:e,items:t,loading:n,error:s,note:i,hasMore:l,loadingMore:c,addingNote:d,onNoteChange:h,onAddNote:m,onRefresh:b,onLoadMore:g}){return f.jsxs("div",{className:"md:col-span-2 rounded-2xl border border-border bg-muted/20 p-4",children:[f.jsxs("div",{className:"mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{className:"flex items-start gap-2.5",children:[f.jsx("span",{className:"mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary",children:f.jsx(f3,{className:"h-4 w-4"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-semibold",children:"Actividad del proyecto"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Comentarios y movimientos recientes con fecha."})]})]}),e&&f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",onClick:()=>void b(),disabled:n,className:"h-8 rounded-full px-2.5 text-xs text-muted-foreground hover:text-foreground",children:[n?f.jsx(Xt,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):null,"Actualizar"]})]}),e?f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"rounded-xl border border-border bg-card p-3",children:[f.jsx(Fe,{className:"text-xs font-medium",children:"Agregar comentario o solicitud adicional"}),f.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[f.jsx(fa,{value:i,onChange:x=>h(x.target.value),placeholder:"Ej: CM pidió ajustar artes, agregar una marca o cambiar una fecha…",rows:2,className:"min-h-[64px] flex-1 resize-none"}),f.jsxs(ke,{type:"button",onClick:()=>void m(),disabled:!i.trim()||d,className:"gap-1.5 rounded-full sm:self-end",children:[d?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):f.jsx(M3,{className:"h-4 w-4"}),"Agregar"]})]})]}),s&&f.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-amber-300/50 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:[f.jsx(Ed,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0"}),f.jsx("span",{children:s})]}),n&&t.length===0?f.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-border bg-card px-3 py-3 text-sm text-muted-foreground",children:[f.jsx(Xt,{className:"h-4 w-4 animate-spin"}),"Cargando actividad…"]}):t.length===0?f.jsx("div",{className:"rounded-xl border border-border bg-card px-3 py-3 text-sm text-muted-foreground",children:"Aún no hay actividad registrada. Los próximos comentarios o cambios quedarán aquí."}):f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between gap-3 px-0.5 text-[11px] text-muted-foreground",children:[f.jsx("span",{children:"Mostrando los movimientos más recientes."}),f.jsxs("span",{children:[t.length," visibles"]})]}),f.jsx("div",{className:"max-h-[440px] space-y-2 overflow-y-auto pr-1",children:t.map(x=>{const w=E8(x.description);return f.jsxs("div",{className:"rounded-xl border border-border bg-card px-3 py-3 shadow-sm",children:[f.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium",children:x.title}),f.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.actorName,x.actorEmail?` · ${x.actorEmail}`:""]})]}),f.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[f.jsx(Ol,{className:"h-3.5 w-3.5"}),S8(x.createdAt)]})]}),w.length>0&&f.jsx("div",{className:"mt-2 space-y-1 text-sm text-muted-foreground",children:w.map(E=>f.jsx("p",{children:E},E))})]},x.id)})}),l&&f.jsx("div",{className:"flex justify-center pt-1",children:f.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:()=>void g(),disabled:c,className:"rounded-full",children:[c?f.jsx(Xt,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,c?"Cargando…":"Cargar más"]})})]})]}):f.jsx("div",{className:"rounded-xl border border-dashed border-border bg-card/70 px-3 py-3 text-sm text-muted-foreground",children:"El historial se activará cuando el proyecto sea creado."})]})}const O8="https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-registro-horas";function M8(){return"".trim()||O8}async function D8(e,t,n=2e4){const s=new AbortController,i=window.setTimeout(()=>s.abort(),n);try{return await fetch(e,{...t,signal:s.signal})}finally{window.clearTimeout(i)}}function L8(e){return new Promise(t=>window.setTimeout(t,e))}async function jp(e){const t=String(e||"").trim();if(!t)throw new Error("No se encontró el proyecto para sincronizar las horas.");const{data:{session:n},error:s}=await Ce.auth.getSession();if(s)throw s;if(!(n!=null&&n.access_token))throw new Error("No se encontró una sesión activa para sincronizar el registro de horas.");let i=null;for(let l=1;l<=3;l+=1)try{const c=await D8(M8(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"sync_project",project_id:t,access_token:n.access_token,source:"tablero-cdc-time"})}),d=await c.text();let h=null;if(d)try{h=JSON.parse(d)}catch{h=null}if(!c.ok||(h==null?void 0:h.ok)===!1)throw new Error((h==null?void 0:h.message)||d||`Error ${c.status} al sincronizar Excel.`);return h||{ok:!0,projectId:t}}catch(c){i=c instanceof Error?c:new Error(String(c||"Error de sincronización")),l<3&&await L8(l*1200)}throw i||new Error("No se pudo sincronizar el registro de horas con Excel.")}const Ki=10;function Tp(){const e=new Date,t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().slice(0,10)}function P8(e){return et(String(e||"").split(",").map(t=>t.trim()).filter(Boolean))}function no(e,t=!1){const n=Math.max(0,Math.round(Number(e||0))),s=Math.floor(n/60),i=n%60;return t?s&&i?`${s} h ${i} min`:s?`${s} h`:`${i} min`:s&&i?`${s} ${s===1?"hora":"horas"} ${i} min`:s?`${s} ${s===1?"hora":"horas"}`:`${i} min`}function z8(e){if(!e)return"—";const t=new Date(`${e}T12:00:00`);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",year:"numeric"}).format(t):e}function I8(e){return new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",hour:"numeric",minute:"2-digit"}).format(new Date(e))}function H_(e,t){const n=new Map;for(const s of e){const i=t(s).trim()||"Sin especificar",l=Te(i)||i.toLowerCase(),c=n.get(l);c?c.minutes+=s.durationMinutes:n.set(l,{key:l,label:i,minutes:s.durationMinutes})}return[...n.values()].sort((s,i)=>i.minutes-s.minutes||s.label.localeCompare(i.label,"es"))}function q_(e){const n=(e instanceof Error?e.message:String(e||"")).toLowerCase();return n.includes("tablero_cdc_project_time_entries")||n.includes("relation")||n.includes("schema cache")}function U8({open:e,onOpenChange:t,project:n}){const{lists:s}=hc(),[i,l]=v.useState([]),[c,d]=v.useState(!1),[h,m]=v.useState(!1),[b,g]=v.useState(null),[x,w]=v.useState(null),[E,S]=v.useState(null),[N,C]=v.useState(null),[A,T]=v.useState(""),[M,U]=v.useState(""),[z,L]=v.useState(""),[B,q]=v.useState(""),[ue,le]=v.useState(Tp()),[he,de]=v.useState(""),[ve,pe]=v.useState(1),O=v.useMemo(()=>P8((n==null?void 0:n.bu)||""),[n==null?void 0:n.bu]),K=v.useMemo(()=>et([...O,...s.bus,A]),[A,s.bus,O]),W=v.useMemo(()=>i.reduce((se,Re)=>se+Re.durationMinutes,0),[i]),J=v.useMemo(()=>H_(i,se=>se.country),[i]),V=v.useMemo(()=>H_(i,se=>se.taskName),[i]),R=v.useMemo(()=>et(i.map(se=>se.taskName)).slice(0,8),[i]),k=Math.max(1,Math.ceil(i.length/Ki)),I=Math.min(ve,k),X=(I-1)*Ki,H=i.slice(X,X+Ki),te=i.length===0?0:X+1,ee=Math.min(X+Ki,i.length),Q=v.useCallback(async()=>{if(n!=null&&n.id)try{d(!0),S(null);const se=await TB(n.id);l(se),jp(n.id).then(()=>C(null)).catch(Re=>{console.warn("No se pudo reconciliar el registro de horas con Excel:",Re)})}catch(se){console.error("No se pudo cargar el tiempo del proyecto:",se),l([]),S(q_(se)?"El módulo de tiempo todavía no está instalado en Supabase. Ejecuta supabase_project_time_entries.sql.":se instanceof Error?se.message:"No se pudo cargar el desglose de tiempo.")}finally{d(!1)}},[n==null?void 0:n.id]);v.useEffect(()=>{!e||!(n!=null&&n.id)||(T(O[0]||""),U(""),L(""),q(""),le(Tp()),de(""),C(null),w(null),pe(1),Q())},[Q,e,n==null?void 0:n.id,O]),v.useEffect(()=>{ve>k&&pe(k)},[ve,k]);const re=Math.max(0,Math.floor(Number(z||0)))*60+Math.max(0,Math.floor(Number(B||0))),Ne=Number.isFinite(re)&&re>0,ze=!!(A.trim()&&M.trim()&&ue&&Ne),Oe=!!x,Qe=()=>{T(O[0]||""),U(""),L(""),q(""),le(Tp()),de(""),w(null)},Ze=se=>{const Re=Math.max(0,Math.round(se.durationMinutes));w(se.id),T(se.country),U(se.taskName),L(String(Math.floor(Re/60))),q(String(Re%60)),le(se.workDate),de(se.notes||""),S(null),requestAnimationFrame(()=>{var De;(De=document.querySelector('[data-project-time-form="true"]'))==null||De.scrollIntoView({behavior:"smooth",block:"start"})})},vt=async()=>{if(!(!(n!=null&&n.id)||!ze||h))try{m(!0),S(null);const se={country:A,taskName:M,durationMinutes:re,workDate:ue,notes:he},Re=x?await RB(x,se):await AB(n.id,se);x?l(De=>De.map(ht=>ht.id===Re.id?Re:ht).sort((ht,Ye)=>Ye.workDate.localeCompare(ht.workDate)||Ye.createdAt-ht.createdAt)):(l(De=>[Re,...De]),pe(1)),Qe(),ot.success(x?"Registro de tiempo actualizado":"Tiempo registrado",{description:`${no(Re.durationMinutes,!0)} · ${Re.country} · ${Re.taskName}`});try{await jp(n.id),C(null)}catch(De){console.warn("El tiempo se guardó, pero Excel no pudo sincronizarse todavía:",De),C("El tiempo quedó guardado en el Tablero, pero el Excel no pudo actualizarse ahora. Se reintentará automáticamente al volver a abrir Tiempo."),ot.warning("Tiempo guardado; Excel pendiente",{description:"La app volverá a intentar la sincronización automáticamente."})}}catch(se){console.error("No se pudo registrar el tiempo:",se);const Re=q_(se)?"Ejecuta supabase_project_time_entries.sql en Supabase antes de usar este módulo.":se instanceof Error?se.message:"No se pudo registrar el tiempo.";S(Re),ot.error("No se pudo registrar el tiempo",{description:Re})}finally{m(!1)}},oe=async se=>{if(window.confirm(`¿Eliminar este registro de ${no(se.durationMinutes,!0)} para “${se.taskName}”?`))try{if(g(se.id),await kB(se.id),l(De=>De.filter(ht=>ht.id!==se.id)),x===se.id&&Qe(),ot.success("Registro de tiempo eliminado"),n!=null&&n.id)try{await jp(n.id),C(null)}catch(De){console.warn("El registro se eliminó, pero Excel no pudo sincronizarse todavía:",De),C("El registro se eliminó del Tablero, pero el Excel no pudo actualizarse ahora. Se reintentará automáticamente al volver a abrir Tiempo."),ot.warning("Registro eliminado; Excel pendiente",{description:"La app volverá a intentar la sincronización automáticamente."})}}catch(De){console.error("No se pudo eliminar el registro de tiempo:",De),ot.error("No se pudo eliminar",{description:De instanceof Error?De.message:"Intenta nuevamente."})}finally{g(null)}};return f.jsx(Eo,{open:e,onOpenChange:t,children:f.jsxs(Ws,{className:"max-h-[92vh] max-w-5xl overflow-y-auto p-0 gap-0",children:[f.jsx("div",{className:"border-b border-border bg-muted/20 px-6 py-5 sm:px-7",children:f.jsx(Xs,{children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("span",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:f.jsx(Ol,{className:"h-5 w-5"})}),f.jsxs("div",{className:"min-w-0",children:[f.jsx(Js,{className:"text-xl tracking-tight",children:"Tiempo dedicado"}),f.jsxs(Qs,{className:"mt-1",children:["Desglose por país y tarea para ",f.jsx("span",{className:"font-medium text-foreground",children:(n==null?void 0:n.nombre)||"este proyecto"}),"."]})]})]})})}),f.jsxs("div",{className:"space-y-6 px-6 py-6 sm:px-7",children:[f.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[f.jsx(Ap,{icon:f.jsx(Ol,{className:"h-4 w-4"}),label:"Total dedicado",value:no(W,!0)}),f.jsx(Ap,{icon:f.jsx(Nd,{className:"h-4 w-4"}),label:"Países con tiempo",value:String(J.length)}),f.jsx(Ap,{icon:f.jsx(Cd,{className:"h-4 w-4"}),label:"Tareas registradas",value:String(V.length)})]}),f.jsxs("section",{"data-project-time-form":"true",className:"rounded-2xl border border-border bg-card p-4 sm:p-5",children:[f.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-semibold",children:Oe?"Editar tiempo":"Agregar tiempo"}),f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:Oe?"Modifica los datos del registro seleccionado y guarda los cambios.":"Cada registro queda asociado a este proyecto y al usuario que lo agrega."})]}),f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",className:"h-8 self-start rounded-full px-2.5 text-xs text-muted-foreground",onClick:()=>void Q(),disabled:c,children:[c?f.jsx(Xt,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):f.jsx(Zd,{className:"mr-1.5 h-3.5 w-3.5"}),"Actualizar"]})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12",children:[f.jsxs("div",{className:"space-y-1.5 md:col-span-4",children:[f.jsx(Fe,{children:"País"}),f.jsx(xr,{value:A,options:K,onValueChange:T,placeholder:"Seleccionar país…",searchPlaceholder:"Buscar país…",emptyText:"No se encontró ese país."})]}),f.jsxs("div",{className:"space-y-1.5 md:col-span-4",children:[f.jsx(Fe,{children:"Tarea"}),f.jsx(lt,{value:M,onChange:se=>U(se.target.value),placeholder:"Ej: Diseño, adaptación, reunión…",className:"h-10",maxLength:160})]}),f.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[f.jsx(Fe,{children:"Horas"}),f.jsx(lt,{type:"number",min:0,step:1,inputMode:"numeric",value:z,onChange:se=>L(se.target.value),placeholder:"0",className:"h-10"})]}),f.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[f.jsx(Fe,{children:"Minutos"}),f.jsx(lt,{type:"number",min:0,max:59,step:1,inputMode:"numeric",value:B,onChange:se=>{const Re=se.target.value;if(Re===""){q("");return}q(String(Math.min(59,Math.max(0,Math.floor(Number(Re)||0)))))},placeholder:"0",className:"h-10"})]}),f.jsxs("div",{className:"space-y-1.5 md:col-span-4",children:[f.jsx(Fe,{children:"Fecha"}),f.jsx(lt,{type:"date",value:ue,onChange:se=>le(se.target.value),className:"h-10"})]}),f.jsxs("div",{className:"space-y-1.5 md:col-span-8",children:[f.jsxs(Fe,{children:["Nota ",f.jsx("span",{className:"font-normal text-muted-foreground",children:"(opcional)"})]}),f.jsx(fa,{value:he,onChange:se=>de(se.target.value),placeholder:"Detalle breve de lo realizado…",rows:2,maxLength:600,className:"min-h-[64px] resize-none"})]})]}),R.length>0&&f.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[f.jsx("span",{className:"mr-1 text-[11px] text-muted-foreground",children:"Tareas recientes:"}),R.map(se=>f.jsx("button",{type:"button",onClick:()=>U(se),className:"rounded-full border border-border bg-muted/30 px-2.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:se},se))]}),f.jsxs("div",{className:"mt-4 flex flex-col gap-2 border-t border-border/70 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("p",{className:"text-xs text-muted-foreground",children:["Duración a registrar: ",f.jsx("span",{className:"font-semibold text-foreground",children:no(re,!0)})]}),f.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[Oe&&f.jsx(ke,{type:"button",variant:"outline",onClick:Qe,disabled:h,className:"rounded-full",children:"Cancelar"}),f.jsxs(ke,{type:"button",onClick:()=>void vt(),disabled:!ze||h||c,className:"gap-1.5 rounded-full",children:[h?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):Oe?f.jsx(Gg,{className:"h-4 w-4"}):f.jsx(Pr,{className:"h-4 w-4"}),h?"Guardando…":Oe?"Guardar cambios":"Agregar registro"]})]})]}),N&&f.jsx("div",{className:"mt-4 rounded-xl border border-amber-300/60 bg-amber-50 px-3 py-2 text-xs text-amber-800",children:N}),E&&f.jsx("div",{className:"mt-4 rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:E})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[f.jsx(V_,{icon:f.jsx(Nd,{className:"h-4 w-4"}),title:"Desglose por país",rows:J,totalMinutes:W,emptyText:"Aún no hay países con tiempo registrado."}),f.jsx(V_,{icon:f.jsx(Cd,{className:"h-4 w-4"}),title:"Desglose por tarea",rows:V,totalMinutes:W,emptyText:"Aún no hay tareas con tiempo registrado."})]}),f.jsxs("section",{className:"overflow-hidden rounded-2xl border border-border bg-card",children:[f.jsxs("div",{className:"flex flex-col gap-2 border-b border-border bg-muted/20 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-semibold",children:"Registros detallados"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:i.length===0?"Sin registros todavía.":`Mostrando ${te}-${ee} de ${i.length}.`})]}),i.length>Ki&&f.jsxs("span",{className:"text-xs text-muted-foreground",children:["Página ",I," de ",k]})]}),c&&i.length===0?f.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-12 text-sm text-muted-foreground",children:[f.jsx(Xt,{className:"h-4 w-4 animate-spin"}),"Cargando tiempo…"]}):i.length===0?f.jsxs("div",{className:"px-4 py-10 text-center",children:[f.jsx(Ol,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),f.jsx("p",{className:"mt-2 text-sm font-medium",children:"Aún no hay tiempo registrado"}),f.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Agrega el primer registro usando el formulario de arriba."})]}):f.jsx("div",{className:"divide-y divide-border/70",children:H.map(se=>f.jsx($8,{entry:se,deleting:b===se.id,editing:x===se.id,onEdit:()=>Ze(se),onDelete:()=>void oe(se)},se.id))}),i.length>Ki&&f.jsxs("div",{className:"flex items-center justify-between border-t border-border bg-muted/10 px-4 py-3",children:[f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 rounded-full",disabled:I<=1,onClick:()=>pe(se=>Math.max(1,se-1)),children:[f.jsx(Vg,{className:"h-3.5 w-3.5"}),"Anterior"]}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[I," / ",k]}),f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 rounded-full",disabled:I>=k,onClick:()=>pe(se=>Math.min(k,se+1)),children:["Siguiente",f.jsx(Qd,{className:"h-3.5 w-3.5"})]})]})]})]})]})})}function Ap({icon:e,label:t,value:n}){return f.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card px-4 py-3.5 shadow-sm",children:[f.jsx("span",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:e}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),f.jsx("p",{className:"mt-0.5 truncate text-lg font-semibold tabular-nums text-foreground",children:n})]})]})}function V_({icon:e,title:t,rows:n,totalMinutes:s,emptyText:i}){return f.jsxs("section",{className:"rounded-2xl border border-border bg-card p-4",children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"text-primary",children:e}),f.jsx("h3",{className:"text-sm font-semibold",children:t})]}),n.length===0?f.jsx("p",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-3 py-5 text-center text-xs text-muted-foreground",children:i}):f.jsx("div",{className:"space-y-3",children:n.map(l=>{const c=s>0?l.minutes/s*100:0;return f.jsxs("div",{children:[f.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3 text-xs",children:[f.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:l.label,children:l.label}),f.jsx("span",{className:"flex-shrink-0 font-semibold tabular-nums text-foreground",children:no(l.minutes,!0)})]}),f.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:f.jsx("div",{className:"h-full rounded-full bg-primary/70 transition-[width]",style:{width:`${Math.max(2,Math.min(100,c))}%`}})})]},l.key)})})]})}function $8({entry:e,deleting:t,editing:n,onEdit:s,onDelete:i}){return f.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 py-4 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-start",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("span",{className:"font-medium text-sm text-foreground",children:e.taskName}),f.jsx(yn,{variant:"secondary",className:"h-5 px-1.5 text-[10px] font-normal",children:e.country}),f.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold tabular-nums text-primary",children:no(e.durationMinutes,!0)})]}),e.notes&&f.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-xs leading-relaxed text-muted-foreground",children:e.notes}),f.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[f.jsxs("span",{className:"inline-flex items-center gap-1",children:[f.jsx(L5,{className:"h-3 w-3"}),z8(e.workDate)]}),f.jsxs("span",{className:"inline-flex items-center gap-1",title:e.actorEmail||e.actorName,children:[f.jsx(K3,{className:"h-3 w-3"}),e.actorName]}),f.jsxs("span",{children:["Registrado ",I8(e.createdAt)]})]})]}),f.jsxs("div",{className:"flex items-center justify-self-end gap-1",children:[f.jsx(ke,{type:"button",variant:"ghost",size:"icon",onClick:s,disabled:t,className:xe("h-8 w-8 rounded-full text-muted-foreground hover:bg-primary/10 hover:text-primary",n&&"bg-primary/10 text-primary"),title:"Editar registro",children:f.jsx(Gg,{className:"h-4 w-4"})}),f.jsx(ke,{type:"button",variant:"ghost",size:"icon",onClick:i,disabled:t,className:xe("h-8 w-8 rounded-full text-muted-foreground hover:bg-destructive/10 hover:text-destructive",t&&"text-destructive"),title:"Eliminar registro",children:t?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):f.jsx(ef,{className:"h-4 w-4"})})]})]})}function hd(e){const t=e.trim();return/^https?:\/\//i.test(t)?t:""}function F_(e){const t=hd(e);t&&window.open(t,"_blank","noopener,noreferrer")}function G_(e){return!e||!Number.isFinite(e)?"—":new Intl.DateTimeFormat("es-DO",{day:"2-digit",month:"short",year:"numeric"}).format(new Date(e))}function B8({item:e,mode:t,busy:n=!1,onApprove:s,onReject:i}){const l=t==="rejected",c=hd(e.documentLink)||hd(e.briefLink),d=hd(e.briefLink);return f.jsxs("article",{className:xe("overflow-hidden rounded-2xl border bg-card shadow-sm transition-shadow hover:shadow-md",l?"border-red-200/70":"border-amber-200/80"),children:[f.jsx("div",{className:xe("flex min-h-14 items-start justify-between gap-3 px-4 py-3",l?"bg-red-50":"bg-amber-50"),children:f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5",children:f.jsx(yn,{variant:"secondary",className:xe("h-5 px-2 text-[10px] font-semibold",l?"bg-red-100 text-red-800 hover:bg-red-100":"bg-amber-100 text-amber-900 hover:bg-amber-100"),children:l?"Rechazado":"Nuevo · CDC Brief"})}),f.jsx("h3",{className:"line-clamp-2 text-sm font-semibold leading-snug text-foreground",children:e.title||"Brief sin título"})]})}),f.jsxs("div",{className:"space-y-3 p-4",children:[f.jsxs("div",{className:"space-y-2.5",children:[f.jsx(_l,{icon:f.jsx(jd,{className:"h-3.5 w-3.5"}),label:"Cliente",value:e.client}),f.jsx(_l,{icon:f.jsx(jd,{className:"h-3.5 w-3.5"}),label:"Marca",value:e.brand}),f.jsx(_l,{icon:f.jsx(Nd,{className:"h-3.5 w-3.5"}),label:"País",value:e.country}),f.jsx(_l,{icon:f.jsx(h1,{className:"h-3.5 w-3.5"}),label:"Solicita",value:e.requestedBy}),f.jsx(_l,{icon:f.jsx(M5,{className:"h-3.5 w-3.5"}),label:"Creado",value:G_(e.sourceCreatedAt)})]}),(e.requestType||e.deliverableType||e.deliveryDate)&&f.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-2.5 text-xs",children:[e.requestType&&f.jsxs("p",{children:[f.jsx("span",{className:"text-muted-foreground",children:"Requerimiento:"})," ",f.jsx("span",{className:"font-medium text-foreground",children:e.requestType})]}),e.deliverableType&&f.jsxs("p",{className:e.requestType?"mt-1":"",children:[f.jsx("span",{className:"text-muted-foreground",children:"Entregable:"})," ",f.jsx("span",{className:"font-medium text-foreground",children:e.deliverableType})]}),e.deliveryDate&&f.jsxs("p",{className:e.requestType||e.deliverableType?"mt-1":"",children:[f.jsx("span",{className:"text-muted-foreground",children:"Entrega:"})," ",f.jsx("span",{className:"font-medium text-foreground",children:e.deliveryDate})]})]}),e.summary&&f.jsx("p",{className:"line-clamp-4 text-xs leading-relaxed text-muted-foreground",children:e.summary}),l&&(e.reviewedByName||e.reviewedAt)&&f.jsxs("div",{className:"rounded-xl border border-red-100 bg-red-50/60 px-3 py-2 text-[11px] text-red-800",children:["Revisado",e.reviewedByName?` por ${e.reviewedByName}`:"",e.reviewedAt?` · ${G_(e.reviewedAt)}`:"",e.rejectionReason?` · ${e.rejectionReason}`:""]}),f.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border/70 pt-3",children:[f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-full px-3 text-xs",disabled:!c||n,onClick:()=>F_(c),children:[f.jsx(Fg,{className:"h-3.5 w-3.5"}),"Ver brief"]}),d&&d!==c&&f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 rounded-full px-3 text-xs",disabled:n,onClick:()=>F_(d),children:[f.jsx(u3,{className:"h-3.5 w-3.5"}),"Carpeta"]}),f.jsxs("div",{className:"ml-auto flex gap-2",children:[!l&&f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-full border-red-200 px-3 text-xs text-red-700 hover:bg-red-50 hover:text-red-800",disabled:n||!i,onClick:i,children:[f.jsx(W5,{className:"h-3.5 w-3.5"}),"No aprobar"]}),f.jsxs(ke,{type:"button",size:"sm",className:"h-8 gap-1.5 rounded-full px-3 text-xs",disabled:n||!s,onClick:s,children:[f.jsx(f1,{className:"h-3.5 w-3.5"}),n?"Procesando…":"Aprobar"]})]})]})]})]})}function _l({icon:e,label:t,value:n}){return f.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[f.jsx("span",{className:"mt-0.5 flex-shrink-0 text-muted-foreground",children:e}),f.jsx("span",{className:"w-14 flex-shrink-0 text-muted-foreground",children:t}),f.jsx("span",{className:"truncate font-medium text-foreground",children:n||"—"})]})}function Rp(e,t=Date.now()){if(!e)return t;const n=new Date(e).getTime();return Number.isFinite(n)?n:t}function H8(e){const t=Rp(e.created_at);return{id:e.id,briefId:e.brief_id||"",sourceCreatedAt:Rp(e.source_created_at,t),title:e.title||"",client:e.client||"",brand:e.brand||"",country:e.country||"",requestedBy:e.requested_by||"",requestedByEmail:e.requested_by_email||"",deliveryDate:e.delivery_date||"",briefLink:e.brief_link||"",documentLink:e.document_link||"",summary:e.summary||"",requestType:e.request_type||"",deliverableType:e.deliverable_type||"",reviewStatus:e.review_status==="approved"?"approved":e.review_status==="rejected"?"rejected":"new",rejectionReason:e.rejection_reason||"",approvedProjectId:e.approved_project_id||"",reviewedByName:e.reviewed_by_name||"",reviewedByEmail:e.reviewed_by_email||"",reviewedAt:e.reviewed_at?Rp(e.reviewed_at):null,createdAt:t}}function q8(e){return e.trim().replace(/[%_,]/g," ").replace(/\s+/g," ")}function V8(){return"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-proyecto".trim()||""}async function F8(e){const t=V8();if(!t)return{sheetSyncStatus:"skipped",sheetSyncMessage:"Proyecto aprobado y creado en Supabase. No hay webhook configurado para sincronizar Google Sheet."};const n=new AbortController,s=window.setTimeout(()=>n.abort(),15e3);try{const i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:e,action:"create",source:"tablero-cdc-brief-review",sent_at:new Date().toISOString()}),signal:n.signal});return i.ok?{sheetSyncStatus:"synced",sheetSyncMessage:"Brief aprobado, proyecto Activo creado y Google Sheet sincronizado."}:{sheetSyncStatus:"failed",sheetSyncMessage:`El proyecto quedó Activo en el Tablero, pero el Sheet no se pudo sincronizar: ${await i.text().catch(()=>"")||`${i.status} ${i.statusText}`.trim()}`}}catch(i){const l=i instanceof DOMException&&i.name==="AbortError";return{sheetSyncStatus:l?"timeout":"failed",sheetSyncMessage:l?"El proyecto quedó Activo en el Tablero, pero n8n tardó demasiado en responder. Revisa el Sheet si fuera necesario.":"El proyecto quedó Activo en el Tablero, pero no se pudo sincronizar con Google Sheet."}}finally{window.clearTimeout(s)}}function G8({status:e,search:t,page:n,pageSize:s,enabled:i=!0}){const[l,c]=v.useState([]),[d,h]=v.useState(0),[m,b]=v.useState(!1),[g,x]=v.useState(null),w=v.useRef(0),E=v.useMemo(()=>q8(t),[t]),S=v.useCallback(async()=>{if(!i)return;const A=w.current+=1;b(!0),x(null);try{const T=Math.max(0,(n-1)*s),M=T+s-1;let U=Ce.from("tablero_cdc_brief_inbox").select("id, brief_id, source_created_at, title, client, brand, country, requested_by, requested_by_email, delivery_date, brief_link, document_link, summary, request_type, deliverable_type, review_status, rejection_reason, approved_project_id, reviewed_by_name, reviewed_by_email, reviewed_at, created_at",{count:"exact"}).eq("review_status",e).order("created_at",{ascending:!1});if(E){const q=`%${E}%`;U=U.or(`title.ilike.${q},client.ilike.${q},brand.ilike.${q},country.ilike.${q},requested_by.ilike.${q},requested_by_email.ilike.${q},request_type.ilike.${q},deliverable_type.ilike.${q},summary.ilike.${q}`)}const{data:z,error:L,count:B}=await U.range(T,M);if(L)throw L;if(A!==w.current)return;c((z||[]).map(H8)),h(B??0)}catch(T){if(A!==w.current)return;console.error("Error cargando bandeja de CDC Brief:",T),x(T instanceof Error?T.message:"No se pudieron cargar los briefs pendientes de revisión."),c([]),h(0)}finally{A===w.current&&b(!1)}},[i,E,n,s,e]);v.useEffect(()=>{i&&S()},[i,S]),v.useEffect(()=>{if(!i)return;let A=null;const T=Ce.channel(`tablero-cdc-brief-inbox-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_brief_inbox"},()=>{A&&clearTimeout(A),A=setTimeout(()=>void S(),300)}).subscribe(M=>{(M==="CHANNEL_ERROR"||M==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo suscribirse a tablero_cdc_brief_inbox:",M)});return()=>{A&&clearTimeout(A),Ce.removeChannel(T)}},[i,S,e]);const N=v.useCallback(async A=>{const{data:T,error:M}=await Ce.rpc("tablero_cdc_approve_brief",{p_inbox_id:A});if(M)throw M;const z=String((T||{}).project_id||"").trim();if(!z)throw new Error("Supabase aprobó el brief, pero no devolvió el Project ID.");const L=await F8(z);return await S(),{projectId:z,...L}},[S]),C=v.useCallback(async(A,T="")=>{const{data:M,error:U}=await Ce.rpc("tablero_cdc_reject_brief",{p_inbox_id:A,p_reason:T.trim()||null});if(U)throw U;if((M||{}).ok===!1)throw new Error("Supabase no pudo mover el brief a Rechazados.");await S()},[S]);return{items:l,totalItems:d,loading:m,error:g,refresh:S,approve:N,reject:C}}function K8(e=!0){const[t,n]=v.useState(0),[s,i]=v.useState(!1),[l,c]=v.useState(null),d=v.useRef(0),h=v.useCallback(async()=>{if(!e){n(0);return}const b=d.current+=1;i(!0);try{const{data:g,error:x}=await Ce.rpc("tablero_cdc_get_unseen_brief_count");if(x)throw x;if(b!==d.current)return;const w=Number(g??0);n(Number.isFinite(w)&&w>0?w:0),c(null)}catch(g){if(b!==d.current)return;console.error("Error cargando notificaciones de briefs nuevos:",g),c(g instanceof Error?g.message:"No se pudo actualizar el contador de briefs nuevos.")}finally{b===d.current&&i(!1)}},[e]),m=v.useCallback(async()=>{if(!e)return 0;n(0);try{const{data:b,error:g}=await Ce.rpc("tablero_cdc_mark_briefs_seen");if(g)throw g;const w=Number((b||{}).unseen_count??0),E=Number.isFinite(w)&&w>0?w:0;return n(E),c(null),E}catch(b){throw await h(),b}},[e,h]);return v.useEffect(()=>{if(!e){n(0);return}h()},[e,h]),v.useEffect(()=>{if(!e)return;let b=null;const g=()=>{b&&clearTimeout(b),b=setTimeout(()=>void h(),250)},x=Ce.channel("tablero-cdc-brief-unread-counter").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_brief_inbox"},g).subscribe(N=>{(N==="CHANNEL_ERROR"||N==="TIMED_OUT")&&console.warn("Supabase Realtime no pudo actualizar el contador de briefs:",N)}),w=window.setInterval(()=>{document.visibilityState==="visible"&&h()},3e4),E=()=>void h(),S=()=>{document.visibilityState==="visible"&&h()};return window.addEventListener("focus",E),document.addEventListener("visibilitychange",S),()=>{b&&clearTimeout(b),window.clearInterval(w),window.removeEventListener("focus",E),document.removeEventListener("visibilitychange",S),Ce.removeChannel(x)}},[e,h]),{unreadCount:t,loading:s,error:l,refresh:h,markAllSeen:m}}const Rj="pricing_summary_public";function kj(e){var t;return!!((t=e==null?void 0:e.value)!=null&&t.enabled)}async function Y8(){const{data:e,error:t}=await Ce.from("tablero_cdc_app_settings").select("key, value").eq("key",Rj).maybeSingle();if(t)throw t;return kj(e)}async function W8(e){const{error:t}=await Ce.rpc("tablero_cdc_set_pricing_summary_public",{p_enabled:e});if(t)throw t}function X8(e=!0){const[t,n]=v.useState(!1),[s,i]=v.useState(e),[l,c]=v.useState(!1),[d,h]=v.useState(null),m=v.useCallback(async()=>{if(!e)return!1;i(!0),h(null);try{const g=await Y8();return n(g),g}catch(g){return console.error("No se pudo leer la visibilidad del total tarifado:",g),h(g instanceof Error?g.message:"No se pudo leer la visibilidad del total tarifado."),!1}finally{i(!1)}},[e]),b=v.useCallback(async g=>{c(!0),h(null);try{return await W8(g),n(g),g}catch(x){throw console.error("No se pudo actualizar la visibilidad del total tarifado:",x),h(x instanceof Error?x.message:"No se pudo actualizar la visibilidad del total tarifado."),x}finally{c(!1)}},[]);return v.useEffect(()=>{m()},[m]),v.useEffect(()=>{if(!e)return;const g=Ce.channel("tablero-cdc-pricing-summary-visibility").on("postgres_changes",{event:"*",schema:"public",table:"tablero_cdc_app_settings",filter:`key=eq.${Rj}`},x=>{const w=x.new||x.old;n(kj(w))}).subscribe();return()=>{Ce.removeChannel(g)}},[e]),{isPublic:t,loading:s,saving:l,error:d,refresh:m,setPublicVisibility:b}}function J8(e,t){return v.useReducer((n,s)=>t[n][s]??n,e)}var Uv="ScrollArea",[Oj]=or(Uv),[Q8,lr]=Oj(Uv),Mj=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:i,scrollHideDelay:l=600,...c}=e,[d,h]=v.useState(null),[m,b]=v.useState(null),[g,x]=v.useState(null),[w,E]=v.useState(null),[S,N]=v.useState(null),[C,A]=v.useState(0),[T,M]=v.useState(0),[U,z]=v.useState(!1),[L,B]=v.useState(!1),q=Je(t,le=>h(le)),ue=nc(i);return f.jsx(Q8,{scope:n,type:s,dir:ue,scrollHideDelay:l,scrollArea:d,viewport:m,onViewportChange:b,content:g,onContentChange:x,scrollbarX:w,onScrollbarXChange:E,scrollbarXEnabled:U,onScrollbarXEnabledChange:z,scrollbarY:S,onScrollbarYChange:N,scrollbarYEnabled:L,onScrollbarYEnabledChange:B,onCornerWidthChange:A,onCornerHeightChange:M,children:f.jsx(Le.div,{dir:ue,...c,ref:q,style:{position:"relative","--radix-scroll-area-corner-width":C+"px","--radix-scroll-area-corner-height":T+"px",...e.style}})})});Mj.displayName=Uv;var Dj="ScrollAreaViewport",Lj=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:i,...l}=e,c=lr(Dj,n),d=v.useRef(null),h=Je(t,d,c.onViewportChange);return f.jsxs(f.Fragment,{children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),f.jsx(Le.div,{"data-radix-scroll-area-viewport":"",...l,ref:h,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:f.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});Lj.displayName=Dj;var Hr="ScrollAreaScrollbar",$v=v.forwardRef((e,t)=>{const{forceMount:n,...s}=e,i=lr(Hr,e.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:c}=i,d=e.orientation==="horizontal";return v.useEffect(()=>(d?l(!0):c(!0),()=>{d?l(!1):c(!1)}),[d,l,c]),i.type==="hover"?f.jsx(Z8,{...s,ref:t,forceMount:n}):i.type==="scroll"?f.jsx(e6,{...s,ref:t,forceMount:n}):i.type==="auto"?f.jsx(Pj,{...s,ref:t,forceMount:n}):i.type==="always"?f.jsx(Bv,{...s,ref:t}):null});$v.displayName=Hr;var Z8=v.forwardRef((e,t)=>{const{forceMount:n,...s}=e,i=lr(Hr,e.__scopeScrollArea),[l,c]=v.useState(!1);return v.useEffect(()=>{const d=i.scrollArea;let h=0;if(d){const m=()=>{window.clearTimeout(h),c(!0)},b=()=>{h=window.setTimeout(()=>c(!1),i.scrollHideDelay)};return d.addEventListener("pointerenter",m),d.addEventListener("pointerleave",b),()=>{window.clearTimeout(h),d.removeEventListener("pointerenter",m),d.removeEventListener("pointerleave",b)}}},[i.scrollArea,i.scrollHideDelay]),f.jsx(pn,{present:n||l,children:f.jsx(Pj,{"data-state":l?"visible":"hidden",...s,ref:t})})}),e6=v.forwardRef((e,t)=>{const{forceMount:n,...s}=e,i=lr(Hr,e.__scopeScrollArea),l=e.orientation==="horizontal",c=Af(()=>h("SCROLL_END"),100),[d,h]=J8("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return v.useEffect(()=>{if(d==="idle"){const m=window.setTimeout(()=>h("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(m)}},[d,i.scrollHideDelay,h]),v.useEffect(()=>{const m=i.viewport,b=l?"scrollLeft":"scrollTop";if(m){let g=m[b];const x=()=>{const w=m[b];g!==w&&(h("SCROLL"),c()),g=w};return m.addEventListener("scroll",x),()=>m.removeEventListener("scroll",x)}},[i.viewport,l,h,c]),f.jsx(pn,{present:n||d!=="hidden",children:f.jsx(Bv,{"data-state":d==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:be(e.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:be(e.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),Pj=v.forwardRef((e,t)=>{const n=lr(Hr,e.__scopeScrollArea),{forceMount:s,...i}=e,[l,c]=v.useState(!1),d=e.orientation==="horizontal",h=Af(()=>{if(n.viewport){const m=n.viewport.offsetWidth<n.viewport.scrollWidth,b=n.viewport.offsetHeight<n.viewport.scrollHeight;c(d?m:b)}},10);return go(n.viewport,h),go(n.content,h),f.jsx(pn,{present:s||l,children:f.jsx(Bv,{"data-state":l?"visible":"hidden",...i,ref:t})})}),Bv=v.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,i=lr(Hr,e.__scopeScrollArea),l=v.useRef(null),c=v.useRef(0),[d,h]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=Bj(d.viewport,d.content),b={...s,sizes:d,onSizesChange:h,hasThumb:m>0&&m<1,onThumbChange:x=>l.current=x,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:x=>c.current=x};function g(x,w){return i6(x,c.current,d,w)}return n==="horizontal"?f.jsx(t6,{...b,ref:t,onThumbPositionChange:()=>{if(i.viewport&&l.current){const x=i.viewport.scrollLeft,w=K_(x,d,i.dir);l.current.style.transform=`translate3d(${w}px, 0, 0)`}},onWheelScroll:x=>{i.viewport&&(i.viewport.scrollLeft=x)},onDragScroll:x=>{i.viewport&&(i.viewport.scrollLeft=g(x,i.dir))}}):n==="vertical"?f.jsx(n6,{...b,ref:t,onThumbPositionChange:()=>{if(i.viewport&&l.current){const x=i.viewport.scrollTop,w=K_(x,d);l.current.style.transform=`translate3d(0, ${w}px, 0)`}},onWheelScroll:x=>{i.viewport&&(i.viewport.scrollTop=x)},onDragScroll:x=>{i.viewport&&(i.viewport.scrollTop=g(x))}}):null}),t6=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...i}=e,l=lr(Hr,e.__scopeScrollArea),[c,d]=v.useState(),h=v.useRef(null),m=Je(t,h,l.onScrollbarXChange);return v.useEffect(()=>{h.current&&d(getComputedStyle(h.current))},[h]),f.jsx(Ij,{"data-orientation":"horizontal",...i,ref:m,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Tf(n)+"px",...e.style},onThumbPointerDown:b=>e.onThumbPointerDown(b.x),onDragScroll:b=>e.onDragScroll(b.x),onWheelScroll:(b,g)=>{if(l.viewport){const x=l.viewport.scrollLeft+b.deltaX;e.onWheelScroll(x),qj(x,g)&&b.preventDefault()}},onResize:()=>{h.current&&l.viewport&&c&&s({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Hd(c.paddingLeft),paddingEnd:Hd(c.paddingRight)}})}})}),n6=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...i}=e,l=lr(Hr,e.__scopeScrollArea),[c,d]=v.useState(),h=v.useRef(null),m=Je(t,h,l.onScrollbarYChange);return v.useEffect(()=>{h.current&&d(getComputedStyle(h.current))},[h]),f.jsx(Ij,{"data-orientation":"vertical",...i,ref:m,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Tf(n)+"px",...e.style},onThumbPointerDown:b=>e.onThumbPointerDown(b.y),onDragScroll:b=>e.onDragScroll(b.y),onWheelScroll:(b,g)=>{if(l.viewport){const x=l.viewport.scrollTop+b.deltaY;e.onWheelScroll(x),qj(x,g)&&b.preventDefault()}},onResize:()=>{h.current&&l.viewport&&c&&s({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Hd(c.paddingTop),paddingEnd:Hd(c.paddingBottom)}})}})}),[r6,zj]=Oj(Hr),Ij=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:i,onThumbChange:l,onThumbPointerUp:c,onThumbPointerDown:d,onThumbPositionChange:h,onDragScroll:m,onWheelScroll:b,onResize:g,...x}=e,w=lr(Hr,n),[E,S]=v.useState(null),N=Je(t,q=>S(q)),C=v.useRef(null),A=v.useRef(""),T=w.viewport,M=s.content-s.viewport,U=en(b),z=en(h),L=Af(g,10);function B(q){if(C.current){const ue=q.clientX-C.current.left,le=q.clientY-C.current.top;m({x:ue,y:le})}}return v.useEffect(()=>{const q=ue=>{const le=ue.target;(E==null?void 0:E.contains(le))&&U(ue,M)};return document.addEventListener("wheel",q,{passive:!1}),()=>document.removeEventListener("wheel",q,{passive:!1})},[T,E,M,U]),v.useEffect(z,[s,z]),go(E,L),go(w.content,L),f.jsx(r6,{scope:n,scrollbar:E,hasThumb:i,onThumbChange:en(l),onThumbPointerUp:en(c),onThumbPositionChange:z,onThumbPointerDown:en(d),children:f.jsx(Le.div,{...x,ref:N,style:{position:"absolute",...x.style},onPointerDown:be(e.onPointerDown,q=>{q.button===0&&(q.target.setPointerCapture(q.pointerId),C.current=E.getBoundingClientRect(),A.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),B(q))}),onPointerMove:be(e.onPointerMove,B),onPointerUp:be(e.onPointerUp,q=>{const ue=q.target;ue.hasPointerCapture(q.pointerId)&&ue.releasePointerCapture(q.pointerId),document.body.style.webkitUserSelect=A.current,w.viewport&&(w.viewport.style.scrollBehavior=""),C.current=null})})})}),Bd="ScrollAreaThumb",Uj=v.forwardRef((e,t)=>{const{forceMount:n,...s}=e,i=zj(Bd,e.__scopeScrollArea);return f.jsx(pn,{present:n||i.hasThumb,children:f.jsx(a6,{ref:t,...s})})}),a6=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...i}=e,l=lr(Bd,n),c=zj(Bd,n),{onThumbPositionChange:d}=c,h=Je(t,g=>c.onThumbChange(g)),m=v.useRef(void 0),b=Af(()=>{m.current&&(m.current(),m.current=void 0)},100);return v.useEffect(()=>{const g=l.viewport;if(g){const x=()=>{if(b(),!m.current){const w=o6(g,d);m.current=w,d()}};return d(),g.addEventListener("scroll",x),()=>g.removeEventListener("scroll",x)}},[l.viewport,b,d]),f.jsx(Le.div,{"data-state":c.hasThumb?"visible":"hidden",...i,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:be(e.onPointerDownCapture,g=>{const w=g.target.getBoundingClientRect(),E=g.clientX-w.left,S=g.clientY-w.top;c.onThumbPointerDown({x:E,y:S})}),onPointerUp:be(e.onPointerUp,c.onThumbPointerUp)})});Uj.displayName=Bd;var Hv="ScrollAreaCorner",$j=v.forwardRef((e,t)=>{const n=lr(Hv,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?f.jsx(s6,{...e,ref:t}):null});$j.displayName=Hv;var s6=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,i=lr(Hv,n),[l,c]=v.useState(0),[d,h]=v.useState(0),m=!!(l&&d);return go(i.scrollbarX,()=>{var g;const b=((g=i.scrollbarX)==null?void 0:g.offsetHeight)||0;i.onCornerHeightChange(b),h(b)}),go(i.scrollbarY,()=>{var g;const b=((g=i.scrollbarY)==null?void 0:g.offsetWidth)||0;i.onCornerWidthChange(b),c(b)}),m?f.jsx(Le.div,{...s,ref:t,style:{width:l,height:d,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Hd(e){return e?parseInt(e,10):0}function Bj(e,t){const n=e/t;return isNaN(n)?0:n}function Tf(e){const t=Bj(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function i6(e,t,n,s="ltr"){const i=Tf(n),l=i/2,c=t||l,d=i-c,h=n.scrollbar.paddingStart+c,m=n.scrollbar.size-n.scrollbar.paddingEnd-d,b=n.content-n.viewport,g=s==="ltr"?[0,b]:[b*-1,0];return Hj([h,m],g)(e)}function K_(e,t,n="ltr"){const s=Tf(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,l=t.scrollbar.size-i,c=t.content-t.viewport,d=l-s,h=n==="ltr"?[0,c]:[c*-1,0],m=ig(e,h);return Hj([0,c],[0,d])(m)}function Hj(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function qj(e,t){return e>0&&e<t}var o6=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return(function i(){const l={left:e.scrollLeft,top:e.scrollTop},c=n.left!==l.left,d=n.top!==l.top;(c||d)&&t(),n=l,s=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(s)};function Af(e,t){const n=en(e),s=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(s.current),[]),v.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function go(e,t){const n=en(t);Ft(()=>{let s=0;if(e){const i=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(s),i.unobserve(e)}}},[e,n])}var Vj=Mj,l6=Lj,c6=$j;const Ng=v.forwardRef(({className:e,children:t,...n},s)=>f.jsxs(Vj,{ref:s,className:xe("relative overflow-hidden",e),...n,children:[f.jsx(l6,{className:"h-full w-full rounded-[inherit]",children:t}),f.jsx(Fj,{}),f.jsx(c6,{})]}));Ng.displayName=Vj.displayName;const Fj=v.forwardRef(({className:e,orientation:t="vertical",...n},s)=>f.jsx($v,{ref:s,orientation:t,className:xe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:f.jsx(Uj,{className:"relative flex-1 rounded-full bg-border"})}));Fj.displayName=$v.displayName;var Rf="Switch",[u6]=or(Rf),[d6,f6]=u6(Rf),Gj=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:s,checked:i,defaultChecked:l,required:c,disabled:d,value:h="on",onCheckedChange:m,form:b,...g}=e,[x,w]=v.useState(null),E=Je(t,T=>w(T)),S=v.useRef(!1),N=x?b||!!x.closest("form"):!0,[C,A]=ma({prop:i,defaultProp:l??!1,onChange:m,caller:Rf});return f.jsxs(d6,{scope:n,checked:C,disabled:d,children:[f.jsx(Le.button,{type:"button",role:"switch","aria-checked":C,"aria-required":c,"data-state":Xj(C),"data-disabled":d?"":void 0,disabled:d,value:h,...g,ref:E,onClick:be(e.onClick,T=>{A(M=>!M),N&&(S.current=T.isPropagationStopped(),S.current||T.stopPropagation())})}),N&&f.jsx(Wj,{control:x,bubbles:!S.current,name:s,value:h,checked:C,required:c,disabled:d,form:b,style:{transform:"translateX(-100%)"}})]})});Gj.displayName=Rf;var Kj="SwitchThumb",Yj=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...s}=e,i=f6(Kj,n);return f.jsx(Le.span,{"data-state":Xj(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t})});Yj.displayName=Kj;var h6="SwitchBubbleInput",Wj=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:s=!0,...i},l)=>{const c=v.useRef(null),d=Je(c,l),h=xv(n),m=ev(t);return v.useEffect(()=>{const b=c.current;if(!b)return;const g=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(g,"checked").set;if(h!==n&&w){const E=new Event("click",{bubbles:s});w.call(b,n),b.dispatchEvent(E)}},[h,n,s]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:d,style:{...i.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Wj.displayName=h6;function Xj(e){return e?"checked":"unchecked"}var Jj=Gj,m6=Yj;const Xl=v.forwardRef(({className:e,...t},n)=>f.jsx(Jj,{className:xe("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:f.jsx(m6,{className:xe("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Xl.displayName=Jj.displayName;var kf="Tabs",[p6]=or(kf,[lf]),Qj=lf(),[g6,qv]=p6(kf),Zj=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:i,defaultValue:l,orientation:c="horizontal",dir:d,activationMode:h="automatic",...m}=e,b=nc(d),[g,x]=ma({prop:s,onChange:i,defaultProp:l??"",caller:kf});return f.jsx(g6,{scope:n,baseId:un(),value:g,onValueChange:x,orientation:c,dir:b,activationMode:h,children:f.jsx(Le.div,{dir:b,"data-orientation":c,...m,ref:t})})});Zj.displayName=kf;var eT="TabsList",tT=v.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...i}=e,l=qv(eT,n),c=Qj(n);return f.jsx(V1,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:f.jsx(Le.div,{role:"tablist","aria-orientation":l.orientation,...i,ref:t})})});tT.displayName=eT;var nT="TabsTrigger",rT=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:i=!1,...l}=e,c=qv(nT,n),d=Qj(n),h=iT(c.baseId,s),m=oT(c.baseId,s),b=s===c.value;return f.jsx(F1,{asChild:!0,...d,focusable:!i,active:b,children:f.jsx(Le.button,{type:"button",role:"tab","aria-selected":b,"aria-controls":m,"data-state":b?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:h,...l,ref:t,onMouseDown:be(e.onMouseDown,g=>{!i&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:be(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:be(e.onFocus,()=>{const g=c.activationMode!=="manual";!b&&!i&&g&&c.onValueChange(s)})})})});rT.displayName=nT;var aT="TabsContent",sT=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:i,children:l,...c}=e,d=qv(aT,n),h=iT(d.baseId,s),m=oT(d.baseId,s),b=s===d.value,g=v.useRef(b);return v.useEffect(()=>{const x=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(x)},[]),f.jsx(pn,{present:i||b,children:({present:x})=>f.jsx(Le.div,{"data-state":b?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":h,hidden:!x,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:x&&l})})});sT.displayName=aT;function iT(e,t){return`${e}-trigger-${t}`}function oT(e,t){return`${e}-content-${t}`}var v6=Zj,lT=tT,cT=rT,uT=sT;const dT=v6,Vv=v.forwardRef(({className:e,...t},n)=>f.jsx(lT,{ref:n,className:xe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Vv.displayName=lT.displayName;const qd=v.forwardRef(({className:e,...t},n)=>f.jsx(cT,{ref:n,className:xe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background cursor-pointer transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));qd.displayName=cT.displayName;const y6=v.forwardRef(({className:e,...t},n)=>f.jsx(uT,{ref:n,className:xe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));y6.displayName=uT.displayName;const Yi=6,Zu=10;function kp(e){return e==null||!Number.isFinite(Number(e))?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(Number(e))}function Op(e){const t=Number(String(e||"").replace(/,/g,"").trim());return Number.isFinite(t)?t:null}function b6(e,t){return e==null&&t==null?"":e!=null&&t!=null&&e!==t?`${e} - ${t}`:String(e??t??"")}function x6(e,t){const n=t.reduce((i,l)=>Math.max(i,l.sortOrder),0),s=e==="client"?"Tarifario especial":"Nueva sección";return{id:tj(e,s),name:s,scope:e,clientName:"",pricingMode:e==="client"?"fixed_multi":"guided",allowManual:!0,description:"",sortOrder:n+10,isActive:!0}}function w6(e){return{id:e.id,name:e.name,scope:e.scope,clientName:e.clientName,pricingMode:e.pricingMode,allowManual:e.allowManual,description:e.description,sortOrder:e.sortOrder,isActive:e.isActive}}function _6(e,t){const s=t.filter(l=>l.section===e.id).reduce((l,c)=>Math.max(l,c.sort_order),0),i=e.scope==="client";return{id:"",catalog_item_id:"",section:e.id,category:i?e.name:"",service:"",notes:"",work_type_id:i?"special_fixed":"",work_type_label:i?"Tarifa fija":"",work_type_short_label:i?"Fijo":"",hour_reference:"",level_id:i?"fixed":"",level_label:i?"Precio fijo":"",reference:"",reference_min:null,reference_max:null,level_hint:"",sort_order:s+1,is_active:!0,managed_by:"app"}}function S6(e){return{id:e.id,catalog_item_id:e.catalog_item_id,section:e.section,category:e.category,service:e.service,notes:e.notes,work_type_id:e.work_type_id,work_type_label:e.work_type_label,work_type_short_label:e.work_type_short_label,hour_reference:e.hour_reference,level_id:e.level_id,level_label:e.level_label,reference:e.reference,reference_min:e.reference_min,reference_max:e.reference_max,level_hint:e.level_hint,sort_order:e.sort_order,is_active:e.is_active,managed_by:"app"}}function E6({open:e,onOpenChange:t}){const{lists:n}=hc(),{sections:s,loading:i,error:l,refresh:c}=nj(),{rows:d,loading:h,error:m,refresh:b}=ej(),[g,x]=v.useState("general"),[w,E]=v.useState(""),[S,N]=v.useState(""),[C,A]=v.useState(!1),[T,M]=v.useState(!1),[U,z]=v.useState(null),[L,B]=v.useState(null),[q,ue]=v.useState(!1),[le,he]=v.useState(null),[de,ve]=v.useState(null),[pe,O]=v.useState(!1),[K,W]=v.useState(!1),[J,V]=v.useState(null),[R,k]=v.useState(1),[I,X]=v.useState(1),H=v.useMemo(()=>s.filter(ce=>ce.scope===g).sort((ce,Pe)=>ce.isActive!==Pe.isActive?ce.isActive?-1:1:ce.sortOrder-Pe.sortOrder||ce.name.localeCompare(Pe.name)),[g,s]),te=Math.max(1,Math.ceil(H.length/Yi)),ee=v.useMemo(()=>{const ce=(R-1)*Yi;return H.slice(ce,ce+Yi)},[H,R]),Q=s.find(ce=>ce.id===w)||H[0]||null;v.useEffect(()=>{var ce;if(!Q&&H.length){E(H[0].id);return}Q&&Q.scope!==g&&E(((ce=H[0])==null?void 0:ce.id)||"")},[g,H,Q]),v.useEffect(()=>{e&&Promise.all([c(),b()])},[e,b,c]),v.useEffect(()=>{k(1)},[g]),v.useEffect(()=>{k(ce=>Math.min(ce,te))},[te]),v.useEffect(()=>{if(!w)return;const ce=H.findIndex(ct=>ct.id===w);if(ce<0)return;const Pe=Math.floor(ce/Yi)+1;k(Pe)},[H,w]);const re=v.useMemo(()=>{if(!Q)return[];const ce=S.trim().toLowerCase();return d.filter(Pe=>Pe.section===Q.id).filter(Pe=>C||Pe.is_active).filter(Pe=>ce?[Pe.category,Pe.service,Pe.work_type_label,Pe.level_label,Pe.notes].join(" ").toLowerCase().includes(ce):!0).sort((Pe,ct)=>Pe.sort_order-ct.sort_order||Pe.service.localeCompare(ct.service))},[d,S,Q,C]),Ne=Math.max(1,Math.ceil(re.length/Zu)),ze=v.useMemo(()=>{const ce=(I-1)*Zu;return re.slice(ce,ce+Zu)},[re,I]);v.useEffect(()=>{X(1)},[S,Q==null?void 0:Q.id,C]),v.useEffect(()=>{X(ce=>Math.min(ce,Ne))},[Ne]);const Oe=d.filter(ce=>ce.is_active).length,Qe=s.filter(ce=>ce.scope==="client"&&ce.isActive).length,Ze=ce=>{const Pe=Math.min(Math.max(ce,1),te);k(Pe);const ct=H[(Pe-1)*Yi];ct&&E(ct.id)},vt=ce=>{B(null),z(x6(ce,s)),M(!0)},oe=ce=>{B(ce),z(w6(ce)),M(!0)},se=async()=>{if(!U)return;const ce=U.name.trim(),Pe=U.scope==="client"?U.clientName.trim():"";if(!ce){ot.error("Escribe el nombre de la sección.");return}if(U.scope==="client"&&!Pe){ot.error("Selecciona el cliente del tarifario especial.");return}O(!0);try{const ct={...U,id:(L==null?void 0:L.id)||tj(U.scope,ce,U.clientName),name:ce,clientName:Pe,pricingMode:U.scope==="client"?"fixed_multi":"guided"};await Y$(ct),x(ct.scope),E(ct.id),M(!1),ot.success(L?"Sección actualizada.":"Sección creada.")}catch(ct){console.error("Error guardando sección del tarifario:",ct),ot.error(ct instanceof Error?ct.message:"No se pudo guardar la sección.")}finally{O(!1)}},Re=async ce=>{V(ce.id);try{await W$(ce,!ce.isActive),ot.success(ce.isActive?"Sección desactivada.":"Sección reactivada.")}catch(Pe){console.error("Error cambiando estado de sección:",Pe),ot.error("No se pudo cambiar el estado de la sección.")}finally{V(null)}},De=()=>{Q&&(ve(null),he(_6(Q,d)),ue(!0))},ht=ce=>{ve(ce),he(S6(ce)),ue(!0)},Ye=async()=>{if(!le||!Q)return;const ce=Q.scope==="client",Pe=le.service.trim(),ct=ce?Q.name:le.category.trim(),tn=le.notes.trim();if(!Pe){ot.error(ce?"Escribe el nombre de la pieza.":"Escribe el servicio o ítem.");return}if(!ce&&!ct){ot.error("Escribe la categoría.");return}const Dt=le.reference_min==null?null:Number(le.reference_min),Gt=le.reference_max==null?null:Number(le.reference_max);if(ce&&(!Number.isFinite(Dt)||Number(Dt)<=0)){ot.error("El monto fijo debe ser mayor que cero.");return}if(Dt!=null&&Gt!=null&&Dt>Gt){ot.error("El monto mínimo no puede ser mayor que el máximo.");return}W(!0);try{const dn=ce?null:d.find(It=>It.section===Q.id&&Xa(It.category)===Xa(ct)&&Xa(It.service)===Xa(Pe)),gn=(de==null?void 0:de.catalog_item_id)||(dn==null?void 0:dn.catalog_item_id)||Xa(`${Q.id}-${ct}-${Pe}`),fn=ce?"Tarifa fija":le.work_type_label.trim()||"Referencia",Nt=ce?"Precio fijo":le.level_label.trim()||"Precio único",Kt=(de==null?void 0:de.work_type_id)||Xa(fn)||"reference",Tt=(de==null?void 0:de.level_id)||Xa(Nt)||"project",cr=ce?Number(Dt):null,ur={...le,id:(de==null?void 0:de.id)||ZN({catalog_item_id:gn,work_type_id:Kt,level_id:Tt}),catalog_item_id:gn,section:Q.id,category:ct,service:Pe,notes:tn,work_type_id:Kt,work_type_label:fn,work_type_short_label:ce?"Fijo":le.work_type_short_label.trim()||fn,hour_reference:ce?"":le.hour_reference.trim(),level_id:Tt,level_label:Nt,reference:ce?`${cr} USD`:le.reference.trim()||b6(Dt,Gt),reference_min:ce?cr:Dt,reference_max:ce?cr:Gt,level_hint:ce?"Monto fijo por pieza.":le.level_hint.trim(),sort_order:Number(le.sort_order||0),is_active:le.is_active,managed_by:"app"};await V$(ur,de),ue(!1),ot.success(de?"Tarifa actualizada.":"Tarifa agregada.")}catch(dn){console.error("Error guardando tarifa:",dn),ot.error(dn instanceof Error?dn.message:"No se pudo guardar la tarifa.")}finally{W(!1)}},mt=async ce=>{V(ce.id);try{await F$(ce,!ce.is_active),ot.success(ce.is_active?"Tarifa desactivada.":"Tarifa reactivada.")}catch(Pe){console.error("Error cambiando estado de tarifa:",Pe),ot.error("No se pudo cambiar el estado de la tarifa.")}finally{V(null)}},zt=i||h,qe=l||m;return f.jsxs(f.Fragment,{children:[f.jsx(Eo,{open:e,onOpenChange:t,children:f.jsx(Ws,{className:"h-[90vh] max-h-[900px] w-[96vw] max-w-[1280px] overflow-hidden p-0",children:f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f.jsxs("div",{className:"border-b border-border px-6 py-5 pr-14",children:[f.jsx(Xs,{children:f.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[f.jsxs("div",{children:[f.jsxs(Js,{className:"flex items-center gap-2 text-xl",children:[f.jsx(u1,{className:"h-5 w-5 text-primary"}),"Administración del tarifario"]}),f.jsx(Qs,{className:"mt-1 max-w-3xl",children:"Crea secciones generales, administra tarifas por cliente y edita los ítems que ya utiliza el equipo al cotizar proyectos."})]}),f.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void Promise.all([c(),b()]),disabled:zt,children:[f.jsx(Zd,{className:xe("h-3.5 w-3.5",zt&&"animate-spin")}),"Actualizar"]}),f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>vt("client"),children:[f.jsx(Gw,{className:"h-3.5 w-3.5"}),"Tarifario por cliente"]}),f.jsxs(ke,{type:"button",size:"sm",className:"gap-1.5",onClick:()=>vt("general"),children:[f.jsx(Pr,{className:"h-3.5 w-3.5"}),"Sección general"]})]})]})}),f.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[f.jsx(Mp,{icon:f.jsx(y3,{className:"h-4 w-4"}),label:"Secciones activas",value:s.filter(ce=>ce.isActive).length}),f.jsx(Mp,{icon:f.jsx(Gw,{className:"h-4 w-4"}),label:"Tarifarios por cliente",value:Qe}),f.jsx(Mp,{icon:f.jsx(Kw,{className:"h-4 w-4"}),label:"Tarifas activas",value:Oe})]})]}),qe&&f.jsx("div",{className:"border-b border-amber-200 bg-amber-50 px-6 py-2 text-xs text-amber-900",children:qe}),f.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[310px_minmax(0,1fr)]",children:[f.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border bg-muted/20 lg:border-b-0 lg:border-r",children:[f.jsxs("div",{className:"space-y-3 p-4",children:[f.jsx(dT,{value:g,onValueChange:ce=>x(ce),children:f.jsxs(Vv,{className:"grid w-full grid-cols-2",children:[f.jsx(qd,{value:"general",children:"Generales"}),f.jsx(qd,{value:"client",children:"Por cliente"})]})}),f.jsx("p",{className:"text-xs text-muted-foreground",children:g==="general"?"Estas secciones aparecen para los clientes que no tienen un tarifario especial.":"Cada tarifario aparece únicamente al seleccionar el cliente asociado."})]}),f.jsx(Ng,{className:"min-h-[220px] flex-1 px-3 pb-3",children:f.jsxs("div",{className:"space-y-2 pr-2",children:[ee.map(ce=>{const Pe=ce.id===(Q==null?void 0:Q.id),ct=d.filter(tn=>tn.section===ce.id&&tn.is_active).length;return f.jsxs("button",{type:"button",onClick:()=>E(ce.id),className:xe("w-full rounded-xl border px-3 py-3 text-left transition-colors",Pe?"border-primary/40 bg-primary/10":"border-border bg-card hover:bg-muted/50",!ce.isActive&&"opacity-60"),children:[f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"truncate text-sm font-semibold",children:ce.name}),ce.scope==="client"&&f.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:ce.clientName})]}),f.jsx(yn,{variant:ce.isActive?"secondary":"outline",children:ce.isActive?"Activa":"Inactiva"})]}),f.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[ct," tarifa(s) activa(s)"]})]},ce.id)}),H.length===0&&f.jsx("div",{className:"rounded-xl border border-dashed border-border bg-card px-3 py-5 text-center text-sm text-muted-foreground",children:"No hay secciones de este tipo."})]})}),f.jsx(Y_,{currentPage:R,totalPages:te,totalItems:H.length,pageSize:Yi,itemLabel:"secciones",onPageChange:Ze,compact:!0})]}),f.jsx("section",{className:"min-h-0",children:Q?f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f.jsx("div",{className:"border-b border-border px-5 py-4",children:f.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("h3",{className:"text-lg font-semibold",children:Q.name}),f.jsx(yn,{variant:Q.scope==="client"?"default":"secondary",children:Q.scope==="client"?"Por cliente":"General"}),!Q.isActive&&f.jsx(yn,{variant:"outline",children:"Inactiva"})]}),Q.scope==="client"&&f.jsxs("p",{className:"mt-1 text-sm text-primary",children:["Se muestra al seleccionar: ",Q.clientName]}),f.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:Q.description||"Sin descripción."})]}),f.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>oe(Q),children:[f.jsx(B3,{className:"h-3.5 w-3.5"}),"Editar sección"]}),f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void Re(Q),disabled:J===Q.id,children:[Q.isActive?f.jsx(Fw,{className:"h-3.5 w-3.5 rotate-180"}):f.jsx(Fw,{className:"h-3.5 w-3.5"}),Q.isActive?"Desactivar":"Reactivar"]}),f.jsxs(ke,{type:"button",size:"sm",className:"gap-1.5",onClick:De,children:[f.jsx(Pr,{className:"h-3.5 w-3.5"}),Q.scope==="client"?"Nueva pieza":"Nueva tarifa"]})]})]})}),f.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-border px-5 py-3",children:[f.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[f.jsx(co,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),f.jsx(lt,{value:S,onChange:ce=>N(ce.target.value),className:"pl-9",placeholder:"Buscar servicio, categoría o nivel…"})]}),f.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[f.jsx(Xl,{checked:C,onCheckedChange:A}),"Mostrar inactivas"]})]}),f.jsx(Ng,{className:"min-h-0 flex-1",children:f.jsx("div",{className:"space-y-3 p-5",children:zt&&re.length===0?f.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-sm text-muted-foreground",children:[f.jsx(Xt,{className:"h-4 w-4 animate-spin"})," Cargando tarifario…"]}):re.length===0?f.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-muted/20 px-5 py-10 text-center",children:[f.jsx(Kw,{className:"mx-auto h-8 w-8 text-muted-foreground"}),f.jsx("p",{className:"mt-3 text-sm font-medium",children:"No hay tarifas para mostrar"}),f.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Agrega la primera tarifa de esta sección o activa “Mostrar inactivas”."}),f.jsxs(ke,{className:"mt-4 gap-1.5",size:"sm",onClick:De,children:[f.jsx(Pr,{className:"h-3.5 w-3.5"})," Agregar tarifa"]})]}):ze.map(ce=>f.jsx(C6,{row:ce,section:Q,busy:J===ce.id,onEdit:()=>ht(ce),onToggle:()=>void mt(ce)},ce.id))})}),f.jsx(Y_,{currentPage:I,totalPages:Ne,totalItems:re.length,pageSize:Zu,itemLabel:"tarifas",onPageChange:X})]}):f.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Selecciona o crea una sección para comenzar."})})]})]})})}),f.jsx(N6,{open:T,onOpenChange:M,draft:U,onDraftChange:z,clients:n.clientes,editing:!!L,saving:pe,onSave:()=>void se()}),f.jsx(j6,{open:q,onOpenChange:ue,section:Q,draft:le,onDraftChange:he,editing:!!de,saving:K,onSave:()=>void Ye()})]})}function Y_({currentPage:e,totalPages:t,totalItems:n,pageSize:s,itemLabel:i,onPageChange:l,compact:c=!1}){const d=n===0?0:(e-1)*s+1,h=Math.min(e*s,n);return f.jsxs("div",{className:xe("flex items-center justify-between gap-3 border-t border-border bg-background/95 px-4 py-2.5",c&&"px-3"),children:[f.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[d,"",h," de ",n," ",i]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[!c&&f.jsxs("span",{className:"mr-1 text-[11px] text-muted-foreground",children:["Página ",e," de ",t]}),f.jsx(ke,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Página anterior",onClick:()=>l(e-1),disabled:e<=1,children:f.jsx(Vg,{className:"h-3.5 w-3.5"})}),c&&f.jsxs("span",{className:"min-w-[42px] text-center text-[11px] text-muted-foreground",children:[e,"/",t]}),f.jsx(ke,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Página siguiente",onClick:()=>l(e+1),disabled:e>=t,children:f.jsx(Qd,{className:"h-3.5 w-3.5"})})]})]})}function Mp({icon:e,label:t,value:n}){return f.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border bg-muted/20 px-3 py-2.5",children:[f.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e}),f.jsxs("div",{children:[f.jsx("p",{className:"text-lg font-semibold leading-none",children:n}),f.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:t})]})]})}function C6({row:e,section:t,busy:n,onEdit:s,onToggle:i}){const l=t.scope==="client",c=l?kp(e.reference_min??e.reference_max):e.reference||(e.reference_min!=null||e.reference_max!=null?`${kp(e.reference_min)} ${kp(e.reference_max)}`:"Sin monto de referencia");return f.jsx("div",{className:xe("rounded-2xl border border-border bg-card px-4 py-3 shadow-sm",!e.is_active&&"opacity-60"),children:f.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("p",{className:"font-medium",children:e.service}),f.jsx(yn,{variant:e.is_active?"secondary":"outline",children:e.is_active?"Activa":"Inactiva"}),e.managed_by==="app"&&f.jsx(yn,{variant:"outline",children:"Gestionada en app"})]}),!l&&f.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.category}),f.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[!l&&f.jsx("span",{children:e.work_type_label}),!l&&f.jsx("span",{children:e.level_label}),f.jsx("span",{className:"font-semibold text-foreground",children:c}),f.jsxs("span",{children:["Orden: ",e.sort_order]})]}),e.notes&&f.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:e.notes})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:s,children:[f.jsx(L3,{className:"h-3.5 w-3.5"})," Editar"]}),f.jsx(ke,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:n,children:n?f.jsx(Xt,{className:"h-3.5 w-3.5 animate-spin"}):e.is_active?"Desactivar":"Reactivar"})]})]})})}function N6({open:e,onOpenChange:t,draft:n,onDraftChange:s,clients:i,editing:l,saving:c,onSave:d}){if(!n)return null;const h=n.scope==="client";return f.jsx(Eo,{open:e,onOpenChange:t,children:f.jsxs(Ws,{className:"max-w-2xl",children:[f.jsxs(Xs,{children:[f.jsx(Js,{children:l?"Editar sección":h?"Nuevo tarifario por cliente":"Nueva sección general"}),f.jsx(Qs,{children:h?"El tarifario aparecerá automáticamente cuando se seleccione el cliente indicado.":"La sección aparecerá junto a las demás secciones del tarifario general."})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-2",children:[f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Nombre de la sección"}),f.jsx(lt,{value:n.name,onChange:m=>s({...n,name:m.target.value}),placeholder:h?"Ej: Tarifario PepsiCo":"Ej: Producción audiovisual"})]}),h&&f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Cliente asociado"}),f.jsx(xr,{value:n.clientName,options:i,onValueChange:m=>s({...n,clientName:m}),placeholder:"Seleccionar cliente…",searchPlaceholder:"Buscar cliente…",emptyText:"No se encontró ese cliente en las listas de la app."}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"El nombre debe coincidir con el cliente disponible en el formulario de proyectos."})]}),f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Descripción para el usuario"}),f.jsx(fa,{value:n.description,onChange:m=>s({...n,description:m.target.value}),placeholder:"Explica brevemente qué incluye esta sección.",rows:3})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Orden"}),f.jsx(lt,{type:"number",min:"0",value:n.sortOrder,onChange:m=>s({...n,sortOrder:Number(m.target.value||0)})})]}),f.jsxs("div",{className:"flex flex-col justify-end gap-3 rounded-xl border border-border bg-muted/20 px-3 py-2.5",children:[f.jsxs("label",{className:"flex items-center justify-between gap-3 text-sm",children:[f.jsx("span",{children:"Sección activa"}),f.jsx(Xl,{checked:n.isActive,onCheckedChange:m=>s({...n,isActive:m})})]}),h&&f.jsxs("label",{className:"flex items-center justify-between gap-3 text-sm",children:[f.jsx("span",{children:"Permitir costo manual"}),f.jsx(Xl,{checked:n.allowManual,onCheckedChange:m=>s({...n,allowManual:m})})]})]})]}),f.jsxs(pf,{children:[f.jsx(ke,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancelar"}),f.jsxs(ke,{type:"button",className:"gap-1.5",onClick:d,disabled:c,children:[c?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):f.jsx($r,{className:"h-4 w-4"}),"Guardar sección"]})]})]})})}function j6({open:e,onOpenChange:t,section:n,draft:s,onDraftChange:i,editing:l,saving:c,onSave:d}){if(!s||!n)return null;const h=n.scope==="client";return f.jsx(Eo,{open:e,onOpenChange:t,children:f.jsxs(Ws,{className:"max-h-[88vh] max-w-3xl overflow-y-auto",children:[f.jsxs(Xs,{children:[f.jsx(Js,{children:l?h?"Editar pieza":"Editar tarifa":h?"Nueva pieza de precio fijo":"Nueva tarifa"}),f.jsxs(Qs,{children:["Sección: ",n.name]})]}),h?f.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-[minmax(0,1fr)_200px]",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Nombre de la pieza"}),f.jsx(lt,{value:s.service,onChange:m=>i({...s,service:m.target.value}),placeholder:"Ej: Photobooth"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Monto fijo (USD)"}),f.jsx(lt,{type:"number",min:"0",step:"0.01",value:s.reference_min??"",onChange:m=>i({...s,reference_min:Op(m.target.value)}),placeholder:"0.00"})]}),f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Descripción / incluye"}),f.jsx(fa,{value:s.notes,onChange:m=>i({...s,notes:m.target.value}),placeholder:"Describe qué incluye esta pieza y cualquier observación importante.",rows:4})]})]}):f.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-2",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Categoría"}),f.jsx(lt,{value:s.category,onChange:m=>i({...s,category:m.target.value}),placeholder:"Ej: Materiales de PDV"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Servicio / ítem"}),f.jsx(lt,{value:s.service,onChange:m=>i({...s,service:m.target.value}),placeholder:"Ej: Diseño de roll up"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Tipo de trabajo"}),f.jsx(lt,{value:s.work_type_label,onChange:m=>i({...s,work_type_label:m.target.value}),placeholder:"Ej: Diseño + Arte Final"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Etiqueta corta"}),f.jsx(lt,{value:s.work_type_short_label,onChange:m=>i({...s,work_type_short_label:m.target.value}),placeholder:"Ej: Diseño"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Nivel / referencia"}),f.jsx(lt,{value:s.level_label,onChange:m=>i({...s,level_label:m.target.value}),placeholder:"Ej: Básico"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Hora hombre ref."}),f.jsx(lt,{value:s.hour_reference,onChange:m=>i({...s,hour_reference:m.target.value}),placeholder:"Ej: 35 - 50"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Monto mínimo"}),f.jsx(lt,{type:"number",min:"0",step:"0.01",value:s.reference_min??"",onChange:m=>i({...s,reference_min:Op(m.target.value)}),placeholder:"0.00"})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Monto máximo"}),f.jsx(lt,{type:"number",min:"0",step:"0.01",value:s.reference_max??"",onChange:m=>i({...s,reference_max:Op(m.target.value)}),placeholder:"0.00"})]}),f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Referencia visible"}),f.jsx(lt,{value:s.reference,onChange:m=>i({...s,reference:m.target.value}),placeholder:"Ej: 100 - 150 USD (se genera automáticamente si se deja vacío)"})]}),f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Observaciones / incluye"}),f.jsx(fa,{value:s.notes,onChange:m=>i({...s,notes:m.target.value}),placeholder:"Describe qué incluye el servicio.",rows:3})]}),f.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[f.jsx(Fe,{children:"Nota del nivel"}),f.jsx(fa,{value:s.level_hint,onChange:m=>i({...s,level_hint:m.target.value}),placeholder:"Ej: Puede superar el rango si la complejidad lo requiere.",rows:2})]})]}),f.jsx(zs,{}),f.jsxs("div",{className:"grid grid-cols-1 gap-4 py-2 sm:grid-cols-2",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Orden"}),f.jsx(lt,{type:"number",min:"0",value:s.sort_order,onChange:m=>i({...s,sort_order:Number(m.target.value||0)})})]}),f.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-xl border border-border bg-muted/20 px-3 py-2.5 text-sm",children:[f.jsx("span",{children:"Tarifa activa"}),f.jsx(Xl,{checked:s.is_active,onCheckedChange:m=>i({...s,is_active:m})})]})]}),f.jsxs(pf,{children:[f.jsx(ke,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancelar"}),f.jsxs(ke,{type:"button",className:"gap-1.5",onClick:d,disabled:c,children:[c?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):f.jsx($r,{className:"h-4 w-4"}),"Guardar tarifa"]})]})]})})}const T6="https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-listas-admin";function A6(){return"https://agenteit.digitalcompass.agency/webhook/tablero-cdc-sync-listas-admin".trim()||T6}async function Dp(e){var l;const{data:t,error:n}=await Ce.auth.getSession();if(n||!((l=t.session)!=null&&l.access_token))throw new Error("No hay una sesión activa. Recarga la página e inicia sesión nuevamente.");const s=new AbortController,i=window.setTimeout(()=>s.abort(),2e4);try{const c=await fetch(A6(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e.action,category:e.category||"",value:e.value||"",previous_value:e.previousValue||"",manager:e.manager||"",source:"tablero-cdc",access_token:t.session.access_token,sent_at:new Date().toISOString()}),signal:s.signal}),d=await c.text();let h=null;if(d)try{h=JSON.parse(d)}catch{h={message:d}}if(!c.ok)throw new Error((h==null?void 0:h.message)||`${c.status} ${c.statusText}`.trim());return h||{ok:!0}}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new Error("n8n tardó demasiado en responder. Revisa el workflow de sincronización de listas."):c}finally{window.clearTimeout(i)}}const R6="https://docs.google.com/spreadsheets/d/19oBoslErcTSk8ibA6Nr38lcOV8Q09JwGahS7JD1o4Ts/edit?gid=1709890592#gid=1709890592",Sl={client:{label:"Clientes",singular:"cliente",placeholder:"Ej: PepsiCo",description:"Opciones disponibles en el campo Cliente de los proyectos."},brand:{label:"Marcas",singular:"marca",placeholder:"Ej: Nescafé",description:"Opciones disponibles en la selección de una o varias marcas."},country:{label:"País / BU",singular:"País / BU",placeholder:"Ej: Guatemala",description:"Cada País / BU puede tener un Country Manager asociado."},status:{label:"Estatus",singular:"estatus",placeholder:"Ej: Stand by",description:"Estatus disponibles para cerrar o clasificar proyectos."}};function ed(e){return[...e].sort((t,n)=>t.value.localeCompare(n.value,"es",{sensitivity:"base"}))}const td=25;function k6(e,t){return t<=7?Array.from({length:t},(n,s)=>s+1):e<=4?[1,2,3,4,5,"ellipsis-end",t]:e>=t-3?[1,"ellipsis-start",t-4,t-3,t-2,t-1,t]:[1,"ellipsis-start",e-1,e,e+1,"ellipsis-end",t]}function O6({open:e,onOpenChange:t}){const[n,s]=v.useState("client"),[i,l]=v.useState(""),[c,d]=v.useState(1),[h,m]=v.useState(""),[b,g]=v.useState(""),[x,w]=v.useState(null),[E,S]=v.useState(!1),[N,C]=v.useState(null),[A,T]=v.useState(!1),{lists:M,loading:U,error:z,refresh:L}=hc(),B=v.useMemo(()=>ed(n==="client"?M.clientes.map(R=>({value:R})):n==="brand"?M.marcas.map(R=>({value:R})):n==="status"?M.status.map(R=>({value:R})):M.bus.map(R=>{var k;return{value:R,manager:M.buCm[R]||((k=Object.entries(M.buCm).find(([I])=>Te(I)===Te(R)))==null?void 0:k[1])||""}})),[n,M]),q=v.useMemo(()=>{const R=Te(i);return R?B.filter(k=>Te(`${k.value} ${k.manager||""}`).includes(R)):B},[i,B]),ue=Math.max(1,Math.ceil(q.length/td)),le=Math.min(c,ue),he=(le-1)*td,de=q.slice(he,he+td),ve=k6(le,ue),pe=()=>{m(""),g(""),w(null)};v.useEffect(()=>{e&&L()},[e,L]),v.useEffect(()=>{pe(),l(""),d(1)},[n]),v.useEffect(()=>{d(1)},[i]),v.useEffect(()=>{c>ue&&d(ue)},[c,ue]);const O=R=>{w(R.value),m(R.value),g(R.manager||"")},K=async()=>{const R=h.trim(),k=b.trim();if(!R){ot.error(`Escribe el ${Sl[n].singular}.`);return}S(!0);try{await Dp({action:x?"update":"create",category:n,value:R,previousValue:x||void 0,manager:n==="country"?k:void 0}),await L(),ot.success(x?"Lista actualizada.":"Opción agregada.",{description:"Google Sheet y Supabase quedaron sincronizados."}),pe()}catch(I){console.error("Error guardando lista:",I),ot.error("No se pudo guardar la lista.",{description:I instanceof Error?I.message:"Revisa n8n e intenta nuevamente."})}finally{S(!1)}},W=async R=>{if(window.confirm(`¿Eliminar "${R.value}" de ${Sl[n].label}?
El cambio también se hará en el Google Sheet. Los proyectos históricos no se borrarán.`)){C(R.value);try{await Dp({action:"delete",category:n,value:R.value,previousValue:R.value}),await L(),x&&Te(x)===Te(R.value)&&pe(),ot.success("Opción eliminada.",{description:"Google Sheet y Supabase quedaron sincronizados."})}catch(k){console.error("Error eliminando lista:",k),ot.error("No se pudo eliminar la opción.",{description:k instanceof Error?k.message:"Revisa n8n e intenta nuevamente."})}finally{C(null)}}},J=async()=>{T(!0);try{await Dp({action:"refresh"}),await L(),ot.success("Listas actualizadas desde el Sheet.")}catch(R){console.error("Error sincronizando listas:",R),ot.error("No se pudieron sincronizar las listas.",{description:R instanceof Error?R.message:"Revisa n8n e intenta nuevamente."})}finally{T(!1)}},V=Sl[n];return f.jsx(Eo,{open:e,onOpenChange:t,children:f.jsx(Ws,{className:"h-[88vh] max-h-[860px] w-[96vw] max-w-[1050px] overflow-hidden p-0",children:f.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f.jsx("div",{className:"border-b border-border px-6 py-5 pr-14",children:f.jsx(Xs,{children:f.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[f.jsxs("div",{children:[f.jsxs(Js,{className:"flex items-center gap-2 text-xl",children:[f.jsx(Cd,{className:"h-5 w-5 text-primary"}),"Administración de listas"]}),f.jsxs(Qs,{className:"mt-1 max-w-2xl",children:["Los cambios que realices aquí se guardarán automáticamente en la hoja"," ",f.jsx("strong",{children:"Listas"})," y se reflejarán de inmediato en las opciones disponibles de la aplicación."]})]}),f.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>window.open(R6,"_blank","noopener,noreferrer"),children:[f.jsx(Fg,{className:"h-3.5 w-3.5"})," Abrir Sheet"]}),f.jsxs(ke,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void J(),disabled:A,children:[f.jsx(Zd,{className:xe("h-3.5 w-3.5",A&&"animate-spin")}),"Sincronizar desde Sheet"]})]})]})})}),f.jsx("div",{className:"border-b border-border px-6 py-4",children:f.jsx(dT,{value:n,onValueChange:R=>s(R),children:f.jsx(Vv,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:Object.keys(Sl).map(R=>f.jsx(qd,{value:R,children:Sl[R].label},R))})})}),f.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[360px_minmax(0,1fr)]",children:[f.jsx("section",{className:"border-b border-border bg-muted/15 p-5 lg:border-b-0 lg:border-r",children:f.jsxs("div",{className:"rounded-2xl border border-border bg-card p-4 shadow-sm",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-semibold",children:x?`Editar ${V.singular}`:`Agregar ${V.singular}`}),f.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:V.description})]}),x&&f.jsx(ke,{type:"button",variant:"ghost",size:"icon",onClick:pe,children:f.jsx(uo,{className:"h-4 w-4"})})]}),f.jsxs("div",{className:"mt-4 space-y-3",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:V.singular.charAt(0).toUpperCase()+V.singular.slice(1)}),f.jsx(lt,{value:h,onChange:R=>m(R.target.value),placeholder:V.placeholder,disabled:E})]}),n==="country"&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Fe,{children:"Country Manager"}),f.jsx(lt,{value:b,onChange:R=>g(R.target.value),placeholder:"Ej: Poul",disabled:E})]}),f.jsxs(ke,{type:"button",className:"w-full gap-1.5",onClick:()=>void K(),disabled:E||!h.trim(),children:[E?f.jsx(Xt,{className:"h-4 w-4 animate-spin"}):x?f.jsx($r,{className:"h-4 w-4"}):f.jsx(Pr,{className:"h-4 w-4"}),x?"Guardar cambios":"Agregar"]})]})]})}),f.jsxs("section",{className:"flex min-h-0 flex-col p-5",children:[f.jsxs("div",{className:"relative mb-3",children:[f.jsx(co,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),f.jsx(lt,{value:i,onChange:R=>l(R.target.value),placeholder:`Buscar en ${V.label}`,className:"pl-9"})]}),z&&f.jsxs("div",{className:"mb-3 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:["No se pudieron cargar las listas desde Supabase: ",z]}),f.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[f.jsxs("span",{children:[q.length," opción(es)"]}),U&&f.jsx("span",{children:"Cargando…"})]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto rounded-2xl border border-border bg-card",children:U&&B.length===0?f.jsxs("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[f.jsx(Xt,{className:"h-4 w-4 animate-spin"})," Cargando listas…"]}):q.length===0?f.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No hay opciones que coincidan."}):f.jsx("div",{className:"divide-y divide-border",children:de.map(R=>f.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"truncate text-sm font-medium",children:R.value}),n==="country"&&f.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:["CM: ",R.manager||"Sin asignar"]})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 px-2",onClick:()=>O(R),disabled:!!N||E,children:[f.jsx(Gg,{className:"h-3.5 w-3.5"})," Editar"]}),f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 px-2 text-muted-foreground hover:text-destructive",onClick:()=>void W(R),disabled:!!N||E,children:[N===R.value?f.jsx(Xt,{className:"h-3.5 w-3.5 animate-spin"}):f.jsx(ef,{className:"h-3.5 w-3.5"}),"Eliminar"]})]})]},Te(`${n}:${R.value}`)))})}),q.length>0&&f.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("span",{className:"text-xs text-muted-foreground",children:["Mostrando ",he+1,"",Math.min(he+td,q.length)," de"," ",q.length]}),ue>1&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[f.jsx(ke,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2.5",onClick:()=>d(R=>Math.max(1,R-1)),disabled:le===1,children:"Anterior"}),ve.map(R=>typeof R=="number"?f.jsx(ke,{type:"button",variant:R===le?"default":"outline",size:"sm",className:"h-8 min-w-8 px-2",onClick:()=>d(R),"aria-current":R===le?"page":void 0,children:R},R):f.jsx("span",{className:"flex h-8 min-w-6 items-center justify-center text-xs text-muted-foreground","aria-hidden":"true",children:"…"},R)),f.jsx(ke,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2.5",onClick:()=>d(R=>Math.min(ue,R+1)),disabled:le===ue,children:"Siguiente"})]})]})]})]})]})})})}const Ms=24,fT={country:"",brand:"",client:"",cm:""},W_={nuevos:1,todos:1,abiertos:1,cerrados:1,no_aprobados:1},hT="tablero-cdc:ui-state:v1";function M6(){var t,n,s,i;const e={query:"",filter:"todos",advancedFilters:fT,pageByFilter:W_,tariffManagerOpen:!1,listManagerOpen:!1,scrollY:0};if(typeof window>"u")return e;try{const l=window.localStorage.getItem(hT);if(!l)return e;const c=JSON.parse(l),h=["nuevos","todos","abiertos","cerrados","no_aprobados"].includes(c.filter)?c.filter:e.filter;return{query:typeof c.query=="string"?c.query:e.query,filter:h,advancedFilters:{country:typeof((t=c.advancedFilters)==null?void 0:t.country)=="string"?c.advancedFilters.country:"",brand:typeof((n=c.advancedFilters)==null?void 0:n.brand)=="string"?c.advancedFilters.brand:"",client:typeof((s=c.advancedFilters)==null?void 0:s.client)=="string"?c.advancedFilters.client:"",cm:typeof((i=c.advancedFilters)==null?void 0:i.cm)=="string"?c.advancedFilters.cm:""},pageByFilter:Object.fromEntries(Object.entries({...W_,...c.pageByFilter||{}}).map(([m,b])=>[m,Math.max(1,Math.floor(Number(b)||1))])),tariffManagerOpen:c.tariffManagerOpen===!0,listManagerOpen:c.listManagerOpen===!0,scrollY:Number.isFinite(Number(c.scrollY))?Math.max(0,Number(c.scrollY)):0}}catch(l){return console.warn("No se pudo restaurar la vista anterior del Tablero CDC:",l),e}}function D6(e,t){if(e){const n=e.trim().split(/\s+/);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():e.slice(0,2).toUpperCase()}return t?t.slice(0,2).toUpperCase():"?"}function L6(){const[e]=v.useState(M6),t=v.useRef(!1),n=v.useRef(e.scrollY<=0),[s,i]=v.useState(!1),[l,c]=v.useState(null),[d,h]=v.useState(e.query),[m,b]=v.useState(e.filter),[g,x]=v.useState(e.advancedFilters),[w,E]=v.useState(e.pageByFilter),[S,N]=v.useState(null),[C,A]=v.useState(e.tariffManagerOpen),[T,M]=v.useState(e.listManagerOpen),[U,z]=v.useState(null),[L,B]=v.useState(null),q=m==="nuevos"||m==="no_aprobados",ue=m==="no_aprobados"?"rejected":"new",le=q?"todos":m,he=w[m],{lists:de}=hc(),{projects:ve,totalProjects:pe,filterOptions:O,loading:K,error:W,refresh:J,remove:V}=Aj({tab:le,search:q?"":d,page:q?w[le]:he,pageSize:Ms,country:q?"":g.country,brand:q?"":g.brand,client:q?"":g.client,cm:q?"":g.cm}),R=G8({status:ue,search:d,page:he,pageSize:Ms,enabled:q}),{user:k,isGerardo:I,canManageInternalPricing:X,canControlPricingSummary:H,canManageTariffCatalog:te,logout:ee}=Xd(),Q=K8(!!k),re={tab:le,search:q?"":d,page:1,pageSize:Ms,country:q?"":g.country,brand:q?"":g.brand,client:q?"":g.client,cm:q?"":g.cm},{isPublic:Ne,loading:ze,saving:Oe,error:Qe,setPublicVisibility:Ze}=X8(!!k),vt=!q&&(H||Ne),{summary:oe,loading:se,error:Re}=KB(re,vt),De=Object.values(de.buCm),ht=et([...de.bus,...uB(O.countries,de.bus),g.country]),Ye=et([...de.marcas,...Cp(O.brands,de.marcas),g.brand]),mt=et([...de.clientes,...Cp(O.clients,de.clientes),g.client]),zt=et([...De,...Cp(O.cms,De),g.cm]),qe=Object.values(g).filter(Boolean).length,ce=q?R.totalItems:pe,Pe=Math.max(1,Math.ceil(ce/Ms)),ct=Math.min(he,Pe),tn=(ct-1)*Ms,Dt=ce===0?0:tn+1,Gt=Math.min(tn+Ms,ce);v.useEffect(()=>{if(!t.current){t.current=!0;return}E(me=>({...me,[m]:1}))},[d,g.country,g.brand,g.client,g.cm]),v.useEffect(()=>{const me=()=>{try{const st={query:d,filter:m,advancedFilters:g,pageByFilter:w,tariffManagerOpen:C,listManagerOpen:T,scrollY:n.current?window.scrollY:e.scrollY};window.localStorage.setItem(hT,JSON.stringify(st))}catch(st){console.warn("No se pudo guardar la vista del Tablero CDC:",st)}};me();const $e=()=>me(),Se=()=>{document.visibilityState==="hidden"&&me()};return window.addEventListener("pagehide",$e),document.addEventListener("visibilitychange",Se),()=>{window.removeEventListener("pagehide",$e),document.removeEventListener("visibilitychange",Se)}},[d,m,g,w,C,T,e.scrollY]),v.useEffect(()=>{const me=e.scrollY,$e=q?R.loading:K;if(me<=0||$e||n.current)return;const Se=window.setTimeout(()=>{window.scrollTo({top:me,behavior:"auto"}),n.current=!0},120);return()=>window.clearTimeout(Se)},[e.scrollY,q,R.loading,K]),v.useEffect(()=>{he>Pe&&E(me=>({...me,[m]:Pe}))},[he,m,Pe]),v.useEffect(()=>{m!=="nuevos"||!k||Q.unreadCount<=0||Q.markAllSeen().catch(me=>{console.error("Error marcando briefs como vistos:",me)})},[m,k==null?void 0:k.id,Q.unreadCount,Q.markAllSeen]);const dn=me=>{const $e=Math.min(Math.max(me,1),Pe);$e!==he&&(E(Se=>({...Se,[m]:$e})),window.scrollTo({top:0,behavior:"smooth"}))},gn=(me,$e)=>{x(Se=>({...Se,[me]:$e}))},fn=()=>{x(fT)},Nt=()=>{c(null),i(!0)},Kt=me=>{c(me),i(!0)},Tt=async me=>{if(window.confirm(`¿Seguro que deseas eliminar el proyecto "${me.nombre||"Sin título"}"?
Esta acción eliminará el proyecto del tablero y del Google Sheet.`)){N(me.id);try{await V(me.id),(l==null?void 0:l.id)===me.id&&(i(!1),c(null))}catch(Se){console.error("Error eliminando proyecto:",Se);const st=Se instanceof Error?Se.message:"No se pudo eliminar el proyecto. Revisa n8n, Supabase o permisos.";window.alert(st)}finally{N(null)}}},cr=async(me,$e,Se=!1)=>{if(!(!window.confirm(Se?`¿Aprobar el brief rechazado "${$e||"Sin título"}"?
Se recuperará de Rechazados, se creará como proyecto Activo y aparecerá en Todos y Activos.`:`¿Aprobar el brief "${$e||"Sin título"}"?
Se creará como proyecto Activo y aparecerá en Todos y Activos.`)||L)){B(me);try{const St=await R.approve(me);await J(),St.sheetSyncStatus==="synced"?window.alert("Brief aprobado. El proyecto quedó Activo y sincronizado con Google Sheet."):window.alert(St.sheetSyncMessage)}catch(St){console.error("Error aprobando brief:",St),window.alert(St instanceof Error?St.message:"No se pudo aprobar el brief. Revisa Supabase e intenta de nuevo.")}finally{B(null)}}},ur=async(me,$e)=>{if(!(!window.confirm(`¿Mover el brief "${$e||"Sin título"}" a Rechazados?
No se creará ningún proyecto en el tablero general.`)||L)){B(me);try{await R.reject(me)}catch(st){console.error("Error marcando brief como rechazado:",st),window.alert(st instanceof Error?st.message:"No se pudo mover el brief a Rechazados. Revisa Supabase e intenta de nuevo.")}finally{B(null)}}},It=(k==null?void 0:k.displayName)??(k==null?void 0:k.email)??"Usuario",fe=I?"Jefe CDC":"Usuario CDC",Ue=D6(k==null?void 0:k.displayName,k==null?void 0:k.email);return f.jsxs("div",{className:"min-h-screen bg-background",children:[f.jsx("header",{className:"sticky top-0 z-30 bg-background/85 backdrop-blur-md border-b border-border",children:f.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-3.5 flex items-center gap-4",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(Hg,{size:"sm"}),f.jsx("div",{className:"h-7 w-px bg-border"}),f.jsx("h1",{className:"text-[15px] font-semibold tracking-tight text-[#4F758B]",children:"CDC Project Management"})]}),f.jsxs("div",{className:"flex-1 max-w-md ml-4 relative hidden md:block",children:[f.jsx(co,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),f.jsx(lt,{value:d,onChange:me=>h(me.target.value),placeholder:q?"Buscar brief, cliente, marca…":"Buscar proyecto, cliente, marca…",className:"pl-9 h-9 bg-muted/40 border-transparent focus-visible:bg-card focus-visible:border-border"})]}),f.jsx("div",{className:"flex-1 md:flex-none"}),f.jsxs(nI,{children:[f.jsx(rI,{asChild:!0,children:f.jsxs(ke,{variant:"ghost",size:"sm",className:"gap-2 h-9 px-2.5",children:[f.jsxs(aC,{className:"w-7 h-7",children:[(k==null?void 0:k.photoURL)&&f.jsx(sC,{src:k.photoURL,alt:It,referrerPolicy:"no-referrer"}),f.jsx(iC,{className:I?"bg-primary text-primary-foreground text-xs":"bg-accent text-accent-foreground text-xs",children:Ue})]}),f.jsxs("div",{className:"text-left leading-tight hidden sm:block",children:[f.jsx("div",{className:"text-xs font-medium",children:It}),f.jsx("div",{className:"text-[10px] text-muted-foreground",children:fe})]}),f.jsx(qg,{className:"w-3.5 h-3.5 text-muted-foreground"})]})}),f.jsxs(GE,{align:"end",className:"w-52",children:[f.jsxs("div",{className:"px-3 py-2",children:[f.jsx("p",{className:"text-xs font-medium truncate",children:It}),f.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:k==null?void 0:k.email})]}),f.jsx(YE,{}),f.jsxs(KE,{onClick:ee,className:"gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer",children:[f.jsx(R3,{className:"w-3.5 h-3.5"}),"Cerrar sesión"]})]})]}),te&&f.jsxs(ke,{type:"button",variant:"outline",onClick:()=>A(!0),className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[f.jsx(u1,{className:"w-4 h-4"})," Tarifario"]}),te&&f.jsxs(ke,{type:"button",variant:"outline",onClick:()=>M(!0),className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[f.jsx(Cd,{className:"w-4 h-4"})," Listas"]}),f.jsxs(ke,{onClick:Nt,className:"gap-1.5 h-9 rounded-full px-4 shadow-sm",children:[f.jsx(Pr,{className:"w-4 h-4"})," Nuevo"]})]})}),f.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 pt-6 pb-3 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:m==="nuevos"?"Briefs por revisar":m==="no_aprobados"?"Briefs rechazados":"Proyectos"}),m==="nuevos"&&f.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Los briefs de CDC Brief llegan aquí antes de convertirse en proyectos Activos."}),m==="no_aprobados"&&f.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Briefs revisados que no se incorporaron al tablero general."})]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"inline-flex flex-wrap bg-muted/60 rounded-full p-1 text-xs",children:[["todos","Todos"],["abiertos","Activos"],["cerrados","Cerrados"],["nuevos","Nuevos"],["no_aprobados","Rechazados"]].map(([me,$e])=>f.jsxs("button",{onClick:()=>b(me),className:`inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full transition-colors font-medium ${m===me?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[f.jsx("span",{children:$e}),me==="nuevos"&&Q.unreadCount>0&&f.jsx("span",{className:"inline-flex min-w-[18px] h-[18px] items-center justify-center rounded-full bg-red-500 px-1 text-[10px] font-bold leading-none text-white shadow-sm","aria-label":`${Q.unreadCount} briefs nuevos sin revisar`,children:Q.unreadCount>99?"99+":Q.unreadCount})]},me))})})]}),f.jsxs("div",{className:"relative md:hidden",children:[f.jsx(co,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),f.jsx(lt,{value:d,onChange:me=>h(me.target.value),placeholder:q?"Buscar brief, cliente, marca…":"Buscar proyecto, cliente, marca…",className:"pl-9 h-9 bg-muted/40 border-transparent focus-visible:bg-card focus-visible:border-border"})]}),!q&&f.jsx(I6,{filters:g,activeCount:qe,countryOptions:ht,brandOptions:Ye,clientOptions:mt,cmOptions:zt,onFilterChange:gn,onClear:fn}),vt&&f.jsx(z6,{totalAmount:oe.totalAmount,projectCount:oe.projectCount,loading:se||ze,error:Re||Qe,hasFilters:m!=="todos"||d.trim().length>0||qe>0,canControlVisibility:H,isPublic:Ne,visibilitySaving:Oe,onToggleVisibility:()=>Ze(!Ne).catch(()=>{})})]}),f.jsxs("main",{className:"max-w-[1400px] mx-auto px-6 pb-16",children:[(q?R.error:W)&&f.jsxs("div",{className:"mb-4 flex flex-col gap-3 rounded-2xl border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("span",{className:"flex items-start gap-2",children:[f.jsx(Ed,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),f.jsxs("span",{children:[f.jsx("span",{className:"font-medium",children:q?"No se pudieron cargar los briefs.":"No se pudieron cargar los proyectos."})," ",q?R.error:W]})]}),f.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>void(q?R.refresh():J()),className:"gap-1.5",children:[f.jsx(Zd,{className:"h-3.5 w-3.5"})," Reintentar"]})]}),q?R.loading&&R.items.length===0?f.jsx(X_,{}):R.items.length===0?f.jsx(B6,{mode:ue,query:d}):f.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3",children:R.items.map(me=>f.jsx(B8,{item:me,mode:ue,busy:L===me.id,onApprove:()=>void cr(me.id,me.title,ue==="rejected"),onReject:()=>void ur(me.id,me.title)},me.id))}):K&&ve.length===0?f.jsx(X_,{}):ve.length===0?f.jsx(H6,{onNew:Nt,hasProjects:pe>0||le!=="todos"||d.trim().length>0||qe>0,filter:le,query:d,activeAdvancedFilterCount:qe}):f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:ve.map(me=>f.jsx(CI,{project:me,onClick:()=>Kt(me),onTimeClick:()=>z(me),showInternalAmount:X},me.id))}),ce>Ms&&f.jsx(U6,{currentPage:ct,totalPages:Pe,visibleStart:Dt,visibleEnd:Gt,totalItems:ce,itemLabel:q?"briefs":"proyectos",onPageChange:dn})]}),f.jsx(R8,{open:s,onOpenChange:i,project:l,onDelete:Tt,deleting:!!l&&S===l.id}),f.jsx(U8,{open:!!U,onOpenChange:me=>{me||z(null)},project:U}),te&&f.jsxs(f.Fragment,{children:[f.jsx(E6,{open:C,onOpenChange:A}),f.jsx(O6,{open:T,onOpenChange:M})]})]})}function P6(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e||0)}function z6({totalAmount:e,projectCount:t,loading:n,error:s,hasFilters:i,canControlVisibility:l,isPublic:c,visibilitySaving:d,onToggleVisibility:h}){return f.jsx("div",{className:"rounded-2xl border border-primary/15 bg-primary/5 px-4 py-3 shadow-sm",children:f.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("span",{className:"mt-0.5 flex h-9 w-9 items-center justify-center rounded-xl bg-primary/10 text-primary",children:f.jsx(Jp,{className:"h-4 w-4"})}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:i?"Total tarifado filtrado":"Total tarifado global"}),f.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${c?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-primary/20 bg-card text-primary"}`,children:c?"Visible para todos":"Privado"})]}),f.jsx("p",{className:"mt-0.5 text-2xl font-semibold tracking-tight text-foreground",children:n?"Calculando…":P6(e)}),f.jsx("p",{className:"text-xs text-muted-foreground",children:s?`No se pudo calcular el total: ${s}`:`${t} proyecto(s) incluidos según los filtros actuales.`})]})]}),f.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center lg:justify-end",children:[f.jsx("div",{className:"rounded-full border border-primary/20 bg-card px-3 py-1 text-xs font-medium text-primary",children:i?"Según filtros activos":"Sin filtros aplicados"}),l&&f.jsxs(ke,{type:"button",variant:c?"secondary":"outline",size:"sm",className:"gap-1.5 rounded-full",disabled:d,onClick:h,title:c?"Ocultar este total para los demás usuarios":"Mostrar este total temporalmente a todos los usuarios",children:[c?f.jsx(n3,{className:"h-3.5 w-3.5"}):f.jsx(a3,{className:"h-3.5 w-3.5"}),d?"Actualizando…":c?"Ocultar a todos":"Mostrar a todos"]})]})]})})}function I6({filters:e,activeCount:t,countryOptions:n,brandOptions:s,clientOptions:i,cmOptions:l,onFilterChange:c,onClear:d}){return f.jsx("div",{className:"rounded-2xl border border-border bg-card/70 px-3.5 py-3 shadow-sm",children:f.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center",children:[f.jsxs("div",{className:"flex items-center justify-between gap-3 lg:w-auto lg:min-w-[120px] lg:justify-start",children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[f.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary",children:f.jsx(q3,{className:"h-4 w-4"})}),f.jsx("span",{children:"Filtros"}),t>0&&f.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:t})]}),t>0&&f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",onClick:d,className:"h-8 rounded-full px-2.5 text-xs text-muted-foreground hover:text-foreground lg:hidden",children:[f.jsx(uo,{className:"mr-1 h-3.5 w-3.5"}),"Limpiar"]})]}),f.jsxs("div",{className:"grid flex-1 grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-4",children:[f.jsx(xr,{value:e.country,options:n,onValueChange:h=>c("country",h),placeholder:"País: Todos",searchPlaceholder:"Buscar país…",emptyText:"No se encontró ese país.",clearLabel:"Todos"}),f.jsx(xr,{value:e.brand,options:s,onValueChange:h=>c("brand",h),placeholder:"Marca: Todas",searchPlaceholder:"Buscar marca…",emptyText:"No se encontró esa marca.",clearLabel:"Todas"}),f.jsx(xr,{value:e.client,options:i,onValueChange:h=>c("client",h),placeholder:"Cliente: Todos",searchPlaceholder:"Buscar cliente…",emptyText:"No se encontró ese cliente.",clearLabel:"Todos"}),f.jsx(xr,{value:e.cm,options:l,onValueChange:h=>c("cm",h),placeholder:"CM: Todos",searchPlaceholder:"Buscar CM…",emptyText:"No se encontró ese CM.",clearLabel:"Todos"})]}),f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",onClick:d,disabled:t===0,className:"hidden h-9 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground lg:inline-flex",children:[f.jsx(uo,{className:"mr-1 h-3.5 w-3.5"}),"Limpiar"]})]})})}function U6({currentPage:e,totalPages:t,visibleStart:n,visibleEnd:s,totalItems:i,itemLabel:l="proyectos",onPageChange:c}){const d=$6(e,t);return f.jsxs("div",{className:"mt-6 flex flex-col sm:flex-row items-center justify-between gap-3 rounded-2xl border border-border bg-card/70 px-4 py-3",children:[f.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.jsxs("span",{className:"font-medium text-foreground",children:[n,"-",s]})," ","de ",f.jsx("span",{className:"font-medium text-foreground",children:i})," ",l]}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 rounded-full px-2.5",onClick:()=>c(e-1),disabled:e===1,children:[f.jsx(Vg,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),f.jsx("div",{className:"flex items-center gap-1",children:d.map((h,m)=>h==="ellipsis"?f.jsx("span",{className:"flex h-8 w-8 items-center justify-center text-xs text-muted-foreground",children:"…"},`ellipsis-${m}`):f.jsx(ke,{type:"button",variant:h===e?"default":"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 text-xs",onClick:()=>c(h),"aria-current":h===e?"page":void 0,children:h},h))}),f.jsxs(ke,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1 rounded-full px-2.5",onClick:()=>c(e+1),disabled:e===t,children:[f.jsx("span",{className:"hidden sm:inline",children:"Siguiente"}),f.jsx(Qd,{className:"h-4 w-4"})]})]})]})}function $6(e,t){if(t<=7)return Array.from({length:t},(i,l)=>l+1);const n=new Set([1,t,e]);return e>1&&n.add(e-1),e<t&&n.add(e+1),e<=3&&(n.add(2),n.add(3),n.add(4)),e>=t-2&&(n.add(t-3),n.add(t-2),n.add(t-1)),Array.from(n).filter(i=>i>=1&&i<=t).sort((i,l)=>i-l).reduce((i,l)=>{const c=i[i.length-1];return typeof c=="number"&&l-c>1&&i.push("ellipsis"),i.push(l),i},[])}function X_(){return f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((e,t)=>f.jsxs("div",{className:"min-h-[230px] overflow-hidden rounded-2xl border border-border bg-card",children:[f.jsx("div",{className:"h-14 bg-muted animate-pulse"}),f.jsxs("div",{className:"space-y-3 p-4",children:[f.jsx("div",{className:"h-3 w-3/4 rounded-full bg-muted animate-pulse"}),f.jsx("div",{className:"h-3 w-2/3 rounded-full bg-muted animate-pulse"}),f.jsx("div",{className:"h-3 w-1/2 rounded-full bg-muted animate-pulse"}),f.jsx("div",{className:"mt-6 h-8 rounded-full bg-muted animate-pulse"})]})]},t))})}function B6({mode:e,query:t}){const n=t.trim().length>0,s=e==="rejected";return f.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-card/40 py-24 text-center",children:[f.jsx("div",{className:`mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl ${s?"bg-red-50 text-red-600":"bg-amber-50 text-amber-700"}`,children:s?f.jsx(l3,{className:"h-6 w-6"}):f.jsx(m3,{className:"h-6 w-6"})}),f.jsx("h3",{className:"text-lg font-semibold",children:n?"No hay briefs que coincidan con la búsqueda":s?"No hay briefs rechazados":"No hay briefs pendientes"}),f.jsx("p",{className:"mx-auto mt-1 max-w-md text-sm text-muted-foreground",children:n?"Prueba con otro nombre, cliente, marca, país o solicitante.":s?"Los briefs que el equipo decida no convertir en proyecto aparecerán aquí.":"Cuando CDC Brief genere un nuevo brief, aparecerá aquí automáticamente para revisión."})]})}function H6({onNew:e,hasProjects:t,filter:n,query:s,activeAdvancedFilterCount:i}){const l=s.trim().length>0,c=i>0;let d="Tu tablero está vacío",h="Crea tu primer proyecto para que el equipo pueda darle seguimiento.";return t&&l&&c?(d="Nada coincide con la búsqueda y filtros",h="Intenta cambiar la búsqueda, limpiar filtros o seleccionar otras opciones."):t&&l?(d="Nada coincide con la búsqueda",h="Intenta cambiar la búsqueda o borrar el texto escrito."):t&&c?(d="Nada coincide con los filtros",h="Intenta limpiar filtros o seleccionar otras opciones."):t&&n==="abiertos"?(d="No hay proyectos activos",h="Cuando se cree un proyecto nuevo, aparecerá en esta pestaña."):t&&n==="cerrados"?(d="No hay proyectos cerrados",h="Cuando el Director Creativo asigne un estatus a un proyecto, aparecerá aquí."):t&&(d="Nada coincide con el filtro",h="Intenta quitar el filtro o cambiar la búsqueda."),f.jsxs("div",{className:"text-center py-24 rounded-2xl border border-dashed border-border bg-card/40",children:[f.jsx("div",{className:"w-14 h-14 rounded-2xl bg-primary/10 mx-auto flex items-center justify-center mb-4",children:f.jsx(x3,{className:"w-6 h-6 text-primary"})}),f.jsx("h3",{className:"text-lg font-semibold",children:d}),f.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm mx-auto",children:h}),!t&&f.jsxs(ke,{onClick:e,className:"mt-5 gap-1.5 rounded-full",children:[f.jsx(Pr,{className:"w-4 h-4"})," Crear proyecto"]})]})}const q6=({...e})=>f.jsx(x8,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});class V6 extends v.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:f.jsxs("div",{className:"max-w-md text-center",children:[f.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground",children:"Ocurrió un error al cargar el tablero."}),f.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Intenta recargar la página."}),f.jsx("div",{className:"mt-6",children:f.jsx("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:"Recargar"})})]})}):this.props.children}}function F6(){const{user:e,loading:t}=Xd();return t&&!e?f.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:f.jsxs("div",{className:"flex flex-col items-center gap-3",children:[f.jsx("div",{className:"animate-pulse",children:f.jsx(Hg,{showWordmark:!1})}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Cargando tablero…"})]})}):e?f.jsx(Mk,{children:f.jsx(pS,{path:"/*",element:f.jsx(L6,{})})}):f.jsx(w5,{})}function G6(){return f.jsx(V6,{children:f.jsx(xD,{children:f.jsxs(r2,{basename:"/tablero-cdc/",children:[f.jsx(F6,{}),f.jsx(q6,{richColors:!0,position:"top-right"})]})})})}DR.createRoot(document.getElementById("root")).render(f.jsx(v.StrictMode,{children:f.jsx(G6,{})}));