@realtimex/email-automator 2.19.2 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/src/services/gmail.ts +24 -5
- package/api/src/services/microsoft.ts +25 -2
- package/dist/api/src/services/gmail.js +16 -0
- package/dist/api/src/services/microsoft.js +15 -0
- package/dist/assets/es-jMIxKu3w.js +1 -0
- package/dist/assets/{fr-CUSL8GiW.js → fr-C2DJGnGk.js} +1 -1
- package/dist/assets/index-Czj6FLF_.js +105 -0
- package/dist/assets/index-dbXCkqFe.css +1 -0
- package/dist/assets/ja-BAbHgg3S.js +1 -0
- package/dist/assets/ko-BqELMO5T.js +1 -0
- package/dist/assets/vi-D_3oX_6P.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/supabase/functions/_shared/gmail-service.ts +4 -0
- package/supabase/functions/_shared/microsoft-service.ts +4 -0
- package/supabase/functions/api-v1-drafts/index.ts +270 -0
- package/supabase/migrations/20260201000000_add_draft_tracking.sql +54 -0
- package/dist/assets/es-161lTAAC.js +0 -1
- package/dist/assets/index-CC1sfcme.css +0 -1
- package/dist/assets/index-CTzd_S0s.js +0 -105
- package/dist/assets/ja-BFTHcNh2.js +0 -1
- package/dist/assets/ko-BBna20Zx.js +0 -1
- package/dist/assets/vi-BckXN65g.js +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function cN(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const l in r)if(l!=="default"&&!(l in t)){const u=Object.getOwnPropertyDescriptor(r,l);u&&Object.defineProperty(t,l,u.get?u:{enumerable:!0,get:()=>r[l]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(l){if(l.ep)return;l.ep=!0;const u=n(l);fetch(l.href,u)}})();function jm(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Kh={exports:{}},No={};var h0;function uN(){if(h0)return No;h0=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,l,u){var d=null;if(u!==void 0&&(d=""+u),l.key!==void 0&&(d=""+l.key),"key"in l){u={};for(var f in l)f!=="key"&&(u[f]=l[f])}else u=l;return l=u.ref,{$$typeof:t,type:r,key:d,ref:l!==void 0?l:null,props:u}}return No.Fragment=e,No.jsx=n,No.jsxs=n,No}var f0;function dN(){return f0||(f0=1,Kh.exports=uN()),Kh.exports}var o=dN(),Yh={exports:{}},je={};var m0;function hN(){if(m0)return je;m0=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(R){return R===null||typeof R!="object"?null:(R=b&&R[b]||R["@@iterator"],typeof R=="function"?R:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,E={};function T(R,Y,Z){this.props=R,this.context=Y,this.refs=E,this.updater=Z||_}T.prototype.isReactComponent={},T.prototype.setState=function(R,Y){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,Y,"setState")},T.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function D(){}D.prototype=T.prototype;function A(R,Y,Z){this.props=R,this.context=Y,this.refs=E,this.updater=Z||_}var U=A.prototype=new D;U.constructor=A,N(U,T.prototype),U.isPureReactComponent=!0;var H=Array.isArray;function G(){}var z={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function J(R,Y,Z){var te=Z.ref;return{$$typeof:t,type:R,key:Y,ref:te!==void 0?te:null,props:Z}}function ie(R,Y){return J(R.type,Y,R.props)}function be(R){return typeof R=="object"&&R!==null&&R.$$typeof===t}function de(R){var Y={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(Z){return Y[Z]})}var Ve=/\/+/g;function Ie(R,Y){return typeof R=="object"&&R!==null&&R.key!=null?de(""+R.key):Y.toString(36)}function ee(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(G,G):(R.status="pending",R.then(function(Y){R.status==="pending"&&(R.status="fulfilled",R.value=Y)},function(Y){R.status==="pending"&&(R.status="rejected",R.reason=Y)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function C(R,Y,Z,te,we){var _e=typeof R;(_e==="undefined"||_e==="boolean")&&(R=null);var ge=!1;if(R===null)ge=!0;else switch(_e){case"bigint":case"string":case"number":ge=!0;break;case"object":switch(R.$$typeof){case t:case e:ge=!0;break;case y:return ge=R._init,C(ge(R._payload),Y,Z,te,we)}}if(ge)return we=we(R),ge=te===""?"."+Ie(R,0):te,H(we)?(Z="",ge!=null&&(Z=ge.replace(Ve,"$&/")+"/"),C(we,Y,Z,"",function(ls){return ls})):we!=null&&(be(we)&&(we=ie(we,Z+(we.key==null||R&&R.key===we.key?"":(""+we.key).replace(Ve,"$&/")+"/")+ge)),Y.push(we)),1;ge=0;var lt=te===""?".":te+":";if(H(R))for(var Le=0;Le<R.length;Le++)te=R[Le],_e=lt+Ie(te,Le),ge+=C(te,Y,Z,_e,we);else if(Le=S(R),typeof Le=="function")for(R=Le.call(R),Le=0;!(te=R.next()).done;)te=te.value,_e=lt+Ie(te,Le++),ge+=C(te,Y,Z,_e,we);else if(_e==="object"){if(typeof R.then=="function")return C(ee(R),Y,Z,te,we);throw Y=String(R),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ge}function q(R,Y,Z){if(R==null)return R;var te=[],we=0;return C(R,te,"","",function(_e){return Y.call(Z,_e,we++)}),te}function B(R){if(R._status===-1){var Y=R._result;Y=Y(),Y.then(function(Z){(R._status===0||R._status===-1)&&(R._status=1,R._result=Z)},function(Z){(R._status===0||R._status===-1)&&(R._status=2,R._result=Z)}),R._status===-1&&(R._status=0,R._result=Y)}if(R._status===1)return R._result.default;throw R._result}var re=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=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(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},pe={map:q,forEach:function(R,Y,Z){q(R,function(){Y.apply(this,arguments)},Z)},count:function(R){var Y=0;return q(R,function(){Y++}),Y},toArray:function(R){return q(R,function(Y){return Y})||[]},only:function(R){if(!be(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return je.Activity=v,je.Children=pe,je.Component=T,je.Fragment=n,je.Profiler=l,je.PureComponent=A,je.StrictMode=r,je.Suspense=p,je.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=z,je.__COMPILER_RUNTIME={__proto__:null,c:function(R){return z.H.useMemoCache(R)}},je.cache=function(R){return function(){return R.apply(null,arguments)}},je.cacheSignal=function(){return null},je.cloneElement=function(R,Y,Z){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var te=N({},R.props),we=R.key;if(Y!=null)for(_e in Y.key!==void 0&&(we=""+Y.key),Y)!M.call(Y,_e)||_e==="key"||_e==="__self"||_e==="__source"||_e==="ref"&&Y.ref===void 0||(te[_e]=Y[_e]);var _e=arguments.length-2;if(_e===1)te.children=Z;else if(1<_e){for(var ge=Array(_e),lt=0;lt<_e;lt++)ge[lt]=arguments[lt+2];te.children=ge}return J(R.type,we,te)},je.createContext=function(R){return R={$$typeof:d,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:u,_context:R},R},je.createElement=function(R,Y,Z){var te,we={},_e=null;if(Y!=null)for(te in Y.key!==void 0&&(_e=""+Y.key),Y)M.call(Y,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(we[te]=Y[te]);var ge=arguments.length-2;if(ge===1)we.children=Z;else if(1<ge){for(var lt=Array(ge),Le=0;Le<ge;Le++)lt[Le]=arguments[Le+2];we.children=lt}if(R&&R.defaultProps)for(te in ge=R.defaultProps,ge)we[te]===void 0&&(we[te]=ge[te]);return J(R,_e,we)},je.createRef=function(){return{current:null}},je.forwardRef=function(R){return{$$typeof:f,render:R}},je.isValidElement=be,je.lazy=function(R){return{$$typeof:y,_payload:{_status:-1,_result:R},_init:B}},je.memo=function(R,Y){return{$$typeof:m,type:R,compare:Y===void 0?null:Y}},je.startTransition=function(R){var Y=z.T,Z={};z.T=Z;try{var te=R(),we=z.S;we!==null&&we(Z,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(G,re)}catch(_e){re(_e)}finally{Y!==null&&Z.types!==null&&(Y.types=Z.types),z.T=Y}},je.unstable_useCacheRefresh=function(){return z.H.useCacheRefresh()},je.use=function(R){return z.H.use(R)},je.useActionState=function(R,Y,Z){return z.H.useActionState(R,Y,Z)},je.useCallback=function(R,Y){return z.H.useCallback(R,Y)},je.useContext=function(R){return z.H.useContext(R)},je.useDebugValue=function(){},je.useDeferredValue=function(R,Y){return z.H.useDeferredValue(R,Y)},je.useEffect=function(R,Y){return z.H.useEffect(R,Y)},je.useEffectEvent=function(R){return z.H.useEffectEvent(R)},je.useId=function(){return z.H.useId()},je.useImperativeHandle=function(R,Y,Z){return z.H.useImperativeHandle(R,Y,Z)},je.useInsertionEffect=function(R,Y){return z.H.useInsertionEffect(R,Y)},je.useLayoutEffect=function(R,Y){return z.H.useLayoutEffect(R,Y)},je.useMemo=function(R,Y){return z.H.useMemo(R,Y)},je.useOptimistic=function(R,Y){return z.H.useOptimistic(R,Y)},je.useReducer=function(R,Y,Z){return z.H.useReducer(R,Y,Z)},je.useRef=function(R){return z.H.useRef(R)},je.useState=function(R){return z.H.useState(R)},je.useSyncExternalStore=function(R,Y,Z){return z.H.useSyncExternalStore(R,Y,Z)},je.useTransition=function(){return z.H.useTransition()},je.version="19.2.3",je}var p0;function Nm(){return p0||(p0=1,Yh.exports=hN()),Yh.exports}var w=Nm();const Db=jm(w),Em=cN({__proto__:null,default:Db},[w]);var Xh={exports:{}},Eo={},Wh={exports:{}},Jh={};var g0;function fN(){return g0||(g0=1,(function(t){function e(C,q){var B=C.length;C.push(q);e:for(;0<B;){var re=B-1>>>1,pe=C[re];if(0<l(pe,q))C[re]=q,C[B]=pe,B=re;else break e}}function n(C){return C.length===0?null:C[0]}function r(C){if(C.length===0)return null;var q=C[0],B=C.pop();if(B!==q){C[0]=B;e:for(var re=0,pe=C.length,R=pe>>>1;re<R;){var Y=2*(re+1)-1,Z=C[Y],te=Y+1,we=C[te];if(0>l(Z,B))te<pe&&0>l(we,Z)?(C[re]=we,C[te]=B,re=te):(C[re]=Z,C[Y]=B,re=Y);else if(te<pe&&0>l(we,B))C[re]=we,C[te]=B,re=te;else break e}}return q}function l(C,q){var B=C.sortIndex-q.sortIndex;return B!==0?B:C.id-q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();t.unstable_now=function(){return d.now()-f}}var p=[],m=[],y=1,v=null,b=3,S=!1,_=!1,N=!1,E=!1,T=typeof setTimeout=="function"?setTimeout:null,D=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function U(C){for(var q=n(m);q!==null;){if(q.callback===null)r(m);else if(q.startTime<=C)r(m),q.sortIndex=q.expirationTime,e(p,q);else break;q=n(m)}}function H(C){if(N=!1,U(C),!_)if(n(p)!==null)_=!0,G||(G=!0,de());else{var q=n(m);q!==null&&ee(H,q.startTime-C)}}var G=!1,z=-1,M=5,J=-1;function ie(){return E?!0:!(t.unstable_now()-J<M)}function be(){if(E=!1,G){var C=t.unstable_now();J=C;var q=!0;try{e:{_=!1,N&&(N=!1,D(z),z=-1),S=!0;var B=b;try{t:{for(U(C),v=n(p);v!==null&&!(v.expirationTime>C&&ie());){var re=v.callback;if(typeof re=="function"){v.callback=null,b=v.priorityLevel;var pe=re(v.expirationTime<=C);if(C=t.unstable_now(),typeof pe=="function"){v.callback=pe,U(C),q=!0;break t}v===n(p)&&r(p),U(C)}else r(p);v=n(p)}if(v!==null)q=!0;else{var R=n(m);R!==null&&ee(H,R.startTime-C),q=!1}}break e}finally{v=null,b=B,S=!1}q=void 0}}finally{q?de():G=!1}}}var de;if(typeof A=="function")de=function(){A(be)};else if(typeof MessageChannel<"u"){var Ve=new MessageChannel,Ie=Ve.port2;Ve.port1.onmessage=be,de=function(){Ie.postMessage(null)}}else de=function(){T(be,0)};function ee(C,q){z=T(function(){C(t.unstable_now())},q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(C){C.callback=null},t.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<C?Math.floor(1e3/C):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(C){switch(b){case 1:case 2:case 3:var q=3;break;default:q=b}var B=b;b=q;try{return C()}finally{b=B}},t.unstable_requestPaint=function(){E=!0},t.unstable_runWithPriority=function(C,q){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var B=b;b=C;try{return q()}finally{b=B}},t.unstable_scheduleCallback=function(C,q,B){var re=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?re+B:re):B=re,C){case 1:var pe=-1;break;case 2:pe=250;break;case 5:pe=1073741823;break;case 4:pe=1e4;break;default:pe=5e3}return pe=B+pe,C={id:y++,callback:q,priorityLevel:C,startTime:B,expirationTime:pe,sortIndex:-1},B>re?(C.sortIndex=B,e(m,C),n(p)===null&&C===n(m)&&(N?(D(z),z=-1):N=!0,ee(H,B-re))):(C.sortIndex=pe,e(p,C),_||S||(_=!0,G||(G=!0,de()))),C},t.unstable_shouldYield=ie,t.unstable_wrapCallback=function(C){var q=b;return function(){var B=b;b=q;try{return C.apply(this,arguments)}finally{b=B}}}})(Jh)),Jh}var y0;function mN(){return y0||(y0=1,Wh.exports=fN()),Wh.exports}var Qh={exports:{}},Ut={};var v0;function pN(){if(v0)return Ut;v0=1;var t=Nm();function e(p){var m="https://react.dev/errors/"+p;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+p+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},l=Symbol.for("react.portal");function u(p,m,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:v==null?null:""+v,children:p,containerInfo:m,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(p,m){if(p==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return Ut.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ut.createPortal=function(p,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(e(299));return u(p,m,null,y)},Ut.flushSync=function(p){var m=d.T,y=r.p;try{if(d.T=null,r.p=2,p)return p()}finally{d.T=m,r.p=y,r.d.f()}},Ut.preconnect=function(p,m){typeof p=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,r.d.C(p,m))},Ut.prefetchDNS=function(p){typeof p=="string"&&r.d.D(p)},Ut.preinit=function(p,m){if(typeof p=="string"&&m&&typeof m.as=="string"){var y=m.as,v=f(y,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?r.d.S(p,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&r.d.X(p,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},Ut.preinitModule=function(p,m){if(typeof p=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=f(m.as,m.crossOrigin);r.d.M(p,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&r.d.M(p)},Ut.preload=function(p,m){if(typeof p=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,v=f(y,m.crossOrigin);r.d.L(p,y,{crossOrigin:v,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})}},Ut.preloadModule=function(p,m){if(typeof p=="string")if(m){var y=f(m.as,m.crossOrigin);r.d.m(p,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else r.d.m(p)},Ut.requestFormReset=function(p){r.d.r(p)},Ut.unstable_batchedUpdates=function(p,m){return p(m)},Ut.useFormState=function(p,m,y){return d.H.useFormState(p,m,y)},Ut.useFormStatus=function(){return d.H.useHostTransitionStatus()},Ut.version="19.2.3",Ut}var x0;function Mb(){if(x0)return Qh.exports;x0=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Qh.exports=pN(),Qh.exports}var b0;function gN(){if(b0)return Eo;b0=1;var t=mN(),e=Nm(),n=Mb();function r(s){var a="https://react.dev/errors/"+s;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)a+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+s+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function u(s){var a=s,i=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(i=a.return),s=a.return;while(s)}return a.tag===3?i:null}function d(s){if(s.tag===13){var a=s.memoizedState;if(a===null&&(s=s.alternate,s!==null&&(a=s.memoizedState)),a!==null)return a.dehydrated}return null}function f(s){if(s.tag===31){var a=s.memoizedState;if(a===null&&(s=s.alternate,s!==null&&(a=s.memoizedState)),a!==null)return a.dehydrated}return null}function p(s){if(u(s)!==s)throw Error(r(188))}function m(s){var a=s.alternate;if(!a){if(a=u(s),a===null)throw Error(r(188));return a!==s?null:s}for(var i=s,c=a;;){var h=i.return;if(h===null)break;var g=h.alternate;if(g===null){if(c=h.return,c!==null){i=c;continue}break}if(h.child===g.child){for(g=h.child;g;){if(g===i)return p(h),s;if(g===c)return p(h),a;g=g.sibling}throw Error(r(188))}if(i.return!==c.return)i=h,c=g;else{for(var x=!1,j=h.child;j;){if(j===i){x=!0,i=h,c=g;break}if(j===c){x=!0,c=h,i=g;break}j=j.sibling}if(!x){for(j=g.child;j;){if(j===i){x=!0,i=g,c=h;break}if(j===c){x=!0,c=g,i=h;break}j=j.sibling}if(!x)throw Error(r(189))}}if(i.alternate!==c)throw Error(r(190))}if(i.tag!==3)throw Error(r(188));return i.stateNode.current===i?s:a}function y(s){var a=s.tag;if(a===5||a===26||a===27||a===6)return s;for(s=s.child;s!==null;){if(a=y(s),a!==null)return a;s=s.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),A=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ie=Symbol.for("react.memo_cache_sentinel"),be=Symbol.iterator;function de(s){return s===null||typeof s!="object"?null:(s=be&&s[be]||s["@@iterator"],typeof s=="function"?s:null)}var Ve=Symbol.for("react.client.reference");function Ie(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===Ve?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case N:return"Fragment";case T:return"Profiler";case E:return"StrictMode";case H:return"Suspense";case G:return"SuspenseList";case J:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case _:return"Portal";case A:return s.displayName||"Context";case D:return(s._context.displayName||"Context")+".Consumer";case U:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case z:return a=s.displayName||null,a!==null?a:Ie(s.type)||"Memo";case M:a=s._payload,s=s._init;try{return Ie(s(a))}catch{}}return null}var ee=Array.isArray,C=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},re=[],pe=-1;function R(s){return{current:s}}function Y(s){0>pe||(s.current=re[pe],re[pe]=null,pe--)}function Z(s,a){pe++,re[pe]=s.current,s.current=a}var te=R(null),we=R(null),_e=R(null),ge=R(null);function lt(s,a){switch(Z(_e,a),Z(we,s),Z(te,null),a.nodeType){case 9:case 11:s=(s=a.documentElement)&&(s=s.namespaceURI)?zv(s):0;break;default:if(s=a.tagName,a=a.namespaceURI)a=zv(a),s=Lv(a,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}Y(te),Z(te,s)}function Le(){Y(te),Y(we),Y(_e)}function ls(s){s.memoizedState!==null&&Z(ge,s);var a=te.current,i=Lv(a,s.type);a!==i&&(Z(we,s),Z(te,i))}function Gt(s){we.current===s&&(Y(te),Y(we)),ge.current===s&&(Y(ge),wo._currentValue=B)}var Et,js;function Ns(s){if(Et===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);Et=a&&a[1]||"",js=-1<i.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Et+s+js}var ca=!1;function ar(s,a){if(!s||ca)return"";ca=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var W=function(){throw Error()};if(Object.defineProperty(W.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(W,[])}catch(F){var $=F}Reflect.construct(s,[],W)}else{try{W.call()}catch(F){$=F}s.call(W.prototype)}}else{try{throw Error()}catch(F){$=F}(W=s())&&typeof W.catch=="function"&&W.catch(function(){})}}catch(F){if(F&&$&&typeof F.stack=="string")return[F.stack,$.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),x=g[0],j=g[1];if(x&&j){var k=x.split(`
|
|
4
|
+
`),V=j.split(`
|
|
5
|
+
`);for(h=c=0;c<k.length&&!k[c].includes("DetermineComponentFrameRoot");)c++;for(;h<V.length&&!V[h].includes("DetermineComponentFrameRoot");)h++;if(c===k.length||h===V.length)for(c=k.length-1,h=V.length-1;1<=c&&0<=h&&k[c]!==V[h];)h--;for(;1<=c&&0<=h;c--,h--)if(k[c]!==V[h]){if(c!==1||h!==1)do if(c--,h--,0>h||k[c]!==V[h]){var K=`
|
|
6
|
+
`+k[c].replace(" at new "," at ");return s.displayName&&K.includes("<anonymous>")&&(K=K.replace("<anonymous>",s.displayName)),K}while(1<=c&&0<=h);break}}}finally{ca=!1,Error.prepareStackTrace=i}return(i=s?s.displayName||s.name:"")?Ns(i):""}function ol(s,a){switch(s.tag){case 26:case 27:case 5:return Ns(s.type);case 16:return Ns("Lazy");case 13:return s.child!==a&&a!==null?Ns("Suspense Fallback"):Ns("Suspense");case 19:return Ns("SuspenseList");case 0:case 15:return ar(s.type,!1);case 11:return ar(s.type.render,!1);case 1:return ar(s.type,!0);case 31:return Ns("Activity");default:return""}}function Ai(s){try{var a="",i=null;do a+=ol(s,i),i=s,s=s.return;while(s);return a}catch(c){return`
|
|
7
|
+
Error generating stack: `+c.message+`
|
|
8
|
+
`+c.stack}}var rr=Object.prototype.hasOwnProperty,ir=t.unstable_scheduleCallback,or=t.unstable_cancelCallback,ll=t.unstable_shouldYield,cl=t.unstable_requestPaint,Tt=t.unstable_now,lr=t.unstable_getCurrentPriorityLevel,ki=t.unstable_ImmediatePriority,Ci=t.unstable_UserBlockingPriority,ua=t.unstable_NormalPriority,Ks=t.unstable_LowPriority,ul=t.unstable_IdlePriority,cr=t.log,dl=t.unstable_setDisableYieldValue,Sn=null,At=null;function Ys(s){if(typeof cr=="function"&&dl(s),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Sn,s)}catch{}}var vt=Math.clz32?Math.clz32:Lu,hl=Math.log,zu=Math.LN2;function Lu(s){return s>>>=0,s===0?32:31-(hl(s)/zu|0)|0}var ur=256,Ri=262144,Oi=4194304;function Vt(s){var a=s&42;if(a!==0)return a;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function da(s,a,i){var c=s.pendingLanes;if(c===0)return 0;var h=0,g=s.suspendedLanes,x=s.pingedLanes;s=s.warmLanes;var j=c&134217727;return j!==0?(c=j&~g,c!==0?h=Vt(c):(x&=j,x!==0?h=Vt(x):i||(i=j&~s,i!==0&&(h=Vt(i))))):(j=c&~g,j!==0?h=Vt(j):x!==0?h=Vt(x):i||(i=c&~s,i!==0&&(h=Vt(i)))),h===0?0:a!==0&&a!==h&&(a&g)===0&&(g=h&-h,i=a&-a,g>=i||g===32&&(i&4194048)!==0)?a:h}function ha(s,a){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&a)===0}function Uu(s,a){switch(s){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 fl(){var s=Oi;return Oi<<=1,(Oi&62914560)===0&&(Oi=4194304),s}function Di(s){for(var a=[],i=0;31>i;i++)a.push(s);return a}function fa(s,a){s.pendingLanes|=a,a!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Pu(s,a,i,c,h,g){var x=s.pendingLanes;s.pendingLanes=i,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=i,s.entangledLanes&=i,s.errorRecoveryDisabledLanes&=i,s.shellSuspendCounter=0;var j=s.entanglements,k=s.expirationTimes,V=s.hiddenUpdates;for(i=x&~i;0<i;){var K=31-vt(i),W=1<<K;j[K]=0,k[K]=-1;var $=V[K];if($!==null)for(V[K]=null,K=0;K<$.length;K++){var F=$[K];F!==null&&(F.lane&=-536870913)}i&=~W}c!==0&&ml(s,c,0),g!==0&&h===0&&s.tag!==0&&(s.suspendedLanes|=g&~(x&~a))}function ml(s,a,i){s.pendingLanes|=a,s.suspendedLanes&=~a;var c=31-vt(a);s.entangledLanes|=a,s.entanglements[c]=s.entanglements[c]|1073741824|i&261930}function pl(s,a){var i=s.entangledLanes|=a;for(s=s.entanglements;i;){var c=31-vt(i),h=1<<c;h&a|s[c]&a&&(s[c]|=a),i&=~h}}function gl(s,a){var i=a&-a;return i=(i&42)!==0?1:Mi(i),(i&(s.suspendedLanes|a))!==0?0:i}function Mi(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=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:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function dr(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function yl(){var s=q.p;return s!==0?s:(s=window.event,s===void 0?32:r0(s.type))}function vl(s,a){var i=q.p;try{return q.p=s,a()}finally{q.p=i}}var Ls=Math.random().toString(36).slice(2),I="__reactFiber$"+Ls,ne="__reactProps$"+Ls,Ae="__reactContainer$"+Ls,Bt="__reactEvents$"+Ls,Vu="__reactListeners$"+Ls,xl="__reactHandles$"+Ls,ma="__reactResources$"+Ls,pa="__reactMarker$"+Ls;function zi(s){delete s[I],delete s[ne],delete s[Bt],delete s[Vu],delete s[xl]}function hr(s){var a=s[I];if(a)return a;for(var i=s.parentNode;i;){if(a=i[Ae]||i[I]){if(i=a.alternate,a.child!==null||i!==null&&i.child!==null)for(s=qv(s);s!==null;){if(i=s[I])return i;s=qv(s)}return a}s=i,i=s.parentNode}return null}function fr(s){if(s=s[I]||s[Ae]){var a=s.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return s}return null}function Li(s){var a=s.tag;if(a===5||a===26||a===27||a===6)return s.stateNode;throw Error(r(33))}function mr(s){var a=s[ma];return a||(a=s[ma]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function jt(s){s[pa]=!0}var _p=new Set,jp={};function ga(s,a){pr(s,a),pr(s+"Capture",a)}function pr(s,a){for(jp[s]=a,s=0;s<a.length;s++)_p.add(a[s])}var e_=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]*$"),Np={},Ep={};function t_(s){return rr.call(Ep,s)?!0:rr.call(Np,s)?!1:e_.test(s)?Ep[s]=!0:(Np[s]=!0,!1)}function bl(s,a,i){if(t_(a))if(i===null)s.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":s.removeAttribute(a);return;case"boolean":var c=a.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){s.removeAttribute(a);return}}s.setAttribute(a,""+i)}}function wl(s,a,i){if(i===null)s.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(a);return}s.setAttribute(a,""+i)}}function Xs(s,a,i,c){if(c===null)s.removeAttribute(i);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(i);return}s.setAttributeNS(a,i,""+c)}}function cs(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Tp(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function s_(s,a,i){var c=Object.getOwnPropertyDescriptor(s.constructor.prototype,a);if(!s.hasOwnProperty(a)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var h=c.get,g=c.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return h.call(this)},set:function(x){i=""+x,g.call(this,x)}}),Object.defineProperty(s,a,{enumerable:c.enumerable}),{getValue:function(){return i},setValue:function(x){i=""+x},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function Bu(s){if(!s._valueTracker){var a=Tp(s)?"checked":"value";s._valueTracker=s_(s,a,""+s[a])}}function Ap(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var i=a.getValue(),c="";return s&&(c=Tp(s)?s.checked?"true":"false":s.value),s=c,s!==i?(a.setValue(s),!0):!1}function Sl(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var n_=/[\n"\\]/g;function us(s){return s.replace(n_,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Iu(s,a,i,c,h,g,x,j){s.name="",x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"?s.type=x:s.removeAttribute("type"),a!=null?x==="number"?(a===0&&s.value===""||s.value!=a)&&(s.value=""+cs(a)):s.value!==""+cs(a)&&(s.value=""+cs(a)):x!=="submit"&&x!=="reset"||s.removeAttribute("value"),a!=null?$u(s,x,cs(a)):i!=null?$u(s,x,cs(i)):c!=null&&s.removeAttribute("value"),h==null&&g!=null&&(s.defaultChecked=!!g),h!=null&&(s.checked=h&&typeof h!="function"&&typeof h!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?s.name=""+cs(j):s.removeAttribute("name")}function kp(s,a,i,c,h,g,x,j){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(s.type=g),a!=null||i!=null){if(!(g!=="submit"&&g!=="reset"||a!=null)){Bu(s);return}i=i!=null?""+cs(i):"",a=a!=null?""+cs(a):i,j||a===s.value||(s.value=a),s.defaultValue=a}c=c??h,c=typeof c!="function"&&typeof c!="symbol"&&!!c,s.checked=j?s.checked:!!c,s.defaultChecked=!!c,x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(s.name=x),Bu(s)}function $u(s,a,i){a==="number"&&Sl(s.ownerDocument)===s||s.defaultValue===""+i||(s.defaultValue=""+i)}function gr(s,a,i,c){if(s=s.options,a){a={};for(var h=0;h<i.length;h++)a["$"+i[h]]=!0;for(i=0;i<s.length;i++)h=a.hasOwnProperty("$"+s[i].value),s[i].selected!==h&&(s[i].selected=h),h&&c&&(s[i].defaultSelected=!0)}else{for(i=""+cs(i),a=null,h=0;h<s.length;h++){if(s[h].value===i){s[h].selected=!0,c&&(s[h].defaultSelected=!0);return}a!==null||s[h].disabled||(a=s[h])}a!==null&&(a.selected=!0)}}function Cp(s,a,i){if(a!=null&&(a=""+cs(a),a!==s.value&&(s.value=a),i==null)){s.defaultValue!==a&&(s.defaultValue=a);return}s.defaultValue=i!=null?""+cs(i):""}function Rp(s,a,i,c){if(a==null){if(c!=null){if(i!=null)throw Error(r(92));if(ee(c)){if(1<c.length)throw Error(r(93));c=c[0]}i=c}i==null&&(i=""),a=i}i=cs(a),s.defaultValue=i,c=s.textContent,c===i&&c!==""&&c!==null&&(s.value=c),Bu(s)}function yr(s,a){if(a){var i=s.firstChild;if(i&&i===s.lastChild&&i.nodeType===3){i.nodeValue=a;return}}s.textContent=a}var a_=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 Op(s,a,i){var c=a.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?c?s.setProperty(a,""):a==="float"?s.cssFloat="":s[a]="":c?s.setProperty(a,i):typeof i!="number"||i===0||a_.has(a)?a==="float"?s.cssFloat=i:s[a]=(""+i).trim():s[a]=i+"px"}function Dp(s,a,i){if(a!=null&&typeof a!="object")throw Error(r(62));if(s=s.style,i!=null){for(var c in i)!i.hasOwnProperty(c)||a!=null&&a.hasOwnProperty(c)||(c.indexOf("--")===0?s.setProperty(c,""):c==="float"?s.cssFloat="":s[c]="");for(var h in a)c=a[h],a.hasOwnProperty(h)&&i[h]!==c&&Op(s,h,c)}else for(var g in a)a.hasOwnProperty(g)&&Op(s,g,a[g])}function qu(s){if(s.indexOf("-")===-1)return!1;switch(s){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 r_=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"]]),i_=/^[\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 _l(s){return i_.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function Ws(){}var Hu=null;function Gu(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var vr=null,xr=null;function Mp(s){var a=fr(s);if(a&&(s=a.stateNode)){var i=s[ne]||null;e:switch(s=a.stateNode,a.type){case"input":if(Iu(s,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),a=i.name,i.type==="radio"&&a!=null){for(i=s;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+us(""+a)+'"][type="radio"]'),a=0;a<i.length;a++){var c=i[a];if(c!==s&&c.form===s.form){var h=c[ne]||null;if(!h)throw Error(r(90));Iu(c,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(a=0;a<i.length;a++)c=i[a],c.form===s.form&&Ap(c)}break e;case"textarea":Cp(s,i.value,i.defaultValue);break e;case"select":a=i.value,a!=null&&gr(s,!!i.multiple,a,!1)}}}var Fu=!1;function zp(s,a,i){if(Fu)return s(a,i);Fu=!0;try{var c=s(a);return c}finally{if(Fu=!1,(vr!==null||xr!==null)&&(uc(),vr&&(a=vr,s=xr,xr=vr=null,Mp(a),s)))for(a=0;a<s.length;a++)Mp(s[a])}}function Ui(s,a){var i=s.stateNode;if(i===null)return null;var c=i[ne]||null;if(c===null)return null;i=c[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":(c=!c.disabled)||(s=s.type,c=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!c;break e;default:s=!1}if(s)return null;if(i&&typeof i!="function")throw Error(r(231,a,typeof i));return i}var Js=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ku=!1;if(Js)try{var Pi={};Object.defineProperty(Pi,"passive",{get:function(){Ku=!0}}),window.addEventListener("test",Pi,Pi),window.removeEventListener("test",Pi,Pi)}catch{Ku=!1}var _n=null,Yu=null,jl=null;function Lp(){if(jl)return jl;var s,a=Yu,i=a.length,c,h="value"in _n?_n.value:_n.textContent,g=h.length;for(s=0;s<i&&a[s]===h[s];s++);var x=i-s;for(c=1;c<=x&&a[i-c]===h[g-c];c++);return jl=h.slice(s,1<c?1-c:void 0)}function Nl(s){var a=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&a===13&&(s=13)):s=a,s===10&&(s=13),32<=s||s===13?s:0}function El(){return!0}function Up(){return!1}function Ft(s){function a(i,c,h,g,x){this._reactName=i,this._targetInst=h,this.type=c,this.nativeEvent=g,this.target=x,this.currentTarget=null;for(var j in s)s.hasOwnProperty(j)&&(i=s[j],this[j]=i?i(g):g[j]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?El:Up,this.isPropagationStopped=Up,this}return v(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=El)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=El)},persist:function(){},isPersistent:El}),a}var ya={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Tl=Ft(ya),Vi=v({},ya,{view:0,detail:0}),o_=Ft(Vi),Xu,Wu,Bi,Al=v({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qu,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Bi&&(Bi&&s.type==="mousemove"?(Xu=s.screenX-Bi.screenX,Wu=s.screenY-Bi.screenY):Wu=Xu=0,Bi=s),Xu)},movementY:function(s){return"movementY"in s?s.movementY:Wu}}),Pp=Ft(Al),l_=v({},Al,{dataTransfer:0}),c_=Ft(l_),u_=v({},Vi,{relatedTarget:0}),Ju=Ft(u_),d_=v({},ya,{animationName:0,elapsedTime:0,pseudoElement:0}),h_=Ft(d_),f_=v({},ya,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),m_=Ft(f_),p_=v({},ya,{data:0}),Vp=Ft(p_),g_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},y_={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"},v_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function x_(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=v_[s])?!!a[s]:!1}function Qu(){return x_}var b_=v({},Vi,{key:function(s){if(s.key){var a=g_[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=Nl(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?y_[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qu,charCode:function(s){return s.type==="keypress"?Nl(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Nl(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),w_=Ft(b_),S_=v({},Al,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bp=Ft(S_),__=v({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qu}),j_=Ft(__),N_=v({},ya,{propertyName:0,elapsedTime:0,pseudoElement:0}),E_=Ft(N_),T_=v({},Al,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),A_=Ft(T_),k_=v({},ya,{newState:0,oldState:0}),C_=Ft(k_),R_=[9,13,27,32],Zu=Js&&"CompositionEvent"in window,Ii=null;Js&&"documentMode"in document&&(Ii=document.documentMode);var O_=Js&&"TextEvent"in window&&!Ii,Ip=Js&&(!Zu||Ii&&8<Ii&&11>=Ii),$p=" ",qp=!1;function Hp(s,a){switch(s){case"keyup":return R_.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Gp(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var br=!1;function D_(s,a){switch(s){case"compositionend":return Gp(a);case"keypress":return a.which!==32?null:(qp=!0,$p);case"textInput":return s=a.data,s===$p&&qp?null:s;default:return null}}function M_(s,a){if(br)return s==="compositionend"||!Zu&&Hp(s,a)?(s=Lp(),jl=Yu=_n=null,br=!1,s):null;switch(s){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 Ip&&a.locale!=="ko"?null:a.data;default:return null}}var z_={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 Fp(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!z_[s.type]:a==="textarea"}function Kp(s,a,i,c){vr?xr?xr.push(c):xr=[c]:vr=c,a=yc(a,"onChange"),0<a.length&&(i=new Tl("onChange","change",null,i,c),s.push({event:i,listeners:a}))}var $i=null,qi=null;function L_(s){kv(s,0)}function kl(s){var a=Li(s);if(Ap(a))return s}function Yp(s,a){if(s==="change")return a}var Xp=!1;if(Js){var ed;if(Js){var td="oninput"in document;if(!td){var Wp=document.createElement("div");Wp.setAttribute("oninput","return;"),td=typeof Wp.oninput=="function"}ed=td}else ed=!1;Xp=ed&&(!document.documentMode||9<document.documentMode)}function Jp(){$i&&($i.detachEvent("onpropertychange",Qp),qi=$i=null)}function Qp(s){if(s.propertyName==="value"&&kl(qi)){var a=[];Kp(a,qi,s,Gu(s)),zp(L_,a)}}function U_(s,a,i){s==="focusin"?(Jp(),$i=a,qi=i,$i.attachEvent("onpropertychange",Qp)):s==="focusout"&&Jp()}function P_(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return kl(qi)}function V_(s,a){if(s==="click")return kl(a)}function B_(s,a){if(s==="input"||s==="change")return kl(a)}function I_(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Qt=typeof Object.is=="function"?Object.is:I_;function Hi(s,a){if(Qt(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var i=Object.keys(s),c=Object.keys(a);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var h=i[c];if(!rr.call(a,h)||!Qt(s[h],a[h]))return!1}return!0}function Zp(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function eg(s,a){var i=Zp(s);s=0;for(var c;i;){if(i.nodeType===3){if(c=s+i.textContent.length,s<=a&&c>=a)return{node:i,offset:a-s};s=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Zp(i)}}function tg(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?tg(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function sg(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var a=Sl(s.document);a instanceof s.HTMLIFrameElement;){try{var i=typeof a.contentWindow.location.href=="string"}catch{i=!1}if(i)s=a.contentWindow;else break;a=Sl(s.document)}return a}function sd(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}var $_=Js&&"documentMode"in document&&11>=document.documentMode,wr=null,nd=null,Gi=null,ad=!1;function ng(s,a,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ad||wr==null||wr!==Sl(c)||(c=wr,"selectionStart"in c&&sd(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Gi&&Hi(Gi,c)||(Gi=c,c=yc(nd,"onSelect"),0<c.length&&(a=new Tl("onSelect","select",null,a,i),s.push({event:a,listeners:c}),a.target=wr)))}function va(s,a){var i={};return i[s.toLowerCase()]=a.toLowerCase(),i["Webkit"+s]="webkit"+a,i["Moz"+s]="moz"+a,i}var Sr={animationend:va("Animation","AnimationEnd"),animationiteration:va("Animation","AnimationIteration"),animationstart:va("Animation","AnimationStart"),transitionrun:va("Transition","TransitionRun"),transitionstart:va("Transition","TransitionStart"),transitioncancel:va("Transition","TransitionCancel"),transitionend:va("Transition","TransitionEnd")},rd={},ag={};Js&&(ag=document.createElement("div").style,"AnimationEvent"in window||(delete Sr.animationend.animation,delete Sr.animationiteration.animation,delete Sr.animationstart.animation),"TransitionEvent"in window||delete Sr.transitionend.transition);function xa(s){if(rd[s])return rd[s];if(!Sr[s])return s;var a=Sr[s],i;for(i in a)if(a.hasOwnProperty(i)&&i in ag)return rd[s]=a[i];return s}var rg=xa("animationend"),ig=xa("animationiteration"),og=xa("animationstart"),q_=xa("transitionrun"),H_=xa("transitionstart"),G_=xa("transitioncancel"),lg=xa("transitionend"),cg=new Map,id="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(" ");id.push("scrollEnd");function Es(s,a){cg.set(s,a),ga(a,[s])}var Cl=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},ds=[],_r=0,od=0;function Rl(){for(var s=_r,a=od=_r=0;a<s;){var i=ds[a];ds[a++]=null;var c=ds[a];ds[a++]=null;var h=ds[a];ds[a++]=null;var g=ds[a];if(ds[a++]=null,c!==null&&h!==null){var x=c.pending;x===null?h.next=h:(h.next=x.next,x.next=h),c.pending=h}g!==0&&ug(i,h,g)}}function Ol(s,a,i,c){ds[_r++]=s,ds[_r++]=a,ds[_r++]=i,ds[_r++]=c,od|=c,s.lanes|=c,s=s.alternate,s!==null&&(s.lanes|=c)}function ld(s,a,i,c){return Ol(s,a,i,c),Dl(s)}function ba(s,a){return Ol(s,null,null,a),Dl(s)}function ug(s,a,i){s.lanes|=i;var c=s.alternate;c!==null&&(c.lanes|=i);for(var h=!1,g=s.return;g!==null;)g.childLanes|=i,c=g.alternate,c!==null&&(c.childLanes|=i),g.tag===22&&(s=g.stateNode,s===null||s._visibility&1||(h=!0)),s=g,g=g.return;return s.tag===3?(g=s.stateNode,h&&a!==null&&(h=31-vt(i),s=g.hiddenUpdates,c=s[h],c===null?s[h]=[a]:c.push(a),a.lane=i|536870912),g):null}function Dl(s){if(50<mo)throw mo=0,yh=null,Error(r(185));for(var a=s.return;a!==null;)s=a,a=s.return;return s.tag===3?s.stateNode:null}var jr={};function F_(s,a,i,c){this.tag=s,this.key=i,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=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zt(s,a,i,c){return new F_(s,a,i,c)}function cd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Qs(s,a){var i=s.alternate;return i===null?(i=Zt(s.tag,a,s.key,s.mode),i.elementType=s.elementType,i.type=s.type,i.stateNode=s.stateNode,i.alternate=s,s.alternate=i):(i.pendingProps=a,i.type=s.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=s.flags&65011712,i.childLanes=s.childLanes,i.lanes=s.lanes,i.child=s.child,i.memoizedProps=s.memoizedProps,i.memoizedState=s.memoizedState,i.updateQueue=s.updateQueue,a=s.dependencies,i.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},i.sibling=s.sibling,i.index=s.index,i.ref=s.ref,i.refCleanup=s.refCleanup,i}function dg(s,a){s.flags&=65011714;var i=s.alternate;return i===null?(s.childLanes=0,s.lanes=a,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=i.childLanes,s.lanes=i.lanes,s.child=i.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=i.memoizedProps,s.memoizedState=i.memoizedState,s.updateQueue=i.updateQueue,s.type=i.type,a=i.dependencies,s.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),s}function Ml(s,a,i,c,h,g){var x=0;if(c=s,typeof s=="function")cd(s)&&(x=1);else if(typeof s=="string")x=Jj(s,i,te.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case J:return s=Zt(31,i,a,h),s.elementType=J,s.lanes=g,s;case N:return wa(i.children,h,g,a);case E:x=8,h|=24;break;case T:return s=Zt(12,i,a,h|2),s.elementType=T,s.lanes=g,s;case H:return s=Zt(13,i,a,h),s.elementType=H,s.lanes=g,s;case G:return s=Zt(19,i,a,h),s.elementType=G,s.lanes=g,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case A:x=10;break e;case D:x=9;break e;case U:x=11;break e;case z:x=14;break e;case M:x=16,c=null;break e}x=29,i=Error(r(130,s===null?"null":typeof s,"")),c=null}return a=Zt(x,i,a,h),a.elementType=s,a.type=c,a.lanes=g,a}function wa(s,a,i,c){return s=Zt(7,s,c,a),s.lanes=i,s}function ud(s,a,i){return s=Zt(6,s,null,a),s.lanes=i,s}function hg(s){var a=Zt(18,null,null,0);return a.stateNode=s,a}function dd(s,a,i){return a=Zt(4,s.children!==null?s.children:[],s.key,a),a.lanes=i,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}var fg=new WeakMap;function hs(s,a){if(typeof s=="object"&&s!==null){var i=fg.get(s);return i!==void 0?i:(a={value:s,source:a,stack:Ai(a)},fg.set(s,a),a)}return{value:s,source:a,stack:Ai(a)}}var Nr=[],Er=0,zl=null,Fi=0,fs=[],ms=0,jn=null,Us=1,Ps="";function Zs(s,a){Nr[Er++]=Fi,Nr[Er++]=zl,zl=s,Fi=a}function mg(s,a,i){fs[ms++]=Us,fs[ms++]=Ps,fs[ms++]=jn,jn=s;var c=Us;s=Ps;var h=32-vt(c)-1;c&=~(1<<h),i+=1;var g=32-vt(a)+h;if(30<g){var x=h-h%5;g=(c&(1<<x)-1).toString(32),c>>=x,h-=x,Us=1<<32-vt(a)+h|i<<h|c,Ps=g+s}else Us=1<<g|i<<h|c,Ps=s}function hd(s){s.return!==null&&(Zs(s,1),mg(s,1,0))}function fd(s){for(;s===zl;)zl=Nr[--Er],Nr[Er]=null,Fi=Nr[--Er],Nr[Er]=null;for(;s===jn;)jn=fs[--ms],fs[ms]=null,Ps=fs[--ms],fs[ms]=null,Us=fs[--ms],fs[ms]=null}function pg(s,a){fs[ms++]=Us,fs[ms++]=Ps,fs[ms++]=jn,Us=a.id,Ps=a.overflow,jn=s}var kt=null,We=null,ze=!1,Nn=null,ps=!1,md=Error(r(519));function En(s){var a=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ki(hs(a,s)),md}function gg(s){var a=s.stateNode,i=s.type,c=s.memoizedProps;switch(a[I]=s,a[ne]=c,i){case"dialog":Re("cancel",a),Re("close",a);break;case"iframe":case"object":case"embed":Re("load",a);break;case"video":case"audio":for(i=0;i<go.length;i++)Re(go[i],a);break;case"source":Re("error",a);break;case"img":case"image":case"link":Re("error",a),Re("load",a);break;case"details":Re("toggle",a);break;case"input":Re("invalid",a),kp(a,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Re("invalid",a);break;case"textarea":Re("invalid",a),Rp(a,c.value,c.defaultValue,c.children)}i=c.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||a.textContent===""+i||c.suppressHydrationWarning===!0||Dv(a.textContent,i)?(c.popover!=null&&(Re("beforetoggle",a),Re("toggle",a)),c.onScroll!=null&&Re("scroll",a),c.onScrollEnd!=null&&Re("scrollend",a),c.onClick!=null&&(a.onclick=Ws),a=!0):a=!1,a||En(s,!0)}function yg(s){for(kt=s.return;kt;)switch(kt.tag){case 5:case 31:case 13:ps=!1;return;case 27:case 3:ps=!0;return;default:kt=kt.return}}function Tr(s){if(s!==kt)return!1;if(!ze)return yg(s),ze=!0,!1;var a=s.tag,i;if((i=a!==3&&a!==27)&&((i=a===5)&&(i=s.type,i=!(i!=="form"&&i!=="button")||Oh(s.type,s.memoizedProps)),i=!i),i&&We&&En(s),yg(s),a===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));We=$v(s)}else if(a===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));We=$v(s)}else a===27?(a=We,Bn(s.type)?(s=Uh,Uh=null,We=s):We=a):We=kt?ys(s.stateNode.nextSibling):null;return!0}function Sa(){We=kt=null,ze=!1}function pd(){var s=Nn;return s!==null&&(Wt===null?Wt=s:Wt.push.apply(Wt,s),Nn=null),s}function Ki(s){Nn===null?Nn=[s]:Nn.push(s)}var gd=R(null),_a=null,en=null;function Tn(s,a,i){Z(gd,a._currentValue),a._currentValue=i}function tn(s){s._currentValue=gd.current,Y(gd)}function yd(s,a,i){for(;s!==null;){var c=s.alternate;if((s.childLanes&a)!==a?(s.childLanes|=a,c!==null&&(c.childLanes|=a)):c!==null&&(c.childLanes&a)!==a&&(c.childLanes|=a),s===i)break;s=s.return}}function vd(s,a,i,c){var h=s.child;for(h!==null&&(h.return=s);h!==null;){var g=h.dependencies;if(g!==null){var x=h.child;g=g.firstContext;e:for(;g!==null;){var j=g;g=h;for(var k=0;k<a.length;k++)if(j.context===a[k]){g.lanes|=i,j=g.alternate,j!==null&&(j.lanes|=i),yd(g.return,i,s),c||(x=null);break e}g=j.next}}else if(h.tag===18){if(x=h.return,x===null)throw Error(r(341));x.lanes|=i,g=x.alternate,g!==null&&(g.lanes|=i),yd(x,i,s),x=null}else x=h.child;if(x!==null)x.return=h;else for(x=h;x!==null;){if(x===s){x=null;break}if(h=x.sibling,h!==null){h.return=x.return,x=h;break}x=x.return}h=x}}function Ar(s,a,i,c){s=null;for(var h=a,g=!1;h!==null;){if(!g){if((h.flags&524288)!==0)g=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var x=h.alternate;if(x===null)throw Error(r(387));if(x=x.memoizedProps,x!==null){var j=h.type;Qt(h.pendingProps.value,x.value)||(s!==null?s.push(j):s=[j])}}else if(h===ge.current){if(x=h.alternate,x===null)throw Error(r(387));x.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(s!==null?s.push(wo):s=[wo])}h=h.return}s!==null&&vd(a,s,i,c),a.flags|=262144}function Ll(s){for(s=s.firstContext;s!==null;){if(!Qt(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function ja(s){_a=s,en=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Ct(s){return vg(_a,s)}function Ul(s,a){return _a===null&&ja(s),vg(s,a)}function vg(s,a){var i=a._currentValue;if(a={context:a,memoizedValue:i,next:null},en===null){if(s===null)throw Error(r(308));en=a,s.dependencies={lanes:0,firstContext:a},s.flags|=524288}else en=en.next=a;return i}var K_=typeof AbortController<"u"?AbortController:function(){var s=[],a=this.signal={aborted:!1,addEventListener:function(i,c){s.push(c)}};this.abort=function(){a.aborted=!0,s.forEach(function(i){return i()})}},Y_=t.unstable_scheduleCallback,X_=t.unstable_NormalPriority,ht={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function xd(){return{controller:new K_,data:new Map,refCount:0}}function Yi(s){s.refCount--,s.refCount===0&&Y_(X_,function(){s.controller.abort()})}var Xi=null,bd=0,kr=0,Cr=null;function W_(s,a){if(Xi===null){var i=Xi=[];bd=0,kr=_h(),Cr={status:"pending",value:void 0,then:function(c){i.push(c)}}}return bd++,a.then(xg,xg),a}function xg(){if(--bd===0&&Xi!==null){Cr!==null&&(Cr.status="fulfilled");var s=Xi;Xi=null,kr=0,Cr=null;for(var a=0;a<s.length;a++)(0,s[a])()}}function J_(s,a){var i=[],c={status:"pending",value:null,reason:null,then:function(h){i.push(h)}};return s.then(function(){c.status="fulfilled",c.value=a;for(var h=0;h<i.length;h++)(0,i[h])(a)},function(h){for(c.status="rejected",c.reason=h,h=0;h<i.length;h++)(0,i[h])(void 0)}),c}var bg=C.S;C.S=function(s,a){nv=Tt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&W_(s,a),bg!==null&&bg(s,a)};var Na=R(null);function wd(){var s=Na.current;return s!==null?s:Ke.pooledCache}function Pl(s,a){a===null?Z(Na,Na.current):Z(Na,a.pool)}function wg(){var s=wd();return s===null?null:{parent:ht._currentValue,pool:s}}var Rr=Error(r(460)),Sd=Error(r(474)),Vl=Error(r(542)),Bl={then:function(){}};function Sg(s){return s=s.status,s==="fulfilled"||s==="rejected"}function _g(s,a,i){switch(i=s[i],i===void 0?s.push(a):i!==a&&(a.then(Ws,Ws),a=i),a.status){case"fulfilled":return a.value;case"rejected":throw s=a.reason,Ng(s),s;default:if(typeof a.status=="string")a.then(Ws,Ws);else{if(s=Ke,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=a,s.status="pending",s.then(function(c){if(a.status==="pending"){var h=a;h.status="fulfilled",h.value=c}},function(c){if(a.status==="pending"){var h=a;h.status="rejected",h.reason=c}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw s=a.reason,Ng(s),s}throw Ta=a,Rr}}function Ea(s){try{var a=s._init;return a(s._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Ta=i,Rr):i}}var Ta=null;function jg(){if(Ta===null)throw Error(r(459));var s=Ta;return Ta=null,s}function Ng(s){if(s===Rr||s===Vl)throw Error(r(483))}var Or=null,Wi=0;function Il(s){var a=Wi;return Wi+=1,Or===null&&(Or=[]),_g(Or,s,a)}function Ji(s,a){a=a.props.ref,s.ref=a!==void 0?a:null}function $l(s,a){throw a.$$typeof===b?Error(r(525)):(s=Object.prototype.toString.call(a),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s)))}function Eg(s){function a(L,O){if(s){var P=L.deletions;P===null?(L.deletions=[O],L.flags|=16):P.push(O)}}function i(L,O){if(!s)return null;for(;O!==null;)a(L,O),O=O.sibling;return null}function c(L){for(var O=new Map;L!==null;)L.key!==null?O.set(L.key,L):O.set(L.index,L),L=L.sibling;return O}function h(L,O){return L=Qs(L,O),L.index=0,L.sibling=null,L}function g(L,O,P){return L.index=P,s?(P=L.alternate,P!==null?(P=P.index,P<O?(L.flags|=67108866,O):P):(L.flags|=67108866,O)):(L.flags|=1048576,O)}function x(L){return s&&L.alternate===null&&(L.flags|=67108866),L}function j(L,O,P,X){return O===null||O.tag!==6?(O=ud(P,L.mode,X),O.return=L,O):(O=h(O,P),O.return=L,O)}function k(L,O,P,X){var me=P.type;return me===N?K(L,O,P.props.children,X,P.key):O!==null&&(O.elementType===me||typeof me=="object"&&me!==null&&me.$$typeof===M&&Ea(me)===O.type)?(O=h(O,P.props),Ji(O,P),O.return=L,O):(O=Ml(P.type,P.key,P.props,null,L.mode,X),Ji(O,P),O.return=L,O)}function V(L,O,P,X){return O===null||O.tag!==4||O.stateNode.containerInfo!==P.containerInfo||O.stateNode.implementation!==P.implementation?(O=dd(P,L.mode,X),O.return=L,O):(O=h(O,P.children||[]),O.return=L,O)}function K(L,O,P,X,me){return O===null||O.tag!==7?(O=wa(P,L.mode,X,me),O.return=L,O):(O=h(O,P),O.return=L,O)}function W(L,O,P){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=ud(""+O,L.mode,P),O.return=L,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case S:return P=Ml(O.type,O.key,O.props,null,L.mode,P),Ji(P,O),P.return=L,P;case _:return O=dd(O,L.mode,P),O.return=L,O;case M:return O=Ea(O),W(L,O,P)}if(ee(O)||de(O))return O=wa(O,L.mode,P,null),O.return=L,O;if(typeof O.then=="function")return W(L,Il(O),P);if(O.$$typeof===A)return W(L,Ul(L,O),P);$l(L,O)}return null}function $(L,O,P,X){var me=O!==null?O.key:null;if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return me!==null?null:j(L,O,""+P,X);if(typeof P=="object"&&P!==null){switch(P.$$typeof){case S:return P.key===me?k(L,O,P,X):null;case _:return P.key===me?V(L,O,P,X):null;case M:return P=Ea(P),$(L,O,P,X)}if(ee(P)||de(P))return me!==null?null:K(L,O,P,X,null);if(typeof P.then=="function")return $(L,O,Il(P),X);if(P.$$typeof===A)return $(L,O,Ul(L,P),X);$l(L,P)}return null}function F(L,O,P,X,me){if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return L=L.get(P)||null,j(O,L,""+X,me);if(typeof X=="object"&&X!==null){switch(X.$$typeof){case S:return L=L.get(X.key===null?P:X.key)||null,k(O,L,X,me);case _:return L=L.get(X.key===null?P:X.key)||null,V(O,L,X,me);case M:return X=Ea(X),F(L,O,P,X,me)}if(ee(X)||de(X))return L=L.get(P)||null,K(O,L,X,me,null);if(typeof X.then=="function")return F(L,O,P,Il(X),me);if(X.$$typeof===A)return F(L,O,P,Ul(O,X),me);$l(O,X)}return null}function oe(L,O,P,X){for(var me=null,Ue=null,he=O,Te=O=0,Me=null;he!==null&&Te<P.length;Te++){he.index>Te?(Me=he,he=null):Me=he.sibling;var Pe=$(L,he,P[Te],X);if(Pe===null){he===null&&(he=Me);break}s&&he&&Pe.alternate===null&&a(L,he),O=g(Pe,O,Te),Ue===null?me=Pe:Ue.sibling=Pe,Ue=Pe,he=Me}if(Te===P.length)return i(L,he),ze&&Zs(L,Te),me;if(he===null){for(;Te<P.length;Te++)he=W(L,P[Te],X),he!==null&&(O=g(he,O,Te),Ue===null?me=he:Ue.sibling=he,Ue=he);return ze&&Zs(L,Te),me}for(he=c(he);Te<P.length;Te++)Me=F(he,L,Te,P[Te],X),Me!==null&&(s&&Me.alternate!==null&&he.delete(Me.key===null?Te:Me.key),O=g(Me,O,Te),Ue===null?me=Me:Ue.sibling=Me,Ue=Me);return s&&he.forEach(function(Gn){return a(L,Gn)}),ze&&Zs(L,Te),me}function ye(L,O,P,X){if(P==null)throw Error(r(151));for(var me=null,Ue=null,he=O,Te=O=0,Me=null,Pe=P.next();he!==null&&!Pe.done;Te++,Pe=P.next()){he.index>Te?(Me=he,he=null):Me=he.sibling;var Gn=$(L,he,Pe.value,X);if(Gn===null){he===null&&(he=Me);break}s&&he&&Gn.alternate===null&&a(L,he),O=g(Gn,O,Te),Ue===null?me=Gn:Ue.sibling=Gn,Ue=Gn,he=Me}if(Pe.done)return i(L,he),ze&&Zs(L,Te),me;if(he===null){for(;!Pe.done;Te++,Pe=P.next())Pe=W(L,Pe.value,X),Pe!==null&&(O=g(Pe,O,Te),Ue===null?me=Pe:Ue.sibling=Pe,Ue=Pe);return ze&&Zs(L,Te),me}for(he=c(he);!Pe.done;Te++,Pe=P.next())Pe=F(he,L,Te,Pe.value,X),Pe!==null&&(s&&Pe.alternate!==null&&he.delete(Pe.key===null?Te:Pe.key),O=g(Pe,O,Te),Ue===null?me=Pe:Ue.sibling=Pe,Ue=Pe);return s&&he.forEach(function(lN){return a(L,lN)}),ze&&Zs(L,Te),me}function Fe(L,O,P,X){if(typeof P=="object"&&P!==null&&P.type===N&&P.key===null&&(P=P.props.children),typeof P=="object"&&P!==null){switch(P.$$typeof){case S:e:{for(var me=P.key;O!==null;){if(O.key===me){if(me=P.type,me===N){if(O.tag===7){i(L,O.sibling),X=h(O,P.props.children),X.return=L,L=X;break e}}else if(O.elementType===me||typeof me=="object"&&me!==null&&me.$$typeof===M&&Ea(me)===O.type){i(L,O.sibling),X=h(O,P.props),Ji(X,P),X.return=L,L=X;break e}i(L,O);break}else a(L,O);O=O.sibling}P.type===N?(X=wa(P.props.children,L.mode,X,P.key),X.return=L,L=X):(X=Ml(P.type,P.key,P.props,null,L.mode,X),Ji(X,P),X.return=L,L=X)}return x(L);case _:e:{for(me=P.key;O!==null;){if(O.key===me)if(O.tag===4&&O.stateNode.containerInfo===P.containerInfo&&O.stateNode.implementation===P.implementation){i(L,O.sibling),X=h(O,P.children||[]),X.return=L,L=X;break e}else{i(L,O);break}else a(L,O);O=O.sibling}X=dd(P,L.mode,X),X.return=L,L=X}return x(L);case M:return P=Ea(P),Fe(L,O,P,X)}if(ee(P))return oe(L,O,P,X);if(de(P)){if(me=de(P),typeof me!="function")throw Error(r(150));return P=me.call(P),ye(L,O,P,X)}if(typeof P.then=="function")return Fe(L,O,Il(P),X);if(P.$$typeof===A)return Fe(L,O,Ul(L,P),X);$l(L,P)}return typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint"?(P=""+P,O!==null&&O.tag===6?(i(L,O.sibling),X=h(O,P),X.return=L,L=X):(i(L,O),X=ud(P,L.mode,X),X.return=L,L=X),x(L)):i(L,O)}return function(L,O,P,X){try{Wi=0;var me=Fe(L,O,P,X);return Or=null,me}catch(he){if(he===Rr||he===Vl)throw he;var Ue=Zt(29,he,null,L.mode);return Ue.lanes=X,Ue.return=L,Ue}}}var Aa=Eg(!0),Tg=Eg(!1),An=!1;function _d(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function jd(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function kn(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Cn(s,a,i){var c=s.updateQueue;if(c===null)return null;if(c=c.shared,(Be&2)!==0){var h=c.pending;return h===null?a.next=a:(a.next=h.next,h.next=a),c.pending=a,a=Dl(s),ug(s,null,i),a}return Ol(s,c,a,i),Dl(s)}function Qi(s,a,i){if(a=a.updateQueue,a!==null&&(a=a.shared,(i&4194048)!==0)){var c=a.lanes;c&=s.pendingLanes,i|=c,a.lanes=i,pl(s,i)}}function Nd(s,a){var i=s.updateQueue,c=s.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var h=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var x={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};g===null?h=g=x:g=g.next=x,i=i.next}while(i!==null);g===null?h=g=a:g=g.next=a}else h=g=a;i={baseState:c.baseState,firstBaseUpdate:h,lastBaseUpdate:g,shared:c.shared,callbacks:c.callbacks},s.updateQueue=i;return}s=i.lastBaseUpdate,s===null?i.firstBaseUpdate=a:s.next=a,i.lastBaseUpdate=a}var Ed=!1;function Zi(){if(Ed){var s=Cr;if(s!==null)throw s}}function eo(s,a,i,c){Ed=!1;var h=s.updateQueue;An=!1;var g=h.firstBaseUpdate,x=h.lastBaseUpdate,j=h.shared.pending;if(j!==null){h.shared.pending=null;var k=j,V=k.next;k.next=null,x===null?g=V:x.next=V,x=k;var K=s.alternate;K!==null&&(K=K.updateQueue,j=K.lastBaseUpdate,j!==x&&(j===null?K.firstBaseUpdate=V:j.next=V,K.lastBaseUpdate=k))}if(g!==null){var W=h.baseState;x=0,K=V=k=null,j=g;do{var $=j.lane&-536870913,F=$!==j.lane;if(F?(De&$)===$:(c&$)===$){$!==0&&$===kr&&(Ed=!0),K!==null&&(K=K.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var oe=s,ye=j;$=a;var Fe=i;switch(ye.tag){case 1:if(oe=ye.payload,typeof oe=="function"){W=oe.call(Fe,W,$);break e}W=oe;break e;case 3:oe.flags=oe.flags&-65537|128;case 0:if(oe=ye.payload,$=typeof oe=="function"?oe.call(Fe,W,$):oe,$==null)break e;W=v({},W,$);break e;case 2:An=!0}}$=j.callback,$!==null&&(s.flags|=64,F&&(s.flags|=8192),F=h.callbacks,F===null?h.callbacks=[$]:F.push($))}else F={lane:$,tag:j.tag,payload:j.payload,callback:j.callback,next:null},K===null?(V=K=F,k=W):K=K.next=F,x|=$;if(j=j.next,j===null){if(j=h.shared.pending,j===null)break;F=j,j=F.next,F.next=null,h.lastBaseUpdate=F,h.shared.pending=null}}while(!0);K===null&&(k=W),h.baseState=k,h.firstBaseUpdate=V,h.lastBaseUpdate=K,g===null&&(h.shared.lanes=0),zn|=x,s.lanes=x,s.memoizedState=W}}function Ag(s,a){if(typeof s!="function")throw Error(r(191,s));s.call(a)}function kg(s,a){var i=s.callbacks;if(i!==null)for(s.callbacks=null,s=0;s<i.length;s++)Ag(i[s],a)}var Dr=R(null),ql=R(0);function Cg(s,a){s=dn,Z(ql,s),Z(Dr,a),dn=s|a.baseLanes}function Td(){Z(ql,dn),Z(Dr,Dr.current)}function Ad(){dn=ql.current,Y(Dr),Y(ql)}var es=R(null),gs=null;function Rn(s){var a=s.alternate;Z(ct,ct.current&1),Z(es,s),gs===null&&(a===null||Dr.current!==null||a.memoizedState!==null)&&(gs=s)}function kd(s){Z(ct,ct.current),Z(es,s),gs===null&&(gs=s)}function Rg(s){s.tag===22?(Z(ct,ct.current),Z(es,s),gs===null&&(gs=s)):On()}function On(){Z(ct,ct.current),Z(es,es.current)}function ts(s){Y(es),gs===s&&(gs=null),Y(ct)}var ct=R(0);function Hl(s){for(var a=s;a!==null;){if(a.tag===13){var i=a.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||zh(i)||Lh(i)))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===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var sn=0,Ne=null,He=null,ft=null,Gl=!1,Mr=!1,ka=!1,Fl=0,to=0,zr=null,Q_=0;function nt(){throw Error(r(321))}function Cd(s,a){if(a===null)return!1;for(var i=0;i<a.length&&i<s.length;i++)if(!Qt(s[i],a[i]))return!1;return!0}function Rd(s,a,i,c,h,g){return sn=g,Ne=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,C.H=s===null||s.memoizedState===null?my:Fd,ka=!1,g=i(c,h),ka=!1,Mr&&(g=Dg(a,i,c,h)),Og(s),g}function Og(s){C.H=ao;var a=He!==null&&He.next!==null;if(sn=0,ft=He=Ne=null,Gl=!1,to=0,zr=null,a)throw Error(r(300));s===null||mt||(s=s.dependencies,s!==null&&Ll(s)&&(mt=!0))}function Dg(s,a,i,c){Ne=s;var h=0;do{if(Mr&&(zr=null),to=0,Mr=!1,25<=h)throw Error(r(301));if(h+=1,ft=He=null,s.updateQueue!=null){var g=s.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}C.H=py,g=a(i,c)}while(Mr);return g}function Z_(){var s=C.H,a=s.useState()[0];return a=typeof a.then=="function"?so(a):a,s=s.useState()[0],(He!==null?He.memoizedState:null)!==s&&(Ne.flags|=1024),a}function Od(){var s=Fl!==0;return Fl=0,s}function Dd(s,a,i){a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~i}function Md(s){if(Gl){for(s=s.memoizedState;s!==null;){var a=s.queue;a!==null&&(a.pending=null),s=s.next}Gl=!1}sn=0,ft=He=Ne=null,Mr=!1,to=Fl=0,zr=null}function It(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ft===null?Ne.memoizedState=ft=s:ft=ft.next=s,ft}function ut(){if(He===null){var s=Ne.alternate;s=s!==null?s.memoizedState:null}else s=He.next;var a=ft===null?Ne.memoizedState:ft.next;if(a!==null)ft=a,He=s;else{if(s===null)throw Ne.alternate===null?Error(r(467)):Error(r(310));He=s,s={memoizedState:He.memoizedState,baseState:He.baseState,baseQueue:He.baseQueue,queue:He.queue,next:null},ft===null?Ne.memoizedState=ft=s:ft=ft.next=s}return ft}function Kl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function so(s){var a=to;return to+=1,zr===null&&(zr=[]),s=_g(zr,s,a),a=Ne,(ft===null?a.memoizedState:ft.next)===null&&(a=a.alternate,C.H=a===null||a.memoizedState===null?my:Fd),s}function Yl(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return so(s);if(s.$$typeof===A)return Ct(s)}throw Error(r(438,String(s)))}function zd(s){var a=null,i=Ne.updateQueue;if(i!==null&&(a=i.memoCache),a==null){var c=Ne.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(a={data:c.data.map(function(h){return h.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),i===null&&(i=Kl(),Ne.updateQueue=i),i.memoCache=a,i=a.data[a.index],i===void 0)for(i=a.data[a.index]=Array(s),c=0;c<s;c++)i[c]=ie;return a.index++,i}function nn(s,a){return typeof a=="function"?a(s):a}function Xl(s){var a=ut();return Ld(a,He,s)}function Ld(s,a,i){var c=s.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=i;var h=s.baseQueue,g=c.pending;if(g!==null){if(h!==null){var x=h.next;h.next=g.next,g.next=x}a.baseQueue=h=g,c.pending=null}if(g=s.baseState,h===null)s.memoizedState=g;else{a=h.next;var j=x=null,k=null,V=a,K=!1;do{var W=V.lane&-536870913;if(W!==V.lane?(De&W)===W:(sn&W)===W){var $=V.revertLane;if($===0)k!==null&&(k=k.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),W===kr&&(K=!0);else if((sn&$)===$){V=V.next,$===kr&&(K=!0);continue}else W={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},k===null?(j=k=W,x=g):k=k.next=W,Ne.lanes|=$,zn|=$;W=V.action,ka&&i(g,W),g=V.hasEagerState?V.eagerState:i(g,W)}else $={lane:W,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},k===null?(j=k=$,x=g):k=k.next=$,Ne.lanes|=W,zn|=W;V=V.next}while(V!==null&&V!==a);if(k===null?x=g:k.next=j,!Qt(g,s.memoizedState)&&(mt=!0,K&&(i=Cr,i!==null)))throw i;s.memoizedState=g,s.baseState=x,s.baseQueue=k,c.lastRenderedState=g}return h===null&&(c.lanes=0),[s.memoizedState,c.dispatch]}function Ud(s){var a=ut(),i=a.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=s;var c=i.dispatch,h=i.pending,g=a.memoizedState;if(h!==null){i.pending=null;var x=h=h.next;do g=s(g,x.action),x=x.next;while(x!==h);Qt(g,a.memoizedState)||(mt=!0),a.memoizedState=g,a.baseQueue===null&&(a.baseState=g),i.lastRenderedState=g}return[g,c]}function Mg(s,a,i){var c=Ne,h=ut(),g=ze;if(g){if(i===void 0)throw Error(r(407));i=i()}else i=a();var x=!Qt((He||h).memoizedState,i);if(x&&(h.memoizedState=i,mt=!0),h=h.queue,Bd(Ug.bind(null,c,h,s),[s]),h.getSnapshot!==a||x||ft!==null&&ft.memoizedState.tag&1){if(c.flags|=2048,Lr(9,{destroy:void 0},Lg.bind(null,c,h,i,a),null),Ke===null)throw Error(r(349));g||(sn&127)!==0||zg(c,a,i)}return i}function zg(s,a,i){s.flags|=16384,s={getSnapshot:a,value:i},a=Ne.updateQueue,a===null?(a=Kl(),Ne.updateQueue=a,a.stores=[s]):(i=a.stores,i===null?a.stores=[s]:i.push(s))}function Lg(s,a,i,c){a.value=i,a.getSnapshot=c,Pg(a)&&Vg(s)}function Ug(s,a,i){return i(function(){Pg(a)&&Vg(s)})}function Pg(s){var a=s.getSnapshot;s=s.value;try{var i=a();return!Qt(s,i)}catch{return!0}}function Vg(s){var a=ba(s,2);a!==null&&Jt(a,s,2)}function Pd(s){var a=It();if(typeof s=="function"){var i=s;if(s=i(),ka){Ys(!0);try{i()}finally{Ys(!1)}}}return a.memoizedState=a.baseState=s,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:nn,lastRenderedState:s},a}function Bg(s,a,i,c){return s.baseState=i,Ld(s,He,typeof c=="function"?c:nn)}function ej(s,a,i,c,h){if(Ql(s))throw Error(r(485));if(s=a.action,s!==null){var g={payload:h,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(x){g.listeners.push(x)}};C.T!==null?i(!0):g.isTransition=!1,c(g),i=a.pending,i===null?(g.next=a.pending=g,Ig(a,g)):(g.next=i.next,a.pending=i.next=g)}}function Ig(s,a){var i=a.action,c=a.payload,h=s.state;if(a.isTransition){var g=C.T,x={};C.T=x;try{var j=i(h,c),k=C.S;k!==null&&k(x,j),$g(s,a,j)}catch(V){Vd(s,a,V)}finally{g!==null&&x.types!==null&&(g.types=x.types),C.T=g}}else try{g=i(h,c),$g(s,a,g)}catch(V){Vd(s,a,V)}}function $g(s,a,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(c){qg(s,a,c)},function(c){return Vd(s,a,c)}):qg(s,a,i)}function qg(s,a,i){a.status="fulfilled",a.value=i,Hg(a),s.state=i,a=s.pending,a!==null&&(i=a.next,i===a?s.pending=null:(i=i.next,a.next=i,Ig(s,i)))}function Vd(s,a,i){var c=s.pending;if(s.pending=null,c!==null){c=c.next;do a.status="rejected",a.reason=i,Hg(a),a=a.next;while(a!==c)}s.action=null}function Hg(s){s=s.listeners;for(var a=0;a<s.length;a++)(0,s[a])()}function Gg(s,a){return a}function Fg(s,a){if(ze){var i=Ke.formState;if(i!==null){e:{var c=Ne;if(ze){if(We){t:{for(var h=We,g=ps;h.nodeType!==8;){if(!g){h=null;break t}if(h=ys(h.nextSibling),h===null){h=null;break t}}g=h.data,h=g==="F!"||g==="F"?h:null}if(h){We=ys(h.nextSibling),c=h.data==="F!";break e}}En(c)}c=!1}c&&(a=i[0])}}return i=It(),i.memoizedState=i.baseState=a,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gg,lastRenderedState:a},i.queue=c,i=dy.bind(null,Ne,c),c.dispatch=i,c=Pd(!1),g=Gd.bind(null,Ne,!1,c.queue),c=It(),h={state:a,dispatch:null,action:s,pending:null},c.queue=h,i=ej.bind(null,Ne,h,g,i),h.dispatch=i,c.memoizedState=s,[a,i,!1]}function Kg(s){var a=ut();return Yg(a,He,s)}function Yg(s,a,i){if(a=Ld(s,a,Gg)[0],s=Xl(nn)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var c=so(a)}catch(x){throw x===Rr?Vl:x}else c=a;a=ut();var h=a.queue,g=h.dispatch;return i!==a.memoizedState&&(Ne.flags|=2048,Lr(9,{destroy:void 0},tj.bind(null,h,i),null)),[c,g,s]}function tj(s,a){s.action=a}function Xg(s){var a=ut(),i=He;if(i!==null)return Yg(a,i,s);ut(),a=a.memoizedState,i=ut();var c=i.queue.dispatch;return i.memoizedState=s,[a,c,!1]}function Lr(s,a,i,c){return s={tag:s,create:i,deps:c,inst:a,next:null},a=Ne.updateQueue,a===null&&(a=Kl(),Ne.updateQueue=a),i=a.lastEffect,i===null?a.lastEffect=s.next=s:(c=i.next,i.next=s,s.next=c,a.lastEffect=s),s}function Wg(){return ut().memoizedState}function Wl(s,a,i,c){var h=It();Ne.flags|=s,h.memoizedState=Lr(1|a,{destroy:void 0},i,c===void 0?null:c)}function Jl(s,a,i,c){var h=ut();c=c===void 0?null:c;var g=h.memoizedState.inst;He!==null&&c!==null&&Cd(c,He.memoizedState.deps)?h.memoizedState=Lr(a,g,i,c):(Ne.flags|=s,h.memoizedState=Lr(1|a,g,i,c))}function Jg(s,a){Wl(8390656,8,s,a)}function Bd(s,a){Jl(2048,8,s,a)}function sj(s){Ne.flags|=4;var a=Ne.updateQueue;if(a===null)a=Kl(),Ne.updateQueue=a,a.events=[s];else{var i=a.events;i===null?a.events=[s]:i.push(s)}}function Qg(s){var a=ut().memoizedState;return sj({ref:a,nextImpl:s}),function(){if((Be&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}function Zg(s,a){return Jl(4,2,s,a)}function ey(s,a){return Jl(4,4,s,a)}function ty(s,a){if(typeof a=="function"){s=s();var i=a(s);return function(){typeof i=="function"?i():a(null)}}if(a!=null)return s=s(),a.current=s,function(){a.current=null}}function sy(s,a,i){i=i!=null?i.concat([s]):null,Jl(4,4,ty.bind(null,a,s),i)}function Id(){}function ny(s,a){var i=ut();a=a===void 0?null:a;var c=i.memoizedState;return a!==null&&Cd(a,c[1])?c[0]:(i.memoizedState=[s,a],s)}function ay(s,a){var i=ut();a=a===void 0?null:a;var c=i.memoizedState;if(a!==null&&Cd(a,c[1]))return c[0];if(c=s(),ka){Ys(!0);try{s()}finally{Ys(!1)}}return i.memoizedState=[c,a],c}function $d(s,a,i){return i===void 0||(sn&1073741824)!==0&&(De&261930)===0?s.memoizedState=a:(s.memoizedState=i,s=rv(),Ne.lanes|=s,zn|=s,i)}function ry(s,a,i,c){return Qt(i,a)?i:Dr.current!==null?(s=$d(s,i,c),Qt(s,a)||(mt=!0),s):(sn&42)===0||(sn&1073741824)!==0&&(De&261930)===0?(mt=!0,s.memoizedState=i):(s=rv(),Ne.lanes|=s,zn|=s,a)}function iy(s,a,i,c,h){var g=q.p;q.p=g!==0&&8>g?g:8;var x=C.T,j={};C.T=j,Gd(s,!1,a,i);try{var k=h(),V=C.S;if(V!==null&&V(j,k),k!==null&&typeof k=="object"&&typeof k.then=="function"){var K=J_(k,c);no(s,a,K,as(s))}else no(s,a,c,as(s))}catch(W){no(s,a,{then:function(){},status:"rejected",reason:W},as())}finally{q.p=g,x!==null&&j.types!==null&&(x.types=j.types),C.T=x}}function nj(){}function qd(s,a,i,c){if(s.tag!==5)throw Error(r(476));var h=oy(s).queue;iy(s,h,a,B,i===null?nj:function(){return ly(s),i(c)})}function oy(s){var a=s.memoizedState;if(a!==null)return a;a={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nn,lastRenderedState:B},next:null};var i={};return a.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nn,lastRenderedState:i},next:null},s.memoizedState=a,s=s.alternate,s!==null&&(s.memoizedState=a),a}function ly(s){var a=oy(s);a.next===null&&(a=s.alternate.memoizedState),no(s,a.next.queue,{},as())}function Hd(){return Ct(wo)}function cy(){return ut().memoizedState}function uy(){return ut().memoizedState}function aj(s){for(var a=s.return;a!==null;){switch(a.tag){case 24:case 3:var i=as();s=kn(i);var c=Cn(a,s,i);c!==null&&(Jt(c,a,i),Qi(c,a,i)),a={cache:xd()},s.payload=a;return}a=a.return}}function rj(s,a,i){var c=as();i={lane:c,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Ql(s)?hy(a,i):(i=ld(s,a,i,c),i!==null&&(Jt(i,s,c),fy(i,a,c)))}function dy(s,a,i){var c=as();no(s,a,i,c)}function no(s,a,i,c){var h={lane:c,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Ql(s))hy(a,h);else{var g=s.alternate;if(s.lanes===0&&(g===null||g.lanes===0)&&(g=a.lastRenderedReducer,g!==null))try{var x=a.lastRenderedState,j=g(x,i);if(h.hasEagerState=!0,h.eagerState=j,Qt(j,x))return Ol(s,a,h,0),Ke===null&&Rl(),!1}catch{}if(i=ld(s,a,h,c),i!==null)return Jt(i,s,c),fy(i,a,c),!0}return!1}function Gd(s,a,i,c){if(c={lane:2,revertLane:_h(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Ql(s)){if(a)throw Error(r(479))}else a=ld(s,i,c,2),a!==null&&Jt(a,s,2)}function Ql(s){var a=s.alternate;return s===Ne||a!==null&&a===Ne}function hy(s,a){Mr=Gl=!0;var i=s.pending;i===null?a.next=a:(a.next=i.next,i.next=a),s.pending=a}function fy(s,a,i){if((i&4194048)!==0){var c=a.lanes;c&=s.pendingLanes,i|=c,a.lanes=i,pl(s,i)}}var ao={readContext:Ct,use:Yl,useCallback:nt,useContext:nt,useEffect:nt,useImperativeHandle:nt,useLayoutEffect:nt,useInsertionEffect:nt,useMemo:nt,useReducer:nt,useRef:nt,useState:nt,useDebugValue:nt,useDeferredValue:nt,useTransition:nt,useSyncExternalStore:nt,useId:nt,useHostTransitionStatus:nt,useFormState:nt,useActionState:nt,useOptimistic:nt,useMemoCache:nt,useCacheRefresh:nt};ao.useEffectEvent=nt;var my={readContext:Ct,use:Yl,useCallback:function(s,a){return It().memoizedState=[s,a===void 0?null:a],s},useContext:Ct,useEffect:Jg,useImperativeHandle:function(s,a,i){i=i!=null?i.concat([s]):null,Wl(4194308,4,ty.bind(null,a,s),i)},useLayoutEffect:function(s,a){return Wl(4194308,4,s,a)},useInsertionEffect:function(s,a){Wl(4,2,s,a)},useMemo:function(s,a){var i=It();a=a===void 0?null:a;var c=s();if(ka){Ys(!0);try{s()}finally{Ys(!1)}}return i.memoizedState=[c,a],c},useReducer:function(s,a,i){var c=It();if(i!==void 0){var h=i(a);if(ka){Ys(!0);try{i(a)}finally{Ys(!1)}}}else h=a;return c.memoizedState=c.baseState=h,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:h},c.queue=s,s=s.dispatch=rj.bind(null,Ne,s),[c.memoizedState,s]},useRef:function(s){var a=It();return s={current:s},a.memoizedState=s},useState:function(s){s=Pd(s);var a=s.queue,i=dy.bind(null,Ne,a);return a.dispatch=i,[s.memoizedState,i]},useDebugValue:Id,useDeferredValue:function(s,a){var i=It();return $d(i,s,a)},useTransition:function(){var s=Pd(!1);return s=iy.bind(null,Ne,s.queue,!0,!1),It().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,a,i){var c=Ne,h=It();if(ze){if(i===void 0)throw Error(r(407));i=i()}else{if(i=a(),Ke===null)throw Error(r(349));(De&127)!==0||zg(c,a,i)}h.memoizedState=i;var g={value:i,getSnapshot:a};return h.queue=g,Jg(Ug.bind(null,c,g,s),[s]),c.flags|=2048,Lr(9,{destroy:void 0},Lg.bind(null,c,g,i,a),null),i},useId:function(){var s=It(),a=Ke.identifierPrefix;if(ze){var i=Ps,c=Us;i=(c&~(1<<32-vt(c)-1)).toString(32)+i,a="_"+a+"R_"+i,i=Fl++,0<i&&(a+="H"+i.toString(32)),a+="_"}else i=Q_++,a="_"+a+"r_"+i.toString(32)+"_";return s.memoizedState=a},useHostTransitionStatus:Hd,useFormState:Fg,useActionState:Fg,useOptimistic:function(s){var a=It();a.memoizedState=a.baseState=s;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=i,a=Gd.bind(null,Ne,!0,i),i.dispatch=a,[s,a]},useMemoCache:zd,useCacheRefresh:function(){return It().memoizedState=aj.bind(null,Ne)},useEffectEvent:function(s){var a=It(),i={impl:s};return a.memoizedState=i,function(){if((Be&2)!==0)throw Error(r(440));return i.impl.apply(void 0,arguments)}}},Fd={readContext:Ct,use:Yl,useCallback:ny,useContext:Ct,useEffect:Bd,useImperativeHandle:sy,useInsertionEffect:Zg,useLayoutEffect:ey,useMemo:ay,useReducer:Xl,useRef:Wg,useState:function(){return Xl(nn)},useDebugValue:Id,useDeferredValue:function(s,a){var i=ut();return ry(i,He.memoizedState,s,a)},useTransition:function(){var s=Xl(nn)[0],a=ut().memoizedState;return[typeof s=="boolean"?s:so(s),a]},useSyncExternalStore:Mg,useId:cy,useHostTransitionStatus:Hd,useFormState:Kg,useActionState:Kg,useOptimistic:function(s,a){var i=ut();return Bg(i,He,s,a)},useMemoCache:zd,useCacheRefresh:uy};Fd.useEffectEvent=Qg;var py={readContext:Ct,use:Yl,useCallback:ny,useContext:Ct,useEffect:Bd,useImperativeHandle:sy,useInsertionEffect:Zg,useLayoutEffect:ey,useMemo:ay,useReducer:Ud,useRef:Wg,useState:function(){return Ud(nn)},useDebugValue:Id,useDeferredValue:function(s,a){var i=ut();return He===null?$d(i,s,a):ry(i,He.memoizedState,s,a)},useTransition:function(){var s=Ud(nn)[0],a=ut().memoizedState;return[typeof s=="boolean"?s:so(s),a]},useSyncExternalStore:Mg,useId:cy,useHostTransitionStatus:Hd,useFormState:Xg,useActionState:Xg,useOptimistic:function(s,a){var i=ut();return He!==null?Bg(i,He,s,a):(i.baseState=s,[s,i.queue.dispatch])},useMemoCache:zd,useCacheRefresh:uy};py.useEffectEvent=Qg;function Kd(s,a,i,c){a=s.memoizedState,i=i(c,a),i=i==null?a:v({},a,i),s.memoizedState=i,s.lanes===0&&(s.updateQueue.baseState=i)}var Yd={enqueueSetState:function(s,a,i){s=s._reactInternals;var c=as(),h=kn(c);h.payload=a,i!=null&&(h.callback=i),a=Cn(s,h,c),a!==null&&(Jt(a,s,c),Qi(a,s,c))},enqueueReplaceState:function(s,a,i){s=s._reactInternals;var c=as(),h=kn(c);h.tag=1,h.payload=a,i!=null&&(h.callback=i),a=Cn(s,h,c),a!==null&&(Jt(a,s,c),Qi(a,s,c))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var i=as(),c=kn(i);c.tag=2,a!=null&&(c.callback=a),a=Cn(s,c,i),a!==null&&(Jt(a,s,i),Qi(a,s,i))}};function gy(s,a,i,c,h,g,x){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(c,g,x):a.prototype&&a.prototype.isPureReactComponent?!Hi(i,c)||!Hi(h,g):!0}function yy(s,a,i,c){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(i,c),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(i,c),a.state!==s&&Yd.enqueueReplaceState(a,a.state,null)}function Ca(s,a){var i=a;if("ref"in a){i={};for(var c in a)c!=="ref"&&(i[c]=a[c])}if(s=s.defaultProps){i===a&&(i=v({},i));for(var h in s)i[h]===void 0&&(i[h]=s[h])}return i}function vy(s){Cl(s)}function xy(s){console.error(s)}function by(s){Cl(s)}function Zl(s,a){try{var i=s.onUncaughtError;i(a.value,{componentStack:a.stack})}catch(c){setTimeout(function(){throw c})}}function wy(s,a,i){try{var c=s.onCaughtError;c(i.value,{componentStack:i.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function Xd(s,a,i){return i=kn(i),i.tag=3,i.payload={element:null},i.callback=function(){Zl(s,a)},i}function Sy(s){return s=kn(s),s.tag=3,s}function _y(s,a,i,c){var h=i.type.getDerivedStateFromError;if(typeof h=="function"){var g=c.value;s.payload=function(){return h(g)},s.callback=function(){wy(a,i,c)}}var x=i.stateNode;x!==null&&typeof x.componentDidCatch=="function"&&(s.callback=function(){wy(a,i,c),typeof h!="function"&&(Ln===null?Ln=new Set([this]):Ln.add(this));var j=c.stack;this.componentDidCatch(c.value,{componentStack:j!==null?j:""})})}function ij(s,a,i,c,h){if(i.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(a=i.alternate,a!==null&&Ar(a,i,h,!0),i=es.current,i!==null){switch(i.tag){case 31:case 13:return gs===null?dc():i.alternate===null&&at===0&&(at=3),i.flags&=-257,i.flags|=65536,i.lanes=h,c===Bl?i.flags|=16384:(a=i.updateQueue,a===null?i.updateQueue=new Set([c]):a.add(c),bh(s,c,h)),!1;case 22:return i.flags|=65536,c===Bl?i.flags|=16384:(a=i.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([c])},i.updateQueue=a):(i=a.retryQueue,i===null?a.retryQueue=new Set([c]):i.add(c)),bh(s,c,h)),!1}throw Error(r(435,i.tag))}return bh(s,c,h),dc(),!1}if(ze)return a=es.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=h,c!==md&&(s=Error(r(422),{cause:c}),Ki(hs(s,i)))):(c!==md&&(a=Error(r(423),{cause:c}),Ki(hs(a,i))),s=s.current.alternate,s.flags|=65536,h&=-h,s.lanes|=h,c=hs(c,i),h=Xd(s.stateNode,c,h),Nd(s,h),at!==4&&(at=2)),!1;var g=Error(r(520),{cause:c});if(g=hs(g,i),fo===null?fo=[g]:fo.push(g),at!==4&&(at=2),a===null)return!0;c=hs(c,i),i=a;do{switch(i.tag){case 3:return i.flags|=65536,s=h&-h,i.lanes|=s,s=Xd(i.stateNode,c,s),Nd(i,s),!1;case 1:if(a=i.type,g=i.stateNode,(i.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Ln===null||!Ln.has(g))))return i.flags|=65536,h&=-h,i.lanes|=h,h=Sy(h),_y(h,s,i,c),Nd(i,h),!1}i=i.return}while(i!==null);return!1}var Wd=Error(r(461)),mt=!1;function Rt(s,a,i,c){a.child=s===null?Tg(a,null,i,c):Aa(a,s.child,i,c)}function jy(s,a,i,c,h){i=i.render;var g=a.ref;if("ref"in c){var x={};for(var j in c)j!=="ref"&&(x[j]=c[j])}else x=c;return ja(a),c=Rd(s,a,i,x,g,h),j=Od(),s!==null&&!mt?(Dd(s,a,h),an(s,a,h)):(ze&&j&&hd(a),a.flags|=1,Rt(s,a,c,h),a.child)}function Ny(s,a,i,c,h){if(s===null){var g=i.type;return typeof g=="function"&&!cd(g)&&g.defaultProps===void 0&&i.compare===null?(a.tag=15,a.type=g,Ey(s,a,g,c,h)):(s=Ml(i.type,null,c,a,a.mode,h),s.ref=a.ref,s.return=a,a.child=s)}if(g=s.child,!ah(s,h)){var x=g.memoizedProps;if(i=i.compare,i=i!==null?i:Hi,i(x,c)&&s.ref===a.ref)return an(s,a,h)}return a.flags|=1,s=Qs(g,c),s.ref=a.ref,s.return=a,a.child=s}function Ey(s,a,i,c,h){if(s!==null){var g=s.memoizedProps;if(Hi(g,c)&&s.ref===a.ref)if(mt=!1,a.pendingProps=c=g,ah(s,h))(s.flags&131072)!==0&&(mt=!0);else return a.lanes=s.lanes,an(s,a,h)}return Jd(s,a,i,c,h)}function Ty(s,a,i,c){var h=c.children,g=s!==null?s.memoizedState:null;if(s===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((a.flags&128)!==0){if(g=g!==null?g.baseLanes|i:i,s!==null){for(c=a.child=s.child,h=0;c!==null;)h=h|c.lanes|c.childLanes,c=c.sibling;c=h&~g}else c=0,a.child=null;return Ay(s,a,g,i,c)}if((i&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},s!==null&&Pl(a,g!==null?g.cachePool:null),g!==null?Cg(a,g):Td(),Rg(a);else return c=a.lanes=536870912,Ay(s,a,g!==null?g.baseLanes|i:i,i,c)}else g!==null?(Pl(a,g.cachePool),Cg(a,g),On(),a.memoizedState=null):(s!==null&&Pl(a,null),Td(),On());return Rt(s,a,h,i),a.child}function ro(s,a){return s!==null&&s.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Ay(s,a,i,c,h){var g=wd();return g=g===null?null:{parent:ht._currentValue,pool:g},a.memoizedState={baseLanes:i,cachePool:g},s!==null&&Pl(a,null),Td(),Rg(a),s!==null&&Ar(s,a,c,!0),a.childLanes=h,null}function ec(s,a){return a=sc({mode:a.mode,children:a.children},s.mode),a.ref=s.ref,s.child=a,a.return=s,a}function ky(s,a,i){return Aa(a,s.child,null,i),s=ec(a,a.pendingProps),s.flags|=2,ts(a),a.memoizedState=null,s}function oj(s,a,i){var c=a.pendingProps,h=(a.flags&128)!==0;if(a.flags&=-129,s===null){if(ze){if(c.mode==="hidden")return s=ec(a,c),a.lanes=536870912,ro(null,s);if(kd(a),(s=We)?(s=Iv(s,ps),s=s!==null&&s.data==="&"?s:null,s!==null&&(a.memoizedState={dehydrated:s,treeContext:jn!==null?{id:Us,overflow:Ps}:null,retryLane:536870912,hydrationErrors:null},i=hg(s),i.return=a,a.child=i,kt=a,We=null)):s=null,s===null)throw En(a);return a.lanes=536870912,null}return ec(a,c)}var g=s.memoizedState;if(g!==null){var x=g.dehydrated;if(kd(a),h)if(a.flags&256)a.flags&=-257,a=ky(s,a,i);else if(a.memoizedState!==null)a.child=s.child,a.flags|=128,a=null;else throw Error(r(558));else if(mt||Ar(s,a,i,!1),h=(i&s.childLanes)!==0,mt||h){if(c=Ke,c!==null&&(x=gl(c,i),x!==0&&x!==g.retryLane))throw g.retryLane=x,ba(s,x),Jt(c,s,x),Wd;dc(),a=ky(s,a,i)}else s=g.treeContext,We=ys(x.nextSibling),kt=a,ze=!0,Nn=null,ps=!1,s!==null&&pg(a,s),a=ec(a,c),a.flags|=4096;return a}return s=Qs(s.child,{mode:c.mode,children:c.children}),s.ref=a.ref,a.child=s,s.return=a,s}function tc(s,a){var i=a.ref;if(i===null)s!==null&&s.ref!==null&&(a.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(r(284));(s===null||s.ref!==i)&&(a.flags|=4194816)}}function Jd(s,a,i,c,h){return ja(a),i=Rd(s,a,i,c,void 0,h),c=Od(),s!==null&&!mt?(Dd(s,a,h),an(s,a,h)):(ze&&c&&hd(a),a.flags|=1,Rt(s,a,i,h),a.child)}function Cy(s,a,i,c,h,g){return ja(a),a.updateQueue=null,i=Dg(a,c,i,h),Og(s),c=Od(),s!==null&&!mt?(Dd(s,a,g),an(s,a,g)):(ze&&c&&hd(a),a.flags|=1,Rt(s,a,i,g),a.child)}function Ry(s,a,i,c,h){if(ja(a),a.stateNode===null){var g=jr,x=i.contextType;typeof x=="object"&&x!==null&&(g=Ct(x)),g=new i(c,g),a.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Yd,a.stateNode=g,g._reactInternals=a,g=a.stateNode,g.props=c,g.state=a.memoizedState,g.refs={},_d(a),x=i.contextType,g.context=typeof x=="object"&&x!==null?Ct(x):jr,g.state=a.memoizedState,x=i.getDerivedStateFromProps,typeof x=="function"&&(Kd(a,i,x,c),g.state=a.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(x=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),x!==g.state&&Yd.enqueueReplaceState(g,g.state,null),eo(a,c,g,h),Zi(),g.state=a.memoizedState),typeof g.componentDidMount=="function"&&(a.flags|=4194308),c=!0}else if(s===null){g=a.stateNode;var j=a.memoizedProps,k=Ca(i,j);g.props=k;var V=g.context,K=i.contextType;x=jr,typeof K=="object"&&K!==null&&(x=Ct(K));var W=i.getDerivedStateFromProps;K=typeof W=="function"||typeof g.getSnapshotBeforeUpdate=="function",j=a.pendingProps!==j,K||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(j||V!==x)&&yy(a,g,c,x),An=!1;var $=a.memoizedState;g.state=$,eo(a,c,g,h),Zi(),V=a.memoizedState,j||$!==V||An?(typeof W=="function"&&(Kd(a,i,W,c),V=a.memoizedState),(k=An||gy(a,i,k,c,$,V,x))?(K||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(a.flags|=4194308)):(typeof g.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=c,a.memoizedState=V),g.props=c,g.state=V,g.context=x,c=k):(typeof g.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{g=a.stateNode,jd(s,a),x=a.memoizedProps,K=Ca(i,x),g.props=K,W=a.pendingProps,$=g.context,V=i.contextType,k=jr,typeof V=="object"&&V!==null&&(k=Ct(V)),j=i.getDerivedStateFromProps,(V=typeof j=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(x!==W||$!==k)&&yy(a,g,c,k),An=!1,$=a.memoizedState,g.state=$,eo(a,c,g,h),Zi();var F=a.memoizedState;x!==W||$!==F||An||s!==null&&s.dependencies!==null&&Ll(s.dependencies)?(typeof j=="function"&&(Kd(a,i,j,c),F=a.memoizedState),(K=An||gy(a,i,K,c,$,F,k)||s!==null&&s.dependencies!==null&&Ll(s.dependencies))?(V||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,F,k),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,F,k)),typeof g.componentDidUpdate=="function"&&(a.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof g.componentDidUpdate!="function"||x===s.memoizedProps&&$===s.memoizedState||(a.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||x===s.memoizedProps&&$===s.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=F),g.props=c,g.state=F,g.context=k,c=K):(typeof g.componentDidUpdate!="function"||x===s.memoizedProps&&$===s.memoizedState||(a.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||x===s.memoizedProps&&$===s.memoizedState||(a.flags|=1024),c=!1)}return g=c,tc(s,a),c=(a.flags&128)!==0,g||c?(g=a.stateNode,i=c&&typeof i.getDerivedStateFromError!="function"?null:g.render(),a.flags|=1,s!==null&&c?(a.child=Aa(a,s.child,null,h),a.child=Aa(a,null,i,h)):Rt(s,a,i,h),a.memoizedState=g.state,s=a.child):s=an(s,a,h),s}function Oy(s,a,i,c){return Sa(),a.flags|=256,Rt(s,a,i,c),a.child}var Qd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zd(s){return{baseLanes:s,cachePool:wg()}}function eh(s,a,i){return s=s!==null?s.childLanes&~i:0,a&&(s|=ns),s}function Dy(s,a,i){var c=a.pendingProps,h=!1,g=(a.flags&128)!==0,x;if((x=g)||(x=s!==null&&s.memoizedState===null?!1:(ct.current&2)!==0),x&&(h=!0,a.flags&=-129),x=(a.flags&32)!==0,a.flags&=-33,s===null){if(ze){if(h?Rn(a):On(),(s=We)?(s=Iv(s,ps),s=s!==null&&s.data!=="&"?s:null,s!==null&&(a.memoizedState={dehydrated:s,treeContext:jn!==null?{id:Us,overflow:Ps}:null,retryLane:536870912,hydrationErrors:null},i=hg(s),i.return=a,a.child=i,kt=a,We=null)):s=null,s===null)throw En(a);return Lh(s)?a.lanes=32:a.lanes=536870912,null}var j=c.children;return c=c.fallback,h?(On(),h=a.mode,j=sc({mode:"hidden",children:j},h),c=wa(c,h,i,null),j.return=a,c.return=a,j.sibling=c,a.child=j,c=a.child,c.memoizedState=Zd(i),c.childLanes=eh(s,x,i),a.memoizedState=Qd,ro(null,c)):(Rn(a),th(a,j))}var k=s.memoizedState;if(k!==null&&(j=k.dehydrated,j!==null)){if(g)a.flags&256?(Rn(a),a.flags&=-257,a=sh(s,a,i)):a.memoizedState!==null?(On(),a.child=s.child,a.flags|=128,a=null):(On(),j=c.fallback,h=a.mode,c=sc({mode:"visible",children:c.children},h),j=wa(j,h,i,null),j.flags|=2,c.return=a,j.return=a,c.sibling=j,a.child=c,Aa(a,s.child,null,i),c=a.child,c.memoizedState=Zd(i),c.childLanes=eh(s,x,i),a.memoizedState=Qd,a=ro(null,c));else if(Rn(a),Lh(j)){if(x=j.nextSibling&&j.nextSibling.dataset,x)var V=x.dgst;x=V,c=Error(r(419)),c.stack="",c.digest=x,Ki({value:c,source:null,stack:null}),a=sh(s,a,i)}else if(mt||Ar(s,a,i,!1),x=(i&s.childLanes)!==0,mt||x){if(x=Ke,x!==null&&(c=gl(x,i),c!==0&&c!==k.retryLane))throw k.retryLane=c,ba(s,c),Jt(x,s,c),Wd;zh(j)||dc(),a=sh(s,a,i)}else zh(j)?(a.flags|=192,a.child=s.child,a=null):(s=k.treeContext,We=ys(j.nextSibling),kt=a,ze=!0,Nn=null,ps=!1,s!==null&&pg(a,s),a=th(a,c.children),a.flags|=4096);return a}return h?(On(),j=c.fallback,h=a.mode,k=s.child,V=k.sibling,c=Qs(k,{mode:"hidden",children:c.children}),c.subtreeFlags=k.subtreeFlags&65011712,V!==null?j=Qs(V,j):(j=wa(j,h,i,null),j.flags|=2),j.return=a,c.return=a,c.sibling=j,a.child=c,ro(null,c),c=a.child,j=s.child.memoizedState,j===null?j=Zd(i):(h=j.cachePool,h!==null?(k=ht._currentValue,h=h.parent!==k?{parent:k,pool:k}:h):h=wg(),j={baseLanes:j.baseLanes|i,cachePool:h}),c.memoizedState=j,c.childLanes=eh(s,x,i),a.memoizedState=Qd,ro(s.child,c)):(Rn(a),i=s.child,s=i.sibling,i=Qs(i,{mode:"visible",children:c.children}),i.return=a,i.sibling=null,s!==null&&(x=a.deletions,x===null?(a.deletions=[s],a.flags|=16):x.push(s)),a.child=i,a.memoizedState=null,i)}function th(s,a){return a=sc({mode:"visible",children:a},s.mode),a.return=s,s.child=a}function sc(s,a){return s=Zt(22,s,null,a),s.lanes=0,s}function sh(s,a,i){return Aa(a,s.child,null,i),s=th(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function My(s,a,i){s.lanes|=a;var c=s.alternate;c!==null&&(c.lanes|=a),yd(s.return,a,i)}function nh(s,a,i,c,h,g){var x=s.memoizedState;x===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:h,treeForkCount:g}:(x.isBackwards=a,x.rendering=null,x.renderingStartTime=0,x.last=c,x.tail=i,x.tailMode=h,x.treeForkCount=g)}function zy(s,a,i){var c=a.pendingProps,h=c.revealOrder,g=c.tail;c=c.children;var x=ct.current,j=(x&2)!==0;if(j?(x=x&1|2,a.flags|=128):x&=1,Z(ct,x),Rt(s,a,c,i),c=ze?Fi:0,!j&&s!==null&&(s.flags&128)!==0)e:for(s=a.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&My(s,i,a);else if(s.tag===19)My(s,i,a);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(h){case"forwards":for(i=a.child,h=null;i!==null;)s=i.alternate,s!==null&&Hl(s)===null&&(h=i),i=i.sibling;i=h,i===null?(h=a.child,a.child=null):(h=i.sibling,i.sibling=null),nh(a,!1,h,i,g,c);break;case"backwards":case"unstable_legacy-backwards":for(i=null,h=a.child,a.child=null;h!==null;){if(s=h.alternate,s!==null&&Hl(s)===null){a.child=h;break}s=h.sibling,h.sibling=i,i=h,h=s}nh(a,!0,i,null,g,c);break;case"together":nh(a,!1,null,null,void 0,c);break;default:a.memoizedState=null}return a.child}function an(s,a,i){if(s!==null&&(a.dependencies=s.dependencies),zn|=a.lanes,(i&a.childLanes)===0)if(s!==null){if(Ar(s,a,i,!1),(i&a.childLanes)===0)return null}else return null;if(s!==null&&a.child!==s.child)throw Error(r(153));if(a.child!==null){for(s=a.child,i=Qs(s,s.pendingProps),a.child=i,i.return=a;s.sibling!==null;)s=s.sibling,i=i.sibling=Qs(s,s.pendingProps),i.return=a;i.sibling=null}return a.child}function ah(s,a){return(s.lanes&a)!==0?!0:(s=s.dependencies,!!(s!==null&&Ll(s)))}function lj(s,a,i){switch(a.tag){case 3:lt(a,a.stateNode.containerInfo),Tn(a,ht,s.memoizedState.cache),Sa();break;case 27:case 5:ls(a);break;case 4:lt(a,a.stateNode.containerInfo);break;case 10:Tn(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,kd(a),null;break;case 13:var c=a.memoizedState;if(c!==null)return c.dehydrated!==null?(Rn(a),a.flags|=128,null):(i&a.child.childLanes)!==0?Dy(s,a,i):(Rn(a),s=an(s,a,i),s!==null?s.sibling:null);Rn(a);break;case 19:var h=(s.flags&128)!==0;if(c=(i&a.childLanes)!==0,c||(Ar(s,a,i,!1),c=(i&a.childLanes)!==0),h){if(c)return zy(s,a,i);a.flags|=128}if(h=a.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Z(ct,ct.current),c)break;return null;case 22:return a.lanes=0,Ty(s,a,i,a.pendingProps);case 24:Tn(a,ht,s.memoizedState.cache)}return an(s,a,i)}function Ly(s,a,i){if(s!==null)if(s.memoizedProps!==a.pendingProps)mt=!0;else{if(!ah(s,i)&&(a.flags&128)===0)return mt=!1,lj(s,a,i);mt=(s.flags&131072)!==0}else mt=!1,ze&&(a.flags&1048576)!==0&&mg(a,Fi,a.index);switch(a.lanes=0,a.tag){case 16:e:{var c=a.pendingProps;if(s=Ea(a.elementType),a.type=s,typeof s=="function")cd(s)?(c=Ca(s,c),a.tag=1,a=Ry(null,a,s,c,i)):(a.tag=0,a=Jd(null,a,s,c,i));else{if(s!=null){var h=s.$$typeof;if(h===U){a.tag=11,a=jy(null,a,s,c,i);break e}else if(h===z){a.tag=14,a=Ny(null,a,s,c,i);break e}}throw a=Ie(s)||s,Error(r(306,a,""))}}return a;case 0:return Jd(s,a,a.type,a.pendingProps,i);case 1:return c=a.type,h=Ca(c,a.pendingProps),Ry(s,a,c,h,i);case 3:e:{if(lt(a,a.stateNode.containerInfo),s===null)throw Error(r(387));c=a.pendingProps;var g=a.memoizedState;h=g.element,jd(s,a),eo(a,c,null,i);var x=a.memoizedState;if(c=x.cache,Tn(a,ht,c),c!==g.cache&&vd(a,[ht],i,!0),Zi(),c=x.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:x.cache},a.updateQueue.baseState=g,a.memoizedState=g,a.flags&256){a=Oy(s,a,c,i);break e}else if(c!==h){h=hs(Error(r(424)),a),Ki(h),a=Oy(s,a,c,i);break e}else for(s=a.stateNode.containerInfo,s.nodeType===9?s=s.body:s=s.nodeName==="HTML"?s.ownerDocument.body:s,We=ys(s.firstChild),kt=a,ze=!0,Nn=null,ps=!0,i=Tg(a,null,c,i),a.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Sa(),c===h){a=an(s,a,i);break e}Rt(s,a,c,i)}a=a.child}return a;case 26:return tc(s,a),s===null?(i=Kv(a.type,null,a.pendingProps,null))?a.memoizedState=i:ze||(i=a.type,s=a.pendingProps,c=vc(_e.current).createElement(i),c[I]=a,c[ne]=s,Ot(c,i,s),jt(c),a.stateNode=c):a.memoizedState=Kv(a.type,s.memoizedProps,a.pendingProps,s.memoizedState),null;case 27:return ls(a),s===null&&ze&&(c=a.stateNode=Hv(a.type,a.pendingProps,_e.current),kt=a,ps=!0,h=We,Bn(a.type)?(Uh=h,We=ys(c.firstChild)):We=h),Rt(s,a,a.pendingProps.children,i),tc(s,a),s===null&&(a.flags|=4194304),a.child;case 5:return s===null&&ze&&((h=c=We)&&(c=Pj(c,a.type,a.pendingProps,ps),c!==null?(a.stateNode=c,kt=a,We=ys(c.firstChild),ps=!1,h=!0):h=!1),h||En(a)),ls(a),h=a.type,g=a.pendingProps,x=s!==null?s.memoizedProps:null,c=g.children,Oh(h,g)?c=null:x!==null&&Oh(h,x)&&(a.flags|=32),a.memoizedState!==null&&(h=Rd(s,a,Z_,null,null,i),wo._currentValue=h),tc(s,a),Rt(s,a,c,i),a.child;case 6:return s===null&&ze&&((s=i=We)&&(i=Vj(i,a.pendingProps,ps),i!==null?(a.stateNode=i,kt=a,We=null,s=!0):s=!1),s||En(a)),null;case 13:return Dy(s,a,i);case 4:return lt(a,a.stateNode.containerInfo),c=a.pendingProps,s===null?a.child=Aa(a,null,c,i):Rt(s,a,c,i),a.child;case 11:return jy(s,a,a.type,a.pendingProps,i);case 7:return Rt(s,a,a.pendingProps,i),a.child;case 8:return Rt(s,a,a.pendingProps.children,i),a.child;case 12:return Rt(s,a,a.pendingProps.children,i),a.child;case 10:return c=a.pendingProps,Tn(a,a.type,c.value),Rt(s,a,c.children,i),a.child;case 9:return h=a.type._context,c=a.pendingProps.children,ja(a),h=Ct(h),c=c(h),a.flags|=1,Rt(s,a,c,i),a.child;case 14:return Ny(s,a,a.type,a.pendingProps,i);case 15:return Ey(s,a,a.type,a.pendingProps,i);case 19:return zy(s,a,i);case 31:return oj(s,a,i);case 22:return Ty(s,a,i,a.pendingProps);case 24:return ja(a),c=Ct(ht),s===null?(h=wd(),h===null&&(h=Ke,g=xd(),h.pooledCache=g,g.refCount++,g!==null&&(h.pooledCacheLanes|=i),h=g),a.memoizedState={parent:c,cache:h},_d(a),Tn(a,ht,h)):((s.lanes&i)!==0&&(jd(s,a),eo(a,null,null,i),Zi()),h=s.memoizedState,g=a.memoizedState,h.parent!==c?(h={parent:c,cache:c},a.memoizedState=h,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=h),Tn(a,ht,c)):(c=g.cache,Tn(a,ht,c),c!==h.cache&&vd(a,[ht],i,!0))),Rt(s,a,a.pendingProps.children,i),a.child;case 29:throw a.pendingProps}throw Error(r(156,a.tag))}function rn(s){s.flags|=4}function rh(s,a,i,c,h){if((a=(s.mode&32)!==0)&&(a=!1),a){if(s.flags|=16777216,(h&335544128)===h)if(s.stateNode.complete)s.flags|=8192;else if(cv())s.flags|=8192;else throw Ta=Bl,Sd}else s.flags&=-16777217}function Uy(s,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!Qv(a))if(cv())s.flags|=8192;else throw Ta=Bl,Sd}function nc(s,a){a!==null&&(s.flags|=4),s.flags&16384&&(a=s.tag!==22?fl():536870912,s.lanes|=a,Br|=a)}function io(s,a){if(!ze)switch(s.tailMode){case"hidden":a=s.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?s.tail=null:i.sibling=null;break;case"collapsed":i=s.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:c.sibling=null}}function Je(s){var a=s.alternate!==null&&s.alternate.child===s.child,i=0,c=0;if(a)for(var h=s.child;h!==null;)i|=h.lanes|h.childLanes,c|=h.subtreeFlags&65011712,c|=h.flags&65011712,h.return=s,h=h.sibling;else for(h=s.child;h!==null;)i|=h.lanes|h.childLanes,c|=h.subtreeFlags,c|=h.flags,h.return=s,h=h.sibling;return s.subtreeFlags|=c,s.childLanes=i,a}function cj(s,a,i){var c=a.pendingProps;switch(fd(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Je(a),null;case 1:return Je(a),null;case 3:return i=a.stateNode,c=null,s!==null&&(c=s.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),tn(ht),Le(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(s===null||s.child===null)&&(Tr(a)?rn(a):s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,pd())),Je(a),null;case 26:var h=a.type,g=a.memoizedState;return s===null?(rn(a),g!==null?(Je(a),Uy(a,g)):(Je(a),rh(a,h,null,c,i))):g?g!==s.memoizedState?(rn(a),Je(a),Uy(a,g)):(Je(a),a.flags&=-16777217):(s=s.memoizedProps,s!==c&&rn(a),Je(a),rh(a,h,s,c,i)),null;case 27:if(Gt(a),i=_e.current,h=a.type,s!==null&&a.stateNode!=null)s.memoizedProps!==c&&rn(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return Je(a),null}s=te.current,Tr(a)?gg(a):(s=Hv(h,c,i),a.stateNode=s,rn(a))}return Je(a),null;case 5:if(Gt(a),h=a.type,s!==null&&a.stateNode!=null)s.memoizedProps!==c&&rn(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return Je(a),null}if(g=te.current,Tr(a))gg(a);else{var x=vc(_e.current);switch(g){case 1:g=x.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:g=x.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":g=x.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":g=x.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":g=x.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?x.createElement("select",{is:c.is}):x.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?x.createElement(h,{is:c.is}):x.createElement(h)}}g[I]=a,g[ne]=c;e:for(x=a.child;x!==null;){if(x.tag===5||x.tag===6)g.appendChild(x.stateNode);else if(x.tag!==4&&x.tag!==27&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===a)break e;for(;x.sibling===null;){if(x.return===null||x.return===a)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}a.stateNode=g;e:switch(Ot(g,h,c),h){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&rn(a)}}return Je(a),rh(a,a.type,s===null?null:s.memoizedProps,a.pendingProps,i),null;case 6:if(s&&a.stateNode!=null)s.memoizedProps!==c&&rn(a);else{if(typeof c!="string"&&a.stateNode===null)throw Error(r(166));if(s=_e.current,Tr(a)){if(s=a.stateNode,i=a.memoizedProps,c=null,h=kt,h!==null)switch(h.tag){case 27:case 5:c=h.memoizedProps}s[I]=a,s=!!(s.nodeValue===i||c!==null&&c.suppressHydrationWarning===!0||Dv(s.nodeValue,i)),s||En(a,!0)}else s=vc(s).createTextNode(c),s[I]=a,a.stateNode=s}return Je(a),null;case 31:if(i=a.memoizedState,s===null||s.memoizedState!==null){if(c=Tr(a),i!==null){if(s===null){if(!c)throw Error(r(318));if(s=a.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[I]=a}else Sa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Je(a),s=!1}else i=pd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=i),s=!0;if(!s)return a.flags&256?(ts(a),a):(ts(a),null);if((a.flags&128)!==0)throw Error(r(558))}return Je(a),null;case 13:if(c=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(h=Tr(a),c!==null&&c.dehydrated!==null){if(s===null){if(!h)throw Error(r(318));if(h=a.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[I]=a}else Sa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Je(a),h=!1}else h=pd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=h),h=!0;if(!h)return a.flags&256?(ts(a),a):(ts(a),null)}return ts(a),(a.flags&128)!==0?(a.lanes=i,a):(i=c!==null,s=s!==null&&s.memoizedState!==null,i&&(c=a.child,h=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(h=c.alternate.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==h&&(c.flags|=2048)),i!==s&&i&&(a.child.flags|=8192),nc(a,a.updateQueue),Je(a),null);case 4:return Le(),s===null&&Th(a.stateNode.containerInfo),Je(a),null;case 10:return tn(a.type),Je(a),null;case 19:if(Y(ct),c=a.memoizedState,c===null)return Je(a),null;if(h=(a.flags&128)!==0,g=c.rendering,g===null)if(h)io(c,!1);else{if(at!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(g=Hl(s),g!==null){for(a.flags|=128,io(c,!1),s=g.updateQueue,a.updateQueue=s,nc(a,s),a.subtreeFlags=0,s=i,i=a.child;i!==null;)dg(i,s),i=i.sibling;return Z(ct,ct.current&1|2),ze&&Zs(a,c.treeForkCount),a.child}s=s.sibling}c.tail!==null&&Tt()>lc&&(a.flags|=128,h=!0,io(c,!1),a.lanes=4194304)}else{if(!h)if(s=Hl(g),s!==null){if(a.flags|=128,h=!0,s=s.updateQueue,a.updateQueue=s,nc(a,s),io(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!ze)return Je(a),null}else 2*Tt()-c.renderingStartTime>lc&&i!==536870912&&(a.flags|=128,h=!0,io(c,!1),a.lanes=4194304);c.isBackwards?(g.sibling=a.child,a.child=g):(s=c.last,s!==null?s.sibling=g:a.child=g,c.last=g)}return c.tail!==null?(s=c.tail,c.rendering=s,c.tail=s.sibling,c.renderingStartTime=Tt(),s.sibling=null,i=ct.current,Z(ct,h?i&1|2:i&1),ze&&Zs(a,c.treeForkCount),s):(Je(a),null);case 22:case 23:return ts(a),Ad(),c=a.memoizedState!==null,s!==null?s.memoizedState!==null!==c&&(a.flags|=8192):c&&(a.flags|=8192),c?(i&536870912)!==0&&(a.flags&128)===0&&(Je(a),a.subtreeFlags&6&&(a.flags|=8192)):Je(a),i=a.updateQueue,i!==null&&nc(a,i.retryQueue),i=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),c=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(c=a.memoizedState.cachePool.pool),c!==i&&(a.flags|=2048),s!==null&&Y(Na),null;case 24:return i=null,s!==null&&(i=s.memoizedState.cache),a.memoizedState.cache!==i&&(a.flags|=2048),tn(ht),Je(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function uj(s,a){switch(fd(a),a.tag){case 1:return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return tn(ht),Le(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 26:case 27:case 5:return Gt(a),null;case 31:if(a.memoizedState!==null){if(ts(a),a.alternate===null)throw Error(r(340));Sa()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 13:if(ts(a),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(r(340));Sa()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return Y(ct),null;case 4:return Le(),null;case 10:return tn(a.type),null;case 22:case 23:return ts(a),Ad(),s!==null&&Y(Na),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 24:return tn(ht),null;case 25:return null;default:return null}}function Py(s,a){switch(fd(a),a.tag){case 3:tn(ht),Le();break;case 26:case 27:case 5:Gt(a);break;case 4:Le();break;case 31:a.memoizedState!==null&&ts(a);break;case 13:ts(a);break;case 19:Y(ct);break;case 10:tn(a.type);break;case 22:case 23:ts(a),Ad(),s!==null&&Y(Na);break;case 24:tn(ht)}}function oo(s,a){try{var i=a.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var h=c.next;i=h;do{if((i.tag&s)===s){c=void 0;var g=i.create,x=i.inst;c=g(),x.destroy=c}i=i.next}while(i!==h)}}catch(j){qe(a,a.return,j)}}function Dn(s,a,i){try{var c=a.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var g=h.next;c=g;do{if((c.tag&s)===s){var x=c.inst,j=x.destroy;if(j!==void 0){x.destroy=void 0,h=a;var k=i,V=j;try{V()}catch(K){qe(h,k,K)}}}c=c.next}while(c!==g)}}catch(K){qe(a,a.return,K)}}function Vy(s){var a=s.updateQueue;if(a!==null){var i=s.stateNode;try{kg(a,i)}catch(c){qe(s,s.return,c)}}}function By(s,a,i){i.props=Ca(s.type,s.memoizedProps),i.state=s.memoizedState;try{i.componentWillUnmount()}catch(c){qe(s,a,c)}}function lo(s,a){try{var i=s.ref;if(i!==null){switch(s.tag){case 26:case 27:case 5:var c=s.stateNode;break;case 30:c=s.stateNode;break;default:c=s.stateNode}typeof i=="function"?s.refCleanup=i(c):i.current=c}}catch(h){qe(s,a,h)}}function Vs(s,a){var i=s.ref,c=s.refCleanup;if(i!==null)if(typeof c=="function")try{c()}catch(h){qe(s,a,h)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(h){qe(s,a,h)}else i.current=null}function Iy(s){var a=s.type,i=s.memoizedProps,c=s.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":i.autoFocus&&c.focus();break e;case"img":i.src?c.src=i.src:i.srcSet&&(c.srcset=i.srcSet)}}catch(h){qe(s,s.return,h)}}function ih(s,a,i){try{var c=s.stateNode;Oj(c,s.type,i,a),c[ne]=a}catch(h){qe(s,s.return,h)}}function $y(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Bn(s.type)||s.tag===4}function oh(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||$y(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Bn(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function lh(s,a,i){var c=s.tag;if(c===5||c===6)s=s.stateNode,a?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(s,a):(a=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.appendChild(s),i=i._reactRootContainer,i!=null||a.onclick!==null||(a.onclick=Ws));else if(c!==4&&(c===27&&Bn(s.type)&&(i=s.stateNode,a=null),s=s.child,s!==null))for(lh(s,a,i),s=s.sibling;s!==null;)lh(s,a,i),s=s.sibling}function ac(s,a,i){var c=s.tag;if(c===5||c===6)s=s.stateNode,a?i.insertBefore(s,a):i.appendChild(s);else if(c!==4&&(c===27&&Bn(s.type)&&(i=s.stateNode),s=s.child,s!==null))for(ac(s,a,i),s=s.sibling;s!==null;)ac(s,a,i),s=s.sibling}function qy(s){var a=s.stateNode,i=s.memoizedProps;try{for(var c=s.type,h=a.attributes;h.length;)a.removeAttributeNode(h[0]);Ot(a,c,i),a[I]=s,a[ne]=i}catch(g){qe(s,s.return,g)}}var on=!1,pt=!1,ch=!1,Hy=typeof WeakSet=="function"?WeakSet:Set,Nt=null;function dj(s,a){if(s=s.containerInfo,Ch=Nc,s=sg(s),sd(s)){if("selectionStart"in s)var i={start:s.selectionStart,end:s.selectionEnd};else e:{i=(i=s.ownerDocument)&&i.defaultView||window;var c=i.getSelection&&i.getSelection();if(c&&c.rangeCount!==0){i=c.anchorNode;var h=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var x=0,j=-1,k=-1,V=0,K=0,W=s,$=null;t:for(;;){for(var F;W!==i||h!==0&&W.nodeType!==3||(j=x+h),W!==g||c!==0&&W.nodeType!==3||(k=x+c),W.nodeType===3&&(x+=W.nodeValue.length),(F=W.firstChild)!==null;)$=W,W=F;for(;;){if(W===s)break t;if($===i&&++V===h&&(j=x),$===g&&++K===c&&(k=x),(F=W.nextSibling)!==null)break;W=$,$=W.parentNode}W=F}i=j===-1||k===-1?null:{start:j,end:k}}else i=null}i=i||{start:0,end:0}}else i=null;for(Rh={focusedElem:s,selectionRange:i},Nc=!1,Nt=a;Nt!==null;)if(a=Nt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,Nt=s;else for(;Nt!==null;){switch(a=Nt,g=a.alternate,s=a.flags,a.tag){case 0:if((s&4)!==0&&(s=a.updateQueue,s=s!==null?s.events:null,s!==null))for(i=0;i<s.length;i++)h=s[i],h.ref.impl=h.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&g!==null){s=void 0,i=a,h=g.memoizedProps,g=g.memoizedState,c=i.stateNode;try{var oe=Ca(i.type,h);s=c.getSnapshotBeforeUpdate(oe,g),c.__reactInternalSnapshotBeforeUpdate=s}catch(ye){qe(i,i.return,ye)}}break;case 3:if((s&1024)!==0){if(s=a.stateNode.containerInfo,i=s.nodeType,i===9)Mh(s);else if(i===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Mh(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(r(163))}if(s=a.sibling,s!==null){s.return=a.return,Nt=s;break}Nt=a.return}}function Gy(s,a,i){var c=i.flags;switch(i.tag){case 0:case 11:case 15:cn(s,i),c&4&&oo(5,i);break;case 1:if(cn(s,i),c&4)if(s=i.stateNode,a===null)try{s.componentDidMount()}catch(x){qe(i,i.return,x)}else{var h=Ca(i.type,a.memoizedProps);a=a.memoizedState;try{s.componentDidUpdate(h,a,s.__reactInternalSnapshotBeforeUpdate)}catch(x){qe(i,i.return,x)}}c&64&&Vy(i),c&512&&lo(i,i.return);break;case 3:if(cn(s,i),c&64&&(s=i.updateQueue,s!==null)){if(a=null,i.child!==null)switch(i.child.tag){case 27:case 5:a=i.child.stateNode;break;case 1:a=i.child.stateNode}try{kg(s,a)}catch(x){qe(i,i.return,x)}}break;case 27:a===null&&c&4&&qy(i);case 26:case 5:cn(s,i),a===null&&c&4&&Iy(i),c&512&&lo(i,i.return);break;case 12:cn(s,i);break;case 31:cn(s,i),c&4&&Yy(s,i);break;case 13:cn(s,i),c&4&&Xy(s,i),c&64&&(s=i.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(i=bj.bind(null,i),Bj(s,i))));break;case 22:if(c=i.memoizedState!==null||on,!c){a=a!==null&&a.memoizedState!==null||pt,h=on;var g=pt;on=c,(pt=a)&&!g?un(s,i,(i.subtreeFlags&8772)!==0):cn(s,i),on=h,pt=g}break;case 30:break;default:cn(s,i)}}function Fy(s){var a=s.alternate;a!==null&&(s.alternate=null,Fy(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&zi(a)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var et=null,Kt=!1;function ln(s,a,i){for(i=i.child;i!==null;)Ky(s,a,i),i=i.sibling}function Ky(s,a,i){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Sn,i)}catch{}switch(i.tag){case 26:pt||Vs(i,a),ln(s,a,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:pt||Vs(i,a);var c=et,h=Kt;Bn(i.type)&&(et=i.stateNode,Kt=!1),ln(s,a,i),vo(i.stateNode),et=c,Kt=h;break;case 5:pt||Vs(i,a);case 6:if(c=et,h=Kt,et=null,ln(s,a,i),et=c,Kt=h,et!==null)if(Kt)try{(et.nodeType===9?et.body:et.nodeName==="HTML"?et.ownerDocument.body:et).removeChild(i.stateNode)}catch(g){qe(i,a,g)}else try{et.removeChild(i.stateNode)}catch(g){qe(i,a,g)}break;case 18:et!==null&&(Kt?(s=et,Vv(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,i.stateNode),Yr(s)):Vv(et,i.stateNode));break;case 4:c=et,h=Kt,et=i.stateNode.containerInfo,Kt=!0,ln(s,a,i),et=c,Kt=h;break;case 0:case 11:case 14:case 15:Dn(2,i,a),pt||Dn(4,i,a),ln(s,a,i);break;case 1:pt||(Vs(i,a),c=i.stateNode,typeof c.componentWillUnmount=="function"&&By(i,a,c)),ln(s,a,i);break;case 21:ln(s,a,i);break;case 22:pt=(c=pt)||i.memoizedState!==null,ln(s,a,i),pt=c;break;default:ln(s,a,i)}}function Yy(s,a){if(a.memoizedState===null&&(s=a.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Yr(s)}catch(i){qe(a,a.return,i)}}}function Xy(s,a){if(a.memoizedState===null&&(s=a.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Yr(s)}catch(i){qe(a,a.return,i)}}function hj(s){switch(s.tag){case 31:case 13:case 19:var a=s.stateNode;return a===null&&(a=s.stateNode=new Hy),a;case 22:return s=s.stateNode,a=s._retryCache,a===null&&(a=s._retryCache=new Hy),a;default:throw Error(r(435,s.tag))}}function rc(s,a){var i=hj(s);a.forEach(function(c){if(!i.has(c)){i.add(c);var h=wj.bind(null,s,c);c.then(h,h)}})}function Yt(s,a){var i=a.deletions;if(i!==null)for(var c=0;c<i.length;c++){var h=i[c],g=s,x=a,j=x;e:for(;j!==null;){switch(j.tag){case 27:if(Bn(j.type)){et=j.stateNode,Kt=!1;break e}break;case 5:et=j.stateNode,Kt=!1;break e;case 3:case 4:et=j.stateNode.containerInfo,Kt=!0;break e}j=j.return}if(et===null)throw Error(r(160));Ky(g,x,h),et=null,Kt=!1,g=h.alternate,g!==null&&(g.return=null),h.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Wy(a,s),a=a.sibling}var Ts=null;function Wy(s,a){var i=s.alternate,c=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:Yt(a,s),Xt(s),c&4&&(Dn(3,s,s.return),oo(3,s),Dn(5,s,s.return));break;case 1:Yt(a,s),Xt(s),c&512&&(pt||i===null||Vs(i,i.return)),c&64&&on&&(s=s.updateQueue,s!==null&&(c=s.callbacks,c!==null&&(i=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=i===null?c:i.concat(c))));break;case 26:var h=Ts;if(Yt(a,s),Xt(s),c&512&&(pt||i===null||Vs(i,i.return)),c&4){var g=i!==null?i.memoizedState:null;if(c=s.memoizedState,i===null)if(c===null)if(s.stateNode===null){e:{c=s.type,i=s.memoizedProps,h=h.ownerDocument||h;t:switch(c){case"title":g=h.getElementsByTagName("title")[0],(!g||g[pa]||g[I]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=h.createElement(c),h.head.insertBefore(g,h.querySelector("head > title"))),Ot(g,c,i),g[I]=s,jt(g),c=g;break e;case"link":var x=Wv("link","href",h).get(c+(i.href||""));if(x){for(var j=0;j<x.length;j++)if(g=x[j],g.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&g.getAttribute("rel")===(i.rel==null?null:i.rel)&&g.getAttribute("title")===(i.title==null?null:i.title)&&g.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){x.splice(j,1);break t}}g=h.createElement(c),Ot(g,c,i),h.head.appendChild(g);break;case"meta":if(x=Wv("meta","content",h).get(c+(i.content||""))){for(j=0;j<x.length;j++)if(g=x[j],g.getAttribute("content")===(i.content==null?null:""+i.content)&&g.getAttribute("name")===(i.name==null?null:i.name)&&g.getAttribute("property")===(i.property==null?null:i.property)&&g.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&g.getAttribute("charset")===(i.charSet==null?null:i.charSet)){x.splice(j,1);break t}}g=h.createElement(c),Ot(g,c,i),h.head.appendChild(g);break;default:throw Error(r(468,c))}g[I]=s,jt(g),c=g}s.stateNode=c}else Jv(h,s.type,s.stateNode);else s.stateNode=Xv(h,c,s.memoizedProps);else g!==c?(g===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):g.count--,c===null?Jv(h,s.type,s.stateNode):Xv(h,c,s.memoizedProps)):c===null&&s.stateNode!==null&&ih(s,s.memoizedProps,i.memoizedProps)}break;case 27:Yt(a,s),Xt(s),c&512&&(pt||i===null||Vs(i,i.return)),i!==null&&c&4&&ih(s,s.memoizedProps,i.memoizedProps);break;case 5:if(Yt(a,s),Xt(s),c&512&&(pt||i===null||Vs(i,i.return)),s.flags&32){h=s.stateNode;try{yr(h,"")}catch(oe){qe(s,s.return,oe)}}c&4&&s.stateNode!=null&&(h=s.memoizedProps,ih(s,h,i!==null?i.memoizedProps:h)),c&1024&&(ch=!0);break;case 6:if(Yt(a,s),Xt(s),c&4){if(s.stateNode===null)throw Error(r(162));c=s.memoizedProps,i=s.stateNode;try{i.nodeValue=c}catch(oe){qe(s,s.return,oe)}}break;case 3:if(wc=null,h=Ts,Ts=xc(a.containerInfo),Yt(a,s),Ts=h,Xt(s),c&4&&i!==null&&i.memoizedState.isDehydrated)try{Yr(a.containerInfo)}catch(oe){qe(s,s.return,oe)}ch&&(ch=!1,Jy(s));break;case 4:c=Ts,Ts=xc(s.stateNode.containerInfo),Yt(a,s),Xt(s),Ts=c;break;case 12:Yt(a,s),Xt(s);break;case 31:Yt(a,s),Xt(s),c&4&&(c=s.updateQueue,c!==null&&(s.updateQueue=null,rc(s,c)));break;case 13:Yt(a,s),Xt(s),s.child.flags&8192&&s.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(oc=Tt()),c&4&&(c=s.updateQueue,c!==null&&(s.updateQueue=null,rc(s,c)));break;case 22:h=s.memoizedState!==null;var k=i!==null&&i.memoizedState!==null,V=on,K=pt;if(on=V||h,pt=K||k,Yt(a,s),pt=K,on=V,Xt(s),c&8192)e:for(a=s.stateNode,a._visibility=h?a._visibility&-2:a._visibility|1,h&&(i===null||k||on||pt||Ra(s)),i=null,a=s;;){if(a.tag===5||a.tag===26){if(i===null){k=i=a;try{if(g=k.stateNode,h)x=g.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none";else{j=k.stateNode;var W=k.memoizedProps.style,$=W!=null&&W.hasOwnProperty("display")?W.display:null;j.style.display=$==null||typeof $=="boolean"?"":(""+$).trim()}}catch(oe){qe(k,k.return,oe)}}}else if(a.tag===6){if(i===null){k=a;try{k.stateNode.nodeValue=h?"":k.memoizedProps}catch(oe){qe(k,k.return,oe)}}}else if(a.tag===18){if(i===null){k=a;try{var F=k.stateNode;h?Bv(F,!0):Bv(k.stateNode,!1)}catch(oe){qe(k,k.return,oe)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===s)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break e;for(;a.sibling===null;){if(a.return===null||a.return===s)break e;i===a&&(i=null),a=a.return}i===a&&(i=null),a.sibling.return=a.return,a=a.sibling}c&4&&(c=s.updateQueue,c!==null&&(i=c.retryQueue,i!==null&&(c.retryQueue=null,rc(s,i))));break;case 19:Yt(a,s),Xt(s),c&4&&(c=s.updateQueue,c!==null&&(s.updateQueue=null,rc(s,c)));break;case 30:break;case 21:break;default:Yt(a,s),Xt(s)}}function Xt(s){var a=s.flags;if(a&2){try{for(var i,c=s.return;c!==null;){if($y(c)){i=c;break}c=c.return}if(i==null)throw Error(r(160));switch(i.tag){case 27:var h=i.stateNode,g=oh(s);ac(s,g,h);break;case 5:var x=i.stateNode;i.flags&32&&(yr(x,""),i.flags&=-33);var j=oh(s);ac(s,j,x);break;case 3:case 4:var k=i.stateNode.containerInfo,V=oh(s);lh(s,V,k);break;default:throw Error(r(161))}}catch(K){qe(s,s.return,K)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function Jy(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var a=s;Jy(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),s=s.sibling}}function cn(s,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Gy(s,a.alternate,a),a=a.sibling}function Ra(s){for(s=s.child;s!==null;){var a=s;switch(a.tag){case 0:case 11:case 14:case 15:Dn(4,a,a.return),Ra(a);break;case 1:Vs(a,a.return);var i=a.stateNode;typeof i.componentWillUnmount=="function"&&By(a,a.return,i),Ra(a);break;case 27:vo(a.stateNode);case 26:case 5:Vs(a,a.return),Ra(a);break;case 22:a.memoizedState===null&&Ra(a);break;case 30:Ra(a);break;default:Ra(a)}s=s.sibling}}function un(s,a,i){for(i=i&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var c=a.alternate,h=s,g=a,x=g.flags;switch(g.tag){case 0:case 11:case 15:un(h,g,i),oo(4,g);break;case 1:if(un(h,g,i),c=g,h=c.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(V){qe(c,c.return,V)}if(c=g,h=c.updateQueue,h!==null){var j=c.stateNode;try{var k=h.shared.hiddenCallbacks;if(k!==null)for(h.shared.hiddenCallbacks=null,h=0;h<k.length;h++)Ag(k[h],j)}catch(V){qe(c,c.return,V)}}i&&x&64&&Vy(g),lo(g,g.return);break;case 27:qy(g);case 26:case 5:un(h,g,i),i&&c===null&&x&4&&Iy(g),lo(g,g.return);break;case 12:un(h,g,i);break;case 31:un(h,g,i),i&&x&4&&Yy(h,g);break;case 13:un(h,g,i),i&&x&4&&Xy(h,g);break;case 22:g.memoizedState===null&&un(h,g,i),lo(g,g.return);break;case 30:break;default:un(h,g,i)}a=a.sibling}}function uh(s,a){var i=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),s=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(s=a.memoizedState.cachePool.pool),s!==i&&(s!=null&&s.refCount++,i!=null&&Yi(i))}function dh(s,a){s=null,a.alternate!==null&&(s=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==s&&(a.refCount++,s!=null&&Yi(s))}function As(s,a,i,c){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Qy(s,a,i,c),a=a.sibling}function Qy(s,a,i,c){var h=a.flags;switch(a.tag){case 0:case 11:case 15:As(s,a,i,c),h&2048&&oo(9,a);break;case 1:As(s,a,i,c);break;case 3:As(s,a,i,c),h&2048&&(s=null,a.alternate!==null&&(s=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==s&&(a.refCount++,s!=null&&Yi(s)));break;case 12:if(h&2048){As(s,a,i,c),s=a.stateNode;try{var g=a.memoizedProps,x=g.id,j=g.onPostCommit;typeof j=="function"&&j(x,a.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(k){qe(a,a.return,k)}}else As(s,a,i,c);break;case 31:As(s,a,i,c);break;case 13:As(s,a,i,c);break;case 23:break;case 22:g=a.stateNode,x=a.alternate,a.memoizedState!==null?g._visibility&2?As(s,a,i,c):co(s,a):g._visibility&2?As(s,a,i,c):(g._visibility|=2,Ur(s,a,i,c,(a.subtreeFlags&10256)!==0||!1)),h&2048&&uh(x,a);break;case 24:As(s,a,i,c),h&2048&&dh(a.alternate,a);break;default:As(s,a,i,c)}}function Ur(s,a,i,c,h){for(h=h&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var g=s,x=a,j=i,k=c,V=x.flags;switch(x.tag){case 0:case 11:case 15:Ur(g,x,j,k,h),oo(8,x);break;case 23:break;case 22:var K=x.stateNode;x.memoizedState!==null?K._visibility&2?Ur(g,x,j,k,h):co(g,x):(K._visibility|=2,Ur(g,x,j,k,h)),h&&V&2048&&uh(x.alternate,x);break;case 24:Ur(g,x,j,k,h),h&&V&2048&&dh(x.alternate,x);break;default:Ur(g,x,j,k,h)}a=a.sibling}}function co(s,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var i=s,c=a,h=c.flags;switch(c.tag){case 22:co(i,c),h&2048&&uh(c.alternate,c);break;case 24:co(i,c),h&2048&&dh(c.alternate,c);break;default:co(i,c)}a=a.sibling}}var uo=8192;function Pr(s,a,i){if(s.subtreeFlags&uo)for(s=s.child;s!==null;)Zy(s,a,i),s=s.sibling}function Zy(s,a,i){switch(s.tag){case 26:Pr(s,a,i),s.flags&uo&&s.memoizedState!==null&&Qj(i,Ts,s.memoizedState,s.memoizedProps);break;case 5:Pr(s,a,i);break;case 3:case 4:var c=Ts;Ts=xc(s.stateNode.containerInfo),Pr(s,a,i),Ts=c;break;case 22:s.memoizedState===null&&(c=s.alternate,c!==null&&c.memoizedState!==null?(c=uo,uo=16777216,Pr(s,a,i),uo=c):Pr(s,a,i));break;default:Pr(s,a,i)}}function ev(s){var a=s.alternate;if(a!==null&&(s=a.child,s!==null)){a.child=null;do a=s.sibling,s.sibling=null,s=a;while(s!==null)}}function ho(s){var a=s.deletions;if((s.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var c=a[i];Nt=c,sv(c,s)}ev(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)tv(s),s=s.sibling}function tv(s){switch(s.tag){case 0:case 11:case 15:ho(s),s.flags&2048&&Dn(9,s,s.return);break;case 3:ho(s);break;case 12:ho(s);break;case 22:var a=s.stateNode;s.memoizedState!==null&&a._visibility&2&&(s.return===null||s.return.tag!==13)?(a._visibility&=-3,ic(s)):ho(s);break;default:ho(s)}}function ic(s){var a=s.deletions;if((s.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var c=a[i];Nt=c,sv(c,s)}ev(s)}for(s=s.child;s!==null;){switch(a=s,a.tag){case 0:case 11:case 15:Dn(8,a,a.return),ic(a);break;case 22:i=a.stateNode,i._visibility&2&&(i._visibility&=-3,ic(a));break;default:ic(a)}s=s.sibling}}function sv(s,a){for(;Nt!==null;){var i=Nt;switch(i.tag){case 0:case 11:case 15:Dn(8,i,a);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var c=i.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:Yi(i.memoizedState.cache)}if(c=i.child,c!==null)c.return=i,Nt=c;else e:for(i=s;Nt!==null;){c=Nt;var h=c.sibling,g=c.return;if(Fy(c),c===i){Nt=null;break e}if(h!==null){h.return=g,Nt=h;break e}Nt=g}}}var fj={getCacheForType:function(s){var a=Ct(ht),i=a.data.get(s);return i===void 0&&(i=s(),a.data.set(s,i)),i},cacheSignal:function(){return Ct(ht).controller.signal}},mj=typeof WeakMap=="function"?WeakMap:Map,Be=0,Ke=null,Ce=null,De=0,$e=0,ss=null,Mn=!1,Vr=!1,hh=!1,dn=0,at=0,zn=0,Oa=0,fh=0,ns=0,Br=0,fo=null,Wt=null,mh=!1,oc=0,nv=0,lc=1/0,cc=null,Ln=null,xt=0,Un=null,Ir=null,hn=0,ph=0,gh=null,av=null,mo=0,yh=null;function as(){return(Be&2)!==0&&De!==0?De&-De:C.T!==null?_h():yl()}function rv(){if(ns===0)if((De&536870912)===0||ze){var s=Ri;Ri<<=1,(Ri&3932160)===0&&(Ri=262144),ns=s}else ns=536870912;return s=es.current,s!==null&&(s.flags|=32),ns}function Jt(s,a,i){(s===Ke&&($e===2||$e===9)||s.cancelPendingCommit!==null)&&($r(s,0),Pn(s,De,ns,!1)),fa(s,i),((Be&2)===0||s!==Ke)&&(s===Ke&&((Be&2)===0&&(Oa|=i),at===4&&Pn(s,De,ns,!1)),Bs(s))}function iv(s,a,i){if((Be&6)!==0)throw Error(r(327));var c=!i&&(a&127)===0&&(a&s.expiredLanes)===0||ha(s,a),h=c?yj(s,a):xh(s,a,!0),g=c;do{if(h===0){Vr&&!c&&Pn(s,a,0,!1);break}else{if(i=s.current.alternate,g&&!pj(i)){h=xh(s,a,!1),g=!1;continue}if(h===2){if(g=a,s.errorRecoveryDisabledLanes&g)var x=0;else x=s.pendingLanes&-536870913,x=x!==0?x:x&536870912?536870912:0;if(x!==0){a=x;e:{var j=s;h=fo;var k=j.current.memoizedState.isDehydrated;if(k&&($r(j,x).flags|=256),x=xh(j,x,!1),x!==2){if(hh&&!k){j.errorRecoveryDisabledLanes|=g,Oa|=g,h=4;break e}g=Wt,Wt=h,g!==null&&(Wt===null?Wt=g:Wt.push.apply(Wt,g))}h=x}if(g=!1,h!==2)continue}}if(h===1){$r(s,0),Pn(s,a,0,!0);break}e:{switch(c=s,g=h,g){case 0:case 1:throw Error(r(345));case 4:if((a&4194048)!==a)break;case 6:Pn(c,a,ns,!Mn);break e;case 2:Wt=null;break;case 3:case 5:break;default:throw Error(r(329))}if((a&62914560)===a&&(h=oc+300-Tt(),10<h)){if(Pn(c,a,ns,!Mn),da(c,0,!0)!==0)break e;hn=a,c.timeoutHandle=Uv(ov.bind(null,c,i,Wt,cc,mh,a,ns,Oa,Br,Mn,g,"Throttled",-0,0),h);break e}ov(c,i,Wt,cc,mh,a,ns,Oa,Br,Mn,g,null,-0,0)}}break}while(!0);Bs(s)}function ov(s,a,i,c,h,g,x,j,k,V,K,W,$,F){if(s.timeoutHandle=-1,W=a.subtreeFlags,W&8192||(W&16785408)===16785408){W={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ws},Zy(a,g,W);var oe=(g&62914560)===g?oc-Tt():(g&4194048)===g?nv-Tt():0;if(oe=Zj(W,oe),oe!==null){hn=g,s.cancelPendingCommit=oe(pv.bind(null,s,a,g,i,c,h,x,j,k,K,W,null,$,F)),Pn(s,g,x,!V);return}}pv(s,a,g,i,c,h,x,j,k)}function pj(s){for(var a=s;;){var i=a.tag;if((i===0||i===11||i===15)&&a.flags&16384&&(i=a.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var c=0;c<i.length;c++){var h=i[c],g=h.getSnapshot;h=h.value;try{if(!Qt(g(),h))return!1}catch{return!1}}if(i=a.child,a.subtreeFlags&16384&&i!==null)i.return=a,a=i;else{if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Pn(s,a,i,c){a&=~fh,a&=~Oa,s.suspendedLanes|=a,s.pingedLanes&=~a,c&&(s.warmLanes|=a),c=s.expirationTimes;for(var h=a;0<h;){var g=31-vt(h),x=1<<g;c[g]=-1,h&=~x}i!==0&&ml(s,i,a)}function uc(){return(Be&6)===0?(po(0),!1):!0}function vh(){if(Ce!==null){if($e===0)var s=Ce.return;else s=Ce,en=_a=null,Md(s),Or=null,Wi=0,s=Ce;for(;s!==null;)Py(s.alternate,s),s=s.return;Ce=null}}function $r(s,a){var i=s.timeoutHandle;i!==-1&&(s.timeoutHandle=-1,zj(i)),i=s.cancelPendingCommit,i!==null&&(s.cancelPendingCommit=null,i()),hn=0,vh(),Ke=s,Ce=i=Qs(s.current,null),De=a,$e=0,ss=null,Mn=!1,Vr=ha(s,a),hh=!1,Br=ns=fh=Oa=zn=at=0,Wt=fo=null,mh=!1,(a&8)!==0&&(a|=a&32);var c=s.entangledLanes;if(c!==0)for(s=s.entanglements,c&=a;0<c;){var h=31-vt(c),g=1<<h;a|=s[h],c&=~g}return dn=a,Rl(),i}function lv(s,a){Ne=null,C.H=ao,a===Rr||a===Vl?(a=jg(),$e=3):a===Sd?(a=jg(),$e=4):$e=a===Wd?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,ss=a,Ce===null&&(at=1,Zl(s,hs(a,s.current)))}function cv(){var s=es.current;return s===null?!0:(De&4194048)===De?gs===null:(De&62914560)===De||(De&536870912)!==0?s===gs:!1}function uv(){var s=C.H;return C.H=ao,s===null?ao:s}function dv(){var s=C.A;return C.A=fj,s}function dc(){at=4,Mn||(De&4194048)!==De&&es.current!==null||(Vr=!0),(zn&134217727)===0&&(Oa&134217727)===0||Ke===null||Pn(Ke,De,ns,!1)}function xh(s,a,i){var c=Be;Be|=2;var h=uv(),g=dv();(Ke!==s||De!==a)&&(cc=null,$r(s,a)),a=!1;var x=at;e:do try{if($e!==0&&Ce!==null){var j=Ce,k=ss;switch($e){case 8:vh(),x=6;break e;case 3:case 2:case 9:case 6:es.current===null&&(a=!0);var V=$e;if($e=0,ss=null,qr(s,j,k,V),i&&Vr){x=0;break e}break;default:V=$e,$e=0,ss=null,qr(s,j,k,V)}}gj(),x=at;break}catch(K){lv(s,K)}while(!0);return a&&s.shellSuspendCounter++,en=_a=null,Be=c,C.H=h,C.A=g,Ce===null&&(Ke=null,De=0,Rl()),x}function gj(){for(;Ce!==null;)hv(Ce)}function yj(s,a){var i=Be;Be|=2;var c=uv(),h=dv();Ke!==s||De!==a?(cc=null,lc=Tt()+500,$r(s,a)):Vr=ha(s,a);e:do try{if($e!==0&&Ce!==null){a=Ce;var g=ss;t:switch($e){case 1:$e=0,ss=null,qr(s,a,g,1);break;case 2:case 9:if(Sg(g)){$e=0,ss=null,fv(a);break}a=function(){$e!==2&&$e!==9||Ke!==s||($e=7),Bs(s)},g.then(a,a);break e;case 3:$e=7;break e;case 4:$e=5;break e;case 7:Sg(g)?($e=0,ss=null,fv(a)):($e=0,ss=null,qr(s,a,g,7));break;case 5:var x=null;switch(Ce.tag){case 26:x=Ce.memoizedState;case 5:case 27:var j=Ce;if(x?Qv(x):j.stateNode.complete){$e=0,ss=null;var k=j.sibling;if(k!==null)Ce=k;else{var V=j.return;V!==null?(Ce=V,hc(V)):Ce=null}break t}}$e=0,ss=null,qr(s,a,g,5);break;case 6:$e=0,ss=null,qr(s,a,g,6);break;case 8:vh(),at=6;break e;default:throw Error(r(462))}}vj();break}catch(K){lv(s,K)}while(!0);return en=_a=null,C.H=c,C.A=h,Be=i,Ce!==null?0:(Ke=null,De=0,Rl(),at)}function vj(){for(;Ce!==null&&!ll();)hv(Ce)}function hv(s){var a=Ly(s.alternate,s,dn);s.memoizedProps=s.pendingProps,a===null?hc(s):Ce=a}function fv(s){var a=s,i=a.alternate;switch(a.tag){case 15:case 0:a=Cy(i,a,a.pendingProps,a.type,void 0,De);break;case 11:a=Cy(i,a,a.pendingProps,a.type.render,a.ref,De);break;case 5:Md(a);default:Py(i,a),a=Ce=dg(a,dn),a=Ly(i,a,dn)}s.memoizedProps=s.pendingProps,a===null?hc(s):Ce=a}function qr(s,a,i,c){en=_a=null,Md(a),Or=null,Wi=0;var h=a.return;try{if(ij(s,h,a,i,De)){at=1,Zl(s,hs(i,s.current)),Ce=null;return}}catch(g){if(h!==null)throw Ce=h,g;at=1,Zl(s,hs(i,s.current)),Ce=null;return}a.flags&32768?(ze||c===1?s=!0:Vr||(De&536870912)!==0?s=!1:(Mn=s=!0,(c===2||c===9||c===3||c===6)&&(c=es.current,c!==null&&c.tag===13&&(c.flags|=16384))),mv(a,s)):hc(a)}function hc(s){var a=s;do{if((a.flags&32768)!==0){mv(a,Mn);return}s=a.return;var i=cj(a.alternate,a,dn);if(i!==null){Ce=i;return}if(a=a.sibling,a!==null){Ce=a;return}Ce=a=s}while(a!==null);at===0&&(at=5)}function mv(s,a){do{var i=uj(s.alternate,s);if(i!==null){i.flags&=32767,Ce=i;return}if(i=s.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!a&&(s=s.sibling,s!==null)){Ce=s;return}Ce=s=i}while(s!==null);at=6,Ce=null}function pv(s,a,i,c,h,g,x,j,k){s.cancelPendingCommit=null;do fc();while(xt!==0);if((Be&6)!==0)throw Error(r(327));if(a!==null){if(a===s.current)throw Error(r(177));if(g=a.lanes|a.childLanes,g|=od,Pu(s,i,g,x,j,k),s===Ke&&(Ce=Ke=null,De=0),Ir=a,Un=s,hn=i,ph=g,gh=h,av=c,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,Sj(ua,function(){return bv(),null})):(s.callbackNode=null,s.callbackPriority=0),c=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||c){c=C.T,C.T=null,h=q.p,q.p=2,x=Be,Be|=4;try{dj(s,a,i)}finally{Be=x,q.p=h,C.T=c}}xt=1,gv(),yv(),vv()}}function gv(){if(xt===1){xt=0;var s=Un,a=Ir,i=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||i){i=C.T,C.T=null;var c=q.p;q.p=2;var h=Be;Be|=4;try{Wy(a,s);var g=Rh,x=sg(s.containerInfo),j=g.focusedElem,k=g.selectionRange;if(x!==j&&j&&j.ownerDocument&&tg(j.ownerDocument.documentElement,j)){if(k!==null&&sd(j)){var V=k.start,K=k.end;if(K===void 0&&(K=V),"selectionStart"in j)j.selectionStart=V,j.selectionEnd=Math.min(K,j.value.length);else{var W=j.ownerDocument||document,$=W&&W.defaultView||window;if($.getSelection){var F=$.getSelection(),oe=j.textContent.length,ye=Math.min(k.start,oe),Fe=k.end===void 0?ye:Math.min(k.end,oe);!F.extend&&ye>Fe&&(x=Fe,Fe=ye,ye=x);var L=eg(j,ye),O=eg(j,Fe);if(L&&O&&(F.rangeCount!==1||F.anchorNode!==L.node||F.anchorOffset!==L.offset||F.focusNode!==O.node||F.focusOffset!==O.offset)){var P=W.createRange();P.setStart(L.node,L.offset),F.removeAllRanges(),ye>Fe?(F.addRange(P),F.extend(O.node,O.offset)):(P.setEnd(O.node,O.offset),F.addRange(P))}}}}for(W=[],F=j;F=F.parentNode;)F.nodeType===1&&W.push({element:F,left:F.scrollLeft,top:F.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<W.length;j++){var X=W[j];X.element.scrollLeft=X.left,X.element.scrollTop=X.top}}Nc=!!Ch,Rh=Ch=null}finally{Be=h,q.p=c,C.T=i}}s.current=a,xt=2}}function yv(){if(xt===2){xt=0;var s=Un,a=Ir,i=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||i){i=C.T,C.T=null;var c=q.p;q.p=2;var h=Be;Be|=4;try{Gy(s,a.alternate,a)}finally{Be=h,q.p=c,C.T=i}}xt=3}}function vv(){if(xt===4||xt===3){xt=0,cl();var s=Un,a=Ir,i=hn,c=av;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?xt=5:(xt=0,Ir=Un=null,xv(s,s.pendingLanes));var h=s.pendingLanes;if(h===0&&(Ln=null),dr(i),a=a.stateNode,At&&typeof At.onCommitFiberRoot=="function")try{At.onCommitFiberRoot(Sn,a,void 0,(a.current.flags&128)===128)}catch{}if(c!==null){a=C.T,h=q.p,q.p=2,C.T=null;try{for(var g=s.onRecoverableError,x=0;x<c.length;x++){var j=c[x];g(j.value,{componentStack:j.stack})}}finally{C.T=a,q.p=h}}(hn&3)!==0&&fc(),Bs(s),h=s.pendingLanes,(i&261930)!==0&&(h&42)!==0?s===yh?mo++:(mo=0,yh=s):mo=0,po(0)}}function xv(s,a){(s.pooledCacheLanes&=a)===0&&(a=s.pooledCache,a!=null&&(s.pooledCache=null,Yi(a)))}function fc(){return gv(),yv(),vv(),bv()}function bv(){if(xt!==5)return!1;var s=Un,a=ph;ph=0;var i=dr(hn),c=C.T,h=q.p;try{q.p=32>i?32:i,C.T=null,i=gh,gh=null;var g=Un,x=hn;if(xt=0,Ir=Un=null,hn=0,(Be&6)!==0)throw Error(r(331));var j=Be;if(Be|=4,tv(g.current),Qy(g,g.current,x,i),Be=j,po(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Sn,g)}catch{}return!0}finally{q.p=h,C.T=c,xv(s,a)}}function wv(s,a,i){a=hs(i,a),a=Xd(s.stateNode,a,2),s=Cn(s,a,2),s!==null&&(fa(s,2),Bs(s))}function qe(s,a,i){if(s.tag===3)wv(s,s,i);else for(;a!==null;){if(a.tag===3){wv(a,s,i);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ln===null||!Ln.has(c))){s=hs(i,s),i=Sy(2),c=Cn(a,i,2),c!==null&&(_y(i,c,a,s),fa(c,2),Bs(c));break}}a=a.return}}function bh(s,a,i){var c=s.pingCache;if(c===null){c=s.pingCache=new mj;var h=new Set;c.set(a,h)}else h=c.get(a),h===void 0&&(h=new Set,c.set(a,h));h.has(i)||(hh=!0,h.add(i),s=xj.bind(null,s,a,i),a.then(s,s))}function xj(s,a,i){var c=s.pingCache;c!==null&&c.delete(a),s.pingedLanes|=s.suspendedLanes&i,s.warmLanes&=~i,Ke===s&&(De&i)===i&&(at===4||at===3&&(De&62914560)===De&&300>Tt()-oc?(Be&2)===0&&$r(s,0):fh|=i,Br===De&&(Br=0)),Bs(s)}function Sv(s,a){a===0&&(a=fl()),s=ba(s,a),s!==null&&(fa(s,a),Bs(s))}function bj(s){var a=s.memoizedState,i=0;a!==null&&(i=a.retryLane),Sv(s,i)}function wj(s,a){var i=0;switch(s.tag){case 31:case 13:var c=s.stateNode,h=s.memoizedState;h!==null&&(i=h.retryLane);break;case 19:c=s.stateNode;break;case 22:c=s.stateNode._retryCache;break;default:throw Error(r(314))}c!==null&&c.delete(a),Sv(s,i)}function Sj(s,a){return ir(s,a)}var mc=null,Hr=null,wh=!1,pc=!1,Sh=!1,Vn=0;function Bs(s){s!==Hr&&s.next===null&&(Hr===null?mc=Hr=s:Hr=Hr.next=s),pc=!0,wh||(wh=!0,jj())}function po(s,a){if(!Sh&&pc){Sh=!0;do for(var i=!1,c=mc;c!==null;){if(s!==0){var h=c.pendingLanes;if(h===0)var g=0;else{var x=c.suspendedLanes,j=c.pingedLanes;g=(1<<31-vt(42|s)+1)-1,g&=h&~(x&~j),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(i=!0,Ev(c,g))}else g=De,g=da(c,c===Ke?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||ha(c,g)||(i=!0,Ev(c,g));c=c.next}while(i);Sh=!1}}function _j(){_v()}function _v(){pc=wh=!1;var s=0;Vn!==0&&Mj()&&(s=Vn);for(var a=Tt(),i=null,c=mc;c!==null;){var h=c.next,g=jv(c,a);g===0?(c.next=null,i===null?mc=h:i.next=h,h===null&&(Hr=i)):(i=c,(s!==0||(g&3)!==0)&&(pc=!0)),c=h}xt!==0&&xt!==5||po(s),Vn!==0&&(Vn=0)}function jv(s,a){for(var i=s.suspendedLanes,c=s.pingedLanes,h=s.expirationTimes,g=s.pendingLanes&-62914561;0<g;){var x=31-vt(g),j=1<<x,k=h[x];k===-1?((j&i)===0||(j&c)!==0)&&(h[x]=Uu(j,a)):k<=a&&(s.expiredLanes|=j),g&=~j}if(a=Ke,i=De,i=da(s,s===a?i:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),c=s.callbackNode,i===0||s===a&&($e===2||$e===9)||s.cancelPendingCommit!==null)return c!==null&&c!==null&&or(c),s.callbackNode=null,s.callbackPriority=0;if((i&3)===0||ha(s,i)){if(a=i&-i,a===s.callbackPriority)return a;switch(c!==null&&or(c),dr(i)){case 2:case 8:i=Ci;break;case 32:i=ua;break;case 268435456:i=ul;break;default:i=ua}return c=Nv.bind(null,s),i=ir(i,c),s.callbackPriority=a,s.callbackNode=i,a}return c!==null&&c!==null&&or(c),s.callbackPriority=2,s.callbackNode=null,2}function Nv(s,a){if(xt!==0&&xt!==5)return s.callbackNode=null,s.callbackPriority=0,null;var i=s.callbackNode;if(fc()&&s.callbackNode!==i)return null;var c=De;return c=da(s,s===Ke?c:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),c===0?null:(iv(s,c,a),jv(s,Tt()),s.callbackNode!=null&&s.callbackNode===i?Nv.bind(null,s):null)}function Ev(s,a){if(fc())return null;iv(s,a,!0)}function jj(){Lj(function(){(Be&6)!==0?ir(ki,_j):_v()})}function _h(){if(Vn===0){var s=kr;s===0&&(s=ur,ur<<=1,(ur&261888)===0&&(ur=256)),Vn=s}return Vn}function Tv(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:_l(""+s)}function Av(s,a){var i=a.ownerDocument.createElement("input");return i.name=a.name,i.value=a.value,s.id&&i.setAttribute("form",s.id),a.parentNode.insertBefore(i,a),s=new FormData(s),i.parentNode.removeChild(i),s}function Nj(s,a,i,c,h){if(a==="submit"&&i&&i.stateNode===h){var g=Tv((h[ne]||null).action),x=c.submitter;x&&(a=(a=x[ne]||null)?Tv(a.formAction):x.getAttribute("formAction"),a!==null&&(g=a,x=null));var j=new Tl("action","action",null,c,h);s.push({event:j,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Vn!==0){var k=x?Av(h,x):new FormData(h);qd(i,{pending:!0,data:k,method:h.method,action:g},null,k)}}else typeof g=="function"&&(j.preventDefault(),k=x?Av(h,x):new FormData(h),qd(i,{pending:!0,data:k,method:h.method,action:g},g,k))},currentTarget:h}]})}}for(var jh=0;jh<id.length;jh++){var Nh=id[jh],Ej=Nh.toLowerCase(),Tj=Nh[0].toUpperCase()+Nh.slice(1);Es(Ej,"on"+Tj)}Es(rg,"onAnimationEnd"),Es(ig,"onAnimationIteration"),Es(og,"onAnimationStart"),Es("dblclick","onDoubleClick"),Es("focusin","onFocus"),Es("focusout","onBlur"),Es(q_,"onTransitionRun"),Es(H_,"onTransitionStart"),Es(G_,"onTransitionCancel"),Es(lg,"onTransitionEnd"),pr("onMouseEnter",["mouseout","mouseover"]),pr("onMouseLeave",["mouseout","mouseover"]),pr("onPointerEnter",["pointerout","pointerover"]),pr("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var go="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(" "),Aj=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(go));function kv(s,a){a=(a&4)!==0;for(var i=0;i<s.length;i++){var c=s[i],h=c.event;c=c.listeners;e:{var g=void 0;if(a)for(var x=c.length-1;0<=x;x--){var j=c[x],k=j.instance,V=j.currentTarget;if(j=j.listener,k!==g&&h.isPropagationStopped())break e;g=j,h.currentTarget=V;try{g(h)}catch(K){Cl(K)}h.currentTarget=null,g=k}else for(x=0;x<c.length;x++){if(j=c[x],k=j.instance,V=j.currentTarget,j=j.listener,k!==g&&h.isPropagationStopped())break e;g=j,h.currentTarget=V;try{g(h)}catch(K){Cl(K)}h.currentTarget=null,g=k}}}}function Re(s,a){var i=a[Bt];i===void 0&&(i=a[Bt]=new Set);var c=s+"__bubble";i.has(c)||(Cv(a,s,2,!1),i.add(c))}function Eh(s,a,i){var c=0;a&&(c|=4),Cv(i,s,c,a)}var gc="_reactListening"+Math.random().toString(36).slice(2);function Th(s){if(!s[gc]){s[gc]=!0,_p.forEach(function(i){i!=="selectionchange"&&(Aj.has(i)||Eh(i,!1,s),Eh(i,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[gc]||(a[gc]=!0,Eh("selectionchange",!1,a))}}function Cv(s,a,i,c){switch(r0(a)){case 2:var h=sN;break;case 8:h=nN;break;default:h=$h}i=h.bind(null,a,i,s),h=void 0,!Ku||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(h=!0),c?h!==void 0?s.addEventListener(a,i,{capture:!0,passive:h}):s.addEventListener(a,i,!0):h!==void 0?s.addEventListener(a,i,{passive:h}):s.addEventListener(a,i,!1)}function Ah(s,a,i,c,h){var g=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var x=c.tag;if(x===3||x===4){var j=c.stateNode.containerInfo;if(j===h)break;if(x===4)for(x=c.return;x!==null;){var k=x.tag;if((k===3||k===4)&&x.stateNode.containerInfo===h)return;x=x.return}for(;j!==null;){if(x=hr(j),x===null)return;if(k=x.tag,k===5||k===6||k===26||k===27){c=g=x;continue e}j=j.parentNode}}c=c.return}zp(function(){var V=g,K=Gu(i),W=[];e:{var $=cg.get(s);if($!==void 0){var F=Tl,oe=s;switch(s){case"keypress":if(Nl(i)===0)break e;case"keydown":case"keyup":F=w_;break;case"focusin":oe="focus",F=Ju;break;case"focusout":oe="blur",F=Ju;break;case"beforeblur":case"afterblur":F=Ju;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":F=Pp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":F=c_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":F=j_;break;case rg:case ig:case og:F=h_;break;case lg:F=E_;break;case"scroll":case"scrollend":F=o_;break;case"wheel":F=A_;break;case"copy":case"cut":case"paste":F=m_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":F=Bp;break;case"toggle":case"beforetoggle":F=C_}var ye=(a&4)!==0,Fe=!ye&&(s==="scroll"||s==="scrollend"),L=ye?$!==null?$+"Capture":null:$;ye=[];for(var O=V,P;O!==null;){var X=O;if(P=X.stateNode,X=X.tag,X!==5&&X!==26&&X!==27||P===null||L===null||(X=Ui(O,L),X!=null&&ye.push(yo(O,X,P))),Fe)break;O=O.return}0<ye.length&&($=new F($,oe,null,i,K),W.push({event:$,listeners:ye}))}}if((a&7)===0){e:{if($=s==="mouseover"||s==="pointerover",F=s==="mouseout"||s==="pointerout",$&&i!==Hu&&(oe=i.relatedTarget||i.fromElement)&&(hr(oe)||oe[Ae]))break e;if((F||$)&&($=K.window===K?K:($=K.ownerDocument)?$.defaultView||$.parentWindow:window,F?(oe=i.relatedTarget||i.toElement,F=V,oe=oe?hr(oe):null,oe!==null&&(Fe=u(oe),ye=oe.tag,oe!==Fe||ye!==5&&ye!==27&&ye!==6)&&(oe=null)):(F=null,oe=V),F!==oe)){if(ye=Pp,X="onMouseLeave",L="onMouseEnter",O="mouse",(s==="pointerout"||s==="pointerover")&&(ye=Bp,X="onPointerLeave",L="onPointerEnter",O="pointer"),Fe=F==null?$:Li(F),P=oe==null?$:Li(oe),$=new ye(X,O+"leave",F,i,K),$.target=Fe,$.relatedTarget=P,X=null,hr(K)===V&&(ye=new ye(L,O+"enter",oe,i,K),ye.target=P,ye.relatedTarget=Fe,X=ye),Fe=X,F&&oe)t:{for(ye=kj,L=F,O=oe,P=0,X=L;X;X=ye(X))P++;X=0;for(var me=O;me;me=ye(me))X++;for(;0<P-X;)L=ye(L),P--;for(;0<X-P;)O=ye(O),X--;for(;P--;){if(L===O||O!==null&&L===O.alternate){ye=L;break t}L=ye(L),O=ye(O)}ye=null}else ye=null;F!==null&&Rv(W,$,F,ye,!1),oe!==null&&Fe!==null&&Rv(W,Fe,oe,ye,!0)}}e:{if($=V?Li(V):window,F=$.nodeName&&$.nodeName.toLowerCase(),F==="select"||F==="input"&&$.type==="file")var Ue=Yp;else if(Fp($))if(Xp)Ue=B_;else{Ue=P_;var he=U_}else F=$.nodeName,!F||F.toLowerCase()!=="input"||$.type!=="checkbox"&&$.type!=="radio"?V&&qu(V.elementType)&&(Ue=Yp):Ue=V_;if(Ue&&(Ue=Ue(s,V))){Kp(W,Ue,i,K);break e}he&&he(s,$,V),s==="focusout"&&V&&$.type==="number"&&V.memoizedProps.value!=null&&$u($,"number",$.value)}switch(he=V?Li(V):window,s){case"focusin":(Fp(he)||he.contentEditable==="true")&&(wr=he,nd=V,Gi=null);break;case"focusout":Gi=nd=wr=null;break;case"mousedown":ad=!0;break;case"contextmenu":case"mouseup":case"dragend":ad=!1,ng(W,i,K);break;case"selectionchange":if($_)break;case"keydown":case"keyup":ng(W,i,K)}var Te;if(Zu)e:{switch(s){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else br?Hp(s,i)&&(Me="onCompositionEnd"):s==="keydown"&&i.keyCode===229&&(Me="onCompositionStart");Me&&(Ip&&i.locale!=="ko"&&(br||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&br&&(Te=Lp()):(_n=K,Yu="value"in _n?_n.value:_n.textContent,br=!0)),he=yc(V,Me),0<he.length&&(Me=new Vp(Me,s,null,i,K),W.push({event:Me,listeners:he}),Te?Me.data=Te:(Te=Gp(i),Te!==null&&(Me.data=Te)))),(Te=O_?D_(s,i):M_(s,i))&&(Me=yc(V,"onBeforeInput"),0<Me.length&&(he=new Vp("onBeforeInput","beforeinput",null,i,K),W.push({event:he,listeners:Me}),he.data=Te)),Nj(W,s,V,i,K)}kv(W,a)})}function yo(s,a,i){return{instance:s,listener:a,currentTarget:i}}function yc(s,a){for(var i=a+"Capture",c=[];s!==null;){var h=s,g=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||g===null||(h=Ui(s,i),h!=null&&c.unshift(yo(s,h,g)),h=Ui(s,a),h!=null&&c.push(yo(s,h,g))),s.tag===3)return c;s=s.return}return[]}function kj(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function Rv(s,a,i,c,h){for(var g=a._reactName,x=[];i!==null&&i!==c;){var j=i,k=j.alternate,V=j.stateNode;if(j=j.tag,k!==null&&k===c)break;j!==5&&j!==26&&j!==27||V===null||(k=V,h?(V=Ui(i,g),V!=null&&x.unshift(yo(i,V,k))):h||(V=Ui(i,g),V!=null&&x.push(yo(i,V,k)))),i=i.return}x.length!==0&&s.push({event:a,listeners:x})}var Cj=/\r\n?/g,Rj=/\u0000|\uFFFD/g;function Ov(s){return(typeof s=="string"?s:""+s).replace(Cj,`
|
|
9
|
+
`).replace(Rj,"")}function Dv(s,a){return a=Ov(a),Ov(s)===a}function Ge(s,a,i,c,h,g){switch(i){case"children":typeof c=="string"?a==="body"||a==="textarea"&&c===""||yr(s,c):(typeof c=="number"||typeof c=="bigint")&&a!=="body"&&yr(s,""+c);break;case"className":wl(s,"class",c);break;case"tabIndex":wl(s,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":wl(s,i,c);break;case"style":Dp(s,c,g);break;case"data":if(a!=="object"){wl(s,"data",c);break}case"src":case"href":if(c===""&&(a!=="a"||i!=="href")){s.removeAttribute(i);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){s.removeAttribute(i);break}c=_l(""+c),s.setAttribute(i,c);break;case"action":case"formAction":if(typeof c=="function"){s.setAttribute(i,"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 g=="function"&&(i==="formAction"?(a!=="input"&&Ge(s,a,"name",h.name,h,null),Ge(s,a,"formEncType",h.formEncType,h,null),Ge(s,a,"formMethod",h.formMethod,h,null),Ge(s,a,"formTarget",h.formTarget,h,null)):(Ge(s,a,"encType",h.encType,h,null),Ge(s,a,"method",h.method,h,null),Ge(s,a,"target",h.target,h,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){s.removeAttribute(i);break}c=_l(""+c),s.setAttribute(i,c);break;case"onClick":c!=null&&(s.onclick=Ws);break;case"onScroll":c!=null&&Re("scroll",s);break;case"onScrollEnd":c!=null&&Re("scrollend",s);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(i=c.__html,i!=null){if(h.children!=null)throw Error(r(60));s.innerHTML=i}}break;case"multiple":s.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":s.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){s.removeAttribute("xlink:href");break}i=_l(""+c),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?s.setAttribute(i,""+c):s.removeAttribute(i);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":c&&typeof c!="function"&&typeof c!="symbol"?s.setAttribute(i,""):s.removeAttribute(i);break;case"capture":case"download":c===!0?s.setAttribute(i,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?s.setAttribute(i,c):s.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?s.setAttribute(i,c):s.removeAttribute(i);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?s.removeAttribute(i):s.setAttribute(i,c);break;case"popover":Re("beforetoggle",s),Re("toggle",s),bl(s,"popover",c);break;case"xlinkActuate":Xs(s,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Xs(s,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Xs(s,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Xs(s,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Xs(s,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Xs(s,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Xs(s,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Xs(s,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Xs(s,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":bl(s,"is",c);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=r_.get(i)||i,bl(s,i,c))}}function kh(s,a,i,c,h,g){switch(i){case"style":Dp(s,c,g);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(i=c.__html,i!=null){if(h.children!=null)throw Error(r(60));s.innerHTML=i}}break;case"children":typeof c=="string"?yr(s,c):(typeof c=="number"||typeof c=="bigint")&&yr(s,""+c);break;case"onScroll":c!=null&&Re("scroll",s);break;case"onScrollEnd":c!=null&&Re("scrollend",s);break;case"onClick":c!=null&&(s.onclick=Ws);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!jp.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(h=i.endsWith("Capture"),a=i.slice(2,h?i.length-7:void 0),g=s[ne]||null,g=g!=null?g[i]:null,typeof g=="function"&&s.removeEventListener(a,g,h),typeof c=="function")){typeof g!="function"&&g!==null&&(i in s?s[i]=null:s.hasAttribute(i)&&s.removeAttribute(i)),s.addEventListener(a,c,h);break e}i in s?s[i]=c:c===!0?s.setAttribute(i,""):bl(s,i,c)}}}function Ot(s,a,i){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Re("error",s),Re("load",s);var c=!1,h=!1,g;for(g in i)if(i.hasOwnProperty(g)){var x=i[g];if(x!=null)switch(g){case"src":c=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:Ge(s,a,g,x,i,null)}}h&&Ge(s,a,"srcSet",i.srcSet,i,null),c&&Ge(s,a,"src",i.src,i,null);return;case"input":Re("invalid",s);var j=g=x=h=null,k=null,V=null;for(c in i)if(i.hasOwnProperty(c)){var K=i[c];if(K!=null)switch(c){case"name":h=K;break;case"type":x=K;break;case"checked":k=K;break;case"defaultChecked":V=K;break;case"value":g=K;break;case"defaultValue":j=K;break;case"children":case"dangerouslySetInnerHTML":if(K!=null)throw Error(r(137,a));break;default:Ge(s,a,c,K,i,null)}}kp(s,g,j,k,V,x,h,!1);return;case"select":Re("invalid",s),c=x=g=null;for(h in i)if(i.hasOwnProperty(h)&&(j=i[h],j!=null))switch(h){case"value":g=j;break;case"defaultValue":x=j;break;case"multiple":c=j;default:Ge(s,a,h,j,i,null)}a=g,i=x,s.multiple=!!c,a!=null?gr(s,!!c,a,!1):i!=null&&gr(s,!!c,i,!0);return;case"textarea":Re("invalid",s),g=h=c=null;for(x in i)if(i.hasOwnProperty(x)&&(j=i[x],j!=null))switch(x){case"value":c=j;break;case"defaultValue":h=j;break;case"children":g=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:Ge(s,a,x,j,i,null)}Rp(s,c,h,g);return;case"option":for(k in i)i.hasOwnProperty(k)&&(c=i[k],c!=null)&&(k==="selected"?s.selected=c&&typeof c!="function"&&typeof c!="symbol":Ge(s,a,k,c,i,null));return;case"dialog":Re("beforetoggle",s),Re("toggle",s),Re("cancel",s),Re("close",s);break;case"iframe":case"object":Re("load",s);break;case"video":case"audio":for(c=0;c<go.length;c++)Re(go[c],s);break;case"image":Re("error",s),Re("load",s);break;case"details":Re("toggle",s);break;case"embed":case"source":case"link":Re("error",s),Re("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in i)if(i.hasOwnProperty(V)&&(c=i[V],c!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:Ge(s,a,V,c,i,null)}return;default:if(qu(a)){for(K in i)i.hasOwnProperty(K)&&(c=i[K],c!==void 0&&kh(s,a,K,c,i,void 0));return}}for(j in i)i.hasOwnProperty(j)&&(c=i[j],c!=null&&Ge(s,a,j,c,i,null))}function Oj(s,a,i,c){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,g=null,x=null,j=null,k=null,V=null,K=null;for(F in i){var W=i[F];if(i.hasOwnProperty(F)&&W!=null)switch(F){case"checked":break;case"value":break;case"defaultValue":k=W;default:c.hasOwnProperty(F)||Ge(s,a,F,null,c,W)}}for(var $ in c){var F=c[$];if(W=i[$],c.hasOwnProperty($)&&(F!=null||W!=null))switch($){case"type":g=F;break;case"name":h=F;break;case"checked":V=F;break;case"defaultChecked":K=F;break;case"value":x=F;break;case"defaultValue":j=F;break;case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(r(137,a));break;default:F!==W&&Ge(s,a,$,F,c,W)}}Iu(s,x,j,k,V,K,g,h);return;case"select":F=x=j=$=null;for(g in i)if(k=i[g],i.hasOwnProperty(g)&&k!=null)switch(g){case"value":break;case"multiple":F=k;default:c.hasOwnProperty(g)||Ge(s,a,g,null,c,k)}for(h in c)if(g=c[h],k=i[h],c.hasOwnProperty(h)&&(g!=null||k!=null))switch(h){case"value":$=g;break;case"defaultValue":j=g;break;case"multiple":x=g;default:g!==k&&Ge(s,a,h,g,c,k)}a=j,i=x,c=F,$!=null?gr(s,!!i,$,!1):!!c!=!!i&&(a!=null?gr(s,!!i,a,!0):gr(s,!!i,i?[]:"",!1));return;case"textarea":F=$=null;for(j in i)if(h=i[j],i.hasOwnProperty(j)&&h!=null&&!c.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:Ge(s,a,j,null,c,h)}for(x in c)if(h=c[x],g=i[x],c.hasOwnProperty(x)&&(h!=null||g!=null))switch(x){case"value":$=h;break;case"defaultValue":F=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(r(91));break;default:h!==g&&Ge(s,a,x,h,c,g)}Cp(s,$,F);return;case"option":for(var oe in i)$=i[oe],i.hasOwnProperty(oe)&&$!=null&&!c.hasOwnProperty(oe)&&(oe==="selected"?s.selected=!1:Ge(s,a,oe,null,c,$));for(k in c)$=c[k],F=i[k],c.hasOwnProperty(k)&&$!==F&&($!=null||F!=null)&&(k==="selected"?s.selected=$&&typeof $!="function"&&typeof $!="symbol":Ge(s,a,k,$,c,F));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 ye in i)$=i[ye],i.hasOwnProperty(ye)&&$!=null&&!c.hasOwnProperty(ye)&&Ge(s,a,ye,null,c,$);for(V in c)if($=c[V],F=i[V],c.hasOwnProperty(V)&&$!==F&&($!=null||F!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if($!=null)throw Error(r(137,a));break;default:Ge(s,a,V,$,c,F)}return;default:if(qu(a)){for(var Fe in i)$=i[Fe],i.hasOwnProperty(Fe)&&$!==void 0&&!c.hasOwnProperty(Fe)&&kh(s,a,Fe,void 0,c,$);for(K in c)$=c[K],F=i[K],!c.hasOwnProperty(K)||$===F||$===void 0&&F===void 0||kh(s,a,K,$,c,F);return}}for(var L in i)$=i[L],i.hasOwnProperty(L)&&$!=null&&!c.hasOwnProperty(L)&&Ge(s,a,L,null,c,$);for(W in c)$=c[W],F=i[W],!c.hasOwnProperty(W)||$===F||$==null&&F==null||Ge(s,a,W,$,c,F)}function Mv(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Dj(){if(typeof performance.getEntriesByType=="function"){for(var s=0,a=0,i=performance.getEntriesByType("resource"),c=0;c<i.length;c++){var h=i[c],g=h.transferSize,x=h.initiatorType,j=h.duration;if(g&&j&&Mv(x)){for(x=0,j=h.responseEnd,c+=1;c<i.length;c++){var k=i[c],V=k.startTime;if(V>j)break;var K=k.transferSize,W=k.initiatorType;K&&Mv(W)&&(k=k.responseEnd,x+=K*(k<j?1:(j-V)/(k-V)))}if(--c,a+=8*(g+x)/(h.duration/1e3),s++,10<s)break}}if(0<s)return a/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var Ch=null,Rh=null;function vc(s){return s.nodeType===9?s:s.ownerDocument}function zv(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Lv(s,a){if(s===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&a==="foreignObject"?0:s}function Oh(s,a){return s==="textarea"||s==="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 Dh=null;function Mj(){var s=window.event;return s&&s.type==="popstate"?s===Dh?!1:(Dh=s,!0):(Dh=null,!1)}var Uv=typeof setTimeout=="function"?setTimeout:void 0,zj=typeof clearTimeout=="function"?clearTimeout:void 0,Pv=typeof Promise=="function"?Promise:void 0,Lj=typeof queueMicrotask=="function"?queueMicrotask:typeof Pv<"u"?function(s){return Pv.resolve(null).then(s).catch(Uj)}:Uv;function Uj(s){setTimeout(function(){throw s})}function Bn(s){return s==="head"}function Vv(s,a){var i=a,c=0;do{var h=i.nextSibling;if(s.removeChild(i),h&&h.nodeType===8)if(i=h.data,i==="/$"||i==="/&"){if(c===0){s.removeChild(h),Yr(a);return}c--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")c++;else if(i==="html")vo(s.ownerDocument.documentElement);else if(i==="head"){i=s.ownerDocument.head,vo(i);for(var g=i.firstChild;g;){var x=g.nextSibling,j=g.nodeName;g[pa]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&g.rel.toLowerCase()==="stylesheet"||i.removeChild(g),g=x}}else i==="body"&&vo(s.ownerDocument.body);i=h}while(i);Yr(a)}function Bv(s,a){var i=s;s=0;do{var c=i.nextSibling;if(i.nodeType===1?a?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(a?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),c&&c.nodeType===8)if(i=c.data,i==="/$"){if(s===0)break;s--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||s++;i=c}while(i)}function Mh(s){var a=s.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var i=a;switch(a=a.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":Mh(i),zi(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}s.removeChild(i)}}function Pj(s,a,i,c){for(;s.nodeType===1;){var h=i;if(s.nodeName.toLowerCase()!==a.toLowerCase()){if(!c&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(c){if(!s[pa])switch(a){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(g=s.getAttribute("rel"),g==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(g!==h.rel||s.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||s.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||s.getAttribute("title")!==(h.title==null?null:h.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(g=s.getAttribute("src"),(g!==(h.src==null?null:h.src)||s.getAttribute("type")!==(h.type==null?null:h.type)||s.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&g&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(a==="input"&&s.type==="hidden"){var g=h.name==null?null:""+h.name;if(h.type==="hidden"&&s.getAttribute("name")===g)return s}else return s;if(s=ys(s.nextSibling),s===null)break}return null}function Vj(s,a,i){if(a==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!i||(s=ys(s.nextSibling),s===null))return null;return s}function Iv(s,a){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!a||(s=ys(s.nextSibling),s===null))return null;return s}function zh(s){return s.data==="$?"||s.data==="$~"}function Lh(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function Bj(s,a){var i=s.ownerDocument;if(s.data==="$~")s._reactRetry=a;else if(s.data!=="$?"||i.readyState!=="loading")a();else{var c=function(){a(),i.removeEventListener("DOMContentLoaded",c)};i.addEventListener("DOMContentLoaded",c),s._reactRetry=c}}function ys(s){for(;s!=null;s=s.nextSibling){var a=s.nodeType;if(a===1||a===3)break;if(a===8){if(a=s.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return s}var Uh=null;function $v(s){s=s.nextSibling;for(var a=0;s;){if(s.nodeType===8){var i=s.data;if(i==="/$"||i==="/&"){if(a===0)return ys(s.nextSibling);a--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||a++}s=s.nextSibling}return null}function qv(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var i=s.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(a===0)return s;a--}else i!=="/$"&&i!=="/&"||a++}s=s.previousSibling}return null}function Hv(s,a,i){switch(a=vc(i),s){case"html":if(s=a.documentElement,!s)throw Error(r(452));return s;case"head":if(s=a.head,!s)throw Error(r(453));return s;case"body":if(s=a.body,!s)throw Error(r(454));return s;default:throw Error(r(451))}}function vo(s){for(var a=s.attributes;a.length;)s.removeAttributeNode(a[0]);zi(s)}var vs=new Map,Gv=new Set;function xc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var fn=q.d;q.d={f:Ij,r:$j,D:qj,C:Hj,L:Gj,m:Fj,X:Yj,S:Kj,M:Xj};function Ij(){var s=fn.f(),a=uc();return s||a}function $j(s){var a=fr(s);a!==null&&a.tag===5&&a.type==="form"?ly(a):fn.r(s)}var Gr=typeof document>"u"?null:document;function Fv(s,a,i){var c=Gr;if(c&&typeof a=="string"&&a){var h=us(a);h='link[rel="'+s+'"][href="'+h+'"]',typeof i=="string"&&(h+='[crossorigin="'+i+'"]'),Gv.has(h)||(Gv.add(h),s={rel:s,crossOrigin:i,href:a},c.querySelector(h)===null&&(a=c.createElement("link"),Ot(a,"link",s),jt(a),c.head.appendChild(a)))}}function qj(s){fn.D(s),Fv("dns-prefetch",s,null)}function Hj(s,a){fn.C(s,a),Fv("preconnect",s,a)}function Gj(s,a,i){fn.L(s,a,i);var c=Gr;if(c&&s&&a){var h='link[rel="preload"][as="'+us(a)+'"]';a==="image"&&i&&i.imageSrcSet?(h+='[imagesrcset="'+us(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(h+='[imagesizes="'+us(i.imageSizes)+'"]')):h+='[href="'+us(s)+'"]';var g=h;switch(a){case"style":g=Fr(s);break;case"script":g=Kr(s)}vs.has(g)||(s=v({rel:"preload",href:a==="image"&&i&&i.imageSrcSet?void 0:s,as:a},i),vs.set(g,s),c.querySelector(h)!==null||a==="style"&&c.querySelector(xo(g))||a==="script"&&c.querySelector(bo(g))||(a=c.createElement("link"),Ot(a,"link",s),jt(a),c.head.appendChild(a)))}}function Fj(s,a){fn.m(s,a);var i=Gr;if(i&&s){var c=a&&typeof a.as=="string"?a.as:"script",h='link[rel="modulepreload"][as="'+us(c)+'"][href="'+us(s)+'"]',g=h;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Kr(s)}if(!vs.has(g)&&(s=v({rel:"modulepreload",href:s},a),vs.set(g,s),i.querySelector(h)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(bo(g)))return}c=i.createElement("link"),Ot(c,"link",s),jt(c),i.head.appendChild(c)}}}function Kj(s,a,i){fn.S(s,a,i);var c=Gr;if(c&&s){var h=mr(c).hoistableStyles,g=Fr(s);a=a||"default";var x=h.get(g);if(!x){var j={loading:0,preload:null};if(x=c.querySelector(xo(g)))j.loading=5;else{s=v({rel:"stylesheet",href:s,"data-precedence":a},i),(i=vs.get(g))&&Ph(s,i);var k=x=c.createElement("link");jt(k),Ot(k,"link",s),k._p=new Promise(function(V,K){k.onload=V,k.onerror=K}),k.addEventListener("load",function(){j.loading|=1}),k.addEventListener("error",function(){j.loading|=2}),j.loading|=4,bc(x,a,c)}x={type:"stylesheet",instance:x,count:1,state:j},h.set(g,x)}}}function Yj(s,a){fn.X(s,a);var i=Gr;if(i&&s){var c=mr(i).hoistableScripts,h=Kr(s),g=c.get(h);g||(g=i.querySelector(bo(h)),g||(s=v({src:s,async:!0},a),(a=vs.get(h))&&Vh(s,a),g=i.createElement("script"),jt(g),Ot(g,"link",s),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function Xj(s,a){fn.M(s,a);var i=Gr;if(i&&s){var c=mr(i).hoistableScripts,h=Kr(s),g=c.get(h);g||(g=i.querySelector(bo(h)),g||(s=v({src:s,async:!0,type:"module"},a),(a=vs.get(h))&&Vh(s,a),g=i.createElement("script"),jt(g),Ot(g,"link",s),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function Kv(s,a,i,c){var h=(h=_e.current)?xc(h):null;if(!h)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(a=Fr(i.href),i=mr(h).hoistableStyles,c=i.get(a),c||(c={type:"style",instance:null,count:0,state:null},i.set(a,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){s=Fr(i.href);var g=mr(h).hoistableStyles,x=g.get(s);if(x||(h=h.ownerDocument||h,x={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(s,x),(g=h.querySelector(xo(s)))&&!g._p&&(x.instance=g,x.state.loading=5),vs.has(s)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},vs.set(s,i),g||Wj(h,s,i,x.state))),a&&c===null)throw Error(r(528,""));return x}if(a&&c!==null)throw Error(r(529,""));return null;case"script":return a=i.async,i=i.src,typeof i=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Kr(i),i=mr(h).hoistableScripts,c=i.get(a),c||(c={type:"script",instance:null,count:0,state:null},i.set(a,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function Fr(s){return'href="'+us(s)+'"'}function xo(s){return'link[rel="stylesheet"]['+s+"]"}function Yv(s){return v({},s,{"data-precedence":s.precedence,precedence:null})}function Wj(s,a,i,c){s.querySelector('link[rel="preload"][as="style"]['+a+"]")?c.loading=1:(a=s.createElement("link"),c.preload=a,a.addEventListener("load",function(){return c.loading|=1}),a.addEventListener("error",function(){return c.loading|=2}),Ot(a,"link",i),jt(a),s.head.appendChild(a))}function Kr(s){return'[src="'+us(s)+'"]'}function bo(s){return"script[async]"+s}function Xv(s,a,i){if(a.count++,a.instance===null)switch(a.type){case"style":var c=s.querySelector('style[data-href~="'+us(i.href)+'"]');if(c)return a.instance=c,jt(c),c;var h=v({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return c=(s.ownerDocument||s).createElement("style"),jt(c),Ot(c,"style",h),bc(c,i.precedence,s),a.instance=c;case"stylesheet":h=Fr(i.href);var g=s.querySelector(xo(h));if(g)return a.state.loading|=4,a.instance=g,jt(g),g;c=Yv(i),(h=vs.get(h))&&Ph(c,h),g=(s.ownerDocument||s).createElement("link"),jt(g);var x=g;return x._p=new Promise(function(j,k){x.onload=j,x.onerror=k}),Ot(g,"link",c),a.state.loading|=4,bc(g,i.precedence,s),a.instance=g;case"script":return g=Kr(i.src),(h=s.querySelector(bo(g)))?(a.instance=h,jt(h),h):(c=i,(h=vs.get(g))&&(c=v({},i),Vh(c,h)),s=s.ownerDocument||s,h=s.createElement("script"),jt(h),Ot(h,"link",c),s.head.appendChild(h),a.instance=h);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(c=a.instance,a.state.loading|=4,bc(c,i.precedence,s));return a.instance}function bc(s,a,i){for(var c=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=c.length?c[c.length-1]:null,g=h,x=0;x<c.length;x++){var j=c[x];if(j.dataset.precedence===a)g=j;else if(g!==h)break}g?g.parentNode.insertBefore(s,g.nextSibling):(a=i.nodeType===9?i.head:i,a.insertBefore(s,a.firstChild))}function Ph(s,a){s.crossOrigin==null&&(s.crossOrigin=a.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=a.referrerPolicy),s.title==null&&(s.title=a.title)}function Vh(s,a){s.crossOrigin==null&&(s.crossOrigin=a.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=a.referrerPolicy),s.integrity==null&&(s.integrity=a.integrity)}var wc=null;function Wv(s,a,i){if(wc===null){var c=new Map,h=wc=new Map;h.set(i,c)}else h=wc,c=h.get(i),c||(c=new Map,h.set(i,c));if(c.has(s))return c;for(c.set(s,null),i=i.getElementsByTagName(s),h=0;h<i.length;h++){var g=i[h];if(!(g[pa]||g[I]||s==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var x=g.getAttribute(a)||"";x=s+x;var j=c.get(x);j?j.push(g):c.set(x,[g])}}return c}function Jv(s,a,i){s=s.ownerDocument||s,s.head.insertBefore(i,a==="title"?s.querySelector("head > title"):null)}function Jj(s,a,i){if(i===1||a.itemProp!=null)return!1;switch(s){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;return a.rel==="stylesheet"?(s=a.disabled,typeof a.precedence=="string"&&s==null):!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 Qv(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function Qj(s,a,i,c){if(i.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var h=Fr(c.href),g=a.querySelector(xo(h));if(g){a=g._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(s.count++,s=Sc.bind(s),a.then(s,s)),i.state.loading|=4,i.instance=g,jt(g);return}g=a.ownerDocument||a,c=Yv(c),(h=vs.get(h))&&Ph(c,h),g=g.createElement("link"),jt(g);var x=g;x._p=new Promise(function(j,k){x.onload=j,x.onerror=k}),Ot(g,"link",c),i.instance=g}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(i,a),(a=i.state.preload)&&(i.state.loading&3)===0&&(s.count++,i=Sc.bind(s),a.addEventListener("load",i),a.addEventListener("error",i))}}var Bh=0;function Zj(s,a){return s.stylesheets&&s.count===0&&jc(s,s.stylesheets),0<s.count||0<s.imgCount?function(i){var c=setTimeout(function(){if(s.stylesheets&&jc(s,s.stylesheets),s.unsuspend){var g=s.unsuspend;s.unsuspend=null,g()}},6e4+a);0<s.imgBytes&&Bh===0&&(Bh=62500*Dj());var h=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&jc(s,s.stylesheets),s.unsuspend)){var g=s.unsuspend;s.unsuspend=null,g()}},(s.imgBytes>Bh?50:800)+a);return s.unsuspend=i,function(){s.unsuspend=null,clearTimeout(c),clearTimeout(h)}}:null}function Sc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)jc(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var _c=null;function jc(s,a){s.stylesheets=null,s.unsuspend!==null&&(s.count++,_c=new Map,a.forEach(eN,s),_c=null,Sc.call(s))}function eN(s,a){if(!(a.state.loading&4)){var i=_c.get(s);if(i)var c=i.get(null);else{i=new Map,_c.set(s,i);for(var h=s.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<h.length;g++){var x=h[g];(x.nodeName==="LINK"||x.getAttribute("media")!=="not all")&&(i.set(x.dataset.precedence,x),c=x)}c&&i.set(null,c)}h=a.instance,x=h.getAttribute("data-precedence"),g=i.get(x)||c,g===c&&i.set(null,h),i.set(x,h),this.count++,c=Sc.bind(this),h.addEventListener("load",c),h.addEventListener("error",c),g?g.parentNode.insertBefore(h,g.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(h,s.firstChild)),a.state.loading|=4}}var wo={$$typeof:A,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function tN(s,a,i,c,h,g,x,j,k){this.tag=1,this.containerInfo=s,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=Di(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Di(0),this.hiddenUpdates=Di(null),this.identifierPrefix=c,this.onUncaughtError=h,this.onCaughtError=g,this.onRecoverableError=x,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=k,this.incompleteTransitions=new Map}function Zv(s,a,i,c,h,g,x,j,k,V,K,W){return s=new tN(s,a,i,x,k,V,K,W,j),a=1,g===!0&&(a|=24),g=Zt(3,null,null,a),s.current=g,g.stateNode=s,a=xd(),a.refCount++,s.pooledCache=a,a.refCount++,g.memoizedState={element:c,isDehydrated:i,cache:a},_d(g),s}function e0(s){return s?(s=jr,s):jr}function t0(s,a,i,c,h,g){h=e0(h),c.context===null?c.context=h:c.pendingContext=h,c=kn(a),c.payload={element:i},g=g===void 0?null:g,g!==null&&(c.callback=g),i=Cn(s,c,a),i!==null&&(Jt(i,s,a),Qi(i,s,a))}function s0(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var i=s.retryLane;s.retryLane=i!==0&&i<a?i:a}}function Ih(s,a){s0(s,a),(s=s.alternate)&&s0(s,a)}function n0(s){if(s.tag===13||s.tag===31){var a=ba(s,67108864);a!==null&&Jt(a,s,67108864),Ih(s,67108864)}}function a0(s){if(s.tag===13||s.tag===31){var a=as();a=Mi(a);var i=ba(s,a);i!==null&&Jt(i,s,a),Ih(s,a)}}var Nc=!0;function sN(s,a,i,c){var h=C.T;C.T=null;var g=q.p;try{q.p=2,$h(s,a,i,c)}finally{q.p=g,C.T=h}}function nN(s,a,i,c){var h=C.T;C.T=null;var g=q.p;try{q.p=8,$h(s,a,i,c)}finally{q.p=g,C.T=h}}function $h(s,a,i,c){if(Nc){var h=qh(c);if(h===null)Ah(s,a,c,Ec,i),i0(s,c);else if(rN(h,s,a,i,c))c.stopPropagation();else if(i0(s,c),a&4&&-1<aN.indexOf(s)){for(;h!==null;){var g=fr(h);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var x=Vt(g.pendingLanes);if(x!==0){var j=g;for(j.pendingLanes|=2,j.entangledLanes|=2;x;){var k=1<<31-vt(x);j.entanglements[1]|=k,x&=~k}Bs(g),(Be&6)===0&&(lc=Tt()+500,po(0))}}break;case 31:case 13:j=ba(g,2),j!==null&&Jt(j,g,2),uc(),Ih(g,2)}if(g=qh(c),g===null&&Ah(s,a,c,Ec,i),g===h)break;h=g}h!==null&&c.stopPropagation()}else Ah(s,a,c,null,i)}}function qh(s){return s=Gu(s),Hh(s)}var Ec=null;function Hh(s){if(Ec=null,s=hr(s),s!==null){var a=u(s);if(a===null)s=null;else{var i=a.tag;if(i===13){if(s=d(a),s!==null)return s;s=null}else if(i===31){if(s=f(a),s!==null)return s;s=null}else if(i===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null)}}return Ec=s,null}function r0(s){switch(s){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(lr()){case ki:return 2;case Ci:return 8;case ua:case Ks:return 32;case ul:return 268435456;default:return 32}default:return 32}}var Gh=!1,In=null,$n=null,qn=null,So=new Map,_o=new Map,Hn=[],aN="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 i0(s,a){switch(s){case"focusin":case"focusout":In=null;break;case"dragenter":case"dragleave":$n=null;break;case"mouseover":case"mouseout":qn=null;break;case"pointerover":case"pointerout":So.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":_o.delete(a.pointerId)}}function jo(s,a,i,c,h,g){return s===null||s.nativeEvent!==g?(s={blockedOn:a,domEventName:i,eventSystemFlags:c,nativeEvent:g,targetContainers:[h]},a!==null&&(a=fr(a),a!==null&&n0(a)),s):(s.eventSystemFlags|=c,a=s.targetContainers,h!==null&&a.indexOf(h)===-1&&a.push(h),s)}function rN(s,a,i,c,h){switch(a){case"focusin":return In=jo(In,s,a,i,c,h),!0;case"dragenter":return $n=jo($n,s,a,i,c,h),!0;case"mouseover":return qn=jo(qn,s,a,i,c,h),!0;case"pointerover":var g=h.pointerId;return So.set(g,jo(So.get(g)||null,s,a,i,c,h)),!0;case"gotpointercapture":return g=h.pointerId,_o.set(g,jo(_o.get(g)||null,s,a,i,c,h)),!0}return!1}function o0(s){var a=hr(s.target);if(a!==null){var i=u(a);if(i!==null){if(a=i.tag,a===13){if(a=d(i),a!==null){s.blockedOn=a,vl(s.priority,function(){a0(i)});return}}else if(a===31){if(a=f(i),a!==null){s.blockedOn=a,vl(s.priority,function(){a0(i)});return}}else if(a===3&&i.stateNode.current.memoizedState.isDehydrated){s.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Tc(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var i=qh(s.nativeEvent);if(i===null){i=s.nativeEvent;var c=new i.constructor(i.type,i);Hu=c,i.target.dispatchEvent(c),Hu=null}else return a=fr(i),a!==null&&n0(a),s.blockedOn=i,!1;a.shift()}return!0}function l0(s,a,i){Tc(s)&&i.delete(a)}function iN(){Gh=!1,In!==null&&Tc(In)&&(In=null),$n!==null&&Tc($n)&&($n=null),qn!==null&&Tc(qn)&&(qn=null),So.forEach(l0),_o.forEach(l0)}function Ac(s,a){s.blockedOn===a&&(s.blockedOn=null,Gh||(Gh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,iN)))}var kc=null;function c0(s){kc!==s&&(kc=s,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){kc===s&&(kc=null);for(var a=0;a<s.length;a+=3){var i=s[a],c=s[a+1],h=s[a+2];if(typeof c!="function"){if(Hh(c||i)===null)continue;break}var g=fr(i);g!==null&&(s.splice(a,3),a-=3,qd(g,{pending:!0,data:h,method:i.method,action:c},c,h))}}))}function Yr(s){function a(k){return Ac(k,s)}In!==null&&Ac(In,s),$n!==null&&Ac($n,s),qn!==null&&Ac(qn,s),So.forEach(a),_o.forEach(a);for(var i=0;i<Hn.length;i++){var c=Hn[i];c.blockedOn===s&&(c.blockedOn=null)}for(;0<Hn.length&&(i=Hn[0],i.blockedOn===null);)o0(i),i.blockedOn===null&&Hn.shift();if(i=(s.ownerDocument||s).$$reactFormReplay,i!=null)for(c=0;c<i.length;c+=3){var h=i[c],g=i[c+1],x=h[ne]||null;if(typeof g=="function")x||c0(i);else if(x){var j=null;if(g&&g.hasAttribute("formAction")){if(h=g,x=g[ne]||null)j=x.formAction;else if(Hh(h)!==null)continue}else j=x.action;typeof j=="function"?i[c+1]=j:(i.splice(c,3),c-=3),c0(i)}}}function u0(){function s(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(x){return h=x})},focusReset:"manual",scroll:"manual"})}function a(){h!==null&&(h(),h=null),c||setTimeout(i,20)}function i(){if(!c&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,h=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(i,100),function(){c=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),h!==null&&(h(),h=null)}}}function Fh(s){this._internalRoot=s}Cc.prototype.render=Fh.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(r(409));var i=a.current,c=as();t0(i,c,s,a,null,null)},Cc.prototype.unmount=Fh.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;t0(s.current,2,null,s,null,null),uc(),a[Ae]=null}};function Cc(s){this._internalRoot=s}Cc.prototype.unstable_scheduleHydration=function(s){if(s){var a=yl();s={blockedOn:null,target:s,priority:a};for(var i=0;i<Hn.length&&a!==0&&a<Hn[i].priority;i++);Hn.splice(i,0,s),i===0&&o0(s)}};var d0=e.version;if(d0!=="19.2.3")throw Error(r(527,d0,"19.2.3"));q.findDOMNode=function(s){var a=s._reactInternals;if(a===void 0)throw typeof s.render=="function"?Error(r(188)):(s=Object.keys(s).join(","),Error(r(268,s)));return s=m(a),s=s!==null?y(s):null,s=s===null?null:s.stateNode,s};var oN={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:C,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Rc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Rc.isDisabled&&Rc.supportsFiber)try{Sn=Rc.inject(oN),At=Rc}catch{}}return Eo.createRoot=function(s,a){if(!l(s))throw Error(r(299));var i=!1,c="",h=vy,g=xy,x=by;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(g=a.onCaughtError),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),a=Zv(s,1,!1,null,null,i,c,null,h,g,x,u0),s[Ae]=a.current,Th(s),new Fh(a)},Eo.hydrateRoot=function(s,a,i){if(!l(s))throw Error(r(299));var c=!1,h="",g=vy,x=xy,j=by,k=null;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(h=i.identifierPrefix),i.onUncaughtError!==void 0&&(g=i.onUncaughtError),i.onCaughtError!==void 0&&(x=i.onCaughtError),i.onRecoverableError!==void 0&&(j=i.onRecoverableError),i.formState!==void 0&&(k=i.formState)),a=Zv(s,1,!0,a,i??null,c,h,k,g,x,j,u0),a.context=e0(null),i=a.current,c=as(),c=Mi(c),h=kn(c),h.callback=null,Cn(i,h,c),i=c,a.current.lanes=i,fa(a,i),Bs(a),s[Ae]=a.current,Th(s),new Cc(a)},Eo.version="19.2.3",Eo}var w0;function yN(){if(w0)return Xh.exports;w0=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Xh.exports=gN(),Xh.exports}var vN=yN();const xN=jm(vN);const bN=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wN=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),S0=t=>{const e=wN(t);return e.charAt(0).toUpperCase()+e.slice(1)},zb=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),SN=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var _N={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const jN=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:l="",children:u,iconNode:d,...f},p)=>w.createElement("svg",{ref:p,..._N,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:zb("lucide",l),...!u&&!SN(f)&&{"aria-hidden":"true"},...f},[...d.map(([m,y])=>w.createElement(m,y)),...Array.isArray(u)?u:[u]]));const ae=(t,e)=>{const n=w.forwardRef(({className:r,...l},u)=>w.createElement(jN,{ref:u,iconNode:e,className:zb(`lucide-${bN(S0(t))}`,`lucide-${t}`,r),...l}));return n.displayName=S0(t),n};const NN=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],EN=ae("activity",NN);const TN=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],AN=ae("archive",TN);const kN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],CN=ae("arrow-down",kN);const RN=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Tm=ae("arrow-left",RN);const ON=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],DN=ae("arrow-up",ON);const MN=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],zN=ae("boxes",MN);const LN=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Vo=ae("brain",LN);const UN=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],PN=ae("briefcase",UN);const VN=[["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"}]],Lb=ae("calendar",VN);const BN=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],IN=ae("camera",BN);const $N=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Ub=ae("chart-column",$N);const qN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Xn=ae("check",qN);const HN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Pb=ae("chevron-down",HN);const GN=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],FN=ae("chevron-left",GN);const KN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],au=ae("chevron-right",KN);const YN=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],XN=ae("chevron-up",YN);const WN=[["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"}]],Ms=ae("circle-alert",WN);const JN=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ru=ae("circle-check-big",JN);const QN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Am=ae("circle-check",QN);const ZN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],eE=ae("circle-user",ZN);const tE=[["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"}]],sE=ae("circle-x",tE);const nE=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],aa=ae("clock",nE);const aE=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],yn=ae("code",aE);const rE=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],wu=ae("cpu",rE);const iE=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],fi=ae("database",iE);const oE=[["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"}]],Bo=ae("external-link",oE);const lE=[["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"}]],cE=ae("eye-off",lE);const uE=[["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"}]],km=ae("eye",uE);const dE=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],hE=ae("file-text",dE);const fE=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],mE=ae("flag",fE);const pE=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],gE=ae("funnel",pE);const yE=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],vE=ae("globe",yE);const xE=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],bE=ae("hash",xE);const wE=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vi=ae("info",wE);const SE=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],_0=ae("key-round",SE);const _E=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Cm=ae("key",_E);const jE=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],NE=ae("layout-dashboard",jE);const EE=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],_t=ae("loader-circle",EE);const TE=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],AE=ae("log-in",TE);const kE=[["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"}]],CE=ae("log-out",kE);const RE=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Gs=ae("mail",RE);const OE=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],DE=ae("minimize-2",OE);const ME=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],zE=ae("moon",ME);const LE=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Vb=ae("paperclip",LE);const UE=[["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"}]],PE=ae("pen",UE);const VE=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],qa=ae("plus",VE);const BE=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Bb=ae("power",BE);const IE=[["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"}]],Lt=ae("refresh-cw",IE);const $E=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],qE=ae("rocket",$E);const HE=[["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"}]],Ib=ae("rotate-ccw",HE);const GE=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],FE=ae("save",GE);const KE=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],YE=ae("search",KE);const XE=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Su=ae("send",XE);const WE=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Io=ae("settings",WE);const JE=[["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"}]],QE=ae("settings-2",JE);const ZE=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],$b=ae("shield-check",ZE);const eT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Rm=ae("shield",eT);const tT=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Jc=ae("sparkles",tT);const sT=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],nT=ae("square-pen",sT);const aT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],rT=ae("square",aT);const iT=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],oT=ae("sun",iT);const lT=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],iu=ae("terminal",lT);const cT=[["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"}]],_u=ae("trash-2",cT);const uT=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],xi=ae("triangle-alert",uT);const dT=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],hT=ae("upload",dT);const fT=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],mT=ae("user-plus",fT);const pT=[["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"}]],Om=ae("user",pT);const gT=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],yT=ae("volume-2",gT);const vT=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],xT=ae("volume-x",vT);const bT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],_s=ae("x",bT);const wT=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],$o=ae("zap",wT),ST={theme:"system",setTheme:()=>null},qb=w.createContext(ST);function _T({children:t,defaultTheme:e="system",storageKey:n="vite-ui-theme"}){const[r,l]=w.useState(()=>localStorage.getItem(n)||e);w.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),r==="system"){const f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(f);return}d.classList.add(r)},[r]);const u={theme:r,setTheme:d=>{localStorage.setItem(n,d),l(d)}};return o.jsx(qb.Provider,{value:u,children:t})}const jT=()=>{const t=w.useContext(qb);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function j0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ju(...t){return e=>{let n=!1;const r=t.map(l=>{const u=j0(l,e);return!n&&typeof u=="function"&&(n=!0),u});if(n)return()=>{for(let l=0;l<r.length;l++){const u=r[l];typeof u=="function"?u():j0(t[l],null)}}}}function nr(...t){return w.useCallback(ju(...t),t)}var NT=Symbol.for("react.lazy"),ou=Em[" use ".trim().toString()];function ET(t){return typeof t=="object"&&t!==null&&"then"in t}function Hb(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===NT&&"_payload"in t&&ET(t._payload)}function Gb(t){const e=AT(t),n=w.forwardRef((r,l)=>{let{children:u,...d}=r;Hb(u)&&typeof ou=="function"&&(u=ou(u._payload));const f=w.Children.toArray(u),p=f.find(CT);if(p){const m=p.props.children,y=f.map(v=>v===p?w.Children.count(m)>1?w.Children.only(null):w.isValidElement(m)?m.props.children:null:v);return o.jsx(e,{...d,ref:l,children:w.isValidElement(m)?w.cloneElement(m,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return n.displayName=`${t}.Slot`,n}var TT=Gb("Slot");function AT(t){const e=w.forwardRef((n,r)=>{let{children:l,...u}=n;if(Hb(l)&&typeof ou=="function"&&(l=ou(l._payload)),w.isValidElement(l)){const d=OT(l),f=RT(u,l.props);return l.type!==w.Fragment&&(f.ref=r?ju(r,d):d),w.cloneElement(l,f)}return w.Children.count(l)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var kT=Symbol("radix.slottable");function CT(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===kT}function RT(t,e){const n={...e};for(const r in e){const l=t[r],u=e[r];/^on[A-Z]/.test(r)?l&&u?n[r]=(...f)=>{const p=u(...f);return l(...f),p}:l&&(n[r]=l):r==="style"?n[r]={...l,...u}:r==="className"&&(n[r]=[l,u].filter(Boolean).join(" "))}return{...t,...n}}function OT(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Fb(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var l=t.length;for(e=0;e<l;e++)t[e]&&(n=Fb(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Kb(){for(var t,e,n=0,r="",l=arguments.length;n<l;n++)(t=arguments[n])&&(e=Fb(t))&&(r&&(r+=" "),r+=e);return r}const N0=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,E0=Kb,Yb=(t,e)=>n=>{var r;if(e?.variants==null)return E0(t,n?.class,n?.className);const{variants:l,defaultVariants:u}=e,d=Object.keys(l).map(m=>{const y=n?.[m],v=u?.[m];if(y===null)return null;const b=N0(y)||N0(v);return l[m][b]}),f=n&&Object.entries(n).reduce((m,y)=>{let[v,b]=y;return b===void 0||(m[v]=b),m},{}),p=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((m,y)=>{let{class:v,className:b,...S}=y;return Object.entries(S).every(_=>{let[N,E]=_;return Array.isArray(E)?E.includes({...u,...f}[N]):{...u,...f}[N]===E})?[...m,v,b]:m},[]);return E0(t,d,p,n?.class,n?.className)},DT=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r<t.length;r++)n[r]=t[r];for(let r=0;r<e.length;r++)n[t.length+r]=e[r];return n},MT=(t,e)=>({classGroupId:t,validator:e}),Xb=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),lu="-",T0=[],zT="arbitrary..",LT=t=>{const e=PT(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return UT(d);const f=d.split(lu),p=f[0]===""&&f.length>1?1:0;return Wb(f,p,e)},getConflictingClassGroupIds:(d,f)=>{if(f){const p=r[d],m=n[d];return p?m?DT(m,p):p:m||T0}return n[d]||T0}}},Wb=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const l=t[e],u=n.nextPart.get(l);if(u){const m=Wb(t,e+1,u);if(m)return m}const d=n.validators;if(d===null)return;const f=e===0?t.join(lu):t.slice(e).join(lu),p=d.length;for(let m=0;m<p;m++){const y=d[m];if(y.validator(f))return y.classGroupId}},UT=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?zT+r:void 0})(),PT=t=>{const{theme:e,classGroups:n}=t;return VT(n,e)},VT=(t,e)=>{const n=Xb();for(const r in t){const l=t[r];Dm(l,n,r,e)}return n},Dm=(t,e,n,r)=>{const l=t.length;for(let u=0;u<l;u++){const d=t[u];BT(d,e,n,r)}},BT=(t,e,n,r)=>{if(typeof t=="string"){IT(t,e,n);return}if(typeof t=="function"){$T(t,e,n,r);return}qT(t,e,n,r)},IT=(t,e,n)=>{const r=t===""?e:Jb(e,t);r.classGroupId=n},$T=(t,e,n,r)=>{if(HT(t)){Dm(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(MT(n,t))},qT=(t,e,n,r)=>{const l=Object.entries(t),u=l.length;for(let d=0;d<u;d++){const[f,p]=l[d];Dm(p,Jb(e,f),n,r)}},Jb=(t,e)=>{let n=t;const r=e.split(lu),l=r.length;for(let u=0;u<l;u++){const d=r[u];let f=n.nextPart.get(d);f||(f=Xb(),n.nextPart.set(d,f)),n=f}return n},HT=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,GT=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const l=(u,d)=>{n[u]=d,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(u){let d=n[u];if(d!==void 0)return d;if((d=r[u])!==void 0)return l(u,d),d},set(u,d){u in n?n[u]=d:l(u,d)}}},Uf="!",A0=":",FT=[],k0=(t,e,n,r,l)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:l}),KT=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=l=>{const u=[];let d=0,f=0,p=0,m;const y=l.length;for(let N=0;N<y;N++){const E=l[N];if(d===0&&f===0){if(E===A0){u.push(l.slice(p,N)),p=N+1;continue}if(E==="/"){m=N;continue}}E==="["?d++:E==="]"?d--:E==="("?f++:E===")"&&f--}const v=u.length===0?l:l.slice(p);let b=v,S=!1;v.endsWith(Uf)?(b=v.slice(0,-1),S=!0):v.startsWith(Uf)&&(b=v.slice(1),S=!0);const _=m&&m>p?m-p:void 0;return k0(u,S,b,_)};if(e){const l=e+A0,u=r;r=d=>d.startsWith(l)?u(d.slice(l.length)):k0(FT,!1,d,void 0,!0)}if(n){const l=r;r=u=>n({className:u,parseClassName:l})}return r},YT=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let l=[];for(let u=0;u<n.length;u++){const d=n[u],f=d[0]==="[",p=e.has(d);f||p?(l.length>0&&(l.sort(),r.push(...l),l=[]),r.push(d)):l.push(d)}return l.length>0&&(l.sort(),r.push(...l)),r}},XT=t=>({cache:GT(t.cacheSize),parseClassName:KT(t),sortModifiers:YT(t),...LT(t)}),WT=/\s+/,JT=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:l,sortModifiers:u}=e,d=[],f=t.trim().split(WT);let p="";for(let m=f.length-1;m>=0;m-=1){const y=f[m],{isExternal:v,modifiers:b,hasImportantModifier:S,baseClassName:_,maybePostfixModifierPosition:N}=n(y);if(v){p=y+(p.length>0?" "+p:p);continue}let E=!!N,T=r(E?_.substring(0,N):_);if(!T){if(!E){p=y+(p.length>0?" "+p:p);continue}if(T=r(_),!T){p=y+(p.length>0?" "+p:p);continue}E=!1}const D=b.length===0?"":b.length===1?b[0]:u(b).join(":"),A=S?D+Uf:D,U=A+T;if(d.indexOf(U)>-1)continue;d.push(U);const H=l(T,E);for(let G=0;G<H.length;++G){const z=H[G];d.push(A+z)}p=y+(p.length>0?" "+p:p)}return p},QT=(...t)=>{let e=0,n,r,l="";for(;e<t.length;)(n=t[e++])&&(r=Qb(n))&&(l&&(l+=" "),l+=r);return l},Qb=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=Qb(t[r]))&&(n&&(n+=" "),n+=e);return n},ZT=(t,...e)=>{let n,r,l,u;const d=p=>{const m=e.reduce((y,v)=>v(y),t());return n=XT(m),r=n.cache.get,l=n.cache.set,u=f,f(p)},f=p=>{const m=r(p);if(m)return m;const y=JT(p,n);return l(p,y),y};return u=d,(...p)=>u(QT(...p))},e2=[],bt=t=>{const e=n=>n[t]||e2;return e.isThemeGetter=!0,e},Zb=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ew=/^\((?:(\w[\w-]*):)?(.+)\)$/i,t2=/^\d+\/\d+$/,s2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,n2=/\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$/,a2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,r2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,i2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Xr=t=>t2.test(t),ke=t=>!!t&&!Number.isNaN(Number(t)),Fn=t=>!!t&&Number.isInteger(Number(t)),Zh=t=>t.endsWith("%")&&ke(t.slice(0,-1)),mn=t=>s2.test(t),o2=()=>!0,l2=t=>n2.test(t)&&!a2.test(t),tw=()=>!1,c2=t=>r2.test(t),u2=t=>i2.test(t),d2=t=>!le(t)&&!ce(t),h2=t=>wi(t,aw,tw),le=t=>Zb.test(t),Da=t=>wi(t,rw,l2),ef=t=>wi(t,y2,ke),C0=t=>wi(t,sw,tw),f2=t=>wi(t,nw,u2),Oc=t=>wi(t,iw,c2),ce=t=>ew.test(t),To=t=>Si(t,rw),m2=t=>Si(t,v2),R0=t=>Si(t,sw),p2=t=>Si(t,aw),g2=t=>Si(t,nw),Dc=t=>Si(t,iw,!0),wi=(t,e,n)=>{const r=Zb.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Si=(t,e,n=!1)=>{const r=ew.exec(t);return r?r[1]?e(r[1]):n:!1},sw=t=>t==="position"||t==="percentage",nw=t=>t==="image"||t==="url",aw=t=>t==="length"||t==="size"||t==="bg-size",rw=t=>t==="length",y2=t=>t==="number",v2=t=>t==="family-name",iw=t=>t==="shadow",x2=()=>{const t=bt("color"),e=bt("font"),n=bt("text"),r=bt("font-weight"),l=bt("tracking"),u=bt("leading"),d=bt("breakpoint"),f=bt("container"),p=bt("spacing"),m=bt("radius"),y=bt("shadow"),v=bt("inset-shadow"),b=bt("text-shadow"),S=bt("drop-shadow"),_=bt("blur"),N=bt("perspective"),E=bt("aspect"),T=bt("ease"),D=bt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],U=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],H=()=>[...U(),ce,le],G=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],M=()=>[ce,le,p],J=()=>[Xr,"full","auto",...M()],ie=()=>[Fn,"none","subgrid",ce,le],be=()=>["auto",{span:["full",Fn,ce,le]},Fn,ce,le],de=()=>[Fn,"auto",ce,le],Ve=()=>["auto","min","max","fr",ce,le],Ie=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ee=()=>["start","end","center","stretch","center-safe","end-safe"],C=()=>["auto",...M()],q=()=>[Xr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...M()],B=()=>[t,ce,le],re=()=>[...U(),R0,C0,{position:[ce,le]}],pe=()=>["no-repeat",{repeat:["","x","y","space","round"]}],R=()=>["auto","cover","contain",p2,h2,{size:[ce,le]}],Y=()=>[Zh,To,Da],Z=()=>["","none","full",m,ce,le],te=()=>["",ke,To,Da],we=()=>["solid","dashed","dotted","double"],_e=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ge=()=>[ke,Zh,R0,C0],lt=()=>["","none",_,ce,le],Le=()=>["none",ke,ce,le],ls=()=>["none",ke,ce,le],Gt=()=>[ke,ce,le],Et=()=>[Xr,"full",...M()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[mn],breakpoint:[mn],color:[o2],container:[mn],"drop-shadow":[mn],ease:["in","out","in-out"],font:[d2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[mn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[mn],shadow:[mn],spacing:["px",ke],text:[mn],"text-shadow":[mn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Xr,le,ce,E]}],container:["container"],columns:[{columns:[ke,le,ce,f]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"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:H()}],overflow:[{overflow:G()}],"overflow-x":[{"overflow-x":G()}],"overflow-y":[{"overflow-y":G()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:J()}],"inset-x":[{"inset-x":J()}],"inset-y":[{"inset-y":J()}],start:[{start:J()}],end:[{end:J()}],top:[{top:J()}],right:[{right:J()}],bottom:[{bottom:J()}],left:[{left:J()}],visibility:["visible","invisible","collapse"],z:[{z:[Fn,"auto",ce,le]}],basis:[{basis:[Xr,"full","auto",f,...M()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ke,Xr,"auto","initial","none",le]}],grow:[{grow:["",ke,ce,le]}],shrink:[{shrink:["",ke,ce,le]}],order:[{order:[Fn,"first","last","none",ce,le]}],"grid-cols":[{"grid-cols":ie()}],"col-start-end":[{col:be()}],"col-start":[{"col-start":de()}],"col-end":[{"col-end":de()}],"grid-rows":[{"grid-rows":ie()}],"row-start-end":[{row:be()}],"row-start":[{"row-start":de()}],"row-end":[{"row-end":de()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ve()}],"auto-rows":[{"auto-rows":Ve()}],gap:[{gap:M()}],"gap-x":[{"gap-x":M()}],"gap-y":[{"gap-y":M()}],"justify-content":[{justify:[...Ie(),"normal"]}],"justify-items":[{"justify-items":[...ee(),"normal"]}],"justify-self":[{"justify-self":["auto",...ee()]}],"align-content":[{content:["normal",...Ie()]}],"align-items":[{items:[...ee(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ee(),{baseline:["","last"]}]}],"place-content":[{"place-content":Ie()}],"place-items":[{"place-items":[...ee(),"baseline"]}],"place-self":[{"place-self":["auto",...ee()]}],p:[{p:M()}],px:[{px:M()}],py:[{py:M()}],ps:[{ps:M()}],pe:[{pe:M()}],pt:[{pt:M()}],pr:[{pr:M()}],pb:[{pb:M()}],pl:[{pl:M()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":M()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":M()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],w:[{w:[f,"screen",...q()]}],"min-w":[{"min-w":[f,"screen","none",...q()]}],"max-w":[{"max-w":[f,"screen","none","prose",{screen:[d]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",n,To,Da]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ce,ef]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Zh,le]}],"font-family":[{font:[m2,le,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:[l,ce,le]}],"line-clamp":[{"line-clamp":[ke,"none",ce,ef]}],leading:[{leading:[u,...M()]}],"list-image":[{"list-image":["none",ce,le]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ce,le]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...we(),"wavy"]}],"text-decoration-thickness":[{decoration:[ke,"from-font","auto",ce,Da]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[ke,"auto",ce,le]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ce,le]}],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",ce,le]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:re()}],"bg-repeat":[{bg:pe()}],"bg-size":[{bg:R()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fn,ce,le],radial:["",ce,le],conic:[Fn,ce,le]},g2,f2]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"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-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:[...we(),"hidden","none"]}],"divide-style":[{divide:[...we(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...we(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ke,ce,le]}],"outline-w":[{outline:["",ke,To,Da]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",y,Dc,Oc]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",v,Dc,Oc]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[ke,Da]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",b,Dc,Oc]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[ke,ce,le]}],"mix-blend":[{"mix-blend":[..._e(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_e()}],"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":[ke]}],"mask-image-linear-from-pos":[{"mask-linear-from":ge()}],"mask-image-linear-to-pos":[{"mask-linear-to":ge()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":ge()}],"mask-image-t-to-pos":[{"mask-t-to":ge()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":ge()}],"mask-image-r-to-pos":[{"mask-r-to":ge()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":ge()}],"mask-image-b-to-pos":[{"mask-b-to":ge()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":ge()}],"mask-image-l-to-pos":[{"mask-l-to":ge()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":ge()}],"mask-image-x-to-pos":[{"mask-x-to":ge()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":ge()}],"mask-image-y-to-pos":[{"mask-y-to":ge()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[ce,le]}],"mask-image-radial-from-pos":[{"mask-radial-from":ge()}],"mask-image-radial-to-pos":[{"mask-radial-to":ge()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"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":U()}],"mask-image-conic-pos":[{"mask-conic":[ke]}],"mask-image-conic-from-pos":[{"mask-conic-from":ge()}],"mask-image-conic-to-pos":[{"mask-conic-to":ge()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:re()}],"mask-repeat":[{mask:pe()}],"mask-size":[{mask:R()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ce,le]}],filter:[{filter:["","none",ce,le]}],blur:[{blur:lt()}],brightness:[{brightness:[ke,ce,le]}],contrast:[{contrast:[ke,ce,le]}],"drop-shadow":[{"drop-shadow":["","none",S,Dc,Oc]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",ke,ce,le]}],"hue-rotate":[{"hue-rotate":[ke,ce,le]}],invert:[{invert:["",ke,ce,le]}],saturate:[{saturate:[ke,ce,le]}],sepia:[{sepia:["",ke,ce,le]}],"backdrop-filter":[{"backdrop-filter":["","none",ce,le]}],"backdrop-blur":[{"backdrop-blur":lt()}],"backdrop-brightness":[{"backdrop-brightness":[ke,ce,le]}],"backdrop-contrast":[{"backdrop-contrast":[ke,ce,le]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ke,ce,le]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ke,ce,le]}],"backdrop-invert":[{"backdrop-invert":["",ke,ce,le]}],"backdrop-opacity":[{"backdrop-opacity":[ke,ce,le]}],"backdrop-saturate":[{"backdrop-saturate":[ke,ce,le]}],"backdrop-sepia":[{"backdrop-sepia":["",ke,ce,le]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":M()}],"border-spacing-x":[{"border-spacing-x":M()}],"border-spacing-y":[{"border-spacing-y":M()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ce,le]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ke,"initial",ce,le]}],ease:[{ease:["linear","initial",T,ce,le]}],delay:[{delay:[ke,ce,le]}],animate:[{animate:["none",D,ce,le]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[N,ce,le]}],"perspective-origin":[{"perspective-origin":H()}],rotate:[{rotate:Le()}],"rotate-x":[{"rotate-x":Le()}],"rotate-y":[{"rotate-y":Le()}],"rotate-z":[{"rotate-z":Le()}],scale:[{scale:ls()}],"scale-x":[{"scale-x":ls()}],"scale-y":[{"scale-y":ls()}],"scale-z":[{"scale-z":ls()}],"scale-3d":["scale-3d"],skew:[{skew:Gt()}],"skew-x":[{"skew-x":Gt()}],"skew-y":[{"skew-y":Gt()}],transform:[{transform:[ce,le,"","none","gpu","cpu"]}],"transform-origin":[{origin:H()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Et()}],"translate-x":[{"translate-x":Et()}],"translate-y":[{"translate-y":Et()}],"translate-z":[{"translate-z":Et()}],"translate-none":["translate-none"],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"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",ce,le]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"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",ce,le]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[ke,To,Da,ef]}],stroke:[{stroke:["none",...B()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},b2=ZT(x2);function Se(...t){return b2(Kb(t))}const w2=Yb("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 focus-visible:ring-4 focus-visible:outline-1 aria-invalid:focus-visible:ring-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs 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"}}),Q=w.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...l},u)=>{const d=r?TT:"button";return o.jsx(d,{className:Se(w2({variant:e,size:n,className:t})),ref:u,...l})});Q.displayName="Button";function ow(){const{setTheme:t,theme:e}=jT();return o.jsxs(Q,{variant:"ghost",size:"sm",onClick:()=>t(e==="dark"?"light":"dark"),className:"text-muted-foreground hover:text-foreground w-8 px-0",title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:[e==="dark"?o.jsx(oT,{className:"h-[1.2rem] w-[1.2rem]"}):o.jsx(zE,{className:"h-[1.2rem] w-[1.2rem]"}),o.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}var $s=function(){return $s=Object.assign||function(e){for(var n,r=1,l=arguments.length;r<l;r++){n=arguments[r];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(e[u]=n[u])}return e},$s.apply(this,arguments)};function _i(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,r=Object.getOwnPropertySymbols(t);l<r.length;l++)e.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(t,r[l])&&(n[r[l]]=t[r[l]]);return n}function S2(t,e,n,r){function l(u){return u instanceof n?u:new n(function(d){d(u)})}return new(n||(n=Promise))(function(u,d){function f(y){try{m(r.next(y))}catch(v){d(v)}}function p(y){try{m(r.throw(y))}catch(v){d(v)}}function m(y){y.done?u(y.value):l(y.value).then(f,p)}m((r=r.apply(t,e||[])).next())})}function _2(t,e,n){if(n||arguments.length===2)for(var r=0,l=e.length,u;r<l;r++)(u||!(r in e))&&(u||(u=Array.prototype.slice.call(e,0,r)),u[r]=e[r]);return t.concat(u||Array.prototype.slice.call(e))}const j2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Mm extends Error{constructor(e,n="FunctionsError",r){super(e),this.name=n,this.context=r}}class N2 extends Mm{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class O0 extends Mm{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class D0 extends Mm{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Pf;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(Pf||(Pf={}));class E2{constructor(e,{headers:n={},customFetch:r,region:l=Pf.Any}={}){this.url=e,this.headers=n,this.region=l,this.fetch=j2(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return S2(this,arguments,void 0,function*(n,r={}){var l;let u,d;try{const{headers:f,method:p,body:m,signal:y,timeout:v}=r;let b={},{region:S}=r;S||(S=this.region);const _=new URL(`${this.url}/${n}`);S&&S!=="any"&&(b["x-region"]=S,_.searchParams.set("forceFunctionRegion",S));let N;m&&(f&&!Object.prototype.hasOwnProperty.call(f,"Content-Type")||!f)?typeof Blob<"u"&&m instanceof Blob||m instanceof ArrayBuffer?(b["Content-Type"]="application/octet-stream",N=m):typeof m=="string"?(b["Content-Type"]="text/plain",N=m):typeof FormData<"u"&&m instanceof FormData?N=m:(b["Content-Type"]="application/json",N=JSON.stringify(m)):m&&typeof m!="string"&&!(typeof Blob<"u"&&m instanceof Blob)&&!(m instanceof ArrayBuffer)&&!(typeof FormData<"u"&&m instanceof FormData)?N=JSON.stringify(m):N=m;let E=y;v&&(d=new AbortController,u=setTimeout(()=>d.abort(),v),y?(E=d.signal,y.addEventListener("abort",()=>d.abort())):E=d.signal);const T=yield this.fetch(_.toString(),{method:p||"POST",headers:Object.assign(Object.assign(Object.assign({},b),this.headers),f),body:N,signal:E}).catch(H=>{throw new N2(H)}),D=T.headers.get("x-relay-error");if(D&&D==="true")throw new O0(T);if(!T.ok)throw new D0(T);let A=((l=T.headers.get("Content-Type"))!==null&&l!==void 0?l:"text/plain").split(";")[0].trim(),U;return A==="application/json"?U=yield T.json():A==="application/octet-stream"||A==="application/pdf"?U=yield T.blob():A==="text/event-stream"?U=T:A==="multipart/form-data"?U=yield T.formData():U=yield T.text(),{data:U,error:null,response:T}}catch(f){return{data:null,error:f,response:f instanceof D0||f instanceof O0?f.context:void 0}}finally{u&&clearTimeout(u)}})}}var T2=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},A2=class{constructor(t){var e,n;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(n=t.isMaybeSingle)!==null&&n!==void 0?n:!1,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var n=this;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");const r=this.fetch;let l=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{let d=null,f=null,p=null,m=u.status,y=u.statusText;if(u.ok){var v,b;if(n.method!=="HEAD"){var S;const T=await u.text();T===""||(n.headers.get("Accept")==="text/csv"||n.headers.get("Accept")&&(!((S=n.headers.get("Accept"))===null||S===void 0)&&S.includes("application/vnd.pgrst.plan+text"))?f=T:f=JSON.parse(T))}const N=(v=n.headers.get("Prefer"))===null||v===void 0?void 0:v.match(/count=(exact|planned|estimated)/),E=(b=u.headers.get("content-range"))===null||b===void 0?void 0:b.split("/");N&&E&&E.length>1&&(p=parseInt(E[1])),n.isMaybeSingle&&n.method==="GET"&&Array.isArray(f)&&(f.length>1?(d={code:"PGRST116",details:`Results contain ${f.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},f=null,p=null,m=406,y="Not Acceptable"):f.length===1?f=f[0]:f=null)}else{var _;const N=await u.text();try{d=JSON.parse(N),Array.isArray(d)&&u.status===404&&(f=[],d=null,m=200,y="OK")}catch{u.status===404&&N===""?(m=204,y="No Content"):d={message:N}}if(d&&n.isMaybeSingle&&(!(d==null||(_=d.details)===null||_===void 0)&&_.includes("0 rows"))&&(d=null,m=200,y="OK"),d&&n.shouldThrowOnError)throw new T2(d)}return{error:d,data:f,count:p,status:m,statusText:y}});return this.shouldThrowOnError||(l=l.catch(u=>{var d;let f="";const p=u?.cause;if(p){var m,y,v,b;const _=(m=p?.message)!==null&&m!==void 0?m:"",N=(y=p?.code)!==null&&y!==void 0?y:"";f=`${(v=u?.name)!==null&&v!==void 0?v:"FetchError"}: ${u?.message}`,f+=`
|
|
10
|
+
|
|
11
|
+
Caused by: ${(b=p?.name)!==null&&b!==void 0?b:"Error"}: ${_}`,N&&(f+=` (${N})`),p?.stack&&(f+=`
|
|
12
|
+
${p.stack}`)}else{var S;f=(S=u?.stack)!==null&&S!==void 0?S:""}return{error:{message:`${(d=u?.name)!==null&&d!==void 0?d:"FetchError"}: ${u?.message}`,details:f,hint:"",code:""},data:null,count:null,status:0,statusText:""}})),l.then(t,e)}returns(){return this}overrideTypes(){return this}},k2=class extends A2{select(t){let e=!1;const n=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:n,foreignTable:r,referencedTable:l=r}={}){const u=l?`${l}.order`:"order",d=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${d?`${d},`:""}${t}.${e?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:n=e}={}){const r=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:n,referencedTable:r=n}={}){const l=typeof r>"u"?"offset":`${r}.offset`,u=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(l,`${t}`),this.url.searchParams.set(u,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),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:t=!1,verbose:e=!1,settings:n=!1,buffers:r=!1,wal:l=!1,format:u="text"}={}){var d;const f=[t?"analyze":null,e?"verbose":null,n?"settings":null,r?"buffers":null,l?"wal":null].filter(Boolean).join("|"),p=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${p}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const M0=new RegExp("[,()]");var ri=class extends k2{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const n=Array.from(new Set(e)).map(r=>typeof r=="string"&&M0.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${n})`),this}notIn(t,e){const n=Array.from(new Set(e)).map(r=>typeof r=="string"&&M0.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${n})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:n,type:r}={}){let l="";r==="plain"?l="pl":r==="phrase"?l="ph":r==="websearch"&&(l="w");const u=n===void 0?"":`(${n})`;return this.url.searchParams.append(t,`${l}fts${u}.${e}`),this}match(t){return Object.entries(t).forEach(([e,n])=>{this.url.searchParams.append(e,`eq.${n}`)}),this}not(t,e,n){return this.url.searchParams.append(t,`not.${e}.${n}`),this}or(t,{foreignTable:e,referencedTable:n=e}={}){const r=n?`${n}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,n){return this.url.searchParams.append(t,`${e}.${n}`),this}},C2=class{constructor(t,{headers:e={},schema:n,fetch:r}){this.url=t,this.headers=new Headers(e),this.schema=n,this.fetch=r}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:n=!1,count:r}=e??{},l=n?"HEAD":"GET";let u=!1;const d=(t??"*").split("").map(m=>/\s/.test(m)&&!u?"":(m==='"'&&(u=!u),m)).join(""),{url:f,headers:p}=this.cloneRequestState();return f.searchParams.set("select",d),r&&p.append("Prefer",`count=${r}`),new ri({method:l,url:f,headers:p,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:n=!0}={}){var r;const l="POST",{url:u,headers:d}=this.cloneRequestState();if(e&&d.append("Prefer",`count=${e}`),n||d.append("Prefer","missing=default"),Array.isArray(t)){const f=t.reduce((p,m)=>p.concat(Object.keys(m)),[]);if(f.length>0){const p=[...new Set(f)].map(m=>`"${m}"`);u.searchParams.set("columns",p.join(","))}}return new ri({method:l,url:u,headers:d,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:n=!1,count:r,defaultToNull:l=!0}={}){var u;const d="POST",{url:f,headers:p}=this.cloneRequestState();if(p.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),e!==void 0&&f.searchParams.set("on_conflict",e),r&&p.append("Prefer",`count=${r}`),l||p.append("Prefer","missing=default"),Array.isArray(t)){const m=t.reduce((y,v)=>y.concat(Object.keys(v)),[]);if(m.length>0){const y=[...new Set(m)].map(v=>`"${v}"`);f.searchParams.set("columns",y.join(","))}}return new ri({method:d,url:f,headers:p,schema:this.schema,body:t,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(t,{count:e}={}){var n;const r="PATCH",{url:l,headers:u}=this.cloneRequestState();return e&&u.append("Prefer",`count=${e}`),new ri({method:r,url:l,headers:u,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:t}={}){var e;const n="DELETE",{url:r,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new ri({method:n,url:r,headers:l,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}},R2=class lw{constructor(e,{headers:n={},schema:r,fetch:l}={}){this.url=e,this.headers=new Headers(n),this.schemaName=r,this.fetch=l}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new C2(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new lw(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,n={},{head:r=!1,get:l=!1,count:u}={}){var d;let f;const p=new URL(`${this.url}/rpc/${e}`);let m;const y=S=>S!==null&&typeof S=="object"&&(!Array.isArray(S)||S.some(y)),v=r&&Object.values(n).some(y);v?(f="POST",m=n):r||l?(f=r?"HEAD":"GET",Object.entries(n).filter(([S,_])=>_!==void 0).map(([S,_])=>[S,Array.isArray(_)?`{${_.join(",")}}`:`${_}`]).forEach(([S,_])=>{p.searchParams.append(S,_)})):(f="POST",m=n);const b=new Headers(this.headers);return v?b.set("Prefer",u?`count=${u},return=minimal`:"return=minimal"):u&&b.set("Prefer",`count=${u}`),new ri({method:f,url:p,headers:b,schema:this.schemaName,body:m,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch})}};class O2{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.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"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.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 n=globalThis.process;if(n){const r=n.versions;if(r&&r.node){const l=r.node,u=parseInt(l.replace(/^v/,"").split(".")[0]);return u>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${u} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${u} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
|
|
13
|
+
import ws from "ws"
|
|
14
|
+
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 e=this.detectEnvironment();if(e.constructor)return e.constructor;let n=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(n+=`
|
|
15
|
+
|
|
16
|
+
Suggested solution: ${e.workaround}`),new Error(n)}static createWebSocket(e,n){const r=this.getWebSocketConstructor();return new r(e,n)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const D2="2.90.1",M2=`realtime-js/${D2}`,cw="1.0.0",z2="2.0.0",z0=cw,Vf=1e4,L2=1e3,U2=100;var Wn;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(Wn||(Wn={}));var wt;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(wt||(wt={}));var Ds;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Ds||(Ds={}));var Bf;(function(t){t.websocket="websocket"})(Bf||(Bf={}));var Ba;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Ba||(Ba={}));class P2{constructor(e){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=e??[]}encode(e,n){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return n(this._binaryEncodeUserBroadcastPush(e));let r=[e.join_ref,e.ref,e.topic,e.event,e.payload];return n(JSON.stringify(r))}_binaryEncodeUserBroadcastPush(e){var n;return this._isArrayBuffer((n=e.payload)===null||n===void 0?void 0:n.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var n,r;const l=(r=(n=e.payload)===null||n===void 0?void 0:n.payload)!==null&&r!==void 0?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,l)}_encodeJsonUserBroadcastPush(e){var n,r;const l=(r=(n=e.payload)===null||n===void 0?void 0:n.payload)!==null&&r!==void 0?r:{},d=new TextEncoder().encode(JSON.stringify(l)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,d)}_encodeUserBroadcastPush(e,n,r){var l,u;const d=e.topic,f=(l=e.ref)!==null&&l!==void 0?l:"",p=(u=e.join_ref)!==null&&u!==void 0?u:"",m=e.payload.event,y=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},v=Object.keys(y).length===0?"":JSON.stringify(y);if(p.length>255)throw new Error(`joinRef length ${p.length} exceeds maximum of 255`);if(f.length>255)throw new Error(`ref length ${f.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`topic length ${d.length} exceeds maximum of 255`);if(m.length>255)throw new Error(`userEvent length ${m.length} exceeds maximum of 255`);if(v.length>255)throw new Error(`metadata length ${v.length} exceeds maximum of 255`);const b=this.USER_BROADCAST_PUSH_META_LENGTH+p.length+f.length+d.length+m.length+v.length,S=new ArrayBuffer(this.HEADER_LENGTH+b);let _=new DataView(S),N=0;_.setUint8(N++,this.KINDS.userBroadcastPush),_.setUint8(N++,p.length),_.setUint8(N++,f.length),_.setUint8(N++,d.length),_.setUint8(N++,m.length),_.setUint8(N++,v.length),_.setUint8(N++,n),Array.from(p,T=>_.setUint8(N++,T.charCodeAt(0))),Array.from(f,T=>_.setUint8(N++,T.charCodeAt(0))),Array.from(d,T=>_.setUint8(N++,T.charCodeAt(0))),Array.from(m,T=>_.setUint8(N++,T.charCodeAt(0))),Array.from(v,T=>_.setUint8(N++,T.charCodeAt(0)));var E=new Uint8Array(S.byteLength+r.byteLength);return E.set(new Uint8Array(S),0),E.set(new Uint8Array(r),S.byteLength),E.buffer}decode(e,n){if(this._isArrayBuffer(e)){let r=this._binaryDecode(e);return n(r)}if(typeof e=="string"){const r=JSON.parse(e),[l,u,d,f,p]=r;return n({join_ref:l,ref:u,topic:d,event:f,payload:p})}return n({})}_binaryDecode(e){const n=new DataView(e),r=n.getUint8(0),l=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,n,l)}_decodeUserBroadcast(e,n,r){const l=n.getUint8(1),u=n.getUint8(2),d=n.getUint8(3),f=n.getUint8(4);let p=this.HEADER_LENGTH+4;const m=r.decode(e.slice(p,p+l));p=p+l;const y=r.decode(e.slice(p,p+u));p=p+u;const v=r.decode(e.slice(p,p+d));p=p+d;const b=e.slice(p,e.byteLength),S=f===this.JSON_ENCODING?JSON.parse(r.decode(b)):b,_={type:this.BROADCAST_EVENT,event:y,payload:S};return d>0&&(_.meta=JSON.parse(v)),{join_ref:null,ref:null,topic:m,event:this.BROADCAST_EVENT,payload:_}}_isArrayBuffer(e){var n;return e instanceof ArrayBuffer||((n=e?.constructor)===null||n===void 0?void 0:n.name)==="ArrayBuffer"}_pick(e,n){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([r])=>n.includes(r)))}}class uw{constructor(e,n){this.callback=e,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Ye;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Ye||(Ye={}));const L0=(t,e,n={})=>{var r;const l=(r=n.skipTypes)!==null&&r!==void 0?r:[];return e?Object.keys(e).reduce((u,d)=>(u[d]=V2(d,t,e,l),u),{}):{}},V2=(t,e,n,r)=>{const l=e.find(f=>f.name===t),u=l?.type,d=n[t];return u&&!r.includes(u)?dw(u,d):If(d)},dw=(t,e)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return q2(e,n)}switch(t){case Ye.bool:return B2(e);case Ye.float4:case Ye.float8:case Ye.int2:case Ye.int4:case Ye.int8:case Ye.numeric:case Ye.oid:return I2(e);case Ye.json:case Ye.jsonb:return $2(e);case Ye.timestamp:return H2(e);case Ye.abstime:case Ye.date:case Ye.daterange:case Ye.int4range:case Ye.int8range:case Ye.money:case Ye.reltime:case Ye.text:case Ye.time:case Ye.timestamptz:case Ye.timetz:case Ye.tsrange:case Ye.tstzrange:return If(e);default:return If(e)}},If=t=>t,B2=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},I2=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},$2=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},q2=(t,e)=>{if(typeof t!="string")return t;const n=t.length-1,r=t[n];if(t[0]==="{"&&r==="}"){let u;const d=t.slice(1,n);try{u=JSON.parse("["+d+"]")}catch{u=d?d.split(","):[]}return u.map(f=>dw(e,f))}return t},H2=t=>typeof t=="string"?t.replace(" ","T"):t,hw=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};class tf{constructor(e,n,r={},l=Vf){this.channel=e,this.event=n,this.payload=r,this.timeout=l,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,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()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,n){var r;return this._hasReceived(e)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:n})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:n}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(n))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var U0;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(U0||(U0={}));class Do{constructor(e,n){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=n?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},l=>{const{onJoin:u,onLeave:d,onSync:f}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Do.syncState(this.state,l,u,d),this.pendingDiffs.forEach(p=>{this.state=Do.syncDiff(this.state,p,u,d)}),this.pendingDiffs=[],f()}),this.channel._on(r.diff,{},l=>{const{onJoin:u,onLeave:d,onSync:f}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(l):(this.state=Do.syncDiff(this.state,l,u,d),f())}),this.onJoin((l,u,d)=>{this.channel._trigger("presence",{event:"join",key:l,currentPresences:u,newPresences:d})}),this.onLeave((l,u,d)=>{this.channel._trigger("presence",{event:"leave",key:l,currentPresences:u,leftPresences:d})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,n,r,l){const u=this.cloneDeep(e),d=this.transformState(n),f={},p={};return this.map(u,(m,y)=>{d[m]||(p[m]=y)}),this.map(d,(m,y)=>{const v=u[m];if(v){const b=y.map(E=>E.presence_ref),S=v.map(E=>E.presence_ref),_=y.filter(E=>S.indexOf(E.presence_ref)<0),N=v.filter(E=>b.indexOf(E.presence_ref)<0);_.length>0&&(f[m]=_),N.length>0&&(p[m]=N)}else f[m]=y}),this.syncDiff(u,{joins:f,leaves:p},r,l)}static syncDiff(e,n,r,l){const{joins:u,leaves:d}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),l||(l=()=>{}),this.map(u,(f,p)=>{var m;const y=(m=e[f])!==null&&m!==void 0?m:[];if(e[f]=this.cloneDeep(p),y.length>0){const v=e[f].map(S=>S.presence_ref),b=y.filter(S=>v.indexOf(S.presence_ref)<0);e[f].unshift(...b)}r(f,y,p)}),this.map(d,(f,p)=>{let m=e[f];if(!m)return;const y=p.map(v=>v.presence_ref);m=m.filter(v=>y.indexOf(v.presence_ref)<0),e[f]=m,l(f,m,p),m.length===0&&delete e[f]}),e}static map(e,n){return Object.getOwnPropertyNames(e).map(r=>n(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((n,r)=>{const l=e[r];return"metas"in l?n[r]=l.metas.map(u=>(u.presence_ref=u.phx_ref,delete u.phx_ref,delete u.phx_ref_prev,u)):n[r]=l,n},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var P0;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(P0||(P0={}));var Mo;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Mo||(Mo={}));var pn;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(pn||(pn={}));class li{constructor(e,n={config:{}},r){var l,u;if(this.topic=e,this.params=n,this.socket=r,this.bindings={},this.state=wt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new tf(this,Ds.join,this.params,this.timeout),this.rejoinTimer=new uw(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=wt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(d=>d.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=wt.closed,this.socket._remove(this)}),this._onError(d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=wt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=wt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=wt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Ds.reply,{},(d,f)=>{this._trigger(this._replyEventName(f),d)}),this.presence=new Do(this),this.broadcastEndpointURL=hw(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((u=(l=this.params.config)===null||l===void 0?void 0:l.broadcast)===null||u===void 0)&&u.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,n=this.timeout){var r,l,u;if(this.socket.isConnected()||this.socket.connect(),this.state==wt.closed){const{config:{broadcast:d,presence:f,private:p}}=this.params,m=(l=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(S=>S.filter))!==null&&l!==void 0?l:[],y=!!this.bindings[Mo.PRESENCE]&&this.bindings[Mo.PRESENCE].length>0||((u=this.params.config.presence)===null||u===void 0?void 0:u.enabled)===!0,v={},b={broadcast:d,presence:Object.assign(Object.assign({},f),{enabled:y}),postgres_changes:m,private:p};this.socket.accessTokenValue&&(v.access_token=this.socket.accessTokenValue),this._onError(S=>e?.(pn.CHANNEL_ERROR,S)),this._onClose(()=>e?.(pn.CLOSED)),this.updateJoinPayload(Object.assign({config:b},v)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:S})=>{var _;if(this.socket._isManualToken()||this.socket.setAuth(),S===void 0){e?.(pn.SUBSCRIBED);return}else{const N=this.bindings.postgres_changes,E=(_=N?.length)!==null&&_!==void 0?_:0,T=[];for(let D=0;D<E;D++){const A=N[D],{filter:{event:U,schema:H,table:G,filter:z}}=A,M=S&&S[D];if(M&&M.event===U&&li.isFilterValueEqual(M.schema,H)&&li.isFilterValueEqual(M.table,G)&&li.isFilterValueEqual(M.filter,z))T.push(Object.assign(Object.assign({},A),{id:M.id}));else{this.unsubscribe(),this.state=wt.errored,e?.(pn.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=T,e&&e(pn.SUBSCRIBED);return}}).receive("error",S=>{this.state=wt.errored,e?.(pn.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(S).join(", ")||"error")))}).receive("timeout",()=>{e?.(pn.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,n={}){return await this.send({type:"presence",event:"track",payload:e},n.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,n,r){return this.state===wt.joined&&e===Mo.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe())),this._on(e,n,r)}async httpSend(e,n,r={}){var l;if(n==null)return Promise.reject("Payload is required for httpSend()");const u={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(u.Authorization=`Bearer ${this.socket.accessTokenValue}`);const d={method:"POST",headers:u,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:n,private:this.private}]})},f=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(l=r.timeout)!==null&&l!==void 0?l:this.timeout);if(f.status===202)return{success:!0};let p=f.statusText;try{const m=await f.json();p=m.error||m.message||p}catch{}return Promise.reject(new Error(p))}async send(e,n={}){var r,l;if(!this._canPush()&&e.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:u,payload:d}=e,f={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(f.Authorization=`Bearer ${this.socket.accessTokenValue}`);const p={method:"POST",headers:f,body:JSON.stringify({messages:[{topic:this.subTopic,event:u,payload:d,private:this.private}]})};try{const m=await this._fetchWithTimeout(this.broadcastEndpointURL,p,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((l=m.body)===null||l===void 0?void 0:l.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(u=>{var d,f,p;const m=this._push(e.type,e,n.timeout||this.timeout);e.type==="broadcast"&&!(!((p=(f=(d=this.params)===null||d===void 0?void 0:d.config)===null||f===void 0?void 0:f.broadcast)===null||p===void 0)&&p.ack)&&u("ok"),m.receive("ok",()=>u("ok")),m.receive("error",()=>u("error")),m.receive("timeout",()=>u("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=wt.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Ds.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(l=>{r=new tf(this,Ds.leave,{},e),r.receive("ok",()=>{n(),l("ok")}).receive("timeout",()=>{n(),l("timed out")}).receive("error",()=>{l("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r?.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=wt.closed,this.bindings={}}async _fetchWithTimeout(e,n,r){const l=new AbortController,u=setTimeout(()=>l.abort(),r),d=await this.socket.fetch(e,Object.assign(Object.assign({},n),{signal:l.signal}));return clearTimeout(u),d}_push(e,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let l=new tf(this,e,n,r);return this._canPush()?l.send():this._addToPushBuffer(l),l}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>U2){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(e,n,r){return n}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,n,r){var l,u;const d=e.toLocaleLowerCase(),{close:f,error:p,leave:m,join:y}=Ds;if(r&&[f,p,m,y].indexOf(d)>=0&&r!==this._joinRef())return;let b=this._onMessage(d,n,r);if(n&&!b)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(d)?(l=this.bindings.postgres_changes)===null||l===void 0||l.filter(S=>{var _,N,E;return((_=S.filter)===null||_===void 0?void 0:_.event)==="*"||((E=(N=S.filter)===null||N===void 0?void 0:N.event)===null||E===void 0?void 0:E.toLocaleLowerCase())===d}).map(S=>S.callback(b,r)):(u=this.bindings[d])===null||u===void 0||u.filter(S=>{var _,N,E,T,D,A,U,H;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in S){const G=S.id,z=(_=S.filter)===null||_===void 0?void 0:_.event;return G&&((N=n.ids)===null||N===void 0?void 0:N.includes(G))&&(z==="*"||z?.toLocaleLowerCase()===((E=n.data)===null||E===void 0?void 0:E.type.toLocaleLowerCase()))&&(!(!((T=S.filter)===null||T===void 0)&&T.table)||S.filter.table===((D=n.data)===null||D===void 0?void 0:D.table))}else{const G=(U=(A=S?.filter)===null||A===void 0?void 0:A.event)===null||U===void 0?void 0:U.toLocaleLowerCase();return G==="*"||G===((H=n?.event)===null||H===void 0?void 0:H.toLocaleLowerCase())}else return S.type.toLocaleLowerCase()===d}).map(S=>{if(typeof b=="object"&&"ids"in b){const _=b.data,{schema:N,table:E,commit_timestamp:T,type:D,errors:A}=_;b=Object.assign(Object.assign({},{schema:N,table:E,commit_timestamp:T,eventType:D,new:{},old:{},errors:A}),this._getPayloadRecords(_))}S.callback(b,r)})}_isClosed(){return this.state===wt.closed}_isJoined(){return this.state===wt.joined}_isJoining(){return this.state===wt.joining}_isLeaving(){return this.state===wt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,n,r){const l=e.toLocaleLowerCase(),u={type:l,filter:n,callback:r};return this.bindings[l]?this.bindings[l].push(u):this.bindings[l]=[u],this}_off(e,n){const r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(l=>{var u;return!(((u=l.type)===null||u===void 0?void 0:u.toLocaleLowerCase())===r&&li.isEqual(l.filter,n))})),this}static isEqual(e,n){if(Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}static isFilterValueEqual(e,n){return(e??void 0)===(n??void 0)}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(Ds.close,{},e)}_onError(e){this._on(Ds.error,{},n=>e(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=wt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const n={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(n.new=L0(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(n.old=L0(e.columns,e.old_record)),n}}const sf=()=>{},Mc={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},G2=[1e3,2e3,5e3,1e4],F2=1e4,K2=`
|
|
17
|
+
addEventListener("message", (e) => {
|
|
18
|
+
if (e.data.event === "start") {
|
|
19
|
+
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
20
|
+
}
|
|
21
|
+
});`;class Y2{constructor(e,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Vf,this.transport=null,this.heartbeatIntervalMs=Mc.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=sf,this.ref=0,this.reconnectTimer=null,this.vsn=z0,this.logger=sf,this.conn=null,this.sendBuffer=[],this.serializer=new P2,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._heartbeatSentAt=null,this._resolveFetch=l=>l?(...u)=>l(...u):(...u)=>fetch(...u),!(!((r=n?.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${e}/${Bf.websocket}`,this.httpEndpoint=hw(e),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=O2.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const n=e.message;throw n.includes("Node.js")?new Error(`${n}
|
|
22
|
+
|
|
23
|
+
To use Realtime in Node.js, you need to provide a WebSocket implementation:
|
|
24
|
+
|
|
25
|
+
Option 1: Use Node.js 22+ which has native WebSocket support
|
|
26
|
+
Option 2: Install and provide the "ws" package:
|
|
27
|
+
|
|
28
|
+
npm install ws
|
|
29
|
+
|
|
30
|
+
import ws from "ws"
|
|
31
|
+
const client = new RealtimeClient(url, {
|
|
32
|
+
...options,
|
|
33
|
+
transport: ws
|
|
34
|
+
})`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(e?this.conn.close(e,n??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const n=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const e=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,n,r){this.logger(e,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case Wn.connecting:return Ba.Connecting;case Wn.open:return Ba.Open;case Wn.closing:return Ba.Closing;default:return Ba.Closed}}isConnected(){return this.connectionState()===Ba.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,n={config:{}}){const r=`realtime:${e}`,l=this.getChannels().find(u=>u.topic===r);if(l)return l;{const u=new li(`realtime:${e}`,n,this);return this.channels.push(u),u}}push(e){const{topic:n,event:r,payload:l,ref:u}=e,d=()=>{this.encode(e,f=>{var p;(p=this.conn)===null||p===void 0||p.send(f)})};this.log("push",`${n} ${r} (${u})`,l),this.isConnected()?d():this.sendBuffer.push(d)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this._heartbeatSentAt=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(L2,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},Mc.HEARTBEAT_TIMEOUT_FALLBACK);return}this._heartbeatSentAt=Date.now(),this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let n=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${e}"`),n.unsubscribe())}_remove(e){this.channels=this.channels.filter(n=>n.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,n=>{if(n.topic==="phoenix"&&n.event==="phx_reply"&&n.ref&&n.ref===this.pendingHeartbeatRef){const m=this._heartbeatSentAt?Date.now()-this._heartbeatSentAt:void 0;try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error",m)}catch(y){this.log("error","error in heartbeat callback",y)}this._heartbeatSentAt=null,this.pendingHeartbeatRef=null}const{topic:r,event:l,payload:u,ref:d}=n,f=d?`(${d})`:"",p=u.status||"";this.log("receive",`${p} ${r} ${l} ${f}`.trim(),u),this.channels.filter(m=>m._isMember(r)).forEach(m=>m._trigger(l,u,d)),this._triggerStateCallbacks("message",n)})}_clearTimer(e){var n;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e),this.conn.readyState===Wn.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===Wn.open||this.conn.readyState===Wn.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this._terminateWorker(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(n=>{this.log("error","error waiting for auth on connect",n),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this._terminateWorker()},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)}_onConnClose(e){var n;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(Ds.error))}_appendParams(e,n){if(Object.keys(n).length===0)return e;const r=e.match(/\?/)?"&":"?",l=new URLSearchParams(n);return`${e}${r}${l}`}_workerObjectUrl(e){let n;if(e)n=e;else{const r=new Blob([K2],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(e,n=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(e=null){let n,r=!1;if(e)n=e,r=!0;else if(this.accessToken)try{n=await this.accessToken()}catch(l){this.log("error","Error fetching access token from callback",l),n=this.accessTokenValue}else n=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(l=>{const u={access_token:n,version:M2};n&&l.updateJoinPayload(u),l.joinedOnce&&l._isJoined()&&l._push(Ds.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(n=>{this.log("error",`Error setting auth in ${e}`,n)})}_triggerStateCallbacks(e,n){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(n)}catch(l){this.log("error",`error in ${e} callback`,l)}})}catch(r){this.log("error",`error triggering ${e} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new uw(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Mc.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var n,r,l,u,d,f,p,m,y,v,b,S;switch(this.transport=(n=e?.transport)!==null&&n!==void 0?n:null,this.timeout=(r=e?.timeout)!==null&&r!==void 0?r:Vf,this.heartbeatIntervalMs=(l=e?.heartbeatIntervalMs)!==null&&l!==void 0?l:Mc.HEARTBEAT_INTERVAL,this.worker=(u=e?.worker)!==null&&u!==void 0?u:!1,this.accessToken=(d=e?.accessToken)!==null&&d!==void 0?d:null,this.heartbeatCallback=(f=e?.heartbeatCallback)!==null&&f!==void 0?f:sf,this.vsn=(p=e?.vsn)!==null&&p!==void 0?p:z0,e?.params&&(this.params=e.params),e?.logger&&(this.logger=e.logger),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(m=e?.reconnectAfterMs)!==null&&m!==void 0?m:(_=>G2[_-1]||F2),this.vsn){case cw:this.encode=(y=e?.encode)!==null&&y!==void 0?y:((_,N)=>N(JSON.stringify(_))),this.decode=(v=e?.decode)!==null&&v!==void 0?v:((_,N)=>N(JSON.parse(_)));break;case z2:this.encode=(b=e?.encode)!==null&&b!==void 0?b:this.serializer.encode.bind(this.serializer),this.decode=(S=e?.decode)!==null&&S!==void 0?S:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl}}}var qo=class extends Error{constructor(t,e){super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&e.icebergType?.includes("CommitState")===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function X2(t,e,n){const r=new URL(e,t);if(n)for(const[l,u]of Object.entries(n))u!==void 0&&r.searchParams.set(l,u);return r.toString()}async function W2(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function J2(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:n,path:r,query:l,body:u,headers:d}){const f=X2(t.baseUrl,r,l),p=await W2(t.auth),m=await e(f,{method:n,headers:{...u?{"Content-Type":"application/json"}:{},...p,...d},body:u?JSON.stringify(u):void 0}),y=await m.text(),v=(m.headers.get("content-type")||"").includes("application/json"),b=v&&y?JSON.parse(y):y;if(!m.ok){const S=v?b:void 0,_=S?.error;throw new qo(_?.message??`Request failed with status ${m.status}`,{status:m.status,icebergType:_?.type,icebergCode:_?.code,details:S})}return{status:m.status,headers:m.headers,data:b}}}}function zc(t){return t.join("")}var Q2=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:zc(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(r=>({namespace:r}))}async createNamespace(t,e){const n={namespace:t.namespace,properties:e?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${zc(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${zc(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${zc(t.namespace)}`}),!0}catch(e){if(e instanceof qo&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(n){if(n instanceof qo&&n.status===409)return;throw n}}};function Wr(t){return t.join("")}var Z2=class{constructor(t,e="",n){this.client=t,this.prefix=e,this.accessDelegation=n}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Wr(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const n={};return this.accessDelegation&&(n["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Wr(t.namespace)}/tables`,body:e,headers:n})).data.metadata}async updateTable(t,e){const n=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Wr(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":n.data["metadata-location"],metadata:n.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Wr(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String(e?.purge??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Wr(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Wr(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(n){if(n instanceof qo&&n.status===404)return!1;throw n}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(n){if(n instanceof qo&&n.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw n}}},eA=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const n=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=J2({baseUrl:n,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new Q2(this.client,e),this.tableOps=new Z2(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}},Nu=class extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}};function tt(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var tA=class extends Nu{constructor(t,e,n){super(t),this.name="StorageApiError",this.status=e,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},$f=class extends Nu{constructor(t,e){super(t),this.name="StorageUnknownError",this.originalError=e}};const zm=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),sA=()=>Response,qf=t=>{if(Array.isArray(t))return t.map(n=>qf(n));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([n,r])=>{const l=n.replace(/([-_][a-z])/gi,u=>u.toUpperCase().replace(/[-_]/g,""));e[l]=qf(r)}),e},nA=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},aA=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t);function Ho(t){"@babel/helpers - typeof";return Ho=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ho(t)}function rA(t,e){if(Ho(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Ho(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function iA(t){var e=rA(t,"string");return Ho(e)=="symbol"?e:e+""}function oA(t,e,n){return(e=iA(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),n.push.apply(n,r)}return n}function xe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V0(Object(n),!0).forEach(function(r){oA(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const nf=t=>{var e;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(e=t.error)===null||e===void 0?void 0:e.message)||JSON.stringify(t)},lA=async(t,e,n)=>{t instanceof await sA()&&!n?.noResolveJson?t.json().then(r=>{const l=t.status||500,u=r?.statusCode||l+"";e(new tA(nf(r),l,u))}).catch(r=>{e(new $f(nf(r),r))}):e(new $f(nf(t),t))},cA=(t,e,n,r)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"||!r?l:(nA(r)?(l.headers=xe({"Content-Type":"application/json"},e?.headers),l.body=JSON.stringify(r)):l.body=r,e?.duplex&&(l.duplex=e.duplex),xe(xe({},l),n))};async function sl(t,e,n,r,l,u){return new Promise((d,f)=>{t(n,cA(e,r,l,u)).then(p=>{if(!p.ok)throw p;return r?.noResolveJson?p:p.json()}).then(p=>d(p)).catch(p=>lA(p,f,r))})}async function Go(t,e,n,r){return sl(t,"GET",e,n,r)}async function Os(t,e,n,r,l){return sl(t,"POST",e,r,l,n)}async function Hf(t,e,n,r,l){return sl(t,"PUT",e,r,l,n)}async function uA(t,e,n,r){return sl(t,"HEAD",e,xe(xe({},n),{},{noResolveJson:!0}),r)}async function Lm(t,e,n,r,l){return sl(t,"DELETE",e,r,l,n)}var dA=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e}then(t,e){return this.execute().then(t,e)}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(tt(e))return{data:null,error:e};throw e}}};let fw;fw=Symbol.toStringTag;var hA=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[fw]="BlobDownloadBuilder",this.promise=null}asStream(){return new dA(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(tt(e))return{data:null,error:e};throw e}}};const fA={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},B0={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var mA=class{constructor(t,e={},n,r){this.shouldThrowOnError=!1,this.url=t,this.headers=e,this.bucketId=n,this.fetch=zm(r)}throwOnError(){return this.shouldThrowOnError=!0,this}async uploadOrUpdate(t,e,n,r){var l=this;try{let u;const d=xe(xe({},B0),r);let f=xe(xe({},l.headers),t==="POST"&&{"x-upsert":String(d.upsert)});const p=d.metadata;typeof Blob<"u"&&n instanceof Blob?(u=new FormData,u.append("cacheControl",d.cacheControl),p&&u.append("metadata",l.encodeMetadata(p)),u.append("",n)):typeof FormData<"u"&&n instanceof FormData?(u=n,u.has("cacheControl")||u.append("cacheControl",d.cacheControl),p&&!u.has("metadata")&&u.append("metadata",l.encodeMetadata(p))):(u=n,f["cache-control"]=`max-age=${d.cacheControl}`,f["content-type"]=d.contentType,p&&(f["x-metadata"]=l.toBase64(l.encodeMetadata(p))),(typeof ReadableStream<"u"&&u instanceof ReadableStream||u&&typeof u=="object"&&"pipe"in u&&typeof u.pipe=="function")&&!d.duplex&&(d.duplex="half")),r?.headers&&(f=xe(xe({},f),r.headers));const m=l._removeEmptyFolders(e),y=l._getFinalPath(m),v=await(t=="PUT"?Hf:Os)(l.fetch,`${l.url}/object/${y}`,u,xe({headers:f},d?.duplex?{duplex:d.duplex}:{}));return{data:{path:m,id:v.Id,fullPath:v.Key},error:null}}catch(u){if(l.shouldThrowOnError)throw u;if(tt(u))return{data:null,error:u};throw u}}async upload(t,e,n){return this.uploadOrUpdate("POST",t,e,n)}async uploadToSignedUrl(t,e,n,r){var l=this;const u=l._removeEmptyFolders(t),d=l._getFinalPath(u),f=new URL(l.url+`/object/upload/sign/${d}`);f.searchParams.set("token",e);try{let p;const m=xe({upsert:B0.upsert},r),y=xe(xe({},l.headers),{"x-upsert":String(m.upsert)});return typeof Blob<"u"&&n instanceof Blob?(p=new FormData,p.append("cacheControl",m.cacheControl),p.append("",n)):typeof FormData<"u"&&n instanceof FormData?(p=n,p.append("cacheControl",m.cacheControl)):(p=n,y["cache-control"]=`max-age=${m.cacheControl}`,y["content-type"]=m.contentType),{data:{path:u,fullPath:(await Hf(l.fetch,f.toString(),p,{headers:y})).Key},error:null}}catch(p){if(l.shouldThrowOnError)throw p;if(tt(p))return{data:null,error:p};throw p}}async createSignedUploadUrl(t,e){var n=this;try{let r=n._getFinalPath(t);const l=xe({},n.headers);e?.upsert&&(l["x-upsert"]="true");const u=await Os(n.fetch,`${n.url}/object/upload/sign/${r}`,{},{headers:l}),d=new URL(n.url+u.url),f=d.searchParams.get("token");if(!f)throw new Nu("No token returned by API");return{data:{signedUrl:d.toString(),path:t,token:f},error:null}}catch(r){if(n.shouldThrowOnError)throw r;if(tt(r))return{data:null,error:r};throw r}}async update(t,e,n){return this.uploadOrUpdate("PUT",t,e,n)}async move(t,e,n){var r=this;try{return{data:await Os(r.fetch,`${r.url}/object/move`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:n?.destinationBucket},{headers:r.headers}),error:null}}catch(l){if(r.shouldThrowOnError)throw l;if(tt(l))return{data:null,error:l};throw l}}async copy(t,e,n){var r=this;try{return{data:{path:(await Os(r.fetch,`${r.url}/object/copy`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:n?.destinationBucket},{headers:r.headers})).Key},error:null}}catch(l){if(r.shouldThrowOnError)throw l;if(tt(l))return{data:null,error:l};throw l}}async createSignedUrl(t,e,n){var r=this;try{let l=r._getFinalPath(t),u=await Os(r.fetch,`${r.url}/object/sign/${l}`,xe({expiresIn:e},n?.transform?{transform:n.transform}:{}),{headers:r.headers});const d=n?.download?`&download=${n.download===!0?"":n.download}`:"";return u={signedUrl:encodeURI(`${r.url}${u.signedURL}${d}`)},{data:u,error:null}}catch(l){if(r.shouldThrowOnError)throw l;if(tt(l))return{data:null,error:l};throw l}}async createSignedUrls(t,e,n){var r=this;try{const l=await Os(r.fetch,`${r.url}/object/sign/${r.bucketId}`,{expiresIn:e,paths:t},{headers:r.headers}),u=n?.download?`&download=${n.download===!0?"":n.download}`:"";return{data:l.map(d=>xe(xe({},d),{},{signedUrl:d.signedURL?encodeURI(`${r.url}${d.signedURL}${u}`):null})),error:null}}catch(l){if(r.shouldThrowOnError)throw l;if(tt(l))return{data:null,error:l};throw l}}download(t,e){const n=typeof e?.transform<"u"?"render/image/authenticated":"object",r=this.transformOptsToQueryString(e?.transform||{}),l=r?`?${r}`:"",u=this._getFinalPath(t),d=()=>Go(this.fetch,`${this.url}/${n}/${u}${l}`,{headers:this.headers,noResolveJson:!0});return new hA(d,this.shouldThrowOnError)}async info(t){var e=this;const n=e._getFinalPath(t);try{return{data:qf(await Go(e.fetch,`${e.url}/object/info/${n}`,{headers:e.headers})),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(tt(r))return{data:null,error:r};throw r}}async exists(t){var e=this;const n=e._getFinalPath(t);try{return await uA(e.fetch,`${e.url}/object/${n}`,{headers:e.headers}),{data:!0,error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(tt(r)&&r instanceof $f){const l=r.originalError;if([400,404].includes(l?.status))return{data:!1,error:r}}throw r}}getPublicUrl(t,e){const n=this._getFinalPath(t),r=[],l=e?.download?`download=${e.download===!0?"":e.download}`:"";l!==""&&r.push(l);const u=typeof e?.transform<"u"?"render/image":"object",d=this.transformOptsToQueryString(e?.transform||{});d!==""&&r.push(d);let f=r.join("&");return f!==""&&(f=`?${f}`),{data:{publicUrl:encodeURI(`${this.url}/${u}/public/${n}${f}`)}}}async remove(t){var e=this;try{return{data:await Lm(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}async list(t,e,n){var r=this;try{const l=xe(xe(xe({},fA),e),{},{prefix:t||""});return{data:await Os(r.fetch,`${r.url}/object/list/${r.bucketId}`,l,{headers:r.headers},n),error:null}}catch(l){if(r.shouldThrowOnError)throw l;if(tt(l))return{data:null,error:l};throw l}}async listV2(t,e){var n=this;try{const r=xe({},t);return{data:await Os(n.fetch,`${n.url}/object/list-v2/${n.bucketId}`,r,{headers:n.headers},e),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if(tt(r))return{data:null,error:r};throw r}}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const e=[];return t.width&&e.push(`width=${t.width}`),t.height&&e.push(`height=${t.height}`),t.resize&&e.push(`resize=${t.resize}`),t.format&&e.push(`format=${t.format}`),t.quality&&e.push(`quality=${t.quality}`),e.join("&")}};const mw="2.90.1",pw={"X-Client-Info":`storage-js/${mw}`};var pA=class{constructor(t,e={},n,r){this.shouldThrowOnError=!1;const l=new URL(t);r?.useNewHostname&&/supabase\.(co|in|red)$/.test(l.hostname)&&!l.hostname.includes("storage.supabase.")&&(l.hostname=l.hostname.replace("supabase.","storage.supabase.")),this.url=l.href.replace(/\/$/,""),this.headers=xe(xe({},pw),e),this.fetch=zm(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async listBuckets(t){var e=this;try{const n=e.listBucketOptionsToQueryString(t);return{data:await Go(e.fetch,`${e.url}/bucket${n}`,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}async getBucket(t){var e=this;try{return{data:await Go(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}async createBucket(t,e={public:!1}){var n=this;try{return{data:await Os(n.fetch,`${n.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:n.headers}),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if(tt(r))return{data:null,error:r};throw r}}async updateBucket(t,e){var n=this;try{return{data:await Hf(n.fetch,`${n.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:n.headers}),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if(tt(r))return{data:null,error:r};throw r}}async emptyBucket(t){var e=this;try{return{data:await Os(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}async deleteBucket(t){var e=this;try{return{data:await Lm(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},gA=class{constructor(t,e={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=xe(xe({},pw),e),this.fetch=zm(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async createBucket(t){var e=this;try{return{data:await Os(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}async listBuckets(t){var e=this;try{const n=new URLSearchParams;t?.limit!==void 0&&n.set("limit",t.limit.toString()),t?.offset!==void 0&&n.set("offset",t.offset.toString()),t?.sortColumn&&n.set("sortColumn",t.sortColumn),t?.sortOrder&&n.set("sortOrder",t.sortOrder),t?.search&&n.set("search",t.search);const r=n.toString(),l=r?`${e.url}/bucket?${r}`:`${e.url}/bucket`;return{data:await Go(e.fetch,l,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}async deleteBucket(t){var e=this;try{return{data:await Lm(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(tt(n))return{data:null,error:n};throw n}}from(t){var e=this;if(!aA(t))throw new Nu("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 eA({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),r=this.shouldThrowOnError;return new Proxy(n,{get(l,u){const d=l[u];return typeof d!="function"?d:async(...f)=>{try{return{data:await d.apply(l,f),error:null}}catch(p){if(r)throw p;return{data:null,error:p}}}}})}};const Um={"X-Client-Info":`storage-js/${mw}`,"Content-Type":"application/json"};var gw=class extends Error{constructor(t){super(t),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}};function is(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}var af=class extends gw{constructor(t,e,n){super(t),this.name="StorageVectorsApiError",this.status=e,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},yA=class extends gw{constructor(t,e){super(t),this.name="StorageVectorsUnknownError",this.originalError=e}};const Pm=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),vA=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},I0=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),xA=async(t,e,n)=>{if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!n?.noResolveJson){const r=t.status||500,l=t;if(typeof l.json=="function")l.json().then(u=>{const d=u?.statusCode||u?.code||r+"";e(new af(I0(u),r,d))}).catch(()=>{const u=r+"";e(new af(l.statusText||`HTTP ${r} error`,r,u))});else{const u=r+"";e(new af(l.statusText||`HTTP ${r} error`,r,u))}}else e(new yA(I0(t),t))},bA=(t,e,n,r)=>{const l={method:t,headers:e?.headers||{}};return r?(vA(r)?(l.headers=xe({"Content-Type":"application/json"},e?.headers),l.body=JSON.stringify(r)):l.body=r,xe(xe({},l),n)):l};async function wA(t,e,n,r,l,u){return new Promise((d,f)=>{t(n,bA(e,r,l,u)).then(p=>{if(!p.ok)throw p;if(r?.noResolveJson)return p;const m=p.headers.get("content-type");return!m||!m.includes("application/json")?{}:p.json()}).then(p=>d(p)).catch(p=>xA(p,f,r))})}async function os(t,e,n,r,l){return wA(t,"POST",e,r,l,n)}var SA=class{constructor(t,e={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=xe(xe({},Um),e),this.fetch=Pm(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async createIndex(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{},error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async getIndex(t,e){var n=this;try{return{data:await os(n.fetch,`${n.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:n.headers}),error:null}}catch(r){if(n.shouldThrowOnError)throw r;if(is(r))return{data:null,error:r};throw r}}async listIndexes(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async deleteIndex(t,e){var n=this;try{return{data:await os(n.fetch,`${n.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:n.headers})||{},error:null}}catch(r){if(n.shouldThrowOnError)throw r;if(is(r))return{data:null,error:r};throw r}}},_A=class{constructor(t,e={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=xe(xe({},Um),e),this.fetch=Pm(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async putVectors(t){var e=this;try{if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:await os(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{},error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async getVectors(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async listVectors(t){var e=this;try{if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return{data:await os(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async queryVectors(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async deleteVectors(t){var e=this;try{if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:await os(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{},error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}},jA=class{constructor(t,e={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=xe(xe({},Um),e),this.fetch=Pm(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async createBucket(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{},error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async getBucket(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async listBuckets(t={}){var e=this;try{return{data:await os(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}async deleteBucket(t){var e=this;try{return{data:await os(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{},error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(is(n))return{data:null,error:n};throw n}}},NA=class extends jA{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new EA(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,n=this;return e().call(n,t)}async getBucket(t){var e=()=>super.getBucket,n=this;return e().call(n,t)}async listBuckets(t={}){var e=()=>super.listBuckets,n=this;return e().call(n,t)}async deleteBucket(t){var e=()=>super.deleteBucket,n=this;return e().call(n,t)}},EA=class extends SA{constructor(t,e,n,r){super(t,e,r),this.vectorBucketName=n}async createIndex(t){var e=()=>super.createIndex,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,n=this;return e().call(n,n.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,n=this;return e().call(n,n.vectorBucketName,t)}index(t){return new TA(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},TA=class extends _A{constructor(t,e,n,r,l){super(t,e,l),this.vectorBucketName=n,this.indexName=r}async putVectors(t){var e=()=>super.putVectors,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async getVectors(t){var e=()=>super.getVectors,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,n=this;return e().call(n,xe(xe({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}},AA=class extends pA{constructor(t,e={},n,r){super(t,e,n,r)}from(t){return new mA(this.url,this.headers,t,this.fetch)}get vectors(){return new NA(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new gA(this.url+"/iceberg",this.headers,this.fetch)}};const yw="2.90.1",ii=30*1e3,Gf=3,rf=Gf*ii,kA="http://localhost:9999",CA="supabase.auth.token",RA={"X-Client-Info":`gotrue-js/${yw}`},Ff="X-Supabase-Api-Version",vw={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},OA=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,DA=600*1e3;class Fo extends Error{constructor(e,n,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function fe(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class MA extends Fo{constructor(e,n,r){super(e,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function zA(t){return fe(t)&&t.name==="AuthApiError"}class Ia extends Fo{constructor(e,n){super(e),this.name="AuthUnknownError",this.originalError=n}}class bn extends Fo{constructor(e,n,r,l){super(e,r,l),this.name=n,this.status=r}}class rs extends bn{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function LA(t){return fe(t)&&t.name==="AuthSessionMissingError"}class Jr extends bn{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Lc extends bn{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Uc extends bn{constructor(e,n=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function UA(t){return fe(t)&&t.name==="AuthImplicitGrantRedirectError"}class $0 extends bn{constructor(e,n=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class PA extends bn{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 Kf extends bn{constructor(e,n){super(e,"AuthRetryableFetchError",n,void 0)}}function of(t){return fe(t)&&t.name==="AuthRetryableFetchError"}class q0 extends bn{constructor(e,n,r){super(e,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class Yf extends bn{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const cu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),H0=`
|
|
35
|
+
\r=`.split(""),VA=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<H0.length;e+=1)t[H0[e].charCodeAt(0)]=-2;for(let e=0;e<cu.length;e+=1)t[cu[e].charCodeAt(0)]=e;return t})();function G0(t,e,n){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(cu[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(cu[r]),e.queuedBits-=6}}function xw(t,e,n){const r=VA[t];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)n(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function F0(t){const e=[],n=d=>{e.push(String.fromCodePoint(d))},r={utf8seq:0,codepoint:0},l={queue:0,queuedBits:0},u=d=>{$A(d,r,n)};for(let d=0;d<t.length;d+=1)xw(t.charCodeAt(d),l,u);return e.join("")}function BA(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function IA(t,e){for(let n=0;n<t.length;n+=1){let r=t.charCodeAt(n);if(r>55295&&r<=56319){const l=(r-55296)*1024&65535;r=(t.charCodeAt(n+1)-56320&65535|l)+65536,n+=1}BA(r,e)}}function $A(t,e,n){if(e.utf8seq===0){if(t<=127){n(t);return}for(let r=1;r<6;r+=1)if((t>>7-r&1)===0){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&n(e.codepoint)}}function mi(t){const e=[],n={queue:0,queuedBits:0},r=l=>{e.push(l)};for(let l=0;l<t.length;l+=1)xw(t.charCodeAt(l),n,r);return new Uint8Array(e)}function qA(t){const e=[];return IA(t,n=>e.push(n)),new Uint8Array(e)}function Ha(t){const e=[],n={queue:0,queuedBits:0},r=l=>{e.push(l)};return t.forEach(l=>G0(l,n,r)),G0(null,n,r),e.join("")}function HA(t){return Math.round(Date.now()/1e3)+t}function GA(){return Symbol("auth-callback")}const Mt=()=>typeof window<"u"&&typeof document<"u",Ma={tested:!1,writable:!1},bw=()=>{if(!Mt())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ma.tested)return Ma.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Ma.tested=!0,Ma.writable=!0}catch{Ma.tested=!0,Ma.writable=!1}return Ma.writable};function FA(t){const e={},n=new URL(t);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((l,u)=>{e[u]=l})}catch{}return n.searchParams.forEach((r,l)=>{e[l]=r}),e}const ww=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),KA=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",oi=async(t,e,n)=>{await t.setItem(e,JSON.stringify(n))},za=async(t,e)=>{const n=await t.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Dt=async(t,e)=>{await t.removeItem(e)};class Eu{constructor(){this.promise=new Eu.promiseConstructor((e,n)=>{this.resolve=e,this.reject=n})}}Eu.promiseConstructor=Promise;function lf(t){const e=t.split(".");if(e.length!==3)throw new Yf("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!OA.test(e[r]))throw new Yf("JWT not in base64url format");return{header:JSON.parse(F0(e[0])),payload:JSON.parse(F0(e[1])),signature:mi(e[2]),raw:{header:e[0],payload:e[1]}}}async function YA(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function XA(t,e){return new Promise((r,l)=>{(async()=>{for(let u=0;u<1/0;u++)try{const d=await t(u);if(!e(u,null,d)){r(d);return}}catch(d){if(!e(u,d)){l(d);return}}})()})}function WA(t){return("0"+t.toString(16)).substr(-2)}function JA(){const e=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let l="";for(let u=0;u<56;u++)l+=n.charAt(Math.floor(Math.random()*r));return l}return crypto.getRandomValues(e),Array.from(e,WA).join("")}async function QA(t){const n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),l=new Uint8Array(r);return Array.from(l).map(u=>String.fromCharCode(u)).join("")}async function ZA(t){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."),t;const n=await QA(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Qr(t,e,n=!1){const r=JA();let l=r;n&&(l+="/PASSWORD_RECOVERY"),await oi(t,`${e}-code-verifier`,l);const u=await ZA(r);return[u,r===u?"plain":"s256"]}const ek=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function tk(t){const e=t.headers.get(Ff);if(!e||!e.match(ek))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function sk(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function nk(t){switch(t){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 ak=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Zr(t){if(!ak.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function cf(){const t={};return new Proxy(t,{get:(e,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="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:(e,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:(e,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 rk(t,e){return new Proxy(t,{get:(n,r,l)=>{if(r==="__isInsecureUserWarningProxy")return!0;if(typeof r=="symbol"){const u=r.toString();if(u==="Symbol(Symbol.toPrimitive)"||u==="Symbol(Symbol.toStringTag)"||u==="Symbol(util.inspect.custom)"||u==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(n,r,l)}return!e.value&&typeof r=="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."),e.value=!0),Reflect.get(n,r,l)}})}function K0(t){return JSON.parse(JSON.stringify(t))}const Ua=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),ik=[502,503,504];async function Y0(t){var e;if(!KA(t))throw new Kf(Ua(t),0);if(ik.includes(t.status))throw new Kf(Ua(t),t.status);let n;try{n=await t.json()}catch(u){throw new Ia(Ua(u),u)}let r;const l=tk(t);if(l&&l.getTime()>=vw["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new q0(Ua(n),t.status,((e=n.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new rs}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((u,d)=>u&&typeof d=="string",!0))throw new q0(Ua(n),t.status,n.weak_password.reasons);throw new MA(Ua(n),t.status||500,r)}const ok=(t,e,n,r)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"?l:(l.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),l.body=JSON.stringify(r),Object.assign(Object.assign({},l),n))};async function ve(t,e,n,r){var l;const u=Object.assign({},r?.headers);u[Ff]||(u[Ff]=vw["2024-01-01"].name),r?.jwt&&(u.Authorization=`Bearer ${r.jwt}`);const d=(l=r?.query)!==null&&l!==void 0?l:{};r?.redirectTo&&(d.redirect_to=r.redirectTo);const f=Object.keys(d).length?"?"+new URLSearchParams(d).toString():"",p=await lk(t,e,n+f,{headers:u,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(p):{data:Object.assign({},p),error:null}}async function lk(t,e,n,r,l,u){const d=ok(e,r,l,u);let f;try{f=await t(n,Object.assign({},d))}catch(p){throw console.error(p),new Kf(Ua(p),0)}if(f.ok||await Y0(f),r?.noResolveJson)return f;try{return await f.json()}catch(p){await Y0(p)}}function Cs(t){var e;let n=null;dk(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=HA(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:n,user:r},error:null}}function X0(t){const e=Cs(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Jn(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function ck(t){return{data:t,error:null}}function uk(t){const{action_link:e,email_otp:n,hashed_token:r,redirect_to:l,verification_type:u}=t,d=_i(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),f={action_link:e,email_otp:n,hashed_token:r,redirect_to:l,verification_type:u},p=Object.assign({},d);return{data:{properties:f,user:p},error:null}}function W0(t){return t}function dk(t){return t.access_token&&t.refresh_token&&t.expires_in}const uf=["global","local","others"];class hk{constructor({url:e="",headers:n={},fetch:r}){this.url=e,this.headers=n,this.fetch=ww(r),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)}}async signOut(e,n=uf[0]){if(uf.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${uf.join(", ")}`);try{return await ve(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(fe(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,n={}){try{return await ve(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:Jn})}catch(r){if(fe(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:n}=e,r=_i(e,["options"]),l=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(l.new_email=r?.newEmail,delete l.newEmail),await ve(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:l,headers:this.headers,xform:uk,redirectTo:n?.redirectTo})}catch(n){if(fe(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(e){try{return await ve(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Jn})}catch(n){if(fe(n))return{data:{user:null},error:n};throw n}}async listUsers(e){var n,r,l,u,d,f,p;try{const m={nextPage:null,lastPage:0,total:0},y=await ve(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(u=(l=e?.perPage)===null||l===void 0?void 0:l.toString())!==null&&u!==void 0?u:""},xform:W0});if(y.error)throw y.error;const v=await y.json(),b=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,S=(p=(f=y.headers.get("link"))===null||f===void 0?void 0:f.split(","))!==null&&p!==void 0?p:[];return S.length>0&&(S.forEach(_=>{const N=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),E=JSON.parse(_.split(";")[1].split("=")[1]);m[`${E}Page`]=N}),m.total=parseInt(b)),{data:Object.assign(Object.assign({},v),m),error:null}}catch(m){if(fe(m))return{data:{users:[]},error:m};throw m}}async getUserById(e){Zr(e);try{return await ve(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Jn})}catch(n){if(fe(n))return{data:{user:null},error:n};throw n}}async updateUserById(e,n){Zr(e);try{return await ve(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:n,headers:this.headers,xform:Jn})}catch(r){if(fe(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,n=!1){Zr(e);try{return await ve(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:n},xform:Jn})}catch(r){if(fe(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){Zr(e.userId);try{const{data:n,error:r}=await ve(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:l=>({data:{factors:l},error:null})});return{data:n,error:r}}catch(n){if(fe(n))return{data:null,error:n};throw n}}async _deleteFactor(e){Zr(e.userId),Zr(e.id);try{return{data:await ve(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(n){if(fe(n))return{data:null,error:n};throw n}}async _listOAuthClients(e){var n,r,l,u,d,f,p;try{const m={nextPage:null,lastPage:0,total:0},y=await ve(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(u=(l=e?.perPage)===null||l===void 0?void 0:l.toString())!==null&&u!==void 0?u:""},xform:W0});if(y.error)throw y.error;const v=await y.json(),b=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,S=(p=(f=y.headers.get("link"))===null||f===void 0?void 0:f.split(","))!==null&&p!==void 0?p:[];return S.length>0&&(S.forEach(_=>{const N=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),E=JSON.parse(_.split(";")[1].split("=")[1]);m[`${E}Page`]=N}),m.total=parseInt(b)),{data:Object.assign(Object.assign({},v),m),error:null}}catch(m){if(fe(m))return{data:{clients:[]},error:m};throw m}}async _createOAuthClient(e){try{return await ve(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(fe(n))return{data:null,error:n};throw n}}async _getOAuthClient(e){try{return await ve(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(fe(n))return{data:null,error:n};throw n}}async _updateOAuthClient(e,n){try{return await ve(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:n,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(fe(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(e){try{return await ve(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(fe(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(e){try{return await ve(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(fe(n))return{data:null,error:n};throw n}}}function J0(t={}){return{getItem:e=>t[e]||null,setItem:(e,n)=>{t[e]=n},removeItem:e=>{delete t[e]}}}const ei={debug:!!(globalThis&&bw()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Sw extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class fk extends Sw{}async function mk(t,e,n){ei.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),ei.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async l=>{if(l){ei.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,l.name);try{return await n()}finally{ei.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,l.name)}}else{if(e===0)throw ei.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new fk(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(ei.debug)try{const u=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(u,null," "))}catch(u){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",u)}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"),await n()}}))}function pk(){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 _w(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function gk(t){return parseInt(t,16)}function yk(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function vk(t){var e;const{chainId:n,domain:r,expirationTime:l,issuedAt:u=new Date,nonce:d,notBefore:f,requestId:p,resources:m,scheme:y,uri:v,version:b}=t;{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(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(d&&d.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${d}`);if(!v)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(b!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${b}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
|
|
36
|
+
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const S=_w(t.address),_=y?`${y}://${r}`:r,N=t.statement?`${t.statement}
|
|
37
|
+
`:"",E=`${_} wants you to sign in with your Ethereum account:
|
|
38
|
+
${S}
|
|
39
|
+
|
|
40
|
+
${N}`;let T=`URI: ${v}
|
|
41
|
+
Version: ${b}
|
|
42
|
+
Chain ID: ${n}${d?`
|
|
43
|
+
Nonce: ${d}`:""}
|
|
44
|
+
Issued At: ${u.toISOString()}`;if(l&&(T+=`
|
|
45
|
+
Expiration Time: ${l.toISOString()}`),f&&(T+=`
|
|
46
|
+
Not Before: ${f.toISOString()}`),p&&(T+=`
|
|
47
|
+
Request ID: ${p}`),m){let D=`
|
|
48
|
+
Resources:`;for(const A of m){if(!A||typeof A!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${A}`);D+=`
|
|
49
|
+
- ${A}`}T+=D}return`${E}
|
|
50
|
+
${T}`}class gt extends Error{constructor({message:e,code:n,cause:r,name:l}){var u;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(u=l??(r instanceof Error?r.name:void 0))!==null&&u!==void 0?u:"Unknown Error",this.code=n}}class uu extends gt{constructor(e,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:e}),this.name="WebAuthnUnknownError",this.originalError=n}}function xk({error:t,options:e}){var n,r,l;const{publicKey:u}=e;if(!u)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new gt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((n=u.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new gt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((r=u.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new gt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((l=u.authenticatorSelection)===null||l===void 0?void 0:l.userVerification)==="required")return new gt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new gt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new gt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return u.pubKeyCredParams.filter(f=>f.type==="public-key").length===0?new gt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new gt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const d=window.location.hostname;if(jw(d)){if(u.rp.id!==d)return new gt({message:`The RP ID "${u.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new gt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(u.user.id.byteLength<1||u.user.id.byteLength>64)return new gt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new gt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new gt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function bk({error:t,options:e}){const{publicKey:n}=e;if(!n)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new gt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new gt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(jw(r)){if(n.rpId!==r)return new gt({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new gt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new gt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new gt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class wk{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const Sk=new wk;function _k(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:n,excludeCredentials:r}=t,l=_i(t,["challenge","user","excludeCredentials"]),u=mi(e).buffer,d=Object.assign(Object.assign({},n),{id:mi(n.id).buffer}),f=Object.assign(Object.assign({},l),{challenge:u,user:d});if(r&&r.length>0){f.excludeCredentials=new Array(r.length);for(let p=0;p<r.length;p++){const m=r[p];f.excludeCredentials[p]=Object.assign(Object.assign({},m),{id:mi(m.id).buffer,type:m.type||"public-key",transports:m.transports})}}return f}function jk(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:n}=t,r=_i(t,["challenge","allowCredentials"]),l=mi(e).buffer,u=Object.assign(Object.assign({},r),{challenge:l});if(n&&n.length>0){u.allowCredentials=new Array(n.length);for(let d=0;d<n.length;d++){const f=n[d];u.allowCredentials[d]=Object.assign(Object.assign({},f),{id:mi(f.id).buffer,type:f.type||"public-key",transports:f.transports})}}return u}function Nk(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t;return{id:t.id,rawId:t.id,response:{attestationObject:Ha(new Uint8Array(t.response.attestationObject)),clientDataJSON:Ha(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Ek(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t,r=t.getClientExtensionResults(),l=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Ha(new Uint8Array(l.authenticatorData)),clientDataJSON:Ha(new Uint8Array(l.clientDataJSON)),signature:Ha(new Uint8Array(l.signature)),userHandle:l.userHandle?Ha(new Uint8Array(l.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function jw(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function Q0(){var t,e;return!!(Mt()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Tk(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new uu("Browser returned unexpected credential type",e)}:{data:null,error:new uu("Empty credential response",e)}}catch(e){return{data:null,error:xk({error:e,options:t})}}}async function Ak(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new uu("Browser returned unexpected credential type",e)}:{data:null,error:new uu("Empty credential response",e)}}catch(e){return{data:null,error:bk({error:e,options:t})}}}const kk={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},Ck={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function du(...t){const e=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),n=l=>l instanceof ArrayBuffer||ArrayBuffer.isView(l),r={};for(const l of t)if(l)for(const u in l){const d=l[u];if(d!==void 0)if(Array.isArray(d))r[u]=d;else if(n(d))r[u]=d;else if(e(d)){const f=r[u];e(f)?r[u]=du(f,d):r[u]=du(d)}else r[u]=d}return r}function Rk(t,e){return du(kk,t,e||{})}function Ok(t,e){return du(Ck,t,e||{})}class Dk{constructor(e){this.client=e,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(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:n,friendlyName:r,signal:l},u){try{const{data:d,error:f}=await this.client.mfa.challenge({factorId:e,webauthn:n});if(!d)return{data:null,error:f};const p=l??Sk.createNewAbortSignal();if(d.webauthn.type==="create"){const{user:m}=d.webauthn.credential_options.publicKey;m.name||(m.name=`${m.id}:${r}`),m.displayName||(m.displayName=m.name)}switch(d.webauthn.type){case"create":{const m=Rk(d.webauthn.credential_options.publicKey,u?.create),{data:y,error:v}=await Tk({publicKey:m,signal:p});return y?{data:{factorId:e,challengeId:d.id,webauthn:{type:d.webauthn.type,credential_response:y}},error:null}:{data:null,error:v}}case"request":{const m=Ok(d.webauthn.credential_options.publicKey,u?.request),{data:y,error:v}=await Ak(Object.assign(Object.assign({},d.webauthn.credential_options),{publicKey:m,signal:p}));return y?{data:{factorId:e,challengeId:d.id,webauthn:{type:d.webauthn.type,credential_response:y}},error:null}:{data:null,error:v}}}}catch(d){return fe(d)?{data:null,error:d}:{data:null,error:new Ia("Unexpected error in challenge",d)}}}async _verify({challengeId:e,factorId:n,webauthn:r}){return this.client.mfa.verify({factorId:n,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!n)return{data:null,error:new Fo("rpId is required for WebAuthn authentication")};try{if(!Q0())return{data:null,error:new Ia("Browser does not support WebAuthn",null)};const{data:d,error:f}=await this.challenge({factorId:e,webauthn:{rpId:n,rpOrigins:r},signal:l},{request:u});if(!d)return{data:null,error:f};const{webauthn:p}=d;return this._verify({factorId:e,challengeId:d.challengeId,webauthn:{type:p.type,rpId:n,rpOrigins:r,credential_response:p.credential_response}})}catch(d){return fe(d)?{data:null,error:d}:{data:null,error:new Ia("Unexpected error in authenticate",d)}}}async _register({friendlyName:e,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!n)return{data:null,error:new Fo("rpId is required for WebAuthn registration")};try{if(!Q0())return{data:null,error:new Ia("Browser does not support WebAuthn",null)};const{data:d,error:f}=await this._enroll({friendlyName:e});if(!d)return await this.client.mfa.listFactors().then(y=>{var v;return(v=y.data)===null||v===void 0?void 0:v.all.find(b=>b.factor_type==="webauthn"&&b.friendly_name===e&&b.status!=="unverified")}).then(y=>y?this.client.mfa.unenroll({factorId:y?.id}):void 0),{data:null,error:f};const{data:p,error:m}=await this._challenge({factorId:d.id,friendlyName:d.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:l},{create:u});return p?this._verify({factorId:d.id,challengeId:p.challengeId,webauthn:{rpId:n,rpOrigins:r,type:p.webauthn.type,credential_response:p.webauthn.credential_response}}):{data:null,error:m}}catch(d){return fe(d)?{data:null,error:d}:{data:null,error:new Ia("Unexpected error in register",d)}}}}pk();const Mk={url:kA,storageKey:CA,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:RA,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4};async function Z0(t,e,n){return await n()}const ti={};class Ko{get jwks(){var e,n;return(n=(e=ti[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(e){ti[this.storageKey]=Object.assign(Object.assign({},ti[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,n;return(n=(e=ti[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){ti[this.storageKey]=Object.assign(Object.assign({},ti[this.storageKey]),{cachedAt:e})}constructor(e){var n,r,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 u=Object.assign(Object.assign({},Mk),e);if(this.storageKey=u.storageKey,this.instanceID=(n=Ko.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,Ko.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!u.debug,typeof u.debug=="function"&&(this.logger=u.debug),this.instanceID>0&&Mt()){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=u.persistSession,this.autoRefreshToken=u.autoRefreshToken,this.admin=new hk({url:u.url,headers:u.headers,fetch:u.fetch}),this.url=u.url,this.headers=u.headers,this.fetch=ww(u.fetch),this.lock=u.lock||Z0,this.detectSessionInUrl=u.detectSessionInUrl,this.flowType=u.flowType,this.hasCustomAuthorizationHeader=u.hasCustomAuthorizationHeader,this.throwOnError=u.throwOnError,this.lockAcquireTimeout=u.lockAcquireTimeout,u.lock?this.lock=u.lock:this.persistSession&&Mt()&&(!((r=globalThis?.navigator)===null||r===void 0)&&r.locks)?this.lock=mk:this.lock=Z0,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 Dk(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.persistSession?(u.storage?this.storage=u.storage:bw()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=J0(this.memoryStorage)),u.userStorage&&(this.userStorage=u.userStorage)):(this.memoryStorage={},this.storage=J0(this.memoryStorage)),Mt()&&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),await this._notifyAllSubscribers(d.data.event,d.data.session,!1)})}this.initialize()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${yw}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),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 e;try{let n={},r="none";if(Mt()&&(n=FA(window.location.href),this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce")),Mt()&&this.detectSessionInUrl&&r!=="none"){const{data:l,error:u}=await this._getSessionFromURL(n,r);if(u){if(this._debug("#_initialize()","error detecting session from URL",u),UA(u)){const p=(e=u.details)===null||e===void 0?void 0:e.code;if(p==="identity_already_exists"||p==="identity_not_found"||p==="single_identity_not_deletable")return{error:u}}return{error:u}}const{session:d,redirectType:f}=l;return this._debug("#_initialize()","detected session in URL",d,"redirect type",f),await this._saveSession(d),setTimeout(async()=>{f==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",d):await this._notifyAllSubscribers("SIGNED_IN",d)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return fe(n)?this._returnResult({error:n}):this._returnResult({error:new Ia("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var n,r,l;try{const u=await ve(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=e?.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(l=e?.options)===null||l===void 0?void 0:l.captchaToken}},xform:Cs}),{data:d,error:f}=u;if(f||!d)return this._returnResult({data:{user:null,session:null},error:f});const p=d.session,m=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",p)),this._returnResult({data:{user:m,session:p},error:null})}catch(u){if(fe(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signUp(e){var n,r,l;try{let u;if("email"in e){const{email:y,password:v,options:b}=e;let S=null,_=null;this.flowType==="pkce"&&([S,_]=await Qr(this.storage,this.storageKey)),u=await ve(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:b?.emailRedirectTo,body:{email:y,password:v,data:(n=b?.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:b?.captchaToken},code_challenge:S,code_challenge_method:_},xform:Cs})}else if("phone"in e){const{phone:y,password:v,options:b}=e;u=await ve(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:v,data:(r=b?.data)!==null&&r!==void 0?r:{},channel:(l=b?.channel)!==null&&l!==void 0?l:"sms",gotrue_meta_security:{captcha_token:b?.captchaToken}},xform:Cs})}else throw new Lc("You must provide either an email or phone number and a password");const{data:d,error:f}=u;if(f||!d)return await Dt(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:f});const p=d.session,m=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",p)),this._returnResult({data:{user:m,session:p},error:null})}catch(u){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signInWithPassword(e){try{let n;if("email"in e){const{email:u,password:d,options:f}=e;n=await ve(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:u,password:d,gotrue_meta_security:{captcha_token:f?.captchaToken}},xform:X0})}else if("phone"in e){const{phone:u,password:d,options:f}=e;n=await ve(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:u,password:d,gotrue_meta_security:{captcha_token:f?.captchaToken}},xform:X0})}else throw new Lc("You must provide either an email or phone number and a password");const{data:r,error:l}=n;if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!r||!r.session||!r.user){const u=new Jr;return this._returnResult({data:{user:null,session:null},error:u})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:l})}catch(n){if(fe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOAuth(e){var n,r,l,u;return await this._handleProviderSignIn(e.provider,{redirectTo:(n=e.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:(u=e.options)===null||u===void 0?void 0:u.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:n}=e;switch(n){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(e){var n,r,l,u,d,f,p,m,y,v,b;let S,_;if("message"in e)S=e.message,_=e.signature;else{const{chain:N,wallet:E,statement:T,options:D}=e;let A;if(Mt())if(typeof E=="object")A=E;else{const J=window;if("ethereum"in J&&typeof J.ethereum=="object"&&"request"in J.ethereum&&typeof J.ethereum.request=="function")A=J.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 E!="object"||!D?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=E}const U=new URL((n=D?.url)!==null&&n!==void 0?n:window.location.href),H=await A.request({method:"eth_requestAccounts"}).then(J=>J).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!H||H.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const G=_w(H[0]);let z=(r=D?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!z){const J=await A.request({method:"eth_chainId"});z=gk(J)}const M={domain:U.host,address:G,statement:T,uri:U.href,version:"1",chainId:z,nonce:(l=D?.signInWithEthereum)===null||l===void 0?void 0:l.nonce,issuedAt:(d=(u=D?.signInWithEthereum)===null||u===void 0?void 0:u.issuedAt)!==null&&d!==void 0?d:new Date,expirationTime:(f=D?.signInWithEthereum)===null||f===void 0?void 0:f.expirationTime,notBefore:(p=D?.signInWithEthereum)===null||p===void 0?void 0:p.notBefore,requestId:(m=D?.signInWithEthereum)===null||m===void 0?void 0:m.requestId,resources:(y=D?.signInWithEthereum)===null||y===void 0?void 0:y.resources};S=vk(M),_=await A.request({method:"personal_sign",params:[yk(S),G]})}try{const{data:N,error:E}=await ve(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:S,signature:_},!((v=e.options)===null||v===void 0)&&v.captchaToken?{gotrue_meta_security:{captcha_token:(b=e.options)===null||b===void 0?void 0:b.captchaToken}}:null),xform:Cs});if(E)throw E;if(!N||!N.session||!N.user){const T=new Jr;return this._returnResult({data:{user:null,session:null},error:T})}return N.session&&(await this._saveSession(N.session),await this._notifyAllSubscribers("SIGNED_IN",N.session)),this._returnResult({data:Object.assign({},N),error:E})}catch(N){if(fe(N))return this._returnResult({data:{user:null,session:null},error:N});throw N}}async signInWithSolana(e){var n,r,l,u,d,f,p,m,y,v,b,S;let _,N;if("message"in e)_=e.message,N=e.signature;else{const{chain:E,wallet:T,statement:D,options:A}=e;let U;if(Mt())if(typeof T=="object")U=T;else{const G=window;if("solana"in G&&typeof G.solana=="object"&&("signIn"in G.solana&&typeof G.solana.signIn=="function"||"signMessage"in G.solana&&typeof G.solana.signMessage=="function"))U=G.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 T!="object"||!A?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");U=T}const H=new URL((n=A?.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in U&&U.signIn){const G=await U.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},A?.signInWithSolana),{version:"1",domain:H.host,uri:H.href}),D?{statement:D}:null));let z;if(Array.isArray(G)&&G[0]&&typeof G[0]=="object")z=G[0];else if(G&&typeof G=="object"&&"signedMessage"in G&&"signature"in G)z=G;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in z&&"signature"in z&&(typeof z.signedMessage=="string"||z.signedMessage instanceof Uint8Array)&&z.signature instanceof Uint8Array)_=typeof z.signedMessage=="string"?z.signedMessage:new TextDecoder().decode(z.signedMessage),N=z.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in U)||typeof U.signMessage!="function"||!("publicKey"in U)||typeof U!="object"||!U.publicKey||!("toBase58"in U.publicKey)||typeof U.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${H.host} wants you to sign in with your Solana account:`,U.publicKey.toBase58(),...D?["",D,""]:[""],"Version: 1",`URI: ${H.href}`,`Issued At: ${(l=(r=A?.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&l!==void 0?l:new Date().toISOString()}`,...!((u=A?.signInWithSolana)===null||u===void 0)&&u.notBefore?[`Not Before: ${A.signInWithSolana.notBefore}`]:[],...!((d=A?.signInWithSolana)===null||d===void 0)&&d.expirationTime?[`Expiration Time: ${A.signInWithSolana.expirationTime}`]:[],...!((f=A?.signInWithSolana)===null||f===void 0)&&f.chainId?[`Chain ID: ${A.signInWithSolana.chainId}`]:[],...!((p=A?.signInWithSolana)===null||p===void 0)&&p.nonce?[`Nonce: ${A.signInWithSolana.nonce}`]:[],...!((m=A?.signInWithSolana)===null||m===void 0)&&m.requestId?[`Request ID: ${A.signInWithSolana.requestId}`]:[],...!((v=(y=A?.signInWithSolana)===null||y===void 0?void 0:y.resources)===null||v===void 0)&&v.length?["Resources",...A.signInWithSolana.resources.map(z=>`- ${z}`)]:[]].join(`
|
|
51
|
+
`);const G=await U.signMessage(new TextEncoder().encode(_),"utf8");if(!G||!(G instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");N=G}}try{const{data:E,error:T}=await ve(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:Ha(N)},!((b=e.options)===null||b===void 0)&&b.captchaToken?{gotrue_meta_security:{captcha_token:(S=e.options)===null||S===void 0?void 0:S.captchaToken}}:null),xform:Cs});if(T)throw T;if(!E||!E.session||!E.user){const D=new Jr;return this._returnResult({data:{user:null,session:null},error:D})}return E.session&&(await this._saveSession(E.session),await this._notifyAllSubscribers("SIGNED_IN",E.session)),this._returnResult({data:Object.assign({},E),error:T})}catch(E){if(fe(E))return this._returnResult({data:{user:null,session:null},error:E});throw E}}async _exchangeCodeForSession(e){const n=await za(this.storage,`${this.storageKey}-code-verifier`),[r,l]=(n??"").split("/");try{if(!r&&this.flowType==="pkce")throw new PA;const{data:u,error:d}=await ve(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:Cs});if(await Dt(this.storage,`${this.storageKey}-code-verifier`),d)throw d;if(!u||!u.session||!u.user){const f=new Jr;return this._returnResult({data:{user:null,session:null,redirectType:null},error:f})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:Object.assign(Object.assign({},u),{redirectType:l??null}),error:d})}catch(u){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(u))return this._returnResult({data:{user:null,session:null,redirectType:null},error:u});throw u}}async signInWithIdToken(e){try{const{options:n,provider:r,token:l,access_token:u,nonce:d}=e,f=await ve(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:l,access_token:u,nonce:d,gotrue_meta_security:{captcha_token:n?.captchaToken}},xform:Cs}),{data:p,error:m}=f;if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!p||!p.session||!p.user){const y=new Jr;return this._returnResult({data:{user:null,session:null},error:y})}return p.session&&(await this._saveSession(p.session),await this._notifyAllSubscribers("SIGNED_IN",p.session)),this._returnResult({data:p,error:m})}catch(n){if(fe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOtp(e){var n,r,l,u,d;try{if("email"in e){const{email:f,options:p}=e;let m=null,y=null;this.flowType==="pkce"&&([m,y]=await Qr(this.storage,this.storageKey));const{error:v}=await ve(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:f,data:(n=p?.data)!==null&&n!==void 0?n:{},create_user:(r=p?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:p?.captchaToken},code_challenge:m,code_challenge_method:y},redirectTo:p?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:v})}if("phone"in e){const{phone:f,options:p}=e,{data:m,error:y}=await ve(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:f,data:(l=p?.data)!==null&&l!==void 0?l:{},create_user:(u=p?.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:p?.captchaToken},channel:(d=p?.channel)!==null&&d!==void 0?d:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:m?.message_id},error:y})}throw new Lc("You must provide either an email or phone number.")}catch(f){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(f))return this._returnResult({data:{user:null,session:null},error:f});throw f}}async verifyOtp(e){var n,r;try{let l,u;"options"in e&&(l=(n=e.options)===null||n===void 0?void 0:n.redirectTo,u=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:d,error:f}=await ve(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:u}}),redirectTo:l,xform:Cs});if(f)throw f;if(!d)throw new Error("An error occurred on token verification.");const p=d.session,m=d.user;return p?.access_token&&(await this._saveSession(p),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",p)),this._returnResult({data:{user:m,session:p},error:null})}catch(l){if(fe(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithSSO(e){var n,r,l,u,d;try{let f=null,p=null;this.flowType==="pkce"&&([f,p]=await Qr(this.storage,this.storageKey));const m=await ve(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(n=e.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((l=e?.options)===null||l===void 0)&&l.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:f,code_challenge_method:p}),headers:this.headers,xform:ck});return!((u=m.data)===null||u===void 0)&&u.url&&Mt()&&!(!((d=e.options)===null||d===void 0)&&d.skipBrowserRedirect)&&window.location.assign(m.data.url),this._returnResult(m)}catch(f){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(f))return this._returnResult({data:null,error:f});throw f}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:n},error:r}=e;if(r)throw r;if(!n)throw new rs;const{error:l}=await ve(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return this._returnResult({data:{user:null,session:null},error:l})})}catch(e){if(fe(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const n=`${this.url}/resend`;if("email"in e){const{email:r,type:l,options:u}=e,{error:d}=await ve(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}},redirectTo:u?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}else if("phone"in e){const{phone:r,type:l,options:u}=e,{data:d,error:f}=await ve(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:d?.message_id},error:f})}throw new Lc("You must provide either an email or phone number and a type")}catch(n){if(fe(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(e,n){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),l=(async()=>(await r,await n()))();return this.pendingInLock.push((async()=>{try{await l}catch{}})()),l}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const l=[...this.pendingInLock];await Promise.all(l),this.pendingInLock.splice(0,l.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await e(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 e=null;const n=await za(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?e=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<rf:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const d=await za(this.userStorage,this.storageKey+"-user");d?.user?e.user=d.user:e.user=cf()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const d={value:this.suppressGetSessionWarning};e.user=rk(e.user,d),d.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{session:null},error:u}):this._returnResult({data:{session:l},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const n=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return n.data.user&&(this.suppressGetSessionWarning=!0),n}async _getUser(e){try{return e?await ve(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Jn}):await this._useSession(async n=>{var r,l,u;const{data:d,error:f}=n;if(f)throw f;return!(!((r=d.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new rs}:await ve(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(u=(l=d.session)===null||l===void 0?void 0:l.access_token)!==null&&u!==void 0?u:void 0,xform:Jn})})}catch(n){if(fe(n))return LA(n)&&(await this._removeSession(),await Dt(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:n});throw n}}async updateUser(e,n={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,n))}async _updateUser(e,n={}){try{return await this._useSession(async r=>{const{data:l,error:u}=r;if(u)throw u;if(!l.session)throw new rs;const d=l.session;let f=null,p=null;this.flowType==="pkce"&&e.email!=null&&([f,p]=await Qr(this.storage,this.storageKey));const{data:m,error:y}=await ve(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:f,code_challenge_method:p}),jwt:d.access_token,xform:Jn});if(y)throw y;return d.user=m.user,await this._saveSession(d),await this._notifyAllSubscribers("USER_UPDATED",d),this._returnResult({data:{user:d.user},error:null})})}catch(r){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new rs;const n=Date.now()/1e3;let r=n,l=!0,u=null;const{payload:d}=lf(e.access_token);if(d.exp&&(r=d.exp,l=r<=n),l){const{data:f,error:p}=await this._callRefreshToken(e.refresh_token);if(p)return this._returnResult({data:{user:null,session:null},error:p});if(!f)return{data:{user:null,session:null},error:null};u=f}else{const{data:f,error:p}=await this._getUser(e.access_token);if(p)throw p;u={access_token:e.access_token,refresh_token:e.refresh_token,user:f.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(u),await this._notifyAllSubscribers("SIGNED_IN",u)}return this._returnResult({data:{user:u.user,session:u},error:null})}catch(n){if(fe(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async n=>{var r;if(!e){const{data:d,error:f}=n;if(f)throw f;e=(r=d.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new rs;const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{user:null,session:null},error:u}):l?this._returnResult({data:{user:l.user,session:l},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(n){if(fe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(e,n){try{if(!Mt())throw new Uc("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Uc(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new $0("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Uc("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new $0("No code detected.");const{data:D,error:A}=await this._exchangeCodeForSession(e.code);if(A)throw A;const U=new URL(window.location.href);return U.searchParams.delete("code"),window.history.replaceState(window.history.state,"",U.toString()),{data:{session:D.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:l,access_token:u,refresh_token:d,expires_in:f,expires_at:p,token_type:m}=e;if(!u||!f||!d||!m)throw new Uc("No session defined in URL");const y=Math.round(Date.now()/1e3),v=parseInt(f);let b=y+v;p&&(b=parseInt(p));const S=b-y;S*1e3<=ii&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${S}s, should have been closer to ${v}s`);const _=b-v;y-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,b,y):y-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,b,y);const{data:N,error:E}=await this._getUser(u);if(E)throw E;const T={provider_token:r,provider_refresh_token:l,access_token:u,expires_in:v,expires_at:b,refresh_token:d,token_type:m,user:N.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:T,redirectType:e.type},error:null})}catch(r){if(fe(r))return this._returnResult({data:{session:null,redirectType:null},error:r});throw r}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const n=await za(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&n)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async n=>{var r;const{data:l,error:u}=n;if(u)return this._returnResult({error:u});const d=(r=l.session)===null||r===void 0?void 0:r.access_token;if(d){const{error:f}=await this.admin.signOut(d,e);if(f&&!(zA(f)&&(f.status===404||f.status===401||f.status===403)))return this._returnResult({error:f})}return e!=="others"&&(await this._removeSession(),await Dt(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const n=GA(),r={id:n,callback:e,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,r),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async n=>{var r,l;try{const{data:{session:u},error:d}=n;if(d)throw d;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",u)),this._debug("INITIAL_SESSION","callback id",e,"session",u)}catch(u){await((l=this.stateChangeEmitters.get(e))===null||l===void 0?void 0:l.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",u),console.error(u)}})}async resetPasswordForEmail(e,n={}){let r=null,l=null;this.flowType==="pkce"&&([r,l]=await Qr(this.storage,this.storageKey,!0));try{return await ve(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:l,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(u){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(u))return this._returnResult({data:null,error:u});throw u}}async getUserIdentities(){var e;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(e=n.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var n;try{const{data:r,error:l}=await this._useSession(async u=>{var d,f,p,m,y;const{data:v,error:b}=u;if(b)throw b;const S=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(d=e.options)===null||d===void 0?void 0:d.redirectTo,scopes:(f=e.options)===null||f===void 0?void 0:f.scopes,queryParams:(p=e.options)===null||p===void 0?void 0:p.queryParams,skipBrowserRedirect:!0});return await ve(this.fetch,"GET",S,{headers:this.headers,jwt:(y=(m=v.session)===null||m===void 0?void 0:m.access_token)!==null&&y!==void 0?y:void 0})});if(l)throw l;return Mt()&&!(!((n=e.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r?.url),this._returnResult({data:{provider:e.provider,url:r?.url},error:null})}catch(r){if(fe(r))return this._returnResult({data:{provider:e.provider,url:null},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async n=>{var r;try{const{error:l,data:{session:u}}=n;if(l)throw l;const{options:d,provider:f,token:p,access_token:m,nonce:y}=e,v=await ve(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=u?.access_token)!==null&&r!==void 0?r:void 0,body:{provider:f,id_token:p,access_token:m,nonce:y,link_identity:!0,gotrue_meta_security:{captcha_token:d?.captchaToken}},xform:Cs}),{data:b,error:S}=v;return S?this._returnResult({data:{user:null,session:null},error:S}):!b||!b.session||!b.user?this._returnResult({data:{user:null,session:null},error:new Jr}):(b.session&&(await this._saveSession(b.session),await this._notifyAllSubscribers("USER_UPDATED",b.session)),this._returnResult({data:b,error:S}))}catch(l){if(await Dt(this.storage,`${this.storageKey}-code-verifier`),fe(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}})}async unlinkIdentity(e){try{return await this._useSession(async n=>{var r,l;const{data:u,error:d}=n;if(d)throw d;return await ve(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(l=(r=u.session)===null||r===void 0?void 0:r.access_token)!==null&&l!==void 0?l:void 0})})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}}async _refreshAccessToken(e){const n=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await XA(async l=>(l>0&&await YA(200*Math.pow(2,l-1)),this._debug(n,"refreshing attempt",l),await ve(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Cs})),(l,u)=>{const d=200*Math.pow(2,l);return u&&of(u)&&Date.now()+d-r<ii})}catch(r){if(this._debug(n,"error",r),fe(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(n,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,n){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",n,"url",r),Mt()&&!n.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,n;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const l=await za(this.storage,this.storageKey);if(l&&this.userStorage){let d=await za(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!d&&(d={user:l.user},await oi(this.userStorage,this.storageKey+"-user",d)),l.user=(e=d?.user)!==null&&e!==void 0?e:cf()}else if(l&&!l.user&&!l.user){const d=await za(this.storage,this.storageKey+"-user");d&&d?.user?(l.user=d.user,await Dt(this.storage,this.storageKey+"-user"),await oi(this.storage,this.storageKey,l)):l.user=cf()}if(this._debug(r,"session from storage",l),!this._isValidSession(l)){this._debug(r,"session is not valid"),l!==null&&await this._removeSession();return}const u=((n=l.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<rf;if(this._debug(r,`session has${u?"":" not"} expired with margin of ${rf}s`),u){if(this.autoRefreshToken&&l.refresh_token){const{error:d}=await this._callRefreshToken(l.refresh_token);d&&(console.error(d),of(d)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",d),await this._removeSession()))}}else if(l.user&&l.user.__isUserNotAvailableProxy===!0)try{const{data:d,error:f}=await this._getUser(l.access_token);!f&&d?.user?(l.user=d.user,await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(d){console.error("Error getting user data:",d),this._debug(r,"error getting user data, skipping SIGNED_IN notification",d)}else await this._notifyAllSubscribers("SIGNED_IN",l)}catch(l){this._debug(r,"error",l),console.error(l);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var n,r;if(!e)throw new rs;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const l=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(l,"begin");try{this.refreshingDeferred=new Eu;const{data:u,error:d}=await this._refreshAccessToken(e);if(d)throw d;if(!u.session)throw new rs;await this._saveSession(u.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",u.session);const f={data:u.session,error:null};return this.refreshingDeferred.resolve(f),f}catch(u){if(this._debug(l,"error",u),fe(u)){const d={data:null,error:u};return of(u)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(d),d}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(u),u}finally{this.refreshingDeferred=null,this._debug(l,"end")}}async _notifyAllSubscribers(e,n,r=!0){const l=`#_notifyAllSubscribers(${e})`;this._debug(l,"begin",n,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:n});const u=[],d=Array.from(this.stateChangeEmitters.values()).map(async f=>{try{await f.callback(e,n)}catch(p){u.push(p)}});if(await Promise.all(d),u.length>0){for(let f=0;f<u.length;f+=1)console.error(u[f]);throw u[0]}}finally{this._debug(l,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Dt(this.storage,`${this.storageKey}-code-verifier`);const n=Object.assign({},e),r=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&n.user&&await oi(this.userStorage,this.storageKey+"-user",{user:n.user});const l=Object.assign({},n);delete l.user;const u=K0(l);await oi(this.storage,this.storageKey,u)}else{const l=K0(n);await oi(this.storage,this.storageKey,l)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Dt(this.storage,this.storageKey),await Dt(this.storage,this.storageKey+"-code-verifier"),await Dt(this.storage,this.storageKey+"-user"),this.userStorage&&await Dt(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Mt()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),ii);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);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 e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);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 e=Date.now();try{return await this._useSession(async n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const l=Math.floor((r.expires_at*1e3-e)/ii);this._debug("#_autoRefreshTokenTick()",`access token expires in ${l} ticks, a tick lasts ${ii}ms, refresh threshold is ${Gf} ticks`),l<=Gf&&await this._callRefreshToken(r.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(e){if(e.isAcquireTimeout||e instanceof Sw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Mt()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const n=`#_onVisibilityChanged(${e})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(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(e,n,r){const l=[`provider=${encodeURIComponent(n)}`];if(r?.redirectTo&&l.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&l.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[u,d]=await Qr(this.storage,this.storageKey),f=new URLSearchParams({code_challenge:`${encodeURIComponent(u)}`,code_challenge_method:`${encodeURIComponent(d)}`});l.push(f.toString())}if(r?.queryParams){const u=new URLSearchParams(r.queryParams);l.push(u.toString())}return r?.skipBrowserRedirect&&l.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${l.join("&")}`}async _unenroll(e){try{return await this._useSession(async n=>{var r;const{data:l,error:u}=n;return u?this._returnResult({data:null,error:u}):await ve(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=l?.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}}async _enroll(e){try{return await this._useSession(async n=>{var r,l;const{data:u,error:d}=n;if(d)return this._returnResult({data:null,error:d});const f=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:p,error:m}=await ve(this.fetch,"POST",`${this.url}/factors`,{body:f,headers:this.headers,jwt:(r=u?.session)===null||r===void 0?void 0:r.access_token});return m?this._returnResult({data:null,error:m}):(e.factorType==="totp"&&p.type==="totp"&&(!((l=p?.totp)===null||l===void 0)&&l.qr_code)&&(p.totp.qr_code=`data:image/svg+xml;utf-8,${p.totp.qr_code}`),this._returnResult({data:p,error:null}))})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var r;const{data:l,error:u}=n;if(u)return this._returnResult({data:null,error:u});const d=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Nk(e.webauthn.credential_response):Ek(e.webauthn.credential_response)})}:{code:e.code}),{data:f,error:p}=await ve(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:d,headers:this.headers,jwt:(r=l?.session)===null||r===void 0?void 0:r.access_token});return p?this._returnResult({data:null,error:p}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+f.expires_in},f)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",f),this._returnResult({data:f,error:p}))})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var r;const{data:l,error:u}=n;if(u)return this._returnResult({data:null,error:u});const d=await ve(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=l?.session)===null||r===void 0?void 0:r.access_token});if(d.error)return d;const{data:f}=d;if(f.type!=="webauthn")return{data:f,error:null};switch(f.webauthn.type){case"create":return{data:Object.assign(Object.assign({},f),{webauthn:Object.assign(Object.assign({},f.webauthn),{credential_options:Object.assign(Object.assign({},f.webauthn.credential_options),{publicKey:_k(f.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},f),{webauthn:Object.assign(Object.assign({},f.webauthn),{credential_options:Object.assign(Object.assign({},f.webauthn.credential_options),{publicKey:jk(f.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}})}async _challengeAndVerify(e){const{data:n,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:n.id,code:e.code})}async _listFactors(){var e;const{data:{user:n},error:r}=await this.getUser();if(r)return{data:null,error:r};const l={all:[],phone:[],totp:[],webauthn:[]};for(const u of(e=n?.factors)!==null&&e!==void 0?e:[])l.all.push(u),u.status==="verified"&&l[u.factor_type].push(u);return{data:l,error:null}}async _getAuthenticatorAssuranceLevel(){var e,n;const{data:{session:r},error:l}=await this.getSession();if(l)return this._returnResult({data:null,error:l});if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:u}=lf(r.access_token);let d=null;u.aal&&(d=u.aal);let f=d;((n=(e=r.user.factors)===null||e===void 0?void 0:e.filter(y=>y.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(f="aal2");const m=u.amr||[];return{data:{currentLevel:d,nextLevel:f,currentAuthenticationMethods:m},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async n=>{const{data:{session:r},error:l}=n;return l?this._returnResult({data:null,error:l}):r?await ve(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:u=>({data:u,error:null})}):this._returnResult({data:null,error:new rs})})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}}async _approveAuthorization(e,n){try{return await this._useSession(async r=>{const{data:{session:l},error:u}=r;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new rs});const d=await ve(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"approve"},xform:f=>({data:f,error:null})});return d.data&&d.data.redirect_url&&Mt()&&!n?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(r){if(fe(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(e,n){try{return await this._useSession(async r=>{const{data:{session:l},error:u}=r;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new rs});const d=await ve(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"deny"},xform:f=>({data:f,error:null})});return d.data&&d.data.redirect_url&&Mt()&&!n?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(r){if(fe(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:n},error:r}=e;return r?this._returnResult({data:null,error:r}):n?await ve(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new rs})})}catch(e){if(fe(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async n=>{const{data:{session:r},error:l}=n;return l?this._returnResult({data:null,error:l}):r?(await ve(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new rs})})}catch(n){if(fe(n))return this._returnResult({data:null,error:n});throw n}}async fetchJwk(e,n={keys:[]}){let r=n.keys.find(f=>f.kid===e);if(r)return r;const l=Date.now();if(r=this.jwks.keys.find(f=>f.kid===e),r&&this.jwks_cached_at+DA>l)return r;const{data:u,error:d}=await ve(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(d)throw d;return!u.keys||u.keys.length===0||(this.jwks=u,this.jwks_cached_at=l,r=u.keys.find(f=>f.kid===e),!r)?null:r}async getClaims(e,n={}){try{let r=e;if(!r){const{data:S,error:_}=await this.getSession();if(_||!S.session)return this._returnResult({data:null,error:_});r=S.session.access_token}const{header:l,payload:u,signature:d,raw:{header:f,payload:p}}=lf(r);n?.allowExpired||sk(u.exp);const m=!l.alg||l.alg.startsWith("HS")||!l.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(l.kid,n?.keys?{keys:n.keys}:n?.jwks);if(!m){const{error:S}=await this.getUser(r);if(S)throw S;return{data:{claims:u,header:l,signature:d},error:null}}const y=nk(l.alg),v=await crypto.subtle.importKey("jwk",m,y,!0,["verify"]);if(!await crypto.subtle.verify(y,v,d,qA(`${f}.${p}`)))throw new Yf("Invalid JWT signature");return{data:{claims:u,header:l,signature:d},error:null}}catch(r){if(fe(r))return this._returnResult({data:null,error:r});throw r}}}Ko.nextInstanceID={};const zk=Ko,Lk="2.90.1";let Co="";typeof Deno<"u"?Co="deno":typeof document<"u"?Co="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Co="react-native":Co="node";const Uk={"X-Client-Info":`supabase-js-${Co}/${Lk}`},Pk={headers:Uk},Vk={schema:"public"},Bk={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Ik={};function Yo(t){"@babel/helpers - typeof";return Yo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yo(t)}function $k(t,e){if(Yo(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Yo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qk(t){var e=$k(t,"string");return Yo(e)=="symbol"?e:e+""}function Hk(t,e,n){return(e=qk(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ex(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),n.push.apply(n,r)}return n}function rt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ex(Object(n),!0).forEach(function(r){Hk(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ex(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const Gk=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Fk=()=>Headers,Kk=(t,e,n)=>{const r=Gk(n),l=Fk();return async(u,d)=>{var f;const p=(f=await e())!==null&&f!==void 0?f:t;let m=new l(d?.headers);return m.has("apikey")||m.set("apikey",t),m.has("Authorization")||m.set("Authorization",`Bearer ${p}`),r(u,rt(rt({},d),{},{headers:m}))}};function Yk(t){return t.endsWith("/")?t:t+"/"}function Xk(t,e){var n,r;const{db:l,auth:u,realtime:d,global:f}=t,{db:p,auth:m,realtime:y,global:v}=e,b={db:rt(rt({},p),l),auth:rt(rt({},m),u),realtime:rt(rt({},y),d),storage:{},global:rt(rt(rt({},v),f),{},{headers:rt(rt({},(n=v?.headers)!==null&&n!==void 0?n:{}),(r=f?.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return t.accessToken?b.accessToken=t.accessToken:delete b.accessToken,b}function Wk(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Yk(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var Jk=class extends zk{constructor(t){super(t)}},Qk=class{constructor(t,e,n){var r,l;this.supabaseUrl=t,this.supabaseKey=e;const u=Wk(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",u),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",u),this.storageUrl=new URL("storage/v1",u),this.functionsUrl=new URL("functions/v1",u);const d=`sb-${u.hostname.split(".")[0]}-auth-token`,f={db:Vk,realtime:Ik,auth:rt(rt({},Bk),{},{storageKey:d}),global:Pk},p=Xk(n??{},f);if(this.storageKey=(r=p.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(l=p.global.headers)!==null&&l!==void 0?l:{},p.accessToken)this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(y,v)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(v)} is not possible`)}});else{var m;this.auth=this._initSupabaseAuthClient((m=p.auth)!==null&&m!==void 0?m:{},this.headers,p.global.fetch)}this.fetch=Kk(e,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(rt({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.accessToken&&this.accessToken().then(y=>this.realtime.setAuth(y)).catch(y=>console.warn("Failed to set initial Realtime auth token:",y)),this.rest=new R2(new URL("rest/v1",u).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new AA(this.storageUrl.href,this.headers,this.fetch,n?.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new E2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,n)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,n;if(t.accessToken)return await t.accessToken();const{data:r}=await t.auth.getSession();return(e=(n=r.session)===null||n===void 0?void 0:n.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:n,storage:r,userStorage:l,storageKey:u,flowType:d,lock:f,debug:p,throwOnError:m},y,v){const b={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Jk({url:this.authUrl.href,headers:rt(rt({},b),y),storageKey:u,autoRefreshToken:t,persistSession:e,detectSessionInUrl:n,storage:r,userStorage:l,flowType:d,lock:f,debug:p,throwOnError:m,fetch:v,hasCustomAuthorizationHeader:Object.keys(this.headers).some(S=>S.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new Y2(this.realtimeUrl.href,rt(rt({},t),{},{params:rt(rt({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,n){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const Xf=(t,e,n)=>new Qk(t,e,n);function Zk(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const n=e.match(/^v(\d+)\./);return n?parseInt(n[1],10)<=18:!1}Zk()&&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 Tu="email_automator_supabase_config";function ji(){const t=n=>n&&typeof n.url=="string"&&typeof n.anonKey=="string"&&n.url.startsWith("http")&&!n.url.includes("placeholder.supabase.co")&&n.url!=="your_supabase_url"&&n.anonKey!=="your_supabase_anon_key";try{const n=localStorage.getItem(Tu);if(n){const r=JSON.parse(n);if(t(r))return r}}catch(n){console.error("Error reading Supabase config:",n)}const e={url:void 0,anonKey:void 0};return t(e)?e:null}function df(t){try{localStorage.setItem(Tu,JSON.stringify(t))}catch(e){console.error("Error saving Supabase config:",e)}}function eC(){try{localStorage.removeItem(Tu)}catch(t){console.error("Error clearing Supabase config:",t)}}async function tC(t,e){try{if(!t.startsWith("http://")&&!t.startsWith("https://"))return{valid:!1,error:"Invalid URL format"};const n=e.startsWith("eyJ"),r=e.startsWith("sb_publishable_");if(!n&&!r)return{valid:!1,error:"Invalid API key format (must be anon or publishable key)"};if(r)return{valid:!0};const l=await fetch(`${t}/rest/v1/`,{method:"GET",headers:{apikey:e,Authorization:`Bearer ${e}`}});return l.ok?{valid:!0}:l.status===401||l.status===403?{valid:!1,error:"Invalid API key"}:{valid:!1,error:`Connection failed: ${l.statusText}`}}catch(n){return{valid:!1,error:n instanceof Error?n.message:"Connection failed"}}}function sC(){return localStorage.getItem(Tu)?"ui":"none"}function nC(){const t=ji();return!t||!t.url?.startsWith("http")?(console.info("[Supabase] Setup required: Waiting for configuration..."),Xf("https://placeholder.supabase.co","placeholder-key")):Xf(t.url,t.anonKey,{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0}})}const Qe=nC();function tx(){const t=ji(),e=t?`${t.url}/functions/v1`:"",n=t?t.anonKey:"",r=window.location.port==="5173";let l="";return r?l="http://localhost:3004":l=window.location.origin,{edgeFunctionsUrl:e,expressApiUrl:l,anonKey:n}}class aC{edgeFunctionsUrl;expressApiUrl;anonKey;token=null;supabaseClient=null;constructor(){const e=tx();this.edgeFunctionsUrl=e.edgeFunctionsUrl,this.expressApiUrl=e.expressApiUrl,this.anonKey=e.anonKey}setSupabaseClient(e){this.supabaseClient=e}setToken(e){console.debug(e?"[HybridApiClient] Token updated":"[HybridApiClient] Token cleared"),this.token=e}async request(e,n,r={}){const{auth:l=!0,...u}=r,d={"Content-Type":"application/json",...r.headers||{}};if(l&&this.supabaseClient)try{const{data:{session:f},error:p}=await this.supabaseClient.auth.getSession();p?console.error("[HybridApiClient] Failed to get Supabase session:",p):f?.access_token&&(this.token=f.access_token)}catch(f){console.error("[HybridApiClient] Session recovery error:",f)}if(l&&!this.token)return console.warn(`[HybridApiClient] Attempted protected request to ${n} without token`),{error:{code:"AUTH_REQUIRED",message:"You must be logged in to perform this action"}};l&&this.token&&(d.Authorization=`Bearer ${this.token}`);try{console.debug(`[HybridApiClient] ${r.method||"GET"} ${e}${n}`);const f=await fetch(`${e}${n}`,{...u,headers:d});if(!f.ok){const m=await f.json().catch(()=>({})),y=typeof m.error=="string"?m.error:m.error?.message||`Request failed: ${f.status}`;return{error:{code:m.error?.code||"API_ERROR",message:y}}}return{data:await f.json()}}catch(f){return{error:{code:"NETWORK_ERROR",message:f instanceof Error?f.message:"Network error"}}}}edgeRequest(e,n){const r={...n?.headers||{},apikey:this.anonKey};return this.request(this.edgeFunctionsUrl,e,{...n,headers:r})}expressRequest(e,n){const r=tx(),l={...n?.headers||{},"X-Supabase-Url":r.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":r.anonKey};return this.request(this.expressApiUrl,e,{...n,headers:l})}async getGmailAuthUrl(){return this.edgeRequest("/auth-gmail?action=url",{method:"GET"})}async connectGmail(e){return this.edgeRequest("/auth-gmail",{method:"POST",body:JSON.stringify({code:e})})}async startMicrosoftDeviceFlow(){return this.edgeRequest("/auth-microsoft?action=device-flow",{method:"POST"})}async pollMicrosoftDeviceCode(e){return this.edgeRequest("/auth-microsoft?action=poll",{method:"POST",body:JSON.stringify({deviceCode:e})})}async getAccounts(){return this.edgeRequest("/api-v1-accounts")}async disconnectAccount(e){return this.edgeRequest(`/api-v1-accounts/${e}`,{method:"DELETE"})}async updateAccount(e,n){return this.edgeRequest(`/api-v1-accounts/${e}`,{method:"PATCH",body:JSON.stringify(n)})}async getEmails(e={}){const n=new URLSearchParams;return e.limit&&n.set("limit",e.limit.toString()),e.offset&&n.set("offset",e.offset.toString()),e.category&&n.set("category",e.category),e.search&&n.set("search",e.search),e.sort_by&&n.set("sort_by",e.sort_by),e.sort_order&&n.set("sort_order",e.sort_order),this.edgeRequest(`/api-v1-emails?${n}`)}async getEmail(e){return this.edgeRequest(`/api-v1-emails/${e}`)}async getEmailEvents(e){return this.edgeRequest(`/api-v1-emails/${e}/events`)}async deleteEmail(e){return this.edgeRequest(`/api-v1-emails/${e}`,{method:"DELETE"})}async getCategorySummary(){return this.edgeRequest("/api-v1-emails/summary/categories")}async retryEmail(e){return this.expressRequest(`/api/emails/${e}/retry`,{method:"POST"})}async getRules(){return this.expressRequest("/api/rules")}async createRule(e){return this.expressRequest("/api/rules",{method:"POST",body:JSON.stringify(e)})}async updateRule(e,n){return this.expressRequest(`/api/rules/${e}`,{method:"PATCH",body:JSON.stringify(n)})}async deleteRule(e){return this.expressRequest(`/api/rules/${e}`,{method:"DELETE"})}async toggleRule(e){return this.expressRequest(`/api/rules/${e}/toggle`,{method:"POST"})}async getSettings(){return this.edgeRequest("/api-v1-settings")}async getRunEvents(e){return this.edgeRequest(`/api-v1-settings/logs/${e}/events`)}async updateSettings(e){return this.edgeRequest("/api-v1-settings",{method:"PATCH",body:JSON.stringify(e)})}async getStats(){return this.edgeRequest("/api-v1-settings/stats")}async testLlm(e){return this.expressRequest("/api/settings/test-llm",{method:"POST",body:JSON.stringify(e||{})})}async getChatProviders(){return this.expressRequest("/api/sdk/providers/chat")}async triggerSync(e){return this.expressRequest("/api/sync",{method:"POST",body:JSON.stringify({accountId:e})})}async syncAll(){return this.expressRequest("/api/sync/all",{method:"POST"})}async getSyncLogs(e=10){return this.expressRequest(`/api/sync/logs?limit=${e}`)}async stopSync(){return this.expressRequest("/api/sync/stop",{method:"POST"})}async executeAction(e,n,r){return this.expressRequest("/api/actions/execute",{method:"POST",body:JSON.stringify({emailId:e,action:n,draftContent:r})})}async generateDraft(e,n){return this.expressRequest(`/api/actions/draft/${e}`,{method:"POST",body:JSON.stringify({instructions:n})})}async bulkAction(e,n){return this.expressRequest("/api/actions/bulk",{method:"POST",body:JSON.stringify({emailIds:e,action:n})})}async healthCheck(){return this.expressRequest("/api/health",{auth:!1})}async getProfile(){if(!this.supabaseClient)return{error:"Supabase client not initialized"};const{data:{user:e}}=await this.supabaseClient.auth.getUser();if(!e)return{error:"Not authenticated"};const{data:n,error:r}=await this.supabaseClient.from("profiles").select("*").eq("id",e.id).single();return{data:n,error:r}}async updateProfile(e){if(!this.supabaseClient)return{error:"Supabase client not initialized"};const{data:{user:n}}=await this.supabaseClient.auth.getUser();if(!n)return{error:"Not authenticated"};const{data:r,error:l}=await this.supabaseClient.from("profiles").update({...e,updated_at:new Date().toISOString()}).eq("id",n.id).select().single();return{data:r,error:l}}async changePassword(e){if(!this.supabaseClient)return{error:"Supabase client not initialized"};const{error:n}=await this.supabaseClient.auth.updateUser({password:e});return{success:!n,error:n}}async getAvailablePacks(){return await this.expressRequest("/rule-packs")}async getInstalledPacks(){return await this.expressRequest("/rule-packs/installed")}async getPack(e){return await this.expressRequest(`/rule-packs/${e}`)}async getPacksForRole(e){return await this.expressRequest(`/rule-packs/for-role/${e}`)}async installPack(e){return await this.expressRequest("/rule-packs/install",{method:"POST",body:JSON.stringify({packId:e})})}async uninstallPack(e){return await this.expressRequest("/rule-packs/uninstall",{method:"POST",body:JSON.stringify({packId:e})})}async setUserRole(e){return await this.expressRequest("/rule-packs/set-role",{method:"POST",body:JSON.stringify({role:e})})}}const Oe=new aC;async function Nw(t){Oe.setSupabaseClient(t);const{data:{session:e}}=await t.auth.getSession();e?.access_token&&Oe.setToken(e.access_token),t.auth.onAuthStateChange((n,r)=>{Oe.setToken(r?.access_token||null)})}const rC=Object.freeze(Object.defineProperty({__proto__:null,api:Oe,initializeApi:Nw},Symbol.toStringTag,{value:"Module"}));function iC({userId:t,onInsert:e,onUpdate:n,onDelete:r,enabled:l=!0}){const[u,d]=w.useState(!1);return w.useEffect(()=>{if(!l||!t){d(!1);return}const f=Qe.channel(`emails-realtime-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"emails"},p=>{p.eventType==="INSERT"?e?.(p.new):p.eventType==="UPDATE"?n?.(p.new):p.eventType==="DELETE"&&r?.(p.old.id)}).subscribe(p=>{d(p==="SUBSCRIBED")});return()=>{Qe.removeChannel(f)}},[t,l,e,n,r]),{isSubscribed:u}}class oC{ctx=null;enabled=!1;constructor(){const e=localStorage.getItem("ea_sounds_enabled");this.enabled=e!=="false"}setEnabled(e){this.enabled=e,localStorage.setItem("ea_sounds_enabled",e?"true":"false")}isEnabled(){return this.enabled}initCtx(){return this.ctx||(this.ctx=new(window.AudioContext||window.webkitAudioContext)),this.ctx.state==="suspended"&&this.ctx.resume(),this.ctx}haptic(e=10){typeof navigator<"u"&&navigator.vibrate&&navigator.vibrate(e)}playNotify(){if(!this.enabled)return;const e=this.initCtx(),n=e.createOscillator(),r=e.createGain();n.type="sine",n.frequency.setValueAtTime(880,e.currentTime),n.frequency.exponentialRampToValueAtTime(440,e.currentTime+.1),r.gain.setValueAtTime(0,e.currentTime),r.gain.linearRampToValueAtTime(.1,e.currentTime+.01),r.gain.exponentialRampToValueAtTime(.001,e.currentTime+.3),n.connect(r),r.connect(e.destination),n.start(),n.stop(e.currentTime+.3),this.haptic(10)}playAlert(){if(!this.enabled)return;const e=this.initCtx(),n=(r,l)=>{const u=e.createOscillator(),d=e.createGain();u.type="sine",u.frequency.setValueAtTime(r,e.currentTime+l),d.gain.setValueAtTime(0,e.currentTime+l),d.gain.linearRampToValueAtTime(.1,e.currentTime+l+.05),d.gain.exponentialRampToValueAtTime(.001,e.currentTime+l+.4),u.connect(d),d.connect(e.destination),u.start(e.currentTime+l),u.stop(e.currentTime+l+.4)};n(660,0),n(880,.1),this.haptic([20,50,20])}playStart(){if(!this.enabled)return;const e=this.initCtx(),n=e.createOscillator(),r=e.createGain();n.type="sine",n.frequency.setValueAtTime(440,e.currentTime),n.frequency.exponentialRampToValueAtTime(880,e.currentTime+.2),r.gain.setValueAtTime(0,e.currentTime),r.gain.linearRampToValueAtTime(.05,e.currentTime+.05),r.gain.exponentialRampToValueAtTime(.001,e.currentTime+.2),n.connect(r),r.connect(e.destination),n.start(),n.stop(e.currentTime+.2),this.haptic(10)}playSuccess(){if(!this.enabled)return;const e=this.initCtx(),n=e.createOscillator(),r=e.createGain();n.type="triangle",n.frequency.setValueAtTime(523.25,e.currentTime),n.frequency.exponentialRampToValueAtTime(1046.5,e.currentTime+.1),r.gain.setValueAtTime(0,e.currentTime),r.gain.linearRampToValueAtTime(.05,e.currentTime+.02),r.gain.exponentialRampToValueAtTime(.001,e.currentTime+.2),n.connect(r),r.connect(e.destination),n.start(),n.stop(e.currentTime+.2),this.haptic(15)}}const qs=new oC;let Is=[],Wf=new Set;function Jf(){Wf.forEach(t=>t())}const se={success:(t,e)=>Pc("success",t,e),error:(t,e)=>Pc("error",t,e),info:(t,e)=>Pc("info",t,e),warning:(t,e)=>Pc("warning",t,e)};function Pc(t,e,n=5e3){const r=Is.findIndex(u=>u.message===e&&u.type===t);if(r!==-1){const u=Is[r];Is=[...Is],Is[r]={...u,count:(u.count||1)+1,lastUpdated:Date.now()},Jf();return}const l=Math.random().toString(36).substr(2,9);Is=[...Is,{id:l,type:t,message:e,duration:n,count:1,lastUpdated:Date.now()}],Jf(),n>0&&setTimeout(()=>Ew(l),n)}function Ew(t){Is=Is.filter(e=>e.id!==t),Jf()}function lC(){const[,t]=w.useState(0);return w.useEffect(()=>{const e=()=>t(n=>n+1);return Wf.add(e),()=>{Wf.delete(e)}},[]),Is}const cC={success:ru,error:Ms,info:vi,warning:xi},uC={success:"bg-emerald-500/10 border-emerald-500/20 text-emerald-600 dark:text-emerald-400",error:"bg-destructive/10 border-destructive/20 text-destructive",info:"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400",warning:"bg-yellow-500/10 border-yellow-500/20 text-yellow-600 dark:text-yellow-400"};function dC({toast:t}){const e=cC[t.type];return o.jsxs("div",{className:Se("flex items-start gap-3 p-4 rounded-lg border shadow-lg backdrop-blur-sm","animate-in slide-in-from-left-full duration-300",uC[t.type]),children:[o.jsxs("div",{className:"relative",children:[o.jsx(e,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.count&&t.count>1&&o.jsx("span",{className:"absolute -top-2 -right-2 bg-primary text-primary-foreground text-[10px] font-bold px-1.5 rounded-full border border-background scale-90 animate-in zoom-in duration-200",children:t.count})]}),o.jsx("p",{className:"text-sm flex-1",children:t.message}),o.jsx("button",{onClick:()=>Ew(t.id),className:"p-1 hover:bg-black/10 rounded transition-colors",children:o.jsx(_s,{className:"w-4 h-4"})})]})}function hC(){const t=lC();return t.length===0?null:o.jsx("div",{className:"fixed bottom-4 left-4 z-50 flex flex-col-reverse gap-2 max-w-sm w-full",children:t.map(e=>o.jsx(dC,{toast:e},e.id))})}function xs(t,e){return t?typeof t=="string"?t:t.message||e:e}const Tw={user:null,isAuthenticated:!1,profile:null,emails:[],accounts:[],rules:[],settings:null,stats:null,isLoading:!0,isInitialized:!1,error:null,selectedEmailId:null,emailsTotal:0,emailsOffset:0,sortBy:"created_at",sortOrder:"desc",activeCategory:null,activeSearch:"",isSyncing:!1};function fC(t,e){switch(e.type){case"SET_USER":return{...t,user:e.payload,isAuthenticated:!!e.payload,isLoading:!1};case"SET_LOADING":return{...t,isLoading:e.payload};case"SET_INITIALIZED":return{...t,isInitialized:e.payload};case"SET_ERROR":return{...t,error:e.payload,isLoading:!1};case"SET_EMAILS":return{...t,emails:e.payload.emails,emailsTotal:e.payload.total,emailsOffset:e.payload.offset,activeCategory:e.payload.category!==void 0?e.payload.category:t.activeCategory,activeSearch:e.payload.search!==void 0?e.payload.search:t.activeSearch,sortBy:e.payload.sortBy||t.sortBy,sortOrder:e.payload.sortOrder||t.sortOrder};case"ADD_EMAIL":{const n=e.payload,r=!t.activeCategory||n.category===t.activeCategory,l=!t.activeSearch||n.subject?.toLowerCase().includes(t.activeSearch.toLowerCase())||n.sender?.toLowerCase().includes(t.activeSearch.toLowerCase());return!r||!l?{...t,emailsTotal:t.emailsTotal+1}:{...t,emails:[n,...t.emails],emailsTotal:t.emailsTotal+1}}case"UPDATE_EMAIL":{const n=e.payload;if(t.emails.findIndex(d=>d.id===n.id)!==-1)return{...t,emails:t.emails.map(d=>d.id===n.id?n:d)};const l=!t.activeCategory||n.category===t.activeCategory,u=!t.activeSearch||n.subject?.toLowerCase().includes(t.activeSearch.toLowerCase())||n.sender?.toLowerCase().includes(t.activeSearch.toLowerCase());return l&&u?{...t,emails:[n,...t.emails]}:t}case"REMOVE_EMAIL":return{...t,emails:t.emails.filter(n=>n.id!==e.payload),emailsTotal:Math.max(0,t.emailsTotal-1)};case"SET_PROFILE":return{...t,profile:e.payload};case"UPDATE_PROFILE":return{...t,profile:e.payload};case"SET_ACCOUNTS":return{...t,accounts:e.payload};case"ADD_ACCOUNT":return{...t,accounts:[e.payload,...t.accounts]};case"REMOVE_ACCOUNT":return{...t,accounts:t.accounts.filter(n=>n.id!==e.payload)};case"SET_RULES":return{...t,rules:e.payload};case"ADD_RULE":return{...t,rules:[e.payload,...t.rules]};case"UPDATE_RULE":return{...t,rules:t.rules.map(n=>n.id===e.payload.id?e.payload:n)};case"REMOVE_RULE":return{...t,rules:t.rules.filter(n=>n.id!==e.payload)};case"SET_SETTINGS":return{...t,settings:e.payload};case"SET_STATS":return{...t,stats:e.payload};case"SET_SELECTED_EMAIL":return{...t,selectedEmailId:e.payload};case"SET_SYNCING":return{...t,isSyncing:e.payload};case"CLEAR_DATA":return{...Tw,isLoading:!1,isInitialized:!0};default:return t}}const Aw=w.createContext(null);function mC({children:t}){const[e,n]=w.useReducer(fC,Tw),r=w.useCallback(async(m,y=3,v=500)=>{for(let b=1;b<=y;b++){const S=await Oe.getEmail(m);if(S.data?.email)return S.data.email;b<y&&await new Promise(_=>setTimeout(_,v))}return null},[]),l=w.useCallback(async m=>{const y=await r(m.id);y&&(n({type:"ADD_EMAIL",payload:y}),y.processing_status==="completed"&&(y.ai_analysis?.priority==="High"?(qs.playAlert(),se.success("High Priority Email Processed!")):(qs.playNotify(),se.info("New email processed"))))},[n,r]),u=w.useCallback(async m=>{const y=await r(m.id);y&&(n({type:"UPDATE_EMAIL",payload:y}),y.processing_status==="completed"&&m.processing_status==="completed"&&(y.ai_analysis?.priority==="High"?(qs.playAlert(),se.success("High Priority Email Processed!")):(qs.playNotify(),se.info("Email analysis complete"))))},[n,r]),d=w.useCallback(m=>{n({type:"REMOVE_EMAIL",payload:m})},[n]),{isSubscribed:f}=iC({userId:e.user?.id,onInsert:l,onUpdate:u,onDelete:d,enabled:e.isAuthenticated});w.useEffect(()=>{async function m(){if(!ji()){n({type:"SET_INITIALIZED",payload:!0});return}try{const{error:v}=await Qe.from("init_state").select("count",{count:"exact",head:!0});if(v&&v.message==="Invalid API key"){console.error("[AppContext] Invalid API Key detected during init"),n({type:"SET_INITIALIZED",payload:!0});return}await Nw(Qe);const{data:{session:b}}=await Qe.auth.getSession();n({type:"SET_USER",payload:b?.user||null}),n({type:"SET_INITIALIZED",payload:!0});const{data:{subscription:S}}=Qe.auth.onAuthStateChange((_,N)=>{n({type:"SET_USER",payload:N?.user||null}),N||n({type:"CLEAR_DATA"})});return()=>S.unsubscribe()}catch(v){console.error("[AppContext] Init error:",v),n({type:"SET_ERROR",payload:"Failed to initialize"}),n({type:"SET_INITIALIZED",payload:!0})}}m()},[]);const p={fetchEmails:async(m={})=>{const y=await Oe.getEmails({limit:20,offset:m.offset||0,category:m.category,search:m.search,sort_by:m.sortBy||e.sortBy,sort_order:m.sortOrder||e.sortOrder});y.data&&n({type:"SET_EMAILS",payload:{emails:y.data.emails,total:y.data.total,offset:m.offset||0,category:m.category||null,search:m.search||"",sortBy:m.sortBy,sortOrder:m.sortOrder}})},fetchAccounts:async()=>{const m=await Oe.getAccounts();m.data&&n({type:"SET_ACCOUNTS",payload:m.data.accounts})},fetchRules:async()=>{const m=await Oe.getRules();m.data&&n({type:"SET_RULES",payload:m.data.rules})},fetchSettings:async()=>{const m=await Oe.getSettings();m.data&&n({type:"SET_SETTINGS",payload:m.data.settings})},fetchProfile:async()=>{const m=await Oe.getProfile();m.data&&n({type:"SET_PROFILE",payload:m.data})},fetchStats:async()=>{const m=await Oe.getStats();m.data&&n({type:"SET_STATS",payload:m.data.stats})},executeAction:async(m,y,v)=>{const b=await Oe.executeAction(m,y,v);if(b.data?.success){const S=e.emails.find(_=>_.id===m);return S&&n({type:"UPDATE_EMAIL",payload:{...S,action_taken:y}}),!0}return n({type:"SET_ERROR",payload:xs(b.error,"Action failed")}),!1},triggerSync:async m=>{n({type:"SET_SYNCING",payload:!0});try{const y=m?await Oe.triggerSync(m):await Oe.syncAll();return await p.fetchAccounts(),y.error?(n({type:"SET_ERROR",payload:xs(y.error,"Sync failed")}),!1):!0}finally{n({type:"SET_SYNCING",payload:!1})}},stopSync:async()=>{const m=await Oe.stopSync();return m.data?.success?(se.info("Stop request sent"),!0):(n({type:"SET_ERROR",payload:xs(m.error,"Failed to stop sync")}),!1)},disconnectAccount:async m=>{const y=await Oe.disconnectAccount(m);return y.data?.success?(n({type:"REMOVE_ACCOUNT",payload:m}),!0):(n({type:"SET_ERROR",payload:xs(y.error,"Failed to disconnect")}),!1)},updateSettings:async m=>{const y=await Oe.updateSettings(m);return y.data?(n({type:"SET_SETTINGS",payload:y.data.settings}),!0):(n({type:"SET_ERROR",payload:xs(y.error,"Failed to update settings")}),!1)},updateProfile:async m=>{const y=await Oe.updateProfile(m);return y.data?(n({type:"UPDATE_PROFILE",payload:y.data}),!0):(n({type:"SET_ERROR",payload:xs(y.error,"Failed to update profile")}),!1)},updateAccount:async(m,y)=>{const v=await Oe.updateAccount(m,y);return v.data?(n({type:"SET_ACCOUNTS",payload:e.accounts.map(b=>b.id===m?{...b,...y}:b)}),!0):(n({type:"SET_ERROR",payload:xs(v.error,"Failed to update account")}),!1)},retryProcessing:async m=>{const y=await Oe.retryEmail(m);if(y.data?.success){const v=e.emails.find(b=>b.id===m);return v&&n({type:"UPDATE_EMAIL",payload:{...v,processing_status:"pending",processing_error:null}}),!0}return n({type:"SET_ERROR",payload:xs(y.error,"Retry failed")}),!1},createRule:async m=>{const y=await Oe.createRule(m);return y.data?(n({type:"ADD_RULE",payload:y.data.rule}),!0):(n({type:"SET_ERROR",payload:xs(y.error,"Failed to create rule")}),!1)},updateRule:async(m,y)=>{const v=await Oe.updateRule(m,y);return v.data?(n({type:"UPDATE_RULE",payload:v.data.rule}),!0):(n({type:"SET_ERROR",payload:xs(v.error,"Failed to update rule")}),!1)},deleteRule:async m=>{const y=await Oe.deleteRule(m);return y.data?.success?(n({type:"REMOVE_RULE",payload:m}),!0):(n({type:"SET_ERROR",payload:xs(y.error,"Failed to delete rule")}),!1)},toggleRule:async m=>{const y=await Oe.toggleRule(m);return y.data?(n({type:"UPDATE_RULE",payload:y.data.rule}),!0):(n({type:"SET_ERROR",payload:xs(y.error,"Failed to toggle rule")}),!1)}};return o.jsx(Aw.Provider,{value:{state:e,isSubscribed:f,dispatch:n,actions:p},children:t})}function oa(){const t=w.useContext(Aw);if(!t)throw new Error("useApp must be used within AppProvider");return t}const pC=w.createContext(void 0);function gC({children:t,value:e}){return o.jsx(pC.Provider,{value:e,children:t})}const kw=w.createContext(null);function yC({children:t}){const[e,n]=w.useState(!1),r=()=>n(!0),l=()=>n(!1);return o.jsx(kw.Provider,{value:{isExpanded:e,setIsExpanded:n,openTerminal:r,closeTerminal:l},children:t})}function Cw(){const t=w.useContext(kw);if(!t)throw new Error("useTerminal must be used within a TerminalProvider");return t}const ot=w.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:Se("rounded-xl border bg-card text-card-foreground shadow",t),...e}));ot.displayName="Card";const Zn=w.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:Se("flex flex-col space-y-1.5 p-6",t),...e}));Zn.displayName="CardHeader";const ea=w.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:Se("font-semibold leading-none tracking-tight",t),...e}));ea.displayName="CardTitle";const Ka=w.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:Se("text-sm text-muted-foreground",t),...e}));Ka.displayName="CardDescription";const ta=w.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:Se("p-6 pt-0",t),...e}));ta.displayName="CardContent";const vC=w.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:Se("flex items-center p-6 pt-0",t),...e}));vC.displayName="CardFooter";class xC extends w.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error("ErrorBoundary caught an error:",e,n)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:o.jsx("div",{className:"min-h-screen flex items-center justify-center p-8 bg-background",children:o.jsxs(ot,{className:"max-w-md w-full p-8 text-center",children:[o.jsx("div",{className:"w-16 h-16 bg-destructive/10 text-destructive rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx(xi,{className:"w-8 h-8"})}),o.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Something went wrong"}),o.jsx("p",{className:"text-muted-foreground mb-6",children:"An unexpected error occurred. Please try refreshing the page."}),this.state.error&&o.jsx("pre",{className:"text-xs text-left bg-secondary p-3 rounded-lg mb-6 overflow-auto max-h-32",children:this.state.error.message}),o.jsxs("div",{className:"flex gap-3 justify-center",children:[o.jsxs(Q,{onClick:this.handleReset,variant:"outline",children:[o.jsx(Lt,{className:"w-4 h-4 mr-2"}),"Try Again"]}),o.jsx(Q,{onClick:()=>window.location.reload(),children:"Refresh Page"})]})]})}):this.props.children}}function dt({size:t="md",className:e,text:n}){const r={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};return o.jsxs("div",{className:Se("flex flex-col items-center justify-center gap-3",e),children:[o.jsx(_t,{className:Se("animate-spin text-primary",r[t])}),n&&o.jsx("p",{className:"text-sm text-muted-foreground",children:n})]})}function hu({text:t="Loading..."}){return o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx(dt,{size:"lg",text:t})})}function bC(){return o.jsx("div",{className:"p-12 flex items-center justify-center",children:o.jsx(dt,{size:"md"})})}const Vm=w.createContext({});function Bm(t){const e=w.useRef(null);return e.current===null&&(e.current=t()),e.current}const Rw=typeof window<"u",Ow=Rw?w.useLayoutEffect:w.useEffect,Au=w.createContext(null);function Im(t,e){t.indexOf(e)===-1&&t.push(e)}function $m(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Fs=(t,e,n)=>n>e?e:n<t?t:n;let qm=()=>{};const xn={},Dw=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Mw(t){return typeof t=="object"&&t!==null}const zw=t=>/^0[^.\s]+$/u.test(t);function Hm(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ss=t=>t,wC=(t,e)=>n=>e(t(n)),nl=(...t)=>t.reduce(wC),Xo=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class Gm{constructor(){this.subscriptions=[]}add(e){return Im(this.subscriptions,e),()=>$m(this.subscriptions,e)}notify(e,n,r){const l=this.subscriptions.length;if(l)if(l===1)this.subscriptions[0](e,n,r);else for(let u=0;u<l;u++){const d=this.subscriptions[u];d&&d(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const vn=t=>t*1e3,ws=t=>t/1e3;function Lw(t,e){return e?t*(1e3/e):0}const Uw=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,SC=1e-7,_C=12;function jC(t,e,n,r,l){let u,d,f=0;do d=e+(n-e)/2,u=Uw(d,r,l)-t,u>0?n=d:e=d;while(Math.abs(u)>SC&&++f<_C);return d}function al(t,e,n,r){if(t===e&&n===r)return Ss;const l=u=>jC(u,0,1,t,n);return u=>u===0||u===1?u:Uw(l(u),e,r)}const Pw=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Vw=t=>e=>1-t(1-e),Bw=al(.33,1.53,.69,.99),Fm=Vw(Bw),Iw=Pw(Fm),$w=t=>(t*=2)<1?.5*Fm(t):.5*(2-Math.pow(2,-10*(t-1))),Km=t=>1-Math.sin(Math.acos(t)),qw=Vw(Km),Hw=Pw(Km),NC=al(.42,0,1,1),EC=al(0,0,.58,1),Gw=al(.42,0,.58,1),TC=t=>Array.isArray(t)&&typeof t[0]!="number",Fw=t=>Array.isArray(t)&&typeof t[0]=="number",AC={linear:Ss,easeIn:NC,easeInOut:Gw,easeOut:EC,circIn:Km,circInOut:Hw,circOut:qw,backIn:Fm,backInOut:Iw,backOut:Bw,anticipate:$w},kC=t=>typeof t=="string",sx=t=>{if(Fw(t)){qm(t.length===4);const[e,n,r,l]=t;return al(e,n,r,l)}else if(kC(t))return AC[t];return t},Vc=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function CC(t,e){let n=new Set,r=new Set,l=!1,u=!1;const d=new WeakSet;let f={delta:0,timestamp:0,isProcessing:!1};function p(y){d.has(y)&&(m.schedule(y),t()),y(f)}const m={schedule:(y,v=!1,b=!1)=>{const _=b&&l?n:r;return v&&d.add(y),_.has(y)||_.add(y),y},cancel:y=>{r.delete(y),d.delete(y)},process:y=>{if(f=y,l){u=!0;return}l=!0,[n,r]=[r,n],n.forEach(p),n.clear(),l=!1,u&&(u=!1,m.process(y))}};return m}const RC=40;function Kw(t,e){let n=!1,r=!0;const l={delta:0,timestamp:0,isProcessing:!1},u=()=>n=!0,d=Vc.reduce((A,U)=>(A[U]=CC(u),A),{}),{setup:f,read:p,resolveKeyframes:m,preUpdate:y,update:v,preRender:b,render:S,postRender:_}=d,N=()=>{const A=xn.useManualTiming?l.timestamp:performance.now();n=!1,xn.useManualTiming||(l.delta=r?1e3/60:Math.max(Math.min(A-l.timestamp,RC),1)),l.timestamp=A,l.isProcessing=!0,f.process(l),p.process(l),m.process(l),y.process(l),v.process(l),b.process(l),S.process(l),_.process(l),l.isProcessing=!1,n&&e&&(r=!1,t(N))},E=()=>{n=!0,r=!0,l.isProcessing||t(N)};return{schedule:Vc.reduce((A,U)=>{const H=d[U];return A[U]=(G,z=!1,M=!1)=>(n||E(),H.schedule(G,z,M)),A},{}),cancel:A=>{for(let U=0;U<Vc.length;U++)d[Vc[U]].cancel(A)},state:l,steps:d}}const{schedule:Ze,cancel:ra,state:zt,steps:hf}=Kw(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ss,!0);let Qc;function OC(){Qc=void 0}const $t={now:()=>(Qc===void 0&&$t.set(zt.isProcessing||xn.useManualTiming?zt.timestamp:performance.now()),Qc),set:t=>{Qc=t,queueMicrotask(OC)}},Yw=t=>e=>typeof e=="string"&&e.startsWith(t),Xw=Yw("--"),DC=Yw("var(--"),Ym=t=>DC(t)?MC.test(t.split("/*")[0].trim()):!1,MC=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function nx(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const Ni={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Wo={...Ni,transform:t=>Fs(0,1,t)},Bc={...Ni,default:1},zo=t=>Math.round(t*1e5)/1e5,Xm=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function zC(t){return t==null}const LC=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Wm=(t,e)=>n=>!!(typeof n=="string"&&LC.test(n)&&n.startsWith(t)||e&&!zC(n)&&Object.prototype.hasOwnProperty.call(n,e)),Ww=(t,e,n)=>r=>{if(typeof r!="string")return r;const[l,u,d,f]=r.match(Xm);return{[t]:parseFloat(l),[e]:parseFloat(u),[n]:parseFloat(d),alpha:f!==void 0?parseFloat(f):1}},UC=t=>Fs(0,255,t),ff={...Ni,transform:t=>Math.round(UC(t))},Ga={test:Wm("rgb","red"),parse:Ww("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+ff.transform(t)+", "+ff.transform(e)+", "+ff.transform(n)+", "+zo(Wo.transform(r))+")"};function PC(t){let e="",n="",r="",l="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),l=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),l=t.substring(4,5),e+=e,n+=n,r+=r,l+=l),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:l?parseInt(l,16)/255:1}}const Qf={test:Wm("#"),parse:PC,transform:Ga.transform},rl=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Kn=rl("deg"),Hs=rl("%"),ue=rl("px"),VC=rl("vh"),BC=rl("vw"),ax={...Hs,parse:t=>Hs.parse(t)/100,transform:t=>Hs.transform(t*100)},ci={test:Wm("hsl","hue"),parse:Ww("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+Hs.transform(zo(e))+", "+Hs.transform(zo(n))+", "+zo(Wo.transform(r))+")"},yt={test:t=>Ga.test(t)||Qf.test(t)||ci.test(t),parse:t=>Ga.test(t)?Ga.parse(t):ci.test(t)?ci.parse(t):Qf.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ga.transform(t):ci.transform(t),getAnimatableNone:t=>{const e=yt.parse(t);return e.alpha=0,yt.transform(e)}},IC=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function $C(t){return isNaN(t)&&typeof t=="string"&&(t.match(Xm)?.length||0)+(t.match(IC)?.length||0)>0}const Jw="number",Qw="color",qC="var",HC="var(",rx="${}",GC=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Jo(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},l=[];let u=0;const f=e.replace(GC,p=>(yt.test(p)?(r.color.push(u),l.push(Qw),n.push(yt.parse(p))):p.startsWith(HC)?(r.var.push(u),l.push(qC),n.push(p)):(r.number.push(u),l.push(Jw),n.push(parseFloat(p))),++u,rx)).split(rx);return{values:n,split:f,indexes:r,types:l}}function Zw(t){return Jo(t).values}function e1(t){const{split:e,types:n}=Jo(t),r=e.length;return l=>{let u="";for(let d=0;d<r;d++)if(u+=e[d],l[d]!==void 0){const f=n[d];f===Jw?u+=zo(l[d]):f===Qw?u+=yt.transform(l[d]):u+=l[d]}return u}}const FC=t=>typeof t=="number"?0:yt.test(t)?yt.getAnimatableNone(t):t;function KC(t){const e=Zw(t);return e1(t)(e.map(FC))}const ia={test:$C,parse:Zw,createTransformer:e1,getAnimatableNone:KC};function mf(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function YC({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let l=0,u=0,d=0;if(!e)l=u=d=n;else{const f=n<.5?n*(1+e):n+e-n*e,p=2*n-f;l=mf(p,f,t+1/3),u=mf(p,f,t),d=mf(p,f,t-1/3)}return{red:Math.round(l*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:r}}function fu(t,e){return n=>n>0?e:t}const st=(t,e,n)=>t+(e-t)*n,pf=(t,e,n)=>{const r=t*t,l=n*(e*e-r)+r;return l<0?0:Math.sqrt(l)},XC=[Qf,Ga,ci],WC=t=>XC.find(e=>e.test(t));function ix(t){const e=WC(t);if(!e)return!1;let n=e.parse(t);return e===ci&&(n=YC(n)),n}const ox=(t,e)=>{const n=ix(t),r=ix(e);if(!n||!r)return fu(t,e);const l={...n};return u=>(l.red=pf(n.red,r.red,u),l.green=pf(n.green,r.green,u),l.blue=pf(n.blue,r.blue,u),l.alpha=st(n.alpha,r.alpha,u),Ga.transform(l))},Zf=new Set(["none","hidden"]);function JC(t,e){return Zf.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function QC(t,e){return n=>st(t,e,n)}function Jm(t){return typeof t=="number"?QC:typeof t=="string"?Ym(t)?fu:yt.test(t)?ox:tR:Array.isArray(t)?t1:typeof t=="object"?yt.test(t)?ox:ZC:fu}function t1(t,e){const n=[...t],r=n.length,l=t.map((u,d)=>Jm(u)(u,e[d]));return u=>{for(let d=0;d<r;d++)n[d]=l[d](u);return n}}function ZC(t,e){const n={...t,...e},r={};for(const l in n)t[l]!==void 0&&e[l]!==void 0&&(r[l]=Jm(t[l])(t[l],e[l]));return l=>{for(const u in r)n[u]=r[u](l);return n}}function eR(t,e){const n=[],r={color:0,var:0,number:0};for(let l=0;l<e.values.length;l++){const u=e.types[l],d=t.indexes[u][r[u]],f=t.values[d]??0;n[l]=f,r[u]++}return n}const tR=(t,e)=>{const n=ia.createTransformer(e),r=Jo(t),l=Jo(e);return r.indexes.var.length===l.indexes.var.length&&r.indexes.color.length===l.indexes.color.length&&r.indexes.number.length>=l.indexes.number.length?Zf.has(t)&&!l.values.length||Zf.has(e)&&!r.values.length?JC(t,e):nl(t1(eR(r,l),l.values),n):fu(t,e)};function s1(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?st(t,e,n):Jm(t)(t,e)}const sR=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Ze.update(e,n),stop:()=>ra(e),now:()=>zt.isProcessing?zt.timestamp:$t.now()}},n1=(t,e,n=10)=>{let r="";const l=Math.max(Math.round(e/n),2);for(let u=0;u<l;u++)r+=Math.round(t(u/(l-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},mu=2e4;function Qm(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<mu;)e+=n,r=t.next(e);return e>=mu?1/0:e}function nR(t,e=100,n){const r=n({...t,keyframes:[0,e]}),l=Math.min(Qm(r),mu);return{type:"keyframes",ease:u=>r.next(l*u).value/e,duration:ws(l)}}const aR=5;function a1(t,e,n){const r=Math.max(e-aR,0);return Lw(n-t(r),e-r)}const it={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},gf=.001;function rR({duration:t=it.duration,bounce:e=it.bounce,velocity:n=it.velocity,mass:r=it.mass}){let l,u,d=1-e;d=Fs(it.minDamping,it.maxDamping,d),t=Fs(it.minDuration,it.maxDuration,ws(t)),d<1?(l=m=>{const y=m*d,v=y*t,b=y-n,S=em(m,d),_=Math.exp(-v);return gf-b/S*_},u=m=>{const v=m*d*t,b=v*n+n,S=Math.pow(d,2)*Math.pow(m,2)*t,_=Math.exp(-v),N=em(Math.pow(m,2),d);return(-l(m)+gf>0?-1:1)*((b-S)*_)/N}):(l=m=>{const y=Math.exp(-m*t),v=(m-n)*t+1;return-gf+y*v},u=m=>{const y=Math.exp(-m*t),v=(n-m)*(t*t);return y*v});const f=5/t,p=oR(l,u,f);if(t=vn(t),isNaN(p))return{stiffness:it.stiffness,damping:it.damping,duration:t};{const m=Math.pow(p,2)*r;return{stiffness:m,damping:d*2*Math.sqrt(r*m),duration:t}}}const iR=12;function oR(t,e,n){let r=n;for(let l=1;l<iR;l++)r=r-t(r)/e(r);return r}function em(t,e){return t*Math.sqrt(1-e*e)}const lR=["duration","bounce"],cR=["stiffness","damping","mass"];function lx(t,e){return e.some(n=>t[n]!==void 0)}function uR(t){let e={velocity:it.velocity,stiffness:it.stiffness,damping:it.damping,mass:it.mass,isResolvedFromDuration:!1,...t};if(!lx(t,cR)&&lx(t,lR))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),l=r*r,u=2*Fs(.05,1,1-(t.bounce||0))*Math.sqrt(l);e={...e,mass:it.mass,stiffness:l,damping:u}}else{const n=rR(t);e={...e,...n,mass:it.mass},e.isResolvedFromDuration=!0}return e}function pu(t=it.visualDuration,e=it.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:l}=n;const u=n.keyframes[0],d=n.keyframes[n.keyframes.length-1],f={done:!1,value:u},{stiffness:p,damping:m,mass:y,duration:v,velocity:b,isResolvedFromDuration:S}=uR({...n,velocity:-ws(n.velocity||0)}),_=b||0,N=m/(2*Math.sqrt(p*y)),E=d-u,T=ws(Math.sqrt(p/y)),D=Math.abs(E)<5;r||(r=D?it.restSpeed.granular:it.restSpeed.default),l||(l=D?it.restDelta.granular:it.restDelta.default);let A;if(N<1){const H=em(T,N);A=G=>{const z=Math.exp(-N*T*G);return d-z*((_+N*T*E)/H*Math.sin(H*G)+E*Math.cos(H*G))}}else if(N===1)A=H=>d-Math.exp(-T*H)*(E+(_+T*E)*H);else{const H=T*Math.sqrt(N*N-1);A=G=>{const z=Math.exp(-N*T*G),M=Math.min(H*G,300);return d-z*((_+N*T*E)*Math.sinh(M)+H*E*Math.cosh(M))/H}}const U={calculatedDuration:S&&v||null,next:H=>{const G=A(H);if(S)f.done=H>=v;else{let z=H===0?_:0;N<1&&(z=H===0?vn(_):a1(A,H,G));const M=Math.abs(z)<=r,J=Math.abs(d-G)<=l;f.done=M&&J}return f.value=f.done?d:G,f},toString:()=>{const H=Math.min(Qm(U),mu),G=n1(z=>U.next(H*z).value,H,30);return H+"ms "+G},toTransition:()=>{}};return U}pu.applyToOptions=t=>{const e=nR(t,100,pu);return t.ease=e.ease,t.duration=vn(e.duration),t.type="keyframes",t};function tm({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:l=10,bounceStiffness:u=500,modifyTarget:d,min:f,max:p,restDelta:m=.5,restSpeed:y}){const v=t[0],b={done:!1,value:v},S=M=>f!==void 0&&M<f||p!==void 0&&M>p,_=M=>f===void 0?p:p===void 0||Math.abs(f-M)<Math.abs(p-M)?f:p;let N=n*e;const E=v+N,T=d===void 0?E:d(E);T!==E&&(N=T-v);const D=M=>-N*Math.exp(-M/r),A=M=>T+D(M),U=M=>{const J=D(M),ie=A(M);b.done=Math.abs(J)<=m,b.value=b.done?T:ie};let H,G;const z=M=>{S(b.value)&&(H=M,G=pu({keyframes:[b.value,_(b.value)],velocity:a1(A,M,b.value),damping:l,stiffness:u,restDelta:m,restSpeed:y}))};return z(0),{calculatedDuration:null,next:M=>{let J=!1;return!G&&H===void 0&&(J=!0,U(M),z(M)),H!==void 0&&M>=H?G.next(M-H):(!J&&U(M),b)}}}function dR(t,e,n){const r=[],l=n||xn.mix||s1,u=t.length-1;for(let d=0;d<u;d++){let f=l(t[d],t[d+1]);if(e){const p=Array.isArray(e)?e[d]||Ss:e;f=nl(p,f)}r.push(f)}return r}function hR(t,e,{clamp:n=!0,ease:r,mixer:l}={}){const u=t.length;if(qm(u===e.length),u===1)return()=>e[0];if(u===2&&e[0]===e[1])return()=>e[1];const d=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),e=[...e].reverse());const f=dR(e,r,l),p=f.length,m=y=>{if(d&&y<t[0])return e[0];let v=0;if(p>1)for(;v<t.length-2&&!(y<t[v+1]);v++);const b=Xo(t[v],t[v+1],y);return f[v](b)};return n?y=>m(Fs(t[0],t[u-1],y)):m}function fR(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const l=Xo(0,e,r);t.push(st(n,1,l))}}function mR(t){const e=[0];return fR(e,t.length-1),e}function pR(t,e){return t.map(n=>n*e)}function gR(t,e){return t.map(()=>e||Gw).splice(0,t.length-1)}function Lo({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const l=TC(r)?r.map(sx):sx(r),u={done:!1,value:e[0]},d=pR(n&&n.length===e.length?n:mR(e),t),f=hR(d,e,{ease:Array.isArray(l)?l:gR(e,l)});return{calculatedDuration:t,next:p=>(u.value=f(p),u.done=p>=t,u)}}const yR=t=>t!==null;function Zm(t,{repeat:e,repeatType:n="loop"},r,l=1){const u=t.filter(yR),f=l<0||e&&n!=="loop"&&e%2===1?0:u.length-1;return!f||r===void 0?u[f]:r}const vR={decay:tm,inertia:tm,tween:Lo,keyframes:Lo,spring:pu};function r1(t){typeof t.type=="string"&&(t.type=vR[t.type])}class ep{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const xR=t=>t/100;class tp extends ep{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==$t.now()&&this.tick($t.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;r1(e);const{type:n=Lo,repeat:r=0,repeatDelay:l=0,repeatType:u,velocity:d=0}=e;let{keyframes:f}=e;const p=n||Lo;p!==Lo&&typeof f[0]!="number"&&(this.mixKeyframes=nl(xR,s1(f[0],f[1])),f=[0,100]);const m=p({...e,keyframes:f});u==="mirror"&&(this.mirroredGenerator=p({...e,keyframes:[...f].reverse(),velocity:-d})),m.calculatedDuration===null&&(m.calculatedDuration=Qm(m));const{calculatedDuration:y}=m;this.calculatedDuration=y,this.resolvedDuration=y+l,this.totalDuration=this.resolvedDuration*(r+1)-l,this.generator=m}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:l,mixKeyframes:u,mirroredGenerator:d,resolvedDuration:f,calculatedDuration:p}=this;if(this.startTime===null)return r.next(0);const{delay:m=0,keyframes:y,repeat:v,repeatType:b,repeatDelay:S,type:_,onUpdate:N,finalKeyframe:E}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-l/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const T=this.currentTime-m*(this.playbackSpeed>=0?1:-1),D=this.playbackSpeed>=0?T<0:T>l;this.currentTime=Math.max(T,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=l);let A=this.currentTime,U=r;if(v){const M=Math.min(this.currentTime,l)/f;let J=Math.floor(M),ie=M%1;!ie&&M>=1&&(ie=1),ie===1&&J--,J=Math.min(J,v+1),J%2&&(b==="reverse"?(ie=1-ie,S&&(ie-=S/f)):b==="mirror"&&(U=d)),A=Fs(0,1,ie)*f}const H=D?{done:!1,value:y[0]}:U.next(A);u&&(H.value=u(H.value));let{done:G}=H;!D&&p!==null&&(G=this.playbackSpeed>=0?this.currentTime>=l:this.currentTime<=0);const z=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&G);return z&&_!==tm&&(H.value=Zm(y,this.options,E,this.speed)),N&&N(H.value),z&&this.finish(),H}then(e,n){return this.finished.then(e,n)}get duration(){return ws(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ws(e)}get time(){return ws(this.currentTime)}set time(e){e=vn(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime($t.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=ws(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=sR,startTime:n}=this.options;this.driver||(this.driver=e(l=>this.tick(l))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime($t.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function bR(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Fa=t=>t*180/Math.PI,sm=t=>{const e=Fa(Math.atan2(t[1],t[0]));return nm(e)},wR={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:sm,rotateZ:sm,skewX:t=>Fa(Math.atan(t[1])),skewY:t=>Fa(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},nm=t=>(t=t%360,t<0&&(t+=360),t),cx=sm,ux=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),dx=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),SR={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ux,scaleY:dx,scale:t=>(ux(t)+dx(t))/2,rotateX:t=>nm(Fa(Math.atan2(t[6],t[5]))),rotateY:t=>nm(Fa(Math.atan2(-t[2],t[0]))),rotateZ:cx,rotate:cx,skewX:t=>Fa(Math.atan(t[4])),skewY:t=>Fa(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function am(t){return t.includes("scale")?1:0}function rm(t,e){if(!t||t==="none")return am(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,l;if(n)r=SR,l=n;else{const f=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=wR,l=f}if(!l)return am(e);const u=r[e],d=l[1].split(",").map(jR);return typeof u=="function"?u(d):d[u]}const _R=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return rm(n,e)};function jR(t){return parseFloat(t.trim())}const Ei=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ti=new Set(Ei),hx=t=>t===Ni||t===ue,NR=new Set(["x","y","z"]),ER=Ei.filter(t=>!NR.has(t));function TR(t){const e=[];return ER.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const Qn={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>rm(e,"x"),y:(t,{transform:e})=>rm(e,"y")};Qn.translateX=Qn.x;Qn.translateY=Qn.y;const Ya=new Set;let im=!1,om=!1,lm=!1;function i1(){if(om){const t=Array.from(Ya).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const l=TR(r);l.length&&(n.set(r,l),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const l=n.get(r);l&&l.forEach(([u,d])=>{r.getValue(u)?.set(d)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}om=!1,im=!1,Ya.forEach(t=>t.complete(lm)),Ya.clear()}function o1(){Ya.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(om=!0)})}function AR(){lm=!0,o1(),i1(),lm=!1}class sp{constructor(e,n,r,l,u,d=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=l,this.element=u,this.isAsync=d}scheduleResolve(){this.state="scheduled",this.isAsync?(Ya.add(this),im||(im=!0,Ze.read(o1),Ze.resolveKeyframes(i1))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:l}=this;if(e[0]===null){const u=l?.get(),d=e[e.length-1];if(u!==void 0)e[0]=u;else if(r&&n){const f=r.readValue(n,d);f!=null&&(e[0]=f)}e[0]===void 0&&(e[0]=d),l&&u===void 0&&l.set(e[0])}bR(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ya.delete(this)}cancel(){this.state==="scheduled"&&(Ya.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const kR=t=>t.startsWith("--");function CR(t,e,n){kR(e)?t.style.setProperty(e,n):t.style[e]=n}const RR=Hm(()=>window.ScrollTimeline!==void 0),OR={};function DR(t,e){const n=Hm(t);return()=>OR[e]??n()}const l1=DR(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ro=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,fx={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ro([0,.65,.55,1]),circOut:Ro([.55,0,1,.45]),backIn:Ro([.31,.01,.66,-.59]),backOut:Ro([.33,1.53,.69,.99])};function c1(t,e){if(t)return typeof t=="function"?l1()?n1(t,e):"ease-out":Fw(t)?Ro(t):Array.isArray(t)?t.map(n=>c1(n,e)||fx.easeOut):fx[t]}function MR(t,e,n,{delay:r=0,duration:l=300,repeat:u=0,repeatType:d="loop",ease:f="easeOut",times:p}={},m=void 0){const y={[e]:n};p&&(y.offset=p);const v=c1(f,l);Array.isArray(v)&&(y.easing=v);const b={delay:r,duration:l,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"};return m&&(b.pseudoElement=m),t.animate(y,b)}function u1(t){return typeof t=="function"&&"applyToOptions"in t}function zR({type:t,...e}){return u1(t)&&l1()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class LR extends ep{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:r,keyframes:l,pseudoElement:u,allowFlatten:d=!1,finalKeyframe:f,onComplete:p}=e;this.isPseudoElement=!!u,this.allowFlatten=d,this.options=e,qm(typeof e.type!="string");const m=zR(e);this.animation=MR(n,r,l,m,u),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!u){const y=Zm(l,this.options,f,this.speed);this.updateMotionValue?this.updateMotionValue(y):CR(n,r,y),this.animation.cancel()}p?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ws(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ws(e)}get time(){return ws(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=vn(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&RR()?(this.animation.timeline=e,Ss):n(this)}}const d1={anticipate:$w,backInOut:Iw,circInOut:Hw};function UR(t){return t in d1}function PR(t){typeof t.ease=="string"&&UR(t.ease)&&(t.ease=d1[t.ease])}const yf=10;class VR extends LR{constructor(e){PR(e),r1(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:l,element:u,...d}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const f=new tp({...d,autoplay:!1}),p=Math.max(yf,$t.now()-this.startTime),m=Fs(0,yf,p-yf);n.setWithVelocity(f.sample(Math.max(0,p-m)).value,f.sample(p).value,m),f.stop()}}const mx=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ia.test(t)||t==="0")&&!t.startsWith("url("));function BR(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function IR(t,e,n,r){const l=t[0];if(l===null)return!1;if(e==="display"||e==="visibility")return!0;const u=t[t.length-1],d=mx(l,e),f=mx(u,e);return!d||!f?!1:BR(t)||(n==="spring"||u1(n))&&r}function cm(t){t.duration=0,t.type="keyframes"}const $R=new Set(["opacity","clipPath","filter","transform"]),qR=Hm(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function HR(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:l,damping:u,type:d}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:p,transformTemplate:m}=e.owner.getProps();return qR()&&n&&$R.has(n)&&(n!=="transform"||!m)&&!p&&!r&&l!=="mirror"&&u!==0&&d!=="inertia"}const GR=40;class FR extends ep{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:l=0,repeatDelay:u=0,repeatType:d="loop",keyframes:f,name:p,motionValue:m,element:y,...v}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=$t.now();const b={autoplay:e,delay:n,type:r,repeat:l,repeatDelay:u,repeatType:d,name:p,motionValue:m,element:y,...v},S=y?.KeyframeResolver||sp;this.keyframeResolver=new S(f,(_,N,E)=>this.onKeyframesResolved(_,N,b,!E),p,m,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,l){this.keyframeResolver=void 0;const{name:u,type:d,velocity:f,delay:p,isHandoff:m,onUpdate:y}=r;this.resolvedAt=$t.now(),IR(e,u,d,f)||((xn.instantAnimations||!p)&&y?.(Zm(e,r,n)),e[0]=e[e.length-1],cm(r),r.repeat=0);const b={startTime:l?this.resolvedAt?this.resolvedAt-this.createdAt>GR?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},S=!m&&HR(b),_=b.motionValue?.owner?.current,N=S?new VR({...b,element:_}):new tp(b);N.finished.then(()=>{this.notifyFinished()}).catch(Ss),this.pendingTimeline&&(this.stopTimeline=N.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=N}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),AR()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function h1(t,e,n,r=0,l=1){const u=Array.from(t).sort((m,y)=>m.sortNodePosition(y)).indexOf(e),d=t.size,f=(d-1)*r;return typeof n=="function"?n(u,d):l===1?u*r:f-u*r}const KR=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function YR(t){const e=KR.exec(t);if(!e)return[,];const[,n,r,l]=e;return[`--${n??r}`,l]}function f1(t,e,n=1){const[r,l]=YR(t);if(!r)return;const u=window.getComputedStyle(e).getPropertyValue(r);if(u){const d=u.trim();return Dw(d)?parseFloat(d):d}return Ym(l)?f1(l,e,n+1):l}const XR={type:"spring",stiffness:500,damping:25,restSpeed:10},WR=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),JR={type:"keyframes",duration:.8},QR={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ZR=(t,{keyframes:e})=>e.length>2?JR:Ti.has(t)?t.startsWith("scale")?WR(e[1]):XR:QR,eO=t=>t!==null;function tO(t,{repeat:e,repeatType:n="loop"},r){const l=t.filter(eO),u=e&&n!=="loop"&&e%2===1?0:l.length-1;return l[u]}function np(t,e){return t?.[e]??t?.default??t}function sO({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:l,repeat:u,repeatType:d,repeatDelay:f,from:p,elapsed:m,...y}){return!!Object.keys(y).length}const ap=(t,e,n,r={},l,u)=>d=>{const f=np(r,t)||{},p=f.delay||r.delay||0;let{elapsed:m=0}=r;m=m-vn(p);const y={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...f,delay:-m,onUpdate:b=>{e.set(b),f.onUpdate&&f.onUpdate(b)},onComplete:()=>{d(),f.onComplete&&f.onComplete()},name:t,motionValue:e,element:u?void 0:l};sO(f)||Object.assign(y,ZR(t,y)),y.duration&&(y.duration=vn(y.duration)),y.repeatDelay&&(y.repeatDelay=vn(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let v=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(cm(y),y.delay===0&&(v=!0)),(xn.instantAnimations||xn.skipAnimations)&&(v=!0,cm(y),y.delay=0),y.allowFlatten=!f.type&&!f.ease,v&&!u&&e.get()!==void 0){const b=tO(y.keyframes,f);if(b!==void 0){Ze.update(()=>{y.onUpdate(b),y.onComplete()});return}}return f.isSync?new tp(y):new FR(y)};function px(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function rp(t,e,n,r){if(typeof e=="function"){const[l,u]=px(r);e=e(n!==void 0?n:t.custom,l,u)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[l,u]=px(r);e=e(n!==void 0?n:t.custom,l,u)}return e}function pi(t,e,n){const r=t.getProps();return rp(r,e,n!==void 0?n:r.custom,t)}const m1=new Set(["width","height","top","left","right","bottom",...Ei]),gx=30,nO=t=>!isNaN(parseFloat(t));class aO{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const l=$t.now();if(this.updatedAt!==l&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const u of this.dependents)u.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=$t.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=nO(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Gm);const r=this.events[e].add(n);return e==="change"?()=>{r(),Ze.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=$t.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>gx)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,gx);return Lw(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function bi(t,e){return new aO(t,e)}const um=t=>Array.isArray(t);function rO(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,bi(n))}function iO(t){return um(t)?t[t.length-1]||0:t}function oO(t,e){const n=pi(t,e);let{transitionEnd:r={},transition:l={},...u}=n||{};u={...u,...r};for(const d in u){const f=iO(u[d]);rO(t,d,f)}}const Pt=t=>!!(t&&t.getVelocity);function lO(t){return!!(Pt(t)&&t.add)}function dm(t,e){const n=t.getValue("willChange");if(lO(n))return n.add(e);if(!n&&xn.WillChange){const r=new xn.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function ip(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const cO="framerAppearId",p1="data-"+ip(cO);function g1(t){return t.props[p1]}function uO({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function y1(t,e,{delay:n=0,transitionOverride:r,type:l}={}){let{transition:u=t.getDefaultTransition(),transitionEnd:d,...f}=e;const p=u?.reduceMotion;r&&(u=r);const m=[],y=l&&t.animationState&&t.animationState.getState()[l];for(const v in f){const b=t.getValue(v,t.latestValues[v]??null),S=f[v];if(S===void 0||y&&uO(y,v))continue;const _={delay:n,...np(u||{},v)},N=b.get();if(N!==void 0&&!b.isAnimating&&!Array.isArray(S)&&S===N&&!_.velocity)continue;let E=!1;if(window.MotionHandoffAnimation){const A=g1(t);if(A){const U=window.MotionHandoffAnimation(A,v,Ze);U!==null&&(_.startTime=U,E=!0)}}dm(t,v);const T=p??t.shouldReduceMotion;b.start(ap(v,b,S,T&&m1.has(v)?{type:!1}:_,t,E));const D=b.animation;D&&m.push(D)}return d&&Promise.all(m).then(()=>{Ze.update(()=>{d&&oO(t,d)})}),m}function hm(t,e,n={}){const r=pi(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:l=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(l=n.transitionOverride);const u=r?()=>Promise.all(y1(t,r,n)):()=>Promise.resolve(),d=t.variantChildren&&t.variantChildren.size?(p=0)=>{const{delayChildren:m=0,staggerChildren:y,staggerDirection:v}=l;return dO(t,e,p,m,y,v,n)}:()=>Promise.resolve(),{when:f}=l;if(f){const[p,m]=f==="beforeChildren"?[u,d]:[d,u];return p().then(()=>m())}else return Promise.all([u(),d(n.delay)])}function dO(t,e,n=0,r=0,l=0,u=1,d){const f=[];for(const p of t.variantChildren)p.notify("AnimationStart",e),f.push(hm(p,e,{...d,delay:n+(typeof r=="function"?0:r)+h1(t.variantChildren,p,r,l,u)}).then(()=>p.notify("AnimationComplete",e)));return Promise.all(f)}function hO(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const l=e.map(u=>hm(t,u,n));r=Promise.all(l)}else if(typeof e=="string")r=hm(t,e,n);else{const l=typeof e=="function"?pi(t,e,n.custom):e;r=Promise.all(y1(t,l,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const fO={test:t=>t==="auto",parse:t=>t},v1=t=>e=>e.test(t),x1=[Ni,ue,Hs,Kn,BC,VC,fO],yx=t=>x1.find(v1(t));function mO(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||zw(t):!0}const pO=new Set(["brightness","contrast","saturate","opacity"]);function gO(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(Xm)||[];if(!r)return t;const l=n.replace(r,"");let u=pO.has(e)?1:0;return r!==n&&(u*=100),e+"("+u+l+")"}const yO=/\b([a-z-]*)\(.*?\)/gu,fm={...ia,getAnimatableNone:t=>{const e=t.match(yO);return e?e.map(gO).join(" "):t}},vx={...Ni,transform:Math.round},vO={rotate:Kn,rotateX:Kn,rotateY:Kn,rotateZ:Kn,scale:Bc,scaleX:Bc,scaleY:Bc,scaleZ:Bc,skew:Kn,skewX:Kn,skewY:Kn,distance:ue,translateX:ue,translateY:ue,translateZ:ue,x:ue,y:ue,z:ue,perspective:ue,transformPerspective:ue,opacity:Wo,originX:ax,originY:ax,originZ:ue},op={borderWidth:ue,borderTopWidth:ue,borderRightWidth:ue,borderBottomWidth:ue,borderLeftWidth:ue,borderRadius:ue,borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomRightRadius:ue,borderBottomLeftRadius:ue,width:ue,maxWidth:ue,height:ue,maxHeight:ue,top:ue,right:ue,bottom:ue,left:ue,inset:ue,insetBlock:ue,insetBlockStart:ue,insetBlockEnd:ue,insetInline:ue,insetInlineStart:ue,insetInlineEnd:ue,padding:ue,paddingTop:ue,paddingRight:ue,paddingBottom:ue,paddingLeft:ue,paddingBlock:ue,paddingBlockStart:ue,paddingBlockEnd:ue,paddingInline:ue,paddingInlineStart:ue,paddingInlineEnd:ue,margin:ue,marginTop:ue,marginRight:ue,marginBottom:ue,marginLeft:ue,marginBlock:ue,marginBlockStart:ue,marginBlockEnd:ue,marginInline:ue,marginInlineStart:ue,marginInlineEnd:ue,fontSize:ue,backgroundPositionX:ue,backgroundPositionY:ue,...vO,zIndex:vx,fillOpacity:Wo,strokeOpacity:Wo,numOctaves:vx},xO={...op,color:yt,backgroundColor:yt,outlineColor:yt,fill:yt,stroke:yt,borderColor:yt,borderTopColor:yt,borderRightColor:yt,borderBottomColor:yt,borderLeftColor:yt,filter:fm,WebkitFilter:fm},b1=t=>xO[t];function w1(t,e){let n=b1(t);return n!==fm&&(n=ia),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const bO=new Set(["auto","none","0"]);function wO(t,e,n){let r=0,l;for(;r<t.length&&!l;){const u=t[r];typeof u=="string"&&!bO.has(u)&&Jo(u).values.length&&(l=t[r]),r++}if(l&&n)for(const u of e)t[u]=w1(n,l)}class SO extends sp{constructor(e,n,r,l,u){super(e,n,r,l,u,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let y=0;y<e.length;y++){let v=e[y];if(typeof v=="string"&&(v=v.trim(),Ym(v))){const b=f1(v,n.current);b!==void 0&&(e[y]=b),y===e.length-1&&(this.finalKeyframe=v)}}if(this.resolveNoneKeyframes(),!m1.has(r)||e.length!==2)return;const[l,u]=e,d=yx(l),f=yx(u),p=nx(l),m=nx(u);if(p!==m&&Qn[r]){this.needsMeasurement=!0;return}if(d!==f)if(hx(d)&&hx(f))for(let y=0;y<e.length;y++){const v=e[y];typeof v=="string"&&(e[y]=parseFloat(v))}else Qn[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let l=0;l<e.length;l++)(e[l]===null||mO(e[l]))&&r.push(l);r.length&&wO(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Qn[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const l=n[n.length-1];l!==void 0&&e.getValue(r,l).jump(l,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const l=e.getValue(n);l&&l.jump(this.measuredOrigin,!1);const u=r.length-1,d=r[u];r[u]=Qn[n](e.measureViewportBox(),window.getComputedStyle(e.current)),d!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=d),this.removedTransforms?.length&&this.removedTransforms.forEach(([f,p])=>{e.getValue(f).set(p)}),this.resolveNoneKeyframes()}}function _O(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const l=n?.[t]??r.querySelectorAll(t);return l?Array.from(l):[]}return Array.from(t).filter(r=>r!=null)}const S1=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function mm(t){return Mw(t)&&"offsetHeight"in t}const{schedule:lp}=Kw(queueMicrotask,!1),Rs={x:!1,y:!1};function _1(){return Rs.x||Rs.y}function jO(t){return t==="x"||t==="y"?Rs[t]?null:(Rs[t]=!0,()=>{Rs[t]=!1}):Rs.x||Rs.y?null:(Rs.x=Rs.y=!0,()=>{Rs.x=Rs.y=!1})}function j1(t,e){const n=_O(t),r=new AbortController,l={passive:!0,...e,signal:r.signal};return[n,l,()=>r.abort()]}function xx(t){return!(t.pointerType==="touch"||_1())}function NO(t,e,n={}){const[r,l,u]=j1(t,n),d=f=>{if(!xx(f))return;const{target:p}=f,m=e(p,f);if(typeof m!="function"||!p)return;const y=v=>{xx(v)&&(m(v),p.removeEventListener("pointerleave",y))};p.addEventListener("pointerleave",y,l)};return r.forEach(f=>{f.addEventListener("pointerenter",d,l)}),u}const N1=(t,e)=>e?t===e?!0:N1(t,e.parentElement):!1,cp=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,EO=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function E1(t){return EO.has(t.tagName)||t.isContentEditable===!0}const Zc=new WeakSet;function bx(t){return e=>{e.key==="Enter"&&t(e)}}function vf(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const TO=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=bx(()=>{if(Zc.has(n))return;vf(n,"down");const l=bx(()=>{vf(n,"up")}),u=()=>vf(n,"cancel");n.addEventListener("keyup",l,e),n.addEventListener("blur",u,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function wx(t){return cp(t)&&!_1()}function AO(t,e,n={}){const[r,l,u]=j1(t,n),d=f=>{const p=f.currentTarget;if(!wx(f))return;Zc.add(p);const m=e(p,f),y=(S,_)=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",b),Zc.has(p)&&Zc.delete(p),wx(S)&&typeof m=="function"&&m(S,{success:_})},v=S=>{y(S,p===window||p===document||n.useGlobalTarget||N1(p,S.target))},b=S=>{y(S,!1)};window.addEventListener("pointerup",v,l),window.addEventListener("pointercancel",b,l)};return r.forEach(f=>{(n.useGlobalTarget?window:f).addEventListener("pointerdown",d,l),mm(f)&&(f.addEventListener("focus",m=>TO(m,l)),!E1(f)&&!f.hasAttribute("tabindex")&&(f.tabIndex=0))}),u}function T1(t){return Mw(t)&&"ownerSVGElement"in t}function kO(t){return T1(t)&&t.tagName==="svg"}const CO=[...x1,yt,ia],RO=t=>CO.find(v1(t)),Sx=()=>({translate:0,scale:1,origin:0,originPoint:0}),ui=()=>({x:Sx(),y:Sx()}),_x=()=>({min:0,max:0}),St=()=>({x:_x(),y:_x()}),pm={current:null},A1={current:!1},OO=typeof window<"u";function DO(){if(A1.current=!0,!!OO)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>pm.current=t.matches;t.addEventListener("change",e),e()}else pm.current=!1}const MO=new WeakMap;function ku(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qo(t){return typeof t=="string"||Array.isArray(t)}const up=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],dp=["initial",...up];function Cu(t){return ku(t.animate)||dp.some(e=>Qo(t[e]))}function k1(t){return!!(Cu(t)||t.variants)}function zO(t,e,n){for(const r in e){const l=e[r],u=n[r];if(Pt(l))t.addValue(r,l);else if(Pt(u))t.addValue(r,bi(l,{owner:t}));else if(u!==l)if(t.hasValue(r)){const d=t.getValue(r);d.liveStyle===!0?d.jump(l):d.hasAnimated||d.set(l)}else{const d=t.getStaticValue(r);t.addValue(r,bi(d!==void 0?d:l,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const jx=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let gu={};function C1(t){gu=t}function LO(){return gu}class UO{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:l,blockInitialAnimation:u,visualState:d},f={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=sp,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const b=$t.now();this.renderScheduledAt<b&&(this.renderScheduledAt=b,Ze.render(this.render,!1,!0))};const{latestValues:p,renderState:m}=d;this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=m,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=l,this.options=f,this.blockInitialAnimation=!!u,this.isControllingVariants=Cu(n),this.isVariantNode=k1(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:y,...v}=this.scrapeMotionValuesFromProps(n,{},this);for(const b in v){const S=v[b];p[b]!==void 0&&Pt(S)&&S.set(p[b])}}mount(e){this.current=e,MO.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(A1.current||DO(),this.shouldReduceMotion=pm.current),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),ra(this.notifyUpdate),ra(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=Ti.has(e);r&&this.onBindTransform&&this.onBindTransform();const l=n.on("change",d=>{this.latestValues[e]=d,this.props.onUpdate&&Ze.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let u;typeof window<"u"&&window.MotionCheckAppearSync&&(u=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{l(),u&&u(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in gu){const n=gu[e];if(!n)continue;const{isEnabled:r,Feature:l}=n;if(!this.features[e]&&l&&r(this.props)&&(this.features[e]=new l(this)),this.features[e]){const u=this.features[e];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):St()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<jx.length;r++){const l=jx[r];this.propEventSubscriptions[l]&&(this.propEventSubscriptions[l](),delete this.propEventSubscriptions[l]);const u="on"+l,d=e[u];d&&(this.propEventSubscriptions[l]=this.on(l,d))}this.prevMotionValues=zO(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=bi(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(Dw(r)||zw(r))?r=parseFloat(r):!RO(r)&&ia.test(n)&&(r=w1(e,n)),this.setBaseTarget(e,Pt(r)?r.get():r)),Pt(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const u=rp(this.props,n,this.presenceContext?.custom);u&&(r=u[e])}if(n&&r!==void 0)return r;const l=this.getBaseTargetFromProps(this.props,e);return l!==void 0&&!Pt(l)?l:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Gm),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){lp.render(this.render)}}class R1 extends UO{constructor(){super(...arguments),this.KeyframeResolver=SO}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const r=e.style;return r?r[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Pt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class la{constructor(e){this.isMounted=!1,this.node=e}update(){}}function O1({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function PO({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function VO(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function xf(t){return t===void 0||t===1}function gm({scale:t,scaleX:e,scaleY:n}){return!xf(t)||!xf(e)||!xf(n)}function Pa(t){return gm(t)||D1(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function D1(t){return Nx(t.x)||Nx(t.y)}function Nx(t){return t&&t!=="0%"}function yu(t,e,n){const r=t-n,l=e*r;return n+l}function Ex(t,e,n,r,l){return l!==void 0&&(t=yu(t,l,r)),yu(t,n,r)+e}function ym(t,e=0,n=1,r,l){t.min=Ex(t.min,e,n,r,l),t.max=Ex(t.max,e,n,r,l)}function M1(t,{x:e,y:n}){ym(t.x,e.translate,e.scale,e.originPoint),ym(t.y,n.translate,n.scale,n.originPoint)}const Tx=.999999999999,Ax=1.0000000000001;function BO(t,e,n,r=!1){const l=n.length;if(!l)return;e.x=e.y=1;let u,d;for(let f=0;f<l;f++){u=n[f],d=u.projectionDelta;const{visualElement:p}=u.options;p&&p.props.style&&p.props.style.display==="contents"||(r&&u.options.layoutScroll&&u.scroll&&u!==u.root&&hi(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(e.x*=d.x.scale,e.y*=d.y.scale,M1(t,d)),r&&Pa(u.latestValues)&&hi(t,u.latestValues))}e.x<Ax&&e.x>Tx&&(e.x=1),e.y<Ax&&e.y>Tx&&(e.y=1)}function di(t,e){t.min=t.min+e,t.max=t.max+e}function kx(t,e,n,r,l=.5){const u=st(t.min,t.max,l);ym(t,e,n,u,r)}function hi(t,e){kx(t.x,e.x,e.scaleX,e.scale,e.originX),kx(t.y,e.y,e.scaleY,e.scale,e.originY)}function z1(t,e){return O1(VO(t.getBoundingClientRect(),e))}function IO(t,e,n){const r=z1(t,n),{scroll:l}=e;return l&&(di(r.x,l.offset.x),di(r.y,l.offset.y)),r}const $O={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},qO=Ei.length;function HO(t,e,n){let r="",l=!0;for(let u=0;u<qO;u++){const d=Ei[u],f=t[d];if(f===void 0)continue;let p=!0;if(typeof f=="number")p=f===(d.startsWith("scale")?1:0);else{const m=parseFloat(f);p=d.startsWith("scale")?m===1:m===0}if(!p||n){const m=S1(f,op[d]);if(!p){l=!1;const y=$O[d]||d;r+=`${y}(${m}) `}n&&(e[d]=m)}}return r=r.trim(),n?r=n(e,l?"":r):l&&(r="none"),r}function hp(t,e,n){const{style:r,vars:l,transformOrigin:u}=t;let d=!1,f=!1;for(const p in e){const m=e[p];if(Ti.has(p)){d=!0;continue}else if(Xw(p)){l[p]=m;continue}else{const y=S1(m,op[p]);p.startsWith("origin")?(f=!0,u[p]=y):r[p]=y}}if(e.transform||(d||n?r.transform=HO(e,t.transform,n):r.transform&&(r.transform="none")),f){const{originX:p="50%",originY:m="50%",originZ:y=0}=u;r.transformOrigin=`${p} ${m} ${y}`}}function L1(t,{style:e,vars:n},r,l){const u=t.style;let d;for(d in e)u[d]=e[d];l?.applyProjectionStyles(u,r);for(d in n)u.setProperty(d,n[d])}function Cx(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ao={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(ue.test(t))t=parseFloat(t);else return t;const n=Cx(t,e.target.x),r=Cx(t,e.target.y);return`${n}% ${r}%`}},GO={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,l=ia.parse(t);if(l.length>5)return r;const u=ia.createTransformer(t),d=typeof l[0]!="number"?1:0,f=n.x.scale*e.x,p=n.y.scale*e.y;l[0+d]/=f,l[1+d]/=p;const m=st(f,p,.5);return typeof l[2+d]=="number"&&(l[2+d]/=m),typeof l[3+d]=="number"&&(l[3+d]/=m),u(l)}},vm={borderRadius:{...Ao,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ao,borderTopRightRadius:Ao,borderBottomLeftRadius:Ao,borderBottomRightRadius:Ao,boxShadow:GO};function U1(t,{layout:e,layoutId:n}){return Ti.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!vm[t]||t==="opacity")}function fp(t,e,n){const r=t.style,l=e?.style,u={};if(!r)return u;for(const d in r)(Pt(r[d])||l&&Pt(l[d])||U1(d,t)||n?.getValue(d)?.liveStyle!==void 0)&&(u[d]=r[d]);return u}function FO(t){return window.getComputedStyle(t)}class KO extends R1{constructor(){super(...arguments),this.type="html",this.renderInstance=L1}readValueFromInstance(e,n){if(Ti.has(n))return this.projection?.isProjecting?am(n):_R(e,n);{const r=FO(e),l=(Xw(n)?r.getPropertyValue(n):r[n])||0;return typeof l=="string"?l.trim():l}}measureInstanceViewportBox(e,{transformPagePoint:n}){return z1(e,n)}build(e,n,r){hp(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return fp(e,n,r)}}const YO={offset:"stroke-dashoffset",array:"stroke-dasharray"},XO={offset:"strokeDashoffset",array:"strokeDasharray"};function WO(t,e,n=1,r=0,l=!0){t.pathLength=1;const u=l?YO:XO;t[u.offset]=`${-r}`,t[u.array]=`${e} ${n}`}const JO=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function P1(t,{attrX:e,attrY:n,attrScale:r,pathLength:l,pathSpacing:u=1,pathOffset:d=0,...f},p,m,y){if(hp(t,f,m),p){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:v,style:b}=t;v.transform&&(b.transform=v.transform,delete v.transform),(b.transform||v.transformOrigin)&&(b.transformOrigin=v.transformOrigin??"50% 50%",delete v.transformOrigin),b.transform&&(b.transformBox=y?.transformBox??"fill-box",delete v.transformBox);for(const S of JO)v[S]!==void 0&&(b[S]=v[S],delete v[S]);e!==void 0&&(v.x=e),n!==void 0&&(v.y=n),r!==void 0&&(v.scale=r),l!==void 0&&WO(v,l,u,d,!1)}const V1=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),B1=t=>typeof t=="string"&&t.toLowerCase()==="svg";function QO(t,e,n,r){L1(t,e,void 0,r);for(const l in e.attrs)t.setAttribute(V1.has(l)?l:ip(l),e.attrs[l])}function I1(t,e,n){const r=fp(t,e,n);for(const l in t)if(Pt(t[l])||Pt(e[l])){const u=Ei.indexOf(l)!==-1?"attr"+l.charAt(0).toUpperCase()+l.substring(1):l;r[u]=t[l]}return r}class ZO extends R1{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=St}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Ti.has(n)){const r=b1(n);return r&&r.default||0}return n=V1.has(n)?n:ip(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return I1(e,n,r)}build(e,n,r){P1(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,l){QO(e,n,r,l)}mount(e){this.isSVGTag=B1(e.tagName),super.mount(e)}}const eD=dp.length;function $1(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?$1(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<eD;n++){const r=dp[n],l=t.props[r];(Qo(l)||l===!1)&&(e[r]=l)}return e}function q1(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const tD=[...up].reverse(),sD=up.length;function nD(t){return e=>Promise.all(e.map(({animation:n,options:r})=>hO(t,n,r)))}function aD(t){let e=nD(t),n=Rx(),r=!0;const l=p=>(m,y)=>{const v=pi(t,y,p==="exit"?t.presenceContext?.custom:void 0);if(v){const{transition:b,transitionEnd:S,..._}=v;m={...m,..._,...S}}return m};function u(p){e=p(t)}function d(p){const{props:m}=t,y=$1(t.parent)||{},v=[],b=new Set;let S={},_=1/0;for(let E=0;E<sD;E++){const T=tD[E],D=n[T],A=m[T]!==void 0?m[T]:y[T],U=Qo(A),H=T===p?D.isActive:null;H===!1&&(_=E);let G=A===y[T]&&A!==m[T]&&U;if(G&&r&&t.manuallyAnimateOnMount&&(G=!1),D.protectedKeys={...S},!D.isActive&&H===null||!A&&!D.prevProp||ku(A)||typeof A=="boolean")continue;const z=rD(D.prevProp,A);let M=z||T===p&&D.isActive&&!G&&U||E>_&&U,J=!1;const ie=Array.isArray(A)?A:[A];let be=ie.reduce(l(T),{});H===!1&&(be={});const{prevResolvedValues:de={}}=D,Ve={...de,...be},Ie=q=>{M=!0,b.has(q)&&(J=!0,b.delete(q)),D.needsAnimating[q]=!0;const B=t.getValue(q);B&&(B.liveStyle=!1)};for(const q in Ve){const B=be[q],re=de[q];if(S.hasOwnProperty(q))continue;let pe=!1;um(B)&&um(re)?pe=!q1(B,re):pe=B!==re,pe?B!=null?Ie(q):b.add(q):B!==void 0&&b.has(q)?Ie(q):D.protectedKeys[q]=!0}D.prevProp=A,D.prevResolvedValues=be,D.isActive&&(S={...S,...be}),r&&t.blockInitialAnimation&&(M=!1);const ee=G&&z;M&&(!ee||J)&&v.push(...ie.map(q=>{const B={type:T};if(typeof q=="string"&&r&&!ee&&t.manuallyAnimateOnMount&&t.parent){const{parent:re}=t,pe=pi(re,q);if(re.enteringChildren&&pe){const{delayChildren:R}=pe.transition||{};B.delay=h1(re.enteringChildren,t,R)}}return{animation:q,options:B}}))}if(b.size){const E={};if(typeof m.initial!="boolean"){const T=pi(t,Array.isArray(m.initial)?m.initial[0]:m.initial);T&&T.transition&&(E.transition=T.transition)}b.forEach(T=>{const D=t.getBaseTarget(T),A=t.getValue(T);A&&(A.liveStyle=!0),E[T]=D??null}),v.push({animation:E})}let N=!!v.length;return r&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(N=!1),r=!1,N?e(v):Promise.resolve()}function f(p,m){if(n[p].isActive===m)return Promise.resolve();t.variantChildren?.forEach(v=>v.animationState?.setActive(p,m)),n[p].isActive=m;const y=d(p);for(const v in n)n[v].protectedKeys={};return y}return{animateChanges:d,setActive:f,setAnimateFunction:u,getState:()=>n,reset:()=>{n=Rx()}}}function rD(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!q1(e,t):!1}function La(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Rx(){return{animate:La(!0),whileInView:La(),whileHover:La(),whileTap:La(),whileDrag:La(),whileFocus:La(),exit:La()}}function Ox(t,e){t.min=e.min,t.max=e.max}function ks(t,e){Ox(t.x,e.x),Ox(t.y,e.y)}function Dx(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const H1=1e-4,iD=1-H1,oD=1+H1,G1=.01,lD=0-G1,cD=0+G1;function qt(t){return t.max-t.min}function uD(t,e,n){return Math.abs(t-e)<=n}function Mx(t,e,n,r=.5){t.origin=r,t.originPoint=st(e.min,e.max,t.origin),t.scale=qt(n)/qt(e),t.translate=st(n.min,n.max,t.origin)-t.originPoint,(t.scale>=iD&&t.scale<=oD||isNaN(t.scale))&&(t.scale=1),(t.translate>=lD&&t.translate<=cD||isNaN(t.translate))&&(t.translate=0)}function Uo(t,e,n,r){Mx(t.x,e.x,n.x,r?r.originX:void 0),Mx(t.y,e.y,n.y,r?r.originY:void 0)}function zx(t,e,n){t.min=n.min+e.min,t.max=t.min+qt(e)}function dD(t,e,n){zx(t.x,e.x,n.x),zx(t.y,e.y,n.y)}function Lx(t,e,n){t.min=e.min-n.min,t.max=t.min+qt(e)}function vu(t,e,n){Lx(t.x,e.x,n.x),Lx(t.y,e.y,n.y)}function Ux(t,e,n,r,l){return t-=e,t=yu(t,1/n,r),l!==void 0&&(t=yu(t,1/l,r)),t}function hD(t,e=0,n=1,r=.5,l,u=t,d=t){if(Hs.test(e)&&(e=parseFloat(e),e=st(d.min,d.max,e/100)-d.min),typeof e!="number")return;let f=st(u.min,u.max,r);t===u&&(f-=e),t.min=Ux(t.min,e,n,f,l),t.max=Ux(t.max,e,n,f,l)}function Px(t,e,[n,r,l],u,d){hD(t,e[n],e[r],e[l],e.scale,u,d)}const fD=["x","scaleX","originX"],mD=["y","scaleY","originY"];function Vx(t,e,n,r){Px(t.x,e,fD,n?n.x:void 0,r?r.x:void 0),Px(t.y,e,mD,n?n.y:void 0,r?r.y:void 0)}function Bx(t){return t.translate===0&&t.scale===1}function F1(t){return Bx(t.x)&&Bx(t.y)}function Ix(t,e){return t.min===e.min&&t.max===e.max}function pD(t,e){return Ix(t.x,e.x)&&Ix(t.y,e.y)}function $x(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function K1(t,e){return $x(t.x,e.x)&&$x(t.y,e.y)}function qx(t){return qt(t.x)/qt(t.y)}function Hx(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function bs(t){return[t("x"),t("y")]}function gD(t,e,n){let r="";const l=t.x.translate/e.x,u=t.y.translate/e.y,d=n?.z||0;if((l||u||d)&&(r=`translate3d(${l}px, ${u}px, ${d}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:m,rotate:y,rotateX:v,rotateY:b,skewX:S,skewY:_}=n;m&&(r=`perspective(${m}px) ${r}`),y&&(r+=`rotate(${y}deg) `),v&&(r+=`rotateX(${v}deg) `),b&&(r+=`rotateY(${b}deg) `),S&&(r+=`skewX(${S}deg) `),_&&(r+=`skewY(${_}deg) `)}const f=t.x.scale*e.x,p=t.y.scale*e.y;return(f!==1||p!==1)&&(r+=`scale(${f}, ${p})`),r||"none"}const Y1=["TopLeft","TopRight","BottomLeft","BottomRight"],yD=Y1.length,Gx=t=>typeof t=="string"?parseFloat(t):t,Fx=t=>typeof t=="number"||ue.test(t);function vD(t,e,n,r,l,u){l?(t.opacity=st(0,n.opacity??1,xD(r)),t.opacityExit=st(e.opacity??1,0,bD(r))):u&&(t.opacity=st(e.opacity??1,n.opacity??1,r));for(let d=0;d<yD;d++){const f=`border${Y1[d]}Radius`;let p=Kx(e,f),m=Kx(n,f);if(p===void 0&&m===void 0)continue;p||(p=0),m||(m=0),p===0||m===0||Fx(p)===Fx(m)?(t[f]=Math.max(st(Gx(p),Gx(m),r),0),(Hs.test(m)||Hs.test(p))&&(t[f]+="%")):t[f]=m}(e.rotate||n.rotate)&&(t.rotate=st(e.rotate||0,n.rotate||0,r))}function Kx(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const xD=X1(0,.5,qw),bD=X1(.5,.95,Ss);function X1(t,e,n){return r=>r<t?0:r>e?1:n(Xo(t,e,r))}function wD(t,e,n){const r=Pt(t)?t:bi(t);return r.start(ap("",r,e,n)),r.animation}function Zo(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const SD=(t,e)=>t.depth-e.depth;class _D{constructor(){this.children=[],this.isDirty=!1}add(e){Im(this.children,e),this.isDirty=!0}remove(e){$m(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(SD),this.isDirty=!1,this.children.forEach(e)}}function jD(t,e){const n=$t.now(),r=({timestamp:l})=>{const u=l-n;u>=e&&(ra(r),t(u-e))};return Ze.setup(r,!0),()=>ra(r)}function eu(t){return Pt(t)?t.get():t}class ND{constructor(){this.members=[]}add(e){Im(this.members,e),e.scheduleRender()}remove(e){if($m(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(l=>e===l);if(n===0)return!1;let r;for(let l=n;l>=0;l--){const u=this.members[l];if(u.isPresent!==!1){r=u;break}}return r?(this.promote(r),!0):!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender();const l=r.options.layoutDependency,u=e.options.layoutDependency;l!==void 0&&u!==void 0&&l===u||(e.resumeFrom=r,n&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0));const{crossfade:f}=e.options;f===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:r}=e;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const tu={hasAnimatedSinceResize:!0,hasEverUpdated:!1},bf=["","X","Y","Z"],ED=1e3;let TD=0;function wf(t,e,n,r){const{latestValues:l}=e;l[t]&&(n[t]=l[t],e.setStaticValue(t,0),r&&(r[t]=0))}function W1(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=g1(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:l,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Ze,!(l||u))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&W1(r)}function J1({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:l}){return class{constructor(d={},f=e?.()){this.id=TD++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(CD),this.nodes.forEach(MD),this.nodes.forEach(zD),this.nodes.forEach(RD)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=f?f.root||f:this,this.path=f?[...f.path,f]:[],this.parent=f,this.depth=f?f.depth+1:0;for(let p=0;p<this.path.length;p++)this.path[p].shouldResetTransform=!0;this.root===this&&(this.nodes=new _D)}addEventListener(d,f){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Gm),this.eventHandlers.get(d).add(f)}notifyListeners(d,...f){const p=this.eventHandlers.get(d);p&&p.notify(...f)}hasListeners(d){return this.eventHandlers.has(d)}mount(d){if(this.instance)return;this.isSVG=T1(d)&&!kO(d),this.instance=d;const{layoutId:f,layout:p,visualElement:m}=this.options;if(m&&!m.current&&m.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(p||f)&&(this.isLayoutDirty=!0),t){let y,v=0;const b=()=>this.root.updateBlockedByResize=!1;Ze.read(()=>{v=window.innerWidth}),t(d,()=>{const S=window.innerWidth;S!==v&&(v=S,this.root.updateBlockedByResize=!0,y&&y(),y=jD(b,250),tu.hasAnimatedSinceResize&&(tu.hasAnimatedSinceResize=!1,this.nodes.forEach(Wx)))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&m&&(f||p)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:v,hasRelativeLayoutChanged:b,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||m.getDefaultTransition()||BD,{onLayoutAnimationStart:N,onLayoutAnimationComplete:E}=m.getProps(),T=!this.targetLayout||!K1(this.targetLayout,S),D=!v&&b;if(this.options.layoutRoot||this.resumeFrom||D||v&&(T||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...np(_,"layout"),onPlay:N,onComplete:E};(m.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(y,D)}else v||Wx(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ra(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(LD),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&W1(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y<this.path.length;y++){const v=this.path[y];v.shouldResetTransform=!0,v.updateScroll("snapshot"),v.options.layoutRoot&&v.willUpdate(!1)}const{layoutId:f,layout:p}=this.options;if(f===void 0&&!p)return;const m=this.getTransformTemplate();this.prevTransformTemplateValue=m?m(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Yx);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Xx);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(DD),this.nodes.forEach(AD),this.nodes.forEach(kD)):this.nodes.forEach(Xx),this.clearAllSnapshots();const f=$t.now();zt.delta=Fs(0,1e3/60,f-zt.timestamp),zt.timestamp=f,zt.isProcessing=!0,hf.update.process(zt),hf.preRender.process(zt),hf.render.process(zt),zt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,lp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(OD),this.sharedNodes.forEach(UD)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ze.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ze.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!qt(this.snapshot.measuredBox.x)&&!qt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let p=0;p<this.path.length;p++)this.path[p].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=St(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:f}=this.options;f&&f.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let f=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(f=!1),f&&this.instance){const p=r(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:p,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:p}}}resetTransform(){if(!l)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,f=this.projectionDelta&&!F1(this.projectionDelta),p=this.getTransformTemplate(),m=p?p(this.latestValues,""):void 0,y=m!==this.prevTransformTemplateValue;d&&this.instance&&(f||Pa(this.latestValues)||y)&&(l(this.instance,m),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const f=this.measurePageBox();let p=this.removeElementScroll(f);return d&&(p=this.removeTransform(p)),ID(p),{animationId:this.root.animationId,measuredBox:f,layoutBox:p,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:d}=this.options;if(!d)return St();const f=d.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some($D))){const{scroll:m}=this.root;m&&(di(f.x,m.offset.x),di(f.y,m.offset.y))}return f}removeElementScroll(d){const f=St();if(ks(f,d),this.scroll?.wasRoot)return f;for(let p=0;p<this.path.length;p++){const m=this.path[p],{scroll:y,options:v}=m;m!==this.root&&y&&v.layoutScroll&&(y.wasRoot&&ks(f,d),di(f.x,y.offset.x),di(f.y,y.offset.y))}return f}applyTransform(d,f=!1){const p=St();ks(p,d);for(let m=0;m<this.path.length;m++){const y=this.path[m];!f&&y.options.layoutScroll&&y.scroll&&y!==y.root&&hi(p,{x:-y.scroll.offset.x,y:-y.scroll.offset.y}),Pa(y.latestValues)&&hi(p,y.latestValues)}return Pa(this.latestValues)&&hi(p,this.latestValues),p}removeTransform(d){const f=St();ks(f,d);for(let p=0;p<this.path.length;p++){const m=this.path[p];if(!m.instance||!Pa(m.latestValues))continue;gm(m.latestValues)&&m.updateSnapshot();const y=St(),v=m.measurePageBox();ks(y,v),Vx(f,m.latestValues,m.snapshot?m.snapshot.layoutBox:void 0,y)}return Pa(this.latestValues)&&Vx(f,this.latestValues),f}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==zt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){const f=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=f.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=f.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=f.isSharedProjectionDirty);const p=!!this.resumingFrom||this!==f;if(!(d||p&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:y,layoutId:v}=this.options;if(!this.layout||!(y||v))return;this.resolvedRelativeTargetAt=zt.timestamp;const b=this.getClosestProjectingParent();b&&this.linkedParentVersion!==b.layoutVersion&&!b.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(b&&b.layout?this.createRelativeTarget(b,this.layout.layoutBox,b.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=St(),this.targetWithTransforms=St()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),dD(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ks(this.target,this.layout.layoutBox),M1(this.target,this.targetDelta)):ks(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,b&&!!b.resumingFrom==!!this.resumingFrom&&!b.options.layoutScroll&&b.target&&this.animationProgress!==1?this.createRelativeTarget(b,this.target,b.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||gm(this.parent.latestValues)||D1(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(d,f,p){this.relativeParent=d,this.linkedParentVersion=d.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=St(),this.relativeTargetOrigin=St(),vu(this.relativeTargetOrigin,f,p),ks(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const d=this.getLead(),f=!!this.resumingFrom||this!==d;let p=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(p=!1),f&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(p=!1),this.resolvedRelativeTargetAt===zt.timestamp&&(p=!1),p)return;const{layout:m,layoutId:y}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(m||y))return;ks(this.layoutCorrected,this.layout.layoutBox);const v=this.treeScale.x,b=this.treeScale.y;BO(this.layoutCorrected,this.treeScale,this.path,f),d.layout&&!d.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(d.target=d.layout.layoutBox,d.targetWithTransforms=St());const{target:S}=d;if(!S){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Dx(this.prevProjectionDelta.x,this.projectionDelta.x),Dx(this.prevProjectionDelta.y,this.projectionDelta.y)),Uo(this.projectionDelta,this.layoutCorrected,S,this.latestValues),(this.treeScale.x!==v||this.treeScale.y!==b||!Hx(this.projectionDelta.x,this.prevProjectionDelta.x)||!Hx(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",S))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){if(this.options.visualElement?.scheduleRender(),d){const f=this.getStack();f&&f.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ui(),this.projectionDelta=ui(),this.projectionDeltaWithTransform=ui()}setAnimationOrigin(d,f=!1){const p=this.snapshot,m=p?p.latestValues:{},y={...this.latestValues},v=ui();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!f;const b=St(),S=p?p.source:void 0,_=this.layout?this.layout.source:void 0,N=S!==_,E=this.getStack(),T=!E||E.members.length<=1,D=!!(N&&!T&&this.options.crossfade===!0&&!this.path.some(VD));this.animationProgress=0;let A;this.mixTargetDelta=U=>{const H=U/1e3;Jx(v.x,d.x,H),Jx(v.y,d.y,H),this.setTargetDelta(v),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(vu(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),PD(this.relativeTarget,this.relativeTargetOrigin,b,H),A&&pD(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=St()),ks(A,this.relativeTarget)),N&&(this.animationValues=y,vD(y,m,this.latestValues,H,D,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=H},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(ra(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ze.update(()=>{tu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=bi(0)),this.currentAnimation=wD(this.motionValue,[0,1e3],{...d,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),d.onUpdate&&d.onUpdate(f)},onStop:()=>{},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(ED),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:f,target:p,layout:m,latestValues:y}=d;if(!(!f||!p||!m)){if(this!==d&&this.layout&&m&&Q1(this.options.animationType,this.layout.layoutBox,m.layoutBox)){p=this.target||St();const v=qt(this.layout.layoutBox.x);p.x.min=d.target.x.min,p.x.max=p.x.min+v;const b=qt(this.layout.layoutBox.y);p.y.min=d.target.y.min,p.y.max=p.y.min+b}ks(f,p),hi(f,y),Uo(this.projectionDeltaWithTransform,this.layoutCorrected,f,y)}}registerSharedNode(d,f){this.sharedNodes.has(d)||this.sharedNodes.set(d,new ND),this.sharedNodes.get(d).add(f);const m=f.options.initialPromotionConfig;f.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.shouldPreserveFollowOpacity(f):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){const{layoutId:d}=this.options;return d?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:d}=this.options;return d?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:f,preserveFollowOpacity:p}={}){const m=this.getStack();m&&m.promote(this,p),d&&(this.projectionDelta=void 0,this.needsReset=!0),f&&this.setOptions({transition:f})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let f=!1;const{latestValues:p}=d;if((p.z||p.rotate||p.rotateX||p.rotateY||p.rotateZ||p.skewX||p.skewY)&&(f=!0),!f)return;const m={};p.z&&wf("z",d,m,this.animationValues);for(let y=0;y<bf.length;y++)wf(`rotate${bf[y]}`,d,m,this.animationValues),wf(`skew${bf[y]}`,d,m,this.animationValues);d.render();for(const y in m)d.setStaticValue(y,m[y]),this.animationValues&&(this.animationValues[y]=m[y]);d.scheduleRender()}applyProjectionStyles(d,f){if(!this.instance||this.isSVG)return;if(!this.isVisible){d.visibility="hidden";return}const p=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,d.visibility="",d.opacity="",d.pointerEvents=eu(f?.pointerEvents)||"",d.transform=p?p(this.latestValues,""):"none";return}const m=this.getLead();if(!this.projectionDelta||!this.layout||!m.target){this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=eu(f?.pointerEvents)||""),this.hasProjected&&!Pa(this.latestValues)&&(d.transform=p?p({},""):"none",this.hasProjected=!1);return}d.visibility="";const y=m.animationValues||m.latestValues;this.applyTransformsToTarget();let v=gD(this.projectionDeltaWithTransform,this.treeScale,y);p&&(v=p(y,v)),d.transform=v;const{x:b,y:S}=this.projectionDelta;d.transformOrigin=`${b.origin*100}% ${S.origin*100}% 0`,m.animationValues?d.opacity=m===this?y.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:d.opacity=m===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const _ in vm){if(y[_]===void 0)continue;const{correct:N,applyTo:E,isCSSVariable:T}=vm[_],D=v==="none"?y[_]:N(y[_],m);if(E){const A=E.length;for(let U=0;U<A;U++)d[E[U]]=D}else T?this.options.visualElement.renderState.vars[_]=D:d[_]=D}this.options.layoutId&&(d.pointerEvents=m===this?eu(f?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>d.currentAnimation?.stop()),this.root.nodes.forEach(Yx),this.root.sharedNodes.clear()}}}function AD(t){t.updateLayout()}function kD(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:l}=t.options,u=e.source!==t.layout.source;l==="size"?bs(y=>{const v=u?e.measuredBox[y]:e.layoutBox[y],b=qt(v);v.min=n[y].min,v.max=v.min+b}):Q1(l,e.layoutBox,n)&&bs(y=>{const v=u?e.measuredBox[y]:e.layoutBox[y],b=qt(n[y]);v.max=v.min+b,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[y].max=t.relativeTarget[y].min+b)});const d=ui();Uo(d,n,e.layoutBox);const f=ui();u?Uo(f,t.applyTransform(r,!0),e.measuredBox):Uo(f,n,e.layoutBox);const p=!F1(d);let m=!1;if(!t.resumeFrom){const y=t.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:v,layout:b}=y;if(v&&b){const S=St();vu(S,e.layoutBox,v.layoutBox);const _=St();vu(_,n,b.layoutBox),K1(S,_)||(m=!0),y.options.layoutRoot&&(t.relativeTarget=_,t.relativeTargetOrigin=S,t.relativeParent=y)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:f,layoutDelta:d,hasLayoutChanged:p,hasRelativeLayoutChanged:m})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function CD(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function RD(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function OD(t){t.clearSnapshot()}function Yx(t){t.clearMeasurements()}function Xx(t){t.isLayoutDirty=!1}function DD(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Wx(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function MD(t){t.resolveTargetDelta()}function zD(t){t.calcProjection()}function LD(t){t.resetSkewAndRotation()}function UD(t){t.removeLeadSnapshot()}function Jx(t,e,n){t.translate=st(e.translate,0,n),t.scale=st(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Qx(t,e,n,r){t.min=st(e.min,n.min,r),t.max=st(e.max,n.max,r)}function PD(t,e,n,r){Qx(t.x,e.x,n.x,r),Qx(t.y,e.y,n.y,r)}function VD(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const BD={duration:.45,ease:[.4,0,.1,1]},Zx=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),eb=Zx("applewebkit/")&&!Zx("chrome/")?Math.round:Ss;function tb(t){t.min=eb(t.min),t.max=eb(t.max)}function ID(t){tb(t.x),tb(t.y)}function Q1(t,e,n){return t==="position"||t==="preserve-aspect"&&!uD(qx(e),qx(n),.2)}function $D(t){return t!==t.root&&t.scroll?.wasRoot}const qD=J1({attachResizeListener:(t,e)=>Zo(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Sf={current:void 0},Z1=J1({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Sf.current){const t=new qD({});t.mount(window),t.setOptions({layoutScroll:!0}),Sf.current=t}return Sf.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),mp=w.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function sb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function HD(...t){return e=>{let n=!1;const r=t.map(l=>{const u=sb(l,e);return!n&&typeof u=="function"&&(n=!0),u});if(n)return()=>{for(let l=0;l<r.length;l++){const u=r[l];typeof u=="function"?u():sb(t[l],null)}}}}function GD(...t){return w.useCallback(HD(...t),t)}class FD extends w.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const r=n.offsetParent,l=mm(r)&&r.offsetWidth||0,u=mm(r)&&r.offsetHeight||0,d=this.props.sizeRef.current;d.height=n.offsetHeight||0,d.width=n.offsetWidth||0,d.top=n.offsetTop,d.left=n.offsetLeft,d.right=l-d.width-d.left,d.bottom=u-d.height-d.top}return null}componentDidUpdate(){}render(){return this.props.children}}function KD({children:t,isPresent:e,anchorX:n,anchorY:r,root:l}){const u=w.useId(),d=w.useRef(null),f=w.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=w.useContext(mp),m=t.props?.ref??t?.ref,y=GD(d,m);return w.useInsertionEffect(()=>{const{width:v,height:b,top:S,left:_,right:N,bottom:E}=f.current;if(e||!d.current||!v||!b)return;const T=n==="left"?`left: ${_}`:`right: ${N}`,D=r==="bottom"?`bottom: ${E}`:`top: ${S}`;d.current.dataset.motionPopId=u;const A=document.createElement("style");p&&(A.nonce=p);const U=l??document.head;return U.appendChild(A),A.sheet&&A.sheet.insertRule(`
|
|
52
|
+
[data-motion-pop-id="${u}"] {
|
|
53
|
+
position: absolute !important;
|
|
54
|
+
width: ${v}px !important;
|
|
55
|
+
height: ${b}px !important;
|
|
56
|
+
${T}px !important;
|
|
57
|
+
${D}px !important;
|
|
58
|
+
}
|
|
59
|
+
`),()=>{U.contains(A)&&U.removeChild(A)}},[e]),o.jsx(FD,{isPresent:e,childRef:d,sizeRef:f,children:w.cloneElement(t,{ref:y})})}const YD=({children:t,initial:e,isPresent:n,onExitComplete:r,custom:l,presenceAffectsLayout:u,mode:d,anchorX:f,anchorY:p,root:m})=>{const y=Bm(XD),v=w.useId();let b=!0,S=w.useMemo(()=>(b=!1,{id:v,initial:e,isPresent:n,custom:l,onExitComplete:_=>{y.set(_,!0);for(const N of y.values())if(!N)return;r&&r()},register:_=>(y.set(_,!1),()=>y.delete(_))}),[n,y,r]);return u&&b&&(S={...S}),w.useMemo(()=>{y.forEach((_,N)=>y.set(N,!1))},[n]),w.useEffect(()=>{!n&&!y.size&&r&&r()},[n]),d==="popLayout"&&(t=o.jsx(KD,{isPresent:n,anchorX:f,anchorY:p,root:m,children:t})),o.jsx(Au.Provider,{value:S,children:t})};function XD(){return new Map}function eS(t=!0){const e=w.useContext(Au);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:l}=e,u=w.useId();w.useEffect(()=>{if(t)return l(u)},[t]);const d=w.useCallback(()=>t&&r&&r(u),[u,r,t]);return!n&&r?[!1,d]:[!0]}const Ic=t=>t.key||"";function nb(t){const e=[];return w.Children.forEach(t,n=>{w.isValidElement(n)&&e.push(n)}),e}const tS=({children:t,custom:e,initial:n=!0,onExitComplete:r,presenceAffectsLayout:l=!0,mode:u="sync",propagate:d=!1,anchorX:f="left",anchorY:p="top",root:m})=>{const[y,v]=eS(d),b=w.useMemo(()=>nb(t),[t]),S=d&&!y?[]:b.map(Ic),_=w.useRef(!0),N=w.useRef(b),E=Bm(()=>new Map),T=w.useRef(new Set),[D,A]=w.useState(b),[U,H]=w.useState(b);Ow(()=>{_.current=!1,N.current=b;for(let M=0;M<U.length;M++){const J=Ic(U[M]);S.includes(J)?(E.delete(J),T.current.delete(J)):E.get(J)!==!0&&E.set(J,!1)}},[U,S.length,S.join("-")]);const G=[];if(b!==D){let M=[...b];for(let J=0;J<U.length;J++){const ie=U[J],be=Ic(ie);S.includes(be)||(M.splice(J,0,ie),G.push(ie))}return u==="wait"&&G.length&&(M=G),H(nb(M)),A(b),null}const{forceRender:z}=w.useContext(Vm);return o.jsx(o.Fragment,{children:U.map(M=>{const J=Ic(M),ie=d&&!y?!1:b===U||S.includes(J),be=()=>{if(T.current.has(J))return;if(T.current.add(J),E.has(J))E.set(J,!0);else return;let de=!0;E.forEach(Ve=>{Ve||(de=!1)}),de&&(z?.(),H(N.current),d&&v?.(),r&&r())};return o.jsx(YD,{isPresent:ie,initial:!_.current||n?void 0:!1,custom:e,presenceAffectsLayout:l,mode:u,root:m,onExitComplete:ie?void 0:be,anchorX:f,anchorY:p,children:M},J)})})},sS=w.createContext({strict:!1}),ab={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let rb=!1;function WD(){if(rb)return;const t={};for(const e in ab)t[e]={isEnabled:n=>ab[e].some(r=>!!n[r])};C1(t),rb=!0}function nS(){return WD(),LO()}function JD(t){const e=nS();for(const n in t)e[n]={...e[n],...t[n]};C1(e)}const QD=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function xu(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||QD.has(t)}let aS=t=>!xu(t);function ZD(t){typeof t=="function"&&(aS=e=>e.startsWith("on")?!xu(e):t(e))}try{ZD(require("@emotion/is-prop-valid").default)}catch{}function e4(t,e,n){const r={};for(const l in t)l==="values"&&typeof t.values=="object"||(aS(l)||n===!0&&xu(l)||!e&&!xu(l)||t.draggable&&l.startsWith("onDrag"))&&(r[l]=t[l]);return r}const Ru=w.createContext({});function t4(t,e){if(Cu(t)){const{initial:n,animate:r}=t;return{initial:n===!1||Qo(n)?n:void 0,animate:Qo(r)?r:void 0}}return t.inherit!==!1?e:{}}function s4(t){const{initial:e,animate:n}=t4(t,w.useContext(Ru));return w.useMemo(()=>({initial:e,animate:n}),[ib(e),ib(n)])}function ib(t){return Array.isArray(t)?t.join(" "):t}const pp=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function rS(t,e,n){for(const r in e)!Pt(e[r])&&!U1(r,n)&&(t[r]=e[r])}function n4({transformTemplate:t},e){return w.useMemo(()=>{const n=pp();return hp(n,e,t),Object.assign({},n.vars,n.style)},[e])}function a4(t,e){const n=t.style||{},r={};return rS(r,n,t),Object.assign(r,n4(t,e)),r}function r4(t,e){const n={},r=a4(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const iS=()=>({...pp(),attrs:{}});function i4(t,e,n,r){const l=w.useMemo(()=>{const u=iS();return P1(u,e,B1(r),t.transformTemplate,t.style),{...u.attrs,style:{...u.style}}},[e]);if(t.style){const u={};rS(u,t.style,t),l.style={...u,...l.style}}return l}const o4=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function gp(t){return typeof t!="string"||t.includes("-")?!1:!!(o4.indexOf(t)>-1||/[A-Z]/u.test(t))}function l4(t,e,n,{latestValues:r},l,u=!1,d){const p=(d??gp(t)?i4:r4)(e,r,l,t),m=e4(e,typeof t=="string",u),y=t!==w.Fragment?{...m,...p,ref:n}:{},{children:v}=e,b=w.useMemo(()=>Pt(v)?v.get():v,[v]);return w.createElement(t,{...y,children:b})}function c4({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,l){return{latestValues:u4(n,r,l,t),renderState:e()}}function u4(t,e,n,r){const l={},u=r(t,{});for(const b in u)l[b]=eu(u[b]);let{initial:d,animate:f}=t;const p=Cu(t),m=k1(t);e&&m&&!p&&t.inherit!==!1&&(d===void 0&&(d=e.initial),f===void 0&&(f=e.animate));let y=n?n.initial===!1:!1;y=y||d===!1;const v=y?f:d;if(v&&typeof v!="boolean"&&!ku(v)){const b=Array.isArray(v)?v:[v];for(let S=0;S<b.length;S++){const _=rp(t,b[S]);if(_){const{transitionEnd:N,transition:E,...T}=_;for(const D in T){let A=T[D];if(Array.isArray(A)){const U=y?A.length-1:0;A=A[U]}A!==null&&(l[D]=A)}for(const D in N)l[D]=N[D]}}}return l}const oS=t=>(e,n)=>{const r=w.useContext(Ru),l=w.useContext(Au),u=()=>c4(t,e,r,l);return n?u():Bm(u)},d4=oS({scrapeMotionValuesFromProps:fp,createRenderState:pp}),h4=oS({scrapeMotionValuesFromProps:I1,createRenderState:iS}),f4=Symbol.for("motionComponentSymbol");function m4(t,e,n){const r=w.useRef(n);w.useInsertionEffect(()=>{r.current=n});const l=w.useRef(null);return w.useCallback(u=>{u&&t.onMount?.(u),e&&(u?e.mount(u):e.unmount());const d=r.current;if(typeof d=="function")if(u){const f=d(u);typeof f=="function"&&(l.current=f)}else l.current?(l.current(),l.current=null):d(u);else d&&(d.current=u)},[e])}const lS=w.createContext({});function Oo(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function p4(t,e,n,r,l,u){const{visualElement:d}=w.useContext(Ru),f=w.useContext(sS),p=w.useContext(Au),m=w.useContext(mp).reducedMotion,y=w.useRef(null),v=w.useRef(!1);r=r||f.renderer,!y.current&&r&&(y.current=r(t,{visualState:e,parent:d,props:n,presenceContext:p,blockInitialAnimation:p?p.initial===!1:!1,reducedMotionConfig:m,isSVG:u}),v.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const b=y.current,S=w.useContext(lS);b&&!b.projection&&l&&(b.type==="html"||b.type==="svg")&&g4(y.current,n,l,S);const _=w.useRef(!1);w.useInsertionEffect(()=>{b&&_.current&&b.update(n,p)});const N=n[p1],E=w.useRef(!!N&&!window.MotionHandoffIsComplete?.(N)&&window.MotionHasOptimisedAnimation?.(N));return Ow(()=>{v.current=!0,b&&(_.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),E.current&&b.animationState&&b.animationState.animateChanges())}),w.useEffect(()=>{b&&(!E.current&&b.animationState&&b.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(N)}),E.current=!1),b.enteringChildren=void 0)}),b}function g4(t,e,n,r){const{layoutId:l,layout:u,drag:d,dragConstraints:f,layoutScroll:p,layoutRoot:m,layoutCrossfade:y}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:cS(t.parent)),t.projection.setOptions({layoutId:l,layout:u,alwaysMeasureLayout:!!d||f&&Oo(f),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:p,layoutRoot:m})}function cS(t){if(t)return t.options.allowProjection!==!1?t.projection:cS(t.parent)}function _f(t,{forwardMotionProps:e=!1,type:n}={},r,l){r&&JD(r);const u=n?n==="svg":gp(t),d=u?h4:d4;function f(m,y){let v;const b={...w.useContext(mp),...m,layoutId:y4(m)},{isStatic:S}=b,_=s4(m),N=d(m,S);if(!S&&Rw){v4();const E=x4(b);v=E.MeasureLayout,_.visualElement=p4(t,N,b,l,E.ProjectionNode,u)}return o.jsxs(Ru.Provider,{value:_,children:[v&&_.visualElement?o.jsx(v,{visualElement:_.visualElement,...b}):null,l4(t,m,m4(N,_.visualElement,y),N,S,e,u)]})}f.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const p=w.forwardRef(f);return p[f4]=t,p}function y4({layoutId:t}){const e=w.useContext(Vm).id;return e&&t!==void 0?e+"-"+t:t}function v4(t,e){w.useContext(sS).strict}function x4(t){const e=nS(),{drag:n,layout:r}=e;if(!n&&!r)return{};const l={...n,...r};return{MeasureLayout:n?.isEnabled(t)||r?.isEnabled(t)?l.MeasureLayout:void 0,ProjectionNode:l.ProjectionNode}}function b4(t,e){if(typeof Proxy>"u")return _f;const n=new Map,r=(u,d)=>_f(u,d,t,e),l=(u,d)=>r(u,d);return new Proxy(l,{get:(u,d)=>d==="create"?r:(n.has(d)||n.set(d,_f(d,void 0,t,e)),n.get(d))})}const w4=(t,e)=>e.isSVG??gp(t)?new ZO(e):new KO(e,{allowProjection:t!==w.Fragment});class S4 extends la{constructor(e){super(e),e.animationState||(e.animationState=aD(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();ku(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let _4=0;class j4 extends la{constructor(){super(...arguments),this.id=_4++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const l=this.node.animationState.setActive("exit",!e);n&&!e&&l.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const N4={animation:{Feature:S4},exit:{Feature:j4}};function il(t){return{point:{x:t.pageX,y:t.pageY}}}const E4=t=>e=>cp(e)&&t(e,il(e));function Po(t,e,n,r){return Zo(t,e,E4(n),r)}const uS=({current:t})=>t?t.ownerDocument.defaultView:null,ob=(t,e)=>Math.abs(t-e);function T4(t,e){const n=ob(t.x,e.x),r=ob(t.y,e.y);return Math.sqrt(n**2+r**2)}const lb=new Set(["auto","scroll"]);class dS{constructor(e,n,{transformPagePoint:r,contextWindow:l=window,dragSnapToOrigin:u=!1,distanceThreshold:d=3,element:f}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=S=>{this.handleScroll(S.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=Nf(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,N=T4(S.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!N)return;const{point:E}=S,{timestamp:T}=zt;this.history.push({...E,timestamp:T});const{onStart:D,onMove:A}=this.handlers;_||(D&&D(this.lastMoveEvent,S),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,S)},this.handlePointerMove=(S,_)=>{this.lastMoveEvent=S,this.lastMoveEventInfo=jf(_,this.transformPagePoint),Ze.update(this.updatePoint,!0)},this.handlePointerUp=(S,_)=>{this.end();const{onEnd:N,onSessionEnd:E,resumeAnimation:T}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const D=Nf(S.type==="pointercancel"?this.lastMoveEventInfo:jf(_,this.transformPagePoint),this.history);this.startEvent&&N&&N(S,D),E&&E(S,D)},!cp(e))return;this.dragSnapToOrigin=u,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=d,this.contextWindow=l||window;const p=il(e),m=jf(p,this.transformPagePoint),{point:y}=m,{timestamp:v}=zt;this.history=[{...y,timestamp:v}];const{onSessionStart:b}=n;b&&b(e,Nf(m,this.history)),this.removeListeners=nl(Po(this.contextWindow,"pointermove",this.handlePointerMove),Po(this.contextWindow,"pointerup",this.handlePointerUp),Po(this.contextWindow,"pointercancel",this.handlePointerUp)),f&&this.startScrollTracking(f)}startScrollTracking(e){let n=e.parentElement;for(;n;){const r=getComputedStyle(n);(lb.has(r.overflowX)||lb.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const r=e===window,l=r?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},u={x:l.x-n.x,y:l.y-n.y};u.x===0&&u.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=u.x,this.lastMoveEventInfo.point.y+=u.y):this.history.length>0&&(this.history[0].x-=u.x,this.history[0].y-=u.y),this.scrollPositions.set(e,l),Ze.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ra(this.updatePoint)}}function jf(t,e){return e?{point:e(t.point)}:t}function cb(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Nf({point:t},e){return{point:t,delta:cb(t,hS(e)),offset:cb(t,A4(e)),velocity:k4(e,.1)}}function A4(t){return t[0]}function hS(t){return t[t.length-1]}function k4(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const l=hS(t);for(;n>=0&&(r=t[n],!(l.timestamp-r.timestamp>vn(e)));)n--;if(!r)return{x:0,y:0};const u=ws(l.timestamp-r.timestamp);if(u===0)return{x:0,y:0};const d={x:(l.x-r.x)/u,y:(l.y-r.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}function C4(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?st(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?st(n,t,r.max):Math.min(t,n)),t}function ub(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function R4(t,{top:e,left:n,bottom:r,right:l}){return{x:ub(t.x,n,l),y:ub(t.y,e,r)}}function db(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function O4(t,e){return{x:db(t.x,e.x),y:db(t.y,e.y)}}function D4(t,e){let n=.5;const r=qt(t),l=qt(e);return l>r?n=Xo(e.min,e.max-r,t.min):r>l&&(n=Xo(t.min,t.max-l,e.min)),Fs(0,1,n)}function M4(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const xm=.35;function z4(t=xm){return t===!1?t=0:t===!0&&(t=xm),{x:hb(t,"left","right"),y:hb(t,"top","bottom")}}function hb(t,e,n){return{min:fb(t,e),max:fb(t,n)}}function fb(t,e){return typeof t=="number"?t:t[e]||0}const L4=new WeakMap;class U4{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=St(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:l}=this.visualElement;if(l&&l.isPresent===!1)return;const u=v=>{n?(this.stopAnimation(),this.snapToCursor(il(v).point)):this.pauseAnimation()},d=(v,b)=>{this.stopAnimation();const{drag:S,dragPropagation:_,onDragStart:N}=this.getProps();if(S&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=jO(S),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=b,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),bs(T=>{let D=this.getAxisMotionValue(T).get()||0;if(Hs.test(D)){const{projection:A}=this.visualElement;if(A&&A.layout){const U=A.layout.layoutBox[T];U&&(D=qt(U)*(parseFloat(D)/100))}}this.originPoint[T]=D}),N&&Ze.postRender(()=>N(v,b)),dm(this.visualElement,"transform");const{animationState:E}=this.visualElement;E&&E.setActive("whileDrag",!0)},f=(v,b)=>{this.latestPointerEvent=v,this.latestPanInfo=b;const{dragPropagation:S,dragDirectionLock:_,onDirectionLock:N,onDrag:E}=this.getProps();if(!S&&!this.openDragLock)return;const{offset:T}=b;if(_&&this.currentDirection===null){this.currentDirection=P4(T),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",b.point,T),this.updateAxis("y",b.point,T),this.visualElement.render(),E&&E(v,b)},p=(v,b)=>{this.latestPointerEvent=v,this.latestPanInfo=b,this.stop(v,b),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>bs(v=>this.getAnimationState(v)==="paused"&&this.getAxisMotionValue(v).animation?.play()),{dragSnapToOrigin:y}=this.getProps();this.panSession=new dS(e,{onSessionStart:u,onStart:d,onMove:f,onSessionEnd:p,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:r,contextWindow:uS(this.visualElement),element:this.visualElement.current})}stop(e,n){const r=e||this.latestPointerEvent,l=n||this.latestPanInfo,u=this.isDragging;if(this.cancel(),!u||!l||!r)return;const{velocity:d}=l;this.startAnimation(d);const{onDragEnd:f}=this.getProps();f&&Ze.postRender(()=>f(r,l))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,r){const{drag:l}=this.getProps();if(!r||!$c(e,l,this.currentDirection))return;const u=this.getAxisMotionValue(e);let d=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(d=C4(d,this.constraints[e],this.elastic[e])),u.set(d)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,l=this.constraints;e&&Oo(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=R4(r.layoutBox,e):this.constraints=!1,this.elastic=z4(n),l!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&bs(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=M4(r.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Oo(e))return!1;const r=e.current,{projection:l}=this.visualElement;if(!l||!l.layout)return!1;const u=IO(r,l.root,this.visualElement.getTransformPagePoint());let d=O4(l.layout.layoutBox,u);if(n){const f=n(PO(d));this.hasMutatedConstraints=!!f,f&&(d=O1(f))}return d}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:l,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:f}=this.getProps(),p=this.constraints||{},m=bs(y=>{if(!$c(y,n,this.currentDirection))return;let v=p&&p[y]||{};d&&(v={min:0,max:0});const b=l?200:1e6,S=l?40:1e7,_={type:"inertia",velocity:r?e[y]:0,bounceStiffness:b,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...v};return this.startAxisValueAnimation(y,_)});return Promise.all(m).then(f)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return dm(this.visualElement,e),r.start(ap(e,r,0,n,this.visualElement,!1))}stopAnimation(){bs(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){bs(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),l=r[n];return l||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){bs(n=>{const{drag:r}=this.getProps();if(!$c(n,r,this.currentDirection))return;const{projection:l}=this.visualElement,u=this.getAxisMotionValue(n);if(l&&l.layout){const{min:d,max:f}=l.layout.layoutBox[n],p=u.get()||0;u.set(e[n]-st(d,f,.5)+p)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Oo(n)||!r||!this.constraints)return;this.stopAnimation();const l={x:0,y:0};bs(d=>{const f=this.getAxisMotionValue(d);if(f&&this.constraints!==!1){const p=f.get();l[d]=D4({min:p,max:p},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),bs(d=>{if(!$c(d,e,null))return;const f=this.getAxisMotionValue(d),{min:p,max:m}=this.constraints[d];f.set(st(p,m,l[d]))})}addListeners(){if(!this.visualElement.current)return;L4.set(this.visualElement,this);const e=this.visualElement.current,n=Po(e,"pointerdown",p=>{const{drag:m,dragListener:y=!0}=this.getProps(),v=p.target,b=v!==e&&E1(v);m&&y&&!b&&this.start(p)}),r=()=>{const{dragConstraints:p}=this.getProps();Oo(p)&&p.current&&(this.constraints=this.resolveRefConstraints())},{projection:l}=this.visualElement,u=l.addEventListener("measure",r);l&&!l.layout&&(l.root&&l.root.updateScroll(),l.updateLayout()),Ze.read(r);const d=Zo(window,"resize",()=>this.scalePositionWithinConstraints()),f=l.addEventListener("didUpdate",(({delta:p,hasLayoutChanged:m})=>{this.isDragging&&m&&(bs(y=>{const v=this.getAxisMotionValue(y);v&&(this.originPoint[y]+=p[y].translate,v.set(v.get()+p[y].translate))}),this.visualElement.render())}));return()=>{d(),n(),u(),f&&f()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:l=!1,dragConstraints:u=!1,dragElastic:d=xm,dragMomentum:f=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:l,dragConstraints:u,dragElastic:d,dragMomentum:f}}}function $c(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function P4(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class V4 extends la{constructor(e){super(e),this.removeGroupControls=Ss,this.removeListeners=Ss,this.controls=new U4(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ss}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const mb=t=>(e,n)=>{t&&Ze.postRender(()=>t(e,n))};class B4 extends la{constructor(){super(...arguments),this.removePointerDownListener=Ss}onPointerDown(e){this.session=new dS(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:uS(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:l}=this.node.getProps();return{onSessionStart:mb(e),onStart:mb(n),onMove:r,onEnd:(u,d)=>{delete this.session,l&&Ze.postRender(()=>l(u,d))}}}mount(){this.removePointerDownListener=Po(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Ef=!1;class I4 extends w.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:l}=this.props,{projection:u}=e;u&&(n.group&&n.group.add(u),r&&r.register&&l&&r.register(u),Ef&&u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),tu.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:l,isPresent:u}=this.props,{projection:d}=r;return d&&(d.isPresent=u,e.layoutDependency!==n&&d.setOptions({...d.options,layoutDependency:n}),Ef=!0,l||e.layoutDependency!==n||n===void 0||e.isPresent!==u?d.willUpdate():this.safeToRemove(),e.isPresent!==u&&(u?d.promote():d.relegate()||Ze.postRender(()=>{const f=d.getStack();(!f||!f.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),lp.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:l}=e;Ef=!0,l&&(l.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(l),r&&r.deregister&&r.deregister(l))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function fS(t){const[e,n]=eS(),r=w.useContext(Vm);return o.jsx(I4,{...t,layoutGroup:r,switchLayoutGroup:w.useContext(lS),isPresent:e,safeToRemove:n})}const $4={pan:{Feature:B4},drag:{Feature:V4,ProjectionNode:Z1,MeasureLayout:fS}};function pb(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const l="onHover"+n,u=r[l];u&&Ze.postRender(()=>u(e,il(e)))}class q4 extends la{mount(){const{current:e}=this.node;e&&(this.unmount=NO(e,(n,r)=>(pb(this.node,r,"Start"),l=>pb(this.node,l,"End"))))}unmount(){}}class H4 extends la{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=nl(Zo(this.node.current,"focus",()=>this.onFocus()),Zo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gb(t,e,n){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const l="onTap"+(n==="End"?"":n),u=r[l];u&&Ze.postRender(()=>u(e,il(e)))}class G4 extends la{mount(){const{current:e}=this.node;e&&(this.unmount=AO(e,(n,r)=>(gb(this.node,r,"Start"),(l,{success:u})=>gb(this.node,l,u?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const bm=new WeakMap,Tf=new WeakMap,F4=t=>{const e=bm.get(t.target);e&&e(t)},K4=t=>{t.forEach(F4)};function Y4({root:t,...e}){const n=t||document;Tf.has(n)||Tf.set(n,{});const r=Tf.get(n),l=JSON.stringify(e);return r[l]||(r[l]=new IntersectionObserver(K4,{root:t,...e})),r[l]}function X4(t,e,n){const r=Y4(e);return bm.set(t,n),r.observe(t),()=>{bm.delete(t),r.unobserve(t)}}const W4={some:0,all:1};class J4 extends la{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:r,amount:l="some",once:u}=e,d={root:n?n.current:void 0,rootMargin:r,threshold:typeof l=="number"?l:W4[l]},f=p=>{const{isIntersecting:m}=p;if(this.isInView===m||(this.isInView=m,u&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:y,onViewportLeave:v}=this.node.getProps(),b=m?y:v;b&&b(p)};return X4(this.node.current,d,f)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Q4(e,n))&&this.startObserver()}unmount(){}}function Q4({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Z4={inView:{Feature:J4},tap:{Feature:G4},focus:{Feature:H4},hover:{Feature:q4}},e5={layout:{ProjectionNode:Z1,MeasureLayout:fS}},t5={...N4,...Z4,...$4,...e5},gn=b4(t5,w4),s5="modulepreload",n5=function(t){return"/"+t},yb={},Va=function(e,n,r){let l=Promise.resolve();if(n&&n.length>0){let m=function(y){return Promise.all(y.map(v=>Promise.resolve(v).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};var d=m;document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),p=f?.nonce||f?.getAttribute("nonce");l=m(n.map(y=>{if(y=n5(y),y in yb)return;yb[y]=!0;const v=y.endsWith(".css"),b=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${b}`))return;const S=document.createElement("link");if(S.rel=v?"stylesheet":s5,v||(S.as="script"),S.crossOrigin="",S.href=y,p&&S.setAttribute("nonce",p),document.head.appendChild(S),v)return new Promise((_,N)=>{S.addEventListener("load",_),S.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${y}`)))})}))}function u(f){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=f,window.dispatchEvent(p),!p.defaultPrevented)throw f}return l.then(f=>{for(const p of f||[])p.status==="rejected"&&u(p.reason);return e().catch(u)})},a5=(t,e,n)=>{const r=t[e];return r?typeof r=="function"?r():Promise.resolve(r):new Promise((l,u)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(u.bind(null,new Error("Unknown variable dynamic import: "+e+(e.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})},mS={"app.name":"Email Automator","app.connecting":"Connecting account...","app.loadingWorkspace":"Loading your workspace...","app.loggedOut":"Logged out successfully","app.statusLive":"LIVE","app.statusOffline":"OFFLINE","common.loading":"Loading...","common.save":"Save Changes","common.cancel":"Cancel","common.delete":"Delete","common.success":"Success","common.error":"Error","common.warning":"Warning","common.syncNow":"Sync Now","common.syncing":"Syncing...","common.stopSync":"Stop Sync","common.systemSync":"System Sync","common.viewLogs":"View Logs","common.saveChanges":"Save Changes","common.errorOccurred":"An error occurred","common.previous":"Previous","common.next":"Next","common.of":"of","common.yes":"Yes","common.no":"No","common.archive":"Archive","common.flag":"Flag","common.on":"On","common.off":"Off","common.enabled":"Enabled","common.disabled":"Disabled","common.active":"Active","common.inactive":"Inactive","common.draft":"Draft","common.star":"Star","nav.dashboard":"Dashboard","nav.drafts":"Drafts","nav.autopilot":"Auto-Pilot","nav.analytics":"Analytics","nav.configuration":"Configuration","nav.accountSettings":"Account Settings","nav.signOut":"Sign Out","drafts.title":"Draft Review Center","drafts.pending":"pending drafts","drafts.noDrafts":"No pending drafts","drafts.noDraftsDesc":"AI-generated draft replies will appear here for your review","drafts.send":"Send Now","drafts.preview":"Preview","drafts.dismiss":"Dismiss","drafts.regenerate":"Regenerate","drafts.selectAll":"Select All","drafts.sendSelected":"Send Selected","drafts.dismissSelected":"Dismiss Selected","drafts.filterByAccount":"All Accounts","drafts.filterByDate":"Filter by Date","drafts.originalEmail":"Original Email","drafts.aiReply":"AI-Generated Reply","drafts.createdBy":"Created by rule:","drafts.sendSuccess":"Draft sent successfully!","drafts.sendError":"Failed to send draft","drafts.dismissSuccess":"Draft dismissed","drafts.loadError":"Failed to load drafts","login.title":"Welcome Back","login.subtitle":"Sign in to your AI email agent","login.email":"Email Address","login.password":"Password","login.signIn":"Sign In","login.noAccount":"Don't have an account?","login.alreadyHaveAccount":"Already have an account?","login.signUp":"Sign Up","login.forgotPassword":"Forgot your password?","login.initialize":"Initialize Automator","login.secureLogin":"Secure Login","login.firstNamePlaceholder":"John","login.lastNamePlaceholder":"Doe","login.emailPlaceholder":"admin@automator.ai","login.initializeMaster":"Initialize Master","login.sendMagicLink":"Send Magic Link","login.openDashboard":"Open Dashboard","setup.title":"System Setup","setup.initiation":"Welcome","setup.coordinates":"Connection Details","setup.foundation":"Database Setup","setup.ignition":"Launch","setup.start":"Start Setup","setup.welcomeTitle":"Automator Initializing","setup.welcomeSubtitle":"Setting up your specialized environment for high-frequency inbox intelligence.","setup.encryptedTitle":"Encrypted","setup.encryptedDesc":"Self-hosted data security.","setup.turboTitle":"Turbo","setup.turboDesc":"Sub-second AI inference.","setup.getStarted":"Get Started","setup.connectionMode":"Connection Mode","setup.selectVector":"Select deployment mode","setup.quickIgnition":"Quick Start","setup.autoProvision":"Auto-provision via token","setup.manualSync":"Manual Sync","setup.existingCredentials":"Existing Credentials","setup.abortAccess":"Abort Access","setup.injectCoordinates":"Enter existing credentials","setup.platformUrl":"Platform URL","setup.urlHelp":"Enter full URL or just the Project ID","setup.anonMatrixKey":"Supabase Anon Key","setup.keyHelp":"Found in your Supabase project settings","setup.back":"Back","setup.engage":"Connect","setup.installation":"Installation","setup.applyingSchema":"Setting up database...","setup.emptyProject":"Empty project detected. Initialization is mandatory to install core AI systems.","setup.versionMismatch":"Version mismatch detected. Normalization recommended.","setup.tokenRequired":"Management Token Required","setup.migrateHelp":"Used once to run migrations on your backend.","setup.bypassRisk":"Bypass (Risky)","setup.installSystems":"Install Systems","setup.normalizeSystem":"Normalize System","setup.retryInstallation":"Retry Installation","dashboard.recentAnalysis":"Recent Analysis","dashboard.emails":"emails","dashboard.noEmails":"No emails found","dashboard.noEmailsConnected":"Connect your email account to get started.","dashboard.noEmailsFilters":"Try syncing or adjusting your filters.","dashboard.syncInProgress":"Sync in progress...","dashboard.syncInProgressDesc":"Fetching and analyzing emails. New emails will appear below automatically.","dashboard.aiTrace":"AI Processing Trace","dashboard.aiTraceDesc":"Step-by-step logs of how AI analyzed and actioned this email.","dashboard.noTrace":"No detailed trace events found for this email.","dashboard.syncNow":"Sync Now","dashboard.syncing":"Syncing...","dashboard.searchPlaceholder":"Search emails...","dashboard.search":"Search","dashboard.receivedTime":"Received Time","dashboard.processedTime":"Processed Time","dashboard.receivedAbbr":"REC","dashboard.processedAbbr":"PROC","dashboard.sortOldest":"Sorting: Oldest First","dashboard.sortNewest":"Sorting: Newest First","dashboard.category.all":"All","dashboard.category.none":"none","dashboard.emailDetails":"Email Details","dashboard.emailContent":"Email Content (sent to LLM)","dashboard.from":"From:","dashboard.subject":"Subject:","dashboard.summary":"Summary:","dashboard.keyPoints":"Key Points:","dashboard.aiDraftReply":"AI Draft Reply","dashboard.draftSavedHelp":"* This draft is already saved in your {provider} Drafts folder.","dashboard.syncScope":"Sync Scope","dashboard.syncFrom":"Sync From","dashboard.maxEmails":"Max Emails","dashboard.lastSync":"Last sync:","dashboard.error":"Error:","dashboard.resetCheckpoint":"Reset Checkpoint (Force Full Re-sync from Start Date)","dashboard.syncHistory":"Sync History","dashboard.noSyncHistory":"No sync history available.","dashboard.processed":"Processed:","dashboard.actioned":"Actioned:","dashboard.running":"Running","dashboard.quickStats":"Quick Stats","dashboard.totalProcessed":"Total Processed","dashboard.connectedAccounts":"Connected Accounts","dashboard.activeRules":"Active Rules","dashboard.noSubject":"No Subject","dashboard.queued":"Queued","dashboard.analyzing":"Analyzing","dashboard.analyzed":"Analyzed","dashboard.failed":"Failed","dashboard.retryProcessing":"Retry Processing","dashboard.suggested":"Suggested:","dashboard.done":"Done:","dashboard.deleteConfirm":"Delete?","dashboard.openIn":"Open in {provider}","dashboard.viewTraceTooltip":"View AI Trace (Prompt/Response)","dashboard.syncSuccess":"Sync completed! Check your emails.","dashboard.syncFailed":"Sync failed. Check account status for details.","config.title":"Automation & Rules","config.rules":"Automation Rules","config.createRule":"Create New Rule","config.llmSettings":"AI Intelligence Settings","config.accounts.title":"Email Accounts","config.accounts.desc":"Connect and manage your email accounts","config.accounts.addNew":"Add New Account","config.accounts.yourAccounts":"Your Connected Accounts","config.accounts.noAccounts":"No email accounts connected yet","config.accounts.connectHelp":"Connect your first email account to start automating","config.accounts.disconnect":"Disconnect","config.gmail.connect":"Connect Gmail","config.gmail.connectDesc":"OAuth 2.0 or Service Account","config.gmail.credentialsDesc":"Paste your Google Cloud credentials JSON","config.gmail.authCodeDesc":"Enter the authorization code from Google","config.gmail.pasteJson":"Paste credentials.json content","config.gmail.downloadHelp":"Download from Google Cloud Console → APIs & Services → Credentials","config.gmail.orEnterManually":"Or enter manually","config.outlook.connect":"Connect Outlook","config.outlook.connectDesc":"Microsoft 365 or Outlook.com","config.outlook.credentialsDesc":"Paste your Azure App credentials JSON","config.outlook.instructions":"Follow the OAuth flow to connect","config.outlook.signinRequired":"Sign-in Required","config.outlook.waitingSignin":"Waiting for sign-in...","config.model.title":"AI Model Configuration","config.model.desc":"Configure your AI model and processing settings","config.model.provider":"LLM Provider","config.model.name":"Model Name","config.model.selectModel":"Select a model","config.model.storagePath":"Storage Path","config.model.storagePlaceholder":"Path for model storage","config.model.storageHelp":"Local directory for caching models","config.model.syncInterval":"Sync Interval (minutes)","config.model.syncHelp":"How often to check for new emails","config.model.intelligentRename":"Intelligent Rename","config.model.renameHelp":"Use AI to suggest better file names","config.model.checkConnection":"Check Connection","config.model.saveConfig":"Save Configuration","config.byok.title":"Bring Your Own Key (BYOK)","config.byok.desc":"Use your own API keys for AI providers","config.byok.systemDefault":"Use system default","config.byok.save":"Save API Key","config.rules.edit":"Edit Rule","config.rules.create":"Create Rule","config.rules.createRule":"Create Rule","config.rules.desc":"Define conditions and actions for email automation","config.rules.name":"Rule Name","config.rules.namePlaceholder":"e.g., Archive Newsletters","config.rules.description":"Description","config.rules.descriptionPlaceholder":"What this rule does","config.rules.semanticHelp":"AI will match emails based on this description","config.rules.intent":"Intent","config.rules.intentPlaceholder":"What should happen when this rule triggers","config.rules.intentHelp":"Used to generate appropriate responses","config.rules.conditionField":"Condition Field","config.rules.aiAnalysis":"AI Analysis","config.rules.metadata":"Metadata","config.rules.category":"Category","config.rules.sentiment":"Sentiment","config.rules.priority":"Priority","config.rules.senderEmail":"Sender Email","config.rules.senderDomain":"Sender Domain","config.rules.senderContains":"Sender Contains","config.rules.subjectContains":"Subject Contains","config.rules.bodyContains":"Body Contains","config.rules.equalsValue":"Equals Value","config.rules.keywordsPlaceholder":"Enter keywords...","config.rules.olderThan":"Only if email is older than (days)","config.rules.olderThanHelp":"Leave empty or 0 to apply immediately","config.rules.performActions":"Then Perform Actions","config.rules.draftInstructions":"Draft Instructions","config.rules.contextHelp":"Specific context for AI to use when drafting","config.rules.addAttachment":"Add Attachment","config.rules.attachmentHelp":"Files will be attached to generated drafts","config.rules.uploading":"Uploading...","config.rules.saveChanges":"Save Changes","account.title":"Account Settings","account.subtitle":"Manage your profile and preferences","account.profile":"Profile","account.security":"Security","account.database":"Supabase","account.logout":"Logout","account.logoutSuccess":"Logged out successfully","account.version":"Version","account.profile.title":"Profile Information","account.profile.desc":"Update your personal information","account.profile.firstName":"First Name","account.profile.firstNamePlaceholder":"John","account.profile.lastName":"Last Name","account.profile.lastNamePlaceholder":"Doe","account.profile.email":"Email","account.profile.emailHelp":"This is your login email and cannot be changed","account.profile.sounds":"Sound & Haptic Feedback","account.profile.soundsHelp":"Play sounds for email notifications","account.profile.soundsEnabled":"Sounds enabled","account.profile.soundsDisabled":"Sounds disabled","account.profile.updated":"Profile updated successfully","account.profile.avatarUpdated":"Avatar updated successfully","account.profile.avatarError":"Failed to update avatar","account.security.title":"Security","account.security.desc":"Update your password","account.security.newPassword":"New Password","account.security.confirmPassword":"Confirm Password","account.security.updatePassword":"Update Password","account.security.enterPassword":"Please enter a password","account.security.passwordsMismatch":"Passwords do not match","account.security.passwordTooShort":"Password must be at least 6 characters","account.security.passwordChanged":"Password changed successfully","account.database.title":"Database Connection","account.database.desc":"Manage your Supabase connection","account.database.connected":"Connected","account.database.noConnection":"No Connection","account.database.configureHelp":"Configure your Supabase connection in the Setup Wizard","account.database.anonKey":"Anon Key","account.database.envAlert":"Connection configured via environment variables","account.database.changeConnection":"Change Connection","account.database.clearConfig":"Clear Configuration","account.database.clearConfirm":"Are you sure you want to clear your database configuration?","account.database.setup":"Setup Database","trace.runTrace":"Sync Run Trace","trace.fullLogFor":"Full log for account: {email}","trace.historicalLog":"Historical log for this synchronization run.","trace.loadingTrace":"Loading trace...","trace.noTraceEvents":"No granular trace events found for this run.","analytics.title":"Analytics Dashboard","analytics.totalEmails":"Total Emails","analytics.spamCaught":"Spam Caught","analytics.actionsTaken":"Actions Taken","analytics.accounts":"Accounts","analytics.categories":"Email Categories","analytics.recentActivity":"Recent Sync Activity","analytics.noActivity":"No sync activity yet","analytics.emails":"{count} emails","analytics.deleted":"{count} deleted","analytics.drafted":"{count} drafted","autopilot.title":"Auto-Pilot Rules","autopilot.rulesEnabled":"{enabled} of {total} rules enabled","autopilot.loadingRules":"Loading rules...","autopilot.loadError":"Failed to load rules","autopilot.deleteConfirm":"Are you sure you want to delete this rule?","autopilot.ruleDeleted":"Rule deleted","autopilot.ruleDeleteFailed":"Failed to delete rule","autopilot.ruleDeleteError":"An error occurred while deleting the rule","autopilot.ruleUpdated":"Rule updated","autopilot.ruleCreated":"Rule created","autopilot.ruleUpdateFailed":"Failed to update rule","autopilot.ruleCreateFailed":"Failed to create rule","autopilot.ruleSaveError":"An error occurred while saving the rule","autopilot.fileUploaded":"File uploaded","autopilot.fileUploadFailed":"Failed to upload file","autopilot.noRulesTitle":"No Rules Yet","autopilot.noRulesDesc":"Rules will be automatically created when you sign up or connect your first email account.","autopilot.addCustomRule":"Add Custom Rule","autopilot.refresh":"Refresh","autopilot.infoDesc":"Auto-Pilot rules use AI to automatically organize your inbox. Toggle any rule on or off to customize behavior.","autopilot.customRules":"Custom Rules","autopilot.customRulesDesc":"Rules you've created manually","autopilot.category.email_organization.label":"Email Organization","autopilot.category.email_organization.desc":"Automatically organize common email types","autopilot.category.priority_alerts.label":"Priority & Alerts","autopilot.category.priority_alerts.desc":"Surface urgent and important messages","autopilot.category.development.label":"Development","autopilot.category.development.desc":"GitHub, CI/CD, and dev tool notifications","autopilot.category.sales_business.label":"Sales & Business","autopilot.category.sales_business.desc":"Lead management and business communications","autopilot.category.operations.label":"Operations","autopilot.category.operations.desc":"Support, internal requests, and system alerts","autopilot.enabledCount":"({enabled}/{total} enabled)","autopilot.badge":"Auto-Pilot","autopilot.editRuleTooltip":"Edit Rule","autopilot.deleteRuleTooltip":"Delete Rule","autopilot.triggeredToday":"{count} today","autopilot.pack.active":"Active","autopilot.pack.partial":"Partial","autopilot.pack.inactive":"Inactive","autopilot.pack.disableTooltip":"Disable all rules","autopilot.pack.enableTooltip":"Enable all rules","autopilot.pack.rulesActive":"{active}/{total} rules active","autopilot.pack.actionsToday":"{count} actions today","autopilot.pack.noRules":"No rules in this pack","autopilot.editDialog.editTitle":"Edit Rule","autopilot.editDialog.createTitle":"Create Custom Rule","autopilot.editDialog.desc":"Define a condition based on AI analysis to trigger an action.","autopilot.editDialog.ruleName":"Rule Name","autopilot.editDialog.namePlaceholder":"e.g. Archive Newsletters","autopilot.editDialog.description":"Description","autopilot.editDialog.descPlaceholder":"e.g. Handle all marketing newsletters and promotional content from subscription services","autopilot.editDialog.descriptionHelp":"Describe what this rule is for. The AI uses this to semantically match emails.","autopilot.editDialog.intent":"Intent","autopilot.editDialog.intentPlaceholder":"e.g. Politely decline all sales pitches","autopilot.editDialog.intentHelp":"The goal of this rule. Used to generate appropriate draft replies.","autopilot.editDialog.conditionField":"If Condition Field","autopilot.editDialog.aiAnalysisGroup":"AI Analysis","autopilot.editDialog.metadataGroup":"Metadata","autopilot.editDialog.category":"Category","autopilot.editDialog.sentiment":"Sentiment","autopilot.editDialog.priority":"Priority","autopilot.editDialog.senderEmail":"Specific Email (Exact)","autopilot.editDialog.senderDomain":"Email Domain (@...)","autopilot.editDialog.senderContains":"Sender contains...","autopilot.editDialog.subjectContains":"Subject contains...","autopilot.editDialog.bodyContains":"Body contains...","autopilot.editDialog.equalsValue":"Equals Value","autopilot.editDialog.cat.newsletter":"Newsletter","autopilot.editDialog.cat.spam":"Spam","autopilot.editDialog.cat.promotional":"Promotional","autopilot.editDialog.cat.transactional":"Transactional","autopilot.editDialog.cat.social":"Social","autopilot.editDialog.cat.support":"Support","autopilot.editDialog.cat.client":"Client","autopilot.editDialog.cat.internal":"Internal","autopilot.editDialog.cat.personal":"Personal","autopilot.editDialog.cat.other":"Other","autopilot.editDialog.sent.positive":"Positive","autopilot.editDialog.sent.neutral":"Neutral","autopilot.editDialog.sent.negative":"Negative","autopilot.editDialog.prio.high":"High","autopilot.editDialog.prio.medium":"Medium","autopilot.editDialog.prio.low":"Low","autopilot.editDialog.keywordsPlaceholder":"Keywords...","autopilot.editDialog.olderThan":"Only if email is older than... (Optional)","autopilot.editDialog.days":"days","autopilot.editDialog.olderThanHelp":"Leave empty or 0 to apply rule immediately upon receipt.","autopilot.editDialog.performActions":"Then Perform Action(s)","autopilot.editDialog.actionsDesc":"Select one or more actions to execute when the rule matches","autopilot.editDialog.action.archive":"Archive Email","autopilot.editDialog.action.delete":"Delete Email","autopilot.editDialog.action.draft":"Draft Reply","autopilot.editDialog.action.star":"Star / Flag","autopilot.editDialog.draftInstructions":"Draft Instructions (Context)","autopilot.editDialog.draftInstPlaceholder":"e.g. Tell them I'm busy until Friday, but interested in the proposal.","autopilot.editDialog.draftInstHelp":"Specific context for the AI ghostwriter.","autopilot.editDialog.attachments":"Attachments (Optional)","autopilot.editDialog.uploading":"Uploading...","autopilot.editDialog.addAttachment":"Add Attachment","autopilot.editDialog.attachmentsHelp":"Files will be attached to every draft generated by this rule.","autopilot.onboarding.allSet":"All Set!","autopilot.onboarding.enabledDesc":"We've enabled {count} automation rules for you","autopilot.onboarding.rules":"rules","autopilot.onboarding.universalDesc":"Essential rules that help everyone stay organized","autopilot.onboarding.executiveDesc":"Focus on high-priority communications and strategic matters","autopilot.onboarding.developerDesc":"Surface critical alerts and filter tool noise","autopilot.onboarding.salesDesc":"Prioritize leads and customer communications","autopilot.onboarding.operationsDesc":"Organize tickets and internal communications","autopilot.onboarding.tip":"Tip: All rules are enabled by default, but you can customize or disable them anytime in the Auto-Pilot section.","autopilot.onboarding.start":"Start Using Email Automator →","autopilot.role.title":"One Last Step!","autopilot.role.subtitle":"What best describes your role? We'll set up the right automation rules for you.","autopilot.role.executive.label":"Executive / Leadership","autopilot.role.executive.desc":"Focus on VIPs, contracts, and strategic communications","autopilot.role.executive.preview":"VIP Client Prioritizer;Travel Organizer;Legal & Contracts","autopilot.role.sales.label":"Sales / Business Development","autopilot.role.sales.desc":"Prioritize leads and customer communications","autopilot.role.sales.preview":"Customer Questions;CRM Organizer;Proposal Tracker","autopilot.role.developer.label":"Developer / Engineer","autopilot.role.developer.desc":"Surface critical alerts and filter tool noise","autopilot.role.developer.preview":"System Alerts;Code Reviews;Project Management","autopilot.role.operations.label":"Operations / Support","autopilot.role.operations.desc":"Organize tickets and internal communications","autopilot.role.operations.preview":"Support Tickets;System Monitoring;Internal Comms","autopilot.role.marketing.label":"Marketing","autopilot.role.marketing.desc":"Track campaigns and customer engagement","autopilot.role.marketing.preview":"Campaign Tracking;Analytics Reports;Social Media","autopilot.role.other.label":"Other / Manual Setup","autopilot.role.other.desc":"I'll configure my own automation rules","autopilot.role.includes":"Includes:","autopilot.role.skip":"Skip for now","autopilot.role.settingUp":"Setting up...","autopilot.role.continue":"Continue →","terminal.title":"Agent Terminal","terminal.liveActivity":"Live Activity","terminal.syncing":"SYNCING","terminal.live":"LIVE","terminal.stopSync":"STOP SYNC","terminal.clear":"Clear","terminal.waiting":"Waiting for agent activity...","terminal.details":"Details","terminal.useless":"USELESS","terminal.relevant":"RELEVANT","terminal.executionComplete":"Execution Complete","terminal.batchFinished":"Batch Sync Finished","terminal.processed":"Processed","terminal.actions":"Actions","terminal.action.delete":"Moved to Trash","terminal.action.archive":"Archived Email","terminal.action.draft":"Drafted Reply","terminal.action.star":"Starred Email"},r5=Object.freeze(Object.defineProperty({__proto__:null,default:mS},Symbol.toStringTag,{value:"Module"})),vb={en:{name:"English",flag:"🇺🇸"},fr:{name:"Français",flag:"🇫🇷"},es:{name:"Español",flag:"🇪🇸"},ja:{name:"日本語",flag:"🇯🇵"},ko:{name:"한국어",flag:"🇰🇷"},vi:{name:"Tiếng Việt",flag:"🇻🇳"}},qc=mS,pS=w.createContext(void 0);function i5({children:t}){const[e,n]=w.useState(()=>localStorage.getItem("app_language")||"en"),[r,l]=w.useState(e==="en"?qc:{}),[u,d]=w.useState(e!=="en");w.useEffect(()=>{localStorage.setItem("app_language",e),document.documentElement.lang=e,(async()=>{if(e==="en"){l(qc),d(!1);return}d(!0);try{const y=await a5(Object.assign({"../locales/languages/en.json":()=>Va(()=>Promise.resolve().then(()=>r5),void 0),"../locales/languages/es.json":()=>Va(()=>import("./es-jMIxKu3w.js"),[]),"../locales/languages/fr.json":()=>Va(()=>import("./fr-C2DJGnGk.js"),[]),"../locales/languages/ja.json":()=>Va(()=>import("./ja-BAbHgg3S.js"),[]),"../locales/languages/ko.json":()=>Va(()=>import("./ko-BqELMO5T.js"),[]),"../locales/languages/vi.json":()=>Va(()=>import("./vi-D_3oX_6P.js"),[])}),`../locales/languages/${e}.json`,4);l(y.default)}catch(y){console.error(`Failed to load translations for ${e}:`,y),l(qc)}finally{d(!1)}})()},[e]);const f=m=>{n(m)},p=m=>r[m]||qc[m]||m;return o.jsx(pS.Provider,{value:{language:e,setLanguage:f,t:p,isLoading:u},children:t})}function Xe(){const t=w.useContext(pS);if(t===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return t}function yp({className:t}){const{language:e,setLanguage:n}=Xe(),[r,l]=w.useState(!1),u=w.useRef(null);w.useEffect(()=>{function f(p){u.current&&!u.current.contains(p.target)&&l(!1)}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const d=vb[e];return o.jsxs("div",{className:Se("relative z-50",t),ref:u,children:[o.jsxs("button",{onClick:()=>l(!r),className:Se("flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","bg-secondary/50 hover:bg-secondary border border-border/50 hover:border-border shadow-sm",r&&"ring-2 ring-primary/20 border-primary/50"),children:[o.jsx("span",{className:"text-lg leading-none",children:d.flag}),o.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:e}),o.jsx(Pb,{className:Se("w-3 h-3 transition-transform duration-200",r&&"rotate-180")})]}),r&&o.jsxs("div",{className:Se("absolute right-0 mt-2 w-48 rounded-xl border border-border bg-card p-1.5 shadow-xl animate-in fade-in zoom-in duration-200","backdrop-blur-xl"),children:[o.jsx("div",{className:"px-2 py-1.5 mb-1 text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:"Choose Language"}),Object.entries(vb).map(([f,{name:p,flag:m}])=>o.jsxs("button",{onClick:()=>{n(f),l(!1)},className:Se("flex items-center justify-between w-full px-3 py-2 rounded-lg text-sm transition-colors",e===f?"bg-primary/10 text-primary font-bold":"hover:bg-secondary text-muted-foreground hover:text-foreground"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-lg leading-none",children:m}),o.jsx("span",{children:p})]}),e===f&&o.jsx(Xn,{className:"w-4 h-4"})]},f))]})]})}const gi="2.20.0",o5="20260201000000";function l5(t,e){const n=t.split(".").map(Number),r=e.split(".").map(Number);for(let l=0;l<Math.max(n.length,r.length);l++){const u=n[l]||0,d=r[l]||0;if(u>d)return 1;if(u<d)return-1}return 0}async function c5(t){try{const{data:e,error:n}=await t.rpc("get_latest_migration_timestamp");return n?n.code==="42883"?(console.info("[Migration Check] RPC function missing - assuming fresh DB."),{version:null,latestMigrationTimestamp:"0"}):(console.warn("Could not get latest migration timestamp:",n.message),{version:null,latestMigrationTimestamp:null}):{version:gi,latestMigrationTimestamp:e||null}}catch(e){return console.error("Error checking database migration info:",e),{version:null,latestMigrationTimestamp:null}}}async function vp(t){const e=gi,n=o5,r=await c5(t);if(console.log("[Migration Check]",{appVersion:e,appMigrationTimestamp:n,dbVersion:r.version,dbMigrationTimestamp:r.latestMigrationTimestamp}),r.latestMigrationTimestamp&&r.latestMigrationTimestamp.trim()!==""){const l=n,u=r.latestMigrationTimestamp;return l>u?{needsMigration:!0,appVersion:e,dbVersion:r.version,latestMigrationTimestamp:u,message:`New migrations available. Database is at ${u}, app has ${l}.`}:l<u?(console.warn("[Migration Check] DB is ahead of app - possible downgrade"),{needsMigration:!1,appVersion:e,dbVersion:r.version,latestMigrationTimestamp:u,message:`Database (${u}) is ahead of app (${l}).`}):(console.log("[Migration Check] Timestamps match - database is up-to-date"),{needsMigration:!1,appVersion:e,dbVersion:r.version,latestMigrationTimestamp:u,message:"Database schema is up-to-date."})}if(r.version){console.log("[Migration Check] Legacy DB detected (no timestamp). Falling back to SemVer.");const l=l5(e,r.version);return l>0?{needsMigration:!0,appVersion:e,dbVersion:r.version,latestMigrationTimestamp:null,message:`Database schema (v${r.version}) is outdated. Migration to v${e} required.`}:l===0?(console.warn("[Migration Check] Legacy DB with matching version - forcing migration to add timestamp tracking"),{needsMigration:!0,appVersion:e,dbVersion:r.version,latestMigrationTimestamp:null,message:`Database lacks timestamp tracking. Please run migration to upgrade to modern schema (v${e}).`}):{needsMigration:!1,appVersion:e,dbVersion:r.version,latestMigrationTimestamp:null,message:`Database version (v${r.version}) is ahead of app (v${e}).`}}return console.log("[Migration Check] No DB info found - assuming migration needed"),{needsMigration:!0,appVersion:e,dbVersion:null,latestMigrationTimestamp:null,message:`Database schema unknown. Migration required to v${e}.`}}const gS="email_automator_migration_reminder_dismissed_at";function u5(t=24){try{const e=localStorage.getItem(gS);if(!e)return!1;const n=new Date(e).getTime();return(Date.now()-n)/(1e3*60*60)<t}catch(e){return console.error("Error checking migration reminder:",e),!1}}function d5(){try{localStorage.setItem(gS,new Date().toISOString())}catch(t){console.error("Error dismissing migration reminder:",t)}}const wm={step:"welcome",managed:{accessToken:"",organizations:[],selectedOrg:"",projectName:"Email-Automator-AI",region:"us-east-1",isFetchingOrgs:!1},manual:{url:"",anonKey:""},projectId:"",logs:[],error:null,isMigrating:!1,migrationStatus:null};function h5(t,e){switch(e.type){case"SET_STEP":return{...t,step:e.payload,error:null};case"SET_ACCESS_TOKEN":return{...t,managed:{...t.managed,accessToken:e.payload}};case"SET_ORGANIZATIONS":return{...t,managed:{...t.managed,organizations:e.payload,selectedOrg:e.payload.length>0?e.payload[0].id:""}};case"SET_SELECTED_ORG":return{...t,managed:{...t.managed,selectedOrg:e.payload}};case"SET_PROJECT_NAME":return{...t,managed:{...t.managed,projectName:e.payload}};case"SET_REGION":return{...t,managed:{...t.managed,region:e.payload}};case"SET_FETCHING_ORGS":return{...t,managed:{...t.managed,isFetchingOrgs:e.payload}};case"SET_MANUAL_URL":return{...t,manual:{...t.manual,url:e.payload}};case"SET_MANUAL_ANON_KEY":return{...t,manual:{...t.manual,anonKey:e.payload}};case"SET_PROJECT_ID":return{...t,projectId:e.payload};case"ADD_LOG":return{...t,logs:[...t.logs,{...e.payload,timestamp:Date.now()}].slice(-500)};case"CLEAR_LOGS":return{...t,logs:[]};case"SET_ERROR":return{...t,error:e.payload};case"SET_MIGRATING":return{...t,isMigrating:e.payload};case"SET_MIGRATION_STATUS":return{...t,migrationStatus:e.payload};case"RESET_MANAGED_FLOW":return{...t,managed:{...wm.managed},error:null};case"RESET_MANUAL_FLOW":return{...t,manual:{...wm.manual},error:null};default:return t}}function Af(t){const e=t.trim();return e?e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}.supabase.co`:""}function yS(t){const e=t.trim();return e?e.startsWith("sbp_")?e.length<20?{valid:!1,message:"Token is too short"}:{valid:!0,message:"Valid access token"}:{valid:!1,message:"Token must start with sbp_"}:{valid:!1,message:"Access token is required"}}function xb(t){const e=t.trim();if(!e)return null;if(!e.includes(".")&&!e.includes("/"))return e;try{return new URL(e.startsWith("http")?e:`https://${e}`).hostname.split(".")[0]||null}catch{return null}}class f5{buffer="";processChunk(e){const n=[];this.buffer+=e;const r=this.buffer.split(`
|
|
60
|
+
`);this.buffer=r.pop()||"";for(const l of r)if(l.startsWith("data: "))try{const u=l.slice(6),d=JSON.parse(u);n.push(d)}catch(u){console.warn("[SSEParser] Failed to parse event:",l,u)}return n}flush(){if(!this.buffer.trim())return[];const e=[];if(this.buffer.startsWith("data: "))try{const n=this.buffer.slice(6),r=JSON.parse(n);e.push(r)}catch(n){console.warn("[SSEParser] Failed to parse final buffer:",this.buffer,n)}return this.buffer="",e}reset(){this.buffer=""}}async function vS(t,e,n={}){const{timeout:r=3e5,onError:l}=n;if(!t.body)throw new Error("Response body is empty");const u=t.body.getReader(),d=new TextDecoder,f=new f5,p=setTimeout(()=>{u.cancel("Timeout")},r);try{for(;;){const{value:m,done:y}=await u.read();if(y){f.flush().forEach(e);break}const v=d.decode(m,{stream:!0});f.processChunk(v).forEach(e)}}catch(m){const y=m instanceof Error?m:new Error(String(m));if(l)l(y);else throw y}finally{clearTimeout(p),f.reset()}}class sa extends Error{constructor(e,n,r){super(e),this.code=n,this.status=r,this.name="SetupApiError"}}async function m5(t){const e=await fetch("/api/setup/organizations",{headers:{Authorization:`Bearer ${t}`}}),n=await e.json();if(!e.ok)throw new sa(n.error||"Failed to fetch organizations","FETCH_ORGS_FAILED",e.status);return n}async function p5(t,e){const n=await fetch("/api/setup/auto-provision",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify({orgId:t.orgId,projectName:t.projectName,region:t.region})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new sa(r.error||"Failed to provision project","PROVISION_FAILED",n.status)}await vS(n,e,{timeout:3e5,onError:r=>{throw new sa(`Provisioning stream error: ${r.message}`,"STREAM_ERROR")}})}async function g5(t,e){const n=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:t.projectRef,dbPassword:t.dbPassword,accessToken:t.accessToken})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new sa(r.error||"Failed to start migration","MIGRATION_FAILED",n.status)}await vS(n,e,{timeout:6e5,onError:r=>{throw new sa(`Migration stream error: ${r.message}`,"STREAM_ERROR")}})}function y5({onNext:t}){const{t:e}=Xe();return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-8",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-4xl font-black italic tracking-tighter uppercase leading-none",children:e("setup.welcomeTitle")}),o.jsx("p",{className:"text-sm text-muted-foreground font-medium max-w-sm",children:e("setup.welcomeSubtitle")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"p-4 rounded-2xl bg-muted/40 border border-border/50 flex flex-col gap-2 group hover:bg-primary/5 hover:border-primary/20 transition-all",children:[o.jsx(Rm,{className:"w-5 h-5 text-primary","aria-hidden":"true"}),o.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest",children:e("setup.encryptedTitle")}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:e("setup.encryptedDesc")})]}),o.jsxs("div",{className:"p-4 rounded-2xl bg-muted/40 border border-border/50 flex flex-col gap-2 group hover:bg-primary/5 hover:border-primary/20 transition-all",children:[o.jsx($o,{className:"w-5 h-5 text-primary","aria-hidden":"true"}),o.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest",children:e("setup.turboTitle")}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:e("setup.turboDesc")})]})]}),o.jsxs(Q,{onClick:t,size:"lg",className:"h-14 rounded-2xl text-md font-bold uppercase tracking-widest group shadow-xl hover:shadow-primary/20 transition-all active:scale-95 bg-primary text-primary-foreground hover:bg-primary/90",children:[e("setup.getStarted"),o.jsx(Tm,{className:"w-5 h-5 ml-4 rotate-180 group-hover:translate-x-1 transition-transform","aria-hidden":"true"})]})]})}function v5({onManaged:t,onManual:e,onBack:n}){const{t:r}=Xe();return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-6",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-2xl font-black uppercase italic tracking-tighter",children:r("setup.connectionMode")}),o.jsx("p",{className:"text-xs text-muted-foreground font-bold tracking-widest uppercase",children:r("setup.selectVector")})]}),o.jsxs("div",{className:"grid gap-4",children:[o.jsxs("button",{onClick:t,className:"group relative flex items-center justify-between p-6 rounded-2xl bg-primary/5 border border-primary/20 hover:bg-primary/10 hover:border-primary/40 transition-all text-left","aria-label":"Quick Ignition - Auto-provision via token",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"p-3 bg-primary rounded-xl shadow-lg ring-4 ring-primary/10",children:o.jsx(qE,{className:"w-6 h-6 text-primary-foreground","aria-hidden":"true"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-black uppercase italic text-sm tracking-tight",children:r("setup.quickIgnition")}),o.jsx("p",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:r("setup.autoProvision")})]})]}),o.jsx(au,{className:"w-5 h-5 text-primary opacity-50 group-hover:opacity-100 transition-all group-hover:translate-x-1"})]}),o.jsxs("button",{onClick:e,className:"group relative flex items-center justify-between p-6 rounded-2xl border border-border hover:bg-muted/50 transition-all text-left","aria-label":"Manual Sync - Use existing credentials",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"p-3 bg-muted rounded-xl",children:o.jsx(wu,{className:"w-6 h-6 text-muted-foreground","aria-hidden":"true"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-black uppercase italic text-sm tracking-tight text-foreground/80",children:r("setup.manualSync")}),o.jsx("p",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:r("setup.existingCredentials")})]})]}),o.jsx(au,{className:"w-5 h-5 text-muted-foreground opacity-50 group-hover:opacity-100 transition-all group-hover:translate-x-1"})]})]}),o.jsxs("button",{onClick:n,className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground flex items-center gap-2 hover:text-primary pt-4 transition-colors","aria-label":"Go back to welcome screen",children:[o.jsx(Tm,{size:12,"aria-hidden":"true"})," ",r("setup.abortAccess")]})]})}const Ee=w.forwardRef(({className:t,type:e,...n},r)=>o.jsx("input",{type:e,className:Se("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",t),ref:r,...n}));Ee.displayName="Input";var xS=Mb();const x5=jm(xS);var b5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],w5=b5.reduce((t,e)=>{const n=Gb(`Primitive.${e}`),r=w.forwardRef((l,u)=>{const{asChild:d,...f}=l,p=d?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(p,{...f,ref:u})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),S5="Label",bS=w.forwardRef((t,e)=>o.jsx(w5.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));bS.displayName=S5;var _5=bS;function Ht({className:t,...e}){return o.jsx(_5,{"data-slot":"label",className:Se("flex items-center gap-2 text-sm leading-none font-medium select-none text-muted-foreground group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const j5=Yb("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function er({className:t,variant:e,...n}){return o.jsx("div",{"data-slot":"alert",role:"alert",className:Se(j5({variant:e}),t),...n})}function tr({className:t,...e}){return o.jsx("div",{"data-slot":"alert-description",className:Se("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...e})}function N5({accessToken:t,error:e,isFetching:n,onTokenChange:r,onFetchOrgs:l,onBack:u}){const f=yS(t).valid;return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-6",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-2xl font-black uppercase italic tracking-tighter",children:"Forge Token"}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-bold tracking-widest uppercase",children:"Supabase API coordinates"})]}),e&&o.jsxs(er,{variant:"destructive",className:"rounded-xl bg-destructive/5 text-destructive border-destructive/20 text-[11px] font-bold",children:[o.jsx(Ms,{className:"h-4 w-4"}),o.jsx(tr,{children:e})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{htmlFor:"access-token",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground ml-1",children:"Personal Access Token"}),o.jsxs("div",{className:"relative",children:[o.jsx(Cm,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground/30",size:14,"aria-hidden":"true"}),o.jsx(Ee,{id:"access-token",type:"password",placeholder:"sbp_xxxxxxxxxxxxxxxx",value:t,onChange:p=>r(p.target.value),className:"pl-10 h-12 bg-muted/20 border-border/50 rounded-xl","aria-describedby":"token-help","aria-invalid":e?"true":"false"})]}),o.jsxs("p",{id:"token-help",className:"text-[9px] text-muted-foreground/60 px-1 italic",children:["Generate at"," ",o.jsx("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"supabase.com/dashboard/tokens"})]})]}),o.jsxs("div",{className:"flex gap-3 pt-4",children:[o.jsx(Q,{variant:"outline",onClick:u,className:"flex-1 h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest",disabled:n,children:"Back"}),o.jsx(Q,{onClick:l,disabled:!f||n,className:"flex-1 h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest group shadow-lg hover:shadow-primary/20",children:n?o.jsx(_t,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:["Scan Organizations"," ",o.jsx(au,{size:14,className:"ml-2 group-hover:translate-x-1 transition-transform"})]})})]})]})]})}function E5({organizations:t,selectedOrg:e,projectName:n,region:r,onOrgSelect:l,onProjectNameChange:u,onRegionChange:d,onProvision:f,onBack:p}){return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-6",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-2xl font-black uppercase italic tracking-tighter",children:"Project Config"}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-bold tracking-widest uppercase",children:"Engine parameters"})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(Ht,{htmlFor:"project-name",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground ml-1",children:"Project Name"}),o.jsx(Ee,{id:"project-name",value:n,onChange:m=>u(m.target.value),className:"bg-muted/20 border-border/50 rounded-xl text-[11px]"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(Ht,{htmlFor:"region",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground ml-1",children:"Hosting Sector"}),o.jsxs("select",{id:"region",value:r,onChange:m=>d(m.target.value),className:"w-full h-10 bg-muted/20 border border-border/50 rounded-xl px-3 text-[11px] font-sans focus:outline-none focus:ring-1 focus:ring-primary/50",children:[o.jsx("option",{value:"us-east-1",children:"US East (N. Virginia)"}),o.jsx("option",{value:"us-west-1",children:"US West (N. California)"}),o.jsx("option",{value:"eu-central-1",children:"Europe (Frankfurt)"}),o.jsx("option",{value:"ap-southeast-1",children:"Asia Pacific (Singapore)"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground ml-1",children:"Vessel (Organization)"}),o.jsx("div",{className:"max-h-[160px] overflow-y-auto space-y-2 pr-1 custom-scrollbar",role:"radiogroup","aria-label":"Select organization",children:t.map(m=>o.jsxs("button",{onClick:()=>l(m.id),role:"radio","aria-checked":e===m.id,className:Se("w-full flex items-center justify-between p-3 rounded-xl border text-[11px] font-bold transition-all",e===m.id?"border-primary bg-primary/5 ring-1 ring-primary":"hover:bg-muted/30 border-border/50"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(vE,{className:Se("w-3.5 h-3.5",e===m.id?"text-primary":"text-muted-foreground/50"),"aria-hidden":"true"}),o.jsx("span",{children:m.name})]}),e===m.id&&o.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse","aria-hidden":"true"})]},m.id))})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(Q,{variant:"outline",onClick:p,className:"flex-1 h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest",children:"Back"}),o.jsx(Q,{onClick:f,disabled:!e,className:"flex-1 h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest shadow-md",children:"Initialize System"})]})]})]})}function wS({logs:t,className:e}){const n=w.useRef(null);return w.useEffect(()=>{n.current?.scrollIntoView({behavior:"smooth"})},[t]),o.jsxs("div",{className:Se("bg-slate-950 rounded-2xl p-4 font-mono text-[10px] h-[240px] overflow-y-auto border border-white/5 shadow-inner custom-scrollbar relative",e),role:"log","aria-live":"polite","aria-label":"Setup progress logs",children:[o.jsxs("div",{className:"absolute top-2 right-4 flex items-center gap-2 text-[9px] font-bold text-muted-foreground/30 uppercase tracking-widest pointer-events-none",children:[o.jsx(iu,{size:10,"aria-hidden":"true"}),o.jsx("span",{children:"Live Feed"})]}),t.length===0?o.jsx("div",{className:"text-slate-600 italic animate-pulse",role:"status",children:"Awaiting kernel signals..."}):o.jsxs(o.Fragment,{children:[t.map((r,l)=>o.jsxs("div",{className:Se("mb-1 break-all transition-all duration-300",r.type==="error"&&"text-red-400 font-bold",r.type==="success"&&"text-green-400 font-bold",r.type==="info"&&"text-blue-300",r.type==="stdout"&&"text-slate-400",r.type==="stderr"&&"text-yellow-400"),children:[o.jsxs("span",{className:"text-slate-600 mr-2 tabular-nums",children:["[",new Date(r.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),"]"]}),r.message]},`${r.timestamp}-${l}`)),o.jsx("div",{ref:n})]})]})}function T5({logs:t,error:e,onRetry:n}){return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-6",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(_t,{className:"w-5 h-5 animate-spin text-primary","aria-hidden":"true"}),o.jsx("h3",{className:"text-2xl font-black uppercase italic tracking-tighter",children:"Provisioning"})]}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-bold tracking-widest uppercase",children:"Assembling infrastructure..."})]}),o.jsx(wS,{logs:t}),e&&o.jsx(Q,{variant:"destructive",onClick:n,className:"w-full h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest",children:"Re-Initialize Engine"})]})}function A5({url:t,anonKey:e,error:n,onUrlChange:r,onAnonKeyChange:l,onSave:u,onBack:d}){const{t:f}=Xe(),p=t.trim().length>0&&e.trim().length>0;return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-6",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-2xl font-black uppercase italic tracking-tighter",children:f("setup.manualSync")}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-bold tracking-widest uppercase",children:f("setup.injectCoordinates")})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(Ht,{htmlFor:"platform-url",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground ml-1",children:f("setup.platformUrl")}),o.jsx(Ee,{id:"platform-url",placeholder:"https://xyz.supabase.co",value:t,onChange:m=>r(m.target.value),className:"bg-muted/20 border-border/50 rounded-xl h-12","aria-describedby":"url-help","aria-invalid":n?"true":"false"}),o.jsx("p",{id:"url-help",className:"text-[9px] text-muted-foreground/60 px-1 italic",children:f("setup.urlHelp")})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(Ht,{htmlFor:"anon-key",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground ml-1",children:f("setup.anonMatrixKey")}),o.jsx(Ee,{id:"anon-key",type:"password",placeholder:"eyJ...",value:e,onChange:m=>l(m.target.value),className:"bg-muted/20 border-border/50 rounded-xl h-12","aria-describedby":"key-help","aria-invalid":n?"true":"false"}),o.jsx("p",{id:"key-help",className:"text-[9px] text-muted-foreground/60 px-1 italic",children:f("setup.keyHelp")})]})]}),n&&o.jsxs(gn.div,{initial:{y:5,opacity:0},animate:{y:0,opacity:1},className:"p-3 bg-destructive/5 border border-destructive/20 text-destructive text-[11px] font-bold rounded-xl flex items-center gap-2",role:"alert",children:[o.jsx(Ms,{size:14,"aria-hidden":"true"}),o.jsx("span",{children:n})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3 pt-4",children:[o.jsx(Q,{variant:"outline",onClick:d,className:"h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest",children:f("setup.back")}),o.jsx(Q,{onClick:u,disabled:!p,className:"h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest bg-primary shadow-lg hover:shadow-primary/20",children:f("setup.engage")})]})]})}function k5({logs:t,error:e,isMigrating:n,migrationStatus:r,accessToken:l,onTokenChange:u,onRunMigration:d,onBypass:f}){const p=!l,m=r?.dbVersion!==null&&!r?.isUnknown,y=r?.dbVersion===null||r?.isUnknown;return o.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-6",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[n?o.jsx(_t,{className:"w-5 h-5 animate-spin text-primary","aria-hidden":"true"}):o.jsx(zN,{className:"w-5 h-5 text-primary","aria-hidden":"true"}),o.jsx("h3",{className:"text-2xl font-black uppercase italic tracking-tighter",children:"Installation"})]}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-bold tracking-widest uppercase",children:"Applying schema DNA..."})]}),o.jsx(wS,{logs:t}),!n&&o.jsxs(gn.div,{initial:{y:10,opacity:0},animate:{y:0,opacity:1},className:"p-5 bg-primary/5 rounded-2xl space-y-4 border border-primary/20",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed font-medium",children:y?"Empty project detected. Initialization is mandatory to install core AI systems.":`Version mismatch detected (v${r?.dbVersion||"?.?"} → v${r?.appVersion||gi}). Normalization is recommended.`}),p&&o.jsxs("div",{className:"space-y-2 pt-2 border-t border-primary/10",children:[o.jsx(Ht,{htmlFor:"migration-token",className:"text-[10px] font-bold uppercase tracking-widest text-primary/60",children:"Management Token Required"}),o.jsxs("div",{className:"relative",children:[o.jsx(Cm,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-primary/30",size:12,"aria-hidden":"true"}),o.jsx(Ee,{id:"migration-token",type:"password",placeholder:"sbp_xxxxxxxxxxxxxxxx",value:l,onChange:v=>u(v.target.value),className:"pl-9 h-10 bg-background/50 border-primary/20 rounded-xl text-[11px]","aria-describedby":"migration-token-help"})]}),o.jsxs("p",{id:"migration-token-help",className:"text-[9px] text-muted-foreground/60 italic px-1",children:["Used once to run ",o.jsx("code",{className:"text-primary/70",children:"migrate.sh"})," on your backend."]})]})]}),o.jsxs("div",{className:"flex gap-3",children:[m&&o.jsx(Q,{variant:"ghost",onClick:f,className:"flex-1 h-11 text-[10px] font-bold uppercase tracking-widest opacity-60 hover:opacity-100","aria-label":"Skip migration (risky)",children:"Bypass (Risk)"}),o.jsx(Q,{onClick:d,disabled:p,className:"flex-1 h-11 bg-primary text-[10px] font-bold uppercase tracking-widest shadow-lg hover:shadow-primary/30",children:y?"Install Systems":"Normalize System"})]})]}),e&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs(er,{variant:"destructive",className:"rounded-xl border-destructive/20 bg-destructive/5 text-destructive font-bold text-[11px]",children:[o.jsx(Ms,{className:"h-4 w-4"}),o.jsx(tr,{children:e})]}),o.jsx(Q,{variant:"outline",onClick:d,className:"w-full h-12 rounded-xl text-[10px] font-bold uppercase tracking-widest",children:"Retry Installation"})]})]})}function Hc({step:t,currentStep:e,label:n}){const r=Array.isArray(t)?t.includes(e):e===t;return o.jsx("div",{className:Se("px-3 py-1.5 rounded-full text-[9px] font-black uppercase tracking-[0.2em] transition-all duration-500",r?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground opacity-40"),role:"status","aria-current":r,children:n})}function xp({className:t}){return o.jsxs("svg",{width:"512",height:"512",viewBox:"0 0 512 512",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:Se("w-9 h-9",t),children:[o.jsx("path",{d:"M112 112H400C426.51 112 448 133.49 448 160V352C448 378.51 426.51 400 400 400H112C85.4903 400 64 378.51 64 352V160C64 133.49 85.4903 112 112 112Z",stroke:"currentColor",strokeWidth:"32",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M64 160 L240 290 C250 295 262 295 272 290 L448 160",stroke:"currentColor",strokeWidth:"28",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M256 160 C256 160 270 190 290 195 C270 200 256 230 256 230 C256 230 242 200 222 195 C242 190 256 160 256 160 Z",fill:"currentColor",className:"opacity-50"})]})}function SS({onComplete:t,open:e=!0,canClose:n=!1}){const[r,l]=w.useReducer(h5,wm),{t:u}=Xe(),d=w.useRef(""),f=w.useRef("");w.useEffect(()=>()=>{d.current="",f.current=""},[]);const p=w.useCallback((_,N)=>{l({type:"ADD_LOG",payload:{type:_,message:N}})},[]),m=w.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_FETCHING_ORGS",payload:!0});const _=r.managed.accessToken.trim(),N=yS(_);if(!N.valid){l({type:"SET_ERROR",payload:N.message||"Invalid token"}),l({type:"SET_FETCHING_ORGS",payload:!1});return}try{d.current=_;const E=await m5(_);l({type:"SET_ORGANIZATIONS",payload:E}),l({type:"SET_STEP",payload:"managed-org"})}catch(E){const T=E instanceof sa?E:new Error(String(E));l({type:"SET_ERROR",payload:T.message})}finally{l({type:"SET_FETCHING_ORGS",payload:!1})}},[r.managed.accessToken]),y=w.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"provisioning"}),l({type:"CLEAR_LOGS"}),p("info","Connecting to Supabase provisioning engine...");const _=d.current||r.managed.accessToken.trim();let N=null;try{if(await p5({accessToken:_,orgId:r.managed.selectedOrg,projectName:r.managed.projectName,region:r.managed.region},E=>{switch(E.type){case"info":p("info",E.data);break;case"project_id":l({type:"SET_PROJECT_ID",payload:E.data});break;case"success":N=E.data,p("success","✨ Project ready! Initializing database..."),df({url:Af(N.url),anonKey:N.anonKey.trim()}),f.current=N.dbPass,l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,dbVersion:null,appVersion:gi,isUnknown:!0}});break;case"error":l({type:"SET_ERROR",payload:E.data}),p("error",E.data);break}}),N){const E=N;await v(E.projectId,_,E.url,E.anonKey)}}catch(E){const T=E instanceof sa?E:new Error(String(E));l({type:"SET_ERROR",payload:T.message}),p("error",`Provisioning failed: ${T.message}`)}},[r.managed.selectedOrg,r.managed.projectName,r.managed.region,r.managed.accessToken,p]),v=w.useCallback(async(_,N,E,T)=>{const D=_||r.projectId||xb(r.manual.url),A=N||d.current||r.managed.accessToken.trim(),U=E||r.manual.url,H=T||r.manual.anonKey;if(!D||!A){l({type:"SET_ERROR",payload:"Project ID and Access Token are required for migration."});return}l({type:"SET_STEP",payload:"migration"}),l({type:"SET_ERROR",payload:null}),l({type:"SET_MIGRATING",payload:!0}),l({type:"CLEAR_LOGS"}),p("info","📦 Preparing database schema initialization...");try{let G=!1;if(await g5({projectRef:D,dbPassword:f.current,accessToken:A},z=>{switch(z.type){case"stdout":p("stdout",z.data);break;case"stderr":p("stderr",`⚠️ ${z.data}`);break;case"info":p("info",z.data);break;case"error":p("error",z.data);break;case"done":z.data==="success"?(G=!0,p("success","✅ Database setup complete!"),U&&H&&df({url:Af(U),anonKey:H.trim()}),d.current="",f.current="",setTimeout(()=>{t(),window.location.reload()},2e3)):l({type:"SET_ERROR",payload:"Migration failed. Check terminal logs for details."});break}}),!G)throw new Error("Migration did not complete successfully")}catch(G){const z=G instanceof sa?G:new Error(String(G));l({type:"SET_ERROR",payload:z.message}),p("error",`Migration failed: ${z.message}`)}finally{l({type:"SET_MIGRATING",payload:!1})}},[r.projectId,r.manual.url,r.manual.anonKey,r.managed.accessToken,p,t]),b=w.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"validating"});const _=Af(r.manual.url),N=r.manual.anonKey.trim(),E=await tC(_,N);if(E.valid){l({type:"SET_MANUAL_URL",payload:_});const T=xb(_);T&&l({type:"SET_PROJECT_ID",payload:T}),df({url:_,anonKey:N});try{const D=Xf(_,N),A=await vp(D);l({type:"SET_MIGRATION_STATUS",payload:A}),A.needsMigration?l({type:"SET_STEP",payload:"migration"}):(p("success","✨ Database is already up-to-date! Redirecting..."),setTimeout(()=>{t(),window.location.reload()},2e3))}catch(D){console.warn("[SetupWizard] Migration check failed:",D),l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,dbVersion:null,appVersion:gi,isUnknown:!0}}),l({type:"SET_STEP",payload:"migration"})}}else l({type:"SET_ERROR",payload:E.error||"Connection failed"}),l({type:"SET_STEP",payload:"credentials"})},[r.manual.url,r.manual.anonKey,p,t]);if(!e)return null;const S={initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20}};return o.jsx("div",{className:"fixed inset-0 z-50 bg-background flex flex-col items-center justify-center p-0 md:p-8",children:o.jsxs("div",{className:"w-full h-full max-w-6xl mx-auto overflow-hidden bg-background/80 backdrop-blur-xl border border-border/50 shadow-2xl rounded-3xl flex",children:[o.jsxs("div",{className:"w-[280px] bg-muted/30 border-r border-border/10 p-8 flex flex-col justify-between relative overflow-hidden hidden md:flex shrink-0",children:[o.jsxs("div",{className:"space-y-8 relative z-10",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[o.jsx("div",{className:"p-2 bg-primary rounded-lg flex-shrink-0",children:o.jsx(xp,{className:"w-5 h-5 text-primary-foreground"})}),o.jsx("span",{className:"font-black italic tracking-tighter uppercase text-xs truncate",children:"Automator Forge"})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.4em] text-muted-foreground/30 ml-1",children:"Assembly Phase"}),o.jsxs("div",{className:"space-y-4 px-1",children:[o.jsx(Hc,{step:"welcome",currentStep:r.step,label:u("setup.initiation")}),o.jsx(Hc,{step:["type","managed-token","credentials"],currentStep:r.step,label:u("setup.coordinates")}),o.jsx(Hc,{step:["managed-org","provisioning","validating"],currentStep:r.step,label:u("setup.foundation")}),o.jsx(Hc,{step:"migration",currentStep:r.step,label:u("setup.ignition")})]})]})]}),o.jsx("div",{className:"relative z-10 space-y-4",children:o.jsxs("p",{className:"text-[9px] font-bold text-muted-foreground/30 uppercase tracking-[0.4em] px-2 text-center",children:["v",gi," // Stable Build"]})})]}),o.jsxs("div",{className:"flex-1 p-8 md:p-12 flex flex-col relative",children:[n&&o.jsx("button",{onClick:t,className:"absolute top-6 right-6 p-2 rounded-full hover:bg-secondary transition-colors z-[60]","aria-label":"Close setup wizard",children:o.jsx(_s,{className:"w-5 h-5 text-muted-foreground opacity-40 hover:opacity-100 transition-opacity"})}),o.jsx("div",{className:"absolute top-6 right-6 flex items-center gap-4 z-50",children:o.jsx(yp,{})}),o.jsx(tS,{mode:"wait",children:o.jsxs(gn.div,{initial:"initial",animate:"animate",exit:"exit",variants:S,transition:{type:"spring",damping:25,stiffness:200},className:"flex-1 flex flex-col",children:[r.step==="welcome"&&o.jsx(y5,{onNext:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="type"&&o.jsx(v5,{onManaged:()=>{l({type:"RESET_MANUAL_FLOW"}),l({type:"SET_STEP",payload:"managed-token"})},onManual:()=>{l({type:"RESET_MANAGED_FLOW"}),l({type:"SET_STEP",payload:"credentials"})},onBack:()=>l({type:"SET_STEP",payload:"welcome"})}),r.step==="managed-token"&&o.jsx(N5,{accessToken:r.managed.accessToken,error:r.error,isFetching:r.managed.isFetchingOrgs,onTokenChange:_=>l({type:"SET_ACCESS_TOKEN",payload:_}),onFetchOrgs:m,onBack:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="managed-org"&&o.jsx(E5,{organizations:r.managed.organizations,selectedOrg:r.managed.selectedOrg,projectName:r.managed.projectName,region:r.managed.region,onOrgSelect:_=>l({type:"SET_SELECTED_ORG",payload:_}),onProjectNameChange:_=>l({type:"SET_PROJECT_NAME",payload:_}),onRegionChange:_=>l({type:"SET_REGION",payload:_}),onProvision:y,onBack:()=>l({type:"SET_STEP",payload:"managed-token"})}),r.step==="provisioning"&&o.jsx(T5,{logs:r.logs,error:r.error,onRetry:()=>l({type:"SET_STEP",payload:"managed-token"})}),r.step==="credentials"&&o.jsx(A5,{url:r.manual.url,anonKey:r.manual.anonKey,error:r.error,onUrlChange:_=>l({type:"SET_MANUAL_URL",payload:_}),onAnonKeyChange:_=>l({type:"SET_MANUAL_ANON_KEY",payload:_}),onSave:b,onBack:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="migration"&&o.jsx(k5,{logs:r.logs,error:r.error,isMigrating:r.isMigrating,migrationStatus:r.migrationStatus,accessToken:r.managed.accessToken,onTokenChange:_=>l({type:"SET_ACCESS_TOKEN",payload:_}),onRunMigration:()=>v(),onBypass:()=>{t(),window.location.reload()}})]},r.step)})]})]})})}function na(t,e,{checkForDefaultPrevented:n=!0}={}){return function(l){if(t?.(l),n===!1||!l.defaultPrevented)return e?.(l)}}function C5(t,e){const n=w.createContext(e),r=u=>{const{children:d,...f}=u,p=w.useMemo(()=>f,Object.values(f));return o.jsx(n.Provider,{value:p,children:d})};r.displayName=t+"Provider";function l(u){const d=w.useContext(n);if(d)return d;if(e!==void 0)return e;throw new Error(`\`${u}\` must be used within \`${t}\``)}return[r,l]}function R5(t,e=[]){let n=[];function r(u,d){const f=w.createContext(d),p=n.length;n=[...n,d];const m=v=>{const{scope:b,children:S,..._}=v,N=b?.[t]?.[p]||f,E=w.useMemo(()=>_,Object.values(_));return o.jsx(N.Provider,{value:E,children:S})};m.displayName=u+"Provider";function y(v,b){const S=b?.[t]?.[p]||f,_=w.useContext(S);if(_)return _;if(d!==void 0)return d;throw new Error(`\`${v}\` must be used within \`${u}\``)}return[m,y]}const l=()=>{const u=n.map(d=>w.createContext(d));return function(f){const p=f?.[t]||u;return w.useMemo(()=>({[`__scope${t}`]:{...f,[t]:p}}),[f,p])}};return l.scopeName=t,[r,O5(l,...e)]}function O5(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(u){const d=r.reduce((f,{useScope:p,scopeName:m})=>{const v=p(u)[`__scope${m}`];return{...f,...v}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:d}),[d])}};return n.scopeName=e.scopeName,n}var el=globalThis?.document?w.useLayoutEffect:()=>{},D5=Em[" useId ".trim().toString()]||(()=>{}),M5=0;function kf(t){const[e,n]=w.useState(D5());return el(()=>{n(r=>r??String(M5++))},[t]),t||(e?`radix-${e}`:"")}var z5=Em[" useInsertionEffect ".trim().toString()]||el;function L5({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[l,u,d]=U5({defaultProp:e,onChange:n}),f=t!==void 0,p=f?t:l;{const y=w.useRef(t!==void 0);w.useEffect(()=>{const v=y.current;v!==f&&console.warn(`${r} is changing from ${v?"controlled":"uncontrolled"} to ${f?"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.`),y.current=f},[f,r])}const m=w.useCallback(y=>{if(f){const v=P5(y)?y(t):y;v!==t&&d.current?.(v)}else u(y)},[f,t,u,d]);return[p,m]}function U5({defaultProp:t,onChange:e}){const[n,r]=w.useState(t),l=w.useRef(n),u=w.useRef(e);return z5(()=>{u.current=e},[e]),w.useEffect(()=>{l.current!==n&&(u.current?.(n),l.current=n)},[n,l]),[n,r,u]}function P5(t){return typeof t=="function"}function V5(t){const e=B5(t),n=w.forwardRef((r,l)=>{const{children:u,...d}=r,f=w.Children.toArray(u),p=f.find($5);if(p){const m=p.props.children,y=f.map(v=>v===p?w.Children.count(m)>1?w.Children.only(null):w.isValidElement(m)?m.props.children:null:v);return o.jsx(e,{...d,ref:l,children:w.isValidElement(m)?w.cloneElement(m,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return n.displayName=`${t}.Slot`,n}function B5(t){const e=w.forwardRef((n,r)=>{const{children:l,...u}=n;if(w.isValidElement(l)){const d=H5(l),f=q5(u,l.props);return l.type!==w.Fragment&&(f.ref=r?ju(r,d):d),w.cloneElement(l,f)}return w.Children.count(l)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var I5=Symbol("radix.slottable");function $5(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===I5}function q5(t,e){const n={...e};for(const r in e){const l=t[r],u=e[r];/^on[A-Z]/.test(r)?l&&u?n[r]=(...f)=>{const p=u(...f);return l(...f),p}:l&&(n[r]=l):r==="style"?n[r]={...l,...u}:r==="className"&&(n[r]=[l,u].filter(Boolean).join(" "))}return{...t,...n}}function H5(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var G5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wn=G5.reduce((t,e)=>{const n=V5(`Primitive.${e}`),r=w.forwardRef((l,u)=>{const{asChild:d,...f}=l,p=d?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(p,{...f,ref:u})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function F5(t,e){t&&xS.flushSync(()=>t.dispatchEvent(e))}function tl(t){const e=w.useRef(t);return w.useEffect(()=>{e.current=t}),w.useMemo(()=>(...n)=>e.current?.(...n),[])}function K5(t,e=globalThis?.document){const n=tl(t);w.useEffect(()=>{const r=l=>{l.key==="Escape"&&n(l)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var Y5="DismissableLayer",Sm="dismissableLayer.update",X5="dismissableLayer.pointerDownOutside",W5="dismissableLayer.focusOutside",bb,_S=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),jS=w.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,onDismiss:f,...p}=t,m=w.useContext(_S),[y,v]=w.useState(null),b=y?.ownerDocument??globalThis?.document,[,S]=w.useState({}),_=nr(e,z=>v(z)),N=Array.from(m.layers),[E]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),T=N.indexOf(E),D=y?N.indexOf(y):-1,A=m.layersWithOutsidePointerEventsDisabled.size>0,U=D>=T,H=Z5(z=>{const M=z.target,J=[...m.branches].some(ie=>ie.contains(M));!U||J||(l?.(z),d?.(z),z.defaultPrevented||f?.())},b),G=eM(z=>{const M=z.target;[...m.branches].some(ie=>ie.contains(M))||(u?.(z),d?.(z),z.defaultPrevented||f?.())},b);return K5(z=>{D===m.layers.size-1&&(r?.(z),!z.defaultPrevented&&f&&(z.preventDefault(),f()))},b),w.useEffect(()=>{if(y)return n&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(bb=b.body.style.pointerEvents,b.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(y)),m.layers.add(y),wb(),()=>{n&&m.layersWithOutsidePointerEventsDisabled.size===1&&(b.body.style.pointerEvents=bb)}},[y,b,n,m]),w.useEffect(()=>()=>{y&&(m.layers.delete(y),m.layersWithOutsidePointerEventsDisabled.delete(y),wb())},[y,m]),w.useEffect(()=>{const z=()=>S({});return document.addEventListener(Sm,z),()=>document.removeEventListener(Sm,z)},[]),o.jsx(wn.div,{...p,ref:_,style:{pointerEvents:A?U?"auto":"none":void 0,...t.style},onFocusCapture:na(t.onFocusCapture,G.onFocusCapture),onBlurCapture:na(t.onBlurCapture,G.onBlurCapture),onPointerDownCapture:na(t.onPointerDownCapture,H.onPointerDownCapture)})});jS.displayName=Y5;var J5="DismissableLayerBranch",Q5=w.forwardRef((t,e)=>{const n=w.useContext(_S),r=w.useRef(null),l=nr(e,r);return w.useEffect(()=>{const u=r.current;if(u)return n.branches.add(u),()=>{n.branches.delete(u)}},[n.branches]),o.jsx(wn.div,{...t,ref:l})});Q5.displayName=J5;function Z5(t,e=globalThis?.document){const n=tl(t),r=w.useRef(!1),l=w.useRef(()=>{});return w.useEffect(()=>{const u=f=>{if(f.target&&!r.current){let p=function(){NS(X5,n,m,{discrete:!0})};const m={originalEvent:f};f.pointerType==="touch"?(e.removeEventListener("click",l.current),l.current=p,e.addEventListener("click",l.current,{once:!0})):p()}else e.removeEventListener("click",l.current);r.current=!1},d=window.setTimeout(()=>{e.addEventListener("pointerdown",u)},0);return()=>{window.clearTimeout(d),e.removeEventListener("pointerdown",u),e.removeEventListener("click",l.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function eM(t,e=globalThis?.document){const n=tl(t),r=w.useRef(!1);return w.useEffect(()=>{const l=u=>{u.target&&!r.current&&NS(W5,n,{originalEvent:u},{discrete:!1})};return e.addEventListener("focusin",l),()=>e.removeEventListener("focusin",l)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function wb(){const t=new CustomEvent(Sm);document.dispatchEvent(t)}function NS(t,e,n,{discrete:r}){const l=n.originalEvent.target,u=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&l.addEventListener(t,e,{once:!0}),r?F5(l,u):l.dispatchEvent(u)}var Cf="focusScope.autoFocusOnMount",Rf="focusScope.autoFocusOnUnmount",Sb={bubbles:!1,cancelable:!0},tM="FocusScope",ES=w.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:l,onUnmountAutoFocus:u,...d}=t,[f,p]=w.useState(null),m=tl(l),y=tl(u),v=w.useRef(null),b=nr(e,N=>p(N)),S=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let N=function(A){if(S.paused||!f)return;const U=A.target;f.contains(U)?v.current=U:Yn(v.current,{select:!0})},E=function(A){if(S.paused||!f)return;const U=A.relatedTarget;U!==null&&(f.contains(U)||Yn(v.current,{select:!0}))},T=function(A){if(document.activeElement===document.body)for(const H of A)H.removedNodes.length>0&&Yn(f)};document.addEventListener("focusin",N),document.addEventListener("focusout",E);const D=new MutationObserver(T);return f&&D.observe(f,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",N),document.removeEventListener("focusout",E),D.disconnect()}}},[r,f,S.paused]),w.useEffect(()=>{if(f){jb.add(S);const N=document.activeElement;if(!f.contains(N)){const T=new CustomEvent(Cf,Sb);f.addEventListener(Cf,m),f.dispatchEvent(T),T.defaultPrevented||(sM(oM(TS(f)),{select:!0}),document.activeElement===N&&Yn(f))}return()=>{f.removeEventListener(Cf,m),setTimeout(()=>{const T=new CustomEvent(Rf,Sb);f.addEventListener(Rf,y),f.dispatchEvent(T),T.defaultPrevented||Yn(N??document.body,{select:!0}),f.removeEventListener(Rf,y),jb.remove(S)},0)}}},[f,m,y,S]);const _=w.useCallback(N=>{if(!n&&!r||S.paused)return;const E=N.key==="Tab"&&!N.altKey&&!N.ctrlKey&&!N.metaKey,T=document.activeElement;if(E&&T){const D=N.currentTarget,[A,U]=nM(D);A&&U?!N.shiftKey&&T===U?(N.preventDefault(),n&&Yn(A,{select:!0})):N.shiftKey&&T===A&&(N.preventDefault(),n&&Yn(U,{select:!0})):T===D&&N.preventDefault()}},[n,r,S.paused]);return o.jsx(wn.div,{tabIndex:-1,...d,ref:b,onKeyDown:_})});ES.displayName=tM;function sM(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Yn(r,{select:e}),document.activeElement!==n)return}function nM(t){const e=TS(t),n=_b(e,t),r=_b(e.reverse(),t);return[n,r]}function TS(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const l=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||l?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function _b(t,e){for(const n of t)if(!aM(n,{upTo:e}))return n}function aM(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function rM(t){return t instanceof HTMLInputElement&&"select"in t}function Yn(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&rM(t)&&e&&t.select()}}var jb=iM();function iM(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=Nb(t,e),t.unshift(e)},remove(e){t=Nb(t,e),t[0]?.resume()}}}function Nb(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function oM(t){return t.filter(e=>e.tagName!=="A")}var lM="Portal",AS=w.forwardRef((t,e)=>{const{container:n,...r}=t,[l,u]=w.useState(!1);el(()=>u(!0),[]);const d=n||l&&globalThis?.document?.body;return d?x5.createPortal(o.jsx(wn.div,{...r,ref:e}),d):null});AS.displayName=lM;function cM(t,e){return w.useReducer((n,r)=>e[n][r]??n,t)}var Ou=t=>{const{present:e,children:n}=t,r=uM(e),l=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),u=nr(r.ref,dM(l));return typeof n=="function"||r.isPresent?w.cloneElement(l,{ref:u}):null};Ou.displayName="Presence";function uM(t){const[e,n]=w.useState(),r=w.useRef(null),l=w.useRef(t),u=w.useRef("none"),d=t?"mounted":"unmounted",[f,p]=cM(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{const m=Gc(r.current);u.current=f==="mounted"?m:"none"},[f]),el(()=>{const m=r.current,y=l.current;if(y!==t){const b=u.current,S=Gc(m);t?p("MOUNT"):S==="none"||m?.display==="none"?p("UNMOUNT"):p(y&&b!==S?"ANIMATION_OUT":"UNMOUNT"),l.current=t}},[t,p]),el(()=>{if(e){let m;const y=e.ownerDocument.defaultView??window,v=S=>{const N=Gc(r.current).includes(CSS.escape(S.animationName));if(S.target===e&&N&&(p("ANIMATION_END"),!l.current)){const E=e.style.animationFillMode;e.style.animationFillMode="forwards",m=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=E)})}},b=S=>{S.target===e&&(u.current=Gc(r.current))};return e.addEventListener("animationstart",b),e.addEventListener("animationcancel",v),e.addEventListener("animationend",v),()=>{y.clearTimeout(m),e.removeEventListener("animationstart",b),e.removeEventListener("animationcancel",v),e.removeEventListener("animationend",v)}}else p("ANIMATION_END")},[e,p]),{isPresent:["mounted","unmountSuspended"].includes(f),ref:w.useCallback(m=>{r.current=m?getComputedStyle(m):null,n(m)},[])}}function Gc(t){return t?.animationName||"none"}function dM(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Of=0;function hM(){w.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Eb()),document.body.insertAdjacentElement("beforeend",t[1]??Eb()),Of++,()=>{Of===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Of--}},[])}function Eb(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var su="right-scroll-bar-position",nu="width-before-scroll-bar",fM="with-scroll-bars-hidden",mM="--removed-body-scroll-bar-size";function Df(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function pM(t,e){var n=w.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var l=n.value;l!==r&&(n.value=r,n.callback(r,l))}}}})[0];return n.callback=e,n.facade}var gM=typeof window<"u"?w.useLayoutEffect:w.useEffect,Tb=new WeakMap;function yM(t,e){var n=pM(null,function(r){return t.forEach(function(l){return Df(l,r)})});return gM(function(){var r=Tb.get(n);if(r){var l=new Set(r),u=new Set(t),d=n.current;l.forEach(function(f){u.has(f)||Df(f,null)}),u.forEach(function(f){l.has(f)||Df(f,d)})}Tb.set(n,t)},[t]),n}function vM(t){return t}function xM(t,e){e===void 0&&(e=vM);var n=[],r=!1,l={read:function(){if(r)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]:t},useMedium:function(u){var d=e(u,r);return n.push(d),function(){n=n.filter(function(f){return f!==d})}},assignSyncMedium:function(u){for(r=!0;n.length;){var d=n;n=[],d.forEach(u)}n={push:function(f){return u(f)},filter:function(){return n}}},assignMedium:function(u){r=!0;var d=[];if(n.length){var f=n;n=[],f.forEach(u),d=n}var p=function(){var y=d;d=[],y.forEach(u)},m=function(){return Promise.resolve().then(p)};m(),n={push:function(y){d.push(y),m()},filter:function(y){return d=d.filter(y),n}}}};return l}function bM(t){t===void 0&&(t={});var e=xM(null);return e.options=$s({async:!0,ssr:!1},t),e}var kS=function(t){var e=t.sideCar,n=_i(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return w.createElement(r,$s({},n))};kS.isSideCarExport=!0;function wM(t,e){return t.useMedium(e),kS}var CS=bM(),Mf=function(){},Du=w.forwardRef(function(t,e){var n=w.useRef(null),r=w.useState({onScrollCapture:Mf,onWheelCapture:Mf,onTouchMoveCapture:Mf}),l=r[0],u=r[1],d=t.forwardProps,f=t.children,p=t.className,m=t.removeScrollBar,y=t.enabled,v=t.shards,b=t.sideCar,S=t.noRelative,_=t.noIsolation,N=t.inert,E=t.allowPinchZoom,T=t.as,D=T===void 0?"div":T,A=t.gapMode,U=_i(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),H=b,G=yM([n,e]),z=$s($s({},U),l);return w.createElement(w.Fragment,null,y&&w.createElement(H,{sideCar:CS,removeScrollBar:m,shards:v,noRelative:S,noIsolation:_,inert:N,setCallbacks:u,allowPinchZoom:!!E,lockRef:n,gapMode:A}),d?w.cloneElement(w.Children.only(f),$s($s({},z),{ref:G})):w.createElement(D,$s({},z,{className:p,ref:G}),f))});Du.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Du.classNames={fullWidth:nu,zeroRight:su};var SM=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function _M(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=SM();return e&&t.setAttribute("nonce",e),t}function jM(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function NM(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var EM=function(){var t=0,e=null;return{add:function(n){t==0&&(e=_M())&&(jM(e,n),NM(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},TM=function(){var t=EM();return function(e,n){w.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},RS=function(){var t=TM(),e=function(n){var r=n.styles,l=n.dynamic;return t(r,l),null};return e},AM={left:0,top:0,right:0,gap:0},zf=function(t){return parseInt(t||"",10)||0},kM=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],l=e[t==="padding"?"paddingRight":"marginRight"];return[zf(n),zf(r),zf(l)]},CM=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return AM;var e=kM(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},RM=RS(),yi="data-scroll-locked",OM=function(t,e,n,r){var l=t.left,u=t.top,d=t.right,f=t.gap;return n===void 0&&(n="margin"),`
|
|
61
|
+
.`.concat(fM,` {
|
|
62
|
+
overflow: hidden `).concat(r,`;
|
|
63
|
+
padding-right: `).concat(f,"px ").concat(r,`;
|
|
64
|
+
}
|
|
65
|
+
body[`).concat(yi,`] {
|
|
66
|
+
overflow: hidden `).concat(r,`;
|
|
67
|
+
overscroll-behavior: contain;
|
|
68
|
+
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
69
|
+
padding-left: `.concat(l,`px;
|
|
70
|
+
padding-top: `).concat(u,`px;
|
|
71
|
+
padding-right: `).concat(d,`px;
|
|
72
|
+
margin-left:0;
|
|
73
|
+
margin-top:0;
|
|
74
|
+
margin-right: `).concat(f,"px ").concat(r,`;
|
|
75
|
+
`),n==="padding"&&"padding-right: ".concat(f,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.`).concat(su,` {
|
|
79
|
+
right: `).concat(f,"px ").concat(r,`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.`).concat(nu,` {
|
|
83
|
+
margin-right: `).concat(f,"px ").concat(r,`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.`).concat(su," .").concat(su,` {
|
|
87
|
+
right: 0 `).concat(r,`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.`).concat(nu," .").concat(nu,` {
|
|
91
|
+
margin-right: 0 `).concat(r,`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
body[`).concat(yi,`] {
|
|
95
|
+
`).concat(mM,": ").concat(f,`px;
|
|
96
|
+
}
|
|
97
|
+
`)},Ab=function(){var t=parseInt(document.body.getAttribute(yi)||"0",10);return isFinite(t)?t:0},DM=function(){w.useEffect(function(){return document.body.setAttribute(yi,(Ab()+1).toString()),function(){var t=Ab()-1;t<=0?document.body.removeAttribute(yi):document.body.setAttribute(yi,t.toString())}},[])},MM=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,l=r===void 0?"margin":r;DM();var u=w.useMemo(function(){return CM(l)},[l]);return w.createElement(RM,{styles:OM(u,!e,l,n?"":"!important")})},_m=!1;if(typeof window<"u")try{var Fc=Object.defineProperty({},"passive",{get:function(){return _m=!0,!0}});window.addEventListener("test",Fc,Fc),window.removeEventListener("test",Fc,Fc)}catch{_m=!1}var si=_m?{passive:!1}:!1,zM=function(t){return t.tagName==="TEXTAREA"},OS=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!zM(t)&&n[e]==="visible")},LM=function(t){return OS(t,"overflowY")},UM=function(t){return OS(t,"overflowX")},kb=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var l=DS(t,r);if(l){var u=MS(t,r),d=u[1],f=u[2];if(d>f)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},PM=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},VM=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},DS=function(t,e){return t==="v"?LM(e):UM(e)},MS=function(t,e){return t==="v"?PM(e):VM(e)},BM=function(t,e){return t==="h"&&e==="rtl"?-1:1},IM=function(t,e,n,r,l){var u=BM(t,window.getComputedStyle(e).direction),d=u*r,f=n.target,p=e.contains(f),m=!1,y=d>0,v=0,b=0;do{if(!f)break;var S=MS(t,f),_=S[0],N=S[1],E=S[2],T=N-E-u*_;(_||T)&&DS(t,f)&&(v+=T,b+=_);var D=f.parentNode;f=D&&D.nodeType===Node.DOCUMENT_FRAGMENT_NODE?D.host:D}while(!p&&f!==document.body||p&&(e.contains(f)||e===f));return(y&&Math.abs(v)<1||!y&&Math.abs(b)<1)&&(m=!0),m},Kc=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Cb=function(t){return[t.deltaX,t.deltaY]},Rb=function(t){return t&&"current"in t?t.current:t},$M=function(t,e){return t[0]===e[0]&&t[1]===e[1]},qM=function(t){return`
|
|
98
|
+
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
99
|
+
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
100
|
+
`)},HM=0,ni=[];function GM(t){var e=w.useRef([]),n=w.useRef([0,0]),r=w.useRef(),l=w.useState(HM++)[0],u=w.useState(RS)[0],d=w.useRef(t);w.useEffect(function(){d.current=t},[t]),w.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(l));var N=_2([t.lockRef.current],(t.shards||[]).map(Rb),!0).filter(Boolean);return N.forEach(function(E){return E.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),N.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(l))})}}},[t.inert,t.lockRef.current,t.shards]);var f=w.useCallback(function(N,E){if("touches"in N&&N.touches.length===2||N.type==="wheel"&&N.ctrlKey)return!d.current.allowPinchZoom;var T=Kc(N),D=n.current,A="deltaX"in N?N.deltaX:D[0]-T[0],U="deltaY"in N?N.deltaY:D[1]-T[1],H,G=N.target,z=Math.abs(A)>Math.abs(U)?"h":"v";if("touches"in N&&z==="h"&&G.type==="range")return!1;var M=window.getSelection(),J=M&&M.anchorNode,ie=J?J===G||J.contains(G):!1;if(ie)return!1;var be=kb(z,G);if(!be)return!0;if(be?H=z:(H=z==="v"?"h":"v",be=kb(z,G)),!be)return!1;if(!r.current&&"changedTouches"in N&&(A||U)&&(r.current=H),!H)return!0;var de=r.current||H;return IM(de,E,N,de==="h"?A:U)},[]),p=w.useCallback(function(N){var E=N;if(!(!ni.length||ni[ni.length-1]!==u)){var T="deltaY"in E?Cb(E):Kc(E),D=e.current.filter(function(H){return H.name===E.type&&(H.target===E.target||E.target===H.shadowParent)&&$M(H.delta,T)})[0];if(D&&D.should){E.cancelable&&E.preventDefault();return}if(!D){var A=(d.current.shards||[]).map(Rb).filter(Boolean).filter(function(H){return H.contains(E.target)}),U=A.length>0?f(E,A[0]):!d.current.noIsolation;U&&E.cancelable&&E.preventDefault()}}},[]),m=w.useCallback(function(N,E,T,D){var A={name:N,delta:E,target:T,should:D,shadowParent:FM(T)};e.current.push(A),setTimeout(function(){e.current=e.current.filter(function(U){return U!==A})},1)},[]),y=w.useCallback(function(N){n.current=Kc(N),r.current=void 0},[]),v=w.useCallback(function(N){m(N.type,Cb(N),N.target,f(N,t.lockRef.current))},[]),b=w.useCallback(function(N){m(N.type,Kc(N),N.target,f(N,t.lockRef.current))},[]);w.useEffect(function(){return ni.push(u),t.setCallbacks({onScrollCapture:v,onWheelCapture:v,onTouchMoveCapture:b}),document.addEventListener("wheel",p,si),document.addEventListener("touchmove",p,si),document.addEventListener("touchstart",y,si),function(){ni=ni.filter(function(N){return N!==u}),document.removeEventListener("wheel",p,si),document.removeEventListener("touchmove",p,si),document.removeEventListener("touchstart",y,si)}},[]);var S=t.removeScrollBar,_=t.inert;return w.createElement(w.Fragment,null,_?w.createElement(u,{styles:qM(l)}):null,S?w.createElement(MM,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function FM(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const KM=wM(CS,GM);var zS=w.forwardRef(function(t,e){return w.createElement(Du,$s({},t,{ref:e,sideCar:KM}))});zS.classNames=Du.classNames;var YM=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ai=new WeakMap,Yc=new WeakMap,Xc={},Lf=0,LS=function(t){return t&&(t.host||LS(t.parentNode))},XM=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=LS(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},WM=function(t,e,n,r){var l=XM(e,Array.isArray(t)?t:[t]);Xc[n]||(Xc[n]=new WeakMap);var u=Xc[n],d=[],f=new Set,p=new Set(l),m=function(v){!v||f.has(v)||(f.add(v),m(v.parentNode))};l.forEach(m);var y=function(v){!v||p.has(v)||Array.prototype.forEach.call(v.children,function(b){if(f.has(b))y(b);else try{var S=b.getAttribute(r),_=S!==null&&S!=="false",N=(ai.get(b)||0)+1,E=(u.get(b)||0)+1;ai.set(b,N),u.set(b,E),d.push(b),N===1&&_&&Yc.set(b,!0),E===1&&b.setAttribute(n,"true"),_||b.setAttribute(r,"true")}catch(T){console.error("aria-hidden: cannot operate on ",b,T)}})};return y(e),f.clear(),Lf++,function(){d.forEach(function(v){var b=ai.get(v)-1,S=u.get(v)-1;ai.set(v,b),u.set(v,S),b||(Yc.has(v)||v.removeAttribute(r),Yc.delete(v)),S||v.removeAttribute(n)}),Lf--,Lf||(ai=new WeakMap,ai=new WeakMap,Yc=new WeakMap,Xc={})}},JM=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),l=YM(t);return l?(r.push.apply(r,Array.from(l.querySelectorAll("[aria-live], script"))),WM(r,l,n,"aria-hidden")):function(){return null}};function QM(t){const e=ZM(t),n=w.forwardRef((r,l)=>{const{children:u,...d}=r,f=w.Children.toArray(u),p=f.find(t3);if(p){const m=p.props.children,y=f.map(v=>v===p?w.Children.count(m)>1?w.Children.only(null):w.isValidElement(m)?m.props.children:null:v);return o.jsx(e,{...d,ref:l,children:w.isValidElement(m)?w.cloneElement(m,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return n.displayName=`${t}.Slot`,n}function ZM(t){const e=w.forwardRef((n,r)=>{const{children:l,...u}=n;if(w.isValidElement(l)){const d=n3(l),f=s3(u,l.props);return l.type!==w.Fragment&&(f.ref=r?ju(r,d):d),w.cloneElement(l,f)}return w.Children.count(l)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var e3=Symbol("radix.slottable");function t3(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===e3}function s3(t,e){const n={...e};for(const r in e){const l=t[r],u=e[r];/^on[A-Z]/.test(r)?l&&u?n[r]=(...f)=>{const p=u(...f);return l(...f),p}:l&&(n[r]=l):r==="style"?n[r]={...l,...u}:r==="className"&&(n[r]=[l,u].filter(Boolean).join(" "))}return{...t,...n}}function n3(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Mu="Dialog",[US]=R5(Mu),[a3,zs]=US(Mu),PS=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:l,onOpenChange:u,modal:d=!0}=t,f=w.useRef(null),p=w.useRef(null),[m,y]=L5({prop:r,defaultProp:l??!1,onChange:u,caller:Mu});return o.jsx(a3,{scope:e,triggerRef:f,contentRef:p,contentId:kf(),titleId:kf(),descriptionId:kf(),open:m,onOpenChange:y,onOpenToggle:w.useCallback(()=>y(v=>!v),[y]),modal:d,children:n})};PS.displayName=Mu;var VS="DialogTrigger",r3=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=zs(VS,n),u=nr(e,l.triggerRef);return o.jsx(wn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":Sp(l.open),...r,ref:u,onClick:na(t.onClick,l.onOpenToggle)})});r3.displayName=VS;var bp="DialogPortal",[i3,BS]=US(bp,{forceMount:void 0}),IS=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:l}=t,u=zs(bp,e);return o.jsx(i3,{scope:e,forceMount:n,children:w.Children.map(r,d=>o.jsx(Ou,{present:n||u.open,children:o.jsx(AS,{asChild:!0,container:l,children:d})}))})};IS.displayName=bp;var bu="DialogOverlay",$S=w.forwardRef((t,e)=>{const n=BS(bu,t.__scopeDialog),{forceMount:r=n.forceMount,...l}=t,u=zs(bu,t.__scopeDialog);return u.modal?o.jsx(Ou,{present:r||u.open,children:o.jsx(l3,{...l,ref:e})}):null});$S.displayName=bu;var o3=QM("DialogOverlay.RemoveScroll"),l3=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=zs(bu,n);return o.jsx(zS,{as:o3,allowPinchZoom:!0,shards:[l.contentRef],children:o.jsx(wn.div,{"data-state":Sp(l.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),sr="DialogContent",qS=w.forwardRef((t,e)=>{const n=BS(sr,t.__scopeDialog),{forceMount:r=n.forceMount,...l}=t,u=zs(sr,t.__scopeDialog);return o.jsx(Ou,{present:r||u.open,children:u.modal?o.jsx(c3,{...l,ref:e}):o.jsx(u3,{...l,ref:e})})});qS.displayName=sr;var c3=w.forwardRef((t,e)=>{const n=zs(sr,t.__scopeDialog),r=w.useRef(null),l=nr(e,n.contentRef,r);return w.useEffect(()=>{const u=r.current;if(u)return JM(u)},[]),o.jsx(HS,{...t,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:na(t.onCloseAutoFocus,u=>{u.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:na(t.onPointerDownOutside,u=>{const d=u.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0;(d.button===2||f)&&u.preventDefault()}),onFocusOutside:na(t.onFocusOutside,u=>u.preventDefault())})}),u3=w.forwardRef((t,e)=>{const n=zs(sr,t.__scopeDialog),r=w.useRef(!1),l=w.useRef(!1);return o.jsx(HS,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{t.onCloseAutoFocus?.(u),u.defaultPrevented||(r.current||n.triggerRef.current?.focus(),u.preventDefault()),r.current=!1,l.current=!1},onInteractOutside:u=>{t.onInteractOutside?.(u),u.defaultPrevented||(r.current=!0,u.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const d=u.target;n.triggerRef.current?.contains(d)&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&l.current&&u.preventDefault()}})}),HS=w.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:l,onCloseAutoFocus:u,...d}=t,f=zs(sr,n),p=w.useRef(null),m=nr(e,p);return hM(),o.jsxs(o.Fragment,{children:[o.jsx(ES,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:l,onUnmountAutoFocus:u,children:o.jsx(jS,{role:"dialog",id:f.contentId,"aria-describedby":f.descriptionId,"aria-labelledby":f.titleId,"data-state":Sp(f.open),...d,ref:m,onDismiss:()=>f.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(d3,{titleId:f.titleId}),o.jsx(f3,{contentRef:p,descriptionId:f.descriptionId})]})]})}),wp="DialogTitle",GS=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=zs(wp,n);return o.jsx(wn.h2,{id:l.titleId,...r,ref:e})});GS.displayName=wp;var FS="DialogDescription",KS=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=zs(FS,n);return o.jsx(wn.p,{id:l.descriptionId,...r,ref:e})});KS.displayName=FS;var YS="DialogClose",XS=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=zs(YS,n);return o.jsx(wn.button,{type:"button",...r,ref:e,onClick:na(t.onClick,()=>l.onOpenChange(!1))})});XS.displayName=YS;function Sp(t){return t?"open":"closed"}var WS="DialogTitleWarning",[l6,JS]=C5(WS,{contentName:sr,titleName:wp,docsSlug:"dialog"}),d3=({titleId:t})=>{const e=JS(WS),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
101
|
+
|
|
102
|
+
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
103
|
+
|
|
104
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return w.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},h3="DialogDescriptionWarning",f3=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${JS(h3).contentName}}.`;return w.useEffect(()=>{const l=t.current?.getAttribute("aria-describedby");e&&l&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},m3=PS,p3=IS,g3=$S,y3=qS,v3=GS,x3=KS,b3=XS;function Xa({...t}){return o.jsx(m3,{"data-slot":"dialog",...t})}function w3({...t}){return o.jsx(p3,{"data-slot":"dialog-portal",...t})}function S3({className:t,...e}){return o.jsx(g3,{"data-slot":"dialog-overlay",className:Se("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function Wa({className:t,children:e,...n}){return o.jsxs(w3,{"data-slot":"dialog-portal",children:[o.jsx(S3,{}),o.jsxs(y3,{"data-slot":"dialog-content",className:Se("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...n,children:[e,o.jsxs(b3,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o.jsx(_s,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ja({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-header",className:Se("flex flex-col gap-2 text-center sm:text-left",t),...e})}function $a({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-footer",className:Se("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Qa({className:t,...e}){return o.jsx(v3,{"data-slot":"dialog-title",className:Se("text-lg leading-none font-semibold",t),...e})}function Za({className:t,...e}){return o.jsx(x3,{"data-slot":"dialog-description",className:Se("text-muted-foreground text-sm",t),...e})}function _3({email:t,isOpen:e,onOpenChange:n,onRetry:r}){const{t:l}=Xe(),[u,d]=w.useState([]),[f,p]=w.useState(!1);w.useEffect(()=>{e&&t&&m()},[e,t]);const m=async()=>{if(t){p(!0);try{const v=await Oe.getEmailEvents(t.id);v.data&&d(v.data.events)}catch(v){console.error("Failed to fetch trace:",v)}finally{p(!1)}}},y=v=>{switch(v){case"analysis":return o.jsx(Vo,{className:"w-4 h-4 text-purple-500"});case"action":return o.jsx($o,{className:"w-4 h-4 text-emerald-500"});case"error":return o.jsx(Ms,{className:"w-4 h-4 text-red-500"});default:return o.jsx(vi,{className:"w-4 h-4 text-blue-500"})}};return o.jsx(Xa,{open:e,onOpenChange:n,children:o.jsxs(Wa,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[o.jsxs(Ja,{className:"p-6 border-b flex flex-row items-center justify-between",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(wu,{className:"w-5 h-5 text-primary"}),o.jsx(Qa,{children:l("dashboard.aiTrace")})]}),o.jsx(Za,{children:l("dashboard.aiTraceDesc")})]}),t?.processing_status==="failed"&&r&&o.jsxs(Q,{size:"sm",variant:"outline",onClick:()=>{r(t),n(!1)},className:"gap-2 text-destructive border-destructive/20 hover:bg-destructive/10",children:[o.jsx(Lt,{className:"w-3.5 h-3.5"}),l("dashboard.retryProcessing")]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar bg-secondary/5",children:f?o.jsx("div",{className:"py-20 flex justify-center",children:o.jsx(dt,{})}):u.length===0?o.jsx("div",{className:"py-20 text-center text-muted-foreground italic font-mono text-sm",children:l("dashboard.noTrace")}):u.map((v,b)=>o.jsxs("div",{className:"relative pl-8",children:[b!==u.length-1&&o.jsx("div",{className:"absolute left-[15px] top-8 bottom-[-24px] w-px bg-border"}),o.jsx("div",{className:"absolute left-0 top-0 w-8 h-8 rounded-full border bg-background flex items-center justify-center z-10 shadow-sm",children:y(v.event_type)}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground/70",children:v.agent_state}),o.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[o.jsx(aa,{className:"w-3 h-3"}),new Date(v.created_at).toLocaleTimeString()]})]}),o.jsxs("div",{className:"bg-card border rounded-lg p-4 shadow-sm",children:[v.event_type==="info"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-foreground/90",children:v.details?.message}),v.details?.system_prompt&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"text-[9px] font-bold text-muted-foreground uppercase flex items-center gap-1",children:[o.jsx(yn,{className:"w-3 h-3"})," System Prompt"]}),o.jsx("pre",{className:"text-[10px] bg-secondary/50 p-2 rounded border overflow-x-auto whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:v.details.system_prompt})]}),v.details?.content_preview&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"text-[9px] font-bold text-muted-foreground uppercase flex items-center gap-1",children:[o.jsx(yn,{className:"w-3 h-3"})," ",l("dashboard.emailContent")]}),o.jsx("pre",{className:"text-[10px] bg-blue-500/5 p-2 rounded border border-blue-500/10 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto font-mono",children:v.details.content_preview})]})]}),v.event_type==="analysis"&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"text-[10px] bg-secondary px-2 py-1 rounded",children:[o.jsxs("span",{className:"text-muted-foreground mr-1",children:[l("config.rules.category"),":"]}),o.jsx("span",{className:"font-bold uppercase",children:v.details?.category||l("dashboard.analyzing")})]}),o.jsxs("div",{className:"text-[10px] bg-secondary px-2 py-1 rounded",children:[o.jsxs("span",{className:"text-muted-foreground mr-1",children:[l("config.rules.sentiment"),":"]}),o.jsx("span",{className:"font-bold uppercase",children:v.details?.sentiment||l("dashboard.analyzing")})]})]}),v.details?.system_prompt&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"text-[9px] font-bold text-muted-foreground uppercase flex items-center gap-1",children:[o.jsx(yn,{className:"w-3 h-3"})," System Prompt"]}),o.jsx("pre",{className:"text-[10px] bg-secondary/50 p-2 rounded border overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto font-mono",children:v.details?.system_prompt})]}),v.details?._raw_response&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"text-[9px] font-bold text-muted-foreground uppercase flex items-center gap-1",children:[o.jsx(yn,{className:"w-3 h-3"})," Raw LLM Response"]}),o.jsx("pre",{className:"text-[10px] bg-emerald-500/5 p-2 rounded border border-emerald-500/10 overflow-x-auto font-mono",children:JSON.stringify(JSON.parse(v.details._raw_response),null,2)})]}),v.details?.usage&&o.jsxs("div",{className:"flex gap-4 pt-2 border-t border-border/50",children:[o.jsxs("div",{className:"text-[10px]",children:[o.jsx("span",{className:"text-muted-foreground mr-1",children:"Prompt:"}),o.jsx("span",{className:"font-mono font-bold",children:v.details.usage.prompt_tokens})]}),o.jsxs("div",{className:"text-[10px]",children:[o.jsx("span",{className:"text-muted-foreground mr-1",children:"Completion:"}),o.jsx("span",{className:"font-mono font-bold",children:v.details.usage.completion_tokens})]}),o.jsxs("div",{className:"text-[10px]",children:[o.jsx("span",{className:"text-muted-foreground mr-1",children:"Total:"}),o.jsx("span",{className:"font-mono font-bold text-primary",children:v.details.usage.total_tokens})]})]})]}),v.event_type==="action"&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-sm font-bold text-emerald-600 dark:text-emerald-400 capitalize",children:[l("dashboard.done")," ",v.details?.action]}),o.jsxs("p",{className:"text-xs text-muted-foreground italic",children:['"',v.details?.reason,'"']})]}),o.jsx(Am,{className:"w-5 h-5 text-emerald-500"})]}),v.event_type==="error"&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 font-bold",children:typeof v.details?.error=="object"?v.details.error.message||JSON.stringify(v.details.error):v.details?.error}),v.details?.raw_response&&o.jsx("pre",{className:"text-[10px] bg-red-500/5 p-2 rounded border border-red-500/10 overflow-x-auto whitespace-pre-wrap font-mono",children:typeof v.details.raw_response=="object"?JSON.stringify(v.details.raw_response,null,2):v.details.raw_response})]})]})]})]},v.id))})]})})}const j3={spam:"bg-destructive/10 text-destructive",newsletter:"bg-blue-500/10 text-blue-600 dark:text-blue-400",support:"bg-orange-500/10 text-orange-600 dark:text-orange-400",client:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",internal:"bg-purple-500/10 text-purple-600 dark:text-purple-400",personal:"bg-pink-500/10 text-pink-600 dark:text-pink-400",other:"bg-gray-500/10 text-gray-600 dark:text-gray-400"};function N3(){const{state:t,actions:e}=oa(),{t:n}=Xe(),{openTerminal:r}=Cw(),[l,u]=w.useState(!0),{isSyncing:d}=t,[f,p]=w.useState(""),[m,y]=w.useState(null),[v,b]=w.useState(null),[S,_]=w.useState({}),[N,E]=w.useState(null),[T,D]=w.useState(!1),[A,U]=w.useState(null);w.useEffect(()=>{t.isAuthenticated?(H(),e.fetchStats()):u(!1)},[m,t.isAuthenticated]);const H=async(ee=0)=>{u(!0),await e.fetchEmails({category:m||void 0,search:f||void 0,offset:ee,sortBy:t.sortBy,sortOrder:t.sortOrder}),u(!1)},G=ee=>{e.fetchEmails({category:m||void 0,search:f||void 0,offset:0,sortBy:ee,sortOrder:t.sortOrder})},z=()=>{e.fetchEmails({category:m||void 0,search:f||void 0,offset:0,sortBy:t.sortBy,sortOrder:t.sortOrder==="asc"?"desc":"asc"})},M=async()=>{if(t.accounts.length===0){se.warning(n("dashboard.noEmailsConnected"));return}qs.playStart(),r(),await e.triggerSync()?(qs.playSuccess(),se.success(n("dashboard.syncSuccess"))):se.error(n("dashboard.syncFailed"))},J=async(ee,C)=>{if(C==="delete"&&N!==ee.id){E(ee.id);return}E(null),_(B=>({...B,[ee.id]:C}));const q=await e.executeAction(ee.id,C);_(B=>{const re={...B};return delete re[ee.id],re}),q&&(se.success(`Email ${C==="delete"?"deleted":C==="archive"?"archived":"updated"}`),C==="delete"&&H(t.emailsOffset))},ie=()=>{E(null)},be=ee=>{ee.preventDefault(),H()},de=ee=>{const C=ee==="next"?t.emailsOffset+20:Math.max(0,t.emailsOffset-20);H(C)},Ve=ee=>{U(ee),D(!0)},Ie=async ee=>{await e.retryProcessing(ee.id)&&se.success("Retrying email processing...")};return o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 animate-in fade-in duration-500",children:[o.jsxs("section",{className:"lg:col-span-2 space-y-4",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[o.jsx(Gs,{className:"w-5 h-5 text-primary"}),n("dashboard.recentAnalysis")]}),o.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[o.jsxs(Q,{onClick:M,size:"sm",variant:"default",className:"h-9 shadow-md px-4",disabled:d,children:[o.jsx(Lt,{className:Se("w-3.5 h-3.5 mr-2",d&&"animate-spin")}),n(d?"dashboard.syncing":"dashboard.syncNow")]}),o.jsxs("span",{className:"h-9 text-xs font-medium text-muted-foreground bg-secondary px-3 py-1 rounded-md border border-border flex items-center",children:[t.emailsTotal," ",n("dashboard.emails")]})]})]}),d&&o.jsxs("div",{className:"bg-primary/5 border border-primary/20 p-4 rounded-lg flex items-center justify-between animate-in fade-in slide-in-from-top-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:o.jsx(_t,{className:"w-5 h-5 text-primary animate-spin"})}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-semibold text-sm",children:n("dashboard.syncInProgress")}),o.jsx("p",{className:"text-xs text-muted-foreground",children:n("dashboard.syncInProgressDesc")})]})]}),o.jsxs(Q,{variant:"outline",size:"sm",onClick:r,className:"h-8 text-xs",children:[o.jsx(wu,{className:"w-3.5 h-3.5 mr-2"}),n("common.viewLogs")]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-center",children:[o.jsxs("form",{onSubmit:be,className:"flex-1 flex gap-2 w-full",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(YE,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),o.jsx(Ee,{placeholder:n("dashboard.searchPlaceholder"),value:f,onChange:ee=>p(ee.target.value),className:"pl-9 h-9"})]}),o.jsx(Q,{type:"submit",size:"sm",className:"h-9 px-4",children:n("dashboard.search")})]}),o.jsxs("div",{className:"flex items-center gap-1 bg-secondary/30 p-1 rounded-md border border-border/50 h-9",children:[o.jsxs("select",{className:"bg-transparent text-xs font-medium border-none focus:ring-0 cursor-pointer pl-2 pr-8 h-full",value:t.sortBy,onChange:ee=>G(ee.target.value),children:[o.jsx("option",{value:"date",children:n("dashboard.receivedTime")}),o.jsx("option",{value:"created_at",children:n("dashboard.processedTime")})]}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 text-primary",onClick:z,title:t.sortOrder==="asc"?n("dashboard.sortOldest"):n("dashboard.sortNewest"),children:t.sortOrder==="asc"?o.jsx(DN,{className:"w-3.5 h-3.5"}):o.jsx(CN,{className:"w-3.5 h-3.5"})})]})]}),o.jsxs("div",{className:"flex gap-1 flex-wrap",children:[o.jsx(Q,{size:"sm",variant:t.activeCategory===null?"secondary":"ghost",onClick:()=>y(null),children:n("dashboard.category.all")}),["spam","client","newsletter","support"].map(ee=>o.jsx(Q,{size:"sm",variant:t.activeCategory===ee?"secondary":"ghost",onClick:()=>y(ee),className:"capitalize",children:ee},ee))]}),l?o.jsx(bC,{}):t.emails.length===0?o.jsxs(ot,{className:"p-20 text-center shadow-sm",children:[o.jsx("div",{className:"w-16 h-16 bg-primary/10 text-primary rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx(Gs,{className:"w-8 h-8"})}),o.jsx("h3",{className:"text-lg font-medium",children:n("dashboard.noEmails")}),o.jsx("p",{className:"text-muted-foreground mt-2 mb-6",children:t.accounts.length===0?n("dashboard.noEmailsConnected"):n("dashboard.noEmailsFilters")}),t.accounts.length>0&&o.jsxs(Q,{onClick:()=>{r(),M()},disabled:d,children:[o.jsx(Lt,{className:Se("w-4 h-4 mr-2",d&&"animate-spin")}),n("dashboard.syncNow")]})]}):o.jsxs(o.Fragment,{children:[t.emails.map(ee=>o.jsx(A3,{email:ee,onAction:J,onRetry:Ie,onViewTrace:Ve,onSelect:()=>b(ee),isSelected:v?.id===ee.id,loadingAction:S[ee.id],isDeletePending:N===ee.id,onCancelDelete:ie},ee.id)),o.jsx(_3,{isOpen:T,onOpenChange:D,email:A,onRetry:Ie}),t.emailsTotal>20&&o.jsxs("div",{className:"flex items-center justify-between pt-4",children:[o.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>de("prev"),disabled:t.emailsOffset===0,children:[o.jsx(FN,{className:"w-4 h-4 mr-1"}),n("common.previous")]}),o.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.emailsOffset+1," - ",Math.min(t.emailsOffset+20,t.emailsTotal)," ",n("common.of")," ",t.emailsTotal]}),o.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>de("next"),disabled:t.emailsOffset+20>=t.emailsTotal,children:[n("common.next"),o.jsx(au,{className:"w-4 h-4 ml-1"})]})]})]})]}),o.jsxs("aside",{className:"space-y-6",children:[v&&o.jsxs(ot,{className:"p-6 border-primary/20 bg-primary/5 animate-in slide-in-from-right-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h3",{className:"font-semibold",children:n("dashboard.emailDetails")}),o.jsx(Q,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(null),children:o.jsx(_s,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground",children:n("dashboard.from")}),o.jsx("p",{className:"font-medium truncate",children:v.sender})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground",children:n("dashboard.subject")}),o.jsx("p",{className:"font-medium",children:v.subject})]}),v.ai_analysis&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground",children:n("dashboard.summary")}),o.jsx("p",{className:"text-xs mt-1",children:v.ai_analysis.summary})]}),v.ai_analysis.key_points&&o.jsxs("div",{children:[o.jsx("span",{className:"text-muted-foreground",children:n("dashboard.keyPoints")}),o.jsx("ul",{className:"text-xs mt-1 list-disc list-inside",children:v.ai_analysis.key_points.map((ee,C)=>o.jsx("li",{children:ee},C))})]}),v.ai_analysis.draft_response&&o.jsxs("div",{className:"mt-4 p-3 bg-emerald-500/5 border border-emerald-500/20 rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2 text-emerald-600 dark:text-emerald-400",children:[o.jsx(Su,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"text-xs font-bold uppercase",children:n("dashboard.aiDraftReply")})]}),o.jsx("p",{className:"text-xs leading-relaxed whitespace-pre-wrap italic text-foreground/80",children:v.ai_analysis.draft_response}),o.jsx("p",{className:"mt-2 text-[9px] text-muted-foreground",children:n("dashboard.draftSavedHelp").replace("{provider}",v.email_accounts?.provider==="gmail"?"Gmail":"Outlook")})]})]})]})]}),o.jsx(E3,{accounts:t.accounts,onUpdate:e.updateAccount,onSync:e.triggerSync,settings:t.settings,onUpdateSettings:e.updateSettings,openTerminal:r}),o.jsxs(ot,{className:"p-6",children:[o.jsxs("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[o.jsx(Ib,{className:"w-4 h-4 text-primary"}),n("dashboard.syncHistory")]}),o.jsx("div",{className:"space-y-4",children:!t.stats?.recentSyncs||t.stats.recentSyncs.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:n("dashboard.noSyncHistory")}):t.stats.recentSyncs.slice(0,5).map(ee=>o.jsxs("div",{className:"flex justify-between items-start text-sm border-b last:border-0 pb-3 last:pb-0",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:Se("w-1.5 h-1.5 rounded-full",ee.status==="success"?"bg-emerald-500":ee.status==="running"?"bg-blue-500 animate-pulse":"bg-red-500")}),o.jsxs("p",{className:"font-medium text-xs",children:[new Date(ee.started_at).toLocaleDateString()," ",new Date(ee.started_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),o.jsxs("p",{className:"text-[10px] text-muted-foreground pl-3.5",children:[n("dashboard.processed")," ",o.jsx("span",{className:"font-medium text-foreground",children:ee.emails_processed})," •",n("dashboard.actioned")," ",o.jsx("span",{className:"font-medium text-foreground",children:ee.emails_deleted+ee.emails_drafted})]}),ee.error_message&&o.jsxs("p",{className:"text-[10px] text-destructive pl-3.5 line-clamp-1",title:ee.error_message,children:[n("dashboard.error")," ",ee.error_message]})]}),o.jsx("div",{className:"text-[10px] text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:ee.status==="running"?n("dashboard.running"):ee.completed_at?`${Math.round((new Date(ee.completed_at).getTime()-new Date(ee.started_at).getTime())/1e3)}s`:"..."})]},ee.id))})]}),o.jsxs(ot,{className:"p-6",children:[o.jsx("h3",{className:"font-semibold mb-4",children:n("dashboard.quickStats")}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:n("dashboard.totalProcessed")}),o.jsx("span",{className:"font-medium",children:t.emailsTotal})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:n("dashboard.connectedAccounts")}),o.jsx("span",{className:"font-medium",children:t.accounts.length})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:n("dashboard.activeRules")}),o.jsx("span",{className:"font-medium",children:t.rules.filter(ee=>ee.is_enabled).length})]})]})]})]})]})}function E3({accounts:t,onUpdate:e,onSync:n,settings:r,onUpdateSettings:l,openTerminal:u}){const{t:d}=Xe();return t.length===0?null:o.jsxs(ot,{className:"p-6",children:[o.jsxs("h3",{className:"font-semibold mb-4 flex items-center gap-2",children:[o.jsx(QE,{className:"w-4 h-4 text-primary"}),d("dashboard.syncScope")]}),o.jsx("div",{className:"space-y-6",children:t.map(f=>o.jsx(T3,{account:f,onUpdate:e,onSync:n,openTerminal:u},f.id))})]})}function T3({account:t,onUpdate:e,onSync:n,openTerminal:r}){const{t:l}=Xe(),[u,d]=w.useState(!1),[f,p]=w.useState(""),[m,y]=w.useState(""),v=N=>{if(!N)return"";const E=typeof N=="string"&&/^\d+$/.test(N)?parseInt(N):N,T=new Date(E);if(isNaN(T.getTime()))return"";const D=A=>A<10?"0"+A:A;return T.getFullYear()+"-"+D(T.getMonth()+1)+"-"+D(T.getDate())+"T"+D(T.getHours())+":"+D(T.getMinutes())};w.useEffect(()=>{const N=t.sync_start_date||t.last_sync_checkpoint||t.last_sync_at;p(v(N)),y((t.sync_max_emails_per_run||50).toString())},[t.id,t.sync_start_date,t.last_sync_checkpoint,t.last_sync_at,t.sync_max_emails_per_run]);const b=async N=>{d(!0),await e(t.id,N),d(!1)},S=()=>{const N=t.sync_start_date?new Date(t.sync_start_date).toISOString():"",E=f?new Date(f).toISOString():"";E!==N&&b({sync_start_date:E||null})},_=()=>{const N=parseInt(m,10)||50;N!==t.sync_max_emails_per_run&&b({sync_max_emails_per_run:N})};return o.jsxs("div",{className:"space-y-3 pb-4 border-b last:border-0 last:pb-0",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-xs font-medium truncate max-w-[150px]",title:t.email_address,children:t.email_address}),o.jsxs("div",{className:"flex items-center gap-1",children:[t.last_sync_status==="syncing"?o.jsx(_t,{className:"w-3 h-3 text-primary animate-spin"}):t.last_sync_status==="success"?o.jsx(Am,{className:"w-3 h-3 text-emerald-500"}):t.last_sync_status==="error"?o.jsx("span",{title:t.last_sync_error||"Error",children:o.jsx(Ms,{className:"w-3 h-3 text-destructive"})}):null,o.jsx(Q,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{r(),n(t.id)},disabled:t.last_sync_status==="syncing",children:o.jsx(Lt,{className:Se("w-3 h-3",t.last_sync_status==="syncing"&&"animate-spin")})}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-orange-500",title:"Reset Checkpoint (Force Full Re-sync from Start Date)",onClick:()=>e(t.id,{last_sync_checkpoint:null}),disabled:t.last_sync_status==="syncing",children:o.jsx(Ib,{className:"w-3 h-3"})})]})]}),o.jsxs("div",{className:"grid grid-cols-[1.5fr_1fr] gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[o.jsx(Lb,{className:"w-2.5 h-2.5"})," ",l("dashboard.syncFrom")]}),o.jsx(Ee,{type:"datetime-local",className:"h-7 text-[10px] px-2 py-0 w-full",value:f,onChange:N=>p(N.target.value),onBlur:S,disabled:u||t.last_sync_status==="syncing"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[o.jsx(bE,{className:"w-2.5 h-2.5"})," ",l("dashboard.maxEmails")]}),o.jsx(Ee,{type:"number",className:"h-7 text-[10px] px-2 py-0",value:m,onChange:N=>y(N.target.value),onBlur:_,disabled:u||t.last_sync_status==="syncing"})]})]}),t.last_sync_at&&o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:[l("dashboard.lastSync")," ",new Date(t.last_sync_at).toLocaleString()]}),t.last_sync_error&&o.jsxs("p",{className:"text-[9px] text-destructive italic line-clamp-1",title:t.last_sync_error,children:[l("dashboard.error")," ",t.last_sync_error]})]})}function A3({email:t,onAction:e,onRetry:n,onViewTrace:r,onSelect:l,isSelected:u,loadingAction:d,isDeletePending:f,onCancelDelete:p}){const{t:m}=Xe();if(!t)return null;const y=j3[t.category||"other"],v=!!d,b=()=>{if(!t.email_accounts)return"#";const{provider:S,email_address:_}=t.email_accounts;return S==="gmail"?`https://mail.google.com/mail/u/${_}/#all/${t.external_id}`:`https://outlook.office.com/mail/deeplink/read/${encodeURIComponent(t.external_id)}`};return o.jsx(ot,{className:Se("hover:shadow-md transition-shadow group cursor-pointer",u&&"ring-2 ring-primary"),onClick:l,children:o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex justify-between items-start mb-3 gap-4",children:[o.jsxs("div",{className:"flex gap-3 flex-1 min-w-0",children:[o.jsx("div",{className:Se("w-8 h-8 rounded-full flex-shrink-0 flex items-center justify-center font-bold text-white text-xs",t.category==="spam"?"bg-destructive":"bg-primary"),children:t.sender?.[0]?.toUpperCase()||"?"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"font-semibold text-sm line-clamp-1 group-hover:text-primary transition-colors",children:t.subject||m("dashboard.noSubject")}),o.jsx("p",{className:"text-xs text-muted-foreground truncate",title:t.sender||"",children:t.sender})]})]}),o.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[o.jsx("span",{className:Se("px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",y),children:t.category||"unknown"}),o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[t.processing_status==="pending"&&o.jsxs("span",{className:"text-[9px] text-muted-foreground bg-secondary px-1.5 py-0.5 rounded flex items-center gap-1",children:[o.jsx(aa,{className:"w-2.5 h-2.5"})," ",m("dashboard.queued")]}),t.processing_status==="processing"&&o.jsxs("span",{className:"text-[9px] text-blue-600 dark:text-blue-400 bg-blue-500/10 border border-blue-500/20 px-1.5 py-0.5 rounded flex items-center gap-1",children:[o.jsx(_t,{className:"w-2.5 h-2.5 animate-spin"})," ",m("dashboard.analyzing")]}),t.processing_status==="completed"&&o.jsxs("span",{className:"text-[9px] text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-1.5 py-0.5 rounded flex items-center gap-1",children:[o.jsx(Vo,{className:"w-2.5 h-2.5"})," ",m("dashboard.analyzed")]}),t.processing_status==="failed"&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("span",{className:"text-[9px] text-red-600 dark:text-red-400 bg-red-500/10 border border-red-500/20 px-1.5 py-0.5 rounded flex items-center gap-1",title:t.processing_error||m("common.error"),children:[o.jsx(Ms,{className:"w-2.5 h-2.5"})," ",m("dashboard.failed")]}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-5 w-5 text-red-600 hover:bg-red-500/10",onClick:S=>{S.stopPropagation(),n(t)},title:m("dashboard.retryProcessing"),children:o.jsx(Lt,{className:"w-2.5 h-2.5"})})]}),!t.processing_status&&!t.ai_analysis&&o.jsxs("span",{className:"text-[9px] text-muted-foreground bg-secondary px-1.5 py-0.5 rounded flex items-center gap-1",children:[o.jsx(_t,{className:"w-2.5 h-2.5 animate-spin"})," ",m("dashboard.queued")]}),!t.processing_status&&t.ai_analysis&&o.jsxs("span",{className:"text-[9px] text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-1.5 py-0.5 rounded flex items-center gap-1",children:[o.jsx(Vo,{className:"w-2.5 h-2.5"})," ",m("dashboard.analyzed")]})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 text-[10px] text-muted-foreground/80 leading-tight",children:[o.jsxs("span",{title:t.date?new Date(t.date).toLocaleString():"",className:"whitespace-nowrap",children:[o.jsxs("span",{className:"opacity-70 text-[9px]",children:[m("dashboard.receivedAbbr"),":"]})," ",t.date?new Date(t.date).toLocaleString([],{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-"]}),o.jsx("span",{className:"opacity-30",children:"•"}),o.jsxs("span",{title:new Date(t.created_at).toLocaleString(),className:"whitespace-nowrap",children:[o.jsxs("span",{className:"opacity-70 text-[9px]",children:[m("dashboard.processedAbbr"),":"]})," ",new Date(t.created_at).toLocaleString([],{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]})]}),o.jsx("p",{className:"text-muted-foreground text-sm mb-4 line-clamp-2 leading-relaxed",children:t.body_snippet}),o.jsxs("div",{className:"bg-secondary/30 p-3 rounded-lg border border-border/50 flex justify-between items-center",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[o.jsx($b,{className:"w-3.5 h-3.5 text-emerald-500"}),m("dashboard.suggested"),t.suggested_actions&&t.suggested_actions.length>0?o.jsx("div",{className:"flex gap-1 flex-wrap",children:t.suggested_actions.map(S=>o.jsx("span",{className:"text-foreground border border-border/50 px-1.5 py-0.5 rounded capitalize bg-background/50",children:S},S))}):o.jsx("span",{className:"text-foreground",children:t.suggested_action||m("dashboard.category.none")}),t.actions_taken&&t.actions_taken.length>0?o.jsxs("span",{className:"text-muted-foreground ml-2 truncate max-w-[100px]",title:t.actions_taken.join(", "),children:["(",m("dashboard.done")," ",t.actions_taken.join(", "),")"]}):t.action_taken?o.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",m("dashboard.done")," ",t.action_taken,")"]}):null]}),o.jsx("div",{className:"flex gap-1 items-center",onClick:S=>S.stopPropagation(),children:f?o.jsxs("div",{className:"flex items-center gap-1 animate-in fade-in duration-200",children:[o.jsx("span",{className:"text-xs text-destructive mr-1",children:m("dashboard.deleteConfirm")}),o.jsx(Q,{variant:"destructive",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>e(t,"delete"),disabled:v,children:d==="delete"?o.jsx(_t,{className:"w-3 h-3 animate-spin"}):m("common.yes")}),o.jsx(Q,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:p,disabled:v,children:m("common.no")})]}):o.jsxs(o.Fragment,{children:[o.jsx("a",{href:b(),target:"_blank",rel:"noreferrer",className:"inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-primary hover:bg-secondary/50 transition-colors",title:m("dashboard.openIn").replace("{provider}",t.email_accounts?.provider==="gmail"?"Gmail":"Outlook"),children:o.jsx(Bo,{className:"w-3.5 h-3.5"})}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-primary",onClick:()=>r(t),title:m("dashboard.viewTraceTooltip"),children:o.jsx(km,{className:"w-3.5 h-3.5"})}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 hover:text-destructive",onClick:()=>e(t,"delete"),disabled:v,title:m("common.delete"),children:d==="delete"?o.jsx(_t,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(_u,{className:"w-3.5 h-3.5"})}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 hover:text-blue-500",onClick:()=>e(t,"archive"),disabled:v,title:m("common.archive"),children:d==="archive"?o.jsx(_t,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(AN,{className:"w-3.5 h-3.5"})}),o.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 hover:text-primary",onClick:()=>e(t,"flag"),disabled:v,title:m("common.flag"),children:d==="flag"?o.jsx(_t,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(mE,{className:"w-3.5 h-3.5"})})]})})]})]})})}function k3({onPreview:t}){const{t:e}=Xe(),[n,r]=w.useState([]),[l,u]=w.useState([]),[d,f]=w.useState(!0),[p,m]=w.useState(new Set),[y,v]=w.useState(null),[b,S]=w.useState("all"),[_,N]=w.useState("pending");w.useEffect(()=>{T(),E()},[b,_]);const E=async()=>{try{const z=await Oe.getAccounts();z.data&&u(z.data.accounts)}catch(z){console.error("Failed to fetch accounts:",z)}},T=async()=>{f(!0);try{const z=new URLSearchParams({status:_,limit:"100"});b!=="all"&&z.append("account_id",b);const M=await fetch(`/api/v1/drafts?${z}`,{headers:{Authorization:`Bearer ${localStorage.getItem("supabase.auth.token")}`}});if(!M.ok)throw new Error("Failed to fetch drafts");const J=await M.json();r(J.drafts||[])}catch(z){console.error("Failed to fetch drafts:",z),se.error(e("drafts.loadError")||"Failed to load drafts")}finally{f(!1)}},D=async z=>{v(z);try{if(!(await fetch(`/api/v1/drafts/${z}/send`,{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("supabase.auth.token")}`}})).ok)throw new Error("Failed to send draft");se.success(e("drafts.sendSuccess")||"Draft sent successfully!"),T()}catch(M){console.error("Failed to send draft:",M),se.error(e("drafts.sendError")||"Failed to send draft")}finally{v(null)}},A=async z=>{v(z);try{if(!(await fetch(`/api/v1/drafts/${z}/dismiss`,{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("supabase.auth.token")}`}})).ok)throw new Error("Failed to dismiss draft");se.success(e("drafts.dismissSuccess")||"Draft dismissed"),T()}catch(M){console.error("Failed to dismiss draft:",M),se.error("Failed to dismiss draft")}finally{v(null)}},U=()=>{p.size===n.length?m(new Set):m(new Set(n.map(z=>z.id)))},H=async()=>{const z=Array.from(p);for(const M of z)await D(M);m(new Set)},G=async()=>{const z=Array.from(p);for(const M of z)await A(M);m(new Set)};return d?o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(dt,{})}):o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-2",children:[o.jsx(Gs,{className:"w-6 h-6 text-primary"}),e("drafts.title")||"Draft Review Center"]}),o.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[n.length," ",e("drafts.pending")||"pending drafts"]})]}),o.jsxs(Q,{onClick:T,variant:"outline",size:"sm",children:[o.jsx(Lt,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),o.jsx(ot,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(gE,{className:"w-4 h-4 text-muted-foreground"}),o.jsxs("select",{value:b,onChange:z=>S(z.target.value),className:"px-3 py-1.5 rounded-md border bg-background text-sm",children:[o.jsx("option",{value:"all",children:e("drafts.filterByAccount")||"All Accounts"}),l.map(z=>o.jsx("option",{value:z.id,children:z.email_address},z.id))]})]}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("select",{value:_,onChange:z=>N(z.target.value),className:"px-3 py-1.5 rounded-md border bg-background text-sm",children:[o.jsx("option",{value:"pending",children:"Pending"}),o.jsx("option",{value:"sent",children:"Sent"}),o.jsx("option",{value:"dismissed",children:"Dismissed"})]})}),p.size>0&&o.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[o.jsxs("span",{className:"text-sm text-muted-foreground",children:[p.size," selected"]}),o.jsxs(Q,{onClick:H,size:"sm",variant:"default",children:[o.jsx(Su,{className:"w-4 h-4 mr-2"}),e("drafts.sendSelected")||"Send Selected"]}),o.jsxs(Q,{onClick:G,size:"sm",variant:"outline",children:[o.jsx(_s,{className:"w-4 h-4 mr-2"}),e("drafts.dismissSelected")||"Dismiss Selected"]})]})]})}),n.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",checked:p.size===n.length,onChange:U,className:"rounded border-gray-300"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e("drafts.selectAll")||"Select All"})]}),n.length===0?o.jsxs(ot,{className:"p-12 text-center",children:[o.jsx(Gs,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),o.jsx("h3",{className:"text-lg font-semibold mb-2",children:e("drafts.noDrafts")||"No pending drafts"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e("drafts.noDraftsDesc")||"AI-generated draft replies will appear here for your review"})]}):o.jsx("div",{className:"space-y-3",children:n.map(z=>o.jsx(C3,{draft:z,isSelected:p.has(z.id),onSelect:()=>{const M=new Set(p);M.has(z.id)?M.delete(z.id):M.add(z.id),m(M)},onSend:()=>D(z.id),onDismiss:()=>A(z.id),onPreview:()=>t(z),isLoading:y===z.id},z.id))})]})}function C3({draft:t,isSelected:e,onSelect:n,onSend:r,onDismiss:l,onPreview:u,isLoading:d}){const{t:f}=Xe(),p=t.draft_content?.substring(0,200)||t.ai_analysis?.draft_response?.substring(0,200)||"",m=t.draft_created_at?R3(new Date(t.draft_created_at)):"";return o.jsx(ot,{className:Se("p-4 hover:shadow-md transition-shadow",e&&"ring-2 ring-primary"),children:o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("input",{type:"checkbox",checked:e,onChange:n,className:"mt-1 rounded border-gray-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4 mb-2",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("h3",{className:"font-semibold text-sm truncate",children:["Re: ",t.subject||f("dashboard.noSubject")]}),o.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["From: ",t.sender]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[o.jsx(aa,{className:"w-3 h-3"}),m]})]}),o.jsxs("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:[p,"..."]}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[o.jsx(Gs,{className:"w-3 h-3"}),t.email_accounts?.email_address]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Q,{onClick:r,disabled:d,size:"sm",className:"gap-2",children:[d?o.jsx(_t,{className:"w-4 h-4 animate-spin"}):o.jsx(Su,{className:"w-4 h-4"}),f("drafts.send")||"Send Now"]}),o.jsxs(Q,{onClick:u,disabled:d,size:"sm",variant:"outline",className:"gap-2",children:[o.jsx(km,{className:"w-4 h-4"}),f("drafts.preview")||"Preview"]}),o.jsxs(Q,{onClick:l,disabled:d,size:"sm",variant:"ghost",className:"gap-2",children:[o.jsx(_s,{className:"w-4 h-4"}),f("drafts.dismiss")||"Dismiss"]})]})]})]})})}function R3(t){const n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),l=Math.floor(r/60),u=Math.floor(l/24);return r<1?"just now":r<60?`${r}m ago`:l<24?`${l}h ago`:`${u}d ago`}function O3({email:t,onClose:e,onSend:n,onDismiss:r}){const{t:l}=Xe(),[u,d]=w.useState(!1),[f,p]=w.useState(""),[m,y]=w.useState(!1),v=t.draft_content||t.ai_analysis?.draft_response||"",b=t.body_snippet||"",S=async()=>{d(!0);try{await n(t.id),e()}catch(T){console.error("Failed to send:",T)}finally{d(!1)}},_=async()=>{d(!0);try{await r(t.id),e()}catch(T){console.error("Failed to dismiss:",T)}finally{d(!1)}},N=async()=>{if(!f.trim()){se.error("Please provide instructions for regeneration");return}d(!0);try{if(!(await fetch(`/api/v1/drafts/${t.id}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("supabase.auth.token")}`},body:JSON.stringify({instructions:f})})).ok)throw new Error("Failed to regenerate draft");se.success("Draft regeneration queued"),y(!1),p("")}catch(T){console.error("Failed to regenerate:",T),se.error("Failed to regenerate draft")}finally{d(!1)}},E=()=>{if(!t.email_accounts)return;const{provider:T,email_address:D}=t.email_accounts;T==="gmail"?window.open(`https://mail.google.com/mail/u/${D}/#drafts`,"_blank"):window.open("https://outlook.office.com/mail/drafts","_blank")};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4 animate-in fade-in duration-200",children:o.jsxs(ot,{className:"w-full max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-6 border-b",children:[o.jsxs("h2",{className:"text-xl font-bold flex items-center gap-2",children:[o.jsx(Gs,{className:"w-5 h-5 text-primary"}),l("drafts.preview")||"Draft Preview"]}),o.jsx(Q,{onClick:e,variant:"ghost",size:"sm",children:o.jsx(_s,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide",children:l("drafts.originalEmail")||"Original Email"}),o.jsxs(ot,{className:"p-4 bg-muted/30",children:[o.jsxs("div",{className:"space-y-2 text-sm",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Om,{className:"w-4 h-4 mt-0.5 text-muted-foreground flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"From:"})," ",t.sender]})]}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Gs,{className:"w-4 h-4 mt-0.5 text-muted-foreground flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Subject:"})," ",t.subject||l("dashboard.noSubject")]})]}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Lb,{className:"w-4 h-4 mt-0.5 text-muted-foreground flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Date:"})," ",t.date?new Date(t.date).toLocaleString():"-"]})]})]}),o.jsx("div",{className:"mt-4 pt-4 border-t",children:o.jsx("p",{className:"text-sm whitespace-pre-wrap",children:b})})]})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide",children:l("drafts.aiReply")||"AI-Generated Reply"}),o.jsx(ot,{className:"p-4 bg-primary/5 border-primary/20",children:o.jsx("div",{className:"prose prose-sm max-w-none",children:o.jsx("p",{className:"text-sm whitespace-pre-wrap",children:v})})})]}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.draft_created_at&&o.jsxs("p",{children:["Created ",new Date(t.draft_created_at).toLocaleString()]})}),m&&o.jsxs(ot,{className:"p-4 bg-muted/30",children:[o.jsx("h4",{className:"text-sm font-semibold mb-3",children:l("drafts.regenerate")||"Regenerate Draft"}),o.jsx("textarea",{value:f,onChange:T=>p(T.target.value),placeholder:"Provide new instructions (e.g., 'Make it more formal', 'Add a specific deadline')",className:"w-full px-3 py-2 rounded-md border bg-background text-sm min-h-[100px]"}),o.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[o.jsxs(Q,{onClick:N,disabled:u||!f.trim(),size:"sm",children:[u?o.jsx(_t,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Lt,{className:"w-4 h-4 mr-2"}),"Regenerate"]}),o.jsx(Q,{onClick:()=>y(!1),variant:"ghost",size:"sm",children:"Cancel"})]})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4 p-6 border-t bg-muted/30",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Q,{onClick:S,disabled:u,className:"gap-2",children:[u?o.jsx(_t,{className:"w-4 h-4 animate-spin"}):o.jsx(Su,{className:"w-4 h-4"}),l("drafts.send")||"Send Now"]}),o.jsxs(Q,{onClick:E,variant:"outline",className:"gap-2",children:[o.jsx(nT,{className:"w-4 h-4"}),"Edit in ",t.email_accounts?.provider==="gmail"?"Gmail":"Outlook"]}),!m&&o.jsxs(Q,{onClick:()=>y(!0),variant:"outline",className:"gap-2",children:[o.jsx(Lt,{className:"w-4 h-4"}),l("drafts.regenerate")||"Regenerate"]})]}),o.jsxs(Q,{onClick:_,disabled:u,variant:"ghost",className:"gap-2",children:[o.jsx(_s,{className:"w-4 h-4"}),l("drafts.dismiss")||"Dismiss"]})]})]})})}const ko="realtimexai";function D3(){const{state:t,actions:e}=oa(),{t:n}=Xe(),[r,l]=w.useState(!1),[u,d]=w.useState(!1),[f,p]=w.useState(null),[m,y]=w.useState(!1),[v,b]=w.useState(!1),[S,_]=w.useState({}),[N,E]=w.useState(!1),[T,D]=w.useState("credentials"),[A,U]=w.useState(""),[H,G]=w.useState(""),[z,M]=w.useState(""),[J,ie]=w.useState(""),[be,de]=w.useState(!1),[Ve,Ie]=w.useState(!1),[ee,C]=w.useState(!1),[q,B]=w.useState("credentials"),[re,pe]=w.useState(""),[R,Y]=w.useState(""),[Z,te]=w.useState(!1),[we,_e]=w.useState(!1),[ge,lt]=w.useState(""),[Le,ls]=w.useState("category"),[Gt,Et]=w.useState("newsletter"),[js,Ns]=w.useState(["archive"]),[ca,ar]=w.useState(""),[ol,Ai]=w.useState(""),[rr,ir]=w.useState(""),[or,ll]=w.useState(""),[cl,Tt]=w.useState([]),[lr,ki]=w.useState(!1),[Ci,ua]=w.useState(!1),[Ks,ul]=w.useState([]),[cr,dl]=w.useState(!1),[Sn,At]=w.useState(null);w.useEffect(()=>{(async()=>{dl(!0),At(null);try{const ne=await Oe.getChatProviders();ne.data?.success?ul(ne.data.providers||[]):At(ne.data?.message||"Failed to load providers")}catch(ne){console.error("Failed to fetch providers:",ne),At("Failed to load providers. Using defaults.")}finally{dl(!1)}})()},[]);const vt=Ks.find(I=>I.provider===(S.llm_provider||ko))?.models||[],hl=w.useMemo(()=>!S.llm_model||vt.some(ne=>ne.id===S.llm_model)?vt:[{id:S.llm_model,name:`${S.llm_model} (saved)`},...vt],[vt,S.llm_model]),zu=w.useMemo(()=>!S.llm_provider||S.llm_provider===ko||Ks.some(ne=>ne.provider===S.llm_provider)?Ks:[{provider:S.llm_provider,name:`${S.llm_provider} (saved)`,models:[]},...Ks],[Ks,S.llm_provider]),Lu=I=>{const ne=Ks.find(Ae=>Ae.provider===I);_(Ae=>({...Ae,llm_provider:I,llm_model:ne?.models?.[0]?.id||""}))},ur=async()=>{b(!0);try{const I=await Oe.testLlm({llm_provider:S.llm_provider||void 0,llm_model:S.llm_model||void 0});I.data?.success?se.success(I.data.message):se.error(I.data?.message||"Connection failed")}catch(I){se.error(I.response?.data?.message||"Connection failed")}finally{b(!1)}},[Ri,Oi]=w.useState(null),[Vt,da]=w.useState(null);w.useEffect(()=>{e.fetchAccounts(),e.fetchRules(),e.fetchSettings()},[]),w.useEffect(()=>{t.settings&&_(t.settings)},[t.settings]);const ha=w.useRef(null),Uu=()=>{D("credentials"),U(""),G(""),M(""),ie(""),E(!0)},fl=I=>{U(I);try{const ne=JSON.parse(I),Ae=ne.installed||ne.web||ne;Ae.client_id&&G(Ae.client_id),Ae.client_secret&&M(Ae.client_secret),ne.installed?se.success("Detected Desktop app credentials"):ne.web&&se.info("Detected Web app - make sure redirect URI is configured in Google Cloud Console")}catch{}},Di=async()=>{if(!H||!z){se.error("Please provide both Client ID and Client Secret");return}de(!0);try{if(await e.updateSettings({...S,google_client_id:H,google_client_secret:z})){_(Ae=>({...Ae,google_client_id:H,google_client_secret:z}));const ne=await Oe.getGmailAuthUrl();if(ne.data?.url)window.open(ne.data.url,"_blank"),D("code"),se.success("Please authorize in the opened tab, then paste the code here");else{const Ae=typeof ne.error=="string"?ne.error:ne.error?.message;se.error(Ae||"Failed to get OAuth URL")}}else se.error("Failed to save credentials")}catch{se.error("Failed to save credentials")}finally{de(!1)}},fa=async()=>{if(!J.trim()){se.error("Please paste the authorization code");return}Ie(!0);try{const I=await Oe.connectGmail(J.trim());if(I.data?.success)se.success("Gmail account connected successfully!"),E(!1),e.fetchAccounts();else{const ne=typeof I.error=="string"?I.error:I.error?.message;se.error(ne||"Failed to connect Gmail")}}catch{se.error("Failed to connect Gmail")}finally{Ie(!1)}},Pu=()=>{B("credentials"),pe(""),Y(""),C(!0)},ml=async()=>{if(!re){se.error("Please provide the Client ID");return}te(!0);try{if(await e.updateSettings({...S,microsoft_client_id:re,microsoft_tenant_id:R||"common"})){_(Ae=>({...Ae,microsoft_client_id:re,microsoft_tenant_id:R||"common"}));const ne=await Oe.startMicrosoftDeviceFlow();if(ne.data)p(ne.data),B("device-code"),pl(ne.data.deviceCode,ne.data.interval);else{const Ae=typeof ne.error=="string"?ne.error:ne.error?.message;se.error(Ae||"Failed to start device flow")}}else se.error("Failed to save credentials")}catch{se.error("Failed to save credentials")}finally{te(!1)}},pl=async(I,ne)=>{const Ae=setInterval(async()=>{try{const Bt=await Oe.pollMicrosoftDeviceCode(I);Bt.data?.status==="completed"?(clearInterval(Ae),p(null),d(!1),C(!1),se.success("Outlook account connected"),e.fetchAccounts()):Bt.error&&typeof Bt.error=="object"&&Bt.error.code}catch{}},ne*1e3);setTimeout(()=>{clearInterval(Ae),u&&(p(null),d(!1),C(!1),se.error("Connection timed out. Please try again."))},900*1e3)},gl=async()=>{if(!ge){se.error("Please name your rule");return}if(js.length===0){se.error("Please select at least one action");return}ua(!0);try{const I={[Le]:Gt};ca&&(I.older_than_days=parseInt(ca,10));const ne=js.includes("draft"),Ae={name:ge,description:rr||void 0,intent:or||void 0,condition:I,actions:js,instructions:ne?ol:void 0,attachments:ne?cl:[],is_enabled:!0};let Bt=!1;Vt?Bt=await e.updateRule(Vt.id,Ae):Bt=await e.createRule(Ae),Bt?(se.success(Vt?"Rule updated":"Rule created"),_e(!1),da(null),lt(""),Ns(["archive"]),ar(""),Ai(""),ir(""),ll(""),Tt([]),e.fetchRules()):se.error(`Failed to ${Vt?"update":"create"} rule`)}catch{se.error("An error occurred while saving the rule")}finally{ua(!1)}},Mi=async I=>{if(!confirm("Are you sure you want to disconnect this account?"))return;await e.disconnectAccount(I)&&se.success("Account disconnected")},dr=async()=>{y(!0);const I=await e.updateSettings(S);y(!1),I&&se.success("Settings saved")},yl=async I=>{const ne=I.target.files;if(!ne||ne.length===0)return;ki(!0);const Ae=ne[0],Bt=Ae.name.split(".").pop(),Vu=`${Math.random().toString(36).substring(2)}.${Bt}`,xl=`${t.user.id}/${Vu}`;try{const{error:ma}=await Qe.storage.from("rule-attachments").upload(xl,Ae);if(ma)throw ma;const pa={name:Ae.name,path:xl,type:Ae.type,size:Ae.size};Tt(zi=>[...zi,pa]),se.success("File uploaded")}catch(ma){console.error("Upload error:",ma),se.error("Failed to upload file")}finally{ki(!1),I.target.value=""}},vl=I=>{Tt(ne=>ne.filter(Ae=>Ae.path!==I))},Ls=I=>I==="gmail"?o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold",children:"G"}):o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold",children:"O"});return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-500",children:[o.jsx(Xa,{open:N,onOpenChange:E,children:o.jsxs(Wa,{className:"sm:max-w-lg",children:[o.jsxs(Ja,{children:[o.jsxs(Qa,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold text-sm",children:"G"}),n("config.gmail.connect")]}),o.jsx(Za,{children:n(T==="credentials"?"config.gmail.credentialsDesc":"config.gmail.authCodeDesc")})]}),T==="credentials"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(hT,{className:"w-4 h-4"}),n("config.gmail.pasteJson")]}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/30 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:A,onChange:I=>fl(I.target.value)}),o.jsx("p",{className:"text-xs text-muted-foreground",children:n("config.gmail.downloadHelp")})]}),o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("span",{className:"w-full border-t"})}),o.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:o.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:n("config.gmail.orEnterManually")})})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client ID"}),o.jsx(Ee,{placeholder:"xxx.apps.googleusercontent.com",value:H,onChange:I=>G(I.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client Secret"}),o.jsx(Ee,{type:"password",placeholder:"GOCSPX-...",value:z,onChange:I=>M(I.target.value)})]})]})]}),o.jsxs($a,{children:[o.jsx(Q,{variant:"outline",onClick:()=>E(!1),children:n("common.cancel")}),o.jsxs(Q,{onClick:Di,disabled:be||!H||!z,children:[be?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Xn,{className:"w-4 h-4 mr-2"}),n("common.save")," & ",n("setup.engage")]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:o.jsxs("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:["1. A new tab opened with Google Sign-In",o.jsx("br",{}),"2. Sign in and authorize the app",o.jsx("br",{}),"3. Copy the authorization code shown",o.jsx("br",{}),"4. Paste it below"]})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Authorization Code"}),o.jsx(Ee,{placeholder:"4/0AQlEd8x...",value:J,onChange:I=>ie(I.target.value),className:"font-mono"})]})]}),o.jsxs($a,{children:[o.jsx(Q,{variant:"outline",onClick:()=>D("credentials"),children:n("setup.back")}),o.jsxs(Q,{onClick:fa,disabled:Ve||!J.trim(),children:[Ve?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Xn,{className:"w-4 h-4 mr-2"}),n("setup.engage")]})]})]})]})}),o.jsx(Xa,{open:ee,onOpenChange:C,children:o.jsxs(Wa,{className:"sm:max-w-lg",children:[o.jsxs(Ja,{children:[o.jsxs(Qa,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold text-sm",children:"O"}),n("config.outlook.connect")]}),o.jsx(Za,{children:n(q==="credentials"?"config.outlook.credentialsDesc":"config.outlook.instructions")})]}),q==="credentials"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:o.jsx("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:"Note: You need an Azure App Registration for this to work."})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client ID (Application ID)"}),o.jsx(Ee,{placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",value:re,onChange:I=>pe(I.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Tenant ID (Optional)"}),o.jsx(Ee,{placeholder:"common",value:R,onChange:I=>Y(I.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:'Default is "common". Use your specific Tenant ID for organization accounts.'})]})]})]}),o.jsxs($a,{children:[o.jsx(Q,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),o.jsxs(Q,{onClick:ml,disabled:Z||!re,children:[Z?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Xn,{className:"w-4 h-4 mr-2"}),"Save & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[f&&o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[o.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"Action Required"}),o.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-4",children:f.message}),o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center gap-2 bg-white dark:bg-black/20 p-2 rounded border border-blue-200 dark:border-blue-800",children:o.jsx("code",{className:"text-lg font-mono font-bold flex-1 text-center select-all",children:f.userCode})}),o.jsxs(Q,{variant:"default",className:"w-full bg-blue-600 hover:bg-blue-700",onClick:()=>window.open(f.verificationUri,"_blank"),children:["Open Microsoft Login",o.jsx(Bo,{className:"w-4 h-4 ml-2"})]})]})]}),o.jsx("div",{className:"flex justify-center",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(dt,{size:"sm"}),"Waiting for authorization..."]})})]}),o.jsx($a,{children:o.jsx(Q,{variant:"outline",onClick:()=>C(!1),children:"Cancel"})})]})]})}),o.jsx(Xa,{open:we,onOpenChange:I=>{_e(I),I||da(null)},children:o.jsxs(Wa,{className:"sm:max-w-xl max-h-[90vh] flex flex-col p-0",children:[o.jsxs(Ja,{className:"p-6 border-b",children:[o.jsx(Qa,{children:n(Vt?"config.rules.edit":"config.rules.create")}),o.jsx(Za,{children:n("config.rules.desc")})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.name")}),o.jsx(Ee,{placeholder:n("config.rules.namePlaceholder"),value:ge,onChange:I=>lt(I.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.description")}),o.jsx("textarea",{className:"w-full p-2 border rounded-md bg-background min-h-[60px] text-sm",placeholder:n("config.rules.descriptionPlaceholder"),value:rr,onChange:I=>ir(I.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("config.rules.semanticHelp")})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.intent")}),o.jsx(Ee,{placeholder:n("config.rules.intentPlaceholder"),value:or,onChange:I=>ll(I.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("config.rules.intentHelp")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.conditionField")}),o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:Le,onChange:I=>{ls(I.target.value),I.target.value==="category"?Et("newsletter"):I.target.value==="sentiment"?Et("Positive"):I.target.value==="priority"?Et("High"):Et("")},children:[o.jsxs("optgroup",{label:n("config.rules.aiAnalysis"),children:[o.jsx("option",{value:"category",children:n("config.rules.category")}),o.jsx("option",{value:"sentiment",children:n("config.rules.sentiment")}),o.jsx("option",{value:"priority",children:n("config.rules.priority")})]}),o.jsxs("optgroup",{label:n("config.rules.metadata"),children:[o.jsx("option",{value:"sender_email",children:n("config.rules.senderEmail")}),o.jsx("option",{value:"sender_domain",children:n("config.rules.senderDomain")}),o.jsx("option",{value:"sender_contains",children:n("config.rules.senderContains")}),o.jsx("option",{value:"subject_contains",children:n("config.rules.subjectContains")}),o.jsx("option",{value:"body_contains",children:n("config.rules.bodyContains")})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.equalsValue")}),Le==="category"?o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:Gt,onChange:I=>Et(I.target.value),children:[o.jsx("option",{value:"newsletter",children:"Newsletter"}),o.jsx("option",{value:"spam",children:"Spam"}),o.jsx("option",{value:"promotional",children:"Promotional"}),o.jsx("option",{value:"transactional",children:"Transactional"}),o.jsx("option",{value:"social",children:"Social"}),o.jsx("option",{value:"support",children:"Support"}),o.jsx("option",{value:"client",children:"Client"}),o.jsx("option",{value:"internal",children:"Internal"}),o.jsx("option",{value:"personal",children:"Personal"}),o.jsx("option",{value:"other",children:"Other"})]}):Le==="sentiment"?o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:Gt,onChange:I=>Et(I.target.value),children:[o.jsx("option",{value:"Positive",children:"Positive"}),o.jsx("option",{value:"Neutral",children:"Neutral"}),o.jsx("option",{value:"Negative",children:"Negative"})]}):Le==="priority"?o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:Gt,onChange:I=>Et(I.target.value),children:[o.jsx("option",{value:"High",children:"High"}),o.jsx("option",{value:"Medium",children:"Medium"}),o.jsx("option",{value:"Low",children:"Low"})]}):o.jsx(Ee,{placeholder:Le==="sender_domain"?"rta.vn":Le==="sender_email"?"john@example.com":n("config.rules.keywordsPlaceholder"),value:Gt,onChange:I=>Et(I.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(aa,{className:"w-4 h-4"}),n("config.rules.olderThan")]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ee,{type:"number",min:"0",placeholder:"0",className:"w-24",value:ca,onChange:I=>ar(I.target.value)}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("config.rules.olderThanHelp")})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.performActions")}),o.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select one or more actions to execute when the rule matches"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"archive",label:n("common.archive")},{value:"delete",label:n("common.delete")},{value:"draft",label:n("common.draft")},{value:"star",label:n("common.star")}].map(I=>o.jsxs("label",{className:`flex items-center gap-2 p-2 border rounded-md cursor-pointer transition-colors ${js.includes(I.value)?"bg-primary/10 border-primary":"bg-background hover:bg-secondary/50"}`,children:[o.jsx("input",{type:"checkbox",checked:js.includes(I.value),onChange:ne=>{ne.target.checked?Ns([...js,I.value]):Ns(js.filter(Ae=>Ae!==I.value))},className:"rounded border-gray-300"}),o.jsx("span",{className:"text-sm",children:I.label})]},I.value))})]}),js.includes("draft")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-2 animate-in slide-in-from-top-2 duration-200",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.rules.draftInstructions")}),o.jsx("textarea",{className:"w-full p-2 border rounded-md bg-background min-h-[80px] text-sm",placeholder:"e.g. Tell them I'm busy until Friday, but interested in the proposal.",value:ol,onChange:I=>Ai(I.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("config.rules.contextHelp")})]}),o.jsxs("div",{className:"space-y-2 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(Vb,{className:"w-4 h-4"}),"Attachments (Optional)"]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[cl.map(I=>o.jsxs("div",{className:"flex items-center justify-between p-2 bg-secondary/50 rounded border text-xs",children:[o.jsx("span",{className:"truncate max-w-[200px]",children:I.name}),o.jsx(Q,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive",onClick:()=>vl(I.path),children:o.jsx(_s,{className:"w-3 h-3"})})]},I.path)),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"file",className:"absolute inset-0 opacity-0 cursor-pointer",onChange:yl,disabled:lr}),o.jsxs(Q,{variant:"outline",size:"sm",className:"w-full border-dashed",disabled:lr,children:[lr?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(qa,{className:"w-3 h-3 mr-2"}),n(lr?"config.rules.uploading":"config.rules.addAttachment")]})]})]}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("config.rules.attachmentHelp")})]})]})]}),o.jsxs($a,{className:"p-6 border-t bg-secondary/5",children:[o.jsx(Q,{variant:"outline",onClick:()=>_e(!1),children:n("common.cancel")}),o.jsxs(Q,{onClick:gl,disabled:Ci,children:[Ci?o.jsx(dt,{size:"sm",className:"mr-2"}):Vt?o.jsx(Xn,{className:"w-4 h-4 mr-2"}):o.jsx(qa,{className:"w-4 h-4 mr-2"}),n(Vt?"config.rules.saveChanges":"config.rules.createRule")]})]})]})}),o.jsxs(ot,{children:[o.jsxs(Zn,{children:[o.jsxs(ea,{className:"flex items-center gap-2",children:[o.jsx(fi,{className:"w-5 h-5 text-primary"}),n("config.accounts.title")]}),o.jsx(Ka,{children:n("config.accounts.desc")})]}),o.jsx(ta,{children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold mb-3",children:n("config.accounts.addNew")}),o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx(Q,{className:"w-full border-dashed justify-start h-auto py-4",variant:"outline",onClick:Uu,disabled:r||u,children:o.jsxs("div",{className:"flex items-center gap-3 w-full",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center text-red-600 dark:text-red-400 font-bold shrink-0",children:"G"}),o.jsxs("div",{className:"flex-1 text-left",children:[o.jsx("div",{className:"font-medium",children:"Gmail"}),o.jsx("div",{className:"text-xs text-muted-foreground",children:n("config.gmail.connectDesc")})]}),r?o.jsx(dt,{size:"sm"}):o.jsx(qa,{className:"w-5 h-5 shrink-0"})]})}),o.jsx(Q,{className:"w-full border-dashed justify-start h-auto py-4",variant:"outline",onClick:Pu,disabled:r||u,children:o.jsxs("div",{className:"flex items-center gap-3 w-full",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 font-bold shrink-0",children:"O"}),o.jsxs("div",{className:"flex-1 text-left",children:[o.jsx("div",{className:"font-medium",children:"Outlook"}),o.jsx("div",{className:"text-xs text-muted-foreground",children:n("config.outlook.connectDesc")})]}),u&&!f?o.jsx(dt,{size:"sm"}):o.jsx(qa,{className:"w-5 h-5 shrink-0"})]})})]})]}),f&&o.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg animate-in slide-in-from-top-2",children:[o.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:n("config.outlook.signinRequired")}),o.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-4",children:f.message}),o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center gap-2 bg-white dark:bg-black/20 p-2 rounded border border-blue-200 dark:border-blue-800",children:o.jsx("code",{className:"text-lg font-mono font-bold flex-1 text-center select-all",children:f.userCode})}),o.jsxs(Q,{variant:"default",className:"w-full bg-blue-600 hover:bg-blue-700",onClick:()=>window.open(f.verificationUri,"_blank"),children:["Open Microsoft Login",o.jsx(Bo,{className:"w-4 h-4 ml-2"})]}),o.jsx("p",{className:"text-xs text-center text-muted-foreground mt-2",children:n("config.outlook.waitingSignin")})]})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-semibold mb-3",children:n("config.accounts.yourAccounts")}),t.accounts.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4 border-2 border-dashed rounded-lg",children:[o.jsx(fi,{className:"w-12 h-12 text-muted-foreground/40 mb-3"}),o.jsx("p",{className:"text-sm text-muted-foreground text-center",children:n("config.accounts.noAccounts")}),o.jsx("p",{className:"text-xs text-muted-foreground text-center mt-1",children:n("config.accounts.connectHelp")})]}):o.jsx("div",{className:"space-y-3",children:t.accounts.map(I=>o.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-card hover:bg-secondary/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[Ls(I.provider),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium capitalize",children:I.provider}),o.jsx("p",{className:"text-xs text-muted-foreground",children:I.email_address})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[I.is_active?o.jsx("span",{className:"text-xs text-emerald-600 bg-emerald-500/10 px-2 py-1 rounded-full",children:n("common.active")}):o.jsx("span",{className:"text-xs text-yellow-600 bg-yellow-500/10 px-2 py-1 rounded-full",children:n("common.inactive")}),o.jsx(Q,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",onClick:()=>Mi(I.id),title:n("config.accounts.disconnect"),children:o.jsx(_u,{className:"w-4 h-4"})})]})]},I.id))})]})]})})]}),o.jsxs(ot,{children:[o.jsxs(Zn,{children:[o.jsxs(ea,{className:"flex items-center gap-2",children:[o.jsx(Lt,{className:"w-5 h-5 text-indigo-500"}),n("config.model.title")]}),o.jsx(Ka,{children:n("config.model.desc")})]}),o.jsxs(ta,{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.model.provider")}),cr?o.jsxs("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20",children:[o.jsx(dt,{size:"sm",className:"mr-2"}),o.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Discovering..."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("select",{className:"w-full h-10 px-3 border rounded-md bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary",value:S.llm_provider||ko,onChange:I=>Lu(I.target.value),disabled:cr,children:[o.jsx("option",{value:ko,children:"RealTimeX AI (Default)"}),zu.filter(I=>I.provider!==ko).map(I=>o.jsx("option",{value:I.provider,children:I.name||I.provider},I.provider))]}),Sn&&o.jsxs("div",{className:"text-[10px] text-amber-500 mt-1 px-1 bg-amber-50/50 rounded",children:["⚠️ ",Sn]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.model.name")}),hl.length>0||cr?o.jsxs("select",{className:"w-full h-10 px-3 border rounded-md bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary",value:S.llm_model||"",onChange:I=>_(ne=>({...ne,llm_model:I.target.value})),disabled:cr,children:[!S.llm_model&&o.jsx("option",{value:"",children:n("config.model.selectModel")}),hl.map(I=>o.jsx("option",{value:I.id,children:I.name||I.id},I.id))]}):o.jsx(Ee,{placeholder:"e.g. gpt-4o-mini",value:S.llm_model||"",onChange:I=>_(ne=>({...ne,llm_model:I.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(fi,{className:"w-4 h-4"}),n("config.model.storagePath")]}),o.jsx(Ee,{placeholder:n("config.model.storagePlaceholder"),value:S.storage_path||"",onChange:I=>_(ne=>({...ne,storage_path:I.target.value}))}),o.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:n("config.model.storageHelp")})]}),o.jsxs("div",{className:"flex justify-between items-center py-3 border-t border-border/50",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-sm",children:n("config.model.intelligentRename")}),o.jsx("p",{className:"text-xs text-muted-foreground",children:n("config.model.renameHelp")})]}),o.jsxs(Q,{variant:S.intelligent_rename?"default":"outline",size:"sm",onClick:()=>_(I=>({...I,intelligent_rename:!I.intelligent_rename})),children:[o.jsx(Bb,{className:"w-4 h-4 mr-1"}),S.intelligent_rename?n("common.enabled"):n("common.disabled")]})]}),o.jsxs("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(aa,{className:"w-4 h-4"}),n("config.model.syncInterval")]}),o.jsx(Ee,{type:"number",min:1,max:1440,value:S.sync_interval_minutes||5,onChange:I=>_(ne=>({...ne,sync_interval_minutes:parseInt(I.target.value,10)||5}))}),o.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:n("config.model.syncHelp")})]}),o.jsxs("div",{className:"flex justify-end mt-4 gap-2",children:[o.jsxs(Q,{variant:"outline",onClick:ur,disabled:v,children:[v?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Lt,{className:"w-4 h-4 mr-2"}),n("config.model.checkConnection")]}),o.jsxs(Q,{onClick:dr,disabled:m,children:[m?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Xn,{className:"w-4 h-4 mr-2"}),n("config.model.saveConfig")]})]})]})]}),o.jsx("div",{ref:ha,children:o.jsxs(ot,{children:[o.jsxs(Zn,{children:[o.jsxs(ea,{className:"flex items-center gap-2",children:[o.jsx($b,{className:"w-5 h-5 text-orange-500"}),n("config.byok.title")]}),o.jsxs(Ka,{children:[n("config.byok.desc"),n("config.byok.systemDefault")]})]}),o.jsxs(ta,{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-4 border-b pb-4",children:[o.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Google / Gmail"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client ID"}),o.jsx(Ee,{type:"password",placeholder:"...apps.googleusercontent.com",value:S.google_client_id||"",onChange:I=>_(ne=>({...ne,google_client_id:I.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client Secret"}),o.jsx(Ee,{type:"password",placeholder:"GOCSPX-...",value:S.google_client_secret||"",onChange:I=>_(ne=>({...ne,google_client_secret:I.target.value}))})]})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"})," Microsoft / Outlook"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client ID"}),o.jsx(Ee,{type:"password",value:S.microsoft_client_id||"",onChange:I=>_(ne=>({...ne,microsoft_client_id:I.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client Secret (Optional)"}),o.jsx(Ee,{type:"password",value:S.microsoft_client_secret||"",onChange:I=>_(ne=>({...ne,microsoft_client_secret:I.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Tenant ID"}),o.jsx(Ee,{placeholder:"common",value:S.microsoft_tenant_id||"",onChange:I=>_(ne=>({...ne,microsoft_tenant_id:I.target.value}))})]})]})]}),o.jsx("div",{className:"flex justify-end mt-4",children:o.jsxs(Q,{onClick:dr,disabled:m,variant:"secondary",children:[m?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Xn,{className:"w-4 h-4 mr-2"}),n("config.byok.save")]})})]})]})})]})}function M3(){const{t}=Xe(),[e,n]=w.useState("profile"),{state:r,actions:l}=oa();w.useEffect(()=>{l.fetchProfile()},[]);const u=[{id:"profile",label:t("account.profile"),icon:Om},{id:"security",label:t("account.security"),icon:Rm},{id:"database",label:t("account.database"),icon:fi}];return o.jsxs("div",{className:"max-w-4xl mx-auto space-y-6 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:t("account.title")}),o.jsx("p",{className:"text-muted-foreground",children:t("account.subtitle")})]}),o.jsxs("div",{className:"flex flex-col md:flex-row gap-8",children:[o.jsxs("aside",{className:"w-full md:w-64 flex flex-col justify-between",children:[o.jsx("nav",{className:"space-y-1",children:u.map(d=>{const f=d.icon,p=e===d.id;return o.jsxs("button",{onClick:()=>n(d.id),className:`w-full flex items-center gap-3 px-4 py-2 text-sm font-medium rounded-lg transition-colors ${p?"bg-primary text-primary-foreground":"hover:bg-secondary text-muted-foreground"}`,children:[o.jsx(f,{className:"w-4 h-4"}),d.label]},d.id)})}),o.jsxs("div",{className:"mt-auto space-y-1",children:[o.jsxs("button",{onClick:async()=>{await Qe.auth.signOut(),se.success(t("account.logoutSuccess")),window.location.reload()},className:"w-full flex items-center gap-3 px-4 py-2 text-sm font-medium rounded-lg transition-colors hover:bg-destructive/10 text-destructive",children:[o.jsx(CE,{className:"w-4 h-4"}),t("account.logout")]}),o.jsxs("div",{className:"px-4 py-4 border-t border-border/40 text-center md:text-left",children:[o.jsx("p",{className:"text-[10px] font-bold text-muted-foreground/50 uppercase tracking-widest mb-1",children:t("account.version")}),o.jsxs("p",{className:"text-xs font-mono text-muted-foreground/70",children:["v","2.20.0"]})]})]})]}),o.jsxs("div",{className:"flex-1 space-y-6",children:[e==="profile"&&o.jsx(z3,{}),e==="security"&&o.jsx(L3,{}),e==="database"&&o.jsx(U3,{})]})]})]})}function z3(){const{t}=Xe(),{state:e,actions:n}=oa(),[r,l]=w.useState(""),[u,d]=w.useState(""),[f,p]=w.useState(!1),[m,y]=w.useState(!1),[v,b]=w.useState(qs.isEnabled());w.useEffect(()=>{e.profile&&(l(e.profile.first_name||""),d(e.profile.last_name||""))},[e.profile]);const S=()=>{const E=!v;qs.setEnabled(E),b(E),E?(qs.playSuccess(),se.success(t("account.profile.soundsEnabled"))):se.info(t("account.profile.soundsDisabled"))},_=async()=>{p(!0);const E=await n.updateProfile({first_name:r,last_name:u});p(!1),E&&se.success(t("account.profile.updated"))},N=async E=>{const T=E.target.files?.[0];if(!(!T||!e.user)){y(!0);try{const D=T.name.split(".").pop(),A=`${e.user.id}/avatar.${D}`,{data:U,error:H}=await Qe.storage.from("avatars").upload(A,T,{upsert:!0});if(H)throw H;const{data:{publicUrl:G}}=Qe.storage.from("avatars").getPublicUrl(A);await n.updateProfile({avatar_url:G}),se.success(t("account.profile.avatarUpdated"))}catch(D){console.error("Avatar upload error:",D),se.error(t("account.profile.avatarError"))}finally{y(!1)}}};return o.jsxs(ot,{children:[o.jsxs(Zn,{children:[o.jsx(ea,{children:t("account.profile.title")}),o.jsx(Ka,{children:t("account.profile.desc")})]}),o.jsxs(ta,{className:"space-y-6",children:[o.jsxs("div",{className:"flex flex-col items-center sm:flex-row sm:items-start gap-6",children:[o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-24 h-24 rounded-full bg-secondary overflow-hidden border-2 border-border flex items-center justify-center",children:e.profile?.avatar_url?o.jsx("img",{src:e.profile.avatar_url,alt:"Avatar",className:"w-full h-full object-cover"}):o.jsx(Om,{className:"w-12 h-12 text-muted-foreground"})}),o.jsxs("label",{className:"absolute inset-0 flex items-center justify-center bg-black/40 rounded-full opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity",children:[o.jsx(IN,{className:"w-6 h-6 text-white"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:N,disabled:m})]}),m&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/60 rounded-full",children:o.jsx(dt,{size:"sm"})})]}),o.jsxs("div",{className:"flex-1 space-y-4 w-full",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{htmlFor:"first-name",children:t("account.profile.firstName")}),o.jsx(Ee,{id:"first-name",value:r,onChange:E=>l(E.target.value),placeholder:t("account.profile.firstNamePlaceholder")})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{htmlFor:"last-name",children:t("account.profile.lastName")}),o.jsx(Ee,{id:"last-name",value:u,onChange:E=>d(E.target.value),placeholder:t("account.profile.lastNamePlaceholder")})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{htmlFor:"email",children:t("account.profile.email")}),o.jsx(Ee,{id:"email",value:e.profile?.email||"",disabled:!0,className:"bg-secondary/50"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:t("account.profile.emailHelp")})]})]})]}),o.jsxs("div",{className:"pt-6 border-t flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("label",{className:"text-sm font-medium",children:t("account.profile.sounds")}),o.jsx("p",{className:"text-xs text-muted-foreground",children:t("account.profile.soundsHelp")})]}),o.jsxs(Q,{variant:v?"default":"outline",size:"sm",onClick:S,className:"gap-2",children:[v?o.jsx(yT,{className:"w-4 h-4"}):o.jsx(xT,{className:"w-4 h-4"}),t(v?"common.enabled":"common.disabled")]})]}),o.jsx("div",{className:"flex justify-end pt-4 border-t",children:o.jsxs(Q,{onClick:_,disabled:f,children:[f?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(FE,{className:"w-4 h-4 mr-2"}),t("common.saveChanges")]})})]})]})}function L3(){const{t}=Xe(),[e,n]=w.useState(""),[r,l]=w.useState(""),[u,d]=w.useState(!1),f=async()=>{if(!e){se.error(t("account.security.enterPassword"));return}if(e!==r){se.error(t("account.security.passwordsMismatch"));return}if(e.length<6){se.error(t("account.security.passwordTooShort"));return}d(!0);try{const{api:p}=await Va(async()=>{const{api:y}=await Promise.resolve().then(()=>rC);return{api:y}},void 0),m=await p.changePassword(e);m.success?(se.success(t("account.security.passwordChanged")),n(""),l("")):se.error(m.error?.message||"Failed to change password")}catch{se.error(t("common.errorOccurred"))}finally{d(!1)}};return o.jsxs(ot,{children:[o.jsxs(Zn,{children:[o.jsx(ea,{children:t("account.security.title")}),o.jsx(Ka,{children:t("account.security.desc")})]}),o.jsxs(ta,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{htmlFor:"new-password",children:t("account.security.newPassword")}),o.jsx(Ee,{id:"new-password",type:"password",value:e,onChange:p=>n(p.target.value),placeholder:"••••••••"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ht,{htmlFor:"confirm-password",children:t("account.security.confirmPassword")}),o.jsx(Ee,{id:"confirm-password",type:"password",value:r,onChange:p=>l(p.target.value),placeholder:"••••••••"})]}),o.jsx("div",{className:"flex justify-end pt-4 border-t",children:o.jsxs(Q,{onClick:f,disabled:u,children:[u?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(Cm,{className:"w-4 h-4 mr-2"}),t("account.security.updatePassword")]})})]})]})}function U3(){const{t}=Xe(),[e,n]=w.useState(!1),[r,l]=w.useState(null),u=ji(),d=sC();w.useEffect(()=>{u&&vp(Qe).then(l)},[]);const f=()=>{confirm(t("account.database.clearConfirm"))&&(eC(),window.location.reload())};return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{children:[o.jsxs(Zn,{children:[o.jsxs(ea,{className:"flex items-center gap-2",children:[o.jsx(fi,{className:"w-5 h-5 text-primary"}),t("account.database.title")]}),o.jsx(Ka,{children:t("account.database.desc")})]}),o.jsx(ta,{className:"space-y-6",children:u?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-xl bg-emerald-500/5 border-emerald-500/20",children:[o.jsx(ru,{className:"w-6 h-6 text-emerald-500 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"font-semibold text-emerald-700 dark:text-emerald-400",children:t("account.database.connected")}),r?.latestMigrationTimestamp&&o.jsxs("span",{className:"text-[10px] font-mono bg-emerald-500/10 text-emerald-600 px-1.5 py-0.5 rounded border border-emerald-500/20",title:"Database Schema Version",children:["Schema ",r.latestMigrationTimestamp]})]}),o.jsx("p",{className:"text-sm font-mono break-all opacity-80",children:u.url})]})]}),d==="env"&&o.jsxs(er,{className:"bg-amber-500/5 border-amber-500/20",children:[o.jsx(Io,{className:"h-4 w-4 text-amber-500"}),o.jsx(tr,{className:"text-amber-700 dark:text-amber-400 text-xs",children:t("account.database.envAlert")})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o.jsxs(Q,{variant:"outline",onClick:()=>n(!0),className:"w-full",children:[o.jsx(Io,{className:"w-4 h-4 mr-2"}),t("account.database.changeConnection")]}),d==="ui"&&o.jsxs(Q,{variant:"outline",onClick:f,className:"w-full text-destructive hover:bg-destructive/10",children:[o.jsx(_u,{className:"w-4 h-4 mr-2"}),t("account.database.clearConfig")]})]}),o.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[o.jsx(Ht,{className:"text-xs uppercase tracking-wider text-muted-foreground",children:t("account.database.anonKey")}),o.jsxs("div",{className:"p-2 bg-secondary/50 rounded-lg font-mono text-xs break-all",children:[u.anonKey.substring(0,20),"...",u.anonKey.substring(u.anonKey.length-10)]})]})]}):o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center space-y-4",children:[o.jsx(sE,{className:"w-12 h-12 text-destructive opacity-20"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:t("account.database.noConnection")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:t("account.database.configureHelp")})]}),o.jsxs(Q,{onClick:()=>n(!0),children:[o.jsx(fi,{className:"w-4 h-4 mr-2"}),t("account.database.setup")]})]})})]}),o.jsx(SS,{open:e,onComplete:()=>n(!1),canClose:!0})]})}function Ob({rules:t,onToggleRule:e,onEditRule:n,onDeleteRule:r}){const{t:l}=Xe(),u={email_organization:{label:l("autopilot.category.email_organization.label"),icon:Gs,emoji:"📧",description:l("autopilot.category.email_organization.desc")},priority_alerts:{label:l("autopilot.category.priority_alerts.label"),icon:Ms,emoji:"🚨",description:l("autopilot.category.priority_alerts.desc")},development:{label:l("autopilot.category.development.label"),icon:yn,emoji:"💻",description:l("autopilot.category.development.desc")},sales_business:{label:l("autopilot.category.sales_business.label"),icon:PN,emoji:"💼",description:l("autopilot.category.sales_business.desc")},operations:{label:l("autopilot.category.operations.label"),icon:Io,emoji:"⚙️",description:l("autopilot.category.operations.desc")}},d=t.reduce((m,y)=>{const v=y.category||"email_organization";return m[v]||(m[v]=[]),m[v].push(y),m},{}),f=m=>{const y=m.filter(b=>b.is_enabled).length,v=m.length;return{enabled:y,total:v}},p=m=>!m||m.length===0?"":m.map(y=>y.startsWith("label:")?`label:${y.substring(6)}`:y).join(" + ");return o.jsx("div",{className:"space-y-8",children:Object.entries(u).map(([m,y])=>{const v=d[m]||[];if(v.length===0)return null;const b=f(v);return o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-secondary/50 flex items-center justify-center",children:o.jsx("span",{className:"text-xl",children:y.emoji})}),o.jsxs("div",{children:[o.jsxs("h3",{className:"font-semibold text-base flex items-center gap-2",children:[y.label,o.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:l("autopilot.enabledCount").replace("{enabled}",b.enabled.toString()).replace("{total}",b.total.toString())})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:y.description})]})]})}),o.jsx("div",{className:"space-y-1",children:v.map(S=>o.jsxs("div",{className:"flex items-center justify-between py-3 px-4 rounded-lg hover:bg-secondary/30 transition-colors",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h4",{className:"font-medium text-sm truncate",children:S.name}),S.is_system_managed&&o.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 shrink-0",children:l("autopilot.badge")})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[S.intent&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:S.intent}),S.actions&&S.actions.length>0&&o.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:["→ ",p(S.actions)]})]})]}),o.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[o.jsx(Q,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>n(S.id),title:l("autopilot.editRuleTooltip"),children:o.jsx(PE,{className:"w-4 h-4 text-muted-foreground"})}),o.jsxs(Q,{variant:S.is_enabled?"default":"outline",size:"sm",onClick:()=>e(S.id,!S.is_enabled),className:"h-8 px-3",children:[o.jsx(Bb,{className:"w-4 h-4 mr-1"}),S.is_enabled?l("common.on"):l("common.off")]}),!S.is_system_managed&&r&&o.jsx(Q,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",onClick:()=>r(S.id),title:l("autopilot.deleteRuleTooltip"),children:o.jsx(_u,{className:"w-4 h-4"})})]})]},S.id))})]},m)})})}function P3({open:t,rule:e,onClose:n,onSave:r,onFileUpload:l,onRemoveAttachment:u}){const{t:d}=Xe(),[f,p]=w.useState(!1),[m,y]=w.useState(!1),[v,b]=w.useState(""),[S,_]=w.useState(""),[N,E]=w.useState(""),[T,D]=w.useState("category"),[A,U]=w.useState("newsletter"),[H,G]=w.useState(""),[z,M]=w.useState(["archive"]),[J,ie]=w.useState(""),[be,de]=w.useState([]);w.useEffect(()=>{if(e){b(e.name||""),_(e.description||""),E(e.intent||""),M(e.actions||["archive"]),ie(e.instructions||""),de(e.attachments||[]);const C=e.condition||{},q=Object.keys(C).filter(B=>B!=="older_than_days");q.length>0&&(D(q[0]),U(C[q[0]])),C.older_than_days&&G(String(C.older_than_days))}else b(""),_(""),E(""),D("category"),U("newsletter"),G(""),M(["archive"]),ie(""),de([])},[e,t]);const Ve=async()=>{if(v.trim()&&z.length!==0){p(!0);try{const C={[T]:A};H&&(C.older_than_days=parseInt(H,10));const q=z.includes("draft"),B={name:v.trim(),description:S.trim()||void 0,intent:N.trim()||void 0,condition:C,actions:z,instructions:q?J:void 0,attachments:q?be:[],is_enabled:!0};await r(B)&&n()}finally{p(!1)}}},Ie=async C=>{if(!l)return;const q=C.target.files;if(!(!q||q.length===0)){y(!0);try{const B=await l(q[0]);B&&de(re=>[...re,B])}finally{y(!1),C.target.value=""}}},ee=C=>{de(q=>q.filter(B=>B.path!==C)),u&&u(C)};return o.jsx(Xa,{open:t,onOpenChange:C=>!C&&n(),children:o.jsxs(Wa,{className:"sm:max-w-xl max-h-[90vh] flex flex-col p-0",children:[o.jsxs(Ja,{className:"p-6 border-b",children:[o.jsx(Qa,{children:d(e?"autopilot.editDialog.editTitle":"autopilot.editDialog.createTitle")}),o.jsx(Za,{children:d("autopilot.editDialog.desc")})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.ruleName")}),o.jsx(Ee,{placeholder:d("autopilot.editDialog.namePlaceholder"),value:v,onChange:C=>b(C.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.description")}),o.jsx("textarea",{className:"w-full p-2 border rounded-md bg-background min-h-[60px] text-sm",placeholder:d("autopilot.editDialog.descPlaceholder"),value:S,onChange:C=>_(C.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("autopilot.editDialog.descriptionHelp")})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.intent")}),o.jsx(Ee,{placeholder:d("autopilot.editDialog.intentPlaceholder"),value:N,onChange:C=>E(C.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("autopilot.editDialog.intentHelp")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.conditionField")}),o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:T,onChange:C=>{D(C.target.value),C.target.value==="category"?U("newsletter"):C.target.value==="sentiment"?U("Positive"):C.target.value==="priority"?U("High"):U("")},children:[o.jsxs("optgroup",{label:d("autopilot.editDialog.aiAnalysisGroup"),children:[o.jsx("option",{value:"category",children:d("autopilot.editDialog.category")}),o.jsx("option",{value:"sentiment",children:d("autopilot.editDialog.sentiment")}),o.jsx("option",{value:"priority",children:d("autopilot.editDialog.priority")})]}),o.jsxs("optgroup",{label:d("autopilot.editDialog.metadataGroup"),children:[o.jsx("option",{value:"sender_email",children:d("autopilot.editDialog.senderEmail")}),o.jsx("option",{value:"sender_domain",children:d("autopilot.editDialog.senderDomain")}),o.jsx("option",{value:"sender_contains",children:d("autopilot.editDialog.senderContains")}),o.jsx("option",{value:"subject_contains",children:d("autopilot.editDialog.subjectContains")}),o.jsx("option",{value:"body_contains",children:d("autopilot.editDialog.bodyContains")})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.equalsValue")}),T==="category"?o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:A,onChange:C=>U(C.target.value),children:[o.jsx("option",{value:"newsletter",children:d("autopilot.editDialog.cat.newsletter")}),o.jsx("option",{value:"spam",children:d("autopilot.editDialog.cat.spam")}),o.jsx("option",{value:"promotional",children:d("autopilot.editDialog.cat.promotional")}),o.jsx("option",{value:"transactional",children:d("autopilot.editDialog.cat.transactional")}),o.jsx("option",{value:"social",children:d("autopilot.editDialog.cat.social")}),o.jsx("option",{value:"support",children:d("autopilot.editDialog.cat.support")}),o.jsx("option",{value:"client",children:d("autopilot.editDialog.cat.client")}),o.jsx("option",{value:"internal",children:d("autopilot.editDialog.cat.internal")}),o.jsx("option",{value:"personal",children:d("autopilot.editDialog.cat.personal")}),o.jsx("option",{value:"other",children:d("autopilot.editDialog.cat.other")})]}):T==="sentiment"?o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:A,onChange:C=>U(C.target.value),children:[o.jsx("option",{value:"Positive",children:d("autopilot.editDialog.sent.positive")}),o.jsx("option",{value:"Neutral",children:d("autopilot.editDialog.sent.neutral")}),o.jsx("option",{value:"Negative",children:d("autopilot.editDialog.sent.negative")})]}):T==="priority"?o.jsxs("select",{className:"w-full p-2 border rounded-md bg-background text-sm",value:A,onChange:C=>U(C.target.value),children:[o.jsx("option",{value:"High",children:d("autopilot.editDialog.prio.high")}),o.jsx("option",{value:"Medium",children:d("autopilot.editDialog.prio.medium")}),o.jsx("option",{value:"Low",children:d("autopilot.editDialog.prio.low")})]}):o.jsx(Ee,{placeholder:T==="sender_domain"?"rta.vn":T==="sender_email"?"john@example.com":d("autopilot.editDialog.keywordsPlaceholder"),value:A,onChange:C=>U(C.target.value)})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(aa,{className:"w-4 h-4"}),d("autopilot.editDialog.olderThan")]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ee,{type:"number",min:"0",placeholder:"0",className:"w-24",value:H,onChange:C=>G(C.target.value)}),o.jsx("span",{className:"text-sm text-muted-foreground",children:d("autopilot.editDialog.days")})]}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("autopilot.editDialog.olderThanHelp")})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.performActions")}),o.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:d("autopilot.editDialog.actionsDesc")}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"archive",label:d("autopilot.editDialog.action.archive")},{value:"delete",label:d("autopilot.editDialog.action.delete")},{value:"draft",label:d("autopilot.editDialog.action.draft")},{value:"star",label:d("autopilot.editDialog.action.star")}].map(C=>o.jsxs("label",{className:`flex items-center gap-2 p-2 border rounded-md cursor-pointer transition-colors ${z.includes(C.value)?"bg-primary/10 border-primary":"bg-background hover:bg-secondary/50"}`,children:[o.jsx("input",{type:"checkbox",checked:z.includes(C.value),onChange:q=>{q.target.checked?M([...z,C.value]):M(z.filter(B=>B!==C.value))},className:"rounded border-gray-300"}),o.jsx("span",{className:"text-sm",children:C.label})]},C.value))})]}),z.includes("draft")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-2 animate-in slide-in-from-top-2 duration-200",children:[o.jsx("label",{className:"text-sm font-medium",children:d("autopilot.editDialog.draftInstructions")}),o.jsx("textarea",{className:"w-full p-2 border rounded-md bg-background min-h-[80px] text-sm",placeholder:d("autopilot.editDialog.draftInstPlaceholder"),value:J,onChange:C=>ie(C.target.value)}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("autopilot.editDialog.draftInstHelp")})]}),l&&o.jsxs("div",{className:"space-y-2 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("label",{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(Vb,{className:"w-4 h-4"}),d("autopilot.editDialog.attachments")]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[be.map(C=>o.jsxs("div",{className:"flex items-center justify-between p-2 bg-secondary/50 rounded border text-xs",children:[o.jsx("span",{className:"truncate max-w-[200px]",children:C.name}),o.jsx(Q,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive",onClick:()=>ee(C.path),children:o.jsx(_s,{className:"w-3 h-3"})})]},C.path)),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"file",className:"absolute inset-0 opacity-0 cursor-pointer",onChange:Ie,disabled:m}),o.jsxs(Q,{variant:"outline",size:"sm",className:"w-full border-dashed",disabled:m,children:[m?o.jsx(dt,{size:"sm",className:"mr-2"}):o.jsx(qa,{className:"w-3 h-3 mr-2"}),d(m?"autopilot.editDialog.uploading":"autopilot.editDialog.addAttachment")]})]})]}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:d("autopilot.editDialog.attachmentsHelp")})]})]})]}),o.jsxs($a,{className:"p-6 border-t bg-secondary/5",children:[o.jsx(Q,{variant:"outline",onClick:n,children:d("common.cancel")}),o.jsxs(Q,{onClick:Ve,disabled:f||!v.trim()||z.length===0,children:[f?o.jsx(dt,{size:"sm",className:"mr-2"}):e?o.jsx(Xn,{className:"w-4 h-4 mr-2"}):o.jsx(qa,{className:"w-4 h-4 mr-2"}),d(e?"common.saveChanges":"autopilot.addCustomRule")]})]})]})})}function V3(){const{state:t,actions:e}=oa(),{t:n}=Xe(),[r,l]=w.useState([]),[u,d]=w.useState(!0),[f,p]=w.useState(null),[m,y]=w.useState(!1),[v,b]=w.useState(null),S=async()=>{d(!0),p(null);try{const M=await Oe.getRules();if(M.error)throw new Error(typeof M.error=="string"?M.error:M.error.message);l(M.data?.rules||[])}catch(M){p(M instanceof Error?M.message:n("autopilot.loadError")),console.error("Error fetching rules:",M)}finally{d(!1)}};w.useEffect(()=>{S()},[]);const _=async(M,J)=>{try{const ie=await Oe.updateRule(M,{is_enabled:J});if(ie.error)throw new Error(typeof ie.error=="string"?ie.error:ie.error.message);l(be=>be.map(de=>de.id===M?{...de,is_enabled:J}:de))}catch(ie){console.error("Error toggling rule:",ie),await S()}},N=M=>{const J=r.find(ie=>ie.id===M);J&&(b(J),y(!0))},E=async M=>{if(confirm(n("autopilot.deleteConfirm")))try{await e.deleteRule(M)?(se.success(n("autopilot.ruleDeleted")),l(ie=>ie.filter(be=>be.id!==M))):se.error(n("autopilot.ruleDeleteFailed"))}catch(J){console.error("Error deleting rule:",J),se.error(n("autopilot.ruleDeleteError"))}},T=()=>{b(null),y(!0)},D=async M=>{try{let J=!1;return v?J=await e.updateRule(v.id,M):J=await e.createRule(M),J?(se.success(n(v?"autopilot.ruleUpdated":"autopilot.ruleCreated")),await S(),!0):(se.error(n(v?"autopilot.ruleUpdateFailed":"autopilot.ruleCreateFailed")),!1)}catch(J){return console.error("Error saving rule:",J),se.error(n("autopilot.ruleSaveError")),!1}},A=async M=>{try{const J=M.name.split(".").pop(),ie=`${Math.random().toString(36).substring(2)}.${J}`,be=`${t.user.id}/${ie}`,{error:de}=await Qe.storage.from("rule-attachments").upload(be,M);if(de)throw de;return se.success(n("autopilot.fileUploaded")),{name:M.name,path:be,type:M.type,size:M.size}}catch(J){return console.error("Upload error:",J),se.error(n("autopilot.fileUploadFailed")),null}},U=()=>{y(!1),b(null)};if(u)return o.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:o.jsxs("div",{className:"flex flex-col items-center gap-4",children:[o.jsx(Lt,{className:"w-8 h-8 animate-spin text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("autopilot.loadingRules")})]})});if(f)return o.jsxs(er,{variant:"destructive",children:[o.jsx(Ms,{className:"h-4 w-4"}),o.jsxs(tr,{children:[f,o.jsxs(Q,{variant:"outline",size:"sm",onClick:S,className:"ml-4",children:[o.jsx(Lt,{className:"w-4 h-4 mr-2"}),n("autopilot.refresh")]})]})]});const H=r.filter(M=>M.is_system_managed),G=r.filter(M=>!M.is_system_managed),z=H.filter(M=>M.is_enabled).length;return r.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:[o.jsx(Jc,{className:"w-16 h-16 text-gray-300 dark:text-gray-700 mb-4"}),o.jsx("h3",{className:"text-lg font-semibold mb-2",children:n("autopilot.noRulesTitle")}),o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 text-center max-w-md mb-4",children:n("autopilot.noRulesDesc")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-8",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-2",children:[o.jsx(Jc,{className:"w-6 h-6 text-blue-500"}),n("autopilot.title")]}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n("autopilot.rulesEnabled").replace("{enabled}",z.toString()).replace("{total}",H.length.toString())})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Q,{variant:"default",size:"sm",onClick:T,children:[o.jsx(qa,{className:"w-4 h-4 mr-2"}),n("autopilot.addCustomRule")]}),o.jsxs(Q,{variant:"outline",size:"sm",onClick:S,disabled:u,children:[o.jsx(Lt,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`}),n("autopilot.refresh")]})]})]}),H.length>0&&o.jsxs(er,{children:[o.jsx(Jc,{className:"h-4 w-4"}),o.jsx(tr,{children:n("autopilot.infoDesc")})]}),H.length>0&&o.jsx(Ob,{rules:H,onToggleRule:_,onEditRule:N,onDeleteRule:E}),G.length>0&&o.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold",children:n("autopilot.customRules")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:n("autopilot.customRulesDesc")})]}),o.jsx(Ob,{rules:G,onToggleRule:_,onEditRule:N,onDeleteRule:E})]})]}),o.jsx(P3,{open:m,rule:v,onClose:U,onSave:D,onFileUpload:A})]})}function B3({length:t=6,value:e,onChange:n,onComplete:r,disabled:l=!1,error:u=!1}){const d=w.useRef([]),[f,p]=w.useState(null),m=(b,S)=>{const _=S.replace(/[^0-9]/g,"");if(_.length===0){const T=e.split("");T[b]=" ",e.split("");let D=e.split("");b<D.length&&D.splice(b,1);const A=D.join("");n(A),b>0&&d.current[b-1]?.focus();return}e.split("");const N=[...e];N[b]=_[0],n(N.join("")),b<t-1&&d.current[b+1]?.focus();const E=N.join("");E.length===t&&r&&r(E)},y=(b,S)=>{S.key==="Backspace"&&!e[b]&&b>0||S.key==="ArrowLeft"&&b>0?d.current[b-1]?.focus():S.key==="ArrowRight"&&b<t-1&&d.current[b+1]?.focus()},v=b=>{b.preventDefault();const _=b.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);n(_);const N=Math.min(_.length,t-1);d.current[N]?.focus(),_.length===t&&r&&r(_)};return o.jsx("div",{className:"flex gap-2 justify-center",children:Array.from({length:t}).map((b,S)=>o.jsx(Ee,{ref:_=>{d.current[S]=_},type:"text",inputMode:"numeric",maxLength:1,value:e[S]||"",onChange:_=>m(S,_.target.value),onKeyDown:_=>y(S,_),onPaste:v,onFocus:()=>p(S),onBlur:()=>p(null),disabled:l,className:Se("w-10 h-10 sm:w-12 sm:h-12 text-center text-lg font-semibold px-0",u&&"border-destructive focus-visible:ring-destructive",f===S&&"ring-2 ring-ring"),"aria-label":`Digit ${S+1}`},S))})}function I3({onSuccess:t,onConfigure:e,isInitialized:n}){const{t:r}=Xe(),[l,u]=w.useState(""),[d,f]=w.useState(""),[p,m]=w.useState(""),[y,v]=w.useState(""),[b,S]=w.useState(!1),[_,N]=w.useState(n===void 0),[E,T]=w.useState(n??!1),[D,A]=w.useState(""),[U,H]=w.useState(!1),[G,z]=w.useState("password"),[M,J]=w.useState("email"),[ie,be]=w.useState(""),[de,Ve]=w.useState(!1);w.useEffect(()=>{n===void 0?Ie():Ve(!n)},[n]);const Ie=async()=>{try{const{data:q,error:B}=await Qe.from("init_state").select("is_initialized");if(B){if(B.code==="42P01"){console.info("[Login] init_state relation missing - fresh database detected."),T(!1),Ve(!0);return}console.warn("[Login] Init check error:",B),T(!1),Ve(!0),A(B.message);return}const re=q&&q.length>0&&q[0].is_initialized>0;T(re),Ve(!re)}catch(q){console.warn("[Login] Init check exception:",q),T(!1),Ve(!0),A(q.message||"Connection failed")}finally{N(!1)}},ee=async q=>{q.preventDefault(),S(!0),A("");try{if(E){if(G==="password"){const{error:B}=await Qe.auth.signInWithPassword({email:l,password:d});if(B)throw B;se.success("Logged in successfully"),t?.()}else if(M==="email"){const{error:B}=await Qe.auth.signInWithOtp({email:l,options:{shouldCreateUser:!1}});if(B)throw B;J("verify"),se.success("Validation code sent to your email")}}else{const{data:B,error:re}=await Qe.functions.invoke("setup",{body:{email:l,password:d,first_name:p,last_name:y}});if(re||!B){if(re?.message?.includes("First user already exists")){se.info("System already initialized. Please log in."),T(!0);return}throw new Error(re?.message||"Failed to create admin account")}se.success("Admin account created! Signing you in...");const{error:pe}=await Qe.auth.signInWithPassword({email:l,password:d});if(pe)throw pe;T(!0),t?.()}}catch(B){A(B?.message||"Authentication failed"),console.error("[Login] Error:",B)}finally{S(!1)}},C=async()=>{S(!0),A("");try{const{data:q,error:B}=await Qe.auth.verifyOtp({email:l,token:ie,type:"magiclink"});if(B)throw B;if(!q.session)throw new Error("Failed to create session");se.success("Logged in successfully"),t?.()}catch(q){A(q?.message||"Invalid code")}finally{S(!1)}};return _?o.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-4",children:[o.jsx(_t,{className:"w-10 h-10 animate-spin text-primary"}),o.jsx("p",{className:"text-xs font-mono uppercase tracking-widest text-muted-foreground",children:"Initializing Engine..."})]})}):o.jsxs("div",{className:"min-h-screen bg-background flex items-center justify-center p-8 relative overflow-hidden",children:[o.jsxs("div",{className:"absolute top-6 right-6 flex items-center gap-4 z-50",children:[e&&o.jsxs(Q,{variant:"ghost",size:"sm",onClick:e,className:"text-xs font-bold uppercase tracking-widest text-muted-foreground hover:text-primary transition-all",children:[o.jsx(Io,{className:"w-3.5 h-3.5 mr-2"}),"Configure"]}),o.jsx(ow,{}),o.jsx(yp,{})]}),o.jsxs(gn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"w-full max-w-md relative z-10",children:[o.jsxs("div",{className:"glass p-10 space-y-8 relative overflow-hidden",children:[o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"mx-auto w-16 h-16 bg-primary rounded-2xl flex items-center justify-center mb-6",children:o.jsx(xp,{className:"w-10 h-10 text-primary-foreground"})}),o.jsx("h2",{className:"text-3xl font-black italic tracking-tighter uppercase text-foreground",children:r(de?"login.initialize":"login.secureLogin")}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-bold tracking-[0.2em] uppercase",children:de?"Create your primary administrator account":G==="otp"?"Magic link authentication":"Personal Access Key Required"})]}),o.jsxs("form",{onSubmit:ee,className:"space-y-4",children:[o.jsxs(tS,{mode:"wait",children:[de&&o.jsxs(gn.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-[10px] font-bold uppercase text-muted-foreground ml-1",children:"First Name"}),o.jsx(Ee,{value:p,onChange:q=>m(q.target.value),required:de,placeholder:r("login.firstNamePlaceholder"),className:"bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-[10px] font-bold uppercase text-muted-foreground ml-1",children:"Last Name"}),o.jsx(Ee,{value:y,onChange:q=>v(q.target.value),required:de,placeholder:r("login.lastNamePlaceholder"),className:"bg-background"})]})]},"signup-fields"),G==="password"||M==="email"?o.jsxs(gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-1",children:[o.jsx("label",{className:"text-[10px] font-bold uppercase text-muted-foreground ml-1",children:"Email Coordinates"}),o.jsxs("div",{className:"relative",children:[o.jsx(Gs,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground/30",size:16}),o.jsx(Ee,{type:"email",placeholder:r("login.emailPlaceholder"),value:l,onChange:q=>u(q.target.value),required:!0,className:"pl-10 bg-background",autoComplete:"email",disabled:M==="verify"})]})]},"email-field"):null,G==="password"&&o.jsxs(gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-1",children:[o.jsx("label",{className:"text-[10px] font-bold uppercase text-muted-foreground ml-1",children:"Access Password"}),o.jsxs("div",{className:"relative",children:[o.jsx(_0,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground/30",size:16}),o.jsx(Ee,{type:U?"text":"password",placeholder:"••••••••",value:d,onChange:q=>f(q.target.value),required:!0,minLength:6,className:"pl-10 pr-10 bg-background",autoComplete:de?"new-password":"current-password"}),o.jsx("button",{type:"button",onClick:()=>H(!U),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground/30 hover:text-primary transition-colors",children:U?o.jsx(cE,{size:16}):o.jsx(km,{size:16})})]})]},"password-field"),G==="otp"&&M==="verify"&&o.jsxs(gn.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"space-y-6 py-4",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(B3,{value:ie,onChange:be,length:6,onComplete:()=>{}})}),o.jsx(Q,{type:"button",variant:"link",className:"w-full text-[10px] font-bold uppercase tracking-widest text-primary/60",onClick:()=>J("email"),children:"Change Coordinates"}),o.jsxs(Q,{type:"button",onClick:C,disabled:b||ie.length!==6,className:"w-full h-12 shadow-md",children:[b?o.jsx(_t,{className:"w-5 h-5 animate-spin mr-2"}):o.jsx(Rm,{size:18,className:"mr-2"}),"Verify Access"]})]},"otp-field")]}),D&&o.jsxs(gn.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"bg-destructive/10 text-destructive text-[11px] font-bold p-3 rounded-xl border border-destructive/20 flex items-start gap-2",children:[o.jsx(Ms,{size:14,className:"mt-0.5 shrink-0"}),o.jsx("p",{children:D})]}),G!=="otp"||M==="email"?o.jsx(Q,{type:"submit",disabled:b||!l||G==="password"&&!d,className:"w-full h-12 shadow-md mt-4",children:b?o.jsx(_t,{className:"w-5 h-5 animate-spin"}):o.jsxs(o.Fragment,{children:[de?o.jsx(mT,{className:"w-5 h-5 mr-2"}):G==="otp"?o.jsx(Gs,{className:"w-5 h-5 mr-2"}):o.jsx(AE,{className:"w-5 h-5 mr-2"}),r(de?"login.initializeMaster":G==="otp"?"login.sendMagicLink":"login.openDashboard")]})}):null]}),o.jsxs("div",{className:"space-y-4 pt-4 border-t border-border/10",children:[!de&&o.jsx("div",{className:"flex flex-col gap-2",children:G==="password"?o.jsxs("button",{type:"button",onClick:()=>{z("otp"),J("email"),A("")},className:"w-full flex items-center justify-center gap-2 py-3 glass hover:bg-white/5 text-[10px] font-bold uppercase tracking-widest text-muted-foreground hover:text-primary transition-all rounded-xl",children:[o.jsx(_0,{size:14})," Magic Link Login"]}):o.jsxs("button",{type:"button",onClick:()=>{z("password"),A("")},className:"w-full flex items-center justify-center gap-2 py-3 glass hover:bg-white/5 text-[10px] font-bold uppercase tracking-widest text-muted-foreground hover:text-primary transition-all rounded-xl",children:[o.jsx(Tm,{size:14})," Password Access"]})}),o.jsxs("p",{className:"text-center text-[10px] text-muted-foreground font-bold uppercase tracking-wider",children:[de?"Already have an account?":"Need a new account?"," "," ",o.jsx("button",{onClick:()=>{Ve(!de),z("password"),A("")},className:"text-primary hover:underline ml-1",children:de?"Login Instead":"Create Account"})]})]})]}),o.jsx("div",{className:"mt-8 text-center",children:o.jsx("p",{className:"text-[10px] font-bold text-muted-foreground/30 uppercase tracking-[0.4em]",children:"Powered by RealTimeX Intelligence"})})]})]})}function $3({status:t,onDismiss:e,onLearnMore:n}){const[r,l]=w.useState(!0);if(!r)return null;const u=()=>{d5(),l(!1),e?.()},d=()=>{n?n():(navigator.clipboard.writeText("npx email-automator migrate"),se.success("Command copied to clipboard"))};return o.jsx("div",{className:"fixed right-4 top-16 z-50 max-w-sm animate-in slide-in-from-top-5",children:o.jsx("div",{className:"rounded-lg border border-yellow-500 bg-yellow-50 p-4 shadow-lg dark:bg-yellow-950/90 dark:border-yellow-600",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(xi,{className:"h-5 w-5 flex-shrink-0 text-yellow-600 dark:text-yellow-500 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-sm font-medium text-yellow-900 dark:text-yellow-100",children:"Database Update Required"}),o.jsxs(Q,{size:"icon",variant:"ghost",className:"h-5 w-5 -mr-1 -mt-1 text-yellow-900 hover:bg-yellow-100 dark:text-yellow-100 dark:hover:bg-yellow-900/30",onClick:u,children:[o.jsx(_s,{className:"h-3 w-3"}),o.jsx("span",{className:"sr-only",children:"Dismiss"})]})]}),o.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-200",children:["Your app version (",t.appVersion,") requires a database schema update."]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Q,{size:"sm",variant:"default",className:"h-7 text-xs bg-yellow-600 hover:bg-yellow-700 dark:bg-yellow-500 dark:hover:bg-yellow-600",onClick:d,children:"Update Now"}),o.jsx(Q,{size:"sm",variant:"ghost",className:"h-7 text-xs text-yellow-900 hover:bg-yellow-100 dark:text-yellow-100 dark:hover:bg-yellow-900/30",onClick:u,children:"Remind Later"})]})]})]})})})}function q3({open:t,onOpenChange:e,status:n}){const r=ji(),[l,u]=w.useState(!1),[d,f]=w.useState([]),[p,m]=w.useState(""),y=w.useRef(null),v=w.useMemo(()=>{const S=r?.url;if(!S)return"";try{return new URL(S).hostname.split(".")[0]||""}catch{return""}},[r?.url]);w.useEffect(()=>{y.current&&y.current.scrollIntoView({behavior:"smooth"})},[d]);const b=async()=>{if(!v){se.error("Missing Project ID");return}if(!p){se.error("Provide a Supabase Personal Access Token.");return}u(!0),f(["Initializing migration..."]);try{const S=async T=>{const D=new TextDecoder;let A="",U=null;const H=G=>{const z=G.trim();if(!(!z||!z.startsWith("data: ")))try{const M=z.substring(6),J=JSON.parse(M);J.type==="done"?(J.data==="success"||J.data==="failed")&&(U=J.data==="success"?"success":"failure"):J.data&&f(ie=>[...ie,J.data])}catch(M){console.error("Failed to parse SSE line:",z,M)}};for(;;){const{done:G,value:z}=await T.read();if(G)break;A+=D.decode(z,{stream:!0});const M=A.split(`
|
|
105
|
+
`);A=M.pop()||"",M.forEach(H)}return A+=D.decode(),A&&H(A),U};f(T=>[...T,"","📦 Database Migration & Edge Functions Deployment"]);const _=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:v,accessToken:p})});if(!_.ok)throw new Error(`Migration failed: ${_.status} ${_.statusText}`);const N=_.body?.getReader();if(!N)throw new Error("No migration response stream received.");if(await S(N)!=="success")throw new Error("Migration did not complete successfully");f(T=>[...T,"","═".repeat(60),"✅ Setup Complete!","","✓ Database schema updated","✓ Edge Functions deployed","","🎉 Your Email Automator is ready to use!","📝 The application will reload automatically...","═".repeat(60)]),setTimeout(()=>{window.location.reload()},3e3)}catch(S){console.error(S),f(_=>[..._,"",`❌ Error: ${S instanceof Error?S.message:String(S)}`]),se.error("Setup failed. Check logs for details.")}finally{u(!1)}};return o.jsx(Xa,{open:t,onOpenChange:S=>!l&&e(S),children:o.jsxs(Wa,{className:"max-h-[90vh] sm:max-w-5xl overflow-y-auto",children:[o.jsxs(Ja,{children:[o.jsxs(Qa,{className:"flex items-center gap-2 text-xl",children:[o.jsx(xi,{className:"h-6 w-6 text-red-700 dark:text-red-600"}),"Database Setup Required"]}),o.jsxs(Za,{children:["Your application version (",n.appVersion,") requires database migration and Edge Functions deployment to function correctly."]})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs(er,{children:[o.jsx(vi,{className:"h-4 w-4"}),o.jsxs(tr,{children:[o.jsx("strong",{children:"Why is this needed?"}),o.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-sm",children:[o.jsxs("li",{children:["Updates your database schema to match version ",n.appVersion]}),o.jsx("li",{children:"Deploys Edge Functions (API endpoints) to your Supabase project"}),o.jsx("li",{children:"Enables new features and performance improvements"}),o.jsx("li",{children:"Your existing data will be preserved (safe migration)"})]})]})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm p-6",children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Automated Setup"}),o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Run database migration and deploy Edge Functions directly from your browser. A Supabase Personal Access Token is required to authenticate with your project."}),o.jsxs("div",{className:"grid gap-4",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Ht,{htmlFor:"project-id",children:"Supabase Project ID"}),o.jsx(Ee,{id:"project-id",value:v,disabled:!0,readOnly:!0,className:"bg-muted"})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx(Ht,{htmlFor:"access-token",children:"Access Token"}),o.jsxs("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:["Generate Token ",o.jsx(Bo,{className:"h-3 w-3"})]})]}),o.jsx(Ee,{id:"access-token",type:"password",placeholder:"sbp_...",value:p,onChange:S=>m(S.target.value),disabled:l}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"This token is used only for this migration and is not stored."})]}),o.jsx(Q,{onClick:b,disabled:l||!p,className:"w-full",children:l?o.jsxs(o.Fragment,{children:[o.jsx(_t,{className:"mr-2 h-4 w-4 animate-spin"}),"Running Setup..."]}):o.jsxs(o.Fragment,{children:[o.jsx(iu,{className:"mr-2 h-4 w-4"}),"Start Setup"]})})]})]}),o.jsxs("div",{className:"rounded-lg border bg-black text-white font-mono text-xs p-4 h-64 overflow-y-auto",children:[d.length===0?o.jsx("div",{className:"text-gray-500 italic",children:"Waiting to start..."}):d.map((S,_)=>o.jsx("div",{className:"mb-1 whitespace-pre-wrap",children:S},_)),o.jsx("div",{ref:y})]})]}),o.jsxs(er,{className:"border-red-200 bg-red-50 dark:border-red-900/40 dark:bg-red-950/20",children:[o.jsx(xi,{className:"h-4 w-4 text-red-700 dark:text-red-600"}),o.jsxs(tr,{children:[o.jsx("strong",{children:"Troubleshooting"}),o.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-sm",children:[o.jsxs("li",{children:["Ensure your Access Token has ",o.jsx("code",{children:"read"})," and ",o.jsx("code",{children:"write"})," permissions."]}),o.jsx("li",{children:"Verify that your Supabase Project ID is correct and active."})]})]})]})]}),o.jsx($a,{children:o.jsx(Q,{type:"button",variant:"outline",onClick:()=>e(!1),disabled:l,children:"Close"})})]})})}const H3="https://registry.npmjs.org/@realtimex/email-automator/latest",G3=300*1e3,QS="email_automator_last_version_check",ZS="email_automator_update_dismissed";function F3(){return"2.20.0"}async function K3(){try{const t=await fetch(H3,{cache:"no-store"});return t.ok?(await t.json()).version||null:(console.warn("[Version Check] Failed to fetch latest version"),null)}catch(t){return console.error("[Version Check] Error fetching latest version:",t),null}}function Y3(t,e){if(e==="unknown")return!1;const n=m=>m.replace(/^v/,"").split(".").map(v=>parseInt(v,10)||0),[r,l,u]=n(t),[d,f,p]=n(e);return d>r?!0:d<r?!1:f>l?!0:f<l?!1:p>u}function X3(){try{const t=localStorage.getItem(QS);if(!t)return!0;const e=new Date(t).getTime();return Date.now()-e>G3}catch{return!0}}function W3(){try{localStorage.setItem(QS,new Date().toISOString())}catch(t){console.error("[Version Check] Error saving check timestamp:",t)}}function J3(t=24){try{const e=localStorage.getItem(ZS);if(!e)return!1;const n=new Date(e).getTime();return(Date.now()-n)/(1e3*60*60)<t}catch{return!1}}function Q3(){try{localStorage.setItem(ZS,new Date().toISOString())}catch(t){console.error("[Version Check] Error dismissing update prompt:",t)}}async function Z3(){if(!X3())return console.log("[Version Check] Skipping (throttled)"),null;const t=F3(),e=await K3();if(W3(),!e)return console.warn("[Version Check] Could not determine latest version"),null;const n=Y3(t,e);return console.log("[Version Check]",{current:t,latest:e,updateAvailable:n}),n?{current:t,latest:e,updateAvailable:!0,updateUrl:"https://github.com/realtimex/email-automator/releases/latest"}:null}function e6(){typeof window<"u"&&window.location.reload(),window.electron?.ipcRenderer&&window.electron.ipcRenderer.send("restart-app")}function t6({versionInfo:t,onDismiss:e}){const[n,r]=w.useState(!0),[l,u]=w.useState(!1);if(!n)return null;const d=()=>{Q3(),r(!1),e?.()},f=()=>{u(!0),setTimeout(()=>{e6()},500)},p=()=>{t.updateUrl&&window.open(t.updateUrl,"_blank")};return o.jsx("div",{className:"fixed right-4 top-16 z-50 max-w-sm animate-in slide-in-from-top-5",children:o.jsx("div",{className:"rounded-lg border border-blue-500 bg-blue-50 p-4 shadow-lg dark:bg-blue-950/90 dark:border-blue-600",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Lt,{className:"h-5 w-5 flex-shrink-0 text-blue-600 dark:text-blue-500 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:"Update Available"}),o.jsxs(Q,{size:"icon",variant:"ghost",className:"h-5 w-5 -mr-1 -mt-1 text-blue-900 hover:bg-blue-100 dark:text-blue-100 dark:hover:bg-blue-900/30",onClick:d,children:[o.jsx(_s,{className:"h-3 w-3"}),o.jsx("span",{className:"sr-only",children:"Dismiss"})]})]}),o.jsxs("p",{className:"text-xs text-blue-800 dark:text-blue-200",children:["Version ",t.latest," is now available (you're on ",t.current,")"]}),o.jsxs("div",{className:"flex gap-2 flex-wrap",children:[o.jsx(Q,{size:"sm",variant:"default",className:"h-7 text-xs bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",onClick:f,disabled:l,children:l?o.jsxs(o.Fragment,{children:[o.jsx(Lt,{className:"h-3 w-3 mr-1 animate-spin"}),"Updating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Lt,{className:"h-3 w-3 mr-1"}),"Update Now"]})}),t.updateUrl&&o.jsxs(Q,{size:"sm",variant:"ghost",className:"h-7 text-xs text-blue-900 hover:bg-blue-100 dark:text-blue-100 dark:hover:bg-blue-900/30",onClick:p,children:[o.jsx(Bo,{className:"h-3 w-3 mr-1"}),"What's New"]}),o.jsx(Q,{size:"sm",variant:"ghost",className:"h-7 text-xs text-blue-900 hover:bg-blue-100 dark:text-blue-100 dark:hover:bg-blue-900/30",onClick:d,children:"Later"})]})]})]})})})}function s6(){const{t}=Xe(),[e,n]=w.useState([]),{isExpanded:r,setIsExpanded:l}=Cw(),{state:u,actions:d}=oa(),{isSyncing:f}=u,[p,m]=w.useState({});w.useEffect(()=>{y();const _=Qe.channel("processing_events_feed").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events"},N=>{const E=N.new;E.event_type==="error"&&m(T=>({...T,[E.id]:!0})),n(T=>{const D=[E,...T];return E.details?.is_completion&&r&&setTimeout(()=>{l(!1)},3e3),D.length>100?D.slice(0,100):D})}).subscribe();return()=>{Qe.removeChannel(_)}},[r,l]);const y=async()=>{const{data:_}=await Qe.from("processing_events").select("*").order("created_at",{ascending:!1}).limit(50);_&&n(_)},v=_=>{m(N=>({...N,[_]:!N[_]}))},b=_=>{if(_.details?.is_completion)return o.jsx(ru,{className:"w-3 h-3 text-emerald-500"});switch(_.event_type){case"analysis":return o.jsx(Vo,{className:"w-3 h-3 text-purple-500"});case"action":return o.jsx($o,{className:"w-3 h-3 text-emerald-500"});case"error":return o.jsx(xi,{className:"w-3 h-3 text-red-500"});default:return o.jsx(vi,{className:"w-3 h-3 text-blue-500"})}},S=_=>new Date(_).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return r?o.jsxs(ot,{className:"fixed bottom-4 right-4 z-50 w-[550px] h-[650px] flex flex-col shadow-2xl border-border bg-background/95 text-foreground backdrop-blur-md animate-in slide-in-from-bottom-10",children:[o.jsxs(Zn,{className:"py-3 px-4 border-b border-border flex flex-row items-center justify-between sticky top-0 bg-background/95 z-20",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(iu,{className:"w-4 h-4 text-primary"}),o.jsx(ea,{className:"text-sm font-mono font-bold",children:t("terminal.title")}),o.jsxs("div",{className:Se("flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full border font-bold animate-pulse transition-colors duration-500",f?"text-red-600 dark:text-red-400 bg-red-500/10 border-red-500/20":"text-green-600 dark:text-green-400 bg-green-500/10 border-green-500/20"),children:[o.jsx(EN,{className:"w-3 h-3"}),t(f?"terminal.syncing":"terminal.live")]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[f&&o.jsxs(Q,{variant:"destructive",size:"sm",className:"h-7 text-[10px] font-mono font-bold bg-red-600 hover:bg-red-700 animate-in fade-in zoom-in duration-300",onClick:()=>d.stopSync(),children:[o.jsx(rT,{className:"w-3 h-3 mr-1 fill-current"}),t("terminal.stopSync")]}),o.jsx(Q,{variant:"ghost",size:"sm",className:"h-7 text-[10px] font-mono hover:bg-secondary",onClick:()=>n([]),children:t("terminal.clear")}),o.jsx(Q,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 hover:bg-secondary",onClick:()=>l(!1),children:o.jsx(DE,{className:"w-4 h-4"})})]})]}),o.jsxs(ta,{className:"flex-1 overflow-y-auto p-4 font-mono text-xs space-y-6 custom-scrollbar",children:[e.length===0&&o.jsx("div",{className:"text-center text-muted-foreground py-20 italic",children:t("terminal.waiting")}),e.map((_,N)=>o.jsxs("div",{className:"relative pl-8 animate-in fade-in slide-in-from-top-2 duration-300",children:[N!==e.length-1&&o.jsx("div",{className:"absolute left-[13px] top-7 bottom-[-24px] w-[1px] bg-border"}),o.jsx("div",{className:Se("absolute left-0 top-0 w-7 h-7 rounded-full border border-border bg-card flex items-center justify-center z-10 shadow-sm",_.event_type==="error"&&"border-red-500/50 bg-red-500/5",_.event_type==="analysis"&&"border-purple-500/50 bg-purple-500/5",_.event_type==="action"&&"border-emerald-500/50 bg-emerald-500/5",_.details?.is_completion&&"border-emerald-500/50 bg-emerald-500/5"),children:b(_)}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between group",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:Se("font-bold uppercase tracking-tight text-[10px]",_.event_type==="info"&&"text-muted-foreground",_.event_type==="analysis"&&"text-purple-600 dark:text-purple-400",_.event_type==="action"&&"text-emerald-600 dark:text-emerald-400",_.event_type==="error"&&"text-red-600 dark:text-red-400"),children:_.agent_state}),o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:S(_.created_at)})]}),(_.details?.system_prompt||_.details?._raw_response||_.details?.raw_response)&&o.jsxs(Q,{variant:"ghost",size:"sm",className:"h-5 px-1.5 text-[9px] text-muted-foreground hover:text-primary opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>v(_.id),children:[p[_.id]?o.jsx(XN,{className:"w-3 h-3 mr-1"}):o.jsx(Pb,{className:"w-3 h-3 mr-1"}),t("terminal.details")]})]}),_.event_type==="analysis"&&_.details?o.jsxs("div",{className:"bg-purple-500/5 border border-purple-500/10 rounded-lg p-3 space-y-2",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("span",{className:Se("px-1.5 py-0.5 rounded text-[9px] font-bold border",_.details.is_useless?"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20":"bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/20"),children:_.details.is_useless?t("terminal.useless"):t("terminal.relevant")}),o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold border bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 uppercase",children:_.details.category})]}),o.jsxs("p",{className:"text-foreground/90 italic leading-relaxed",children:['"',_.details.summary,'"']}),_.details.suggested_actions&&_.details.suggested_actions.length>0&&o.jsx("div",{className:"pt-1 flex items-center gap-2 flex-wrap",children:_.details.suggested_actions.map(E=>o.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-emerald-600 dark:text-emerald-400 font-bold bg-emerald-500/10 px-1.5 py-0.5 rounded border border-emerald-500/20 uppercase",children:[o.jsx($o,{className:"w-2.5 h-2.5"}),E]},E))}),_.details.usage&&o.jsx("div",{className:"pt-1.5 flex items-center gap-3 text-[9px] text-muted-foreground/70 border-t border-purple-500/10 mt-1",children:o.jsxs("span",{children:["Tokens: ",_.details.usage.prompt_tokens," (in) + ",_.details.usage.completion_tokens," (out) = ",o.jsx("span",{className:"text-purple-500 font-bold",children:_.details.usage.total_tokens})]})})]}):_.event_type==="action"&&_.details?o.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/10 rounded-lg p-3",children:[o.jsx("p",{className:"text-emerald-600 dark:text-emerald-400 font-bold mb-1 uppercase text-[9px] tracking-widest",children:t("terminal.executionComplete")}),o.jsxs("p",{className:"text-foreground font-medium",children:[_.details.action==="delete"&&t("terminal.action.delete"),_.details.action==="archive"&&t("terminal.action.archive"),_.details.action==="draft"&&t("terminal.action.draft"),_.details.action==="star"&&t("terminal.action.star"),!["delete","archive","draft","star"].includes(_.details.action)&&_.details.action]}),_.details.reason&&o.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 flex items-center gap-1",children:[o.jsx(vi,{className:"w-3 h-3"}),_.details.reason]})]}):_.event_type==="error"&&_.details?o.jsx("div",{className:"bg-red-500/5 border border-red-500/10 rounded-lg p-2.5 text-red-600 dark:text-red-400 font-medium",children:typeof _.details.error=="object"?_.details.error.message||JSON.stringify(_.details.error):_.details.error}):_.details?.is_completion?o.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/20 rounded-lg p-3 space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 dark:text-emerald-400 font-bold uppercase text-[9px] tracking-[0.2em]",children:[o.jsx(ru,{className:"w-3.5 h-3.5"}),t("terminal.batchFinished")]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-1",children:[o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("p",{className:"text-[10px] text-muted-foreground uppercase",children:t("terminal.processed")}),o.jsx("p",{className:"text-sm font-bold",children:_.details.total_processed||0})]}),o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("p",{className:"text-[10px] text-muted-foreground uppercase",children:t("terminal.actions")}),o.jsx("p",{className:"text-sm font-bold text-emerald-500",children:(_.details.deleted||0)+(_.details.drafted||0)})]})]}),_.details.errors>0&&o.jsxs("p",{className:"text-[10px] text-red-500 font-bold pt-1 border-t border-emerald-500/10",children:["⚠️ ",_.details.errors," items failed to process."]})]}):o.jsx("p",{className:"text-muted-foreground leading-relaxed",children:_.details?.message||JSON.stringify(_.details)}),p[_.id]&&o.jsxs("div",{className:"mt-2 space-y-3 animate-in fade-in zoom-in-95 duration-200",children:[_.details?.system_prompt&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-bold text-muted-foreground uppercase tracking-widest px-1",children:[o.jsx(yn,{className:"w-3 h-3"})," System Prompt"]}),o.jsx("div",{className:"bg-secondary/50 rounded-md p-3 border border-border overflow-x-auto",children:o.jsx("pre",{className:"whitespace-pre-wrap break-words text-[10px] leading-normal text-muted-foreground select-all",children:_.details.system_prompt})})]}),_.details?.content_preview&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-bold text-muted-foreground uppercase tracking-widest px-1",children:[o.jsx(yn,{className:"w-3 h-3"})," Input Content (Cleaned)"]}),o.jsx("div",{className:"bg-secondary/50 rounded-md p-3 border border-border",children:o.jsx("p",{className:"whitespace-pre-wrap break-words text-[10px] text-muted-foreground",children:_.details.content_preview})})]}),_.details?._raw_response&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-bold text-muted-foreground uppercase tracking-widest px-1",children:[o.jsx(yn,{className:"w-3 h-3"})," Raw LLM JSON Output"]}),o.jsx("div",{className:"bg-secondary/50 rounded-md p-3 border border-border overflow-x-auto",children:o.jsx("pre",{className:"text-[10px] text-muted-foreground select-all",children:JSON.stringify(JSON.parse(_.details._raw_response),null,2)})})]}),_.details?.raw_response&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-bold text-muted-foreground uppercase tracking-widest px-1",children:[o.jsx(yn,{className:"w-3 h-3"})," Raw Response (from Error)"]}),o.jsx("div",{className:"bg-secondary/50 rounded-md p-3 border border-border overflow-x-auto",children:o.jsx("pre",{className:"text-[10px] text-muted-foreground select-all whitespace-pre-wrap",children:typeof _.details.raw_response=="object"?JSON.stringify(_.details.raw_response,null,2):_.details.raw_response})})]})]})]})]},_.id))]})]}):o.jsx("div",{className:"fixed bottom-4 right-4 z-50",children:o.jsxs(Q,{onClick:()=>l(!0),className:"shadow-lg bg-primary text-primary-foreground hover:opacity-90 border border-border",children:[o.jsx(iu,{className:"w-4 h-4 mr-2"}),t("terminal.liveActivity"),(e.length>0||f)&&o.jsxs("span",{className:"ml-2 flex h-2 w-2 relative",children:[o.jsx("span",{className:Se("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",f?"bg-red-400":"bg-green-400")}),o.jsx("span",{className:Se("relative inline-flex rounded-full h-2 w-2",f?"bg-red-500":"bg-green-500")})]})]})})}function n6(){const{state:t,isSubscribed:e,actions:n}=oa(),{t:r}=Xe(),[l,u]=w.useState(null),[d,f]=w.useState(!0),[p,m]=w.useState(!1),[y,v]=w.useState(!0),[b,S]=w.useState("dashboard"),[_,N]=w.useState(!1),[E,T]=w.useState(null),[D,A]=w.useState(!1),[U,H]=w.useState(!1),[G,z]=w.useState(!1),[M,J]=w.useState(null),[ie,be]=w.useState(!1),[de,Ve]=w.useState(null);if(w.useEffect(()=>{const q=new URLSearchParams(window.location.search).get("code");q&&!_&&(async()=>{N(!0);try{const re=await Oe.connectGmail(q);if(re.data?.success)se.success("Gmail connected successfully!"),window.opener?setTimeout(()=>window.close(),1500):(window.history.replaceState({},"",window.location.pathname),n.fetchAccounts());else{const pe=typeof re.error=="string"?re.error:re.error?.message;se.error(pe||"Failed to connect Gmail")}}catch{se.error("Connection failed")}finally{N(!1)}})()},[]),_)return o.jsx(hu,{text:r("app.connecting")});w.useEffect(()=>{(async()=>{if(!ji()){m(!0),f(!1);return}try{const{data:pe,error:R}=await Qe.from("init_state").select("is_initialized").single();R?(console.warn("[App] Init check error (might be fresh DB):",R),R.code==="42P01"&&v(!1)):v(pe.is_initialized>0);const{data:{session:Y}}=await Qe.auth.getSession();if(u(Y?.user??null),Y?.user){const te=await vp(Qe);T(te.needsMigration?te:null),te.needsMigration&&!u5()&&A(!0)}const Z=await Z3();Z&&!J3()&&(J(Z),be(!0))}catch(pe){console.error("[App] Status check failed:",pe),pe instanceof Error&&pe.message.includes("Invalid API key")&&m(!0)}finally{f(!1)}})();const{data:{subscription:q}}=Qe.auth.onAuthStateChange((re,pe)=>{u(pe?.user??null),pe||(T(null),A(!1))}),B=()=>{if(qs.isEnabled()){const re=new(window.AudioContext||window.webkitAudioContext);re.state==="suspended"&&re.resume()}window.removeEventListener("click",B),window.removeEventListener("keydown",B)};return window.addEventListener("click",B),window.addEventListener("keydown",B),()=>{q.unsubscribe(),window.removeEventListener("click",B),window.removeEventListener("keydown",B)}},[]),w.useEffect(()=>{l&&(n.fetchAccounts(),n.fetchRules(),n.fetchSettings(),n.fetchProfile())},[l]),w.useEffect(()=>{const C=async()=>{try{await Oe.healthCheck()}catch{console.warn("[App] Keep-alive ping failed")}};C();const q=setInterval(C,3e4);return()=>clearInterval(q)},[]);const Ie=()=>{H(!0),A(!1)},ee={migrationStatus:E,showMigrationBanner:D,showMigrationModal:U,openMigrationModal:Ie,suppressMigrationBanner:G,setSuppressMigrationBanner:z};return d?o.jsx(hu,{text:r("app.loadingWorkspace")}):p?o.jsx(SS,{onComplete:()=>m(!1)}):l?o.jsx(gC,{value:ee,children:o.jsxs("div",{className:"min-h-screen bg-background font-sans text-foreground transition-colors duration-300",children:[o.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border/40 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:o.jsxs("div",{className:"max-w-7xl mx-auto flex h-16 items-center justify-between px-4 sm:px-8",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("button",{onClick:()=>S("dashboard"),className:"text-xl font-bold flex items-center gap-2 hover:opacity-80 transition-opacity",children:[o.jsx(xp,{className:"w-8 h-8"}),o.jsx("span",{className:"hidden sm:inline",children:r("app.name")}),o.jsx("span",{className:"sm:hidden",children:"Email AI"})]}),o.jsxs("div",{className:Se("flex items-center gap-1.5 px-2 h-6 rounded-full text-[10px] font-bold border transition-colors",e?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20 dark:text-emerald-400":"bg-yellow-500/10 text-yellow-600 border-yellow-500/20 dark:text-yellow-400"),children:[o.jsxs("div",{className:"relative flex items-center justify-center",children:[e&&o.jsx("span",{className:"absolute inline-flex h-3 w-3 rounded-full bg-emerald-500/40 animate-ping"}),o.jsx("div",{className:Se("relative w-2 h-2 rounded-full",e?"bg-emerald-500":"bg-yellow-500")})]}),o.jsx("span",{className:"hidden xs:inline leading-none",children:r(e?"app.statusLive":"app.statusOffline")})]})]}),o.jsxs("div",{className:"flex gap-4 items-center",children:[o.jsxs("nav",{className:"flex items-center gap-1 bg-secondary/50 p-1 rounded-lg",children:[o.jsxs(Q,{variant:b==="dashboard"?"secondary":"ghost",size:"sm",onClick:()=>S("dashboard"),className:"gap-2",children:[o.jsx(NE,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:r("nav.dashboard")})]}),o.jsxs(Q,{variant:b==="drafts"?"secondary":"ghost",size:"sm",onClick:()=>S("drafts"),className:"gap-2",children:[o.jsx(hE,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:r("nav.drafts")||"Drafts"})]}),o.jsxs(Q,{variant:b==="autopilot"?"secondary":"ghost",size:"sm",onClick:()=>S("autopilot"),className:"gap-2",children:[o.jsx(Jc,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:r("nav.autopilot")})]}),o.jsxs(Q,{variant:b==="analytics"?"secondary":"ghost",size:"sm",onClick:()=>S("analytics"),className:"gap-2",children:[o.jsx(Ub,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:r("nav.analytics")})]}),o.jsxs(Q,{variant:b==="config"?"secondary":"ghost",size:"sm",onClick:()=>S("config"),className:"gap-2",children:[o.jsx(Io,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:r("nav.configuration")})]})]}),o.jsx("div",{className:"h-6 w-px bg-border/50 mx-2 hidden sm:block"}),o.jsx(yp,{}),o.jsx(ow,{}),o.jsx(Q,{variant:b==="account"?"secondary":"ghost",size:"sm",onClick:()=>S("account"),className:"text-muted-foreground hover:text-foreground p-0 w-8 h-8 rounded-full overflow-hidden border",title:r("nav.accountSettings"),children:t.profile?.avatar_url?o.jsx("img",{src:t.profile.avatar_url,alt:"Profile",className:"w-full h-full object-cover"}):o.jsx(eE,{className:"w-5 h-5"})})]})]})}),o.jsxs("main",{className:"max-w-7xl mx-auto p-4 sm:p-8 mt-4 mb-12",children:[b==="dashboard"&&o.jsx(N3,{}),b==="drafts"&&o.jsx(k3,{onPreview:Ve}),b==="autopilot"&&o.jsx(V3,{}),b==="config"&&o.jsx(D3,{}),b==="analytics"&&o.jsx(r6,{}),b==="account"&&o.jsx(M3,{})]}),o.jsx("footer",{className:"max-w-7xl mx-auto px-4 sm:px-8 pb-8 text-center sm:text-left",children:o.jsxs("p",{className:"text-[10px] font-medium text-muted-foreground/40 uppercase tracking-[0.2em]",children:["Email Automator ",o.jsx("span",{className:"mx-1",children:"•"})," v","2.20.0"]})}),t.error&&o.jsx("div",{className:"fixed bottom-20 left-4 right-4 sm:left-auto sm:right-4 sm:max-w-sm z-50",children:o.jsx("div",{className:"bg-destructive/10 border border-destructive/20 text-destructive p-4 rounded-lg",children:o.jsx("p",{className:"text-sm",children:t.error})})}),E&&D&&!G&&o.jsx($3,{status:E,onDismiss:()=>A(!1),onLearnMore:Ie}),M&&ie&&o.jsx(t6,{versionInfo:M,onDismiss:()=>be(!1)}),E&&o.jsx(q3,{open:U,onOpenChange:H,status:E}),de&&o.jsx(O3,{email:de,onClose:()=>Ve(null),onSend:async C=>{(await fetch(`/api/v1/drafts/${C}/send`,{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("supabase.auth.token")}`}})).ok?se.success(r("drafts.sendSuccess")||"Draft sent successfully!"):se.error(r("drafts.sendError")||"Failed to send draft")},onDismiss:async C=>{(await fetch(`/api/v1/drafts/${C}/dismiss`,{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("supabase.auth.token")}`}})).ok&&se.success(r("drafts.dismissSuccess")||"Draft dismissed")}}),o.jsx(s6,{})]})}):o.jsx(I3,{onSuccess:()=>n.fetchProfile(),onConfigure:()=>m(!0),isInitialized:y})}function a6({runId:t,accountEmail:e,isOpen:n,onOpenChange:r}){const{t:l}=Xe(),[u,d]=w.useState([]),[f,p]=w.useState(!1);w.useEffect(()=>{n&&t&&m()},[n,t]);const m=async()=>{if(t){p(!0);try{const v=await Oe.getRunEvents(t);v.data&&d(v.data.events)}catch(v){console.error("Failed to fetch run trace:",v)}finally{p(!1)}}},y=v=>{switch(v){case"analysis":return o.jsx(Vo,{className:"w-4 h-4 text-purple-500"});case"action":return o.jsx($o,{className:"w-4 h-4 text-emerald-500"});case"error":return o.jsx(Ms,{className:"w-4 h-4 text-red-500"});default:return o.jsx(vi,{className:"w-4 h-4 text-blue-500"})}};return o.jsx(Xa,{open:n,onOpenChange:r,children:o.jsxs(Wa,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[o.jsxs(Ja,{className:"p-6 border-b",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(wu,{className:"w-5 h-5 text-primary"}),o.jsx(Qa,{children:l("trace.runTrace")})]}),o.jsx(Za,{children:e?l("trace.fullLogFor").replace("{email}",e):l("trace.historicalLog")})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar bg-secondary/5",children:f?o.jsx("div",{className:"py-20 flex justify-center",children:o.jsx(hu,{text:l("trace.loadingTrace")})}):u.length===0?o.jsx("div",{className:"py-20 text-center text-muted-foreground italic font-mono text-sm",children:l("trace.noTraceEvents")}):u.map((v,b)=>o.jsxs("div",{className:"relative pl-8",children:[b!==u.length-1&&o.jsx("div",{className:"absolute left-[15px] top-8 bottom-[-24px] w-px bg-border"}),o.jsx("div",{className:"absolute left-0 top-0 w-8 h-8 rounded-full border bg-background flex items-center justify-center z-10 shadow-sm",children:y(v.event_type)}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-foreground/70",children:v.agent_state}),v.emails?.subject&&o.jsxs("span",{className:"text-[10px] text-primary font-medium truncate max-w-[300px]",children:["Re: ",v.emails.subject]})]}),o.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[o.jsx(aa,{className:"w-3 h-3"}),new Date(v.created_at).toLocaleTimeString()]})]}),o.jsxs("div",{className:"bg-card border rounded-lg p-4 shadow-sm",children:[v.event_type==="info"&&o.jsx("p",{className:"text-sm text-foreground/90",children:v.details?.message}),v.event_type==="analysis"&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("p",{className:"text-xs text-foreground italic leading-relaxed",children:['"',v.details?.summary,'"']}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("span",{className:"text-[9px] bg-secondary px-1.5 py-0.5 rounded font-bold uppercase",children:v.details?.category}),v.details?.suggested_actions?.map(S=>o.jsx("span",{className:"text-[9px] bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded border border-emerald-500/20 font-bold uppercase",children:S},S))]}),v.details?.usage&&o.jsxs("div",{className:"flex gap-3 pt-1.5 mt-1 border-t border-border/50 text-[9px] text-muted-foreground",children:[o.jsxs("span",{children:["In: ",o.jsx("b",{children:v.details.usage.prompt_tokens})]}),o.jsxs("span",{children:["Out: ",o.jsx("b",{children:v.details.usage.completion_tokens})]}),o.jsxs("span",{children:["Total: ",o.jsx("span",{className:"text-primary font-bold",children:v.details.usage.total_tokens})]})]})]}),v.event_type==="action"&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm font-bold text-emerald-600 dark:text-emerald-400 capitalize",children:[l("dashboard.done")," ",v.details?.action]}),o.jsx(Am,{className:"w-4 h-4 text-emerald-500"})]}),v.event_type==="error"&&o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 font-bold",children:v.details?.error})]})]})]},v.id))})]})})}function r6(){const{state:t,actions:e}=oa(),{t:n}=Xe(),[r,l]=w.useState(null),[u,d]=w.useState(void 0),[f,p]=w.useState(!1);if(w.useEffect(()=>{e.fetchStats()},[]),!t.stats)return o.jsx(hu,{text:n("common.loading")});const m=(v,b)=>{l(v),d(b),p(!0)},{stats:y}=t;return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-500",children:[o.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-2",children:[o.jsx(Ub,{className:"w-6 h-6 text-primary"}),n("analytics.title")]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Wc,{title:n("analytics.totalEmails"),value:y.totalEmails,color:"primary"}),o.jsx(Wc,{title:n("analytics.spamCaught"),value:y.categoryCounts.spam||0,color:"destructive"}),o.jsx(Wc,{title:n("analytics.actionsTaken"),value:Object.values(y.actionCounts).reduce((v,b)=>v+b,0)-(y.actionCounts.none||0),color:"emerald"}),o.jsx(Wc,{title:n("analytics.accounts"),value:y.accountCount,color:"blue"})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"bg-card border rounded-xl p-6",children:[o.jsx("h3",{className:"font-semibold mb-4",children:n("analytics.categories")}),o.jsx("div",{className:"space-y-3",children:Object.entries(y.categoryCounts).map(([v,b])=>o.jsx("div",{className:"flex items-center gap-3",children:o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"capitalize",children:v}),o.jsx("span",{className:"text-muted-foreground",children:b})]}),o.jsx("div",{className:"h-2 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${b/y.totalEmails*100}%`}})})]})},v))})]}),o.jsxs("div",{className:"bg-card border rounded-xl p-6",children:[o.jsx("h3",{className:"font-semibold mb-4",children:n("analytics.actionsTaken")}),o.jsx("div",{className:"space-y-3",children:Object.entries(y.actionCounts).map(([v,b])=>o.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-0",children:[o.jsx("span",{className:"capitalize",children:v}),o.jsx("span",{className:"font-medium",children:b})]},v))})]})]}),o.jsxs("div",{className:"bg-card border rounded-xl p-6",children:[o.jsx("h3",{className:"font-semibold mb-4",children:n("analytics.recentActivity")}),y.recentSyncs.length===0?o.jsx("p",{className:"text-muted-foreground text-sm",children:n("analytics.noActivity")}):o.jsx("div",{className:"space-y-3",children:y.recentSyncs.map(v=>{const b=v.completed_at?Math.round((new Date(v.completed_at).getTime()-new Date(v.started_at).getTime())/1e3):null;return o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between p-3 border rounded-lg hover:bg-secondary/30 transition-colors gap-3 cursor-pointer group",onClick:()=>m(v.id,v.email_accounts?.email_address),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:Se("w-2.5 h-2.5 rounded-full",v.status==="success"?"bg-emerald-500":v.status==="failed"?"bg-destructive":"bg-yellow-500 shadow-[0_0_8px_rgba(234,179,8,0.5)] animate-pulse")}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-medium group-hover:text-primary transition-colors",children:v.email_accounts?.email_address||n("common.systemSync")}),o.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[o.jsx(aa,{className:"w-3 h-3"}),new Date(v.started_at).toLocaleString(),b!==null&&o.jsxs("span",{className:"ml-2 px-1.5 py-0.5 bg-secondary rounded-full",children:[b,"s"]})]})]})]}),o.jsx("div",{className:"flex items-center gap-4 text-xs",children:o.jsxs("div",{className:"flex flex-col items-end",children:[o.jsx("span",{className:"font-bold text-primary",children:n("analytics.emails").replace("{count}",v.emails_processed.toString())}),o.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[n("analytics.deleted").replace("{count}",v.emails_deleted.toString()),", ",n("analytics.drafted").replace("{count}",v.emails_drafted.toString())]})]})})]},v.id)})})]}),o.jsx(a6,{runId:r,accountEmail:u,isOpen:f,onOpenChange:p})]})}function Wc({title:t,value:e,color:n}){const r={primary:"bg-primary/10 text-primary",destructive:"bg-destructive/10 text-destructive",emerald:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",blue:"bg-blue-500/10 text-blue-600 dark:text-blue-400"};return o.jsxs("div",{className:"bg-card border rounded-xl p-6",children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:t}),o.jsx("p",{className:`text-3xl font-bold ${r[n]||""}`,children:e})]})}function i6(){return o.jsx(i5,{children:o.jsx(_T,{defaultTheme:"system",storageKey:"email-automator-theme",children:o.jsx(xC,{children:o.jsx(yC,{children:o.jsxs(mC,{children:[o.jsx(n6,{}),o.jsx(hC,{})]})})})})})}xN.createRoot(document.getElementById("root")).render(o.jsx(Db.StrictMode,{children:o.jsx(i6,{})}));
|