@realtimex/folio 0.1.16 → 0.1.17
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/middleware/auth.ts +77 -0
- package/api/src/routes/chat.ts +7 -1
- package/api/src/routes/index.ts +2 -0
- package/api/src/routes/ingestions.ts +45 -5
- package/api/src/routes/policies.ts +50 -7
- package/api/src/routes/stats.ts +9 -5
- package/api/src/routes/workspaces.ts +290 -0
- package/api/src/services/ChatService.ts +8 -2
- package/api/src/services/IngestionService.ts +38 -26
- package/api/src/services/PolicyEngine.ts +4 -1
- package/api/src/services/PolicyLearningService.ts +31 -6
- package/api/src/services/PolicyLoader.ts +44 -25
- package/api/src/services/RAGService.ts +52 -12
- package/dist/api/src/middleware/auth.js +59 -0
- package/dist/api/src/routes/chat.js +1 -1
- package/dist/api/src/routes/index.js +2 -0
- package/dist/api/src/routes/ingestions.js +45 -8
- package/dist/api/src/routes/policies.js +49 -7
- package/dist/api/src/routes/stats.js +9 -5
- package/dist/api/src/routes/workspaces.js +220 -0
- package/dist/api/src/services/ChatService.js +7 -2
- package/dist/api/src/services/IngestionService.js +35 -30
- package/dist/api/src/services/PolicyEngine.js +2 -1
- package/dist/api/src/services/PolicyLearningService.js +28 -6
- package/dist/api/src/services/PolicyLoader.js +29 -25
- package/dist/api/src/services/RAGService.js +43 -11
- package/dist/assets/index-CTn5FcC4.js +113 -0
- package/dist/assets/index-Dq9sxoZK.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/supabase/functions/workspace-invite/index.ts +110 -0
- package/supabase/migrations/20260223000000_initial_foundation.sql +5 -0
- package/supabase/migrations/20260224000004_add_avatars_storage.sql +4 -0
- package/supabase/migrations/20260224000006_add_policies_table.sql +5 -0
- package/supabase/migrations/20260224000008_add_ingestions_table.sql +2 -0
- package/supabase/migrations/20260225000000_setup_compatible_mode.sql +17 -4
- package/supabase/migrations/20260225000003_add_baseline_configs.sql +4 -3
- package/supabase/migrations/20260226000000_add_processing_events.sql +1 -0
- package/supabase/migrations/20260226000002_add_dynamic_rag.sql +1 -0
- package/supabase/migrations/20260226000005_add_chat_tables.sql +3 -0
- package/supabase/migrations/20260228000001_add_policy_match_feedback.sql +4 -0
- package/supabase/migrations/20260302064608_add_ingestion_llm_settings_compat.sql +15 -0
- package/supabase/migrations/20260303000000_add_workspaces_phase1.sql +459 -0
- package/supabase/migrations/20260303010000_add_workspace_management_rpc.sql +310 -0
- package/supabase/migrations/20260303020000_workspace_scope_document_chunks.sql +139 -0
- package/dist/assets/index-DzN8-j-e.css +0 -1
- package/dist/assets/index-dnBz6SWG.js +0 -113
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function QN(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 sw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qh={exports:{}},xo={};var Tx;function ZN(){if(Tx)return xo;Tx=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 h in l)h!=="key"&&(u[h]=l[h])}else u=l;return l=u.ref,{$$typeof:t,type:r,key:d,ref:l!==void 0?l:null,props:u}}return xo.Fragment=e,xo.jsx=n,xo.jsxs=n,xo}var Ex;function e2(){return Ex||(Ex=1,Qh.exports=ZN()),Qh.exports}var o=e2(),Zh={exports:{}},Me={};var Cx;function t2(){if(Cx)return Me;Cx=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"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),w=Symbol.iterator;function j(D){return D===null||typeof D!="object"?null:(D=w&&D[w]||D["@@iterator"],typeof D=="function"?D:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,_={};function T(D,L,J){this.props=D,this.context=L,this.refs=_,this.updater=J||k}T.prototype.isReactComponent={},T.prototype.setState=function(D,L){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,L,"setState")},T.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function C(){}C.prototype=T.prototype;function A(D,L,J){this.props=D,this.context=L,this.refs=_,this.updater=J||k}var E=A.prototype=new C;E.constructor=A,S(E,T.prototype),E.isPureReactComponent=!0;var M=Array.isArray;function P(){}var U={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function B(D,L,J){var H=J.ref;return{$$typeof:t,type:D,key:L,ref:H!==void 0?H:null,props:J}}function se(D,L){return B(D.type,L,D.props)}function re(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function ue(D){var L={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(J){return L[J]})}var xe=/\/+/g;function ge(D,L){return typeof D=="object"&&D!==null&&D.key!=null?ue(""+D.key):L.toString(36)}function X(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(P,P):(D.status="pending",D.then(function(L){D.status==="pending"&&(D.status="fulfilled",D.value=L)},function(L){D.status==="pending"&&(D.status="rejected",D.reason=L)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function V(D,L,J,H,ae){var ie=typeof D;(ie==="undefined"||ie==="boolean")&&(D=null);var $=!1;if(D===null)$=!0;else switch(ie){case"bigint":case"string":case"number":$=!0;break;case"object":switch(D.$$typeof){case t:case e:$=!0;break;case y:return $=D._init,V($(D._payload),L,J,H,ae)}}if($)return ae=ae(D),$=H===""?"."+ge(D,0):H,M(ae)?(J="",$!=null&&(J=$.replace(xe,"$&/")+"/"),V(ae,L,J,"",function(Oe){return Oe})):ae!=null&&(re(ae)&&(ae=se(ae,J+(ae.key==null||D&&D.key===ae.key?"":(""+ae.key).replace(xe,"$&/")+"/")+$)),L.push(ae)),1;$=0;var fe=H===""?".":H+":";if(M(D))for(var le=0;le<D.length;le++)H=D[le],ie=fe+ge(H,le),$+=V(H,L,J,ie,ae);else if(le=j(D),typeof le=="function")for(D=le.call(D),le=0;!(H=D.next()).done;)H=H.value,ie=fe+ge(H,le++),$+=V(H,L,J,ie,ae);else if(ie==="object"){if(typeof D.then=="function")return V(X(D),L,J,H,ae);throw L=String(D),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.")}return $}function F(D,L,J){if(D==null)return D;var H=[],ae=0;return V(D,H,"","",function(ie){return L.call(J,ie,ae++)}),H}function Z(D){if(D._status===-1){var L=D._result;L=L(),L.then(function(J){(D._status===0||D._status===-1)&&(D._status=1,D._result=J)},function(J){(D._status===0||D._status===-1)&&(D._status=2,D._result=J)}),D._status===-1&&(D._status=0,D._result=L)}if(D._status===1)return D._result.default;throw D._result}var ye=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var L=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(L))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},ne={map:F,forEach:function(D,L,J){F(D,function(){L.apply(this,arguments)},J)},count:function(D){var L=0;return F(D,function(){L++}),L},toArray:function(D){return F(D,function(L){return L})||[]},only:function(D){if(!re(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return Me.Activity=x,Me.Children=ne,Me.Component=T,Me.Fragment=n,Me.Profiler=l,Me.PureComponent=A,Me.StrictMode=r,Me.Suspense=m,Me.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,Me.__COMPILER_RUNTIME={__proto__:null,c:function(D){return U.H.useMemoCache(D)}},Me.cache=function(D){return function(){return D.apply(null,arguments)}},Me.cacheSignal=function(){return null},Me.cloneElement=function(D,L,J){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var H=S({},D.props),ae=D.key;if(L!=null)for(ie in L.key!==void 0&&(ae=""+L.key),L)!R.call(L,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&L.ref===void 0||(H[ie]=L[ie]);var ie=arguments.length-2;if(ie===1)H.children=J;else if(1<ie){for(var $=Array(ie),fe=0;fe<ie;fe++)$[fe]=arguments[fe+2];H.children=$}return B(D.type,ae,H)},Me.createContext=function(D){return D={$$typeof:d,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:u,_context:D},D},Me.createElement=function(D,L,J){var H,ae={},ie=null;if(L!=null)for(H in L.key!==void 0&&(ie=""+L.key),L)R.call(L,H)&&H!=="key"&&H!=="__self"&&H!=="__source"&&(ae[H]=L[H]);var $=arguments.length-2;if($===1)ae.children=J;else if(1<$){for(var fe=Array($),le=0;le<$;le++)fe[le]=arguments[le+2];ae.children=fe}if(D&&D.defaultProps)for(H in $=D.defaultProps,$)ae[H]===void 0&&(ae[H]=$[H]);return B(D,ie,ae)},Me.createRef=function(){return{current:null}},Me.forwardRef=function(D){return{$$typeof:h,render:D}},Me.isValidElement=re,Me.lazy=function(D){return{$$typeof:y,_payload:{_status:-1,_result:D},_init:Z}},Me.memo=function(D,L){return{$$typeof:p,type:D,compare:L===void 0?null:L}},Me.startTransition=function(D){var L=U.T,J={};U.T=J;try{var H=D(),ae=U.S;ae!==null&&ae(J,H),typeof H=="object"&&H!==null&&typeof H.then=="function"&&H.then(P,ye)}catch(ie){ye(ie)}finally{L!==null&&J.types!==null&&(L.types=J.types),U.T=L}},Me.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},Me.use=function(D){return U.H.use(D)},Me.useActionState=function(D,L,J){return U.H.useActionState(D,L,J)},Me.useCallback=function(D,L){return U.H.useCallback(D,L)},Me.useContext=function(D){return U.H.useContext(D)},Me.useDebugValue=function(){},Me.useDeferredValue=function(D,L){return U.H.useDeferredValue(D,L)},Me.useEffect=function(D,L){return U.H.useEffect(D,L)},Me.useEffectEvent=function(D){return U.H.useEffectEvent(D)},Me.useId=function(){return U.H.useId()},Me.useImperativeHandle=function(D,L,J){return U.H.useImperativeHandle(D,L,J)},Me.useInsertionEffect=function(D,L){return U.H.useInsertionEffect(D,L)},Me.useLayoutEffect=function(D,L){return U.H.useLayoutEffect(D,L)},Me.useMemo=function(D,L){return U.H.useMemo(D,L)},Me.useOptimistic=function(D,L){return U.H.useOptimistic(D,L)},Me.useReducer=function(D,L,J){return U.H.useReducer(D,L,J)},Me.useRef=function(D){return U.H.useRef(D)},Me.useState=function(D){return U.H.useState(D)},Me.useSyncExternalStore=function(D,L,J){return U.H.useSyncExternalStore(D,L,J)},Me.useTransition=function(){return U.H.useTransition()},Me.version="19.2.4",Me}var Ax;function Pm(){return Ax||(Ax=1,Zh.exports=t2()),Zh.exports}var v=Pm();const nw=sw(v),Lm=QN({__proto__:null,default:nw},[v]);var ef={exports:{}},bo={},tf={exports:{}},sf={};var Rx;function s2(){return Rx||(Rx=1,(function(t){function e(V,F){var Z=V.length;V.push(F);e:for(;0<Z;){var ye=Z-1>>>1,ne=V[ye];if(0<l(ne,F))V[ye]=F,V[Z]=ne,Z=ye;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var F=V[0],Z=V.pop();if(Z!==F){V[0]=Z;e:for(var ye=0,ne=V.length,D=ne>>>1;ye<D;){var L=2*(ye+1)-1,J=V[L],H=L+1,ae=V[H];if(0>l(J,Z))H<ne&&0>l(ae,J)?(V[ye]=ae,V[H]=Z,ye=H):(V[ye]=J,V[L]=Z,ye=L);else if(H<ne&&0>l(ae,Z))V[ye]=ae,V[H]=Z,ye=H;else break e}}return F}function l(V,F){var Z=V.sortIndex-F.sortIndex;return Z!==0?Z:V.id-F.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,h=d.now();t.unstable_now=function(){return d.now()-h}}var m=[],p=[],y=1,x=null,w=3,j=!1,k=!1,S=!1,_=!1,T=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function E(V){for(var F=n(p);F!==null;){if(F.callback===null)r(p);else if(F.startTime<=V)r(p),F.sortIndex=F.expirationTime,e(m,F);else break;F=n(p)}}function M(V){if(S=!1,E(V),!k)if(n(m)!==null)k=!0,P||(P=!0,ue());else{var F=n(p);F!==null&&X(M,F.startTime-V)}}var P=!1,U=-1,R=5,B=-1;function se(){return _?!0:!(t.unstable_now()-B<R)}function re(){if(_=!1,P){var V=t.unstable_now();B=V;var F=!0;try{e:{k=!1,S&&(S=!1,C(U),U=-1),j=!0;var Z=w;try{t:{for(E(V),x=n(m);x!==null&&!(x.expirationTime>V&&se());){var ye=x.callback;if(typeof ye=="function"){x.callback=null,w=x.priorityLevel;var ne=ye(x.expirationTime<=V);if(V=t.unstable_now(),typeof ne=="function"){x.callback=ne,E(V),F=!0;break t}x===n(m)&&r(m),E(V)}else r(m);x=n(m)}if(x!==null)F=!0;else{var D=n(p);D!==null&&X(M,D.startTime-V),F=!1}}break e}finally{x=null,w=Z,j=!1}F=void 0}}finally{F?ue():P=!1}}}var ue;if(typeof A=="function")ue=function(){A(re)};else if(typeof MessageChannel<"u"){var xe=new MessageChannel,ge=xe.port2;xe.port1.onmessage=re,ue=function(){ge.postMessage(null)}}else ue=function(){T(re,0)};function X(V,F){U=T(function(){V(t.unstable_now())},F)}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(V){V.callback=null},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return w},t.unstable_next=function(V){switch(w){case 1:case 2:case 3:var F=3;break;default:F=w}var Z=w;w=F;try{return V()}finally{w=Z}},t.unstable_requestPaint=function(){_=!0},t.unstable_runWithPriority=function(V,F){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var Z=w;w=V;try{return F()}finally{w=Z}},t.unstable_scheduleCallback=function(V,F,Z){var ye=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?ye+Z:ye):Z=ye,V){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=Z+ne,V={id:y++,callback:F,priorityLevel:V,startTime:Z,expirationTime:ne,sortIndex:-1},Z>ye?(V.sortIndex=Z,e(p,V),n(m)===null&&V===n(p)&&(S?(C(U),U=-1):S=!0,X(M,Z-ye))):(V.sortIndex=ne,e(m,V),k||j||(k=!0,P||(P=!0,ue()))),V},t.unstable_shouldYield=se,t.unstable_wrapCallback=function(V){var F=w;return function(){var Z=w;w=F;try{return V.apply(this,arguments)}finally{w=Z}}}})(sf)),sf}var Ox;function n2(){return Ox||(Ox=1,tf.exports=s2()),tf.exports}var nf={exports:{}},Wt={};var Mx;function a2(){if(Mx)return Wt;Mx=1;var t=Pm();function e(m){var p="https://react.dev/errors/"+m;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+m+"; visit "+p+" 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(m,p,y){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:x==null?null:""+x,children:m,containerInfo:p,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Wt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Wt.createPortal=function(m,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(e(299));return u(m,p,null,y)},Wt.flushSync=function(m){var p=d.T,y=r.p;try{if(d.T=null,r.p=2,m)return m()}finally{d.T=p,r.p=y,r.d.f()}},Wt.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(m,p))},Wt.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},Wt.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var y=p.as,x=h(y,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,j=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:x,integrity:w,fetchPriority:j}):y==="script"&&r.d.X(m,{crossOrigin:x,integrity:w,fetchPriority:j,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Wt.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=h(p.as,p.crossOrigin);r.d.M(m,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(m)},Wt.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,x=h(y,p.crossOrigin);r.d.L(m,y,{crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Wt.preloadModule=function(m,p){if(typeof m=="string")if(p){var y=h(p.as,p.crossOrigin);r.d.m(m,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(m)},Wt.requestFormReset=function(m){r.d.r(m)},Wt.unstable_batchedUpdates=function(m,p){return m(p)},Wt.useFormState=function(m,p,y){return d.H.useFormState(m,p,y)},Wt.useFormStatus=function(){return d.H.useHostTransitionStatus()},Wt.version="19.2.4",Wt}var Dx;function aw(){if(Dx)return nf.exports;Dx=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(),nf.exports=a2(),nf.exports}var Px;function r2(){if(Px)return bo;Px=1;var t=n2(),e=Pm(),n=aw();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 h(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 m(s){if(u(s)!==s)throw Error(r(188))}function p(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 f=i.return;if(f===null)break;var g=f.alternate;if(g===null){if(c=f.return,c!==null){i=c;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===i)return m(f),s;if(g===c)return m(f),a;g=g.sibling}throw Error(r(188))}if(i.return!==c.return)i=f,c=g;else{for(var b=!1,N=f.child;N;){if(N===i){b=!0,i=f,c=g;break}if(N===c){b=!0,c=f,i=g;break}N=N.sibling}if(!b){for(N=g.child;N;){if(N===i){b=!0,i=g,c=f;break}if(N===c){b=!0,c=g,i=f;break}N=N.sibling}if(!b)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 x=Object.assign,w=Symbol.for("react.element"),j=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),A=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),se=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function ue(s){return s===null||typeof s!="object"?null:(s=re&&s[re]||s["@@iterator"],typeof s=="function"?s:null)}var xe=Symbol.for("react.client.reference");function ge(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===xe?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case S:return"Fragment";case T:return"Profiler";case _:return"StrictMode";case M:return"Suspense";case P:return"SuspenseList";case B:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case k:return"Portal";case A:return s.displayName||"Context";case C:return(s._context.displayName||"Context")+".Consumer";case E:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case U:return a=s.displayName||null,a!==null?a:ge(s.type)||"Memo";case R:a=s._payload,s=s._init;try{return ge(s(a))}catch{}}return null}var X=Array.isArray,V=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},ye=[],ne=-1;function D(s){return{current:s}}function L(s){0>ne||(s.current=ye[ne],ye[ne]=null,ne--)}function J(s,a){ne++,ye[ne]=s.current,s.current=a}var H=D(null),ae=D(null),ie=D(null),$=D(null);function fe(s,a){switch(J(ie,a),J(ae,s),J(H,null),a.nodeType){case 9:case 11:s=(s=a.documentElement)&&(s=s.namespaceURI)?Xv(s):0;break;default:if(s=a.tagName,a=a.namespaceURI)a=Xv(a),s=Jv(a,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}L(H),J(H,s)}function le(){L(H),L(ae),L(ie)}function Oe(s){s.memoizedState!==null&&J($,s);var a=H.current,i=Jv(a,s.type);a!==i&&(J(ae,s),J(H,i))}function Ue(s){ae.current===s&&(L(H),L(ae)),$.current===s&&(L($),po._currentValue=Z)}var ft,Ye;function de(s){if(ft===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);ft=a&&a[1]||"",Ye=-1<i.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+ft+s+Ye}var Fe=!1;function pe(s,a){if(!s||Fe)return"";Fe=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var te=function(){throw Error()};if(Object.defineProperty(te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(te,[])}catch(W){var Y=W}Reflect.construct(s,[],te)}else{try{te.call()}catch(W){Y=W}s.call(te.prototype)}}else{try{throw Error()}catch(W){Y=W}(te=s())&&typeof te.catch=="function"&&te.catch(function(){})}}catch(W){if(W&&Y&&typeof W.stack=="string")return[W.stack,Y.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),b=g[0],N=g[1];if(b&&N){var O=b.split(`
|
|
4
|
+
`),K=N.split(`
|
|
5
|
+
`);for(f=c=0;c<O.length&&!O[c].includes("DetermineComponentFrameRoot");)c++;for(;f<K.length&&!K[f].includes("DetermineComponentFrameRoot");)f++;if(c===O.length||f===K.length)for(c=O.length-1,f=K.length-1;1<=c&&0<=f&&O[c]!==K[f];)f--;for(;1<=c&&0<=f;c--,f--)if(O[c]!==K[f]){if(c!==1||f!==1)do if(c--,f--,0>f||O[c]!==K[f]){var Q=`
|
|
6
|
+
`+O[c].replace(" at new "," at ");return s.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",s.displayName)),Q}while(1<=c&&0<=f);break}}}finally{Fe=!1,Error.prepareStackTrace=i}return(i=s?s.displayName||s.name:"")?de(i):""}function De(s,a){switch(s.tag){case 26:case 27:case 5:return de(s.type);case 16:return de("Lazy");case 13:return s.child!==a&&a!==null?de("Suspense Fallback"):de("Suspense");case 19:return de("SuspenseList");case 0:case 15:return pe(s.type,!1);case 11:return pe(s.type.render,!1);case 1:return pe(s.type,!0);case 31:return de("Activity");default:return""}}function it(s){try{var a="",i=null;do a+=De(s,i),i=s,s=s.return;while(s);return a}catch(c){return`
|
|
7
|
+
Error generating stack: `+c.message+`
|
|
8
|
+
`+c.stack}}var Ut=Object.prototype.hasOwnProperty,Ws=t.unstable_scheduleCallback,Ni=t.unstable_cancelCallback,ki=t.unstable_shouldYield,Bu=t.unstable_requestPaint,I=t.unstable_now,ce=t.unstable_getCurrentPriorityLevel,Pe=t.unstable_ImmediatePriority,qe=t.unstable_UserBlockingPriority,pt=t.unstable_NormalPriority,ss=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,ns=t.log,cl=t.unstable_setDisableYieldValue,Mn=null,Yt=null;function Xs(s){if(typeof ns=="function"&&cl(s),Yt&&typeof Yt.setStrictMode=="function")try{Yt.setStrictMode(Mn,s)}catch{}}var ms=Math.clz32?Math.clz32:Uj,Lj=Math.log,zj=Math.LN2;function Uj(s){return s>>>=0,s===0?32:31-(Lj(s)/zj|0)|0}var ul=256,dl=262144,hl=4194304;function wa(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 fl(s,a,i){var c=s.pendingLanes;if(c===0)return 0;var f=0,g=s.suspendedLanes,b=s.pingedLanes;s=s.warmLanes;var N=c&134217727;return N!==0?(c=N&~g,c!==0?f=wa(c):(b&=N,b!==0?f=wa(b):i||(i=N&~s,i!==0&&(f=wa(i))))):(N=c&~g,N!==0?f=wa(N):b!==0?f=wa(b):i||(i=c&~s,i!==0&&(f=wa(i)))),f===0?0:a!==0&&a!==f&&(a&g)===0&&(g=f&-f,i=a&-a,g>=i||g===32&&(i&4194048)!==0)?a:f}function Ti(s,a){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&a)===0}function Bj(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 Rp(){var s=hl;return hl<<=1,(hl&62914560)===0&&(hl=4194304),s}function Iu(s){for(var a=[],i=0;31>i;i++)a.push(s);return a}function Ei(s,a){s.pendingLanes|=a,a!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Ij(s,a,i,c,f,g){var b=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 N=s.entanglements,O=s.expirationTimes,K=s.hiddenUpdates;for(i=b&~i;0<i;){var Q=31-ms(i),te=1<<Q;N[Q]=0,O[Q]=-1;var Y=K[Q];if(Y!==null)for(K[Q]=null,Q=0;Q<Y.length;Q++){var W=Y[Q];W!==null&&(W.lane&=-536870913)}i&=~te}c!==0&&Op(s,c,0),g!==0&&f===0&&s.tag!==0&&(s.suspendedLanes|=g&~(b&~a))}function Op(s,a,i){s.pendingLanes|=a,s.suspendedLanes&=~a;var c=31-ms(a);s.entangledLanes|=a,s.entanglements[c]=s.entanglements[c]|1073741824|i&261930}function Mp(s,a){var i=s.entangledLanes|=a;for(s=s.entanglements;i;){var c=31-ms(i),f=1<<c;f&a|s[c]&a&&(s[c]|=a),i&=~f}}function Dp(s,a){var i=a&-a;return i=(i&42)!==0?1:Vu(i),(i&(s.suspendedLanes|a))!==0?0:i}function Vu(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 $u(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function Pp(){var s=F.p;return s!==0?s:(s=window.event,s===void 0?32:bx(s.type))}function Lp(s,a){var i=F.p;try{return F.p=s,a()}finally{F.p=i}}var Dn=Math.random().toString(36).slice(2),Bt="__reactFiber$"+Dn,as="__reactProps$"+Dn,lr="__reactContainer$"+Dn,qu="__reactEvents$"+Dn,Vj="__reactListeners$"+Dn,$j="__reactHandles$"+Dn,zp="__reactResources$"+Dn,Ci="__reactMarker$"+Dn;function Hu(s){delete s[Bt],delete s[as],delete s[qu],delete s[Vj],delete s[$j]}function cr(s){var a=s[Bt];if(a)return a;for(var i=s.parentNode;i;){if(a=i[lr]||i[Bt]){if(i=a.alternate,a.child!==null||i!==null&&i.child!==null)for(s=ax(s);s!==null;){if(i=s[Bt])return i;s=ax(s)}return a}s=i,i=s.parentNode}return null}function ur(s){if(s=s[Bt]||s[lr]){var a=s.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return s}return null}function Ai(s){var a=s.tag;if(a===5||a===26||a===27||a===6)return s.stateNode;throw Error(r(33))}function dr(s){var a=s[zp];return a||(a=s[zp]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function Lt(s){s[Ci]=!0}var Up=new Set,Bp={};function Sa(s,a){hr(s,a),hr(s+"Capture",a)}function hr(s,a){for(Bp[s]=a,s=0;s<a.length;s++)Up.add(a[s])}var qj=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]*$"),Ip={},Vp={};function Hj(s){return Ut.call(Vp,s)?!0:Ut.call(Ip,s)?!1:qj.test(s)?Vp[s]=!0:(Ip[s]=!0,!1)}function ml(s,a,i){if(Hj(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 pl(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 cn(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 _s(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function $p(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Gj(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 f=c.get,g=c.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return f.call(this)},set:function(b){i=""+b,g.call(this,b)}}),Object.defineProperty(s,a,{enumerable:c.enumerable}),{getValue:function(){return i},setValue:function(b){i=""+b},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function Gu(s){if(!s._valueTracker){var a=$p(s)?"checked":"value";s._valueTracker=Gj(s,a,""+s[a])}}function qp(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var i=a.getValue(),c="";return s&&(c=$p(s)?s.checked?"true":"false":s.value),s=c,s!==i?(a.setValue(s),!0):!1}function gl(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 Fj=/[\n"\\]/g;function Ns(s){return s.replace(Fj,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Fu(s,a,i,c,f,g,b,N){s.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?s.type=b:s.removeAttribute("type"),a!=null?b==="number"?(a===0&&s.value===""||s.value!=a)&&(s.value=""+_s(a)):s.value!==""+_s(a)&&(s.value=""+_s(a)):b!=="submit"&&b!=="reset"||s.removeAttribute("value"),a!=null?Ku(s,b,_s(a)):i!=null?Ku(s,b,_s(i)):c!=null&&s.removeAttribute("value"),f==null&&g!=null&&(s.defaultChecked=!!g),f!=null&&(s.checked=f&&typeof f!="function"&&typeof f!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?s.name=""+_s(N):s.removeAttribute("name")}function Hp(s,a,i,c,f,g,b,N){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)){Gu(s);return}i=i!=null?""+_s(i):"",a=a!=null?""+_s(a):i,N||a===s.value||(s.value=a),s.defaultValue=a}c=c??f,c=typeof c!="function"&&typeof c!="symbol"&&!!c,s.checked=N?s.checked:!!c,s.defaultChecked=!!c,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(s.name=b),Gu(s)}function Ku(s,a,i){a==="number"&&gl(s.ownerDocument)===s||s.defaultValue===""+i||(s.defaultValue=""+i)}function fr(s,a,i,c){if(s=s.options,a){a={};for(var f=0;f<i.length;f++)a["$"+i[f]]=!0;for(i=0;i<s.length;i++)f=a.hasOwnProperty("$"+s[i].value),s[i].selected!==f&&(s[i].selected=f),f&&c&&(s[i].defaultSelected=!0)}else{for(i=""+_s(i),a=null,f=0;f<s.length;f++){if(s[f].value===i){s[f].selected=!0,c&&(s[f].defaultSelected=!0);return}a!==null||s[f].disabled||(a=s[f])}a!==null&&(a.selected=!0)}}function Gp(s,a,i){if(a!=null&&(a=""+_s(a),a!==s.value&&(s.value=a),i==null)){s.defaultValue!==a&&(s.defaultValue=a);return}s.defaultValue=i!=null?""+_s(i):""}function Fp(s,a,i,c){if(a==null){if(c!=null){if(i!=null)throw Error(r(92));if(X(c)){if(1<c.length)throw Error(r(93));c=c[0]}i=c}i==null&&(i=""),a=i}i=_s(a),s.defaultValue=i,c=s.textContent,c===i&&c!==""&&c!==null&&(s.value=c),Gu(s)}function mr(s,a){if(a){var i=s.firstChild;if(i&&i===s.lastChild&&i.nodeType===3){i.nodeValue=a;return}}s.textContent=a}var Kj=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 Kp(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||Kj.has(a)?a==="float"?s.cssFloat=i:s[a]=(""+i).trim():s[a]=i+"px"}function Yp(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 f in a)c=a[f],a.hasOwnProperty(f)&&i[f]!==c&&Kp(s,f,c)}else for(var g in a)a.hasOwnProperty(g)&&Kp(s,g,a[g])}function Yu(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 Yj=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"]]),Wj=/^[\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 yl(s){return Wj.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function un(){}var Wu=null;function Xu(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var pr=null,gr=null;function Wp(s){var a=ur(s);if(a&&(s=a.stateNode)){var i=s[as]||null;e:switch(s=a.stateNode,a.type){case"input":if(Fu(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="'+Ns(""+a)+'"][type="radio"]'),a=0;a<i.length;a++){var c=i[a];if(c!==s&&c.form===s.form){var f=c[as]||null;if(!f)throw Error(r(90));Fu(c,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(a=0;a<i.length;a++)c=i[a],c.form===s.form&&qp(c)}break e;case"textarea":Gp(s,i.value,i.defaultValue);break e;case"select":a=i.value,a!=null&&fr(s,!!i.multiple,a,!1)}}}var Ju=!1;function Xp(s,a,i){if(Ju)return s(a,i);Ju=!0;try{var c=s(a);return c}finally{if(Ju=!1,(pr!==null||gr!==null)&&(ac(),pr&&(a=pr,s=gr,gr=pr=null,Wp(a),s)))for(a=0;a<s.length;a++)Wp(s[a])}}function Ri(s,a){var i=s.stateNode;if(i===null)return null;var c=i[as]||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 dn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qu=!1;if(dn)try{var Oi={};Object.defineProperty(Oi,"passive",{get:function(){Qu=!0}}),window.addEventListener("test",Oi,Oi),window.removeEventListener("test",Oi,Oi)}catch{Qu=!1}var Pn=null,Zu=null,vl=null;function Jp(){if(vl)return vl;var s,a=Zu,i=a.length,c,f="value"in Pn?Pn.value:Pn.textContent,g=f.length;for(s=0;s<i&&a[s]===f[s];s++);var b=i-s;for(c=1;c<=b&&a[i-c]===f[g-c];c++);return vl=f.slice(s,1<c?1-c:void 0)}function xl(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 bl(){return!0}function Qp(){return!1}function rs(s){function a(i,c,f,g,b){this._reactName=i,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=b,this.currentTarget=null;for(var N in s)s.hasOwnProperty(N)&&(i=s[N],this[N]=i?i(g):g[N]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?bl:Qp,this.isPropagationStopped=Qp,this}return x(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=bl)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=bl)},persist:function(){},isPersistent:bl}),a}var ja={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wl=rs(ja),Mi=x({},ja,{view:0,detail:0}),Xj=rs(Mi),ed,td,Di,Sl=x({},Mi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,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!==Di&&(Di&&s.type==="mousemove"?(ed=s.screenX-Di.screenX,td=s.screenY-Di.screenY):td=ed=0,Di=s),ed)},movementY:function(s){return"movementY"in s?s.movementY:td}}),Zp=rs(Sl),Jj=x({},Sl,{dataTransfer:0}),Qj=rs(Jj),Zj=x({},Mi,{relatedTarget:0}),sd=rs(Zj),e_=x({},ja,{animationName:0,elapsedTime:0,pseudoElement:0}),t_=rs(e_),s_=x({},ja,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),n_=rs(s_),a_=x({},ja,{data:0}),eg=rs(a_),r_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},i_={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"},o_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function l_(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=o_[s])?!!a[s]:!1}function nd(){return l_}var c_=x({},Mi,{key:function(s){if(s.key){var a=r_[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=xl(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?i_[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nd,charCode:function(s){return s.type==="keypress"?xl(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?xl(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),u_=rs(c_),d_=x({},Sl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tg=rs(d_),h_=x({},Mi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),f_=rs(h_),m_=x({},ja,{propertyName:0,elapsedTime:0,pseudoElement:0}),p_=rs(m_),g_=x({},Sl,{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}),y_=rs(g_),v_=x({},ja,{newState:0,oldState:0}),x_=rs(v_),b_=[9,13,27,32],ad=dn&&"CompositionEvent"in window,Pi=null;dn&&"documentMode"in document&&(Pi=document.documentMode);var w_=dn&&"TextEvent"in window&&!Pi,sg=dn&&(!ad||Pi&&8<Pi&&11>=Pi),ng=" ",ag=!1;function rg(s,a){switch(s){case"keyup":return b_.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ig(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var yr=!1;function S_(s,a){switch(s){case"compositionend":return ig(a);case"keypress":return a.which!==32?null:(ag=!0,ng);case"textInput":return s=a.data,s===ng&&ag?null:s;default:return null}}function j_(s,a){if(yr)return s==="compositionend"||!ad&&rg(s,a)?(s=Jp(),vl=Zu=Pn=null,yr=!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 sg&&a.locale!=="ko"?null:a.data;default:return null}}var __={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 og(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!__[s.type]:a==="textarea"}function lg(s,a,i,c){pr?gr?gr.push(c):gr=[c]:pr=c,a=dc(a,"onChange"),0<a.length&&(i=new wl("onChange","change",null,i,c),s.push({event:i,listeners:a}))}var Li=null,zi=null;function N_(s){Hv(s,0)}function jl(s){var a=Ai(s);if(qp(a))return s}function cg(s,a){if(s==="change")return a}var ug=!1;if(dn){var rd;if(dn){var id="oninput"in document;if(!id){var dg=document.createElement("div");dg.setAttribute("oninput","return;"),id=typeof dg.oninput=="function"}rd=id}else rd=!1;ug=rd&&(!document.documentMode||9<document.documentMode)}function hg(){Li&&(Li.detachEvent("onpropertychange",fg),zi=Li=null)}function fg(s){if(s.propertyName==="value"&&jl(zi)){var a=[];lg(a,zi,s,Xu(s)),Xp(N_,a)}}function k_(s,a,i){s==="focusin"?(hg(),Li=a,zi=i,Li.attachEvent("onpropertychange",fg)):s==="focusout"&&hg()}function T_(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return jl(zi)}function E_(s,a){if(s==="click")return jl(a)}function C_(s,a){if(s==="input"||s==="change")return jl(a)}function A_(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var ps=typeof Object.is=="function"?Object.is:A_;function Ui(s,a){if(ps(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 f=i[c];if(!Ut.call(a,f)||!ps(s[f],a[f]))return!1}return!0}function mg(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function pg(s,a){var i=mg(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=mg(i)}}function gg(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?gg(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function yg(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var a=gl(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=gl(s.document)}return a}function od(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 R_=dn&&"documentMode"in document&&11>=document.documentMode,vr=null,ld=null,Bi=null,cd=!1;function vg(s,a,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;cd||vr==null||vr!==gl(c)||(c=vr,"selectionStart"in c&&od(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}),Bi&&Ui(Bi,c)||(Bi=c,c=dc(ld,"onSelect"),0<c.length&&(a=new wl("onSelect","select",null,a,i),s.push({event:a,listeners:c}),a.target=vr)))}function _a(s,a){var i={};return i[s.toLowerCase()]=a.toLowerCase(),i["Webkit"+s]="webkit"+a,i["Moz"+s]="moz"+a,i}var xr={animationend:_a("Animation","AnimationEnd"),animationiteration:_a("Animation","AnimationIteration"),animationstart:_a("Animation","AnimationStart"),transitionrun:_a("Transition","TransitionRun"),transitionstart:_a("Transition","TransitionStart"),transitioncancel:_a("Transition","TransitionCancel"),transitionend:_a("Transition","TransitionEnd")},ud={},xg={};dn&&(xg=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);function Na(s){if(ud[s])return ud[s];if(!xr[s])return s;var a=xr[s],i;for(i in a)if(a.hasOwnProperty(i)&&i in xg)return ud[s]=a[i];return s}var bg=Na("animationend"),wg=Na("animationiteration"),Sg=Na("animationstart"),O_=Na("transitionrun"),M_=Na("transitionstart"),D_=Na("transitioncancel"),jg=Na("transitionend"),_g=new Map,dd="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(" ");dd.push("scrollEnd");function zs(s,a){_g.set(s,a),Sa(a,[s])}var _l=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)},ks=[],br=0,hd=0;function Nl(){for(var s=br,a=hd=br=0;a<s;){var i=ks[a];ks[a++]=null;var c=ks[a];ks[a++]=null;var f=ks[a];ks[a++]=null;var g=ks[a];if(ks[a++]=null,c!==null&&f!==null){var b=c.pending;b===null?f.next=f:(f.next=b.next,b.next=f),c.pending=f}g!==0&&Ng(i,f,g)}}function kl(s,a,i,c){ks[br++]=s,ks[br++]=a,ks[br++]=i,ks[br++]=c,hd|=c,s.lanes|=c,s=s.alternate,s!==null&&(s.lanes|=c)}function fd(s,a,i,c){return kl(s,a,i,c),Tl(s)}function ka(s,a){return kl(s,null,null,a),Tl(s)}function Ng(s,a,i){s.lanes|=i;var c=s.alternate;c!==null&&(c.lanes|=i);for(var f=!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||(f=!0)),s=g,g=g.return;return s.tag===3?(g=s.stateNode,f&&a!==null&&(f=31-ms(i),s=g.hiddenUpdates,c=s[f],c===null?s[f]=[a]:c.push(a),a.lane=i|536870912),g):null}function Tl(s){if(50<oo)throw oo=0,Sh=null,Error(r(185));for(var a=s.return;a!==null;)s=a,a=s.return;return s.tag===3?s.stateNode:null}var wr={};function P_(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 gs(s,a,i,c){return new P_(s,a,i,c)}function md(s){return s=s.prototype,!(!s||!s.isReactComponent)}function hn(s,a){var i=s.alternate;return i===null?(i=gs(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 kg(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 El(s,a,i,c,f,g){var b=0;if(c=s,typeof s=="function")md(s)&&(b=1);else if(typeof s=="string")b=IN(s,i,H.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case B:return s=gs(31,i,a,f),s.elementType=B,s.lanes=g,s;case S:return Ta(i.children,f,g,a);case _:b=8,f|=24;break;case T:return s=gs(12,i,a,f|2),s.elementType=T,s.lanes=g,s;case M:return s=gs(13,i,a,f),s.elementType=M,s.lanes=g,s;case P:return s=gs(19,i,a,f),s.elementType=P,s.lanes=g,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case A:b=10;break e;case C:b=9;break e;case E:b=11;break e;case U:b=14;break e;case R:b=16,c=null;break e}b=29,i=Error(r(130,s===null?"null":typeof s,"")),c=null}return a=gs(b,i,a,f),a.elementType=s,a.type=c,a.lanes=g,a}function Ta(s,a,i,c){return s=gs(7,s,c,a),s.lanes=i,s}function pd(s,a,i){return s=gs(6,s,null,a),s.lanes=i,s}function Tg(s){var a=gs(18,null,null,0);return a.stateNode=s,a}function gd(s,a,i){return a=gs(4,s.children!==null?s.children:[],s.key,a),a.lanes=i,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}var Eg=new WeakMap;function Ts(s,a){if(typeof s=="object"&&s!==null){var i=Eg.get(s);return i!==void 0?i:(a={value:s,source:a,stack:it(a)},Eg.set(s,a),a)}return{value:s,source:a,stack:it(a)}}var Sr=[],jr=0,Cl=null,Ii=0,Es=[],Cs=0,Ln=null,Js=1,Qs="";function fn(s,a){Sr[jr++]=Ii,Sr[jr++]=Cl,Cl=s,Ii=a}function Cg(s,a,i){Es[Cs++]=Js,Es[Cs++]=Qs,Es[Cs++]=Ln,Ln=s;var c=Js;s=Qs;var f=32-ms(c)-1;c&=~(1<<f),i+=1;var g=32-ms(a)+f;if(30<g){var b=f-f%5;g=(c&(1<<b)-1).toString(32),c>>=b,f-=b,Js=1<<32-ms(a)+f|i<<f|c,Qs=g+s}else Js=1<<g|i<<f|c,Qs=s}function yd(s){s.return!==null&&(fn(s,1),Cg(s,1,0))}function vd(s){for(;s===Cl;)Cl=Sr[--jr],Sr[jr]=null,Ii=Sr[--jr],Sr[jr]=null;for(;s===Ln;)Ln=Es[--Cs],Es[Cs]=null,Qs=Es[--Cs],Es[Cs]=null,Js=Es[--Cs],Es[Cs]=null}function Ag(s,a){Es[Cs++]=Js,Es[Cs++]=Qs,Es[Cs++]=Ln,Js=a.id,Qs=a.overflow,Ln=s}var It=null,ut=null,Ke=!1,zn=null,As=!1,xd=Error(r(519));function Un(s){var a=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Vi(Ts(a,s)),xd}function Rg(s){var a=s.stateNode,i=s.type,c=s.memoizedProps;switch(a[Bt]=s,a[as]=c,i){case"dialog":$e("cancel",a),$e("close",a);break;case"iframe":case"object":case"embed":$e("load",a);break;case"video":case"audio":for(i=0;i<co.length;i++)$e(co[i],a);break;case"source":$e("error",a);break;case"img":case"image":case"link":$e("error",a),$e("load",a);break;case"details":$e("toggle",a);break;case"input":$e("invalid",a),Hp(a,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":$e("invalid",a);break;case"textarea":$e("invalid",a),Fp(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||Yv(a.textContent,i)?(c.popover!=null&&($e("beforetoggle",a),$e("toggle",a)),c.onScroll!=null&&$e("scroll",a),c.onScrollEnd!=null&&$e("scrollend",a),c.onClick!=null&&(a.onclick=un),a=!0):a=!1,a||Un(s,!0)}function Og(s){for(It=s.return;It;)switch(It.tag){case 5:case 31:case 13:As=!1;return;case 27:case 3:As=!0;return;default:It=It.return}}function _r(s){if(s!==It)return!1;if(!Ke)return Og(s),Ke=!0,!1;var a=s.tag,i;if((i=a!==3&&a!==27)&&((i=a===5)&&(i=s.type,i=!(i!=="form"&&i!=="button")||zh(s.type,s.memoizedProps)),i=!i),i&&ut&&Un(s),Og(s),a===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));ut=nx(s)}else if(a===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));ut=nx(s)}else a===27?(a=ut,Qn(s.type)?(s=$h,$h=null,ut=s):ut=a):ut=It?Os(s.stateNode.nextSibling):null;return!0}function Ea(){ut=It=null,Ke=!1}function bd(){var s=zn;return s!==null&&(cs===null?cs=s:cs.push.apply(cs,s),zn=null),s}function Vi(s){zn===null?zn=[s]:zn.push(s)}var wd=D(null),Ca=null,mn=null;function Bn(s,a,i){J(wd,a._currentValue),a._currentValue=i}function pn(s){s._currentValue=wd.current,L(wd)}function Sd(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 jd(s,a,i,c){var f=s.child;for(f!==null&&(f.return=s);f!==null;){var g=f.dependencies;if(g!==null){var b=f.child;g=g.firstContext;e:for(;g!==null;){var N=g;g=f;for(var O=0;O<a.length;O++)if(N.context===a[O]){g.lanes|=i,N=g.alternate,N!==null&&(N.lanes|=i),Sd(g.return,i,s),c||(b=null);break e}g=N.next}}else if(f.tag===18){if(b=f.return,b===null)throw Error(r(341));b.lanes|=i,g=b.alternate,g!==null&&(g.lanes|=i),Sd(b,i,s),b=null}else b=f.child;if(b!==null)b.return=f;else for(b=f;b!==null;){if(b===s){b=null;break}if(f=b.sibling,f!==null){f.return=b.return,b=f;break}b=b.return}f=b}}function Nr(s,a,i,c){s=null;for(var f=a,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var b=f.alternate;if(b===null)throw Error(r(387));if(b=b.memoizedProps,b!==null){var N=f.type;ps(f.pendingProps.value,b.value)||(s!==null?s.push(N):s=[N])}}else if(f===$.current){if(b=f.alternate,b===null)throw Error(r(387));b.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(s!==null?s.push(po):s=[po])}f=f.return}s!==null&&jd(a,s,i,c),a.flags|=262144}function Al(s){for(s=s.firstContext;s!==null;){if(!ps(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function Aa(s){Ca=s,mn=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Vt(s){return Mg(Ca,s)}function Rl(s,a){return Ca===null&&Aa(s),Mg(s,a)}function Mg(s,a){var i=a._currentValue;if(a={context:a,memoizedValue:i,next:null},mn===null){if(s===null)throw Error(r(308));mn=a,s.dependencies={lanes:0,firstContext:a},s.flags|=524288}else mn=mn.next=a;return i}var L_=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()})}},z_=t.unstable_scheduleCallback,U_=t.unstable_NormalPriority,kt={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _d(){return{controller:new L_,data:new Map,refCount:0}}function $i(s){s.refCount--,s.refCount===0&&z_(U_,function(){s.controller.abort()})}var qi=null,Nd=0,kr=0,Tr=null;function B_(s,a){if(qi===null){var i=qi=[];Nd=0,kr=Eh(),Tr={status:"pending",value:void 0,then:function(c){i.push(c)}}}return Nd++,a.then(Dg,Dg),a}function Dg(){if(--Nd===0&&qi!==null){Tr!==null&&(Tr.status="fulfilled");var s=qi;qi=null,kr=0,Tr=null;for(var a=0;a<s.length;a++)(0,s[a])()}}function I_(s,a){var i=[],c={status:"pending",value:null,reason:null,then:function(f){i.push(f)}};return s.then(function(){c.status="fulfilled",c.value=a;for(var f=0;f<i.length;f++)(0,i[f])(a)},function(f){for(c.status="rejected",c.reason=f,f=0;f<i.length;f++)(0,i[f])(void 0)}),c}var Pg=V.S;V.S=function(s,a){vv=I(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&B_(s,a),Pg!==null&&Pg(s,a)};var Ra=D(null);function kd(){var s=Ra.current;return s!==null?s:ot.pooledCache}function Ol(s,a){a===null?J(Ra,Ra.current):J(Ra,a.pool)}function Lg(){var s=kd();return s===null?null:{parent:kt._currentValue,pool:s}}var Er=Error(r(460)),Td=Error(r(474)),Ml=Error(r(542)),Dl={then:function(){}};function zg(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Ug(s,a,i){switch(i=s[i],i===void 0?s.push(a):i!==a&&(a.then(un,un),a=i),a.status){case"fulfilled":return a.value;case"rejected":throw s=a.reason,Ig(s),s;default:if(typeof a.status=="string")a.then(un,un);else{if(s=ot,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=a,s.status="pending",s.then(function(c){if(a.status==="pending"){var f=a;f.status="fulfilled",f.value=c}},function(c){if(a.status==="pending"){var f=a;f.status="rejected",f.reason=c}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw s=a.reason,Ig(s),s}throw Ma=a,Er}}function Oa(s){try{var a=s._init;return a(s._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Ma=i,Er):i}}var Ma=null;function Bg(){if(Ma===null)throw Error(r(459));var s=Ma;return Ma=null,s}function Ig(s){if(s===Er||s===Ml)throw Error(r(483))}var Cr=null,Hi=0;function Pl(s){var a=Hi;return Hi+=1,Cr===null&&(Cr=[]),Ug(Cr,s,a)}function Gi(s,a){a=a.props.ref,s.ref=a!==void 0?a:null}function Ll(s,a){throw a.$$typeof===w?Error(r(525)):(s=Object.prototype.toString.call(a),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s)))}function Vg(s){function a(q,z){if(s){var G=q.deletions;G===null?(q.deletions=[z],q.flags|=16):G.push(z)}}function i(q,z){if(!s)return null;for(;z!==null;)a(q,z),z=z.sibling;return null}function c(q){for(var z=new Map;q!==null;)q.key!==null?z.set(q.key,q):z.set(q.index,q),q=q.sibling;return z}function f(q,z){return q=hn(q,z),q.index=0,q.sibling=null,q}function g(q,z,G){return q.index=G,s?(G=q.alternate,G!==null?(G=G.index,G<z?(q.flags|=67108866,z):G):(q.flags|=67108866,z)):(q.flags|=1048576,z)}function b(q){return s&&q.alternate===null&&(q.flags|=67108866),q}function N(q,z,G,ee){return z===null||z.tag!==6?(z=pd(G,q.mode,ee),z.return=q,z):(z=f(z,G),z.return=q,z)}function O(q,z,G,ee){var Ee=G.type;return Ee===S?Q(q,z,G.props.children,ee,G.key):z!==null&&(z.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===R&&Oa(Ee)===z.type)?(z=f(z,G.props),Gi(z,G),z.return=q,z):(z=El(G.type,G.key,G.props,null,q.mode,ee),Gi(z,G),z.return=q,z)}function K(q,z,G,ee){return z===null||z.tag!==4||z.stateNode.containerInfo!==G.containerInfo||z.stateNode.implementation!==G.implementation?(z=gd(G,q.mode,ee),z.return=q,z):(z=f(z,G.children||[]),z.return=q,z)}function Q(q,z,G,ee,Ee){return z===null||z.tag!==7?(z=Ta(G,q.mode,ee,Ee),z.return=q,z):(z=f(z,G),z.return=q,z)}function te(q,z,G){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=pd(""+z,q.mode,G),z.return=q,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case j:return G=El(z.type,z.key,z.props,null,q.mode,G),Gi(G,z),G.return=q,G;case k:return z=gd(z,q.mode,G),z.return=q,z;case R:return z=Oa(z),te(q,z,G)}if(X(z)||ue(z))return z=Ta(z,q.mode,G,null),z.return=q,z;if(typeof z.then=="function")return te(q,Pl(z),G);if(z.$$typeof===A)return te(q,Rl(q,z),G);Ll(q,z)}return null}function Y(q,z,G,ee){var Ee=z!==null?z.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Ee!==null?null:N(q,z,""+G,ee);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case j:return G.key===Ee?O(q,z,G,ee):null;case k:return G.key===Ee?K(q,z,G,ee):null;case R:return G=Oa(G),Y(q,z,G,ee)}if(X(G)||ue(G))return Ee!==null?null:Q(q,z,G,ee,null);if(typeof G.then=="function")return Y(q,z,Pl(G),ee);if(G.$$typeof===A)return Y(q,z,Rl(q,G),ee);Ll(q,G)}return null}function W(q,z,G,ee,Ee){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return q=q.get(G)||null,N(z,q,""+ee,Ee);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case j:return q=q.get(ee.key===null?G:ee.key)||null,O(z,q,ee,Ee);case k:return q=q.get(ee.key===null?G:ee.key)||null,K(z,q,ee,Ee);case R:return ee=Oa(ee),W(q,z,G,ee,Ee)}if(X(ee)||ue(ee))return q=q.get(G)||null,Q(z,q,ee,Ee,null);if(typeof ee.then=="function")return W(q,z,G,Pl(ee),Ee);if(ee.$$typeof===A)return W(q,z,G,Rl(z,ee),Ee);Ll(z,ee)}return null}function we(q,z,G,ee){for(var Ee=null,We=null,ke=z,ze=z=0,Ge=null;ke!==null&&ze<G.length;ze++){ke.index>ze?(Ge=ke,ke=null):Ge=ke.sibling;var Xe=Y(q,ke,G[ze],ee);if(Xe===null){ke===null&&(ke=Ge);break}s&&ke&&Xe.alternate===null&&a(q,ke),z=g(Xe,z,ze),We===null?Ee=Xe:We.sibling=Xe,We=Xe,ke=Ge}if(ze===G.length)return i(q,ke),Ke&&fn(q,ze),Ee;if(ke===null){for(;ze<G.length;ze++)ke=te(q,G[ze],ee),ke!==null&&(z=g(ke,z,ze),We===null?Ee=ke:We.sibling=ke,We=ke);return Ke&&fn(q,ze),Ee}for(ke=c(ke);ze<G.length;ze++)Ge=W(ke,q,ze,G[ze],ee),Ge!==null&&(s&&Ge.alternate!==null&&ke.delete(Ge.key===null?ze:Ge.key),z=g(Ge,z,ze),We===null?Ee=Ge:We.sibling=Ge,We=Ge);return s&&ke.forEach(function(na){return a(q,na)}),Ke&&fn(q,ze),Ee}function Ce(q,z,G,ee){if(G==null)throw Error(r(151));for(var Ee=null,We=null,ke=z,ze=z=0,Ge=null,Xe=G.next();ke!==null&&!Xe.done;ze++,Xe=G.next()){ke.index>ze?(Ge=ke,ke=null):Ge=ke.sibling;var na=Y(q,ke,Xe.value,ee);if(na===null){ke===null&&(ke=Ge);break}s&&ke&&na.alternate===null&&a(q,ke),z=g(na,z,ze),We===null?Ee=na:We.sibling=na,We=na,ke=Ge}if(Xe.done)return i(q,ke),Ke&&fn(q,ze),Ee;if(ke===null){for(;!Xe.done;ze++,Xe=G.next())Xe=te(q,Xe.value,ee),Xe!==null&&(z=g(Xe,z,ze),We===null?Ee=Xe:We.sibling=Xe,We=Xe);return Ke&&fn(q,ze),Ee}for(ke=c(ke);!Xe.done;ze++,Xe=G.next())Xe=W(ke,q,ze,Xe.value,ee),Xe!==null&&(s&&Xe.alternate!==null&&ke.delete(Xe.key===null?ze:Xe.key),z=g(Xe,z,ze),We===null?Ee=Xe:We.sibling=Xe,We=Xe);return s&&ke.forEach(function(JN){return a(q,JN)}),Ke&&fn(q,ze),Ee}function at(q,z,G,ee){if(typeof G=="object"&&G!==null&&G.type===S&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case j:e:{for(var Ee=G.key;z!==null;){if(z.key===Ee){if(Ee=G.type,Ee===S){if(z.tag===7){i(q,z.sibling),ee=f(z,G.props.children),ee.return=q,q=ee;break e}}else if(z.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===R&&Oa(Ee)===z.type){i(q,z.sibling),ee=f(z,G.props),Gi(ee,G),ee.return=q,q=ee;break e}i(q,z);break}else a(q,z);z=z.sibling}G.type===S?(ee=Ta(G.props.children,q.mode,ee,G.key),ee.return=q,q=ee):(ee=El(G.type,G.key,G.props,null,q.mode,ee),Gi(ee,G),ee.return=q,q=ee)}return b(q);case k:e:{for(Ee=G.key;z!==null;){if(z.key===Ee)if(z.tag===4&&z.stateNode.containerInfo===G.containerInfo&&z.stateNode.implementation===G.implementation){i(q,z.sibling),ee=f(z,G.children||[]),ee.return=q,q=ee;break e}else{i(q,z);break}else a(q,z);z=z.sibling}ee=gd(G,q.mode,ee),ee.return=q,q=ee}return b(q);case R:return G=Oa(G),at(q,z,G,ee)}if(X(G))return we(q,z,G,ee);if(ue(G)){if(Ee=ue(G),typeof Ee!="function")throw Error(r(150));return G=Ee.call(G),Ce(q,z,G,ee)}if(typeof G.then=="function")return at(q,z,Pl(G),ee);if(G.$$typeof===A)return at(q,z,Rl(q,G),ee);Ll(q,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,z!==null&&z.tag===6?(i(q,z.sibling),ee=f(z,G),ee.return=q,q=ee):(i(q,z),ee=pd(G,q.mode,ee),ee.return=q,q=ee),b(q)):i(q,z)}return function(q,z,G,ee){try{Hi=0;var Ee=at(q,z,G,ee);return Cr=null,Ee}catch(ke){if(ke===Er||ke===Ml)throw ke;var We=gs(29,ke,null,q.mode);return We.lanes=ee,We.return=q,We}}}var Da=Vg(!0),$g=Vg(!1),In=!1;function Ed(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Cd(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 Vn(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function $n(s,a,i){var c=s.updateQueue;if(c===null)return null;if(c=c.shared,(Ze&2)!==0){var f=c.pending;return f===null?a.next=a:(a.next=f.next,f.next=a),c.pending=a,a=Tl(s),Ng(s,null,i),a}return kl(s,c,a,i),Tl(s)}function Fi(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,Mp(s,i)}}function Ad(s,a){var i=s.updateQueue,c=s.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var b={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};g===null?f=g=b:g=g.next=b,i=i.next}while(i!==null);g===null?f=g=a:g=g.next=a}else f=g=a;i={baseState:c.baseState,firstBaseUpdate:f,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 Rd=!1;function Ki(){if(Rd){var s=Tr;if(s!==null)throw s}}function Yi(s,a,i,c){Rd=!1;var f=s.updateQueue;In=!1;var g=f.firstBaseUpdate,b=f.lastBaseUpdate,N=f.shared.pending;if(N!==null){f.shared.pending=null;var O=N,K=O.next;O.next=null,b===null?g=K:b.next=K,b=O;var Q=s.alternate;Q!==null&&(Q=Q.updateQueue,N=Q.lastBaseUpdate,N!==b&&(N===null?Q.firstBaseUpdate=K:N.next=K,Q.lastBaseUpdate=O))}if(g!==null){var te=f.baseState;b=0,Q=K=O=null,N=g;do{var Y=N.lane&-536870913,W=Y!==N.lane;if(W?(He&Y)===Y:(c&Y)===Y){Y!==0&&Y===kr&&(Rd=!0),Q!==null&&(Q=Q.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var we=s,Ce=N;Y=a;var at=i;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){te=we.call(at,te,Y);break e}te=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,Y=typeof we=="function"?we.call(at,te,Y):we,Y==null)break e;te=x({},te,Y);break e;case 2:In=!0}}Y=N.callback,Y!==null&&(s.flags|=64,W&&(s.flags|=8192),W=f.callbacks,W===null?f.callbacks=[Y]:W.push(Y))}else W={lane:Y,tag:N.tag,payload:N.payload,callback:N.callback,next:null},Q===null?(K=Q=W,O=te):Q=Q.next=W,b|=Y;if(N=N.next,N===null){if(N=f.shared.pending,N===null)break;W=N,N=W.next,W.next=null,f.lastBaseUpdate=W,f.shared.pending=null}}while(!0);Q===null&&(O=te),f.baseState=O,f.firstBaseUpdate=K,f.lastBaseUpdate=Q,g===null&&(f.shared.lanes=0),Kn|=b,s.lanes=b,s.memoizedState=te}}function qg(s,a){if(typeof s!="function")throw Error(r(191,s));s.call(a)}function Hg(s,a){var i=s.callbacks;if(i!==null)for(s.callbacks=null,s=0;s<i.length;s++)qg(i[s],a)}var Ar=D(null),zl=D(0);function Gg(s,a){s=_n,J(zl,s),J(Ar,a),_n=s|a.baseLanes}function Od(){J(zl,_n),J(Ar,Ar.current)}function Md(){_n=zl.current,L(Ar),L(zl)}var ys=D(null),Rs=null;function qn(s){var a=s.alternate;J(_t,_t.current&1),J(ys,s),Rs===null&&(a===null||Ar.current!==null||a.memoizedState!==null)&&(Rs=s)}function Dd(s){J(_t,_t.current),J(ys,s),Rs===null&&(Rs=s)}function Fg(s){s.tag===22?(J(_t,_t.current),J(ys,s),Rs===null&&(Rs=s)):Hn()}function Hn(){J(_t,_t.current),J(ys,ys.current)}function vs(s){L(ys),Rs===s&&(Rs=null),L(_t)}var _t=D(0);function Ul(s){for(var a=s;a!==null;){if(a.tag===13){var i=a.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Ih(i)||Vh(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 gn=0,Le=null,st=null,Tt=null,Bl=!1,Rr=!1,Pa=!1,Il=0,Wi=0,Or=null,V_=0;function yt(){throw Error(r(321))}function Pd(s,a){if(a===null)return!1;for(var i=0;i<a.length&&i<s.length;i++)if(!ps(s[i],a[i]))return!1;return!0}function Ld(s,a,i,c,f,g){return gn=g,Le=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,V.H=s===null||s.memoizedState===null?Cy:Jd,Pa=!1,g=i(c,f),Pa=!1,Rr&&(g=Yg(a,i,c,f)),Kg(s),g}function Kg(s){V.H=Qi;var a=st!==null&&st.next!==null;if(gn=0,Tt=st=Le=null,Bl=!1,Wi=0,Or=null,a)throw Error(r(300));s===null||Et||(s=s.dependencies,s!==null&&Al(s)&&(Et=!0))}function Yg(s,a,i,c){Le=s;var f=0;do{if(Rr&&(Or=null),Wi=0,Rr=!1,25<=f)throw Error(r(301));if(f+=1,Tt=st=null,s.updateQueue!=null){var g=s.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}V.H=Ay,g=a(i,c)}while(Rr);return g}function $_(){var s=V.H,a=s.useState()[0];return a=typeof a.then=="function"?Xi(a):a,s=s.useState()[0],(st!==null?st.memoizedState:null)!==s&&(Le.flags|=1024),a}function zd(){var s=Il!==0;return Il=0,s}function Ud(s,a,i){a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~i}function Bd(s){if(Bl){for(s=s.memoizedState;s!==null;){var a=s.queue;a!==null&&(a.pending=null),s=s.next}Bl=!1}gn=0,Tt=st=Le=null,Rr=!1,Wi=Il=0,Or=null}function Jt(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tt===null?Le.memoizedState=Tt=s:Tt=Tt.next=s,Tt}function Nt(){if(st===null){var s=Le.alternate;s=s!==null?s.memoizedState:null}else s=st.next;var a=Tt===null?Le.memoizedState:Tt.next;if(a!==null)Tt=a,st=s;else{if(s===null)throw Le.alternate===null?Error(r(467)):Error(r(310));st=s,s={memoizedState:st.memoizedState,baseState:st.baseState,baseQueue:st.baseQueue,queue:st.queue,next:null},Tt===null?Le.memoizedState=Tt=s:Tt=Tt.next=s}return Tt}function Vl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xi(s){var a=Wi;return Wi+=1,Or===null&&(Or=[]),s=Ug(Or,s,a),a=Le,(Tt===null?a.memoizedState:Tt.next)===null&&(a=a.alternate,V.H=a===null||a.memoizedState===null?Cy:Jd),s}function $l(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Xi(s);if(s.$$typeof===A)return Vt(s)}throw Error(r(438,String(s)))}function Id(s){var a=null,i=Le.updateQueue;if(i!==null&&(a=i.memoCache),a==null){var c=Le.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(a={data:c.data.map(function(f){return f.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),i===null&&(i=Vl(),Le.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]=se;return a.index++,i}function yn(s,a){return typeof a=="function"?a(s):a}function ql(s){var a=Nt();return Vd(a,st,s)}function Vd(s,a,i){var c=s.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=i;var f=s.baseQueue,g=c.pending;if(g!==null){if(f!==null){var b=f.next;f.next=g.next,g.next=b}a.baseQueue=f=g,c.pending=null}if(g=s.baseState,f===null)s.memoizedState=g;else{a=f.next;var N=b=null,O=null,K=a,Q=!1;do{var te=K.lane&-536870913;if(te!==K.lane?(He&te)===te:(gn&te)===te){var Y=K.revertLane;if(Y===0)O!==null&&(O=O.next={lane:0,revertLane:0,gesture:null,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null}),te===kr&&(Q=!0);else if((gn&Y)===Y){K=K.next,Y===kr&&(Q=!0);continue}else te={lane:0,revertLane:K.revertLane,gesture:null,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null},O===null?(N=O=te,b=g):O=O.next=te,Le.lanes|=Y,Kn|=Y;te=K.action,Pa&&i(g,te),g=K.hasEagerState?K.eagerState:i(g,te)}else Y={lane:te,revertLane:K.revertLane,gesture:K.gesture,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null},O===null?(N=O=Y,b=g):O=O.next=Y,Le.lanes|=te,Kn|=te;K=K.next}while(K!==null&&K!==a);if(O===null?b=g:O.next=N,!ps(g,s.memoizedState)&&(Et=!0,Q&&(i=Tr,i!==null)))throw i;s.memoizedState=g,s.baseState=b,s.baseQueue=O,c.lastRenderedState=g}return f===null&&(c.lanes=0),[s.memoizedState,c.dispatch]}function $d(s){var a=Nt(),i=a.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=s;var c=i.dispatch,f=i.pending,g=a.memoizedState;if(f!==null){i.pending=null;var b=f=f.next;do g=s(g,b.action),b=b.next;while(b!==f);ps(g,a.memoizedState)||(Et=!0),a.memoizedState=g,a.baseQueue===null&&(a.baseState=g),i.lastRenderedState=g}return[g,c]}function Wg(s,a,i){var c=Le,f=Nt(),g=Ke;if(g){if(i===void 0)throw Error(r(407));i=i()}else i=a();var b=!ps((st||f).memoizedState,i);if(b&&(f.memoizedState=i,Et=!0),f=f.queue,Gd(Qg.bind(null,c,f,s),[s]),f.getSnapshot!==a||b||Tt!==null&&Tt.memoizedState.tag&1){if(c.flags|=2048,Mr(9,{destroy:void 0},Jg.bind(null,c,f,i,a),null),ot===null)throw Error(r(349));g||(gn&127)!==0||Xg(c,a,i)}return i}function Xg(s,a,i){s.flags|=16384,s={getSnapshot:a,value:i},a=Le.updateQueue,a===null?(a=Vl(),Le.updateQueue=a,a.stores=[s]):(i=a.stores,i===null?a.stores=[s]:i.push(s))}function Jg(s,a,i,c){a.value=i,a.getSnapshot=c,Zg(a)&&ey(s)}function Qg(s,a,i){return i(function(){Zg(a)&&ey(s)})}function Zg(s){var a=s.getSnapshot;s=s.value;try{var i=a();return!ps(s,i)}catch{return!0}}function ey(s){var a=ka(s,2);a!==null&&us(a,s,2)}function qd(s){var a=Jt();if(typeof s=="function"){var i=s;if(s=i(),Pa){Xs(!0);try{i()}finally{Xs(!1)}}}return a.memoizedState=a.baseState=s,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yn,lastRenderedState:s},a}function ty(s,a,i,c){return s.baseState=i,Vd(s,st,typeof c=="function"?c:yn)}function q_(s,a,i,c,f){if(Fl(s))throw Error(r(485));if(s=a.action,s!==null){var g={payload:f,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){g.listeners.push(b)}};V.T!==null?i(!0):g.isTransition=!1,c(g),i=a.pending,i===null?(g.next=a.pending=g,sy(a,g)):(g.next=i.next,a.pending=i.next=g)}}function sy(s,a){var i=a.action,c=a.payload,f=s.state;if(a.isTransition){var g=V.T,b={};V.T=b;try{var N=i(f,c),O=V.S;O!==null&&O(b,N),ny(s,a,N)}catch(K){Hd(s,a,K)}finally{g!==null&&b.types!==null&&(g.types=b.types),V.T=g}}else try{g=i(f,c),ny(s,a,g)}catch(K){Hd(s,a,K)}}function ny(s,a,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(c){ay(s,a,c)},function(c){return Hd(s,a,c)}):ay(s,a,i)}function ay(s,a,i){a.status="fulfilled",a.value=i,ry(a),s.state=i,a=s.pending,a!==null&&(i=a.next,i===a?s.pending=null:(i=i.next,a.next=i,sy(s,i)))}function Hd(s,a,i){var c=s.pending;if(s.pending=null,c!==null){c=c.next;do a.status="rejected",a.reason=i,ry(a),a=a.next;while(a!==c)}s.action=null}function ry(s){s=s.listeners;for(var a=0;a<s.length;a++)(0,s[a])()}function iy(s,a){return a}function oy(s,a){if(Ke){var i=ot.formState;if(i!==null){e:{var c=Le;if(Ke){if(ut){t:{for(var f=ut,g=As;f.nodeType!==8;){if(!g){f=null;break t}if(f=Os(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){ut=Os(f.nextSibling),c=f.data==="F!";break e}}Un(c)}c=!1}c&&(a=i[0])}}return i=Jt(),i.memoizedState=i.baseState=a,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:iy,lastRenderedState:a},i.queue=c,i=ky.bind(null,Le,c),c.dispatch=i,c=qd(!1),g=Xd.bind(null,Le,!1,c.queue),c=Jt(),f={state:a,dispatch:null,action:s,pending:null},c.queue=f,i=q_.bind(null,Le,f,g,i),f.dispatch=i,c.memoizedState=s,[a,i,!1]}function ly(s){var a=Nt();return cy(a,st,s)}function cy(s,a,i){if(a=Vd(s,a,iy)[0],s=ql(yn)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var c=Xi(a)}catch(b){throw b===Er?Ml:b}else c=a;a=Nt();var f=a.queue,g=f.dispatch;return i!==a.memoizedState&&(Le.flags|=2048,Mr(9,{destroy:void 0},H_.bind(null,f,i),null)),[c,g,s]}function H_(s,a){s.action=a}function uy(s){var a=Nt(),i=st;if(i!==null)return cy(a,i,s);Nt(),a=a.memoizedState,i=Nt();var c=i.queue.dispatch;return i.memoizedState=s,[a,c,!1]}function Mr(s,a,i,c){return s={tag:s,create:i,deps:c,inst:a,next:null},a=Le.updateQueue,a===null&&(a=Vl(),Le.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 dy(){return Nt().memoizedState}function Hl(s,a,i,c){var f=Jt();Le.flags|=s,f.memoizedState=Mr(1|a,{destroy:void 0},i,c===void 0?null:c)}function Gl(s,a,i,c){var f=Nt();c=c===void 0?null:c;var g=f.memoizedState.inst;st!==null&&c!==null&&Pd(c,st.memoizedState.deps)?f.memoizedState=Mr(a,g,i,c):(Le.flags|=s,f.memoizedState=Mr(1|a,g,i,c))}function hy(s,a){Hl(8390656,8,s,a)}function Gd(s,a){Gl(2048,8,s,a)}function G_(s){Le.flags|=4;var a=Le.updateQueue;if(a===null)a=Vl(),Le.updateQueue=a,a.events=[s];else{var i=a.events;i===null?a.events=[s]:i.push(s)}}function fy(s){var a=Nt().memoizedState;return G_({ref:a,nextImpl:s}),function(){if((Ze&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}function my(s,a){return Gl(4,2,s,a)}function py(s,a){return Gl(4,4,s,a)}function gy(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 yy(s,a,i){i=i!=null?i.concat([s]):null,Gl(4,4,gy.bind(null,a,s),i)}function Fd(){}function vy(s,a){var i=Nt();a=a===void 0?null:a;var c=i.memoizedState;return a!==null&&Pd(a,c[1])?c[0]:(i.memoizedState=[s,a],s)}function xy(s,a){var i=Nt();a=a===void 0?null:a;var c=i.memoizedState;if(a!==null&&Pd(a,c[1]))return c[0];if(c=s(),Pa){Xs(!0);try{s()}finally{Xs(!1)}}return i.memoizedState=[c,a],c}function Kd(s,a,i){return i===void 0||(gn&1073741824)!==0&&(He&261930)===0?s.memoizedState=a:(s.memoizedState=i,s=bv(),Le.lanes|=s,Kn|=s,i)}function by(s,a,i,c){return ps(i,a)?i:Ar.current!==null?(s=Kd(s,i,c),ps(s,a)||(Et=!0),s):(gn&42)===0||(gn&1073741824)!==0&&(He&261930)===0?(Et=!0,s.memoizedState=i):(s=bv(),Le.lanes|=s,Kn|=s,a)}function wy(s,a,i,c,f){var g=F.p;F.p=g!==0&&8>g?g:8;var b=V.T,N={};V.T=N,Xd(s,!1,a,i);try{var O=f(),K=V.S;if(K!==null&&K(N,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var Q=I_(O,c);Ji(s,a,Q,ws(s))}else Ji(s,a,c,ws(s))}catch(te){Ji(s,a,{then:function(){},status:"rejected",reason:te},ws())}finally{F.p=g,b!==null&&N.types!==null&&(b.types=N.types),V.T=b}}function F_(){}function Yd(s,a,i,c){if(s.tag!==5)throw Error(r(476));var f=Sy(s).queue;wy(s,f,a,Z,i===null?F_:function(){return jy(s),i(c)})}function Sy(s){var a=s.memoizedState;if(a!==null)return a;a={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yn,lastRenderedState:Z},next:null};var i={};return a.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yn,lastRenderedState:i},next:null},s.memoizedState=a,s=s.alternate,s!==null&&(s.memoizedState=a),a}function jy(s){var a=Sy(s);a.next===null&&(a=s.alternate.memoizedState),Ji(s,a.next.queue,{},ws())}function Wd(){return Vt(po)}function _y(){return Nt().memoizedState}function Ny(){return Nt().memoizedState}function K_(s){for(var a=s.return;a!==null;){switch(a.tag){case 24:case 3:var i=ws();s=Vn(i);var c=$n(a,s,i);c!==null&&(us(c,a,i),Fi(c,a,i)),a={cache:_d()},s.payload=a;return}a=a.return}}function Y_(s,a,i){var c=ws();i={lane:c,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Fl(s)?Ty(a,i):(i=fd(s,a,i,c),i!==null&&(us(i,s,c),Ey(i,a,c)))}function ky(s,a,i){var c=ws();Ji(s,a,i,c)}function Ji(s,a,i,c){var f={lane:c,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Fl(s))Ty(a,f);else{var g=s.alternate;if(s.lanes===0&&(g===null||g.lanes===0)&&(g=a.lastRenderedReducer,g!==null))try{var b=a.lastRenderedState,N=g(b,i);if(f.hasEagerState=!0,f.eagerState=N,ps(N,b))return kl(s,a,f,0),ot===null&&Nl(),!1}catch{}if(i=fd(s,a,f,c),i!==null)return us(i,s,c),Ey(i,a,c),!0}return!1}function Xd(s,a,i,c){if(c={lane:2,revertLane:Eh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Fl(s)){if(a)throw Error(r(479))}else a=fd(s,i,c,2),a!==null&&us(a,s,2)}function Fl(s){var a=s.alternate;return s===Le||a!==null&&a===Le}function Ty(s,a){Rr=Bl=!0;var i=s.pending;i===null?a.next=a:(a.next=i.next,i.next=a),s.pending=a}function Ey(s,a,i){if((i&4194048)!==0){var c=a.lanes;c&=s.pendingLanes,i|=c,a.lanes=i,Mp(s,i)}}var Qi={readContext:Vt,use:$l,useCallback:yt,useContext:yt,useEffect:yt,useImperativeHandle:yt,useLayoutEffect:yt,useInsertionEffect:yt,useMemo:yt,useReducer:yt,useRef:yt,useState:yt,useDebugValue:yt,useDeferredValue:yt,useTransition:yt,useSyncExternalStore:yt,useId:yt,useHostTransitionStatus:yt,useFormState:yt,useActionState:yt,useOptimistic:yt,useMemoCache:yt,useCacheRefresh:yt};Qi.useEffectEvent=yt;var Cy={readContext:Vt,use:$l,useCallback:function(s,a){return Jt().memoizedState=[s,a===void 0?null:a],s},useContext:Vt,useEffect:hy,useImperativeHandle:function(s,a,i){i=i!=null?i.concat([s]):null,Hl(4194308,4,gy.bind(null,a,s),i)},useLayoutEffect:function(s,a){return Hl(4194308,4,s,a)},useInsertionEffect:function(s,a){Hl(4,2,s,a)},useMemo:function(s,a){var i=Jt();a=a===void 0?null:a;var c=s();if(Pa){Xs(!0);try{s()}finally{Xs(!1)}}return i.memoizedState=[c,a],c},useReducer:function(s,a,i){var c=Jt();if(i!==void 0){var f=i(a);if(Pa){Xs(!0);try{i(a)}finally{Xs(!1)}}}else f=a;return c.memoizedState=c.baseState=f,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:f},c.queue=s,s=s.dispatch=Y_.bind(null,Le,s),[c.memoizedState,s]},useRef:function(s){var a=Jt();return s={current:s},a.memoizedState=s},useState:function(s){s=qd(s);var a=s.queue,i=ky.bind(null,Le,a);return a.dispatch=i,[s.memoizedState,i]},useDebugValue:Fd,useDeferredValue:function(s,a){var i=Jt();return Kd(i,s,a)},useTransition:function(){var s=qd(!1);return s=wy.bind(null,Le,s.queue,!0,!1),Jt().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,a,i){var c=Le,f=Jt();if(Ke){if(i===void 0)throw Error(r(407));i=i()}else{if(i=a(),ot===null)throw Error(r(349));(He&127)!==0||Xg(c,a,i)}f.memoizedState=i;var g={value:i,getSnapshot:a};return f.queue=g,hy(Qg.bind(null,c,g,s),[s]),c.flags|=2048,Mr(9,{destroy:void 0},Jg.bind(null,c,g,i,a),null),i},useId:function(){var s=Jt(),a=ot.identifierPrefix;if(Ke){var i=Qs,c=Js;i=(c&~(1<<32-ms(c)-1)).toString(32)+i,a="_"+a+"R_"+i,i=Il++,0<i&&(a+="H"+i.toString(32)),a+="_"}else i=V_++,a="_"+a+"r_"+i.toString(32)+"_";return s.memoizedState=a},useHostTransitionStatus:Wd,useFormState:oy,useActionState:oy,useOptimistic:function(s){var a=Jt();a.memoizedState=a.baseState=s;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=i,a=Xd.bind(null,Le,!0,i),i.dispatch=a,[s,a]},useMemoCache:Id,useCacheRefresh:function(){return Jt().memoizedState=K_.bind(null,Le)},useEffectEvent:function(s){var a=Jt(),i={impl:s};return a.memoizedState=i,function(){if((Ze&2)!==0)throw Error(r(440));return i.impl.apply(void 0,arguments)}}},Jd={readContext:Vt,use:$l,useCallback:vy,useContext:Vt,useEffect:Gd,useImperativeHandle:yy,useInsertionEffect:my,useLayoutEffect:py,useMemo:xy,useReducer:ql,useRef:dy,useState:function(){return ql(yn)},useDebugValue:Fd,useDeferredValue:function(s,a){var i=Nt();return by(i,st.memoizedState,s,a)},useTransition:function(){var s=ql(yn)[0],a=Nt().memoizedState;return[typeof s=="boolean"?s:Xi(s),a]},useSyncExternalStore:Wg,useId:_y,useHostTransitionStatus:Wd,useFormState:ly,useActionState:ly,useOptimistic:function(s,a){var i=Nt();return ty(i,st,s,a)},useMemoCache:Id,useCacheRefresh:Ny};Jd.useEffectEvent=fy;var Ay={readContext:Vt,use:$l,useCallback:vy,useContext:Vt,useEffect:Gd,useImperativeHandle:yy,useInsertionEffect:my,useLayoutEffect:py,useMemo:xy,useReducer:$d,useRef:dy,useState:function(){return $d(yn)},useDebugValue:Fd,useDeferredValue:function(s,a){var i=Nt();return st===null?Kd(i,s,a):by(i,st.memoizedState,s,a)},useTransition:function(){var s=$d(yn)[0],a=Nt().memoizedState;return[typeof s=="boolean"?s:Xi(s),a]},useSyncExternalStore:Wg,useId:_y,useHostTransitionStatus:Wd,useFormState:uy,useActionState:uy,useOptimistic:function(s,a){var i=Nt();return st!==null?ty(i,st,s,a):(i.baseState=s,[s,i.queue.dispatch])},useMemoCache:Id,useCacheRefresh:Ny};Ay.useEffectEvent=fy;function Qd(s,a,i,c){a=s.memoizedState,i=i(c,a),i=i==null?a:x({},a,i),s.memoizedState=i,s.lanes===0&&(s.updateQueue.baseState=i)}var Zd={enqueueSetState:function(s,a,i){s=s._reactInternals;var c=ws(),f=Vn(c);f.payload=a,i!=null&&(f.callback=i),a=$n(s,f,c),a!==null&&(us(a,s,c),Fi(a,s,c))},enqueueReplaceState:function(s,a,i){s=s._reactInternals;var c=ws(),f=Vn(c);f.tag=1,f.payload=a,i!=null&&(f.callback=i),a=$n(s,f,c),a!==null&&(us(a,s,c),Fi(a,s,c))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var i=ws(),c=Vn(i);c.tag=2,a!=null&&(c.callback=a),a=$n(s,c,i),a!==null&&(us(a,s,i),Fi(a,s,i))}};function Ry(s,a,i,c,f,g,b){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(c,g,b):a.prototype&&a.prototype.isPureReactComponent?!Ui(i,c)||!Ui(f,g):!0}function Oy(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&&Zd.enqueueReplaceState(a,a.state,null)}function La(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=x({},i));for(var f in s)i[f]===void 0&&(i[f]=s[f])}return i}function My(s){_l(s)}function Dy(s){console.error(s)}function Py(s){_l(s)}function Kl(s,a){try{var i=s.onUncaughtError;i(a.value,{componentStack:a.stack})}catch(c){setTimeout(function(){throw c})}}function Ly(s,a,i){try{var c=s.onCaughtError;c(i.value,{componentStack:i.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function eh(s,a,i){return i=Vn(i),i.tag=3,i.payload={element:null},i.callback=function(){Kl(s,a)},i}function zy(s){return s=Vn(s),s.tag=3,s}function Uy(s,a,i,c){var f=i.type.getDerivedStateFromError;if(typeof f=="function"){var g=c.value;s.payload=function(){return f(g)},s.callback=function(){Ly(a,i,c)}}var b=i.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(s.callback=function(){Ly(a,i,c),typeof f!="function"&&(Yn===null?Yn=new Set([this]):Yn.add(this));var N=c.stack;this.componentDidCatch(c.value,{componentStack:N!==null?N:""})})}function W_(s,a,i,c,f){if(i.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(a=i.alternate,a!==null&&Nr(a,i,f,!0),i=ys.current,i!==null){switch(i.tag){case 31:case 13:return Rs===null?rc():i.alternate===null&&vt===0&&(vt=3),i.flags&=-257,i.flags|=65536,i.lanes=f,c===Dl?i.flags|=16384:(a=i.updateQueue,a===null?i.updateQueue=new Set([c]):a.add(c),Nh(s,c,f)),!1;case 22:return i.flags|=65536,c===Dl?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)),Nh(s,c,f)),!1}throw Error(r(435,i.tag))}return Nh(s,c,f),rc(),!1}if(Ke)return a=ys.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=f,c!==xd&&(s=Error(r(422),{cause:c}),Vi(Ts(s,i)))):(c!==xd&&(a=Error(r(423),{cause:c}),Vi(Ts(a,i))),s=s.current.alternate,s.flags|=65536,f&=-f,s.lanes|=f,c=Ts(c,i),f=eh(s.stateNode,c,f),Ad(s,f),vt!==4&&(vt=2)),!1;var g=Error(r(520),{cause:c});if(g=Ts(g,i),io===null?io=[g]:io.push(g),vt!==4&&(vt=2),a===null)return!0;c=Ts(c,i),i=a;do{switch(i.tag){case 3:return i.flags|=65536,s=f&-f,i.lanes|=s,s=eh(i.stateNode,c,s),Ad(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"&&(Yn===null||!Yn.has(g))))return i.flags|=65536,f&=-f,i.lanes|=f,f=zy(f),Uy(f,s,i,c),Ad(i,f),!1}i=i.return}while(i!==null);return!1}var th=Error(r(461)),Et=!1;function $t(s,a,i,c){a.child=s===null?$g(a,null,i,c):Da(a,s.child,i,c)}function By(s,a,i,c,f){i=i.render;var g=a.ref;if("ref"in c){var b={};for(var N in c)N!=="ref"&&(b[N]=c[N])}else b=c;return Aa(a),c=Ld(s,a,i,b,g,f),N=zd(),s!==null&&!Et?(Ud(s,a,f),vn(s,a,f)):(Ke&&N&&yd(a),a.flags|=1,$t(s,a,c,f),a.child)}function Iy(s,a,i,c,f){if(s===null){var g=i.type;return typeof g=="function"&&!md(g)&&g.defaultProps===void 0&&i.compare===null?(a.tag=15,a.type=g,Vy(s,a,g,c,f)):(s=El(i.type,null,c,a,a.mode,f),s.ref=a.ref,s.return=a,a.child=s)}if(g=s.child,!ch(s,f)){var b=g.memoizedProps;if(i=i.compare,i=i!==null?i:Ui,i(b,c)&&s.ref===a.ref)return vn(s,a,f)}return a.flags|=1,s=hn(g,c),s.ref=a.ref,s.return=a,a.child=s}function Vy(s,a,i,c,f){if(s!==null){var g=s.memoizedProps;if(Ui(g,c)&&s.ref===a.ref)if(Et=!1,a.pendingProps=c=g,ch(s,f))(s.flags&131072)!==0&&(Et=!0);else return a.lanes=s.lanes,vn(s,a,f)}return sh(s,a,i,c,f)}function $y(s,a,i,c){var f=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,f=0;c!==null;)f=f|c.lanes|c.childLanes,c=c.sibling;c=f&~g}else c=0,a.child=null;return qy(s,a,g,i,c)}if((i&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},s!==null&&Ol(a,g!==null?g.cachePool:null),g!==null?Gg(a,g):Od(),Fg(a);else return c=a.lanes=536870912,qy(s,a,g!==null?g.baseLanes|i:i,i,c)}else g!==null?(Ol(a,g.cachePool),Gg(a,g),Hn(),a.memoizedState=null):(s!==null&&Ol(a,null),Od(),Hn());return $t(s,a,f,i),a.child}function Zi(s,a){return s!==null&&s.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function qy(s,a,i,c,f){var g=kd();return g=g===null?null:{parent:kt._currentValue,pool:g},a.memoizedState={baseLanes:i,cachePool:g},s!==null&&Ol(a,null),Od(),Fg(a),s!==null&&Nr(s,a,c,!0),a.childLanes=f,null}function Yl(s,a){return a=Xl({mode:a.mode,children:a.children},s.mode),a.ref=s.ref,s.child=a,a.return=s,a}function Hy(s,a,i){return Da(a,s.child,null,i),s=Yl(a,a.pendingProps),s.flags|=2,vs(a),a.memoizedState=null,s}function X_(s,a,i){var c=a.pendingProps,f=(a.flags&128)!==0;if(a.flags&=-129,s===null){if(Ke){if(c.mode==="hidden")return s=Yl(a,c),a.lanes=536870912,Zi(null,s);if(Dd(a),(s=ut)?(s=sx(s,As),s=s!==null&&s.data==="&"?s:null,s!==null&&(a.memoizedState={dehydrated:s,treeContext:Ln!==null?{id:Js,overflow:Qs}:null,retryLane:536870912,hydrationErrors:null},i=Tg(s),i.return=a,a.child=i,It=a,ut=null)):s=null,s===null)throw Un(a);return a.lanes=536870912,null}return Yl(a,c)}var g=s.memoizedState;if(g!==null){var b=g.dehydrated;if(Dd(a),f)if(a.flags&256)a.flags&=-257,a=Hy(s,a,i);else if(a.memoizedState!==null)a.child=s.child,a.flags|=128,a=null;else throw Error(r(558));else if(Et||Nr(s,a,i,!1),f=(i&s.childLanes)!==0,Et||f){if(c=ot,c!==null&&(b=Dp(c,i),b!==0&&b!==g.retryLane))throw g.retryLane=b,ka(s,b),us(c,s,b),th;rc(),a=Hy(s,a,i)}else s=g.treeContext,ut=Os(b.nextSibling),It=a,Ke=!0,zn=null,As=!1,s!==null&&Ag(a,s),a=Yl(a,c),a.flags|=4096;return a}return s=hn(s.child,{mode:c.mode,children:c.children}),s.ref=a.ref,a.child=s,s.return=a,s}function Wl(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 sh(s,a,i,c,f){return Aa(a),i=Ld(s,a,i,c,void 0,f),c=zd(),s!==null&&!Et?(Ud(s,a,f),vn(s,a,f)):(Ke&&c&&yd(a),a.flags|=1,$t(s,a,i,f),a.child)}function Gy(s,a,i,c,f,g){return Aa(a),a.updateQueue=null,i=Yg(a,c,i,f),Kg(s),c=zd(),s!==null&&!Et?(Ud(s,a,g),vn(s,a,g)):(Ke&&c&&yd(a),a.flags|=1,$t(s,a,i,g),a.child)}function Fy(s,a,i,c,f){if(Aa(a),a.stateNode===null){var g=wr,b=i.contextType;typeof b=="object"&&b!==null&&(g=Vt(b)),g=new i(c,g),a.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Zd,a.stateNode=g,g._reactInternals=a,g=a.stateNode,g.props=c,g.state=a.memoizedState,g.refs={},Ed(a),b=i.contextType,g.context=typeof b=="object"&&b!==null?Vt(b):wr,g.state=a.memoizedState,b=i.getDerivedStateFromProps,typeof b=="function"&&(Qd(a,i,b,c),g.state=a.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(b=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),b!==g.state&&Zd.enqueueReplaceState(g,g.state,null),Yi(a,c,g,f),Ki(),g.state=a.memoizedState),typeof g.componentDidMount=="function"&&(a.flags|=4194308),c=!0}else if(s===null){g=a.stateNode;var N=a.memoizedProps,O=La(i,N);g.props=O;var K=g.context,Q=i.contextType;b=wr,typeof Q=="object"&&Q!==null&&(b=Vt(Q));var te=i.getDerivedStateFromProps;Q=typeof te=="function"||typeof g.getSnapshotBeforeUpdate=="function",N=a.pendingProps!==N,Q||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(N||K!==b)&&Oy(a,g,c,b),In=!1;var Y=a.memoizedState;g.state=Y,Yi(a,c,g,f),Ki(),K=a.memoizedState,N||Y!==K||In?(typeof te=="function"&&(Qd(a,i,te,c),K=a.memoizedState),(O=In||Ry(a,i,O,c,Y,K,b))?(Q||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=K),g.props=c,g.state=K,g.context=b,c=O):(typeof g.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{g=a.stateNode,Cd(s,a),b=a.memoizedProps,Q=La(i,b),g.props=Q,te=a.pendingProps,Y=g.context,K=i.contextType,O=wr,typeof K=="object"&&K!==null&&(O=Vt(K)),N=i.getDerivedStateFromProps,(K=typeof N=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(b!==te||Y!==O)&&Oy(a,g,c,O),In=!1,Y=a.memoizedState,g.state=Y,Yi(a,c,g,f),Ki();var W=a.memoizedState;b!==te||Y!==W||In||s!==null&&s.dependencies!==null&&Al(s.dependencies)?(typeof N=="function"&&(Qd(a,i,N,c),W=a.memoizedState),(Q=In||Ry(a,i,Q,c,Y,W,O)||s!==null&&s.dependencies!==null&&Al(s.dependencies))?(K||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,W,O),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,W,O)),typeof g.componentDidUpdate=="function"&&(a.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof g.componentDidUpdate!="function"||b===s.memoizedProps&&Y===s.memoizedState||(a.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||b===s.memoizedProps&&Y===s.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=W),g.props=c,g.state=W,g.context=O,c=Q):(typeof g.componentDidUpdate!="function"||b===s.memoizedProps&&Y===s.memoizedState||(a.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||b===s.memoizedProps&&Y===s.memoizedState||(a.flags|=1024),c=!1)}return g=c,Wl(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=Da(a,s.child,null,f),a.child=Da(a,null,i,f)):$t(s,a,i,f),a.memoizedState=g.state,s=a.child):s=vn(s,a,f),s}function Ky(s,a,i,c){return Ea(),a.flags|=256,$t(s,a,i,c),a.child}var nh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ah(s){return{baseLanes:s,cachePool:Lg()}}function rh(s,a,i){return s=s!==null?s.childLanes&~i:0,a&&(s|=bs),s}function Yy(s,a,i){var c=a.pendingProps,f=!1,g=(a.flags&128)!==0,b;if((b=g)||(b=s!==null&&s.memoizedState===null?!1:(_t.current&2)!==0),b&&(f=!0,a.flags&=-129),b=(a.flags&32)!==0,a.flags&=-33,s===null){if(Ke){if(f?qn(a):Hn(),(s=ut)?(s=sx(s,As),s=s!==null&&s.data!=="&"?s:null,s!==null&&(a.memoizedState={dehydrated:s,treeContext:Ln!==null?{id:Js,overflow:Qs}:null,retryLane:536870912,hydrationErrors:null},i=Tg(s),i.return=a,a.child=i,It=a,ut=null)):s=null,s===null)throw Un(a);return Vh(s)?a.lanes=32:a.lanes=536870912,null}var N=c.children;return c=c.fallback,f?(Hn(),f=a.mode,N=Xl({mode:"hidden",children:N},f),c=Ta(c,f,i,null),N.return=a,c.return=a,N.sibling=c,a.child=N,c=a.child,c.memoizedState=ah(i),c.childLanes=rh(s,b,i),a.memoizedState=nh,Zi(null,c)):(qn(a),ih(a,N))}var O=s.memoizedState;if(O!==null&&(N=O.dehydrated,N!==null)){if(g)a.flags&256?(qn(a),a.flags&=-257,a=oh(s,a,i)):a.memoizedState!==null?(Hn(),a.child=s.child,a.flags|=128,a=null):(Hn(),N=c.fallback,f=a.mode,c=Xl({mode:"visible",children:c.children},f),N=Ta(N,f,i,null),N.flags|=2,c.return=a,N.return=a,c.sibling=N,a.child=c,Da(a,s.child,null,i),c=a.child,c.memoizedState=ah(i),c.childLanes=rh(s,b,i),a.memoizedState=nh,a=Zi(null,c));else if(qn(a),Vh(N)){if(b=N.nextSibling&&N.nextSibling.dataset,b)var K=b.dgst;b=K,c=Error(r(419)),c.stack="",c.digest=b,Vi({value:c,source:null,stack:null}),a=oh(s,a,i)}else if(Et||Nr(s,a,i,!1),b=(i&s.childLanes)!==0,Et||b){if(b=ot,b!==null&&(c=Dp(b,i),c!==0&&c!==O.retryLane))throw O.retryLane=c,ka(s,c),us(b,s,c),th;Ih(N)||rc(),a=oh(s,a,i)}else Ih(N)?(a.flags|=192,a.child=s.child,a=null):(s=O.treeContext,ut=Os(N.nextSibling),It=a,Ke=!0,zn=null,As=!1,s!==null&&Ag(a,s),a=ih(a,c.children),a.flags|=4096);return a}return f?(Hn(),N=c.fallback,f=a.mode,O=s.child,K=O.sibling,c=hn(O,{mode:"hidden",children:c.children}),c.subtreeFlags=O.subtreeFlags&65011712,K!==null?N=hn(K,N):(N=Ta(N,f,i,null),N.flags|=2),N.return=a,c.return=a,c.sibling=N,a.child=c,Zi(null,c),c=a.child,N=s.child.memoizedState,N===null?N=ah(i):(f=N.cachePool,f!==null?(O=kt._currentValue,f=f.parent!==O?{parent:O,pool:O}:f):f=Lg(),N={baseLanes:N.baseLanes|i,cachePool:f}),c.memoizedState=N,c.childLanes=rh(s,b,i),a.memoizedState=nh,Zi(s.child,c)):(qn(a),i=s.child,s=i.sibling,i=hn(i,{mode:"visible",children:c.children}),i.return=a,i.sibling=null,s!==null&&(b=a.deletions,b===null?(a.deletions=[s],a.flags|=16):b.push(s)),a.child=i,a.memoizedState=null,i)}function ih(s,a){return a=Xl({mode:"visible",children:a},s.mode),a.return=s,s.child=a}function Xl(s,a){return s=gs(22,s,null,a),s.lanes=0,s}function oh(s,a,i){return Da(a,s.child,null,i),s=ih(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function Wy(s,a,i){s.lanes|=a;var c=s.alternate;c!==null&&(c.lanes|=a),Sd(s.return,a,i)}function lh(s,a,i,c,f,g){var b=s.memoizedState;b===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:f,treeForkCount:g}:(b.isBackwards=a,b.rendering=null,b.renderingStartTime=0,b.last=c,b.tail=i,b.tailMode=f,b.treeForkCount=g)}function Xy(s,a,i){var c=a.pendingProps,f=c.revealOrder,g=c.tail;c=c.children;var b=_t.current,N=(b&2)!==0;if(N?(b=b&1|2,a.flags|=128):b&=1,J(_t,b),$t(s,a,c,i),c=Ke?Ii:0,!N&&s!==null&&(s.flags&128)!==0)e:for(s=a.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Wy(s,i,a);else if(s.tag===19)Wy(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(f){case"forwards":for(i=a.child,f=null;i!==null;)s=i.alternate,s!==null&&Ul(s)===null&&(f=i),i=i.sibling;i=f,i===null?(f=a.child,a.child=null):(f=i.sibling,i.sibling=null),lh(a,!1,f,i,g,c);break;case"backwards":case"unstable_legacy-backwards":for(i=null,f=a.child,a.child=null;f!==null;){if(s=f.alternate,s!==null&&Ul(s)===null){a.child=f;break}s=f.sibling,f.sibling=i,i=f,f=s}lh(a,!0,i,null,g,c);break;case"together":lh(a,!1,null,null,void 0,c);break;default:a.memoizedState=null}return a.child}function vn(s,a,i){if(s!==null&&(a.dependencies=s.dependencies),Kn|=a.lanes,(i&a.childLanes)===0)if(s!==null){if(Nr(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=hn(s,s.pendingProps),a.child=i,i.return=a;s.sibling!==null;)s=s.sibling,i=i.sibling=hn(s,s.pendingProps),i.return=a;i.sibling=null}return a.child}function ch(s,a){return(s.lanes&a)!==0?!0:(s=s.dependencies,!!(s!==null&&Al(s)))}function J_(s,a,i){switch(a.tag){case 3:fe(a,a.stateNode.containerInfo),Bn(a,kt,s.memoizedState.cache),Ea();break;case 27:case 5:Oe(a);break;case 4:fe(a,a.stateNode.containerInfo);break;case 10:Bn(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Dd(a),null;break;case 13:var c=a.memoizedState;if(c!==null)return c.dehydrated!==null?(qn(a),a.flags|=128,null):(i&a.child.childLanes)!==0?Yy(s,a,i):(qn(a),s=vn(s,a,i),s!==null?s.sibling:null);qn(a);break;case 19:var f=(s.flags&128)!==0;if(c=(i&a.childLanes)!==0,c||(Nr(s,a,i,!1),c=(i&a.childLanes)!==0),f){if(c)return Xy(s,a,i);a.flags|=128}if(f=a.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),J(_t,_t.current),c)break;return null;case 22:return a.lanes=0,$y(s,a,i,a.pendingProps);case 24:Bn(a,kt,s.memoizedState.cache)}return vn(s,a,i)}function Jy(s,a,i){if(s!==null)if(s.memoizedProps!==a.pendingProps)Et=!0;else{if(!ch(s,i)&&(a.flags&128)===0)return Et=!1,J_(s,a,i);Et=(s.flags&131072)!==0}else Et=!1,Ke&&(a.flags&1048576)!==0&&Cg(a,Ii,a.index);switch(a.lanes=0,a.tag){case 16:e:{var c=a.pendingProps;if(s=Oa(a.elementType),a.type=s,typeof s=="function")md(s)?(c=La(s,c),a.tag=1,a=Fy(null,a,s,c,i)):(a.tag=0,a=sh(null,a,s,c,i));else{if(s!=null){var f=s.$$typeof;if(f===E){a.tag=11,a=By(null,a,s,c,i);break e}else if(f===U){a.tag=14,a=Iy(null,a,s,c,i);break e}}throw a=ge(s)||s,Error(r(306,a,""))}}return a;case 0:return sh(s,a,a.type,a.pendingProps,i);case 1:return c=a.type,f=La(c,a.pendingProps),Fy(s,a,c,f,i);case 3:e:{if(fe(a,a.stateNode.containerInfo),s===null)throw Error(r(387));c=a.pendingProps;var g=a.memoizedState;f=g.element,Cd(s,a),Yi(a,c,null,i);var b=a.memoizedState;if(c=b.cache,Bn(a,kt,c),c!==g.cache&&jd(a,[kt],i,!0),Ki(),c=b.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:b.cache},a.updateQueue.baseState=g,a.memoizedState=g,a.flags&256){a=Ky(s,a,c,i);break e}else if(c!==f){f=Ts(Error(r(424)),a),Vi(f),a=Ky(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,ut=Os(s.firstChild),It=a,Ke=!0,zn=null,As=!0,i=$g(a,null,c,i),a.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Ea(),c===f){a=vn(s,a,i);break e}$t(s,a,c,i)}a=a.child}return a;case 26:return Wl(s,a),s===null?(i=lx(a.type,null,a.pendingProps,null))?a.memoizedState=i:Ke||(i=a.type,s=a.pendingProps,c=hc(ie.current).createElement(i),c[Bt]=a,c[as]=s,qt(c,i,s),Lt(c),a.stateNode=c):a.memoizedState=lx(a.type,s.memoizedProps,a.pendingProps,s.memoizedState),null;case 27:return Oe(a),s===null&&Ke&&(c=a.stateNode=rx(a.type,a.pendingProps,ie.current),It=a,As=!0,f=ut,Qn(a.type)?($h=f,ut=Os(c.firstChild)):ut=f),$t(s,a,a.pendingProps.children,i),Wl(s,a),s===null&&(a.flags|=4194304),a.child;case 5:return s===null&&Ke&&((f=c=ut)&&(c=TN(c,a.type,a.pendingProps,As),c!==null?(a.stateNode=c,It=a,ut=Os(c.firstChild),As=!1,f=!0):f=!1),f||Un(a)),Oe(a),f=a.type,g=a.pendingProps,b=s!==null?s.memoizedProps:null,c=g.children,zh(f,g)?c=null:b!==null&&zh(f,b)&&(a.flags|=32),a.memoizedState!==null&&(f=Ld(s,a,$_,null,null,i),po._currentValue=f),Wl(s,a),$t(s,a,c,i),a.child;case 6:return s===null&&Ke&&((s=i=ut)&&(i=EN(i,a.pendingProps,As),i!==null?(a.stateNode=i,It=a,ut=null,s=!0):s=!1),s||Un(a)),null;case 13:return Yy(s,a,i);case 4:return fe(a,a.stateNode.containerInfo),c=a.pendingProps,s===null?a.child=Da(a,null,c,i):$t(s,a,c,i),a.child;case 11:return By(s,a,a.type,a.pendingProps,i);case 7:return $t(s,a,a.pendingProps,i),a.child;case 8:return $t(s,a,a.pendingProps.children,i),a.child;case 12:return $t(s,a,a.pendingProps.children,i),a.child;case 10:return c=a.pendingProps,Bn(a,a.type,c.value),$t(s,a,c.children,i),a.child;case 9:return f=a.type._context,c=a.pendingProps.children,Aa(a),f=Vt(f),c=c(f),a.flags|=1,$t(s,a,c,i),a.child;case 14:return Iy(s,a,a.type,a.pendingProps,i);case 15:return Vy(s,a,a.type,a.pendingProps,i);case 19:return Xy(s,a,i);case 31:return X_(s,a,i);case 22:return $y(s,a,i,a.pendingProps);case 24:return Aa(a),c=Vt(kt),s===null?(f=kd(),f===null&&(f=ot,g=_d(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=i),f=g),a.memoizedState={parent:c,cache:f},Ed(a),Bn(a,kt,f)):((s.lanes&i)!==0&&(Cd(s,a),Yi(a,null,null,i),Ki()),f=s.memoizedState,g=a.memoizedState,f.parent!==c?(f={parent:c,cache:c},a.memoizedState=f,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=f),Bn(a,kt,c)):(c=g.cache,Bn(a,kt,c),c!==f.cache&&jd(a,[kt],i,!0))),$t(s,a,a.pendingProps.children,i),a.child;case 29:throw a.pendingProps}throw Error(r(156,a.tag))}function xn(s){s.flags|=4}function uh(s,a,i,c,f){if((a=(s.mode&32)!==0)&&(a=!1),a){if(s.flags|=16777216,(f&335544128)===f)if(s.stateNode.complete)s.flags|=8192;else if(_v())s.flags|=8192;else throw Ma=Dl,Td}else s.flags&=-16777217}function Qy(s,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!fx(a))if(_v())s.flags|=8192;else throw Ma=Dl,Td}function Jl(s,a){a!==null&&(s.flags|=4),s.flags&16384&&(a=s.tag!==22?Rp():536870912,s.lanes|=a,zr|=a)}function eo(s,a){if(!Ke)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 dt(s){var a=s.alternate!==null&&s.alternate.child===s.child,i=0,c=0;if(a)for(var f=s.child;f!==null;)i|=f.lanes|f.childLanes,c|=f.subtreeFlags&65011712,c|=f.flags&65011712,f.return=s,f=f.sibling;else for(f=s.child;f!==null;)i|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=s,f=f.sibling;return s.subtreeFlags|=c,s.childLanes=i,a}function Q_(s,a,i){var c=a.pendingProps;switch(vd(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dt(a),null;case 1:return dt(a),null;case 3:return i=a.stateNode,c=null,s!==null&&(c=s.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),pn(kt),le(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(s===null||s.child===null)&&(_r(a)?xn(a):s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,bd())),dt(a),null;case 26:var f=a.type,g=a.memoizedState;return s===null?(xn(a),g!==null?(dt(a),Qy(a,g)):(dt(a),uh(a,f,null,c,i))):g?g!==s.memoizedState?(xn(a),dt(a),Qy(a,g)):(dt(a),a.flags&=-16777217):(s=s.memoizedProps,s!==c&&xn(a),dt(a),uh(a,f,s,c,i)),null;case 27:if(Ue(a),i=ie.current,f=a.type,s!==null&&a.stateNode!=null)s.memoizedProps!==c&&xn(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return dt(a),null}s=H.current,_r(a)?Rg(a):(s=rx(f,c,i),a.stateNode=s,xn(a))}return dt(a),null;case 5:if(Ue(a),f=a.type,s!==null&&a.stateNode!=null)s.memoizedProps!==c&&xn(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return dt(a),null}if(g=H.current,_r(a))Rg(a);else{var b=hc(ie.current);switch(g){case 1:g=b.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:g=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":g=b.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":g=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":g=b.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?b.createElement("select",{is:c.is}):b.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?b.createElement(f,{is:c.is}):b.createElement(f)}}g[Bt]=a,g[as]=c;e:for(b=a.child;b!==null;){if(b.tag===5||b.tag===6)g.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===a)break e;for(;b.sibling===null;){if(b.return===null||b.return===a)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}a.stateNode=g;e:switch(qt(g,f,c),f){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&xn(a)}}return dt(a),uh(a,a.type,s===null?null:s.memoizedProps,a.pendingProps,i),null;case 6:if(s&&a.stateNode!=null)s.memoizedProps!==c&&xn(a);else{if(typeof c!="string"&&a.stateNode===null)throw Error(r(166));if(s=ie.current,_r(a)){if(s=a.stateNode,i=a.memoizedProps,c=null,f=It,f!==null)switch(f.tag){case 27:case 5:c=f.memoizedProps}s[Bt]=a,s=!!(s.nodeValue===i||c!==null&&c.suppressHydrationWarning===!0||Yv(s.nodeValue,i)),s||Un(a,!0)}else s=hc(s).createTextNode(c),s[Bt]=a,a.stateNode=s}return dt(a),null;case 31:if(i=a.memoizedState,s===null||s.memoizedState!==null){if(c=_r(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[Bt]=a}else Ea(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;dt(a),s=!1}else i=bd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=i),s=!0;if(!s)return a.flags&256?(vs(a),a):(vs(a),null);if((a.flags&128)!==0)throw Error(r(558))}return dt(a),null;case 13:if(c=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(f=_r(a),c!==null&&c.dehydrated!==null){if(s===null){if(!f)throw Error(r(318));if(f=a.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));f[Bt]=a}else Ea(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;dt(a),f=!1}else f=bd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=f),f=!0;if(!f)return a.flags&256?(vs(a),a):(vs(a),null)}return vs(a),(a.flags&128)!==0?(a.lanes=i,a):(i=c!==null,s=s!==null&&s.memoizedState!==null,i&&(c=a.child,f=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(f=c.alternate.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==f&&(c.flags|=2048)),i!==s&&i&&(a.child.flags|=8192),Jl(a,a.updateQueue),dt(a),null);case 4:return le(),s===null&&Oh(a.stateNode.containerInfo),dt(a),null;case 10:return pn(a.type),dt(a),null;case 19:if(L(_t),c=a.memoizedState,c===null)return dt(a),null;if(f=(a.flags&128)!==0,g=c.rendering,g===null)if(f)eo(c,!1);else{if(vt!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(g=Ul(s),g!==null){for(a.flags|=128,eo(c,!1),s=g.updateQueue,a.updateQueue=s,Jl(a,s),a.subtreeFlags=0,s=i,i=a.child;i!==null;)kg(i,s),i=i.sibling;return J(_t,_t.current&1|2),Ke&&fn(a,c.treeForkCount),a.child}s=s.sibling}c.tail!==null&&I()>sc&&(a.flags|=128,f=!0,eo(c,!1),a.lanes=4194304)}else{if(!f)if(s=Ul(g),s!==null){if(a.flags|=128,f=!0,s=s.updateQueue,a.updateQueue=s,Jl(a,s),eo(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!Ke)return dt(a),null}else 2*I()-c.renderingStartTime>sc&&i!==536870912&&(a.flags|=128,f=!0,eo(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=I(),s.sibling=null,i=_t.current,J(_t,f?i&1|2:i&1),Ke&&fn(a,c.treeForkCount),s):(dt(a),null);case 22:case 23:return vs(a),Md(),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&&(dt(a),a.subtreeFlags&6&&(a.flags|=8192)):dt(a),i=a.updateQueue,i!==null&&Jl(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&&L(Ra),null;case 24:return i=null,s!==null&&(i=s.memoizedState.cache),a.memoizedState.cache!==i&&(a.flags|=2048),pn(kt),dt(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function Z_(s,a){switch(vd(a),a.tag){case 1:return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return pn(kt),le(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 26:case 27:case 5:return Ue(a),null;case 31:if(a.memoizedState!==null){if(vs(a),a.alternate===null)throw Error(r(340));Ea()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 13:if(vs(a),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(r(340));Ea()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return L(_t),null;case 4:return le(),null;case 10:return pn(a.type),null;case 22:case 23:return vs(a),Md(),s!==null&&L(Ra),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 24:return pn(kt),null;case 25:return null;default:return null}}function Zy(s,a){switch(vd(a),a.tag){case 3:pn(kt),le();break;case 26:case 27:case 5:Ue(a);break;case 4:le();break;case 31:a.memoizedState!==null&&vs(a);break;case 13:vs(a);break;case 19:L(_t);break;case 10:pn(a.type);break;case 22:case 23:vs(a),Md(),s!==null&&L(Ra);break;case 24:pn(kt)}}function to(s,a){try{var i=a.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var f=c.next;i=f;do{if((i.tag&s)===s){c=void 0;var g=i.create,b=i.inst;c=g(),b.destroy=c}i=i.next}while(i!==f)}}catch(N){tt(a,a.return,N)}}function Gn(s,a,i){try{var c=a.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var g=f.next;c=g;do{if((c.tag&s)===s){var b=c.inst,N=b.destroy;if(N!==void 0){b.destroy=void 0,f=a;var O=i,K=N;try{K()}catch(Q){tt(f,O,Q)}}}c=c.next}while(c!==g)}}catch(Q){tt(a,a.return,Q)}}function ev(s){var a=s.updateQueue;if(a!==null){var i=s.stateNode;try{Hg(a,i)}catch(c){tt(s,s.return,c)}}}function tv(s,a,i){i.props=La(s.type,s.memoizedProps),i.state=s.memoizedState;try{i.componentWillUnmount()}catch(c){tt(s,a,c)}}function so(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(f){tt(s,a,f)}}function Zs(s,a){var i=s.ref,c=s.refCleanup;if(i!==null)if(typeof c=="function")try{c()}catch(f){tt(s,a,f)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(f){tt(s,a,f)}else i.current=null}function sv(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(f){tt(s,s.return,f)}}function dh(s,a,i){try{var c=s.stateNode;wN(c,s.type,i,a),c[as]=a}catch(f){tt(s,s.return,f)}}function nv(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Qn(s.type)||s.tag===4}function hh(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||nv(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&&Qn(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 fh(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=un));else if(c!==4&&(c===27&&Qn(s.type)&&(i=s.stateNode,a=null),s=s.child,s!==null))for(fh(s,a,i),s=s.sibling;s!==null;)fh(s,a,i),s=s.sibling}function Ql(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&&Qn(s.type)&&(i=s.stateNode),s=s.child,s!==null))for(Ql(s,a,i),s=s.sibling;s!==null;)Ql(s,a,i),s=s.sibling}function av(s){var a=s.stateNode,i=s.memoizedProps;try{for(var c=s.type,f=a.attributes;f.length;)a.removeAttributeNode(f[0]);qt(a,c,i),a[Bt]=s,a[as]=i}catch(g){tt(s,s.return,g)}}var bn=!1,Ct=!1,mh=!1,rv=typeof WeakSet=="function"?WeakSet:Set,zt=null;function eN(s,a){if(s=s.containerInfo,Ph=xc,s=yg(s),od(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 f=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var b=0,N=-1,O=-1,K=0,Q=0,te=s,Y=null;t:for(;;){for(var W;te!==i||f!==0&&te.nodeType!==3||(N=b+f),te!==g||c!==0&&te.nodeType!==3||(O=b+c),te.nodeType===3&&(b+=te.nodeValue.length),(W=te.firstChild)!==null;)Y=te,te=W;for(;;){if(te===s)break t;if(Y===i&&++K===f&&(N=b),Y===g&&++Q===c&&(O=b),(W=te.nextSibling)!==null)break;te=Y,Y=te.parentNode}te=W}i=N===-1||O===-1?null:{start:N,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Lh={focusedElem:s,selectionRange:i},xc=!1,zt=a;zt!==null;)if(a=zt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,zt=s;else for(;zt!==null;){switch(a=zt,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++)f=s[i],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&g!==null){s=void 0,i=a,f=g.memoizedProps,g=g.memoizedState,c=i.stateNode;try{var we=La(i.type,f);s=c.getSnapshotBeforeUpdate(we,g),c.__reactInternalSnapshotBeforeUpdate=s}catch(Ce){tt(i,i.return,Ce)}}break;case 3:if((s&1024)!==0){if(s=a.stateNode.containerInfo,i=s.nodeType,i===9)Bh(s);else if(i===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Bh(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,zt=s;break}zt=a.return}}function iv(s,a,i){var c=i.flags;switch(i.tag){case 0:case 11:case 15:Sn(s,i),c&4&&to(5,i);break;case 1:if(Sn(s,i),c&4)if(s=i.stateNode,a===null)try{s.componentDidMount()}catch(b){tt(i,i.return,b)}else{var f=La(i.type,a.memoizedProps);a=a.memoizedState;try{s.componentDidUpdate(f,a,s.__reactInternalSnapshotBeforeUpdate)}catch(b){tt(i,i.return,b)}}c&64&&ev(i),c&512&&so(i,i.return);break;case 3:if(Sn(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{Hg(s,a)}catch(b){tt(i,i.return,b)}}break;case 27:a===null&&c&4&&av(i);case 26:case 5:Sn(s,i),a===null&&c&4&&sv(i),c&512&&so(i,i.return);break;case 12:Sn(s,i);break;case 31:Sn(s,i),c&4&&cv(s,i);break;case 13:Sn(s,i),c&4&&uv(s,i),c&64&&(s=i.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(i=cN.bind(null,i),CN(s,i))));break;case 22:if(c=i.memoizedState!==null||bn,!c){a=a!==null&&a.memoizedState!==null||Ct,f=bn;var g=Ct;bn=c,(Ct=a)&&!g?jn(s,i,(i.subtreeFlags&8772)!==0):Sn(s,i),bn=f,Ct=g}break;case 30:break;default:Sn(s,i)}}function ov(s){var a=s.alternate;a!==null&&(s.alternate=null,ov(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&Hu(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 mt=null,is=!1;function wn(s,a,i){for(i=i.child;i!==null;)lv(s,a,i),i=i.sibling}function lv(s,a,i){if(Yt&&typeof Yt.onCommitFiberUnmount=="function")try{Yt.onCommitFiberUnmount(Mn,i)}catch{}switch(i.tag){case 26:Ct||Zs(i,a),wn(s,a,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Ct||Zs(i,a);var c=mt,f=is;Qn(i.type)&&(mt=i.stateNode,is=!1),wn(s,a,i),ho(i.stateNode),mt=c,is=f;break;case 5:Ct||Zs(i,a);case 6:if(c=mt,f=is,mt=null,wn(s,a,i),mt=c,is=f,mt!==null)if(is)try{(mt.nodeType===9?mt.body:mt.nodeName==="HTML"?mt.ownerDocument.body:mt).removeChild(i.stateNode)}catch(g){tt(i,a,g)}else try{mt.removeChild(i.stateNode)}catch(g){tt(i,a,g)}break;case 18:mt!==null&&(is?(s=mt,ex(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,i.stateNode),Gr(s)):ex(mt,i.stateNode));break;case 4:c=mt,f=is,mt=i.stateNode.containerInfo,is=!0,wn(s,a,i),mt=c,is=f;break;case 0:case 11:case 14:case 15:Gn(2,i,a),Ct||Gn(4,i,a),wn(s,a,i);break;case 1:Ct||(Zs(i,a),c=i.stateNode,typeof c.componentWillUnmount=="function"&&tv(i,a,c)),wn(s,a,i);break;case 21:wn(s,a,i);break;case 22:Ct=(c=Ct)||i.memoizedState!==null,wn(s,a,i),Ct=c;break;default:wn(s,a,i)}}function cv(s,a){if(a.memoizedState===null&&(s=a.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Gr(s)}catch(i){tt(a,a.return,i)}}}function uv(s,a){if(a.memoizedState===null&&(s=a.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Gr(s)}catch(i){tt(a,a.return,i)}}function tN(s){switch(s.tag){case 31:case 13:case 19:var a=s.stateNode;return a===null&&(a=s.stateNode=new rv),a;case 22:return s=s.stateNode,a=s._retryCache,a===null&&(a=s._retryCache=new rv),a;default:throw Error(r(435,s.tag))}}function Zl(s,a){var i=tN(s);a.forEach(function(c){if(!i.has(c)){i.add(c);var f=uN.bind(null,s,c);c.then(f,f)}})}function os(s,a){var i=a.deletions;if(i!==null)for(var c=0;c<i.length;c++){var f=i[c],g=s,b=a,N=b;e:for(;N!==null;){switch(N.tag){case 27:if(Qn(N.type)){mt=N.stateNode,is=!1;break e}break;case 5:mt=N.stateNode,is=!1;break e;case 3:case 4:mt=N.stateNode.containerInfo,is=!0;break e}N=N.return}if(mt===null)throw Error(r(160));lv(g,b,f),mt=null,is=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)dv(a,s),a=a.sibling}var Us=null;function dv(s,a){var i=s.alternate,c=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:os(a,s),ls(s),c&4&&(Gn(3,s,s.return),to(3,s),Gn(5,s,s.return));break;case 1:os(a,s),ls(s),c&512&&(Ct||i===null||Zs(i,i.return)),c&64&&bn&&(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 f=Us;if(os(a,s),ls(s),c&512&&(Ct||i===null||Zs(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,f=f.ownerDocument||f;t:switch(c){case"title":g=f.getElementsByTagName("title")[0],(!g||g[Ci]||g[Bt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(c),f.head.insertBefore(g,f.querySelector("head > title"))),qt(g,c,i),g[Bt]=s,Lt(g),c=g;break e;case"link":var b=dx("link","href",f).get(c+(i.href||""));if(b){for(var N=0;N<b.length;N++)if(g=b[N],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)){b.splice(N,1);break t}}g=f.createElement(c),qt(g,c,i),f.head.appendChild(g);break;case"meta":if(b=dx("meta","content",f).get(c+(i.content||""))){for(N=0;N<b.length;N++)if(g=b[N],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)){b.splice(N,1);break t}}g=f.createElement(c),qt(g,c,i),f.head.appendChild(g);break;default:throw Error(r(468,c))}g[Bt]=s,Lt(g),c=g}s.stateNode=c}else hx(f,s.type,s.stateNode);else s.stateNode=ux(f,c,s.memoizedProps);else g!==c?(g===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):g.count--,c===null?hx(f,s.type,s.stateNode):ux(f,c,s.memoizedProps)):c===null&&s.stateNode!==null&&dh(s,s.memoizedProps,i.memoizedProps)}break;case 27:os(a,s),ls(s),c&512&&(Ct||i===null||Zs(i,i.return)),i!==null&&c&4&&dh(s,s.memoizedProps,i.memoizedProps);break;case 5:if(os(a,s),ls(s),c&512&&(Ct||i===null||Zs(i,i.return)),s.flags&32){f=s.stateNode;try{mr(f,"")}catch(we){tt(s,s.return,we)}}c&4&&s.stateNode!=null&&(f=s.memoizedProps,dh(s,f,i!==null?i.memoizedProps:f)),c&1024&&(mh=!0);break;case 6:if(os(a,s),ls(s),c&4){if(s.stateNode===null)throw Error(r(162));c=s.memoizedProps,i=s.stateNode;try{i.nodeValue=c}catch(we){tt(s,s.return,we)}}break;case 3:if(pc=null,f=Us,Us=fc(a.containerInfo),os(a,s),Us=f,ls(s),c&4&&i!==null&&i.memoizedState.isDehydrated)try{Gr(a.containerInfo)}catch(we){tt(s,s.return,we)}mh&&(mh=!1,hv(s));break;case 4:c=Us,Us=fc(s.stateNode.containerInfo),os(a,s),ls(s),Us=c;break;case 12:os(a,s),ls(s);break;case 31:os(a,s),ls(s),c&4&&(c=s.updateQueue,c!==null&&(s.updateQueue=null,Zl(s,c)));break;case 13:os(a,s),ls(s),s.child.flags&8192&&s.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(tc=I()),c&4&&(c=s.updateQueue,c!==null&&(s.updateQueue=null,Zl(s,c)));break;case 22:f=s.memoizedState!==null;var O=i!==null&&i.memoizedState!==null,K=bn,Q=Ct;if(bn=K||f,Ct=Q||O,os(a,s),Ct=Q,bn=K,ls(s),c&8192)e:for(a=s.stateNode,a._visibility=f?a._visibility&-2:a._visibility|1,f&&(i===null||O||bn||Ct||za(s)),i=null,a=s;;){if(a.tag===5||a.tag===26){if(i===null){O=i=a;try{if(g=O.stateNode,f)b=g.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{N=O.stateNode;var te=O.memoizedProps.style,Y=te!=null&&te.hasOwnProperty("display")?te.display:null;N.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(we){tt(O,O.return,we)}}}else if(a.tag===6){if(i===null){O=a;try{O.stateNode.nodeValue=f?"":O.memoizedProps}catch(we){tt(O,O.return,we)}}}else if(a.tag===18){if(i===null){O=a;try{var W=O.stateNode;f?tx(W,!0):tx(O.stateNode,!1)}catch(we){tt(O,O.return,we)}}}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,Zl(s,i))));break;case 19:os(a,s),ls(s),c&4&&(c=s.updateQueue,c!==null&&(s.updateQueue=null,Zl(s,c)));break;case 30:break;case 21:break;default:os(a,s),ls(s)}}function ls(s){var a=s.flags;if(a&2){try{for(var i,c=s.return;c!==null;){if(nv(c)){i=c;break}c=c.return}if(i==null)throw Error(r(160));switch(i.tag){case 27:var f=i.stateNode,g=hh(s);Ql(s,g,f);break;case 5:var b=i.stateNode;i.flags&32&&(mr(b,""),i.flags&=-33);var N=hh(s);Ql(s,N,b);break;case 3:case 4:var O=i.stateNode.containerInfo,K=hh(s);fh(s,K,O);break;default:throw Error(r(161))}}catch(Q){tt(s,s.return,Q)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function hv(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var a=s;hv(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),s=s.sibling}}function Sn(s,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)iv(s,a.alternate,a),a=a.sibling}function za(s){for(s=s.child;s!==null;){var a=s;switch(a.tag){case 0:case 11:case 14:case 15:Gn(4,a,a.return),za(a);break;case 1:Zs(a,a.return);var i=a.stateNode;typeof i.componentWillUnmount=="function"&&tv(a,a.return,i),za(a);break;case 27:ho(a.stateNode);case 26:case 5:Zs(a,a.return),za(a);break;case 22:a.memoizedState===null&&za(a);break;case 30:za(a);break;default:za(a)}s=s.sibling}}function jn(s,a,i){for(i=i&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var c=a.alternate,f=s,g=a,b=g.flags;switch(g.tag){case 0:case 11:case 15:jn(f,g,i),to(4,g);break;case 1:if(jn(f,g,i),c=g,f=c.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(K){tt(c,c.return,K)}if(c=g,f=c.updateQueue,f!==null){var N=c.stateNode;try{var O=f.shared.hiddenCallbacks;if(O!==null)for(f.shared.hiddenCallbacks=null,f=0;f<O.length;f++)qg(O[f],N)}catch(K){tt(c,c.return,K)}}i&&b&64&&ev(g),so(g,g.return);break;case 27:av(g);case 26:case 5:jn(f,g,i),i&&c===null&&b&4&&sv(g),so(g,g.return);break;case 12:jn(f,g,i);break;case 31:jn(f,g,i),i&&b&4&&cv(f,g);break;case 13:jn(f,g,i),i&&b&4&&uv(f,g);break;case 22:g.memoizedState===null&&jn(f,g,i),so(g,g.return);break;case 30:break;default:jn(f,g,i)}a=a.sibling}}function ph(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&&$i(i))}function gh(s,a){s=null,a.alternate!==null&&(s=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==s&&(a.refCount++,s!=null&&$i(s))}function Bs(s,a,i,c){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)fv(s,a,i,c),a=a.sibling}function fv(s,a,i,c){var f=a.flags;switch(a.tag){case 0:case 11:case 15:Bs(s,a,i,c),f&2048&&to(9,a);break;case 1:Bs(s,a,i,c);break;case 3:Bs(s,a,i,c),f&2048&&(s=null,a.alternate!==null&&(s=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==s&&(a.refCount++,s!=null&&$i(s)));break;case 12:if(f&2048){Bs(s,a,i,c),s=a.stateNode;try{var g=a.memoizedProps,b=g.id,N=g.onPostCommit;typeof N=="function"&&N(b,a.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(O){tt(a,a.return,O)}}else Bs(s,a,i,c);break;case 31:Bs(s,a,i,c);break;case 13:Bs(s,a,i,c);break;case 23:break;case 22:g=a.stateNode,b=a.alternate,a.memoizedState!==null?g._visibility&2?Bs(s,a,i,c):no(s,a):g._visibility&2?Bs(s,a,i,c):(g._visibility|=2,Dr(s,a,i,c,(a.subtreeFlags&10256)!==0||!1)),f&2048&&ph(b,a);break;case 24:Bs(s,a,i,c),f&2048&&gh(a.alternate,a);break;default:Bs(s,a,i,c)}}function Dr(s,a,i,c,f){for(f=f&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var g=s,b=a,N=i,O=c,K=b.flags;switch(b.tag){case 0:case 11:case 15:Dr(g,b,N,O,f),to(8,b);break;case 23:break;case 22:var Q=b.stateNode;b.memoizedState!==null?Q._visibility&2?Dr(g,b,N,O,f):no(g,b):(Q._visibility|=2,Dr(g,b,N,O,f)),f&&K&2048&&ph(b.alternate,b);break;case 24:Dr(g,b,N,O,f),f&&K&2048&&gh(b.alternate,b);break;default:Dr(g,b,N,O,f)}a=a.sibling}}function no(s,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var i=s,c=a,f=c.flags;switch(c.tag){case 22:no(i,c),f&2048&&ph(c.alternate,c);break;case 24:no(i,c),f&2048&&gh(c.alternate,c);break;default:no(i,c)}a=a.sibling}}var ao=8192;function Pr(s,a,i){if(s.subtreeFlags&ao)for(s=s.child;s!==null;)mv(s,a,i),s=s.sibling}function mv(s,a,i){switch(s.tag){case 26:Pr(s,a,i),s.flags&ao&&s.memoizedState!==null&&VN(i,Us,s.memoizedState,s.memoizedProps);break;case 5:Pr(s,a,i);break;case 3:case 4:var c=Us;Us=fc(s.stateNode.containerInfo),Pr(s,a,i),Us=c;break;case 22:s.memoizedState===null&&(c=s.alternate,c!==null&&c.memoizedState!==null?(c=ao,ao=16777216,Pr(s,a,i),ao=c):Pr(s,a,i));break;default:Pr(s,a,i)}}function pv(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 ro(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];zt=c,yv(c,s)}pv(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)gv(s),s=s.sibling}function gv(s){switch(s.tag){case 0:case 11:case 15:ro(s),s.flags&2048&&Gn(9,s,s.return);break;case 3:ro(s);break;case 12:ro(s);break;case 22:var a=s.stateNode;s.memoizedState!==null&&a._visibility&2&&(s.return===null||s.return.tag!==13)?(a._visibility&=-3,ec(s)):ro(s);break;default:ro(s)}}function ec(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];zt=c,yv(c,s)}pv(s)}for(s=s.child;s!==null;){switch(a=s,a.tag){case 0:case 11:case 15:Gn(8,a,a.return),ec(a);break;case 22:i=a.stateNode,i._visibility&2&&(i._visibility&=-3,ec(a));break;default:ec(a)}s=s.sibling}}function yv(s,a){for(;zt!==null;){var i=zt;switch(i.tag){case 0:case 11:case 15:Gn(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:$i(i.memoizedState.cache)}if(c=i.child,c!==null)c.return=i,zt=c;else e:for(i=s;zt!==null;){c=zt;var f=c.sibling,g=c.return;if(ov(c),c===i){zt=null;break e}if(f!==null){f.return=g,zt=f;break e}zt=g}}}var sN={getCacheForType:function(s){var a=Vt(kt),i=a.data.get(s);return i===void 0&&(i=s(),a.data.set(s,i)),i},cacheSignal:function(){return Vt(kt).controller.signal}},nN=typeof WeakMap=="function"?WeakMap:Map,Ze=0,ot=null,Ve=null,He=0,et=0,xs=null,Fn=!1,Lr=!1,yh=!1,_n=0,vt=0,Kn=0,Ua=0,vh=0,bs=0,zr=0,io=null,cs=null,xh=!1,tc=0,vv=0,sc=1/0,nc=null,Yn=null,Ot=0,Wn=null,Ur=null,Nn=0,bh=0,wh=null,xv=null,oo=0,Sh=null;function ws(){return(Ze&2)!==0&&He!==0?He&-He:V.T!==null?Eh():Pp()}function bv(){if(bs===0)if((He&536870912)===0||Ke){var s=dl;dl<<=1,(dl&3932160)===0&&(dl=262144),bs=s}else bs=536870912;return s=ys.current,s!==null&&(s.flags|=32),bs}function us(s,a,i){(s===ot&&(et===2||et===9)||s.cancelPendingCommit!==null)&&(Br(s,0),Xn(s,He,bs,!1)),Ei(s,i),((Ze&2)===0||s!==ot)&&(s===ot&&((Ze&2)===0&&(Ua|=i),vt===4&&Xn(s,He,bs,!1)),en(s))}function wv(s,a,i){if((Ze&6)!==0)throw Error(r(327));var c=!i&&(a&127)===0&&(a&s.expiredLanes)===0||Ti(s,a),f=c?iN(s,a):_h(s,a,!0),g=c;do{if(f===0){Lr&&!c&&Xn(s,a,0,!1);break}else{if(i=s.current.alternate,g&&!aN(i)){f=_h(s,a,!1),g=!1;continue}if(f===2){if(g=a,s.errorRecoveryDisabledLanes&g)var b=0;else b=s.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){a=b;e:{var N=s;f=io;var O=N.current.memoizedState.isDehydrated;if(O&&(Br(N,b).flags|=256),b=_h(N,b,!1),b!==2){if(yh&&!O){N.errorRecoveryDisabledLanes|=g,Ua|=g,f=4;break e}g=cs,cs=f,g!==null&&(cs===null?cs=g:cs.push.apply(cs,g))}f=b}if(g=!1,f!==2)continue}}if(f===1){Br(s,0),Xn(s,a,0,!0);break}e:{switch(c=s,g=f,g){case 0:case 1:throw Error(r(345));case 4:if((a&4194048)!==a)break;case 6:Xn(c,a,bs,!Fn);break e;case 2:cs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((a&62914560)===a&&(f=tc+300-I(),10<f)){if(Xn(c,a,bs,!Fn),fl(c,0,!0)!==0)break e;Nn=a,c.timeoutHandle=Qv(Sv.bind(null,c,i,cs,nc,xh,a,bs,Ua,zr,Fn,g,"Throttled",-0,0),f);break e}Sv(c,i,cs,nc,xh,a,bs,Ua,zr,Fn,g,null,-0,0)}}break}while(!0);en(s)}function Sv(s,a,i,c,f,g,b,N,O,K,Q,te,Y,W){if(s.timeoutHandle=-1,te=a.subtreeFlags,te&8192||(te&16785408)===16785408){te={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:un},mv(a,g,te);var we=(g&62914560)===g?tc-I():(g&4194048)===g?vv-I():0;if(we=$N(te,we),we!==null){Nn=g,s.cancelPendingCommit=we(Av.bind(null,s,a,g,i,c,f,b,N,O,Q,te,null,Y,W)),Xn(s,g,b,!K);return}}Av(s,a,g,i,c,f,b,N,O)}function aN(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 f=i[c],g=f.getSnapshot;f=f.value;try{if(!ps(g(),f))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 Xn(s,a,i,c){a&=~vh,a&=~Ua,s.suspendedLanes|=a,s.pingedLanes&=~a,c&&(s.warmLanes|=a),c=s.expirationTimes;for(var f=a;0<f;){var g=31-ms(f),b=1<<g;c[g]=-1,f&=~b}i!==0&&Op(s,i,a)}function ac(){return(Ze&6)===0?(lo(0),!1):!0}function jh(){if(Ve!==null){if(et===0)var s=Ve.return;else s=Ve,mn=Ca=null,Bd(s),Cr=null,Hi=0,s=Ve;for(;s!==null;)Zy(s.alternate,s),s=s.return;Ve=null}}function Br(s,a){var i=s.timeoutHandle;i!==-1&&(s.timeoutHandle=-1,_N(i)),i=s.cancelPendingCommit,i!==null&&(s.cancelPendingCommit=null,i()),Nn=0,jh(),ot=s,Ve=i=hn(s.current,null),He=a,et=0,xs=null,Fn=!1,Lr=Ti(s,a),yh=!1,zr=bs=vh=Ua=Kn=vt=0,cs=io=null,xh=!1,(a&8)!==0&&(a|=a&32);var c=s.entangledLanes;if(c!==0)for(s=s.entanglements,c&=a;0<c;){var f=31-ms(c),g=1<<f;a|=s[f],c&=~g}return _n=a,Nl(),i}function jv(s,a){Le=null,V.H=Qi,a===Er||a===Ml?(a=Bg(),et=3):a===Td?(a=Bg(),et=4):et=a===th?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,xs=a,Ve===null&&(vt=1,Kl(s,Ts(a,s.current)))}function _v(){var s=ys.current;return s===null?!0:(He&4194048)===He?Rs===null:(He&62914560)===He||(He&536870912)!==0?s===Rs:!1}function Nv(){var s=V.H;return V.H=Qi,s===null?Qi:s}function kv(){var s=V.A;return V.A=sN,s}function rc(){vt=4,Fn||(He&4194048)!==He&&ys.current!==null||(Lr=!0),(Kn&134217727)===0&&(Ua&134217727)===0||ot===null||Xn(ot,He,bs,!1)}function _h(s,a,i){var c=Ze;Ze|=2;var f=Nv(),g=kv();(ot!==s||He!==a)&&(nc=null,Br(s,a)),a=!1;var b=vt;e:do try{if(et!==0&&Ve!==null){var N=Ve,O=xs;switch(et){case 8:jh(),b=6;break e;case 3:case 2:case 9:case 6:ys.current===null&&(a=!0);var K=et;if(et=0,xs=null,Ir(s,N,O,K),i&&Lr){b=0;break e}break;default:K=et,et=0,xs=null,Ir(s,N,O,K)}}rN(),b=vt;break}catch(Q){jv(s,Q)}while(!0);return a&&s.shellSuspendCounter++,mn=Ca=null,Ze=c,V.H=f,V.A=g,Ve===null&&(ot=null,He=0,Nl()),b}function rN(){for(;Ve!==null;)Tv(Ve)}function iN(s,a){var i=Ze;Ze|=2;var c=Nv(),f=kv();ot!==s||He!==a?(nc=null,sc=I()+500,Br(s,a)):Lr=Ti(s,a);e:do try{if(et!==0&&Ve!==null){a=Ve;var g=xs;t:switch(et){case 1:et=0,xs=null,Ir(s,a,g,1);break;case 2:case 9:if(zg(g)){et=0,xs=null,Ev(a);break}a=function(){et!==2&&et!==9||ot!==s||(et=7),en(s)},g.then(a,a);break e;case 3:et=7;break e;case 4:et=5;break e;case 7:zg(g)?(et=0,xs=null,Ev(a)):(et=0,xs=null,Ir(s,a,g,7));break;case 5:var b=null;switch(Ve.tag){case 26:b=Ve.memoizedState;case 5:case 27:var N=Ve;if(b?fx(b):N.stateNode.complete){et=0,xs=null;var O=N.sibling;if(O!==null)Ve=O;else{var K=N.return;K!==null?(Ve=K,ic(K)):Ve=null}break t}}et=0,xs=null,Ir(s,a,g,5);break;case 6:et=0,xs=null,Ir(s,a,g,6);break;case 8:jh(),vt=6;break e;default:throw Error(r(462))}}oN();break}catch(Q){jv(s,Q)}while(!0);return mn=Ca=null,V.H=c,V.A=f,Ze=i,Ve!==null?0:(ot=null,He=0,Nl(),vt)}function oN(){for(;Ve!==null&&!ki();)Tv(Ve)}function Tv(s){var a=Jy(s.alternate,s,_n);s.memoizedProps=s.pendingProps,a===null?ic(s):Ve=a}function Ev(s){var a=s,i=a.alternate;switch(a.tag){case 15:case 0:a=Gy(i,a,a.pendingProps,a.type,void 0,He);break;case 11:a=Gy(i,a,a.pendingProps,a.type.render,a.ref,He);break;case 5:Bd(a);default:Zy(i,a),a=Ve=kg(a,_n),a=Jy(i,a,_n)}s.memoizedProps=s.pendingProps,a===null?ic(s):Ve=a}function Ir(s,a,i,c){mn=Ca=null,Bd(a),Cr=null,Hi=0;var f=a.return;try{if(W_(s,f,a,i,He)){vt=1,Kl(s,Ts(i,s.current)),Ve=null;return}}catch(g){if(f!==null)throw Ve=f,g;vt=1,Kl(s,Ts(i,s.current)),Ve=null;return}a.flags&32768?(Ke||c===1?s=!0:Lr||(He&536870912)!==0?s=!1:(Fn=s=!0,(c===2||c===9||c===3||c===6)&&(c=ys.current,c!==null&&c.tag===13&&(c.flags|=16384))),Cv(a,s)):ic(a)}function ic(s){var a=s;do{if((a.flags&32768)!==0){Cv(a,Fn);return}s=a.return;var i=Q_(a.alternate,a,_n);if(i!==null){Ve=i;return}if(a=a.sibling,a!==null){Ve=a;return}Ve=a=s}while(a!==null);vt===0&&(vt=5)}function Cv(s,a){do{var i=Z_(s.alternate,s);if(i!==null){i.flags&=32767,Ve=i;return}if(i=s.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!a&&(s=s.sibling,s!==null)){Ve=s;return}Ve=s=i}while(s!==null);vt=6,Ve=null}function Av(s,a,i,c,f,g,b,N,O){s.cancelPendingCommit=null;do oc();while(Ot!==0);if((Ze&6)!==0)throw Error(r(327));if(a!==null){if(a===s.current)throw Error(r(177));if(g=a.lanes|a.childLanes,g|=hd,Ij(s,i,g,b,N,O),s===ot&&(Ve=ot=null,He=0),Ur=a,Wn=s,Nn=i,bh=g,wh=f,xv=c,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,dN(pt,function(){return Pv(),null})):(s.callbackNode=null,s.callbackPriority=0),c=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||c){c=V.T,V.T=null,f=F.p,F.p=2,b=Ze,Ze|=4;try{eN(s,a,i)}finally{Ze=b,F.p=f,V.T=c}}Ot=1,Rv(),Ov(),Mv()}}function Rv(){if(Ot===1){Ot=0;var s=Wn,a=Ur,i=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||i){i=V.T,V.T=null;var c=F.p;F.p=2;var f=Ze;Ze|=4;try{dv(a,s);var g=Lh,b=yg(s.containerInfo),N=g.focusedElem,O=g.selectionRange;if(b!==N&&N&&N.ownerDocument&&gg(N.ownerDocument.documentElement,N)){if(O!==null&&od(N)){var K=O.start,Q=O.end;if(Q===void 0&&(Q=K),"selectionStart"in N)N.selectionStart=K,N.selectionEnd=Math.min(Q,N.value.length);else{var te=N.ownerDocument||document,Y=te&&te.defaultView||window;if(Y.getSelection){var W=Y.getSelection(),we=N.textContent.length,Ce=Math.min(O.start,we),at=O.end===void 0?Ce:Math.min(O.end,we);!W.extend&&Ce>at&&(b=at,at=Ce,Ce=b);var q=pg(N,Ce),z=pg(N,at);if(q&&z&&(W.rangeCount!==1||W.anchorNode!==q.node||W.anchorOffset!==q.offset||W.focusNode!==z.node||W.focusOffset!==z.offset)){var G=te.createRange();G.setStart(q.node,q.offset),W.removeAllRanges(),Ce>at?(W.addRange(G),W.extend(z.node,z.offset)):(G.setEnd(z.node,z.offset),W.addRange(G))}}}}for(te=[],W=N;W=W.parentNode;)W.nodeType===1&&te.push({element:W,left:W.scrollLeft,top:W.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<te.length;N++){var ee=te[N];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}xc=!!Ph,Lh=Ph=null}finally{Ze=f,F.p=c,V.T=i}}s.current=a,Ot=2}}function Ov(){if(Ot===2){Ot=0;var s=Wn,a=Ur,i=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||i){i=V.T,V.T=null;var c=F.p;F.p=2;var f=Ze;Ze|=4;try{iv(s,a.alternate,a)}finally{Ze=f,F.p=c,V.T=i}}Ot=3}}function Mv(){if(Ot===4||Ot===3){Ot=0,Bu();var s=Wn,a=Ur,i=Nn,c=xv;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Ot=5:(Ot=0,Ur=Wn=null,Dv(s,s.pendingLanes));var f=s.pendingLanes;if(f===0&&(Yn=null),$u(i),a=a.stateNode,Yt&&typeof Yt.onCommitFiberRoot=="function")try{Yt.onCommitFiberRoot(Mn,a,void 0,(a.current.flags&128)===128)}catch{}if(c!==null){a=V.T,f=F.p,F.p=2,V.T=null;try{for(var g=s.onRecoverableError,b=0;b<c.length;b++){var N=c[b];g(N.value,{componentStack:N.stack})}}finally{V.T=a,F.p=f}}(Nn&3)!==0&&oc(),en(s),f=s.pendingLanes,(i&261930)!==0&&(f&42)!==0?s===Sh?oo++:(oo=0,Sh=s):oo=0,lo(0)}}function Dv(s,a){(s.pooledCacheLanes&=a)===0&&(a=s.pooledCache,a!=null&&(s.pooledCache=null,$i(a)))}function oc(){return Rv(),Ov(),Mv(),Pv()}function Pv(){if(Ot!==5)return!1;var s=Wn,a=bh;bh=0;var i=$u(Nn),c=V.T,f=F.p;try{F.p=32>i?32:i,V.T=null,i=wh,wh=null;var g=Wn,b=Nn;if(Ot=0,Ur=Wn=null,Nn=0,(Ze&6)!==0)throw Error(r(331));var N=Ze;if(Ze|=4,gv(g.current),fv(g,g.current,b,i),Ze=N,lo(0,!1),Yt&&typeof Yt.onPostCommitFiberRoot=="function")try{Yt.onPostCommitFiberRoot(Mn,g)}catch{}return!0}finally{F.p=f,V.T=c,Dv(s,a)}}function Lv(s,a,i){a=Ts(i,a),a=eh(s.stateNode,a,2),s=$n(s,a,2),s!==null&&(Ei(s,2),en(s))}function tt(s,a,i){if(s.tag===3)Lv(s,s,i);else for(;a!==null;){if(a.tag===3){Lv(a,s,i);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Yn===null||!Yn.has(c))){s=Ts(i,s),i=zy(2),c=$n(a,i,2),c!==null&&(Uy(i,c,a,s),Ei(c,2),en(c));break}}a=a.return}}function Nh(s,a,i){var c=s.pingCache;if(c===null){c=s.pingCache=new nN;var f=new Set;c.set(a,f)}else f=c.get(a),f===void 0&&(f=new Set,c.set(a,f));f.has(i)||(yh=!0,f.add(i),s=lN.bind(null,s,a,i),a.then(s,s))}function lN(s,a,i){var c=s.pingCache;c!==null&&c.delete(a),s.pingedLanes|=s.suspendedLanes&i,s.warmLanes&=~i,ot===s&&(He&i)===i&&(vt===4||vt===3&&(He&62914560)===He&&300>I()-tc?(Ze&2)===0&&Br(s,0):vh|=i,zr===He&&(zr=0)),en(s)}function zv(s,a){a===0&&(a=Rp()),s=ka(s,a),s!==null&&(Ei(s,a),en(s))}function cN(s){var a=s.memoizedState,i=0;a!==null&&(i=a.retryLane),zv(s,i)}function uN(s,a){var i=0;switch(s.tag){case 31:case 13:var c=s.stateNode,f=s.memoizedState;f!==null&&(i=f.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),zv(s,i)}function dN(s,a){return Ws(s,a)}var lc=null,Vr=null,kh=!1,cc=!1,Th=!1,Jn=0;function en(s){s!==Vr&&s.next===null&&(Vr===null?lc=Vr=s:Vr=Vr.next=s),cc=!0,kh||(kh=!0,fN())}function lo(s,a){if(!Th&&cc){Th=!0;do for(var i=!1,c=lc;c!==null;){if(s!==0){var f=c.pendingLanes;if(f===0)var g=0;else{var b=c.suspendedLanes,N=c.pingedLanes;g=(1<<31-ms(42|s)+1)-1,g&=f&~(b&~N),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(i=!0,Vv(c,g))}else g=He,g=fl(c,c===ot?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||Ti(c,g)||(i=!0,Vv(c,g));c=c.next}while(i);Th=!1}}function hN(){Uv()}function Uv(){cc=kh=!1;var s=0;Jn!==0&&jN()&&(s=Jn);for(var a=I(),i=null,c=lc;c!==null;){var f=c.next,g=Bv(c,a);g===0?(c.next=null,i===null?lc=f:i.next=f,f===null&&(Vr=i)):(i=c,(s!==0||(g&3)!==0)&&(cc=!0)),c=f}Ot!==0&&Ot!==5||lo(s),Jn!==0&&(Jn=0)}function Bv(s,a){for(var i=s.suspendedLanes,c=s.pingedLanes,f=s.expirationTimes,g=s.pendingLanes&-62914561;0<g;){var b=31-ms(g),N=1<<b,O=f[b];O===-1?((N&i)===0||(N&c)!==0)&&(f[b]=Bj(N,a)):O<=a&&(s.expiredLanes|=N),g&=~N}if(a=ot,i=He,i=fl(s,s===a?i:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),c=s.callbackNode,i===0||s===a&&(et===2||et===9)||s.cancelPendingCommit!==null)return c!==null&&c!==null&&Ni(c),s.callbackNode=null,s.callbackPriority=0;if((i&3)===0||Ti(s,i)){if(a=i&-i,a===s.callbackPriority)return a;switch(c!==null&&Ni(c),$u(i)){case 2:case 8:i=qe;break;case 32:i=pt;break;case 268435456:i=Ie;break;default:i=pt}return c=Iv.bind(null,s),i=Ws(i,c),s.callbackPriority=a,s.callbackNode=i,a}return c!==null&&c!==null&&Ni(c),s.callbackPriority=2,s.callbackNode=null,2}function Iv(s,a){if(Ot!==0&&Ot!==5)return s.callbackNode=null,s.callbackPriority=0,null;var i=s.callbackNode;if(oc()&&s.callbackNode!==i)return null;var c=He;return c=fl(s,s===ot?c:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),c===0?null:(wv(s,c,a),Bv(s,I()),s.callbackNode!=null&&s.callbackNode===i?Iv.bind(null,s):null)}function Vv(s,a){if(oc())return null;wv(s,a,!0)}function fN(){NN(function(){(Ze&6)!==0?Ws(Pe,hN):Uv()})}function Eh(){if(Jn===0){var s=kr;s===0&&(s=ul,ul<<=1,(ul&261888)===0&&(ul=256)),Jn=s}return Jn}function $v(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:yl(""+s)}function qv(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 mN(s,a,i,c,f){if(a==="submit"&&i&&i.stateNode===f){var g=$v((f[as]||null).action),b=c.submitter;b&&(a=(a=b[as]||null)?$v(a.formAction):b.getAttribute("formAction"),a!==null&&(g=a,b=null));var N=new wl("action","action",null,c,f);s.push({event:N,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Jn!==0){var O=b?qv(f,b):new FormData(f);Yd(i,{pending:!0,data:O,method:f.method,action:g},null,O)}}else typeof g=="function"&&(N.preventDefault(),O=b?qv(f,b):new FormData(f),Yd(i,{pending:!0,data:O,method:f.method,action:g},g,O))},currentTarget:f}]})}}for(var Ch=0;Ch<dd.length;Ch++){var Ah=dd[Ch],pN=Ah.toLowerCase(),gN=Ah[0].toUpperCase()+Ah.slice(1);zs(pN,"on"+gN)}zs(bg,"onAnimationEnd"),zs(wg,"onAnimationIteration"),zs(Sg,"onAnimationStart"),zs("dblclick","onDoubleClick"),zs("focusin","onFocus"),zs("focusout","onBlur"),zs(O_,"onTransitionRun"),zs(M_,"onTransitionStart"),zs(D_,"onTransitionCancel"),zs(jg,"onTransitionEnd"),hr("onMouseEnter",["mouseout","mouseover"]),hr("onMouseLeave",["mouseout","mouseover"]),hr("onPointerEnter",["pointerout","pointerover"]),hr("onPointerLeave",["pointerout","pointerover"]),Sa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Sa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Sa("onBeforeInput",["compositionend","keypress","textInput","paste"]),Sa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Sa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Sa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var co="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(" "),yN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(co));function Hv(s,a){a=(a&4)!==0;for(var i=0;i<s.length;i++){var c=s[i],f=c.event;c=c.listeners;e:{var g=void 0;if(a)for(var b=c.length-1;0<=b;b--){var N=c[b],O=N.instance,K=N.currentTarget;if(N=N.listener,O!==g&&f.isPropagationStopped())break e;g=N,f.currentTarget=K;try{g(f)}catch(Q){_l(Q)}f.currentTarget=null,g=O}else for(b=0;b<c.length;b++){if(N=c[b],O=N.instance,K=N.currentTarget,N=N.listener,O!==g&&f.isPropagationStopped())break e;g=N,f.currentTarget=K;try{g(f)}catch(Q){_l(Q)}f.currentTarget=null,g=O}}}}function $e(s,a){var i=a[qu];i===void 0&&(i=a[qu]=new Set);var c=s+"__bubble";i.has(c)||(Gv(a,s,2,!1),i.add(c))}function Rh(s,a,i){var c=0;a&&(c|=4),Gv(i,s,c,a)}var uc="_reactListening"+Math.random().toString(36).slice(2);function Oh(s){if(!s[uc]){s[uc]=!0,Up.forEach(function(i){i!=="selectionchange"&&(yN.has(i)||Rh(i,!1,s),Rh(i,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[uc]||(a[uc]=!0,Rh("selectionchange",!1,a))}}function Gv(s,a,i,c){switch(bx(a)){case 2:var f=GN;break;case 8:f=FN;break;default:f=Kh}i=f.bind(null,a,i,s),f=void 0,!Qu||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(f=!0),c?f!==void 0?s.addEventListener(a,i,{capture:!0,passive:f}):s.addEventListener(a,i,!0):f!==void 0?s.addEventListener(a,i,{passive:f}):s.addEventListener(a,i,!1)}function Mh(s,a,i,c,f){var g=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var b=c.tag;if(b===3||b===4){var N=c.stateNode.containerInfo;if(N===f)break;if(b===4)for(b=c.return;b!==null;){var O=b.tag;if((O===3||O===4)&&b.stateNode.containerInfo===f)return;b=b.return}for(;N!==null;){if(b=cr(N),b===null)return;if(O=b.tag,O===5||O===6||O===26||O===27){c=g=b;continue e}N=N.parentNode}}c=c.return}Xp(function(){var K=g,Q=Xu(i),te=[];e:{var Y=_g.get(s);if(Y!==void 0){var W=wl,we=s;switch(s){case"keypress":if(xl(i)===0)break e;case"keydown":case"keyup":W=u_;break;case"focusin":we="focus",W=sd;break;case"focusout":we="blur",W=sd;break;case"beforeblur":case"afterblur":W=sd;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":W=Zp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":W=Qj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":W=f_;break;case bg:case wg:case Sg:W=t_;break;case jg:W=p_;break;case"scroll":case"scrollend":W=Xj;break;case"wheel":W=y_;break;case"copy":case"cut":case"paste":W=n_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":W=tg;break;case"toggle":case"beforetoggle":W=x_}var Ce=(a&4)!==0,at=!Ce&&(s==="scroll"||s==="scrollend"),q=Ce?Y!==null?Y+"Capture":null:Y;Ce=[];for(var z=K,G;z!==null;){var ee=z;if(G=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||G===null||q===null||(ee=Ri(z,q),ee!=null&&Ce.push(uo(z,ee,G))),at)break;z=z.return}0<Ce.length&&(Y=new W(Y,we,null,i,Q),te.push({event:Y,listeners:Ce}))}}if((a&7)===0){e:{if(Y=s==="mouseover"||s==="pointerover",W=s==="mouseout"||s==="pointerout",Y&&i!==Wu&&(we=i.relatedTarget||i.fromElement)&&(cr(we)||we[lr]))break e;if((W||Y)&&(Y=Q.window===Q?Q:(Y=Q.ownerDocument)?Y.defaultView||Y.parentWindow:window,W?(we=i.relatedTarget||i.toElement,W=K,we=we?cr(we):null,we!==null&&(at=u(we),Ce=we.tag,we!==at||Ce!==5&&Ce!==27&&Ce!==6)&&(we=null)):(W=null,we=K),W!==we)){if(Ce=Zp,ee="onMouseLeave",q="onMouseEnter",z="mouse",(s==="pointerout"||s==="pointerover")&&(Ce=tg,ee="onPointerLeave",q="onPointerEnter",z="pointer"),at=W==null?Y:Ai(W),G=we==null?Y:Ai(we),Y=new Ce(ee,z+"leave",W,i,Q),Y.target=at,Y.relatedTarget=G,ee=null,cr(Q)===K&&(Ce=new Ce(q,z+"enter",we,i,Q),Ce.target=G,Ce.relatedTarget=at,ee=Ce),at=ee,W&&we)t:{for(Ce=vN,q=W,z=we,G=0,ee=q;ee;ee=Ce(ee))G++;ee=0;for(var Ee=z;Ee;Ee=Ce(Ee))ee++;for(;0<G-ee;)q=Ce(q),G--;for(;0<ee-G;)z=Ce(z),ee--;for(;G--;){if(q===z||z!==null&&q===z.alternate){Ce=q;break t}q=Ce(q),z=Ce(z)}Ce=null}else Ce=null;W!==null&&Fv(te,Y,W,Ce,!1),we!==null&&at!==null&&Fv(te,at,we,Ce,!0)}}e:{if(Y=K?Ai(K):window,W=Y.nodeName&&Y.nodeName.toLowerCase(),W==="select"||W==="input"&&Y.type==="file")var We=cg;else if(og(Y))if(ug)We=C_;else{We=T_;var ke=k_}else W=Y.nodeName,!W||W.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?K&&Yu(K.elementType)&&(We=cg):We=E_;if(We&&(We=We(s,K))){lg(te,We,i,Q);break e}ke&&ke(s,Y,K),s==="focusout"&&K&&Y.type==="number"&&K.memoizedProps.value!=null&&Ku(Y,"number",Y.value)}switch(ke=K?Ai(K):window,s){case"focusin":(og(ke)||ke.contentEditable==="true")&&(vr=ke,ld=K,Bi=null);break;case"focusout":Bi=ld=vr=null;break;case"mousedown":cd=!0;break;case"contextmenu":case"mouseup":case"dragend":cd=!1,vg(te,i,Q);break;case"selectionchange":if(R_)break;case"keydown":case"keyup":vg(te,i,Q)}var ze;if(ad)e:{switch(s){case"compositionstart":var Ge="onCompositionStart";break e;case"compositionend":Ge="onCompositionEnd";break e;case"compositionupdate":Ge="onCompositionUpdate";break e}Ge=void 0}else yr?rg(s,i)&&(Ge="onCompositionEnd"):s==="keydown"&&i.keyCode===229&&(Ge="onCompositionStart");Ge&&(sg&&i.locale!=="ko"&&(yr||Ge!=="onCompositionStart"?Ge==="onCompositionEnd"&&yr&&(ze=Jp()):(Pn=Q,Zu="value"in Pn?Pn.value:Pn.textContent,yr=!0)),ke=dc(K,Ge),0<ke.length&&(Ge=new eg(Ge,s,null,i,Q),te.push({event:Ge,listeners:ke}),ze?Ge.data=ze:(ze=ig(i),ze!==null&&(Ge.data=ze)))),(ze=w_?S_(s,i):j_(s,i))&&(Ge=dc(K,"onBeforeInput"),0<Ge.length&&(ke=new eg("onBeforeInput","beforeinput",null,i,Q),te.push({event:ke,listeners:Ge}),ke.data=ze)),mN(te,s,K,i,Q)}Hv(te,a)})}function uo(s,a,i){return{instance:s,listener:a,currentTarget:i}}function dc(s,a){for(var i=a+"Capture",c=[];s!==null;){var f=s,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=Ri(s,i),f!=null&&c.unshift(uo(s,f,g)),f=Ri(s,a),f!=null&&c.push(uo(s,f,g))),s.tag===3)return c;s=s.return}return[]}function vN(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function Fv(s,a,i,c,f){for(var g=a._reactName,b=[];i!==null&&i!==c;){var N=i,O=N.alternate,K=N.stateNode;if(N=N.tag,O!==null&&O===c)break;N!==5&&N!==26&&N!==27||K===null||(O=K,f?(K=Ri(i,g),K!=null&&b.unshift(uo(i,K,O))):f||(K=Ri(i,g),K!=null&&b.push(uo(i,K,O)))),i=i.return}b.length!==0&&s.push({event:a,listeners:b})}var xN=/\r\n?/g,bN=/\u0000|\uFFFD/g;function Kv(s){return(typeof s=="string"?s:""+s).replace(xN,`
|
|
9
|
+
`).replace(bN,"")}function Yv(s,a){return a=Kv(a),Kv(s)===a}function nt(s,a,i,c,f,g){switch(i){case"children":typeof c=="string"?a==="body"||a==="textarea"&&c===""||mr(s,c):(typeof c=="number"||typeof c=="bigint")&&a!=="body"&&mr(s,""+c);break;case"className":pl(s,"class",c);break;case"tabIndex":pl(s,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":pl(s,i,c);break;case"style":Yp(s,c,g);break;case"data":if(a!=="object"){pl(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=yl(""+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"&&nt(s,a,"name",f.name,f,null),nt(s,a,"formEncType",f.formEncType,f,null),nt(s,a,"formMethod",f.formMethod,f,null),nt(s,a,"formTarget",f.formTarget,f,null)):(nt(s,a,"encType",f.encType,f,null),nt(s,a,"method",f.method,f,null),nt(s,a,"target",f.target,f,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){s.removeAttribute(i);break}c=yl(""+c),s.setAttribute(i,c);break;case"onClick":c!=null&&(s.onclick=un);break;case"onScroll":c!=null&&$e("scroll",s);break;case"onScrollEnd":c!=null&&$e("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(f.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=yl(""+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":$e("beforetoggle",s),$e("toggle",s),ml(s,"popover",c);break;case"xlinkActuate":cn(s,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":cn(s,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":cn(s,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":cn(s,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":cn(s,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":cn(s,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":cn(s,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":cn(s,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":cn(s,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":ml(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=Yj.get(i)||i,ml(s,i,c))}}function Dh(s,a,i,c,f,g){switch(i){case"style":Yp(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(f.children!=null)throw Error(r(60));s.innerHTML=i}}break;case"children":typeof c=="string"?mr(s,c):(typeof c=="number"||typeof c=="bigint")&&mr(s,""+c);break;case"onScroll":c!=null&&$e("scroll",s);break;case"onScrollEnd":c!=null&&$e("scrollend",s);break;case"onClick":c!=null&&(s.onclick=un);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bp.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(f=i.endsWith("Capture"),a=i.slice(2,f?i.length-7:void 0),g=s[as]||null,g=g!=null?g[i]:null,typeof g=="function"&&s.removeEventListener(a,g,f),typeof c=="function")){typeof g!="function"&&g!==null&&(i in s?s[i]=null:s.hasAttribute(i)&&s.removeAttribute(i)),s.addEventListener(a,c,f);break e}i in s?s[i]=c:c===!0?s.setAttribute(i,""):ml(s,i,c)}}}function qt(s,a,i){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$e("error",s),$e("load",s);var c=!1,f=!1,g;for(g in i)if(i.hasOwnProperty(g)){var b=i[g];if(b!=null)switch(g){case"src":c=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:nt(s,a,g,b,i,null)}}f&&nt(s,a,"srcSet",i.srcSet,i,null),c&&nt(s,a,"src",i.src,i,null);return;case"input":$e("invalid",s);var N=g=b=f=null,O=null,K=null;for(c in i)if(i.hasOwnProperty(c)){var Q=i[c];if(Q!=null)switch(c){case"name":f=Q;break;case"type":b=Q;break;case"checked":O=Q;break;case"defaultChecked":K=Q;break;case"value":g=Q;break;case"defaultValue":N=Q;break;case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(r(137,a));break;default:nt(s,a,c,Q,i,null)}}Hp(s,g,N,O,K,b,f,!1);return;case"select":$e("invalid",s),c=b=g=null;for(f in i)if(i.hasOwnProperty(f)&&(N=i[f],N!=null))switch(f){case"value":g=N;break;case"defaultValue":b=N;break;case"multiple":c=N;default:nt(s,a,f,N,i,null)}a=g,i=b,s.multiple=!!c,a!=null?fr(s,!!c,a,!1):i!=null&&fr(s,!!c,i,!0);return;case"textarea":$e("invalid",s),g=f=c=null;for(b in i)if(i.hasOwnProperty(b)&&(N=i[b],N!=null))switch(b){case"value":c=N;break;case"defaultValue":f=N;break;case"children":g=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:nt(s,a,b,N,i,null)}Fp(s,c,f,g);return;case"option":for(O in i)i.hasOwnProperty(O)&&(c=i[O],c!=null)&&(O==="selected"?s.selected=c&&typeof c!="function"&&typeof c!="symbol":nt(s,a,O,c,i,null));return;case"dialog":$e("beforetoggle",s),$e("toggle",s),$e("cancel",s),$e("close",s);break;case"iframe":case"object":$e("load",s);break;case"video":case"audio":for(c=0;c<co.length;c++)$e(co[c],s);break;case"image":$e("error",s),$e("load",s);break;case"details":$e("toggle",s);break;case"embed":case"source":case"link":$e("error",s),$e("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(K in i)if(i.hasOwnProperty(K)&&(c=i[K],c!=null))switch(K){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:nt(s,a,K,c,i,null)}return;default:if(Yu(a)){for(Q in i)i.hasOwnProperty(Q)&&(c=i[Q],c!==void 0&&Dh(s,a,Q,c,i,void 0));return}}for(N in i)i.hasOwnProperty(N)&&(c=i[N],c!=null&&nt(s,a,N,c,i,null))}function wN(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 f=null,g=null,b=null,N=null,O=null,K=null,Q=null;for(W in i){var te=i[W];if(i.hasOwnProperty(W)&&te!=null)switch(W){case"checked":break;case"value":break;case"defaultValue":O=te;default:c.hasOwnProperty(W)||nt(s,a,W,null,c,te)}}for(var Y in c){var W=c[Y];if(te=i[Y],c.hasOwnProperty(Y)&&(W!=null||te!=null))switch(Y){case"type":g=W;break;case"name":f=W;break;case"checked":K=W;break;case"defaultChecked":Q=W;break;case"value":b=W;break;case"defaultValue":N=W;break;case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(r(137,a));break;default:W!==te&&nt(s,a,Y,W,c,te)}}Fu(s,b,N,O,K,Q,g,f);return;case"select":W=b=N=Y=null;for(g in i)if(O=i[g],i.hasOwnProperty(g)&&O!=null)switch(g){case"value":break;case"multiple":W=O;default:c.hasOwnProperty(g)||nt(s,a,g,null,c,O)}for(f in c)if(g=c[f],O=i[f],c.hasOwnProperty(f)&&(g!=null||O!=null))switch(f){case"value":Y=g;break;case"defaultValue":N=g;break;case"multiple":b=g;default:g!==O&&nt(s,a,f,g,c,O)}a=N,i=b,c=W,Y!=null?fr(s,!!i,Y,!1):!!c!=!!i&&(a!=null?fr(s,!!i,a,!0):fr(s,!!i,i?[]:"",!1));return;case"textarea":W=Y=null;for(N in i)if(f=i[N],i.hasOwnProperty(N)&&f!=null&&!c.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:nt(s,a,N,null,c,f)}for(b in c)if(f=c[b],g=i[b],c.hasOwnProperty(b)&&(f!=null||g!=null))switch(b){case"value":Y=f;break;case"defaultValue":W=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(r(91));break;default:f!==g&&nt(s,a,b,f,c,g)}Gp(s,Y,W);return;case"option":for(var we in i)Y=i[we],i.hasOwnProperty(we)&&Y!=null&&!c.hasOwnProperty(we)&&(we==="selected"?s.selected=!1:nt(s,a,we,null,c,Y));for(O in c)Y=c[O],W=i[O],c.hasOwnProperty(O)&&Y!==W&&(Y!=null||W!=null)&&(O==="selected"?s.selected=Y&&typeof Y!="function"&&typeof Y!="symbol":nt(s,a,O,Y,c,W));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 Ce in i)Y=i[Ce],i.hasOwnProperty(Ce)&&Y!=null&&!c.hasOwnProperty(Ce)&&nt(s,a,Ce,null,c,Y);for(K in c)if(Y=c[K],W=i[K],c.hasOwnProperty(K)&&Y!==W&&(Y!=null||W!=null))switch(K){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(r(137,a));break;default:nt(s,a,K,Y,c,W)}return;default:if(Yu(a)){for(var at in i)Y=i[at],i.hasOwnProperty(at)&&Y!==void 0&&!c.hasOwnProperty(at)&&Dh(s,a,at,void 0,c,Y);for(Q in c)Y=c[Q],W=i[Q],!c.hasOwnProperty(Q)||Y===W||Y===void 0&&W===void 0||Dh(s,a,Q,Y,c,W);return}}for(var q in i)Y=i[q],i.hasOwnProperty(q)&&Y!=null&&!c.hasOwnProperty(q)&&nt(s,a,q,null,c,Y);for(te in c)Y=c[te],W=i[te],!c.hasOwnProperty(te)||Y===W||Y==null&&W==null||nt(s,a,te,Y,c,W)}function Wv(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function SN(){if(typeof performance.getEntriesByType=="function"){for(var s=0,a=0,i=performance.getEntriesByType("resource"),c=0;c<i.length;c++){var f=i[c],g=f.transferSize,b=f.initiatorType,N=f.duration;if(g&&N&&Wv(b)){for(b=0,N=f.responseEnd,c+=1;c<i.length;c++){var O=i[c],K=O.startTime;if(K>N)break;var Q=O.transferSize,te=O.initiatorType;Q&&Wv(te)&&(O=O.responseEnd,b+=Q*(O<N?1:(N-K)/(O-K)))}if(--c,a+=8*(g+b)/(f.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 Ph=null,Lh=null;function hc(s){return s.nodeType===9?s:s.ownerDocument}function Xv(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 Jv(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 zh(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 Uh=null;function jN(){var s=window.event;return s&&s.type==="popstate"?s===Uh?!1:(Uh=s,!0):(Uh=null,!1)}var Qv=typeof setTimeout=="function"?setTimeout:void 0,_N=typeof clearTimeout=="function"?clearTimeout:void 0,Zv=typeof Promise=="function"?Promise:void 0,NN=typeof queueMicrotask=="function"?queueMicrotask:typeof Zv<"u"?function(s){return Zv.resolve(null).then(s).catch(kN)}:Qv;function kN(s){setTimeout(function(){throw s})}function Qn(s){return s==="head"}function ex(s,a){var i=a,c=0;do{var f=i.nextSibling;if(s.removeChild(i),f&&f.nodeType===8)if(i=f.data,i==="/$"||i==="/&"){if(c===0){s.removeChild(f),Gr(a);return}c--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")c++;else if(i==="html")ho(s.ownerDocument.documentElement);else if(i==="head"){i=s.ownerDocument.head,ho(i);for(var g=i.firstChild;g;){var b=g.nextSibling,N=g.nodeName;g[Ci]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&g.rel.toLowerCase()==="stylesheet"||i.removeChild(g),g=b}}else i==="body"&&ho(s.ownerDocument.body);i=f}while(i);Gr(a)}function tx(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 Bh(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":Bh(i),Hu(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}s.removeChild(i)}}function TN(s,a,i,c){for(;s.nodeType===1;){var f=i;if(s.nodeName.toLowerCase()!==a.toLowerCase()){if(!c&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(c){if(!s[Ci])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!==f.rel||s.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||s.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||s.getAttribute("title")!==(f.title==null?null:f.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(g=s.getAttribute("src"),(g!==(f.src==null?null:f.src)||s.getAttribute("type")!==(f.type==null?null:f.type)||s.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(a==="input"&&s.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&s.getAttribute("name")===g)return s}else return s;if(s=Os(s.nextSibling),s===null)break}return null}function EN(s,a,i){if(a==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!i||(s=Os(s.nextSibling),s===null))return null;return s}function sx(s,a){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!a||(s=Os(s.nextSibling),s===null))return null;return s}function Ih(s){return s.data==="$?"||s.data==="$~"}function Vh(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function CN(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 Os(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 $h=null;function nx(s){s=s.nextSibling;for(var a=0;s;){if(s.nodeType===8){var i=s.data;if(i==="/$"||i==="/&"){if(a===0)return Os(s.nextSibling);a--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||a++}s=s.nextSibling}return null}function ax(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 rx(s,a,i){switch(a=hc(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 ho(s){for(var a=s.attributes;a.length;)s.removeAttributeNode(a[0]);Hu(s)}var Ms=new Map,ix=new Set;function fc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var kn=F.d;F.d={f:AN,r:RN,D:ON,C:MN,L:DN,m:PN,X:zN,S:LN,M:UN};function AN(){var s=kn.f(),a=ac();return s||a}function RN(s){var a=ur(s);a!==null&&a.tag===5&&a.type==="form"?jy(a):kn.r(s)}var $r=typeof document>"u"?null:document;function ox(s,a,i){var c=$r;if(c&&typeof a=="string"&&a){var f=Ns(a);f='link[rel="'+s+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),ix.has(f)||(ix.add(f),s={rel:s,crossOrigin:i,href:a},c.querySelector(f)===null&&(a=c.createElement("link"),qt(a,"link",s),Lt(a),c.head.appendChild(a)))}}function ON(s){kn.D(s),ox("dns-prefetch",s,null)}function MN(s,a){kn.C(s,a),ox("preconnect",s,a)}function DN(s,a,i){kn.L(s,a,i);var c=$r;if(c&&s&&a){var f='link[rel="preload"][as="'+Ns(a)+'"]';a==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+Ns(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+Ns(i.imageSizes)+'"]')):f+='[href="'+Ns(s)+'"]';var g=f;switch(a){case"style":g=qr(s);break;case"script":g=Hr(s)}Ms.has(g)||(s=x({rel:"preload",href:a==="image"&&i&&i.imageSrcSet?void 0:s,as:a},i),Ms.set(g,s),c.querySelector(f)!==null||a==="style"&&c.querySelector(fo(g))||a==="script"&&c.querySelector(mo(g))||(a=c.createElement("link"),qt(a,"link",s),Lt(a),c.head.appendChild(a)))}}function PN(s,a){kn.m(s,a);var i=$r;if(i&&s){var c=a&&typeof a.as=="string"?a.as:"script",f='link[rel="modulepreload"][as="'+Ns(c)+'"][href="'+Ns(s)+'"]',g=f;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Hr(s)}if(!Ms.has(g)&&(s=x({rel:"modulepreload",href:s},a),Ms.set(g,s),i.querySelector(f)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(mo(g)))return}c=i.createElement("link"),qt(c,"link",s),Lt(c),i.head.appendChild(c)}}}function LN(s,a,i){kn.S(s,a,i);var c=$r;if(c&&s){var f=dr(c).hoistableStyles,g=qr(s);a=a||"default";var b=f.get(g);if(!b){var N={loading:0,preload:null};if(b=c.querySelector(fo(g)))N.loading=5;else{s=x({rel:"stylesheet",href:s,"data-precedence":a},i),(i=Ms.get(g))&&qh(s,i);var O=b=c.createElement("link");Lt(O),qt(O,"link",s),O._p=new Promise(function(K,Q){O.onload=K,O.onerror=Q}),O.addEventListener("load",function(){N.loading|=1}),O.addEventListener("error",function(){N.loading|=2}),N.loading|=4,mc(b,a,c)}b={type:"stylesheet",instance:b,count:1,state:N},f.set(g,b)}}}function zN(s,a){kn.X(s,a);var i=$r;if(i&&s){var c=dr(i).hoistableScripts,f=Hr(s),g=c.get(f);g||(g=i.querySelector(mo(f)),g||(s=x({src:s,async:!0},a),(a=Ms.get(f))&&Hh(s,a),g=i.createElement("script"),Lt(g),qt(g,"link",s),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(f,g))}}function UN(s,a){kn.M(s,a);var i=$r;if(i&&s){var c=dr(i).hoistableScripts,f=Hr(s),g=c.get(f);g||(g=i.querySelector(mo(f)),g||(s=x({src:s,async:!0,type:"module"},a),(a=Ms.get(f))&&Hh(s,a),g=i.createElement("script"),Lt(g),qt(g,"link",s),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(f,g))}}function lx(s,a,i,c){var f=(f=ie.current)?fc(f):null;if(!f)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(a=qr(i.href),i=dr(f).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=qr(i.href);var g=dr(f).hoistableStyles,b=g.get(s);if(b||(f=f.ownerDocument||f,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(s,b),(g=f.querySelector(fo(s)))&&!g._p&&(b.instance=g,b.state.loading=5),Ms.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},Ms.set(s,i),g||BN(f,s,i,b.state))),a&&c===null)throw Error(r(528,""));return b}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=Hr(i),i=dr(f).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 qr(s){return'href="'+Ns(s)+'"'}function fo(s){return'link[rel="stylesheet"]['+s+"]"}function cx(s){return x({},s,{"data-precedence":s.precedence,precedence:null})}function BN(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}),qt(a,"link",i),Lt(a),s.head.appendChild(a))}function Hr(s){return'[src="'+Ns(s)+'"]'}function mo(s){return"script[async]"+s}function ux(s,a,i){if(a.count++,a.instance===null)switch(a.type){case"style":var c=s.querySelector('style[data-href~="'+Ns(i.href)+'"]');if(c)return a.instance=c,Lt(c),c;var f=x({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return c=(s.ownerDocument||s).createElement("style"),Lt(c),qt(c,"style",f),mc(c,i.precedence,s),a.instance=c;case"stylesheet":f=qr(i.href);var g=s.querySelector(fo(f));if(g)return a.state.loading|=4,a.instance=g,Lt(g),g;c=cx(i),(f=Ms.get(f))&&qh(c,f),g=(s.ownerDocument||s).createElement("link"),Lt(g);var b=g;return b._p=new Promise(function(N,O){b.onload=N,b.onerror=O}),qt(g,"link",c),a.state.loading|=4,mc(g,i.precedence,s),a.instance=g;case"script":return g=Hr(i.src),(f=s.querySelector(mo(g)))?(a.instance=f,Lt(f),f):(c=i,(f=Ms.get(g))&&(c=x({},i),Hh(c,f)),s=s.ownerDocument||s,f=s.createElement("script"),Lt(f),qt(f,"link",c),s.head.appendChild(f),a.instance=f);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,mc(c,i.precedence,s));return a.instance}function mc(s,a,i){for(var c=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=c.length?c[c.length-1]:null,g=f,b=0;b<c.length;b++){var N=c[b];if(N.dataset.precedence===a)g=N;else if(g!==f)break}g?g.parentNode.insertBefore(s,g.nextSibling):(a=i.nodeType===9?i.head:i,a.insertBefore(s,a.firstChild))}function qh(s,a){s.crossOrigin==null&&(s.crossOrigin=a.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=a.referrerPolicy),s.title==null&&(s.title=a.title)}function Hh(s,a){s.crossOrigin==null&&(s.crossOrigin=a.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=a.referrerPolicy),s.integrity==null&&(s.integrity=a.integrity)}var pc=null;function dx(s,a,i){if(pc===null){var c=new Map,f=pc=new Map;f.set(i,c)}else f=pc,c=f.get(i),c||(c=new Map,f.set(i,c));if(c.has(s))return c;for(c.set(s,null),i=i.getElementsByTagName(s),f=0;f<i.length;f++){var g=i[f];if(!(g[Ci]||g[Bt]||s==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var b=g.getAttribute(a)||"";b=s+b;var N=c.get(b);N?N.push(g):c.set(b,[g])}}return c}function hx(s,a,i){s=s.ownerDocument||s,s.head.insertBefore(i,a==="title"?s.querySelector("head > title"):null)}function IN(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 fx(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function VN(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 f=qr(c.href),g=a.querySelector(fo(f));if(g){a=g._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(s.count++,s=gc.bind(s),a.then(s,s)),i.state.loading|=4,i.instance=g,Lt(g);return}g=a.ownerDocument||a,c=cx(c),(f=Ms.get(f))&&qh(c,f),g=g.createElement("link"),Lt(g);var b=g;b._p=new Promise(function(N,O){b.onload=N,b.onerror=O}),qt(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=gc.bind(s),a.addEventListener("load",i),a.addEventListener("error",i))}}var Gh=0;function $N(s,a){return s.stylesheets&&s.count===0&&vc(s,s.stylesheets),0<s.count||0<s.imgCount?function(i){var c=setTimeout(function(){if(s.stylesheets&&vc(s,s.stylesheets),s.unsuspend){var g=s.unsuspend;s.unsuspend=null,g()}},6e4+a);0<s.imgBytes&&Gh===0&&(Gh=62500*SN());var f=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&vc(s,s.stylesheets),s.unsuspend)){var g=s.unsuspend;s.unsuspend=null,g()}},(s.imgBytes>Gh?50:800)+a);return s.unsuspend=i,function(){s.unsuspend=null,clearTimeout(c),clearTimeout(f)}}:null}function gc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)vc(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var yc=null;function vc(s,a){s.stylesheets=null,s.unsuspend!==null&&(s.count++,yc=new Map,a.forEach(qN,s),yc=null,gc.call(s))}function qN(s,a){if(!(a.state.loading&4)){var i=yc.get(s);if(i)var c=i.get(null);else{i=new Map,yc.set(s,i);for(var f=s.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var b=f[g];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(i.set(b.dataset.precedence,b),c=b)}c&&i.set(null,c)}f=a.instance,b=f.getAttribute("data-precedence"),g=i.get(b)||c,g===c&&i.set(null,f),i.set(b,f),this.count++,c=gc.bind(this),f.addEventListener("load",c),f.addEventListener("error",c),g?g.parentNode.insertBefore(f,g.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(f,s.firstChild)),a.state.loading|=4}}var po={$$typeof:A,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function HN(s,a,i,c,f,g,b,N,O){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=Iu(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Iu(0),this.hiddenUpdates=Iu(null),this.identifierPrefix=c,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=O,this.incompleteTransitions=new Map}function mx(s,a,i,c,f,g,b,N,O,K,Q,te){return s=new HN(s,a,i,b,O,K,Q,te,N),a=1,g===!0&&(a|=24),g=gs(3,null,null,a),s.current=g,g.stateNode=s,a=_d(),a.refCount++,s.pooledCache=a,a.refCount++,g.memoizedState={element:c,isDehydrated:i,cache:a},Ed(g),s}function px(s){return s?(s=wr,s):wr}function gx(s,a,i,c,f,g){f=px(f),c.context===null?c.context=f:c.pendingContext=f,c=Vn(a),c.payload={element:i},g=g===void 0?null:g,g!==null&&(c.callback=g),i=$n(s,c,a),i!==null&&(us(i,s,a),Fi(i,s,a))}function yx(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var i=s.retryLane;s.retryLane=i!==0&&i<a?i:a}}function Fh(s,a){yx(s,a),(s=s.alternate)&&yx(s,a)}function vx(s){if(s.tag===13||s.tag===31){var a=ka(s,67108864);a!==null&&us(a,s,67108864),Fh(s,67108864)}}function xx(s){if(s.tag===13||s.tag===31){var a=ws();a=Vu(a);var i=ka(s,a);i!==null&&us(i,s,a),Fh(s,a)}}var xc=!0;function GN(s,a,i,c){var f=V.T;V.T=null;var g=F.p;try{F.p=2,Kh(s,a,i,c)}finally{F.p=g,V.T=f}}function FN(s,a,i,c){var f=V.T;V.T=null;var g=F.p;try{F.p=8,Kh(s,a,i,c)}finally{F.p=g,V.T=f}}function Kh(s,a,i,c){if(xc){var f=Yh(c);if(f===null)Mh(s,a,c,bc,i),wx(s,c);else if(YN(f,s,a,i,c))c.stopPropagation();else if(wx(s,c),a&4&&-1<KN.indexOf(s)){for(;f!==null;){var g=ur(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var b=wa(g.pendingLanes);if(b!==0){var N=g;for(N.pendingLanes|=2,N.entangledLanes|=2;b;){var O=1<<31-ms(b);N.entanglements[1]|=O,b&=~O}en(g),(Ze&6)===0&&(sc=I()+500,lo(0))}}break;case 31:case 13:N=ka(g,2),N!==null&&us(N,g,2),ac(),Fh(g,2)}if(g=Yh(c),g===null&&Mh(s,a,c,bc,i),g===f)break;f=g}f!==null&&c.stopPropagation()}else Mh(s,a,c,null,i)}}function Yh(s){return s=Xu(s),Wh(s)}var bc=null;function Wh(s){if(bc=null,s=cr(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=h(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 bc=s,null}function bx(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(ce()){case Pe:return 2;case qe:return 8;case pt:case ss:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var Xh=!1,Zn=null,ea=null,ta=null,go=new Map,yo=new Map,sa=[],KN="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 wx(s,a){switch(s){case"focusin":case"focusout":Zn=null;break;case"dragenter":case"dragleave":ea=null;break;case"mouseover":case"mouseout":ta=null;break;case"pointerover":case"pointerout":go.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":yo.delete(a.pointerId)}}function vo(s,a,i,c,f,g){return s===null||s.nativeEvent!==g?(s={blockedOn:a,domEventName:i,eventSystemFlags:c,nativeEvent:g,targetContainers:[f]},a!==null&&(a=ur(a),a!==null&&vx(a)),s):(s.eventSystemFlags|=c,a=s.targetContainers,f!==null&&a.indexOf(f)===-1&&a.push(f),s)}function YN(s,a,i,c,f){switch(a){case"focusin":return Zn=vo(Zn,s,a,i,c,f),!0;case"dragenter":return ea=vo(ea,s,a,i,c,f),!0;case"mouseover":return ta=vo(ta,s,a,i,c,f),!0;case"pointerover":var g=f.pointerId;return go.set(g,vo(go.get(g)||null,s,a,i,c,f)),!0;case"gotpointercapture":return g=f.pointerId,yo.set(g,vo(yo.get(g)||null,s,a,i,c,f)),!0}return!1}function Sx(s){var a=cr(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,Lp(s.priority,function(){xx(i)});return}}else if(a===31){if(a=h(i),a!==null){s.blockedOn=a,Lp(s.priority,function(){xx(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 wc(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var i=Yh(s.nativeEvent);if(i===null){i=s.nativeEvent;var c=new i.constructor(i.type,i);Wu=c,i.target.dispatchEvent(c),Wu=null}else return a=ur(i),a!==null&&vx(a),s.blockedOn=i,!1;a.shift()}return!0}function jx(s,a,i){wc(s)&&i.delete(a)}function WN(){Xh=!1,Zn!==null&&wc(Zn)&&(Zn=null),ea!==null&&wc(ea)&&(ea=null),ta!==null&&wc(ta)&&(ta=null),go.forEach(jx),yo.forEach(jx)}function Sc(s,a){s.blockedOn===a&&(s.blockedOn=null,Xh||(Xh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,WN)))}var jc=null;function _x(s){jc!==s&&(jc=s,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jc===s&&(jc=null);for(var a=0;a<s.length;a+=3){var i=s[a],c=s[a+1],f=s[a+2];if(typeof c!="function"){if(Wh(c||i)===null)continue;break}var g=ur(i);g!==null&&(s.splice(a,3),a-=3,Yd(g,{pending:!0,data:f,method:i.method,action:c},c,f))}}))}function Gr(s){function a(O){return Sc(O,s)}Zn!==null&&Sc(Zn,s),ea!==null&&Sc(ea,s),ta!==null&&Sc(ta,s),go.forEach(a),yo.forEach(a);for(var i=0;i<sa.length;i++){var c=sa[i];c.blockedOn===s&&(c.blockedOn=null)}for(;0<sa.length&&(i=sa[0],i.blockedOn===null);)Sx(i),i.blockedOn===null&&sa.shift();if(i=(s.ownerDocument||s).$$reactFormReplay,i!=null)for(c=0;c<i.length;c+=3){var f=i[c],g=i[c+1],b=f[as]||null;if(typeof g=="function")b||_x(i);else if(b){var N=null;if(g&&g.hasAttribute("formAction")){if(f=g,b=g[as]||null)N=b.formAction;else if(Wh(f)!==null)continue}else N=b.action;typeof N=="function"?i[c+1]=N:(i.splice(c,3),c-=3),_x(i)}}}function Nx(){function s(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(b){return f=b})},focusReset:"manual",scroll:"manual"})}function a(){f!==null&&(f(),f=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,f=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),f!==null&&(f(),f=null)}}}function Jh(s){this._internalRoot=s}_c.prototype.render=Jh.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(r(409));var i=a.current,c=ws();gx(i,c,s,a,null,null)},_c.prototype.unmount=Jh.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;gx(s.current,2,null,s,null,null),ac(),a[lr]=null}};function _c(s){this._internalRoot=s}_c.prototype.unstable_scheduleHydration=function(s){if(s){var a=Pp();s={blockedOn:null,target:s,priority:a};for(var i=0;i<sa.length&&a!==0&&a<sa[i].priority;i++);sa.splice(i,0,s),i===0&&Sx(s)}};var kx=e.version;if(kx!=="19.2.4")throw Error(r(527,kx,"19.2.4"));F.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=p(a),s=s!==null?y(s):null,s=s===null?null:s.stateNode,s};var XN={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nc.isDisabled&&Nc.supportsFiber)try{Mn=Nc.inject(XN),Yt=Nc}catch{}}return bo.createRoot=function(s,a){if(!l(s))throw Error(r(299));var i=!1,c="",f=My,g=Dy,b=Py;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(f=a.onUncaughtError),a.onCaughtError!==void 0&&(g=a.onCaughtError),a.onRecoverableError!==void 0&&(b=a.onRecoverableError)),a=mx(s,1,!1,null,null,i,c,null,f,g,b,Nx),s[lr]=a.current,Oh(s),new Jh(a)},bo.hydrateRoot=function(s,a,i){if(!l(s))throw Error(r(299));var c=!1,f="",g=My,b=Dy,N=Py,O=null;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onUncaughtError!==void 0&&(g=i.onUncaughtError),i.onCaughtError!==void 0&&(b=i.onCaughtError),i.onRecoverableError!==void 0&&(N=i.onRecoverableError),i.formState!==void 0&&(O=i.formState)),a=mx(s,1,!0,a,i??null,c,f,O,g,b,N,Nx),a.context=px(null),i=a.current,c=ws(),c=Vu(c),f=Vn(c),f.callback=null,$n(i,f,c),i=c,a.current.lanes=i,Ei(a,i),en(a),s[lr]=a.current,Oh(s),new _c(a)},bo.version="19.2.4",bo}var Lx;function i2(){if(Lx)return ef.exports;Lx=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(),ef.exports=r2(),ef.exports}var o2=i2(),nn=function(){return nn=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},nn.apply(this,arguments)};function vi(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 l2(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 h(y){try{p(r.next(y))}catch(x){d(x)}}function m(y){try{p(r.throw(y))}catch(x){d(x)}}function p(y){y.done?u(y.value):l(y.value).then(h,m)}p((r=r.apply(t,e||[])).next())})}function c2(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 u2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class zm extends Error{constructor(e,n="FunctionsError",r){super(e),this.name=n,this.context=r}}class d2 extends zm{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class zx extends zm{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class Ux extends zm{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Hf;(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"})(Hf||(Hf={}));class h2{constructor(e,{headers:n={},customFetch:r,region:l=Hf.Any}={}){this.url=e,this.headers=n,this.region=l,this.fetch=u2(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return l2(this,arguments,void 0,function*(n,r={}){var l;let u,d;try{const{headers:h,method:m,body:p,signal:y,timeout:x}=r;let w={},{region:j}=r;j||(j=this.region);const k=new URL(`${this.url}/${n}`);j&&j!=="any"&&(w["x-region"]=j,k.searchParams.set("forceFunctionRegion",j));let S;p&&(h&&!Object.prototype.hasOwnProperty.call(h,"Content-Type")||!h)?typeof Blob<"u"&&p instanceof Blob||p instanceof ArrayBuffer?(w["Content-Type"]="application/octet-stream",S=p):typeof p=="string"?(w["Content-Type"]="text/plain",S=p):typeof FormData<"u"&&p instanceof FormData?S=p:(w["Content-Type"]="application/json",S=JSON.stringify(p)):p&&typeof p!="string"&&!(typeof Blob<"u"&&p instanceof Blob)&&!(p instanceof ArrayBuffer)&&!(typeof FormData<"u"&&p instanceof FormData)?S=JSON.stringify(p):S=p;let _=y;x&&(d=new AbortController,u=setTimeout(()=>d.abort(),x),y?(_=d.signal,y.addEventListener("abort",()=>d.abort())):_=d.signal);const T=yield this.fetch(k.toString(),{method:m||"POST",headers:Object.assign(Object.assign(Object.assign({},w),this.headers),h),body:S,signal:_}).catch(M=>{throw new d2(M)}),C=T.headers.get("x-relay-error");if(C&&C==="true")throw new zx(T);if(!T.ok)throw new Ux(T);let A=((l=T.headers.get("Content-Type"))!==null&&l!==void 0?l:"text/plain").split(";")[0].trim(),E;return A==="application/json"?E=yield T.json():A==="application/octet-stream"||A==="application/pdf"?E=yield T.blob():A==="text/event-stream"?E=T:A==="multipart/form-data"?E=yield T.formData():E=yield T.text(),{data:E,error:null,response:T}}catch(h){return{data:null,error:h,response:h instanceof Ux||h instanceof zx?h.context:void 0}}finally{u&&clearTimeout(u)}})}}var f2=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},m2=class{constructor(t){var e,n,r;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,this.urlLengthLimit=(r=t.urlLengthLimit)!==null&&r!==void 0?r:8e3,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,h=null,m=null,p=u.status,y=u.statusText;if(u.ok){var x,w;if(n.method!=="HEAD"){var j;const T=await u.text();T===""||(n.headers.get("Accept")==="text/csv"||n.headers.get("Accept")&&(!((j=n.headers.get("Accept"))===null||j===void 0)&&j.includes("application/vnd.pgrst.plan+text"))?h=T:h=JSON.parse(T))}const S=(x=n.headers.get("Prefer"))===null||x===void 0?void 0:x.match(/count=(exact|planned|estimated)/),_=(w=u.headers.get("content-range"))===null||w===void 0?void 0:w.split("/");S&&_&&_.length>1&&(m=parseInt(_[1])),n.isMaybeSingle&&n.method==="GET"&&Array.isArray(h)&&(h.length>1?(d={code:"PGRST116",details:`Results contain ${h.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},h=null,m=null,p=406,y="Not Acceptable"):h.length===1?h=h[0]:h=null)}else{var k;const S=await u.text();try{d=JSON.parse(S),Array.isArray(d)&&u.status===404&&(h=[],d=null,p=200,y="OK")}catch{u.status===404&&S===""?(p=204,y="No Content"):d={message:S}}if(d&&n.isMaybeSingle&&(!(d==null||(k=d.details)===null||k===void 0)&&k.includes("0 rows"))&&(d=null,p=200,y="OK"),d&&n.shouldThrowOnError)throw new f2(d)}return{error:d,data:h,count:m,status:p,statusText:y}});return this.shouldThrowOnError||(l=l.catch(u=>{var d;let h="",m="",p="";const y=u?.cause;if(y){var x,w,j,k;const T=(x=y?.message)!==null&&x!==void 0?x:"",C=(w=y?.code)!==null&&w!==void 0?w:"";h=`${(j=u?.name)!==null&&j!==void 0?j:"FetchError"}: ${u?.message}`,h+=`
|
|
10
|
+
|
|
11
|
+
Caused by: ${(k=y?.name)!==null&&k!==void 0?k:"Error"}: ${T}`,C&&(h+=` (${C})`),y?.stack&&(h+=`
|
|
12
|
+
${y.stack}`)}else{var S;h=(S=u?.stack)!==null&&S!==void 0?S:""}const _=this.url.toString().length;return u?.name==="AbortError"||u?.code==="ABORT_ERR"?(p="",m="Request was aborted (timeout or manual cancellation)",_>this.urlLengthLimit&&(m+=`. Note: Your request URL is ${_} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(y?.name==="HeadersOverflowError"||y?.code==="UND_ERR_HEADERS_OVERFLOW")&&(p="",m="HTTP headers exceeded server limits (typically 16KB)",_>this.urlLengthLimit&&(m+=`. Your request URL is ${_} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(d=u?.name)!==null&&d!==void 0?d:"FetchError"}: ${u?.message}`,details:h,hint:m,code:p},data:null,count:null,status:0,statusText:""}})),l.then(t,e)}returns(){return this}overrideTypes(){return this}},p2=class extends m2{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 h=[t?"analyze":null,e?"verbose":null,n?"settings":null,r?"buffers":null,l?"wal":null].filter(Boolean).join("|"),m=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${m}"; options=${h};`),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 Bx=new RegExp("[,()]");var ti=class extends p2{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"&&Bx.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"&&Bx.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}},g2=class{constructor(t,{headers:e={},schema:n,fetch:r,urlLengthLimit:l=8e3}){this.url=t,this.headers=new Headers(e),this.schema=n,this.fetch=r,this.urlLengthLimit=l}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(p=>/\s/.test(p)&&!u?"":(p==='"'&&(u=!u),p)).join(""),{url:h,headers:m}=this.cloneRequestState();return h.searchParams.set("select",d),r&&m.append("Prefer",`count=${r}`),new ti({method:l,url:h,headers:m,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}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 h=t.reduce((m,p)=>m.concat(Object.keys(p)),[]);if(h.length>0){const m=[...new Set(h)].map(p=>`"${p}"`);u.searchParams.set("columns",m.join(","))}}return new ti({method:l,url:u,headers:d,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(t,{onConflict:e,ignoreDuplicates:n=!1,count:r,defaultToNull:l=!0}={}){var u;const d="POST",{url:h,headers:m}=this.cloneRequestState();if(m.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),e!==void 0&&h.searchParams.set("on_conflict",e),r&&m.append("Prefer",`count=${r}`),l||m.append("Prefer","missing=default"),Array.isArray(t)){const p=t.reduce((y,x)=>y.concat(Object.keys(x)),[]);if(p.length>0){const y=[...new Set(p)].map(x=>`"${x}"`);h.searchParams.set("columns",y.join(","))}}return new ti({method:d,url:h,headers:m,schema:this.schema,body:t,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch,urlLengthLimit:this.urlLengthLimit})}update(t,{count:e}={}){var n;const r="PATCH",{url:l,headers:u}=this.cloneRequestState();return e&&u.append("Prefer",`count=${e}`),new ti({method:r,url:l,headers:u,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:t}={}){var e;const n="DELETE",{url:r,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new ti({method:n,url:r,headers:l,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function Po(t){"@babel/helpers - typeof";return Po=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},Po(t)}function y2(t,e){if(Po(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Po(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function v2(t){var e=y2(t,"string");return Po(e)=="symbol"?e:e+""}function x2(t,e,n){return(e=v2(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ix(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 kc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ix(Object(n),!0).forEach(function(r){x2(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ix(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var b2=class rw{constructor(e,{headers:n={},schema:r,fetch:l,timeout:u,urlLengthLimit:d=8e3}={}){this.url=e,this.headers=new Headers(n),this.schemaName=r,this.urlLengthLimit=d;const h=l??globalThis.fetch;u!==void 0&&u>0?this.fetch=(m,p)=>{const y=new AbortController,x=setTimeout(()=>y.abort(),u),w=p?.signal;if(w){if(w.aborted)return clearTimeout(x),h(m,p);const j=()=>{clearTimeout(x),y.abort()};return w.addEventListener("abort",j,{once:!0}),h(m,kc(kc({},p),{},{signal:y.signal})).finally(()=>{clearTimeout(x),w.removeEventListener("abort",j)})}return h(m,kc(kc({},p),{},{signal:y.signal})).finally(()=>clearTimeout(x))}:this.fetch=h}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new g2(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new rw(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,n={},{head:r=!1,get:l=!1,count:u}={}){var d;let h;const m=new URL(`${this.url}/rpc/${e}`);let p;const y=j=>j!==null&&typeof j=="object"&&(!Array.isArray(j)||j.some(y)),x=r&&Object.values(n).some(y);x?(h="POST",p=n):r||l?(h=r?"HEAD":"GET",Object.entries(n).filter(([j,k])=>k!==void 0).map(([j,k])=>[j,Array.isArray(k)?`{${k.join(",")}}`:`${k}`]).forEach(([j,k])=>{m.searchParams.append(j,k)})):(h="POST",p=n);const w=new Headers(this.headers);return x?w.set("Prefer",u?`count=${u},return=minimal`:"return=minimal"):u&&w.set("Prefer",`count=${u}`),new ti({method:h,url:m,headers:w,schema:this.schemaName,body:p,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch,urlLengthLimit:this.urlLengthLimit})}};class w2{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 S2="2.97.0",j2=`realtime-js/${S2}`,_2="1.0.0",iw="2.0.0",Vx=iw,Gf=1e4,N2=1e3,k2=100;var ca;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(ca||(ca={}));var Dt;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Dt||(Dt={}));var Hs;(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"})(Hs||(Hs={}));var Ff;(function(t){t.websocket="websocket"})(Ff||(Ff={}));var Ka;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Ka||(Ka={}));class T2{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,h=(l=e.ref)!==null&&l!==void 0?l:"",m=(u=e.join_ref)!==null&&u!==void 0?u:"",p=e.payload.event,y=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},x=Object.keys(y).length===0?"":JSON.stringify(y);if(m.length>255)throw new Error(`joinRef length ${m.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`ref length ${h.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`topic length ${d.length} exceeds maximum of 255`);if(p.length>255)throw new Error(`userEvent length ${p.length} exceeds maximum of 255`);if(x.length>255)throw new Error(`metadata length ${x.length} exceeds maximum of 255`);const w=this.USER_BROADCAST_PUSH_META_LENGTH+m.length+h.length+d.length+p.length+x.length,j=new ArrayBuffer(this.HEADER_LENGTH+w);let k=new DataView(j),S=0;k.setUint8(S++,this.KINDS.userBroadcastPush),k.setUint8(S++,m.length),k.setUint8(S++,h.length),k.setUint8(S++,d.length),k.setUint8(S++,p.length),k.setUint8(S++,x.length),k.setUint8(S++,n),Array.from(m,T=>k.setUint8(S++,T.charCodeAt(0))),Array.from(h,T=>k.setUint8(S++,T.charCodeAt(0))),Array.from(d,T=>k.setUint8(S++,T.charCodeAt(0))),Array.from(p,T=>k.setUint8(S++,T.charCodeAt(0))),Array.from(x,T=>k.setUint8(S++,T.charCodeAt(0)));var _=new Uint8Array(j.byteLength+r.byteLength);return _.set(new Uint8Array(j),0),_.set(new Uint8Array(r),j.byteLength),_.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,h,m]=r;return n({join_ref:l,ref:u,topic:d,event:h,payload:m})}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),h=n.getUint8(4);let m=this.HEADER_LENGTH+4;const p=r.decode(e.slice(m,m+l));m=m+l;const y=r.decode(e.slice(m,m+u));m=m+u;const x=r.decode(e.slice(m,m+d));m=m+d;const w=e.slice(m,e.byteLength),j=h===this.JSON_ENCODING?JSON.parse(r.decode(w)):w,k={type:this.BROADCAST_EVENT,event:y,payload:j};return d>0&&(k.meta=JSON.parse(x)),{join_ref:null,ref:null,topic:p,event:this.BROADCAST_EVENT,payload:k}}_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 ow{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 lt;(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"})(lt||(lt={}));const $x=(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]=E2(d,t,e,l),u),{}):{}},E2=(t,e,n,r)=>{const l=e.find(h=>h.name===t),u=l?.type,d=n[t];return u&&!r.includes(u)?lw(u,d):Kf(d)},lw=(t,e)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return O2(e,n)}switch(t){case lt.bool:return C2(e);case lt.float4:case lt.float8:case lt.int2:case lt.int4:case lt.int8:case lt.numeric:case lt.oid:return A2(e);case lt.json:case lt.jsonb:return R2(e);case lt.timestamp:return M2(e);case lt.abstime:case lt.date:case lt.daterange:case lt.int4range:case lt.int8range:case lt.money:case lt.reltime:case lt.text:case lt.time:case lt.timestamptz:case lt.timetz:case lt.tsrange:case lt.tstzrange:return Kf(e);default:return Kf(e)}},Kf=t=>t,C2=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},A2=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},R2=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},O2=(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(h=>lw(e,h))}return t},M2=t=>typeof t=="string"?t.replace(" ","T"):t,cw=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 af{constructor(e,n,r={},l=Gf){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 qx;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(qx||(qx={}));class Eo{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:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Eo.syncState(this.state,l,u,d),this.pendingDiffs.forEach(m=>{this.state=Eo.syncDiff(this.state,m,u,d)}),this.pendingDiffs=[],h()}),this.channel._on(r.diff,{},l=>{const{onJoin:u,onLeave:d,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(l):(this.state=Eo.syncDiff(this.state,l,u,d),h())}),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),h={},m={};return this.map(u,(p,y)=>{d[p]||(m[p]=y)}),this.map(d,(p,y)=>{const x=u[p];if(x){const w=y.map(_=>_.presence_ref),j=x.map(_=>_.presence_ref),k=y.filter(_=>j.indexOf(_.presence_ref)<0),S=x.filter(_=>w.indexOf(_.presence_ref)<0);k.length>0&&(h[p]=k),S.length>0&&(m[p]=S)}else h[p]=y}),this.syncDiff(u,{joins:h,leaves:m},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,(h,m)=>{var p;const y=(p=e[h])!==null&&p!==void 0?p:[];if(e[h]=this.cloneDeep(m),y.length>0){const x=e[h].map(j=>j.presence_ref),w=y.filter(j=>x.indexOf(j.presence_ref)<0);e[h].unshift(...w)}r(h,y,m)}),this.map(d,(h,m)=>{let p=e[h];if(!p)return;const y=m.map(x=>x.presence_ref);p=p.filter(x=>y.indexOf(x.presence_ref)<0),e[h]=p,l(h,p,m),p.length===0&&delete e[h]}),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 Hx;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Hx||(Hx={}));var Co;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Co||(Co={}));var En;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(En||(En={}));class ri{constructor(e,n={config:{}},r){var l,u;if(this.topic=e,this.params=n,this.socket=r,this.bindings={},this.state=Dt.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 af(this,Hs.join,this.params,this.timeout),this.rejoinTimer=new ow(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Dt.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=Dt.closed,this.socket._remove(this)}),this._onError(d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=Dt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Dt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",d=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,d),this.state=Dt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Hs.reply,{},(d,h)=>{this._trigger(this._replyEventName(h),d)}),this.presence=new Eo(this),this.broadcastEndpointURL=cw(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==Dt.closed){const{config:{broadcast:d,presence:h,private:m}}=this.params,p=(l=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(j=>j.filter))!==null&&l!==void 0?l:[],y=!!this.bindings[Co.PRESENCE]&&this.bindings[Co.PRESENCE].length>0||((u=this.params.config.presence)===null||u===void 0?void 0:u.enabled)===!0,x={},w={broadcast:d,presence:Object.assign(Object.assign({},h),{enabled:y}),postgres_changes:p,private:m};this.socket.accessTokenValue&&(x.access_token=this.socket.accessTokenValue),this._onError(j=>e?.(En.CHANNEL_ERROR,j)),this._onClose(()=>e?.(En.CLOSED)),this.updateJoinPayload(Object.assign({config:w},x)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:j})=>{var k;if(this.socket._isManualToken()||this.socket.setAuth(),j===void 0){e?.(En.SUBSCRIBED);return}else{const S=this.bindings.postgres_changes,_=(k=S?.length)!==null&&k!==void 0?k:0,T=[];for(let C=0;C<_;C++){const A=S[C],{filter:{event:E,schema:M,table:P,filter:U}}=A,R=j&&j[C];if(R&&R.event===E&&ri.isFilterValueEqual(R.schema,M)&&ri.isFilterValueEqual(R.table,P)&&ri.isFilterValueEqual(R.filter,U))T.push(Object.assign(Object.assign({},A),{id:R.id}));else{this.unsubscribe(),this.state=Dt.errored,e?.(En.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=T,e&&e(En.SUBSCRIBED);return}}).receive("error",j=>{this.state=Dt.errored,e?.(En.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(j).join(", ")||"error")))}).receive("timeout",()=>{e?.(En.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===Dt.joined&&e===Co.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}]})},h=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(l=r.timeout)!==null&&l!==void 0?l:this.timeout);if(h.status===202)return{success:!0};let m=h.statusText;try{const p=await h.json();m=p.error||p.message||m}catch{}return Promise.reject(new Error(m))}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,h={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(h.Authorization=`Bearer ${this.socket.accessTokenValue}`);const m={method:"POST",headers:h,body:JSON.stringify({messages:[{topic:this.subTopic,event:u,payload:d,private:this.private}]})};try{const p=await this._fetchWithTimeout(this.broadcastEndpointURL,m,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((l=p.body)===null||l===void 0?void 0:l.cancel()),p.ok?"ok":"error"}catch(p){return p.name==="AbortError"?"timed out":"error"}}else return new Promise(u=>{var d,h,m;const p=this._push(e.type,e,n.timeout||this.timeout);e.type==="broadcast"&&!(!((m=(h=(d=this.params)===null||d===void 0?void 0:d.config)===null||h===void 0?void 0:h.broadcast)===null||m===void 0)&&m.ack)&&u("ok"),p.receive("ok",()=>u("ok")),p.receive("error",()=>u("error")),p.receive("timeout",()=>u("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Dt.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Hs.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(l=>{r=new af(this,Hs.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=Dt.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 af(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>k2){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:h,error:m,leave:p,join:y}=Hs;if(r&&[h,m,p,y].indexOf(d)>=0&&r!==this._joinRef())return;let w=this._onMessage(d,n,r);if(n&&!w)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(j=>{var k,S,_;return((k=j.filter)===null||k===void 0?void 0:k.event)==="*"||((_=(S=j.filter)===null||S===void 0?void 0:S.event)===null||_===void 0?void 0:_.toLocaleLowerCase())===d}).map(j=>j.callback(w,r)):(u=this.bindings[d])===null||u===void 0||u.filter(j=>{var k,S,_,T,C,A;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in j){const E=j.id,M=(k=j.filter)===null||k===void 0?void 0:k.event;return E&&((S=n.ids)===null||S===void 0?void 0:S.includes(E))&&(M==="*"||M?.toLocaleLowerCase()===((_=n.data)===null||_===void 0?void 0:_.type.toLocaleLowerCase()))}else{const E=(C=(T=j?.filter)===null||T===void 0?void 0:T.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return E==="*"||E===((A=n?.event)===null||A===void 0?void 0:A.toLocaleLowerCase())}else return j.type.toLocaleLowerCase()===d}).map(j=>{if(typeof w=="object"&&"ids"in w){const k=w.data,{schema:S,table:_,commit_timestamp:T,type:C,errors:A}=k;w=Object.assign(Object.assign({},{schema:S,table:_,commit_timestamp:T,eventType:C,new:{},old:{},errors:A}),this._getPayloadRecords(k))}j.callback(w,r)})}_isClosed(){return this.state===Dt.closed}_isJoined(){return this.state===Dt.joined}_isJoining(){return this.state===Dt.joining}_isLeaving(){return this.state===Dt.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&&ri.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(Hs.close,{},e)}_onError(e){this._on(Hs.error,{},n=>e(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Dt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const n={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(n.new=$x(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(n.old=$x(e.columns,e.old_record)),n}}const rf=()=>{},Tc={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},D2=[1e3,2e3,5e3,1e4],P2=1e4,L2=`
|
|
17
|
+
addEventListener("message", (e) => {
|
|
18
|
+
if (e.data.event === "start") {
|
|
19
|
+
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
20
|
+
}
|
|
21
|
+
});`;class z2{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=Gf,this.transport=null,this.heartbeatIntervalMs=Tc.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=rf,this.ref=0,this.reconnectTimer=null,this.vsn=Vx,this.logger=rf,this.conn=null,this.sendBuffer=[],this.serializer=new T2,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}/${Ff.websocket}`,this.httpEndpoint=cw(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=w2.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 ca.connecting:return Ka.Connecting;case ca.open:return Ka.Open;case ca.closing:return Ka.Closing;default:return Ka.Closed}}isConnected(){return this.connectionState()===Ka.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 ri(`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,h=>{var m;(m=this.conn)===null||m===void 0||m.send(h)})};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(N2,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},Tc.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 p=this._heartbeatSentAt?Date.now()-this._heartbeatSentAt:void 0;try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error",p)}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,h=d?`(${d})`:"",m=u.status||"";this.log("receive",`${m} ${r} ${l} ${h}`.trim(),u),this.channels.filter(p=>p._isMember(r)).forEach(p=>p._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===ca.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===ca.open||this.conn.readyState===ca.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);try{this.heartbeatCallback("error")}catch(n){this.log("error","error in heartbeat callback",n)}}_triggerChanError(){this.channels.forEach(e=>e._trigger(Hs.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([L2],{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:j2};n&&l.updateJoinPayload(u),l.joinedOnce&&l._isJoined()&&l._push(Hs.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 ow(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Tc.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var n,r,l,u,d,h,m,p,y,x,w,j;switch(this.transport=(n=e?.transport)!==null&&n!==void 0?n:null,this.timeout=(r=e?.timeout)!==null&&r!==void 0?r:Gf,this.heartbeatIntervalMs=(l=e?.heartbeatIntervalMs)!==null&&l!==void 0?l:Tc.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=(h=e?.heartbeatCallback)!==null&&h!==void 0?h:rf,this.vsn=(m=e?.vsn)!==null&&m!==void 0?m:Vx,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=(p=e?.reconnectAfterMs)!==null&&p!==void 0?p:(k=>D2[k-1]||P2),this.vsn){case _2:this.encode=(y=e?.encode)!==null&&y!==void 0?y:((k,S)=>S(JSON.stringify(k))),this.decode=(x=e?.decode)!==null&&x!==void 0?x:((k,S)=>S(JSON.parse(k)));break;case iw:this.encode=(w=e?.encode)!==null&&w!==void 0?w:this.serializer.encode.bind(this.serializer),this.decode=(j=e?.decode)!==null&&j!==void 0?j: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 Lo=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 U2(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 B2(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 I2(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:n,path:r,query:l,body:u,headers:d}){const h=U2(t.baseUrl,r,l),m=await B2(t.auth),p=await e(h,{method:n,headers:{...u?{"Content-Type":"application/json"}:{},...m,...d},body:u?JSON.stringify(u):void 0}),y=await p.text(),x=(p.headers.get("content-type")||"").includes("application/json"),w=x&&y?JSON.parse(y):y;if(!p.ok){const j=x?w:void 0,k=j?.error;throw new Lo(k?.message??`Request failed with status ${p.status}`,{status:p.status,icebergType:k?.type,icebergCode:k?.code,details:j})}return{status:p.status,headers:p.headers,data:w}}}}function Ec(t){return t.join("")}var V2=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Ec(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/${Ec(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ec(t.namespace)}`}),!0}catch(e){if(e instanceof Lo&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(n){if(n instanceof Lo&&n.status===409)return;throw n}}};function Fr(t){return t.join("")}var $2=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/${Fr(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/${Fr(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/${Fr(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/${Fr(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/${Fr(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/${Fr(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(n){if(n instanceof Lo&&n.status===404)return!1;throw n}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(n){if(n instanceof Lo&&n.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw n}}},q2=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const n=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=I2({baseUrl:n,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new V2(this.client,e),this.tableOps=new $2(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)}},ju=class extends Error{constructor(t,e="storage",n,r){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=n,this.statusCode=r}};function _u(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var Cc=class extends ju{constructor(t,e,n,r="storage"){super(t,r,e,n),this.name=r==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},uw=class extends ju{constructor(t,e,n="storage"){super(t,n),this.name=n==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};const H2=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),G2=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)},Yf=t=>{if(Array.isArray(t))return t.map(n=>Yf(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]=Yf(r)}),e},F2=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t);function zo(t){"@babel/helpers - typeof";return zo=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},zo(t)}function K2(t,e){if(zo(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(zo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Y2(t){var e=K2(t,"string");return zo(e)=="symbol"?e:e+""}function W2(t,e,n){return(e=Y2(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gx(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 Ae(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Gx(Object(n),!0).forEach(function(r){W2(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gx(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const Fx=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)},X2=async(t,e,n,r)=>{if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!n?.noResolveJson){const l=t,u=l.status||500;if(typeof l.json=="function")l.json().then(d=>{const h=d?.statusCode||d?.code||u+"";e(new Cc(Fx(d),u,h,r))}).catch(()=>{if(r==="vectors"){const d=u+"";e(new Cc(l.statusText||`HTTP ${u} error`,u,d,r))}else{const d=u+"";e(new Cc(l.statusText||`HTTP ${u} error`,u,d,r))}});else{const d=u+"";e(new Cc(l.statusText||`HTTP ${u} error`,u,d,r))}}else e(new uw(Fx(t),t,r))},J2=(t,e,n,r)=>{const l={method:t,headers:e?.headers||{}};return t==="GET"||t==="HEAD"||!r?Ae(Ae({},l),n):(G2(r)?(l.headers=Ae({"Content-Type":"application/json"},e?.headers),l.body=JSON.stringify(r)):l.body=r,e?.duplex&&(l.duplex=e.duplex),Ae(Ae({},l),n))};async function wo(t,e,n,r,l,u,d){return new Promise((h,m)=>{t(n,J2(e,r,l,u)).then(p=>{if(!p.ok)throw p;if(r?.noResolveJson)return p;if(d==="vectors"){const y=p.headers.get("content-type");if(p.headers.get("content-length")==="0"||p.status===204)return{};if(!y||!y.includes("application/json"))return{}}return p.json()}).then(p=>h(p)).catch(p=>X2(p,m,r,d))})}function dw(t="storage"){return{get:async(e,n,r,l)=>wo(e,"GET",n,r,l,void 0,t),post:async(e,n,r,l,u)=>wo(e,"POST",n,l,u,r,t),put:async(e,n,r,l,u)=>wo(e,"PUT",n,l,u,r,t),head:async(e,n,r,l)=>wo(e,"HEAD",n,Ae(Ae({},r),{},{noResolveJson:!0}),l,void 0,t),remove:async(e,n,r,l,u)=>wo(e,"DELETE",n,l,u,r,t)}}const Q2=dw("storage"),{get:Uo,post:qs,put:Wf,head:Z2,remove:Um}=Q2,js=dw("vectors");var xi=class{constructor(t,e={},n,r="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=e,this.fetch=H2(n),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Ae(Ae({},this.headers),{},{[t]:e}),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(_u(n))return{data:null,error:n};throw n}}},ek=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(_u(e))return{data:null,error:e};throw e}}};let hw;hw=Symbol.toStringTag;var tk=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[hw]="BlobDownloadBuilder",this.promise=null}asStream(){return new ek(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(_u(e))return{data:null,error:e};throw e}}};const sk={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Kx={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var nk=class extends xi{constructor(t,e={},n,r){super(t,e,r,"storage"),this.bucketId=n}async uploadOrUpdate(t,e,n,r){var l=this;return l.handleOperation(async()=>{let u;const d=Ae(Ae({},Kx),r);let h=Ae(Ae({},l.headers),t==="POST"&&{"x-upsert":String(d.upsert)});const m=d.metadata;typeof Blob<"u"&&n instanceof Blob?(u=new FormData,u.append("cacheControl",d.cacheControl),m&&u.append("metadata",l.encodeMetadata(m)),u.append("",n)):typeof FormData<"u"&&n instanceof FormData?(u=n,u.has("cacheControl")||u.append("cacheControl",d.cacheControl),m&&!u.has("metadata")&&u.append("metadata",l.encodeMetadata(m))):(u=n,h["cache-control"]=`max-age=${d.cacheControl}`,h["content-type"]=d.contentType,m&&(h["x-metadata"]=l.toBase64(l.encodeMetadata(m))),(typeof ReadableStream<"u"&&u instanceof ReadableStream||u&&typeof u=="object"&&"pipe"in u&&typeof u.pipe=="function")&&!d.duplex&&(d.duplex="half")),r?.headers&&(h=Ae(Ae({},h),r.headers));const p=l._removeEmptyFolders(e),y=l._getFinalPath(p),x=await(t=="PUT"?Wf:qs)(l.fetch,`${l.url}/object/${y}`,u,Ae({headers:h},d?.duplex?{duplex:d.duplex}:{}));return{path:p,id:x.Id,fullPath:x.Key}})}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),h=new URL(l.url+`/object/upload/sign/${d}`);return h.searchParams.set("token",e),l.handleOperation(async()=>{let m;const p=Ae({upsert:Kx.upsert},r),y=Ae(Ae({},l.headers),{"x-upsert":String(p.upsert)});return typeof Blob<"u"&&n instanceof Blob?(m=new FormData,m.append("cacheControl",p.cacheControl),m.append("",n)):typeof FormData<"u"&&n instanceof FormData?(m=n,m.append("cacheControl",p.cacheControl)):(m=n,y["cache-control"]=`max-age=${p.cacheControl}`,y["content-type"]=p.contentType),{path:u,fullPath:(await Wf(l.fetch,h.toString(),m,{headers:y})).Key}})}async createSignedUploadUrl(t,e){var n=this;return n.handleOperation(async()=>{let r=n._getFinalPath(t);const l=Ae({},n.headers);e?.upsert&&(l["x-upsert"]="true");const u=await qs(n.fetch,`${n.url}/object/upload/sign/${r}`,{},{headers:l}),d=new URL(n.url+u.url),h=d.searchParams.get("token");if(!h)throw new ju("No token returned by API");return{signedUrl:d.toString(),path:t,token:h}})}async update(t,e,n){return this.uploadOrUpdate("PUT",t,e,n)}async move(t,e,n){var r=this;return r.handleOperation(async()=>await qs(r.fetch,`${r.url}/object/move`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:n?.destinationBucket},{headers:r.headers}))}async copy(t,e,n){var r=this;return r.handleOperation(async()=>({path:(await qs(r.fetch,`${r.url}/object/copy`,{bucketId:r.bucketId,sourceKey:t,destinationKey:e,destinationBucket:n?.destinationBucket},{headers:r.headers})).Key}))}async createSignedUrl(t,e,n){var r=this;return r.handleOperation(async()=>{let l=r._getFinalPath(t),u=await qs(r.fetch,`${r.url}/object/sign/${l}`,Ae({expiresIn:e},n?.transform?{transform:n.transform}:{}),{headers:r.headers});const d=n?.download?`&download=${n.download===!0?"":n.download}`:"";return{signedUrl:encodeURI(`${r.url}${u.signedURL}${d}`)}})}async createSignedUrls(t,e,n){var r=this;return r.handleOperation(async()=>{const l=await qs(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 l.map(d=>Ae(Ae({},d),{},{signedUrl:d.signedURL?encodeURI(`${r.url}${d.signedURL}${u}`):null}))})}download(t,e,n){const r=typeof e?.transform<"u"?"render/image/authenticated":"object",l=this.transformOptsToQueryString(e?.transform||{}),u=l?`?${l}`:"",d=this._getFinalPath(t),h=()=>Uo(this.fetch,`${this.url}/${r}/${d}${u}`,{headers:this.headers,noResolveJson:!0},n);return new tk(h,this.shouldThrowOnError)}async info(t){var e=this;const n=e._getFinalPath(t);return e.handleOperation(async()=>Yf(await Uo(e.fetch,`${e.url}/object/info/${n}`,{headers:e.headers})))}async exists(t){var e=this;const n=e._getFinalPath(t);try{return await Z2(e.fetch,`${e.url}/object/${n}`,{headers:e.headers}),{data:!0,error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(_u(r)&&r instanceof uw){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 h=r.join("&");return h!==""&&(h=`?${h}`),{data:{publicUrl:encodeURI(`${this.url}/${u}/public/${n}${h}`)}}}async remove(t){var e=this;return e.handleOperation(async()=>await Um(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,n){var r=this;return r.handleOperation(async()=>{const l=Ae(Ae(Ae({},sk),e),{},{prefix:t||""});return await qs(r.fetch,`${r.url}/object/list/${r.bucketId}`,l,{headers:r.headers},n)})}async listV2(t,e){var n=this;return n.handleOperation(async()=>{const r=Ae({},t);return await qs(n.fetch,`${n.url}/object/list-v2/${n.bucketId}`,r,{headers:n.headers},e)})}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 ak="2.97.0",el={"X-Client-Info":`storage-js/${ak}`};var rk=class extends xi{constructor(t,e={},n,r){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."));const u=l.href.replace(/\/$/,""),d=Ae(Ae({},el),e);super(u,d,n,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const n=e.listBucketOptionsToQueryString(t);return await Uo(e.fetch,`${e.url}/bucket${n}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Uo(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var n=this;return n.handleOperation(async()=>await qs(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}))}async updateBucket(t,e){var n=this;return n.handleOperation(async()=>await Wf(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}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await qs(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Um(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}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():""}},ik=class extends xi{constructor(t,e={},n){const r=t.replace(/\/$/,""),l=Ae(Ae({},el),e);super(r,l,n,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await qs(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{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 await Uo(e.fetch,l,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Um(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!F2(t))throw new ju("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 q2({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(...h)=>{try{return{data:await d.apply(l,h),error:null}}catch(m){if(r)throw m;return{data:null,error:m}}}}})}},ok=class extends xi{constructor(t,e={},n){const r=t.replace(/\/$/,""),l=Ae(Ae({},el),{},{"Content-Type":"application/json"},e);super(r,l,n,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var n=this;return n.handleOperation(async()=>await js.post(n.fetch,`${n.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:n.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var n=this;return n.handleOperation(async()=>await js.post(n.fetch,`${n.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:n.headers})||{})}},lk=class extends xi{constructor(t,e={},n){const r=t.replace(/\/$/,""),l=Ae(Ae({},el),{},{"Content-Type":"application/json"},e);super(r,l,n,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;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 e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},ck=class extends xi{constructor(t,e={},n){const r=t.replace(/\/$/,""),l=Ae(Ae({},el),{},{"Content-Type":"application/json"},e);super(r,l,n,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await js.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},uk=class extends ck{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new dk(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)}},dk=class extends ok{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,Ae(Ae({},t),{},{vectorBucketName:n.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,n=this;return e().call(n,Ae(Ae({},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 hk(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},hk=class extends lk{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,Ae(Ae({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async getVectors(t){var e=()=>super.getVectors,n=this;return e().call(n,Ae(Ae({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,n=this;return e().call(n,Ae(Ae({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,n=this;return e().call(n,Ae(Ae({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,n=this;return e().call(n,Ae(Ae({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}},fk=class extends rk{constructor(t,e={},n,r){super(t,e,n,r)}from(t){return new nk(this.url,this.headers,t,this.fetch)}get vectors(){return new uk(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new ik(this.url+"/iceberg",this.headers,this.fetch)}};const fw="2.97.0",si=30*1e3,Xf=3,of=Xf*si,mk="http://localhost:9999",pk="supabase.auth.token",gk={"X-Client-Info":`gotrue-js/${fw}`},Jf="X-Supabase-Api-Version",mw={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},yk=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,vk=600*1e3;class Bo extends Error{constructor(e,n,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function Te(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class xk extends Bo{constructor(e,n,r){super(e,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function bk(t){return Te(t)&&t.name==="AuthApiError"}class Ya extends Bo{constructor(e,n){super(e),this.name="AuthUnknownError",this.originalError=n}}class Rn extends Bo{constructor(e,n,r,l){super(e,r,l),this.name=n,this.status=r}}class Ss extends Rn{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function lf(t){return Te(t)&&t.name==="AuthSessionMissingError"}class Kr extends Rn{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Ac extends Rn{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Rc extends Rn{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 wk(t){return Te(t)&&t.name==="AuthImplicitGrantRedirectError"}class Yx extends Rn{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 Sk extends Rn{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 Qf extends Rn{constructor(e,n){super(e,"AuthRetryableFetchError",n,void 0)}}function cf(t){return Te(t)&&t.name==="AuthRetryableFetchError"}class Wx extends Rn{constructor(e,n,r){super(e,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class Zf extends Rn{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const au="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Xx=`
|
|
35
|
+
\r=`.split(""),jk=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<Xx.length;e+=1)t[Xx[e].charCodeAt(0)]=-2;for(let e=0;e<au.length;e+=1)t[au[e].charCodeAt(0)]=e;return t})();function Jx(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(au[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(au[r]),e.queuedBits-=6}}function pw(t,e,n){const r=jk[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 Qx(t){const e=[],n=d=>{e.push(String.fromCodePoint(d))},r={utf8seq:0,codepoint:0},l={queue:0,queuedBits:0},u=d=>{kk(d,r,n)};for(let d=0;d<t.length;d+=1)pw(t.charCodeAt(d),l,u);return e.join("")}function _k(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 Nk(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}_k(r,e)}}function kk(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 di(t){const e=[],n={queue:0,queuedBits:0},r=l=>{e.push(l)};for(let l=0;l<t.length;l+=1)pw(t.charCodeAt(l),n,r);return new Uint8Array(e)}function Tk(t){const e=[];return Nk(t,n=>e.push(n)),new Uint8Array(e)}function Wa(t){const e=[],n={queue:0,queuedBits:0},r=l=>{e.push(l)};return t.forEach(l=>Jx(l,n,r)),Jx(null,n,r),e.join("")}function Ek(t){return Math.round(Date.now()/1e3)+t}function Ck(){return Symbol("auth-callback")}const Gt=()=>typeof window<"u"&&typeof document<"u",Ba={tested:!1,writable:!1},gw=()=>{if(!Gt())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ba.tested)return Ba.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Ba.tested=!0,Ba.writable=!0}catch{Ba.tested=!0,Ba.writable=!1}return Ba.writable};function Ak(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 yw=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Rk=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",ni=async(t,e,n)=>{await t.setItem(e,JSON.stringify(n))},Ia=async(t,e)=>{const n=await t.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Ht=async(t,e)=>{await t.removeItem(e)};class Nu{constructor(){this.promise=new Nu.promiseConstructor((e,n)=>{this.resolve=e,this.reject=n})}}Nu.promiseConstructor=Promise;function Oc(t){const e=t.split(".");if(e.length!==3)throw new Zf("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!yk.test(e[r]))throw new Zf("JWT not in base64url format");return{header:JSON.parse(Qx(e[0])),payload:JSON.parse(Qx(e[1])),signature:di(e[2]),raw:{header:e[0],payload:e[1]}}}async function Ok(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function Mk(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 Dk(t){return("0"+t.toString(16)).substr(-2)}function Pk(){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,Dk).join("")}async function Lk(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 zk(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 Lk(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Yr(t,e,n=!1){const r=Pk();let l=r;n&&(l+="/PASSWORD_RECOVERY"),await ni(t,`${e}-code-verifier`,l);const u=await zk(r);return[u,r===u?"plain":"s256"]}const Uk=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Bk(t){const e=t.headers.get(Jf);if(!e||!e.match(Uk))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function Ik(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 Vk(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 $k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Wr(t){if(!$k.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function uf(){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 qk(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 Zx(t){return JSON.parse(JSON.stringify(t))}const Ga=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Hk=[502,503,504];async function e0(t){var e;if(!Rk(t))throw new Qf(Ga(t),0);if(Hk.includes(t.status))throw new Qf(Ga(t),t.status);let n;try{n=await t.json()}catch(u){throw new Ya(Ga(u),u)}let r;const l=Bk(t);if(l&&l.getTime()>=mw["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 Wx(Ga(n),t.status,((e=n.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new Ss}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 Wx(Ga(n),t.status,n.weak_password.reasons);throw new xk(Ga(n),t.status||500,r)}const Gk=(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 Re(t,e,n,r){var l;const u=Object.assign({},r?.headers);u[Jf]||(u[Jf]=mw["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 h=Object.keys(d).length?"?"+new URLSearchParams(d).toString():"",m=await Fk(t,e,n+h,{headers:u,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(m):{data:Object.assign({},m),error:null}}async function Fk(t,e,n,r,l,u){const d=Gk(e,r,l,u);let h;try{h=await t(n,Object.assign({},d))}catch(m){throw console.error(m),new Qf(Ga(m),0)}if(h.ok||await e0(h),r?.noResolveJson)return h;try{return await h.json()}catch(m){await e0(m)}}function Vs(t){var e;let n=null;Wk(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=Ek(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:n,user:r},error:null}}function t0(t){const e=Vs(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 ua(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function Kk(t){return{data:t,error:null}}function Yk(t){const{action_link:e,email_otp:n,hashed_token:r,redirect_to:l,verification_type:u}=t,d=vi(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:n,hashed_token:r,redirect_to:l,verification_type:u},m=Object.assign({},d);return{data:{properties:h,user:m},error:null}}function s0(t){return t}function Wk(t){return t.access_token&&t.refresh_token&&t.expires_in}const df=["global","local","others"];class Xk{constructor({url:e="",headers:n={},fetch:r}){this.url=e,this.headers=n,this.fetch=yw(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=df[0]){if(df.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${df.join(", ")}`);try{return await Re(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Te(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,n={}){try{return await Re(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:ua})}catch(r){if(Te(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:n}=e,r=vi(e,["options"]),l=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(l.new_email=r?.newEmail,delete l.newEmail),await Re(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:l,headers:this.headers,xform:Yk,redirectTo:n?.redirectTo})}catch(n){if(Te(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:ua})}catch(n){if(Te(n))return{data:{user:null},error:n};throw n}}async listUsers(e){var n,r,l,u,d,h,m;try{const p={nextPage:null,lastPage:0,total:0},y=await Re(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:s0});if(y.error)throw y.error;const x=await y.json(),w=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,j=(m=(h=y.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&m!==void 0?m:[];return j.length>0&&(j.forEach(k=>{const S=parseInt(k.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(k.split(";")[1].split("=")[1]);p[`${_}Page`]=S}),p.total=parseInt(w)),{data:Object.assign(Object.assign({},x),p),error:null}}catch(p){if(Te(p))return{data:{users:[]},error:p};throw p}}async getUserById(e){Wr(e);try{return await Re(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:ua})}catch(n){if(Te(n))return{data:{user:null},error:n};throw n}}async updateUserById(e,n){Wr(e);try{return await Re(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:n,headers:this.headers,xform:ua})}catch(r){if(Te(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,n=!1){Wr(e);try{return await Re(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:n},xform:ua})}catch(r){if(Te(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){Wr(e.userId);try{const{data:n,error:r}=await Re(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(Te(n))return{data:null,error:n};throw n}}async _deleteFactor(e){Wr(e.userId),Wr(e.id);try{return{data:await Re(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(n){if(Te(n))return{data:null,error:n};throw n}}async _listOAuthClients(e){var n,r,l,u,d,h,m;try{const p={nextPage:null,lastPage:0,total:0},y=await Re(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:s0});if(y.error)throw y.error;const x=await y.json(),w=(d=y.headers.get("x-total-count"))!==null&&d!==void 0?d:0,j=(m=(h=y.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&m!==void 0?m:[];return j.length>0&&(j.forEach(k=>{const S=parseInt(k.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(k.split(";")[1].split("=")[1]);p[`${_}Page`]=S}),p.total=parseInt(w)),{data:Object.assign(Object.assign({},x),p),error:null}}catch(p){if(Te(p))return{data:{clients:[]},error:p};throw p}}async _createOAuthClient(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Te(n))return{data:null,error:n};throw n}}async _getOAuthClient(e){try{return await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Te(n))return{data:null,error:n};throw n}}async _updateOAuthClient(e,n){try{return await Re(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:n,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Te(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(e){try{return await Re(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Te(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(e){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Te(n))return{data:null,error:n};throw n}}}function n0(t={}){return{getItem:e=>t[e]||null,setItem:(e,n)=>{t[e]=n},removeItem:e=>{delete t[e]}}}const Xr={debug:!!(globalThis&&gw()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class vw extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class a0 extends vw{}async function Jk(t,e,n){Xr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;e>0&&setTimeout(()=>{r.abort(),Xr.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async l=>{if(l){Xr.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,l.name);try{return await n()}finally{Xr.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,l.name)}}else{if(e===0)throw Xr.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new a0(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Xr.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()}})}catch(l){throw l?.name==="AbortError"?new a0(`Acquiring an exclusive Navigator LockManager lock "${t}" timed out waiting ${e}ms`):l}}function Qk(){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 xw(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Zk(t){return parseInt(t,16)}function eT(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function tT(t){var e;const{chainId:n,domain:r,expirationTime:l,issuedAt:u=new Date,nonce:d,notBefore:h,requestId:m,resources:p,scheme:y,uri:x,version:w}=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(!x)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(w!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${w}`);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 j=xw(t.address),k=y?`${y}://${r}`:r,S=t.statement?`${t.statement}
|
|
37
|
+
`:"",_=`${k} wants you to sign in with your Ethereum account:
|
|
38
|
+
${j}
|
|
39
|
+
|
|
40
|
+
${S}`;let T=`URI: ${x}
|
|
41
|
+
Version: ${w}
|
|
42
|
+
Chain ID: ${n}${d?`
|
|
43
|
+
Nonce: ${d}`:""}
|
|
44
|
+
Issued At: ${u.toISOString()}`;if(l&&(T+=`
|
|
45
|
+
Expiration Time: ${l.toISOString()}`),h&&(T+=`
|
|
46
|
+
Not Before: ${h.toISOString()}`),m&&(T+=`
|
|
47
|
+
Request ID: ${m}`),p){let C=`
|
|
48
|
+
Resources:`;for(const A of p){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}`);C+=`
|
|
49
|
+
- ${A}`}T+=C}return`${_}
|
|
50
|
+
${T}`}class At 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 ru extends At{constructor(e,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:e}),this.name="WebAuthnUnknownError",this.originalError=n}}function sT({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 At({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 At({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 At({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 At({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 At({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new At({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return u.pubKeyCredParams.filter(h=>h.type==="public-key").length===0?new At({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new At({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(bw(d)){if(u.rp.id!==d)return new At({message:`The RP ID "${u.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new At({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 At({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 At({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 At({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function nT({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 At({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new At({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(bw(r)){if(n.rpId!==r)return new At({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new At({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new At({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 At({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class aT{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 rT=new aT;function iT(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=vi(t,["challenge","user","excludeCredentials"]),u=di(e).buffer,d=Object.assign(Object.assign({},n),{id:di(n.id).buffer}),h=Object.assign(Object.assign({},l),{challenge:u,user:d});if(r&&r.length>0){h.excludeCredentials=new Array(r.length);for(let m=0;m<r.length;m++){const p=r[m];h.excludeCredentials[m]=Object.assign(Object.assign({},p),{id:di(p.id).buffer,type:p.type||"public-key",transports:p.transports})}}return h}function oT(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=vi(t,["challenge","allowCredentials"]),l=di(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 h=n[d];u.allowCredentials[d]=Object.assign(Object.assign({},h),{id:di(h.id).buffer,type:h.type||"public-key",transports:h.transports})}}return u}function lT(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:Wa(new Uint8Array(t.response.attestationObject)),clientDataJSON:Wa(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function cT(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:Wa(new Uint8Array(l.authenticatorData)),clientDataJSON:Wa(new Uint8Array(l.clientDataJSON)),signature:Wa(new Uint8Array(l.signature)),userHandle:l.userHandle?Wa(new Uint8Array(l.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function bw(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function r0(){var t,e;return!!(Gt()&&"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 uT(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new ru("Browser returned unexpected credential type",e)}:{data:null,error:new ru("Empty credential response",e)}}catch(e){return{data:null,error:sT({error:e,options:t})}}}async function dT(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new ru("Browser returned unexpected credential type",e)}:{data:null,error:new ru("Empty credential response",e)}}catch(e){return{data:null,error:nT({error:e,options:t})}}}const hT={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},fT={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function iu(...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 h=r[u];e(h)?r[u]=iu(h,d):r[u]=iu(d)}else r[u]=d}return r}function mT(t,e){return iu(hT,t,e||{})}function pT(t,e){return iu(fT,t,e||{})}class gT{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){var d;try{const{data:h,error:m}=await this.client.mfa.challenge({factorId:e,webauthn:n});if(!h)return{data:null,error:m};const p=l??rT.createNewAbortSignal();if(h.webauthn.type==="create"){const{user:y}=h.webauthn.credential_options.publicKey;if(!y.name){const x=r;if(x)y.name=`${y.id}:${x}`;else{const j=(await this.client.getUser()).data.user,k=((d=j?.user_metadata)===null||d===void 0?void 0:d.name)||j?.email||j?.id||"User";y.name=`${y.id}:${k}`}}y.displayName||(y.displayName=y.name)}switch(h.webauthn.type){case"create":{const y=mT(h.webauthn.credential_options.publicKey,u?.create),{data:x,error:w}=await uT({publicKey:y,signal:p});return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}case"request":{const y=pT(h.webauthn.credential_options.publicKey,u?.request),{data:x,error:w}=await dT(Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:y,signal:p}));return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}}}catch(h){return Te(h)?{data:null,error:h}:{data:null,error:new Ya("Unexpected error in challenge",h)}}}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 Bo("rpId is required for WebAuthn authentication")};try{if(!r0())return{data:null,error:new Ya("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this.challenge({factorId:e,webauthn:{rpId:n,rpOrigins:r},signal:l},{request:u});if(!d)return{data:null,error:h};const{webauthn:m}=d;return this._verify({factorId:e,challengeId:d.challengeId,webauthn:{type:m.type,rpId:n,rpOrigins:r,credential_response:m.credential_response}})}catch(d){return Te(d)?{data:null,error:d}:{data:null,error:new Ya("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 Bo("rpId is required for WebAuthn registration")};try{if(!r0())return{data:null,error:new Ya("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this._enroll({friendlyName:e});if(!d)return await this.client.mfa.listFactors().then(y=>{var x;return(x=y.data)===null||x===void 0?void 0:x.all.find(w=>w.factor_type==="webauthn"&&w.friendly_name===e&&w.status!=="unverified")}).then(y=>y?this.client.mfa.unenroll({factorId:y?.id}):void 0),{data:null,error:h};const{data:m,error:p}=await this._challenge({factorId:d.id,friendlyName:d.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:l},{create:u});return m?this._verify({factorId:d.id,challengeId:m.challengeId,webauthn:{rpId:n,rpOrigins:r,type:m.webauthn.type,credential_response:m.webauthn.credential_response}}):{data:null,error:p}}catch(d){return Te(d)?{data:null,error:d}:{data:null,error:new Ya("Unexpected error in register",d)}}}}Qk();const yT={url:mk,storageKey:pk,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:gk,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4,skipAutoInitialize:!1};async function i0(t,e,n){return await n()}const Jr={};class Io{get jwks(){var e,n;return(n=(e=Jr[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(e){Jr[this.storageKey]=Object.assign(Object.assign({},Jr[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,n;return(n=(e=Jr[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Jr[this.storageKey]=Object.assign(Object.assign({},Jr[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({},yT),e);if(this.storageKey=u.storageKey,this.instanceID=(n=Io.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,Io.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!u.debug,typeof u.debug=="function"&&(this.logger=u.debug),this.instanceID>0&&Gt()){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 Xk({url:u.url,headers:u.headers,fetch:u.fetch}),this.url=u.url,this.headers=u.headers,this.fetch=yw(u.fetch),this.lock=u.lock||i0,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&&Gt()&&(!((r=globalThis?.navigator)===null||r===void 0)&&r.locks)?this.lock=Jk:this.lock=i0,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 gT(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:gw()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=n0(this.memoryStorage)),u.userStorage&&(this.userStorage=u.userStorage)):(this.memoryStorage={},this.storage=n0(this.memoryStorage)),Gt()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(d){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",d)}(l=this.broadcastChannel)===null||l===void 0||l.addEventListener("message",async d=>{this._debug("received broadcast notification from other tab or client",d);try{await this._notifyAllSubscribers(d.data.event,d.data.session,!1)}catch(h){this._debug("#broadcastChannel","error",h)}})}u.skipAutoInitialize||this.initialize().catch(d=>{this._debug("#initialize()","error",d)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${fw}) ${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(Gt()&&(n=Ak(window.location.href),this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce")),Gt()&&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),wk(u)){const m=(e=u.details)===null||e===void 0?void 0:e.code;if(m==="identity_already_exists"||m==="identity_not_found"||m==="single_identity_not_deletable")return{error:u}}return{error:u}}const{session:d,redirectType:h}=l;return this._debug("#_initialize()","detected session in URL",d,"redirect type",h),await this._saveSession(d),setTimeout(async()=>{h==="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 Te(n)?this._returnResult({error:n}):this._returnResult({error:new Ya("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var n,r,l;try{const u=await Re(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:Vs}),{data:d,error:h}=u;if(h||!d)return this._returnResult({data:{user:null,session:null},error:h});const m=d.session,p=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:p,session:m},error:null})}catch(u){if(Te(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:x,options:w}=e;let j=null,k=null;this.flowType==="pkce"&&([j,k]=await Yr(this.storage,this.storageKey)),u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:w?.emailRedirectTo,body:{email:y,password:x,data:(n=w?.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:w?.captchaToken},code_challenge:j,code_challenge_method:k},xform:Vs})}else if("phone"in e){const{phone:y,password:x,options:w}=e;u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:x,data:(r=w?.data)!==null&&r!==void 0?r:{},channel:(l=w?.channel)!==null&&l!==void 0?l:"sms",gotrue_meta_security:{captcha_token:w?.captchaToken}},xform:Vs})}else throw new Ac("You must provide either an email or phone number and a password");const{data:d,error:h}=u;if(h||!d)return await Ht(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:h});const m=d.session,p=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:p,session:m},error:null})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Te(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:h}=e;n=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:t0})}else if("phone"in e){const{phone:u,password:d,options:h}=e;n=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:t0})}else throw new Ac("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 Kr;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(Te(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,h,m,p,y,x,w;let j,k;if("message"in e)j=e.message,k=e.signature;else{const{chain:S,wallet:_,statement:T,options:C}=e;let A;if(Gt())if(typeof _=="object")A=_;else{const B=window;if("ethereum"in B&&typeof B.ethereum=="object"&&"request"in B.ethereum&&typeof B.ethereum.request=="function")A=B.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 _!="object"||!C?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=_}const E=new URL((n=C?.url)!==null&&n!==void 0?n:window.location.href),M=await A.request({method:"eth_requestAccounts"}).then(B=>B).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!M||M.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const P=xw(M[0]);let U=(r=C?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!U){const B=await A.request({method:"eth_chainId"});U=Zk(B)}const R={domain:E.host,address:P,statement:T,uri:E.href,version:"1",chainId:U,nonce:(l=C?.signInWithEthereum)===null||l===void 0?void 0:l.nonce,issuedAt:(d=(u=C?.signInWithEthereum)===null||u===void 0?void 0:u.issuedAt)!==null&&d!==void 0?d:new Date,expirationTime:(h=C?.signInWithEthereum)===null||h===void 0?void 0:h.expirationTime,notBefore:(m=C?.signInWithEthereum)===null||m===void 0?void 0:m.notBefore,requestId:(p=C?.signInWithEthereum)===null||p===void 0?void 0:p.requestId,resources:(y=C?.signInWithEthereum)===null||y===void 0?void 0:y.resources};j=tT(R),k=await A.request({method:"personal_sign",params:[eT(j),P]})}try{const{data:S,error:_}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:j,signature:k},!((x=e.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(w=e.options)===null||w===void 0?void 0:w.captchaToken}}:null),xform:Vs});if(_)throw _;if(!S||!S.session||!S.user){const T=new Kr;return this._returnResult({data:{user:null,session:null},error:T})}return S.session&&(await this._saveSession(S.session),await this._notifyAllSubscribers("SIGNED_IN",S.session)),this._returnResult({data:Object.assign({},S),error:_})}catch(S){if(Te(S))return this._returnResult({data:{user:null,session:null},error:S});throw S}}async signInWithSolana(e){var n,r,l,u,d,h,m,p,y,x,w,j;let k,S;if("message"in e)k=e.message,S=e.signature;else{const{chain:_,wallet:T,statement:C,options:A}=e;let E;if(Gt())if(typeof T=="object")E=T;else{const P=window;if("solana"in P&&typeof P.solana=="object"&&("signIn"in P.solana&&typeof P.solana.signIn=="function"||"signMessage"in P.solana&&typeof P.solana.signMessage=="function"))E=P.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.");E=T}const M=new URL((n=A?.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in E&&E.signIn){const P=await E.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},A?.signInWithSolana),{version:"1",domain:M.host,uri:M.href}),C?{statement:C}:null));let U;if(Array.isArray(P)&&P[0]&&typeof P[0]=="object")U=P[0];else if(P&&typeof P=="object"&&"signedMessage"in P&&"signature"in P)U=P;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in U&&"signature"in U&&(typeof U.signedMessage=="string"||U.signedMessage instanceof Uint8Array)&&U.signature instanceof Uint8Array)k=typeof U.signedMessage=="string"?U.signedMessage:new TextDecoder().decode(U.signedMessage),S=U.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in E)||typeof E.signMessage!="function"||!("publicKey"in E)||typeof E!="object"||!E.publicKey||!("toBase58"in E.publicKey)||typeof E.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");k=[`${M.host} wants you to sign in with your Solana account:`,E.publicKey.toBase58(),...C?["",C,""]:[""],"Version: 1",`URI: ${M.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}`]:[],...!((h=A?.signInWithSolana)===null||h===void 0)&&h.chainId?[`Chain ID: ${A.signInWithSolana.chainId}`]:[],...!((m=A?.signInWithSolana)===null||m===void 0)&&m.nonce?[`Nonce: ${A.signInWithSolana.nonce}`]:[],...!((p=A?.signInWithSolana)===null||p===void 0)&&p.requestId?[`Request ID: ${A.signInWithSolana.requestId}`]:[],...!((x=(y=A?.signInWithSolana)===null||y===void 0?void 0:y.resources)===null||x===void 0)&&x.length?["Resources",...A.signInWithSolana.resources.map(U=>`- ${U}`)]:[]].join(`
|
|
51
|
+
`);const P=await E.signMessage(new TextEncoder().encode(k),"utf8");if(!P||!(P instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");S=P}}try{const{data:_,error:T}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:k,signature:Wa(S)},!((w=e.options)===null||w===void 0)&&w.captchaToken?{gotrue_meta_security:{captcha_token:(j=e.options)===null||j===void 0?void 0:j.captchaToken}}:null),xform:Vs});if(T)throw T;if(!_||!_.session||!_.user){const C=new Kr;return this._returnResult({data:{user:null,session:null},error:C})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign({},_),error:T})}catch(_){if(Te(_))return this._returnResult({data:{user:null,session:null},error:_});throw _}}async _exchangeCodeForSession(e){const n=await Ia(this.storage,`${this.storageKey}-code-verifier`),[r,l]=(n??"").split("/");try{if(!r&&this.flowType==="pkce")throw new Sk;const{data:u,error:d}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:Vs});if(await Ht(this.storage,`${this.storageKey}-code-verifier`),d)throw d;if(!u||!u.session||!u.user){const h=new Kr;return this._returnResult({data:{user:null,session:null,redirectType:null},error:h})}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 Ht(this.storage,`${this.storageKey}-code-verifier`),Te(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,h=await Re(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:Vs}),{data:m,error:p}=h;if(p)return this._returnResult({data:{user:null,session:null},error:p});if(!m||!m.session||!m.user){const y=new Kr;return this._returnResult({data:{user:null,session:null},error:y})}return m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("SIGNED_IN",m.session)),this._returnResult({data:m,error:p})}catch(n){if(Te(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:h,options:m}=e;let p=null,y=null;this.flowType==="pkce"&&([p,y]=await Yr(this.storage,this.storageKey));const{error:x}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(n=m?.data)!==null&&n!==void 0?n:{},create_user:(r=m?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},code_challenge:p,code_challenge_method:y},redirectTo:m?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:x})}if("phone"in e){const{phone:h,options:m}=e,{data:p,error:y}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(l=m?.data)!==null&&l!==void 0?l:{},create_user:(u=m?.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},channel:(d=m?.channel)!==null&&d!==void 0?d:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:p?.message_id},error:y})}throw new Ac("You must provide either an email or phone number.")}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Te(h))return this._returnResult({data:{user:null,session:null},error:h});throw h}}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:h}=await Re(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:u}}),redirectTo:l,xform:Vs});if(h)throw h;if(!d)throw new Error("An error occurred on token verification.");const m=d.session,p=d.user;return m?.access_token&&(await this._saveSession(m),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",m)),this._returnResult({data:{user:p,session:m},error:null})}catch(l){if(Te(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithSSO(e){var n,r,l,u,d;try{let h=null,m=null;this.flowType==="pkce"&&([h,m]=await Yr(this.storage,this.storageKey));const p=await Re(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:h,code_challenge_method:m}),headers:this.headers,xform:Kk});return!((u=p.data)===null||u===void 0)&&u.url&&Gt()&&!(!((d=e.options)===null||d===void 0)&&d.skipBrowserRedirect)&&window.location.assign(p.data.url),this._returnResult(p)}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Te(h))return this._returnResult({data:null,error:h});throw h}}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 Ss;const{error:l}=await Re(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(Te(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 Re(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:h}=await Re(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:h})}throw new Ac("You must provide either an email or phone number and a type")}catch(n){if(Te(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 Ia(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()<of:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const d=await Ia(this.userStorage,this.storageKey+"-user");d?.user?e.user=d.user:e.user=uf()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const d={value:this.suppressGetSessionWarning};e.user=qk(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 Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ua}):await this._useSession(async n=>{var r,l,u;const{data:d,error:h}=n;if(h)throw h;return!(!((r=d.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Ss}:await Re(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:ua})})}catch(n){if(Te(n))return lf(n)&&(await this._removeSession(),await Ht(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 Ss;const d=l.session;let h=null,m=null;this.flowType==="pkce"&&e.email!=null&&([h,m]=await Yr(this.storage,this.storageKey));const{data:p,error:y}=await Re(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:m}),jwt:d.access_token,xform:ua});if(y)throw y;return d.user=p.user,await this._saveSession(d),await this._notifyAllSubscribers("USER_UPDATED",d),this._returnResult({data:{user:d.user},error:null})})}catch(r){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Te(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 Ss;const n=Date.now()/1e3;let r=n,l=!0,u=null;const{payload:d}=Oc(e.access_token);if(d.exp&&(r=d.exp,l=r<=n),l){const{data:h,error:m}=await this._callRefreshToken(e.refresh_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h)return{data:{user:null,session:null},error:null};u=h}else{const{data:h,error:m}=await this._getUser(e.access_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});u={access_token:e.access_token,refresh_token:e.refresh_token,user:h.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(Te(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:h}=n;if(h)throw h;e=(r=d.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new Ss;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(Te(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(e,n){try{if(!Gt())throw new Rc("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Rc(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 Yx("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Rc("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 Yx("No code detected.");const{data:C,error:A}=await this._exchangeCodeForSession(e.code);if(A)throw A;const E=new URL(window.location.href);return E.searchParams.delete("code"),window.history.replaceState(window.history.state,"",E.toString()),{data:{session:C.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:l,access_token:u,refresh_token:d,expires_in:h,expires_at:m,token_type:p}=e;if(!u||!h||!d||!p)throw new Rc("No session defined in URL");const y=Math.round(Date.now()/1e3),x=parseInt(h);let w=y+x;m&&(w=parseInt(m));const j=w-y;j*1e3<=si&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${j}s, should have been closer to ${x}s`);const k=w-x;y-k>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",k,w,y):y-k<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",k,w,y);const{data:S,error:_}=await this._getUser(u);if(_)throw _;const T={provider_token:r,provider_refresh_token:l,access_token:u,expires_in:x,expires_at:w,refresh_token:d,token_type:p,user:S.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(Te(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 Ia(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&&!lf(u))return this._returnResult({error:u});const d=(r=l.session)===null||r===void 0?void 0:r.access_token;if(d){const{error:h}=await this.admin.signOut(d,e);if(h&&!(bk(h)&&(h.status===404||h.status===401||h.status===403)||lf(h)))return this._returnResult({error:h})}return e!=="others"&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const n=Ck(),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 Yr(this.storage,this.storageKey,!0));try{return await Re(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 Ht(this.storage,`${this.storageKey}-code-verifier`),Te(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(Te(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,h,m,p,y;const{data:x,error:w}=u;if(w)throw w;const j=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(d=e.options)===null||d===void 0?void 0:d.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(m=e.options)===null||m===void 0?void 0:m.queryParams,skipBrowserRedirect:!0});return await Re(this.fetch,"GET",j,{headers:this.headers,jwt:(y=(p=x.session)===null||p===void 0?void 0:p.access_token)!==null&&y!==void 0?y:void 0})});if(l)throw l;return Gt()&&!(!((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(Te(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:h,token:m,access_token:p,nonce:y}=e,x=await Re(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:h,id_token:m,access_token:p,nonce:y,link_identity:!0,gotrue_meta_security:{captcha_token:d?.captchaToken}},xform:Vs}),{data:w,error:j}=x;return j?this._returnResult({data:{user:null,session:null},error:j}):!w||!w.session||!w.user?this._returnResult({data:{user:null,session:null},error:new Kr}):(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("USER_UPDATED",w.session)),this._returnResult({data:w,error:j}))}catch(l){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Te(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 Re(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(Te(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 Mk(async l=>(l>0&&await Ok(200*Math.pow(2,l-1)),this._debug(n,"refreshing attempt",l),await Re(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Vs})),(l,u)=>{const d=200*Math.pow(2,l);return u&&cf(u)&&Date.now()+d-r<si})}catch(r){if(this._debug(n,"error",r),Te(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),Gt()&&!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 Ia(this.storage,this.storageKey);if(l&&this.userStorage){let d=await Ia(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!d&&(d={user:l.user},await ni(this.userStorage,this.storageKey+"-user",d)),l.user=(e=d?.user)!==null&&e!==void 0?e:uf()}else if(l&&!l.user&&!l.user){const d=await Ia(this.storage,this.storageKey+"-user");d&&d?.user?(l.user=d.user,await Ht(this.storage,this.storageKey+"-user"),await ni(this.storage,this.storageKey,l)):l.user=uf()}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()<of;if(this._debug(r,`session has${u?"":" not"} expired with margin of ${of}s`),u){if(this.autoRefreshToken&&l.refresh_token){const{error:d}=await this._callRefreshToken(l.refresh_token);d&&(console.error(d),cf(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:h}=await this._getUser(l.access_token);!h&&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 Ss;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const l=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(l,"begin");try{this.refreshingDeferred=new Nu;const{data:u,error:d}=await this._refreshAccessToken(e);if(d)throw d;if(!u.session)throw new Ss;await this._saveSession(u.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",u.session);const h={data:u.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(u){if(this._debug(l,"error",u),Te(u)){const d={data:null,error:u};return cf(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 h=>{try{await h.callback(e,n)}catch(m){u.push(m)}});if(await Promise.all(d),u.length>0){for(let h=0;h<u.length;h+=1)console.error(u[h]);throw u[0]}}finally{this._debug(l,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ht(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 ni(this.userStorage,this.storageKey+"-user",{user:n.user});const l=Object.assign({},n);delete l.user;const u=Zx(l);await ni(this.storage,this.storageKey,u)}else{const l=Zx(n);await ni(this.storage,this.storageKey,l)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ht(this.storage,this.storageKey),await Ht(this.storage,this.storageKey+"-code-verifier"),await Ht(this.storage,this.storageKey+"-user"),this.userStorage&&await Ht(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Gt()&&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(),si);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)/si);this._debug("#_autoRefreshTokenTick()",`access token expires in ${l} ticks, a tick lasts ${si}ms, refresh threshold is ${Xf} ticks`),l<=Xf&&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 vw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Gt()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},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 Yr(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(u)}`,code_challenge_method:`${encodeURIComponent(d)}`});l.push(h.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 Re(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(Te(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 h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:m,error:p}=await Re(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(r=u?.session)===null||r===void 0?void 0:r.access_token});return p?this._returnResult({data:null,error:p}):(e.factorType==="totp"&&m.type==="totp"&&(!((l=m?.totp)===null||l===void 0)&&l.qr_code)&&(m.totp.qr_code=`data:image/svg+xml;utf-8,${m.totp.qr_code}`),this._returnResult({data:m,error:null}))})}catch(n){if(Te(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"?lT(e.webauthn.credential_response):cT(e.webauthn.credential_response)})}:{code:e.code}),{data:h,error:m}=await Re(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 m?this._returnResult({data:null,error:m}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+h.expires_in},h)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",h),this._returnResult({data:h,error:m}))})}catch(n){if(Te(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 Re(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:h}=d;if(h.type!=="webauthn")return{data:h,error:null};switch(h.webauthn.type){case"create":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:iT(h.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:oT(h.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(Te(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(e){var n,r,l,u;if(e)try{const{payload:j}=Oc(e);let k=null;j.aal&&(k=j.aal);let S=k;const{data:{user:_},error:T}=await this.getUser(e);if(T)return this._returnResult({data:null,error:T});((r=(n=_?.factors)===null||n===void 0?void 0:n.filter(E=>E.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(S="aal2");const A=j.amr||[];return{data:{currentLevel:k,nextLevel:S,currentAuthenticationMethods:A},error:null}}catch(j){if(Te(j))return this._returnResult({data:null,error:j});throw j}const{data:{session:d},error:h}=await this.getSession();if(h)return this._returnResult({data:null,error:h});if(!d)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:m}=Oc(d.access_token);let p=null;m.aal&&(p=m.aal);let y=p;((u=(l=d.user.factors)===null||l===void 0?void 0:l.filter(j=>j.status==="verified"))!==null&&u!==void 0?u:[]).length>0&&(y="aal2");const w=m.amr||[];return{data:{currentLevel:p,nextLevel:y,currentAuthenticationMethods:w},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 Re(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 Ss})})}catch(n){if(Te(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 Ss});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"approve"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!n?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(r){if(Te(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 Ss});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"deny"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!n?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(r){if(Te(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 Re(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 Ss})})}catch(e){if(Te(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 Re(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 Ss})})}catch(n){if(Te(n))return this._returnResult({data:null,error:n});throw n}}async fetchJwk(e,n={keys:[]}){let r=n.keys.find(h=>h.kid===e);if(r)return r;const l=Date.now();if(r=this.jwks.keys.find(h=>h.kid===e),r&&this.jwks_cached_at+vk>l)return r;const{data:u,error:d}=await Re(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(h=>h.kid===e),!r)?null:r}async getClaims(e,n={}){try{let r=e;if(!r){const{data:j,error:k}=await this.getSession();if(k||!j.session)return this._returnResult({data:null,error:k});r=j.session.access_token}const{header:l,payload:u,signature:d,raw:{header:h,payload:m}}=Oc(r);n?.allowExpired||Ik(u.exp);const p=!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(!p){const{error:j}=await this.getUser(r);if(j)throw j;return{data:{claims:u,header:l,signature:d},error:null}}const y=Vk(l.alg),x=await crypto.subtle.importKey("jwk",p,y,!0,["verify"]);if(!await crypto.subtle.verify(y,x,d,Tk(`${h}.${m}`)))throw new Zf("Invalid JWT signature");return{data:{claims:u,header:l,signature:d},error:null}}catch(r){if(Te(r))return this._returnResult({data:null,error:r});throw r}}}Io.nextInstanceID={};const vT=Io,xT="2.97.0";let _o="";typeof Deno<"u"?_o="deno":typeof document<"u"?_o="web":typeof navigator<"u"&&navigator.product==="ReactNative"?_o="react-native":_o="node";const bT={"X-Client-Info":`supabase-js-${_o}/${xT}`},wT={headers:bT},ST={schema:"public"},jT={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},_T={};function Vo(t){"@babel/helpers - typeof";return Vo=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},Vo(t)}function NT(t,e){if(Vo(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Vo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function kT(t){var e=NT(t,"string");return Vo(e)=="symbol"?e:e+""}function TT(t,e,n){return(e=kT(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o0(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 xt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o0(Object(n),!0).forEach(function(r){TT(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const ET=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),CT=()=>Headers,AT=(t,e,n)=>{const r=ET(n),l=CT();return async(u,d)=>{var h;const m=(h=await e())!==null&&h!==void 0?h:t;let p=new l(d?.headers);return p.has("apikey")||p.set("apikey",t),p.has("Authorization")||p.set("Authorization",`Bearer ${m}`),r(u,xt(xt({},d),{},{headers:p}))}};function RT(t){return t.endsWith("/")?t:t+"/"}function OT(t,e){var n,r;const{db:l,auth:u,realtime:d,global:h}=t,{db:m,auth:p,realtime:y,global:x}=e,w={db:xt(xt({},m),l),auth:xt(xt({},p),u),realtime:xt(xt({},y),d),storage:{},global:xt(xt(xt({},x),h),{},{headers:xt(xt({},(n=x?.headers)!==null&&n!==void 0?n:{}),(r=h?.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return t.accessToken?w.accessToken=t.accessToken:delete w.accessToken,w}function MT(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(RT(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var DT=class extends vT{constructor(t){super(t)}},PT=class{constructor(t,e,n){var r,l;this.supabaseUrl=t,this.supabaseKey=e;const u=MT(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`,h={db:ST,realtime:_T,auth:xt(xt({},jT),{},{storageKey:d}),global:wT},m=OT(n??{},h);if(this.storageKey=(r=m.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(l=m.global.headers)!==null&&l!==void 0?l:{},m.accessToken)this.accessToken=m.accessToken,this.auth=new Proxy({},{get:(y,x)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(x)} is not possible`)}});else{var p;this.auth=this._initSupabaseAuthClient((p=m.auth)!==null&&p!==void 0?p:{},this.headers,m.global.fetch)}this.fetch=AT(e,this._getAccessToken.bind(this),m.global.fetch),this.realtime=this._initRealtimeClient(xt({headers:this.headers,accessToken:this._getAccessToken.bind(this)},m.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(y=>this.realtime.setAuth(y)).catch(y=>console.warn("Failed to set initial Realtime auth token:",y)),this.rest=new b2(new URL("rest/v1",u).href,{headers:this.headers,schema:m.db.schema,fetch:this.fetch,timeout:m.db.timeout,urlLengthLimit:m.db.urlLengthLimit}),this.storage=new fk(this.storageUrl.href,this.headers,this.fetch,n?.storage),m.accessToken||this._listenForAuthEvents()}get functions(){return new h2(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:h,debug:m,throwOnError:p},y,x){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new DT({url:this.authUrl.href,headers:xt(xt({},w),y),storageKey:u,autoRefreshToken:t,persistSession:e,detectSessionInUrl:n,storage:r,userStorage:l,flowType:d,lock:h,debug:m,throwOnError:p,fetch:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(j=>j.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new z2(this.realtimeUrl.href,xt(xt({},t),{},{params:xt(xt({},{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 Bm=(t,e,n)=>new PT(t,e,n);function LT(){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}LT()&&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");function ww(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=ww(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Sw(){for(var t,e,n=0,r="",l=arguments.length;n<l;n++)(t=arguments[n])&&(e=ww(t))&&(r&&(r+=" "),r+=e);return r}const zT=(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},UT=(t,e)=>({classGroupId:t,validator:e}),jw=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),ou="-",l0=[],BT="arbitrary..",IT=t=>{const e=$T(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return VT(d);const h=d.split(ou),m=h[0]===""&&h.length>1?1:0;return _w(h,m,e)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=r[d],p=n[d];return m?p?zT(p,m):m:p||l0}return n[d]||l0}}},_w=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const l=t[e],u=n.nextPart.get(l);if(u){const p=_w(t,e+1,u);if(p)return p}const d=n.validators;if(d===null)return;const h=e===0?t.join(ou):t.slice(e).join(ou),m=d.length;for(let p=0;p<m;p++){const y=d[p];if(y.validator(h))return y.classGroupId}},VT=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?BT+r:void 0})(),$T=t=>{const{theme:e,classGroups:n}=t;return qT(n,e)},qT=(t,e)=>{const n=jw();for(const r in t){const l=t[r];Im(l,n,r,e)}return n},Im=(t,e,n,r)=>{const l=t.length;for(let u=0;u<l;u++){const d=t[u];HT(d,e,n,r)}},HT=(t,e,n,r)=>{if(typeof t=="string"){GT(t,e,n);return}if(typeof t=="function"){FT(t,e,n,r);return}KT(t,e,n,r)},GT=(t,e,n)=>{const r=t===""?e:Nw(e,t);r.classGroupId=n},FT=(t,e,n,r)=>{if(YT(t)){Im(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(UT(n,t))},KT=(t,e,n,r)=>{const l=Object.entries(t),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];Im(m,Nw(e,h),n,r)}},Nw=(t,e)=>{let n=t;const r=e.split(ou),l=r.length;for(let u=0;u<l;u++){const d=r[u];let h=n.nextPart.get(d);h||(h=jw(),n.nextPart.set(d,h)),n=h}return n},YT=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,WT=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)}}},em="!",c0=":",XT=[],u0=(t,e,n,r,l)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:l}),JT=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=l=>{const u=[];let d=0,h=0,m=0,p;const y=l.length;for(let S=0;S<y;S++){const _=l[S];if(d===0&&h===0){if(_===c0){u.push(l.slice(m,S)),m=S+1;continue}if(_==="/"){p=S;continue}}_==="["?d++:_==="]"?d--:_==="("?h++:_===")"&&h--}const x=u.length===0?l:l.slice(m);let w=x,j=!1;x.endsWith(em)?(w=x.slice(0,-1),j=!0):x.startsWith(em)&&(w=x.slice(1),j=!0);const k=p&&p>m?p-m:void 0;return u0(u,j,w,k)};if(e){const l=e+c0,u=r;r=d=>d.startsWith(l)?u(d.slice(l.length)):u0(XT,!1,d,void 0,!0)}if(n){const l=r;r=u=>n({className:u,parseClassName:l})}return r},QT=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],h=d[0]==="[",m=e.has(d);h||m?(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}},ZT=t=>({cache:WT(t.cacheSize),parseClassName:JT(t),sortModifiers:QT(t),...IT(t)}),eE=/\s+/,tE=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:l,sortModifiers:u}=e,d=[],h=t.trim().split(eE);let m="";for(let p=h.length-1;p>=0;p-=1){const y=h[p],{isExternal:x,modifiers:w,hasImportantModifier:j,baseClassName:k,maybePostfixModifierPosition:S}=n(y);if(x){m=y+(m.length>0?" "+m:m);continue}let _=!!S,T=r(_?k.substring(0,S):k);if(!T){if(!_){m=y+(m.length>0?" "+m:m);continue}if(T=r(k),!T){m=y+(m.length>0?" "+m:m);continue}_=!1}const C=w.length===0?"":w.length===1?w[0]:u(w).join(":"),A=j?C+em:C,E=A+T;if(d.indexOf(E)>-1)continue;d.push(E);const M=l(T,_);for(let P=0;P<M.length;++P){const U=M[P];d.push(A+U)}m=y+(m.length>0?" "+m:m)}return m},sE=(...t)=>{let e=0,n,r,l="";for(;e<t.length;)(n=t[e++])&&(r=kw(n))&&(l&&(l+=" "),l+=r);return l},kw=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=kw(t[r]))&&(n&&(n+=" "),n+=e);return n},nE=(t,...e)=>{let n,r,l,u;const d=m=>{const p=e.reduce((y,x)=>x(y),t());return n=ZT(p),r=n.cache.get,l=n.cache.set,u=h,h(m)},h=m=>{const p=r(m);if(p)return p;const y=tE(m,n);return l(m,y),y};return u=d,(...m)=>u(sE(...m))},aE=[],Mt=t=>{const e=n=>n[t]||aE;return e.isThemeGetter=!0,e},Tw=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ew=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rE=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,iE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oE=/\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$/,lE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,uE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>rE.test(t),Be=t=>!!t&&!Number.isNaN(Number(t)),ra=t=>!!t&&Number.isInteger(Number(t)),hf=t=>t.endsWith("%")&&Be(t.slice(0,-1)),Tn=t=>iE.test(t),Cw=()=>!0,dE=t=>oE.test(t)&&!lE.test(t),Vm=()=>!1,hE=t=>cE.test(t),fE=t=>uE.test(t),mE=t=>!Se(t)&&!_e(t),pE=t=>va(t,Ow,Vm),Se=t=>Tw.test(t),Va=t=>va(t,Mw,dE),d0=t=>va(t,jE,Be),gE=t=>va(t,Pw,Cw),yE=t=>va(t,Dw,Vm),h0=t=>va(t,Aw,Vm),vE=t=>va(t,Rw,fE),Mc=t=>va(t,Lw,hE),_e=t=>Ew.test(t),So=t=>ir(t,Mw),xE=t=>ir(t,Dw),f0=t=>ir(t,Aw),bE=t=>ir(t,Ow),wE=t=>ir(t,Rw),Dc=t=>ir(t,Lw,!0),SE=t=>ir(t,Pw,!0),va=(t,e,n)=>{const r=Tw.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},ir=(t,e,n=!1)=>{const r=Ew.exec(t);return r?r[1]?e(r[1]):n:!1},Aw=t=>t==="position"||t==="percentage",Rw=t=>t==="image"||t==="url",Ow=t=>t==="length"||t==="size"||t==="bg-size",Mw=t=>t==="length",jE=t=>t==="number",Dw=t=>t==="family-name",Pw=t=>t==="number"||t==="weight",Lw=t=>t==="shadow",_E=()=>{const t=Mt("color"),e=Mt("font"),n=Mt("text"),r=Mt("font-weight"),l=Mt("tracking"),u=Mt("leading"),d=Mt("breakpoint"),h=Mt("container"),m=Mt("spacing"),p=Mt("radius"),y=Mt("shadow"),x=Mt("inset-shadow"),w=Mt("text-shadow"),j=Mt("drop-shadow"),k=Mt("blur"),S=Mt("perspective"),_=Mt("aspect"),T=Mt("ease"),C=Mt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],M=()=>[...E(),_e,Se],P=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto","contain","none"],R=()=>[_e,Se,m],B=()=>[aa,"full","auto",...R()],se=()=>[ra,"none","subgrid",_e,Se],re=()=>["auto",{span:["full",ra,_e,Se]},ra,_e,Se],ue=()=>[ra,"auto",_e,Se],xe=()=>["auto","min","max","fr",_e,Se],ge=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...R()],F=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],Z=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...R()],ye=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],ne=()=>[t,_e,Se],D=()=>[...E(),f0,h0,{position:[_e,Se]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],J=()=>["auto","cover","contain",bE,pE,{size:[_e,Se]}],H=()=>[hf,So,Va],ae=()=>["","none","full",p,_e,Se],ie=()=>["",Be,So,Va],$=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[Be,hf,f0,h0],Oe=()=>["","none",k,_e,Se],Ue=()=>["none",Be,_e,Se],ft=()=>["none",Be,_e,Se],Ye=()=>[Be,_e,Se],de=()=>[aa,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Tn],breakpoint:[Tn],color:[Cw],container:[Tn],"drop-shadow":[Tn],ease:["in","out","in-out"],font:[mE],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Tn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Tn],shadow:[Tn],spacing:["px",Be],text:[Tn],"text-shadow":[Tn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,Se,_e,_]}],container:["container"],columns:[{columns:[Be,Se,_e,h]}],"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:M()}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:B()}],"inset-x":[{"inset-x":B()}],"inset-y":[{"inset-y":B()}],start:[{"inset-s":B(),start:B()}],end:[{"inset-e":B(),end:B()}],"inset-bs":[{"inset-bs":B()}],"inset-be":[{"inset-be":B()}],top:[{top:B()}],right:[{right:B()}],bottom:[{bottom:B()}],left:[{left:B()}],visibility:["visible","invisible","collapse"],z:[{z:[ra,"auto",_e,Se]}],basis:[{basis:[aa,"full","auto",h,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Be,aa,"auto","initial","none",Se]}],grow:[{grow:["",Be,_e,Se]}],shrink:[{shrink:["",Be,_e,Se]}],order:[{order:[ra,"first","last","none",_e,Se]}],"grid-cols":[{"grid-cols":se()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":ue()}],"col-end":[{"col-end":ue()}],"grid-rows":[{"grid-rows":se()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":ue()}],"row-end":[{"row-end":ue()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":xe()}],"auto-rows":[{"auto-rows":xe()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ge(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...ge()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":ge()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mbs:[{mbs:V()}],mbe:[{mbe:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...Z()]}],"min-inline-size":[{"min-inline":["auto",...Z()]}],"max-inline-size":[{"max-inline":["none",...Z()]}],"block-size":[{block:["auto",...ye()]}],"min-block-size":[{"min-block":["auto",...ye()]}],"max-block-size":[{"max-block":["none",...ye()]}],w:[{w:[h,"screen",...F()]}],"min-w":[{"min-w":[h,"screen","none",...F()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,So,Va]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,SE,gE]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",hf,Se]}],"font-family":[{font:[xE,yE,e]}],"font-features":[{"font-features":[Se]}],"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,_e,Se]}],"line-clamp":[{"line-clamp":[Be,"none",_e,d0]}],leading:[{leading:[u,...R()]}],"list-image":[{"list-image":["none",_e,Se]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",_e,Se]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:ne()}],"text-color":[{text:ne()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:[Be,"from-font","auto",_e,Va]}],"text-decoration-color":[{decoration:ne()}],"underline-offset":[{"underline-offset":[Be,"auto",_e,Se]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",_e,Se]}],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",_e,Se]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:J()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ra,_e,Se],radial:["",_e,Se],conic:[ra,_e,Se]},wE,vE]}],"bg-color":[{bg:ne()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:ne()}],"gradient-via":[{via:ne()}],"gradient-to":[{to:ne()}],rounded:[{rounded:ae()}],"rounded-s":[{"rounded-s":ae()}],"rounded-e":[{"rounded-e":ae()}],"rounded-t":[{"rounded-t":ae()}],"rounded-r":[{"rounded-r":ae()}],"rounded-b":[{"rounded-b":ae()}],"rounded-l":[{"rounded-l":ae()}],"rounded-ss":[{"rounded-ss":ae()}],"rounded-se":[{"rounded-se":ae()}],"rounded-ee":[{"rounded-ee":ae()}],"rounded-es":[{"rounded-es":ae()}],"rounded-tl":[{"rounded-tl":ae()}],"rounded-tr":[{"rounded-tr":ae()}],"rounded-br":[{"rounded-br":ae()}],"rounded-bl":[{"rounded-bl":ae()}],"border-w":[{border:ie()}],"border-w-x":[{"border-x":ie()}],"border-w-y":[{"border-y":ie()}],"border-w-s":[{"border-s":ie()}],"border-w-e":[{"border-e":ie()}],"border-w-bs":[{"border-bs":ie()}],"border-w-be":[{"border-be":ie()}],"border-w-t":[{"border-t":ie()}],"border-w-r":[{"border-r":ie()}],"border-w-b":[{"border-b":ie()}],"border-w-l":[{"border-l":ie()}],"divide-x":[{"divide-x":ie()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ie()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...$(),"hidden","none"]}],"divide-style":[{divide:[...$(),"hidden","none"]}],"border-color":[{border:ne()}],"border-color-x":[{"border-x":ne()}],"border-color-y":[{"border-y":ne()}],"border-color-s":[{"border-s":ne()}],"border-color-e":[{"border-e":ne()}],"border-color-bs":[{"border-bs":ne()}],"border-color-be":[{"border-be":ne()}],"border-color-t":[{"border-t":ne()}],"border-color-r":[{"border-r":ne()}],"border-color-b":[{"border-b":ne()}],"border-color-l":[{"border-l":ne()}],"divide-color":[{divide:ne()}],"outline-style":[{outline:[...$(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Be,_e,Se]}],"outline-w":[{outline:["",Be,So,Va]}],"outline-color":[{outline:ne()}],shadow:[{shadow:["","none",y,Dc,Mc]}],"shadow-color":[{shadow:ne()}],"inset-shadow":[{"inset-shadow":["none",x,Dc,Mc]}],"inset-shadow-color":[{"inset-shadow":ne()}],"ring-w":[{ring:ie()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:ne()}],"ring-offset-w":[{"ring-offset":[Be,Va]}],"ring-offset-color":[{"ring-offset":ne()}],"inset-ring-w":[{"inset-ring":ie()}],"inset-ring-color":[{"inset-ring":ne()}],"text-shadow":[{"text-shadow":["none",w,Dc,Mc]}],"text-shadow-color":[{"text-shadow":ne()}],opacity:[{opacity:[Be,_e,Se]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"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":[Be]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":ne()}],"mask-image-linear-to-color":[{"mask-linear-to":ne()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":ne()}],"mask-image-t-to-color":[{"mask-t-to":ne()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":ne()}],"mask-image-r-to-color":[{"mask-r-to":ne()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":ne()}],"mask-image-b-to-color":[{"mask-b-to":ne()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":ne()}],"mask-image-l-to-color":[{"mask-l-to":ne()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":ne()}],"mask-image-x-to-color":[{"mask-x-to":ne()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":ne()}],"mask-image-y-to-color":[{"mask-y-to":ne()}],"mask-image-radial":[{"mask-radial":[_e,Se]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":ne()}],"mask-image-radial-to-color":[{"mask-radial-to":ne()}],"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":E()}],"mask-image-conic-pos":[{"mask-conic":[Be]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":ne()}],"mask-image-conic-to-color":[{"mask-conic-to":ne()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:J()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",_e,Se]}],filter:[{filter:["","none",_e,Se]}],blur:[{blur:Oe()}],brightness:[{brightness:[Be,_e,Se]}],contrast:[{contrast:[Be,_e,Se]}],"drop-shadow":[{"drop-shadow":["","none",j,Dc,Mc]}],"drop-shadow-color":[{"drop-shadow":ne()}],grayscale:[{grayscale:["",Be,_e,Se]}],"hue-rotate":[{"hue-rotate":[Be,_e,Se]}],invert:[{invert:["",Be,_e,Se]}],saturate:[{saturate:[Be,_e,Se]}],sepia:[{sepia:["",Be,_e,Se]}],"backdrop-filter":[{"backdrop-filter":["","none",_e,Se]}],"backdrop-blur":[{"backdrop-blur":Oe()}],"backdrop-brightness":[{"backdrop-brightness":[Be,_e,Se]}],"backdrop-contrast":[{"backdrop-contrast":[Be,_e,Se]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Be,_e,Se]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Be,_e,Se]}],"backdrop-invert":[{"backdrop-invert":["",Be,_e,Se]}],"backdrop-opacity":[{"backdrop-opacity":[Be,_e,Se]}],"backdrop-saturate":[{"backdrop-saturate":[Be,_e,Se]}],"backdrop-sepia":[{"backdrop-sepia":["",Be,_e,Se]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",_e,Se]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Be,"initial",_e,Se]}],ease:[{ease:["linear","initial",T,_e,Se]}],delay:[{delay:[Be,_e,Se]}],animate:[{animate:["none",C,_e,Se]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,_e,Se]}],"perspective-origin":[{"perspective-origin":M()}],rotate:[{rotate:Ue()}],"rotate-x":[{"rotate-x":Ue()}],"rotate-y":[{"rotate-y":Ue()}],"rotate-z":[{"rotate-z":Ue()}],scale:[{scale:ft()}],"scale-x":[{"scale-x":ft()}],"scale-y":[{"scale-y":ft()}],"scale-z":[{"scale-z":ft()}],"scale-3d":["scale-3d"],skew:[{skew:Ye()}],"skew-x":[{"skew-x":Ye()}],"skew-y":[{"skew-y":Ye()}],transform:[{transform:[_e,Se,"","none","gpu","cpu"]}],"transform-origin":[{origin:M()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:de()}],"translate-x":[{"translate-x":de()}],"translate-y":[{"translate-y":de()}],"translate-z":[{"translate-z":de()}],"translate-none":["translate-none"],accent:[{accent:ne()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:ne()}],"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",_e,Se]}],"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":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",_e,Se]}],fill:[{fill:["none",...ne()]}],"stroke-w":[{stroke:[Be,So,Va,d0]}],stroke:[{stroke:["none",...ne()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},NE=nE(_E);function ve(...t){return NE(Sw(t))}const rt=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("rounded-xl border bg-card text-card-foreground shadow",t),...e}));rt.displayName="Card";const St=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("flex flex-col space-y-1.5 p-6",t),...e}));St.displayName="CardHeader";const jt=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("font-semibold leading-none tracking-tight",t),...e}));jt.displayName="CardTitle";const Kt=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("text-sm text-muted-foreground",t),...e}));Kt.displayName="CardDescription";const ht=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("p-6 pt-0",t),...e}));ht.displayName="CardContent";const ku=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("flex items-center p-6 pt-0",t),...e}));ku.displayName="CardFooter";function lu({className:t}){return o.jsx("img",{src:"/folio-logo.svg",alt:"Folio Logo",className:ve("w-full h-full object-contain",t)})}const zw=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const kE=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const TE=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const m0=t=>{const e=TE(t);return e.charAt(0).toUpperCase()+e.slice(1)};var EE={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 CE=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const AE=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:l="",children:u,iconNode:d,...h},m)=>v.createElement("svg",{ref:m,...EE,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:zw("lucide",l),...!u&&!CE(h)&&{"aria-hidden":"true"},...h},[...d.map(([p,y])=>v.createElement(p,y)),...Array.isArray(u)?u:[u]]));const me=(t,e)=>{const n=v.forwardRef(({className:r,...l},u)=>v.createElement(AE,{ref:u,iconNode:e,className:zw(`lucide-${kE(m0(t))}`,`lucide-${t}`,r),...l}));return n.displayName=m0(t),n};const RE=[["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"}]],mi=me("activity",RE);const OE=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],p0=me("arrow-right",OE);const ME=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],DE=me("book-open",ME);const PE=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],tm=me("bot",PE);const LE=[["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"}]],Uw=me("brain",LE);const zE=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],UE=me("building-2",zE);const BE=[["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"}]],Bw=me("calendar",BE);const IE=[["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"}]],VE=me("camera",IE);const $E=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],an=me("check",$E);const qE=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],$o=me("chevron-down",qE);const HE=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],tl=me("chevron-left",HE);const GE=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],pi=me("chevron-right",GE);const FE=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],cu=me("chevron-up",FE);const KE=[["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"}]],fs=me("circle-alert",KE);const YE=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],WE=me("circle-check-big",YE);const XE=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ks=me("circle-check",XE);const JE=[["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"}]],Iw=me("circle-x",JE);const QE=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],sl=me("clock",QE);const ZE=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],g0=me("cloud",ZE);const eC=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],tC=me("copy",eC);const sC=[["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"}]],$m=me("cpu",sC);const nC=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],aC=me("crown",nC);const rC=[["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"}]],Tu=me("database",rC);const iC=[["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"}]],Vw=me("external-link",iC);const oC=[["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"}]],lC=me("eye-off",oC);const cC=[["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"}]],uC=me("eye",cC);const dC=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],hC=me("file-digit",dC);const fC=[["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"}]],qm=me("file-text",fC);const mC=[["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"}]],$w=me("funnel",mC);const pC=[["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"}]],gC=me("globe",pC);const yC=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],vC=me("hard-drive",yC);const xC=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],bC=me("history",xC);const wC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Hm=me("info",wC);const SC=[["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"}]],gi=me("key",SC);const jC=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],_C=me("layers",jC);const NC=[["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"}]],y0=me("layout-dashboard",NC);const kC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Qe=me("loader-circle",kC);const TC=[["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"}]],qw=me("log-in",TC);const EC=[["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"}]],Hw=me("log-out",EC);const CC=[["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"}]],qo=me("mail",CC);const AC=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],uu=me("message-square",AC);const RC=[["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"}]],Gw=me("minimize-2",RC);const OC=[["path",{d:"M5 12h14",key:"1ays0h"}]],sm=me("minus",OC);const MC=[["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"}]],DC=me("moon",MC);const PC=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],LC=me("package",PC);const zC=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Fw=me("play",zC);const UC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],er=me("plus",UC);const BC=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],Kw=me("refresh-ccw",BC);const IC=[["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"}]],ma=me("refresh-cw",IC);const VC=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["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-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],$C=me("rocket",VC);const qC=[["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"}]],HC=me("save",qC);const GC=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Yw=me("scroll-text",GC);const FC=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],KC=me("search",FC);const YC=[["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"}]],WC=me("send",YC);const XC=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],JC=me("server",XC);const QC=[["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"}]],Gm=me("settings-2",QC);const ZC=[["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"}]],eA=me("settings",ZC);const tA=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],v0=me("share-2",tA);const sA=[["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:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ho=me("shield-alert",sA);const nA=[["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"}]],xa=me("shield-check",nA);const aA=[["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"}]],Cn=me("sparkles",aA);const rA=[["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"}]],iA=me("sun",rA);const oA=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],du=me("tag",oA);const lA=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Go=me("terminal",lA);const cA=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],uA=me("test-tube",cA);const dA=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],hA=me("toggle-left",dA);const fA=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],mA=me("toggle-right",fA);const pA=[["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"}]],sr=me("trash-2",pA);const gA=[["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"}]],Ww=me("triangle-alert",gA);const yA=[["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"}]],nm=me("upload",yA);const vA=[["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"}]],am=me("user-plus",vA);const xA=[["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"}]],Eu=me("user",xA);const bA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],wA=me("users",bA);const SA=[["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"}]],rm=me("volume-2",SA);const jA=[["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"}]],Xw=me("volume-x",jA);const _A=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ps=me("x",_A);const NA=[["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"}]],hu=me("zap",NA),Cu="folio_supabase_config";function x0(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.url=="string"&&typeof e.anonKey=="string"&&e.url.startsWith("http")&&e.anonKey.length>20&&!e.url.includes("placeholder.supabase.co")}function Fo(){try{const e=localStorage.getItem(Cu);if(e){const n=JSON.parse(e);if(x0(n))return n}}catch{}const t={url:void 0,anonKey:void 0};return x0(t)?t:null}function ff(t){localStorage.setItem(Cu,JSON.stringify(t))}function kA(){localStorage.removeItem(Cu)}async function TA(t,e){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 anon key format"};if(r)return{valid:!0};const l=new AbortController,u=setTimeout(()=>l.abort("Validation timeout"),12e3);try{const d=await fetch(`${t}/rest/v1/`,{method:"GET",headers:{apikey:e,Authorization:`Bearer ${e}`},signal:l.signal});return d.ok?(clearTimeout(u),{valid:!0}):(clearTimeout(u),{valid:!1,error:`Connection failed (${d.status})`})}catch(d){return clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?{valid:!1,error:"Connection validation timed out (12s). Check project URL/key and network."}:{valid:!1,error:d instanceof Error?d.message:"Connection failed"}}}function EA(){return localStorage.getItem(Cu)?"ui":"none"}let Pc=null;function hs(){const t=Fo();return t?(Pc||(Pc=Bm(t.url,t.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}})),Pc):(Pc=null,null)}function mf(){const t=Fo(),e=t?`${t.url}/functions/v1`:"",n=t?.anonKey??"",u=window.location.port==="5173"?void 0||"http://localhost:3006":window.location.origin;return{edgeFunctionsUrl:e,expressApiUrl:u,anonKey:n}}const pf="folio_active_workspace_id";class CA{edgeFunctionsUrl;expressApiUrl;anonKey;constructor(){const e=mf();this.edgeFunctionsUrl=e.edgeFunctionsUrl,this.expressApiUrl=e.expressApiUrl,this.anonKey=e.anonKey}async request(e,n,r={}){const{auth:l=!1,token:u,workspaceId:d,...h}=r,m={"Content-Type":"application/json",...h.headers||{}},p=this.resolveWorkspaceId(d??null);p&&(m["X-Workspace-Id"]=p),l&&u&&(m.Authorization=`Bearer ${u}`);try{const y=await fetch(`${e}${n}`,{...h,headers:m}),x=await y.json().catch(()=>({}));return y.ok?{data:x}:{error:{code:x?.error?.code||"API_ERROR",message:x?.error?.message||x?.error||`Request failed (${y.status})`}}}catch(y){return{error:{code:"NETWORK_ERROR",message:y instanceof Error?y.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=mf(),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})}get(e,n={}){return this.expressRequest(e,{method:"GET",...n,auth:!0})}post(e,n,r={}){return this.expressRequest(e,{method:"POST",body:n?JSON.stringify(n):void 0,...r,auth:!0})}resolveWorkspaceId(e){const n=(e??this.getActiveWorkspaceId()??"").trim();return n.length>0?n:null}getActiveWorkspaceId(){if(typeof window>"u")return null;const n=(window.localStorage.getItem(pf)??"").trim();return n.length>0?n:null}setActiveWorkspaceId(e){if(typeof window>"u")return;const n=(e??"").trim();n?window.localStorage.setItem(pf,n):window.localStorage.removeItem(pf),window.dispatchEvent(new CustomEvent("folio:workspace-changed",{detail:{workspaceId:n||null}}))}getWorkspaces(e){return this.expressRequest("/api/workspaces",{method:"GET",auth:!!e,token:e})}getWorkspaceMembers(e,n){return this.expressRequest(`/api/workspaces/${e}/members`,{method:"GET",auth:!!n,token:n})}inviteWorkspaceMember(e,n,r){return this.expressRequest(`/api/workspaces/${e}/members/invite`,{method:"POST",auth:!!r,token:r,body:JSON.stringify(n)})}updateWorkspaceMemberRole(e,n,r,l){return this.expressRequest(`/api/workspaces/${e}/members/${n}`,{method:"PATCH",auth:!!l,token:l,body:JSON.stringify({role:r})})}removeWorkspaceMember(e,n,r){return this.expressRequest(`/api/workspaces/${e}/members/${n}`,{method:"DELETE",auth:!!r,token:r})}getChatSessions(e){return this.expressRequest("/api/chat/sessions",{method:"GET",auth:!!e,token:e})}getDashboardStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}createChatSession(e){return this.expressRequest("/api/chat/sessions",{method:"POST",auth:!!e,token:e})}getChatMessages(e,n){return this.expressRequest(`/api/chat/sessions/${e}/messages`,{method:"GET",auth:!!n,token:n})}sendChatMessage(e,n){return this.expressRequest("/api/chat/message",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}getHealth(){return this.expressRequest("/api/health",{method:"GET"})}testSupabase(e,n){return this.expressRequest("/api/setup/test-supabase",{method:"POST",body:JSON.stringify({url:e,anonKey:n})})}dispatchProcessingJob(e,n){return this.expressRequest("/api/processing/dispatch",{method:"POST",auth:!!n,token:n,body:JSON.stringify({source_type:"manual",payload:e})})}getSettings(e){return this.expressRequest("/api/settings",{method:"GET",auth:!!e,token:e})}updateSettings(e,n){return this.expressRequest("/api/settings",{method:"PATCH",auth:!!n,token:n,body:JSON.stringify(e)})}getAccounts(e){return this.expressRequest("/api/accounts",{method:"GET",auth:!!e,token:e})}disconnectAccount(e,n){return this.expressRequest("/api/accounts/disconnect",{method:"POST",auth:!!n,token:n,body:JSON.stringify({accountId:e})})}getRules(e){return this.expressRequest("/api/rules",{method:"GET",auth:!!e,token:e})}createRule(e,n){return this.expressRequest("/api/rules",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}updateRule(e,n,r){return this.expressRequest(`/api/rules/${e}`,{method:"PATCH",auth:!!r,token:r,body:JSON.stringify(n)})}deleteRule(e,n){return this.expressRequest(`/api/rules/${e}`,{method:"DELETE",auth:!!n,token:n})}toggleRule(e,n){return this.expressRequest(`/api/rules/${e}/toggle`,{method:"POST",auth:!!n,token:n})}getStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}getProfile(e){return this.edgeRequest("/api-v1-profile",{method:"GET",auth:!!e,token:e})}updateProfile(e,n){return this.edgeRequest("/api-v1-profile",{method:"PATCH",auth:!!n,token:n,body:JSON.stringify(e)})}getChatProviders(e){return this.expressRequest("/api/sdk/providers/chat",{method:"GET",auth:!!e,token:e})}getEmbedProviders(e){return this.expressRequest("/api/sdk/providers/embed",{method:"GET",auth:!!e,token:e})}testLlm(e,n){return this.expressRequest("/api/sdk/test-llm",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}getGmailAuthUrl(e,n,r){return this.expressRequest("/api/accounts/gmail/auth-url",{method:"POST",auth:!!r,token:r,body:JSON.stringify({clientId:e,clientSecret:n})})}connectGmail(e,n,r,l){return this.expressRequest("/api/accounts/gmail/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:n,clientSecret:r})})}getGoogleDriveAuthUrl(e,n){return this.expressRequest("/api/accounts/google-drive/auth-url",{method:"POST",auth:!!n,token:n,body:JSON.stringify({clientId:e})})}connectGoogleDrive(e,n,r,l){return this.expressRequest("/api/accounts/google-drive/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:n,clientSecret:r})})}startMicrosoftDeviceFlow(e,n,r){return this.expressRequest("/api/accounts/microsoft/device-flow",{method:"POST",auth:!!r,token:r,body:JSON.stringify({clientId:e,tenantId:n})})}pollMicrosoftDeviceCode(e,n,r,l){return this.expressRequest("/api/accounts/microsoft/poll",{method:"POST",auth:!!l,token:l,body:JSON.stringify({deviceCode:e,clientId:n,tenantId:r})})}connectImap(e,n){return this.expressRequest("/api/accounts/imap/connect",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}setup(e){return this.edgeRequest("/setup",{method:"POST",body:JSON.stringify(e)})}getPolicies(e){return this.expressRequest("/api/policies",{auth:!!e,token:e})}savePolicy(e,n){return this.expressRequest("/api/policies",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}deletePolicy(e,n){return this.expressRequest(`/api/policies/${e}`,{method:"DELETE",auth:!!n,token:n})}patchPolicy(e,n,r){return this.expressRequest(`/api/policies/${e}`,{method:"PATCH",auth:!!r,token:r,body:JSON.stringify(n)})}reloadPolicies(e){return this.expressRequest("/api/policies/reload",{method:"POST",auth:!!e,token:e})}synthesizePolicy(e,n){return this.expressRequest("/api/policies/synthesize",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}getSDKChatProviders(){return this.expressRequest("/api/sdk/providers/chat")}getIngestions(e={},n){const r=new URLSearchParams;e.page&&r.set("page",String(e.page)),e.pageSize&&r.set("pageSize",String(e.pageSize)),e.q&&r.set("q",e.q);const l=r.toString()?`?${r}`:"";return this.expressRequest(`/api/ingestions${l}`,{auth:!!n,token:n})}uploadDocument(e,n){const r=new FormData;r.append("file",e);const l=mf(),u={"X-Supabase-Url":l.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":l.anonKey};return n&&(u.Authorization=`Bearer ${n}`),fetch(`${l.expressApiUrl}/api/ingestions/upload`,{method:"POST",headers:u,body:r}).then(d=>d.json())}rerunIngestion(e,n){return this.expressRequest(`/api/ingestions/${e}/rerun`,{method:"POST",auth:!!n,token:n})}matchIngestionToPolicy(e,n,r){const l=n.learn!==!1,u=n.rerun!==!1;return this.expressRequest(`/api/ingestions/${e}/match`,{method:"POST",auth:!!r,token:r,body:JSON.stringify({policy_id:n.policyId,learn:l,rerun:u,allow_side_effects:n.allowSideEffects===!0})})}suggestPolicyRefinement(e,n,r){return this.expressRequest(`/api/ingestions/${e}/refine-policy`,{method:"POST",auth:!!r,token:r,body:JSON.stringify({policy_id:n.policyId,provider:n.provider,model:n.model})})}deleteIngestion(e,n){return this.expressRequest(`/api/ingestions/${e}`,{method:"DELETE",auth:!!n,token:n})}updateIngestionTags(e,n,r){return this.expressRequest(`/api/ingestions/${e}/tags`,{method:"PATCH",auth:!!r,token:r,body:JSON.stringify({tags:n})})}summarizeIngestion(e,n){return this.expressRequest(`/api/ingestions/${e}/summarize`,{method:"POST",auth:!!n,token:n})}getBaselineConfig(e){return this.expressRequest("/api/baseline-config",{auth:!!e,token:e})}getBaselineConfigHistory(e){return this.expressRequest("/api/baseline-config/history",{auth:!!e,token:e})}saveBaselineConfig(e,n){return this.expressRequest("/api/baseline-config",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}activateBaselineConfig(e,n){return this.expressRequest(`/api/baseline-config/${e}/activate`,{method:"POST",auth:!!n,token:n})}suggestBaselineConfig(e,n){return this.expressRequest("/api/baseline-config/suggest",{method:"POST",auth:!!n,token:n,body:JSON.stringify(e)})}}const be=new CA;let sn=[],im=new Set;function om(){im.forEach(t=>t())}const he={success:(t,e)=>Lc("success",t,e),error:(t,e)=>Lc("error",t,e),info:(t,e)=>Lc("info",t,e),warning:(t,e)=>Lc("warning",t,e)};function Lc(t,e,n=5e3){const r=sn.findIndex(u=>u.message===e&&u.type===t);if(r!==-1){const u=sn[r];sn=[...sn],sn[r]={...u,count:(u.count||1)+1,lastUpdated:Date.now()},om();return}const l=Math.random().toString(36).substr(2,9);sn=[...sn,{id:l,type:t,message:e,duration:n,count:1,lastUpdated:Date.now()}],om(),n>0&&setTimeout(()=>Jw(l),n)}function Jw(t){sn=sn.filter(e=>e.id!==t),om()}function AA(){const[,t]=v.useState(0);return v.useEffect(()=>{const e=()=>t(n=>n+1);return im.add(e),()=>{im.delete(e)}},[]),sn}const RA={success:WE,error:fs,info:Hm,warning:Ww},OA={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 MA({toast:t}){const e=RA[t.type];return o.jsxs("div",{className:ve("flex items-start gap-3 p-4 rounded-lg border shadow-lg backdrop-blur-sm","animate-in slide-in-from-left-full duration-300",OA[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:()=>Jw(t.id),className:"p-1 hover:bg-black/10 rounded transition-colors",children:o.jsx(Ps,{className:"w-4 h-4"})})]})}function DA(){const t=AA();return t.length===0?null:o.jsx("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col-reverse gap-2 max-w-sm w-full",children:t.map(e=>o.jsx(MA,{toast:e},e.id))})}function PA({configSnapshot:t,configSource:e,setActivePage:n}){const[r,l]=v.useState(null),[u,d]=v.useState(!0),[h,m]=v.useState(!1),[p,y]=v.useState(!1),x=v.useRef(null),w=v.useCallback(async()=>{d(!0);try{const S=hs();if(!S)return;const{data:_}=await S.auth.getSession(),T=_.session?.access_token??null;if(!T)return;const C=await be.getDashboardStats(T);C.data?.success&&l(C.data.stats)}catch(S){console.error("Failed to fetch dashboard stats",S)}finally{d(!1)}},[]);v.useEffect(()=>{w()},[w]);const j=async S=>{const _=Array.from(S);if(_.length){n("funnel"),y(!0);try{const T=hs();if(!T)return;const{data:C}=await T.auth.getSession(),A=C.session?.access_token??null;if(!A)return;for(const E of _){he.info(`Ingesting ${E.name}…`);const M=await be.uploadDocument?.(E,A);if(M?.success)if(M.ingestion?.status==="duplicate"){const P=M.ingestion.extracted?.original_filename??"a previous upload";he.warning(`${E.name} is a duplicate of "${P}" — skipped.`)}else he.success(`${E.name} → ${M.ingestion?.status}`);else he.error(`Failed to ingest ${E.name}`)}await w()}finally{y(!1)}}},k=S=>{S.preventDefault(),m(!1),j(S.dataTransfer.files)};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-12 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"text-center space-y-3",children:[o.jsxs("h2",{className:"text-4xl font-black tracking-tight flex items-center justify-center gap-3",children:[o.jsx(lu,{className:"w-10 h-10 animate-pulse"}),"Command Center"]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-2xl mx-auto",children:"Central intelligence hub for document ingestion, routing, and synthetic knowledge."})]}),o.jsxs("div",{className:"w-full space-y-10",children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(zc,{title:"Documents Ingested",value:r?.totalDocuments,icon:o.jsx(qm,{className:"w-5 h-5 text-blue-500"}),isLoading:u,colorClass:"bg-blue-500/10"}),o.jsx(zc,{title:"Active Policies",value:r?.activePolicies,icon:o.jsx(v0,{className:"w-5 h-5 text-emerald-500"}),isLoading:u,colorClass:"bg-emerald-500/10"}),o.jsx(zc,{title:"Knowledge Chunks",value:r?.ragChunks,icon:o.jsx(Tu,{className:"w-5 h-5 text-purple-500"}),isLoading:u,colorClass:"bg-purple-500/10"}),o.jsx(zc,{title:"Automation Runs",value:r?.automationRuns,icon:o.jsx(mi,{className:"w-5 h-5 text-amber-500"}),isLoading:u,colorClass:"bg-amber-500/10"})]}),o.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsxs("div",{onDragOver:S=>{S.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:k,onClick:()=>x.current?.click(),className:ve("h-full rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-4 py-16",h?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:S=>S.target.files&&j(S.target.files)}),p?o.jsx(Qe,{className:"w-12 h-12 animate-spin text-primary"}):o.jsx(nm,{className:ve("w-12 h-12 transition-colors",h?"text-primary":"text-muted-foreground/50")}),o.jsxs("div",{className:"text-center space-y-1",children:[o.jsx("p",{className:"text-lg font-medium text-foreground",children:h?"Drop to ingest...":"Drag & drop files to ingest"}),o.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Supports .pdf, .docx, .md, .txt (up to 20MB)"})]})]})}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs(rt,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>n("chat"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-indigo-500/10 flex items-center justify-center mb-4",children:o.jsx(uu,{className:"w-6 h-6 text-indigo-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Chat with Data"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions against your vectorized knowledge base."})]}),o.jsxs(rt,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>n("policies"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/10 flex items-center justify-center mb-4",children:o.jsx(v0,{className:"w-6 h-6 text-orange-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Create Policy"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Define a new routing and automation contract."})]})]})]})]})]})}function zc({title:t,value:e,icon:n,isLoading:r,colorClass:l}){return o.jsx(rt,{className:"shadow-sm",children:o.jsxs(ht,{className:"p-6",children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsx("div",{className:ve("w-10 h-10 rounded-xl flex items-center justify-center",l),children:n})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:t}),r?o.jsx("div",{className:"h-8 w-16 bg-muted animate-pulse rounded-md"}):o.jsx("p",{className:"text-3xl font-black",children:e!==void 0?e.toLocaleString():"0"})]})]})})}function b0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Au(...t){return e=>{let n=!1;const r=t.map(l=>{const u=b0(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():b0(t[l],null)}}}}function or(...t){return v.useCallback(Au(...t),t)}var LA=Symbol.for("react.lazy"),fu=Lm[" use ".trim().toString()];function zA(t){return typeof t=="object"&&t!==null&&"then"in t}function Qw(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===LA&&"_payload"in t&&zA(t._payload)}function Zw(t){const e=BA(t),n=v.forwardRef((r,l)=>{let{children:u,...d}=r;Qw(u)&&typeof fu=="function"&&(u=fu(u._payload));const h=v.Children.toArray(u),m=h.find(VA);if(m){const p=m.props.children,y=h.map(x=>x===m?v.Children.count(p)>1?v.Children.only(null):v.isValidElement(p)?p.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(p)?v.cloneElement(p,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return n.displayName=`${t}.Slot`,n}var UA=Zw("Slot");function BA(t){const e=v.forwardRef((n,r)=>{let{children:l,...u}=n;if(Qw(l)&&typeof fu=="function"&&(l=fu(l._payload)),v.isValidElement(l)){const d=qA(l),h=$A(u,l.props);return l.type!==v.Fragment&&(h.ref=r?Au(r,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var IA=Symbol("radix.slottable");function VA(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===IA}function $A(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]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(n[r]=l):r==="style"?n[r]={...l,...u}:r==="className"&&(n[r]=[l,u].filter(Boolean).join(" "))}return{...t,...n}}function qA(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)}const w0=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,S0=Sw,Fm=(t,e)=>n=>{var r;if(e?.variants==null)return S0(t,n?.class,n?.className);const{variants:l,defaultVariants:u}=e,d=Object.keys(l).map(p=>{const y=n?.[p],x=u?.[p];if(y===null)return null;const w=w0(y)||w0(x);return l[p][w]}),h=n&&Object.entries(n).reduce((p,y)=>{let[x,w]=y;return w===void 0||(p[x]=w),p},{}),m=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((p,y)=>{let{class:x,className:w,...j}=y;return Object.entries(j).every(k=>{let[S,_]=k;return Array.isArray(_)?_.includes({...u,...h}[S]):{...u,...h}[S]===_})?[...p,x,w]:p},[]);return S0(t,d,m,n?.class,n?.className)},HA=Fm("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"}}),oe=v.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...l},u)=>{const d=r?UA:"button";return o.jsx(d,{className:ve(HA({variant:e,size:n,className:t})),ref:u,...l})});oe.displayName="Button";const Ne=v.forwardRef(({className:t,type:e,...n},r)=>o.jsx("input",{type:e,className:ve("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}));Ne.displayName="Input";var e1=aw();const GA=sw(e1);var FA=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],KA=FA.reduce((t,e)=>{const n=Zw(`Primitive.${e}`),r=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),YA="Label",t1=v.forwardRef((t,e)=>o.jsx(KA.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));t1.displayName=YA;var WA=t1;function Je({className:t,...e}){return o.jsx(WA,{"data-slot":"label",className:ve("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 XA=Fm("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function wt({className:t,variant:e,...n}){return o.jsx("div",{className:ve(XA({variant:e}),t),...n})}const JA=Fm("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),es=v.forwardRef(({className:t,variant:e,...n},r)=>o.jsx("div",{ref:r,role:"alert",className:ve(JA({variant:e}),t),...n}));es.displayName="Alert";const Ru=v.forwardRef(({className:t,...e},n)=>o.jsx("h5",{ref:n,className:ve("mb-1 font-medium leading-none tracking-tight",t),...e}));Ru.displayName="AlertTitle";const ts=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("text-sm [&_p]:leading-relaxed",t),...e}));ts.displayName="AlertDescription";function ha(t,e,{checkForDefaultPrevented:n=!0}={}){return function(l){if(t?.(l),n===!1||!l.defaultPrevented)return e?.(l)}}function QA(t,e){const n=v.createContext(e),r=u=>{const{children:d,...h}=u,m=v.useMemo(()=>h,Object.values(h));return o.jsx(n.Provider,{value:m,children:d})};r.displayName=t+"Provider";function l(u){const d=v.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 ZA(t,e=[]){let n=[];function r(u,d){const h=v.createContext(d),m=n.length;n=[...n,d];const p=x=>{const{scope:w,children:j,...k}=x,S=w?.[t]?.[m]||h,_=v.useMemo(()=>k,Object.values(k));return o.jsx(S.Provider,{value:_,children:j})};p.displayName=u+"Provider";function y(x,w){const j=w?.[t]?.[m]||h,k=v.useContext(j);if(k)return k;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${u}\``)}return[p,y]}const l=()=>{const u=n.map(d=>v.createContext(d));return function(h){const m=h?.[t]||u;return v.useMemo(()=>({[`__scope${t}`]:{...h,[t]:m}}),[h,m])}};return l.scopeName=t,[r,eR(l,...e)]}function eR(...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((h,{useScope:m,scopeName:p})=>{const x=m(u)[`__scope${p}`];return{...h,...x}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:d}),[d])}};return n.scopeName=e.scopeName,n}var Ko=globalThis?.document?v.useLayoutEffect:()=>{},tR=Lm[" useId ".trim().toString()]||(()=>{}),sR=0;function gf(t){const[e,n]=v.useState(tR());return Ko(()=>{n(r=>r??String(sR++))},[t]),t||(e?`radix-${e}`:"")}var nR=Lm[" useInsertionEffect ".trim().toString()]||Ko;function aR({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[l,u,d]=rR({defaultProp:e,onChange:n}),h=t!==void 0,m=h?t:l;{const y=v.useRef(t!==void 0);v.useEffect(()=>{const x=y.current;x!==h&&console.warn(`${r} is changing from ${x?"controlled":"uncontrolled"} to ${h?"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=h},[h,r])}const p=v.useCallback(y=>{if(h){const x=iR(y)?y(t):y;x!==t&&d.current?.(x)}else u(y)},[h,t,u,d]);return[m,p]}function rR({defaultProp:t,onChange:e}){const[n,r]=v.useState(t),l=v.useRef(n),u=v.useRef(e);return nR(()=>{u.current=e},[e]),v.useEffect(()=>{l.current!==n&&(u.current?.(n),l.current=n)},[n,l]),[n,r,u]}function iR(t){return typeof t=="function"}function oR(t){const e=lR(t),n=v.forwardRef((r,l)=>{const{children:u,...d}=r,h=v.Children.toArray(u),m=h.find(uR);if(m){const p=m.props.children,y=h.map(x=>x===m?v.Children.count(p)>1?v.Children.only(null):v.isValidElement(p)?p.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(p)?v.cloneElement(p,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return n.displayName=`${t}.Slot`,n}function lR(t){const e=v.forwardRef((n,r)=>{const{children:l,...u}=n;if(v.isValidElement(l)){const d=hR(l),h=dR(u,l.props);return l.type!==v.Fragment&&(h.ref=r?Au(r,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var cR=Symbol("radix.slottable");function uR(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cR}function dR(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]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(n[r]=l):r==="style"?n[r]={...l,...u}:r==="className"&&(n[r]=[l,u].filter(Boolean).join(" "))}return{...t,...n}}function hR(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 fR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],On=fR.reduce((t,e)=>{const n=oR(`Primitive.${e}`),r=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function mR(t,e){t&&e1.flushSync(()=>t.dispatchEvent(e))}function Yo(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...n)=>e.current?.(...n),[])}function pR(t,e=globalThis?.document){const n=Yo(t);v.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 gR="DismissableLayer",lm="dismissableLayer.update",yR="dismissableLayer.pointerDownOutside",vR="dismissableLayer.focusOutside",j0,s1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),n1=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,onDismiss:h,...m}=t,p=v.useContext(s1),[y,x]=v.useState(null),w=y?.ownerDocument??globalThis?.document,[,j]=v.useState({}),k=or(e,U=>x(U)),S=Array.from(p.layers),[_]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),T=S.indexOf(_),C=y?S.indexOf(y):-1,A=p.layersWithOutsidePointerEventsDisabled.size>0,E=C>=T,M=wR(U=>{const R=U.target,B=[...p.branches].some(se=>se.contains(R));!E||B||(l?.(U),d?.(U),U.defaultPrevented||h?.())},w),P=SR(U=>{const R=U.target;[...p.branches].some(se=>se.contains(R))||(u?.(U),d?.(U),U.defaultPrevented||h?.())},w);return pR(U=>{C===p.layers.size-1&&(r?.(U),!U.defaultPrevented&&h&&(U.preventDefault(),h()))},w),v.useEffect(()=>{if(y)return n&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(j0=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(y)),p.layers.add(y),_0(),()=>{n&&p.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=j0)}},[y,w,n,p]),v.useEffect(()=>()=>{y&&(p.layers.delete(y),p.layersWithOutsidePointerEventsDisabled.delete(y),_0())},[y,p]),v.useEffect(()=>{const U=()=>j({});return document.addEventListener(lm,U),()=>document.removeEventListener(lm,U)},[]),o.jsx(On.div,{...m,ref:k,style:{pointerEvents:A?E?"auto":"none":void 0,...t.style},onFocusCapture:ha(t.onFocusCapture,P.onFocusCapture),onBlurCapture:ha(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:ha(t.onPointerDownCapture,M.onPointerDownCapture)})});n1.displayName=gR;var xR="DismissableLayerBranch",bR=v.forwardRef((t,e)=>{const n=v.useContext(s1),r=v.useRef(null),l=or(e,r);return v.useEffect(()=>{const u=r.current;if(u)return n.branches.add(u),()=>{n.branches.delete(u)}},[n.branches]),o.jsx(On.div,{...t,ref:l})});bR.displayName=xR;function wR(t,e=globalThis?.document){const n=Yo(t),r=v.useRef(!1),l=v.useRef(()=>{});return v.useEffect(()=>{const u=h=>{if(h.target&&!r.current){let m=function(){a1(yR,n,p,{discrete:!0})};const p={originalEvent:h};h.pointerType==="touch"?(e.removeEventListener("click",l.current),l.current=m,e.addEventListener("click",l.current,{once:!0})):m()}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 SR(t,e=globalThis?.document){const n=Yo(t),r=v.useRef(!1);return v.useEffect(()=>{const l=u=>{u.target&&!r.current&&a1(vR,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 _0(){const t=new CustomEvent(lm);document.dispatchEvent(t)}function a1(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?mR(l,u):l.dispatchEvent(u)}var yf="focusScope.autoFocusOnMount",vf="focusScope.autoFocusOnUnmount",N0={bubbles:!1,cancelable:!0},jR="FocusScope",r1=v.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:l,onUnmountAutoFocus:u,...d}=t,[h,m]=v.useState(null),p=Yo(l),y=Yo(u),x=v.useRef(null),w=or(e,S=>m(S)),j=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let S=function(A){if(j.paused||!h)return;const E=A.target;h.contains(E)?x.current=E:oa(x.current,{select:!0})},_=function(A){if(j.paused||!h)return;const E=A.relatedTarget;E!==null&&(h.contains(E)||oa(x.current,{select:!0}))},T=function(A){if(document.activeElement===document.body)for(const M of A)M.removedNodes.length>0&&oa(h)};document.addEventListener("focusin",S),document.addEventListener("focusout",_);const C=new MutationObserver(T);return h&&C.observe(h,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",S),document.removeEventListener("focusout",_),C.disconnect()}}},[r,h,j.paused]),v.useEffect(()=>{if(h){T0.add(j);const S=document.activeElement;if(!h.contains(S)){const T=new CustomEvent(yf,N0);h.addEventListener(yf,p),h.dispatchEvent(T),T.defaultPrevented||(_R(CR(i1(h)),{select:!0}),document.activeElement===S&&oa(h))}return()=>{h.removeEventListener(yf,p),setTimeout(()=>{const T=new CustomEvent(vf,N0);h.addEventListener(vf,y),h.dispatchEvent(T),T.defaultPrevented||oa(S??document.body,{select:!0}),h.removeEventListener(vf,y),T0.remove(j)},0)}}},[h,p,y,j]);const k=v.useCallback(S=>{if(!n&&!r||j.paused)return;const _=S.key==="Tab"&&!S.altKey&&!S.ctrlKey&&!S.metaKey,T=document.activeElement;if(_&&T){const C=S.currentTarget,[A,E]=NR(C);A&&E?!S.shiftKey&&T===E?(S.preventDefault(),n&&oa(A,{select:!0})):S.shiftKey&&T===A&&(S.preventDefault(),n&&oa(E,{select:!0})):T===C&&S.preventDefault()}},[n,r,j.paused]);return o.jsx(On.div,{tabIndex:-1,...d,ref:w,onKeyDown:k})});r1.displayName=jR;function _R(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(oa(r,{select:e}),document.activeElement!==n)return}function NR(t){const e=i1(t),n=k0(e,t),r=k0(e.reverse(),t);return[n,r]}function i1(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 k0(t,e){for(const n of t)if(!kR(n,{upTo:e}))return n}function kR(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 TR(t){return t instanceof HTMLInputElement&&"select"in t}function oa(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&TR(t)&&e&&t.select()}}var T0=ER();function ER(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=E0(t,e),t.unshift(e)},remove(e){t=E0(t,e),t[0]?.resume()}}}function E0(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function CR(t){return t.filter(e=>e.tagName!=="A")}var AR="Portal",o1=v.forwardRef((t,e)=>{const{container:n,...r}=t,[l,u]=v.useState(!1);Ko(()=>u(!0),[]);const d=n||l&&globalThis?.document?.body;return d?GA.createPortal(o.jsx(On.div,{...r,ref:e}),d):null});o1.displayName=AR;function RR(t,e){return v.useReducer((n,r)=>e[n][r]??n,t)}var Ou=t=>{const{present:e,children:n}=t,r=OR(e),l=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),u=or(r.ref,MR(l));return typeof n=="function"||r.isPresent?v.cloneElement(l,{ref:u}):null};Ou.displayName="Presence";function OR(t){const[e,n]=v.useState(),r=v.useRef(null),l=v.useRef(t),u=v.useRef("none"),d=t?"mounted":"unmounted",[h,m]=RR(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const p=Uc(r.current);u.current=h==="mounted"?p:"none"},[h]),Ko(()=>{const p=r.current,y=l.current;if(y!==t){const w=u.current,j=Uc(p);t?m("MOUNT"):j==="none"||p?.display==="none"?m("UNMOUNT"):m(y&&w!==j?"ANIMATION_OUT":"UNMOUNT"),l.current=t}},[t,m]),Ko(()=>{if(e){let p;const y=e.ownerDocument.defaultView??window,x=j=>{const S=Uc(r.current).includes(CSS.escape(j.animationName));if(j.target===e&&S&&(m("ANIMATION_END"),!l.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",p=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},w=j=>{j.target===e&&(u.current=Uc(r.current))};return e.addEventListener("animationstart",w),e.addEventListener("animationcancel",x),e.addEventListener("animationend",x),()=>{y.clearTimeout(p),e.removeEventListener("animationstart",w),e.removeEventListener("animationcancel",x),e.removeEventListener("animationend",x)}}else m("ANIMATION_END")},[e,m]),{isPresent:["mounted","unmountSuspended"].includes(h),ref:v.useCallback(p=>{r.current=p?getComputedStyle(p):null,n(p)},[])}}function Uc(t){return t?.animationName||"none"}function MR(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 xf=0;function DR(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??C0()),document.body.insertAdjacentElement("beforeend",t[1]??C0()),xf++,()=>{xf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),xf--}},[])}function C0(){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 Wc="right-scroll-bar-position",Xc="width-before-scroll-bar",PR="with-scroll-bars-hidden",LR="--removed-body-scroll-bar-size";function bf(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function zR(t,e){var n=v.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 UR=typeof window<"u"?v.useLayoutEffect:v.useEffect,A0=new WeakMap;function BR(t,e){var n=zR(null,function(r){return t.forEach(function(l){return bf(l,r)})});return UR(function(){var r=A0.get(n);if(r){var l=new Set(r),u=new Set(t),d=n.current;l.forEach(function(h){u.has(h)||bf(h,null)}),u.forEach(function(h){l.has(h)||bf(h,d)})}A0.set(n,t)},[t]),n}function IR(t){return t}function VR(t,e){e===void 0&&(e=IR);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(h){return h!==d})}},assignSyncMedium:function(u){for(r=!0;n.length;){var d=n;n=[],d.forEach(u)}n={push:function(h){return u(h)},filter:function(){return n}}},assignMedium:function(u){r=!0;var d=[];if(n.length){var h=n;n=[],h.forEach(u),d=n}var m=function(){var y=d;d=[],y.forEach(u)},p=function(){return Promise.resolve().then(m)};p(),n={push:function(y){d.push(y),p()},filter:function(y){return d=d.filter(y),n}}}};return l}function $R(t){t===void 0&&(t={});var e=VR(null);return e.options=nn({async:!0,ssr:!1},t),e}var l1=function(t){var e=t.sideCar,n=vi(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 v.createElement(r,nn({},n))};l1.isSideCarExport=!0;function qR(t,e){return t.useMedium(e),l1}var c1=$R(),wf=function(){},Mu=v.forwardRef(function(t,e){var n=v.useRef(null),r=v.useState({onScrollCapture:wf,onWheelCapture:wf,onTouchMoveCapture:wf}),l=r[0],u=r[1],d=t.forwardProps,h=t.children,m=t.className,p=t.removeScrollBar,y=t.enabled,x=t.shards,w=t.sideCar,j=t.noRelative,k=t.noIsolation,S=t.inert,_=t.allowPinchZoom,T=t.as,C=T===void 0?"div":T,A=t.gapMode,E=vi(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),M=w,P=BR([n,e]),U=nn(nn({},E),l);return v.createElement(v.Fragment,null,y&&v.createElement(M,{sideCar:c1,removeScrollBar:p,shards:x,noRelative:j,noIsolation:k,inert:S,setCallbacks:u,allowPinchZoom:!!_,lockRef:n,gapMode:A}),d?v.cloneElement(v.Children.only(h),nn(nn({},U),{ref:P})):v.createElement(C,nn({},U,{className:m,ref:P}),h))});Mu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Mu.classNames={fullWidth:Xc,zeroRight:Wc};var HR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function GR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=HR();return e&&t.setAttribute("nonce",e),t}function FR(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function KR(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var YR=function(){var t=0,e=null;return{add:function(n){t==0&&(e=GR())&&(FR(e,n),KR(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},WR=function(){var t=YR();return function(e,n){v.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},u1=function(){var t=WR(),e=function(n){var r=n.styles,l=n.dynamic;return t(r,l),null};return e},XR={left:0,top:0,right:0,gap:0},Sf=function(t){return parseInt(t||"",10)||0},JR=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[Sf(n),Sf(r),Sf(l)]},QR=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return XR;var e=JR(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])}},ZR=u1(),hi="data-scroll-locked",e4=function(t,e,n,r){var l=t.left,u=t.top,d=t.right,h=t.gap;return n===void 0&&(n="margin"),`
|
|
52
|
+
.`.concat(PR,` {
|
|
53
|
+
overflow: hidden `).concat(r,`;
|
|
54
|
+
padding-right: `).concat(h,"px ").concat(r,`;
|
|
55
|
+
}
|
|
56
|
+
body[`).concat(hi,`] {
|
|
57
|
+
overflow: hidden `).concat(r,`;
|
|
58
|
+
overscroll-behavior: contain;
|
|
59
|
+
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
60
|
+
padding-left: `.concat(l,`px;
|
|
61
|
+
padding-top: `).concat(u,`px;
|
|
62
|
+
padding-right: `).concat(d,`px;
|
|
63
|
+
margin-left:0;
|
|
64
|
+
margin-top:0;
|
|
65
|
+
margin-right: `).concat(h,"px ").concat(r,`;
|
|
66
|
+
`),n==="padding"&&"padding-right: ".concat(h,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.`).concat(Wc,` {
|
|
70
|
+
right: `).concat(h,"px ").concat(r,`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.`).concat(Xc,` {
|
|
74
|
+
margin-right: `).concat(h,"px ").concat(r,`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.`).concat(Wc," .").concat(Wc,` {
|
|
78
|
+
right: 0 `).concat(r,`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.`).concat(Xc," .").concat(Xc,` {
|
|
82
|
+
margin-right: 0 `).concat(r,`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
body[`).concat(hi,`] {
|
|
86
|
+
`).concat(LR,": ").concat(h,`px;
|
|
87
|
+
}
|
|
88
|
+
`)},R0=function(){var t=parseInt(document.body.getAttribute(hi)||"0",10);return isFinite(t)?t:0},t4=function(){v.useEffect(function(){return document.body.setAttribute(hi,(R0()+1).toString()),function(){var t=R0()-1;t<=0?document.body.removeAttribute(hi):document.body.setAttribute(hi,t.toString())}},[])},s4=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,l=r===void 0?"margin":r;t4();var u=v.useMemo(function(){return QR(l)},[l]);return v.createElement(ZR,{styles:e4(u,!e,l,n?"":"!important")})},cm=!1;if(typeof window<"u")try{var Bc=Object.defineProperty({},"passive",{get:function(){return cm=!0,!0}});window.addEventListener("test",Bc,Bc),window.removeEventListener("test",Bc,Bc)}catch{cm=!1}var Qr=cm?{passive:!1}:!1,n4=function(t){return t.tagName==="TEXTAREA"},d1=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!n4(t)&&n[e]==="visible")},a4=function(t){return d1(t,"overflowY")},r4=function(t){return d1(t,"overflowX")},O0=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var l=h1(t,r);if(l){var u=f1(t,r),d=u[1],h=u[2];if(d>h)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},i4=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},o4=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},h1=function(t,e){return t==="v"?a4(e):r4(e)},f1=function(t,e){return t==="v"?i4(e):o4(e)},l4=function(t,e){return t==="h"&&e==="rtl"?-1:1},c4=function(t,e,n,r,l){var u=l4(t,window.getComputedStyle(e).direction),d=u*r,h=n.target,m=e.contains(h),p=!1,y=d>0,x=0,w=0;do{if(!h)break;var j=f1(t,h),k=j[0],S=j[1],_=j[2],T=S-_-u*k;(k||T)&&h1(t,h)&&(x+=T,w+=k);var C=h.parentNode;h=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!m&&h!==document.body||m&&(e.contains(h)||e===h));return(y&&Math.abs(x)<1||!y&&Math.abs(w)<1)&&(p=!0),p},Ic=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},M0=function(t){return[t.deltaX,t.deltaY]},D0=function(t){return t&&"current"in t?t.current:t},u4=function(t,e){return t[0]===e[0]&&t[1]===e[1]},d4=function(t){return`
|
|
89
|
+
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
90
|
+
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
91
|
+
`)},h4=0,Zr=[];function f4(t){var e=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),l=v.useState(h4++)[0],u=v.useState(u1)[0],d=v.useRef(t);v.useEffect(function(){d.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(l));var S=c2([t.lockRef.current],(t.shards||[]).map(D0),!0).filter(Boolean);return S.forEach(function(_){return _.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),S.forEach(function(_){return _.classList.remove("allow-interactivity-".concat(l))})}}},[t.inert,t.lockRef.current,t.shards]);var h=v.useCallback(function(S,_){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!d.current.allowPinchZoom;var T=Ic(S),C=n.current,A="deltaX"in S?S.deltaX:C[0]-T[0],E="deltaY"in S?S.deltaY:C[1]-T[1],M,P=S.target,U=Math.abs(A)>Math.abs(E)?"h":"v";if("touches"in S&&U==="h"&&P.type==="range")return!1;var R=window.getSelection(),B=R&&R.anchorNode,se=B?B===P||B.contains(P):!1;if(se)return!1;var re=O0(U,P);if(!re)return!0;if(re?M=U:(M=U==="v"?"h":"v",re=O0(U,P)),!re)return!1;if(!r.current&&"changedTouches"in S&&(A||E)&&(r.current=M),!M)return!0;var ue=r.current||M;return c4(ue,_,S,ue==="h"?A:E)},[]),m=v.useCallback(function(S){var _=S;if(!(!Zr.length||Zr[Zr.length-1]!==u)){var T="deltaY"in _?M0(_):Ic(_),C=e.current.filter(function(M){return M.name===_.type&&(M.target===_.target||_.target===M.shadowParent)&&u4(M.delta,T)})[0];if(C&&C.should){_.cancelable&&_.preventDefault();return}if(!C){var A=(d.current.shards||[]).map(D0).filter(Boolean).filter(function(M){return M.contains(_.target)}),E=A.length>0?h(_,A[0]):!d.current.noIsolation;E&&_.cancelable&&_.preventDefault()}}},[]),p=v.useCallback(function(S,_,T,C){var A={name:S,delta:_,target:T,should:C,shadowParent:m4(T)};e.current.push(A),setTimeout(function(){e.current=e.current.filter(function(E){return E!==A})},1)},[]),y=v.useCallback(function(S){n.current=Ic(S),r.current=void 0},[]),x=v.useCallback(function(S){p(S.type,M0(S),S.target,h(S,t.lockRef.current))},[]),w=v.useCallback(function(S){p(S.type,Ic(S),S.target,h(S,t.lockRef.current))},[]);v.useEffect(function(){return Zr.push(u),t.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:w}),document.addEventListener("wheel",m,Qr),document.addEventListener("touchmove",m,Qr),document.addEventListener("touchstart",y,Qr),function(){Zr=Zr.filter(function(S){return S!==u}),document.removeEventListener("wheel",m,Qr),document.removeEventListener("touchmove",m,Qr),document.removeEventListener("touchstart",y,Qr)}},[]);var j=t.removeScrollBar,k=t.inert;return v.createElement(v.Fragment,null,k?v.createElement(u,{styles:d4(l)}):null,j?v.createElement(s4,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function m4(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const p4=qR(c1,f4);var m1=v.forwardRef(function(t,e){return v.createElement(Mu,nn({},t,{ref:e,sideCar:p4}))});m1.classNames=Mu.classNames;var g4=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ei=new WeakMap,Vc=new WeakMap,$c={},jf=0,p1=function(t){return t&&(t.host||p1(t.parentNode))},y4=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=p1(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})},v4=function(t,e,n,r){var l=y4(e,Array.isArray(t)?t:[t]);$c[n]||($c[n]=new WeakMap);var u=$c[n],d=[],h=new Set,m=new Set(l),p=function(x){!x||h.has(x)||(h.add(x),p(x.parentNode))};l.forEach(p);var y=function(x){!x||m.has(x)||Array.prototype.forEach.call(x.children,function(w){if(h.has(w))y(w);else try{var j=w.getAttribute(r),k=j!==null&&j!=="false",S=(ei.get(w)||0)+1,_=(u.get(w)||0)+1;ei.set(w,S),u.set(w,_),d.push(w),S===1&&k&&Vc.set(w,!0),_===1&&w.setAttribute(n,"true"),k||w.setAttribute(r,"true")}catch(T){console.error("aria-hidden: cannot operate on ",w,T)}})};return y(e),h.clear(),jf++,function(){d.forEach(function(x){var w=ei.get(x)-1,j=u.get(x)-1;ei.set(x,w),u.set(x,j),w||(Vc.has(x)||x.removeAttribute(r),Vc.delete(x)),j||x.removeAttribute(n)}),jf--,jf||(ei=new WeakMap,ei=new WeakMap,Vc=new WeakMap,$c={})}},x4=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),l=g4(t);return l?(r.push.apply(r,Array.from(l.querySelectorAll("[aria-live], script"))),v4(r,l,n,"aria-hidden")):function(){return null}};function b4(t){const e=w4(t),n=v.forwardRef((r,l)=>{const{children:u,...d}=r,h=v.Children.toArray(u),m=h.find(j4);if(m){const p=m.props.children,y=h.map(x=>x===m?v.Children.count(p)>1?v.Children.only(null):v.isValidElement(p)?p.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(p)?v.cloneElement(p,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return n.displayName=`${t}.Slot`,n}function w4(t){const e=v.forwardRef((n,r)=>{const{children:l,...u}=n;if(v.isValidElement(l)){const d=N4(l),h=_4(u,l.props);return l.type!==v.Fragment&&(h.ref=r?Au(r,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var S4=Symbol("radix.slottable");function j4(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===S4}function _4(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]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(n[r]=l):r==="style"?n[r]={...l,...u}:r==="className"&&(n[r]=[l,u].filter(Boolean).join(" "))}return{...t,...n}}function N4(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 Du="Dialog",[g1]=ZA(Du),[k4,Ys]=g1(Du),y1=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:l,onOpenChange:u,modal:d=!0}=t,h=v.useRef(null),m=v.useRef(null),[p,y]=aR({prop:r,defaultProp:l??!1,onChange:u,caller:Du});return o.jsx(k4,{scope:e,triggerRef:h,contentRef:m,contentId:gf(),titleId:gf(),descriptionId:gf(),open:p,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(x=>!x),[y]),modal:d,children:n})};y1.displayName=Du;var v1="DialogTrigger",T4=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=Ys(v1,n),u=or(e,l.triggerRef);return o.jsx(On.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":Wm(l.open),...r,ref:u,onClick:ha(t.onClick,l.onOpenToggle)})});T4.displayName=v1;var Km="DialogPortal",[E4,x1]=g1(Km,{forceMount:void 0}),b1=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:l}=t,u=Ys(Km,e);return o.jsx(E4,{scope:e,forceMount:n,children:v.Children.map(r,d=>o.jsx(Ou,{present:n||u.open,children:o.jsx(o1,{asChild:!0,container:l,children:d})}))})};b1.displayName=Km;var mu="DialogOverlay",w1=v.forwardRef((t,e)=>{const n=x1(mu,t.__scopeDialog),{forceMount:r=n.forceMount,...l}=t,u=Ys(mu,t.__scopeDialog);return u.modal?o.jsx(Ou,{present:r||u.open,children:o.jsx(A4,{...l,ref:e})}):null});w1.displayName=mu;var C4=b4("DialogOverlay.RemoveScroll"),A4=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=Ys(mu,n);return o.jsx(m1,{as:C4,allowPinchZoom:!0,shards:[l.contentRef],children:o.jsx(On.div,{"data-state":Wm(l.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),nr="DialogContent",S1=v.forwardRef((t,e)=>{const n=x1(nr,t.__scopeDialog),{forceMount:r=n.forceMount,...l}=t,u=Ys(nr,t.__scopeDialog);return o.jsx(Ou,{present:r||u.open,children:u.modal?o.jsx(R4,{...l,ref:e}):o.jsx(O4,{...l,ref:e})})});S1.displayName=nr;var R4=v.forwardRef((t,e)=>{const n=Ys(nr,t.__scopeDialog),r=v.useRef(null),l=or(e,n.contentRef,r);return v.useEffect(()=>{const u=r.current;if(u)return x4(u)},[]),o.jsx(j1,{...t,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ha(t.onCloseAutoFocus,u=>{u.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ha(t.onPointerDownOutside,u=>{const d=u.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0;(d.button===2||h)&&u.preventDefault()}),onFocusOutside:ha(t.onFocusOutside,u=>u.preventDefault())})}),O4=v.forwardRef((t,e)=>{const n=Ys(nr,t.__scopeDialog),r=v.useRef(!1),l=v.useRef(!1);return o.jsx(j1,{...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()}})}),j1=v.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:l,onCloseAutoFocus:u,...d}=t,h=Ys(nr,n),m=v.useRef(null),p=or(e,m);return DR(),o.jsxs(o.Fragment,{children:[o.jsx(r1,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:l,onUnmountAutoFocus:u,children:o.jsx(n1,{role:"dialog",id:h.contentId,"aria-describedby":h.descriptionId,"aria-labelledby":h.titleId,"data-state":Wm(h.open),...d,ref:p,onDismiss:()=>h.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(M4,{titleId:h.titleId}),o.jsx(P4,{contentRef:m,descriptionId:h.descriptionId})]})]})}),Ym="DialogTitle",_1=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=Ys(Ym,n);return o.jsx(On.h2,{id:l.titleId,...r,ref:e})});_1.displayName=Ym;var N1="DialogDescription",k1=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=Ys(N1,n);return o.jsx(On.p,{id:l.descriptionId,...r,ref:e})});k1.displayName=N1;var T1="DialogClose",E1=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,l=Ys(T1,n);return o.jsx(On.button,{type:"button",...r,ref:e,onClick:ha(t.onClick,()=>l.onOpenChange(!1))})});E1.displayName=T1;function Wm(t){return t?"open":"closed"}var C1="DialogTitleWarning",[fP,A1]=QA(C1,{contentName:nr,titleName:Ym,docsSlug:"dialog"}),M4=({titleId:t})=>{const e=A1(C1),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
92
|
+
|
|
93
|
+
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
94
|
+
|
|
95
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},D4="DialogDescriptionWarning",P4=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${A1(D4).contentName}}.`;return v.useEffect(()=>{const l=t.current?.getAttribute("aria-describedby");e&&l&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},L4=y1,z4=b1,U4=w1,B4=S1,I4=_1,V4=k1,$4=E1;function pa({...t}){return o.jsx(L4,{"data-slot":"dialog",...t})}function q4({...t}){return o.jsx(z4,{"data-slot":"dialog-portal",...t})}function R1({className:t,...e}){return o.jsx(U4,{"data-slot":"dialog-overlay",className:ve("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 ga({className:t,children:e,...n}){return o.jsxs(q4,{"data-slot":"dialog-portal",children:[o.jsx(R1,{}),o.jsxs(B4,{"data-slot":"dialog-content",className:ve("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($4,{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(Ps,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function ar({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-header",className:ve("flex flex-col gap-2 text-center sm:text-left",t),...e})}function Xa({className:t,...e}){return o.jsx("div",{"data-slot":"dialog-footer",className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function rr({className:t,...e}){return o.jsx(I4,{"data-slot":"dialog-title",className:ve("text-lg leading-none font-semibold",t),...e})}function bi({className:t,...e}){return o.jsx(V4,{"data-slot":"dialog-description",className:ve("text-muted-foreground text-sm",t),...e})}function H4({supabase:t,initStatus:e,sessionStatus:n,sessionEmail:r,onRefresh:l}){const[u,d]=v.useState(""),[h,m]=v.useState(""),[p,y]=v.useState(""),[x,w]=v.useState(""),[j,k]=v.useState(!1),[S,_]=v.useState(null),T=e==="empty";async function C(){k(!0),_(null);const{error:P}=await t.auth.signInWithPassword({email:u,password:h});P?_(P.message):l(),k(!1)}async function A(){k(!0),_(null);try{const P=await be.setup({email:u,password:h,first_name:p,last_name:x});if(P.error)throw new Error(typeof P.error=="string"?P.error:P.error.message);const{error:U}=await t.auth.signInWithPassword({email:u,password:h});if(U)throw U;l()}catch(P){_(P.message||"Failed to initialize foundation.")}finally{k(!1)}}async function E(){k(!0),_(null);const{error:P}=await t.auth.signUp({email:u,password:h,options:{data:{first_name:p,last_name:x}}});P?_(P.message):l(),k(!1)}async function M(){k(!0),await t.auth.signOut(),l(),k(!1)}return n==="authenticated"?o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl bg-primary/5 border border-primary/10",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary flex items-center justify-center text-primary-foreground",children:o.jsx(Eu,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground leading-none mb-1",children:"Authenticated as"}),o.jsx("p",{className:"text-sm font-medium truncate",children:r})]})]}),e==="missing_view"&&o.jsxs(es,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20",children:[o.jsx(Ho,{className:"w-4 h-4"}),o.jsx(ts,{className:"text-xs",children:"Database views missing. Foundation may be corrupted."})]}),o.jsxs(oe,{variant:"outline",className:"w-full h-11 hover:bg-destructive hover:text-destructive-reveal group transition-all duration-300",onClick:M,disabled:j,children:[j?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Hw,{className:"w-4 h-4 mr-2 group-hover:rotate-180 transition-transform duration-500"}),"Logout Protocol"]})]}):o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"grid gap-4",children:[T&&o.jsxs("div",{className:"grid grid-cols-2 gap-4 animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-firstname",children:"First Name"}),o.jsx(Ne,{id:"auth-firstname",placeholder:"Agent",value:p,onChange:P=>y(P.target.value),className:"h-10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-lastname",children:"Last Name"}),o.jsx(Ne,{id:"auth-lastname",placeholder:"Zero",value:x,onChange:P=>w(P.target.value),className:"h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-email",children:"Email Address"}),o.jsxs("div",{className:"relative",children:[o.jsx(qo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(Ne,{id:"auth-email",type:"email",placeholder:"admin@example.com",value:u,onChange:P=>d(P.target.value),className:"pl-9 h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-password",children:"Security Key"}),o.jsxs("div",{className:"relative",children:[o.jsx(gi,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(Ne,{id:"auth-password",type:"password",placeholder:"••••••••",value:h,onChange:P=>m(P.target.value),className:"pl-9 h-10",autoComplete:T?"new-password":"current-password"})]})]})]}),S&&o.jsx(es,{variant:"destructive",className:"py-2 px-3",children:o.jsx(ts,{className:"text-[11px] leading-relaxed italic",children:S})}),o.jsx("div",{className:"pt-2",children:T?o.jsxs(oe,{className:"w-full h-11 shadow-lg shadow-primary/20",onClick:A,disabled:j||!u||!h||!p,children:[j?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(xa,{className:"w-4 h-4 mr-2"}),"Initialize Primary Admin"]}):o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs(oe,{className:"h-10",onClick:C,disabled:j||!u||!h,children:[j?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(qw,{className:"w-4 h-4 mr-2"}),"Login"]}),o.jsxs(oe,{variant:"secondary",className:"h-10",onClick:E,disabled:j||!u||!h,children:[o.jsx(am,{className:"w-4 h-4 mr-2"}),"Enroll"]})]})}),o.jsx("p",{className:"text-[10px] text-center text-muted-foreground uppercase tracking-widest font-bold opacity-50 pt-2",children:T?"Foundation Assembly Phase":"Foundation Access Required"})]})}const fa="0.1.17",G4="20260303020000";async function F4(t,e){const n=Promise.resolve(t);let r=null;const l=new Promise((u,d)=>{r=setTimeout(()=>{d(new Error(`Operation timed out after ${e}ms`))},e)});try{return await Promise.race([n,l])}finally{r&&clearTimeout(r)}}async function K4(t){try{const{data:e,error:n}=await F4(t.rpc("get_latest_migration_timestamp"),12e3);if(n)return n.code==="42883"?{latestMigrationTimestamp:"0"}:{latestMigrationTimestamp:null};const r=e??null;return r&&r>="29990000000000"?{latestMigrationTimestamp:null}:{latestMigrationTimestamp:r}}catch{return{latestMigrationTimestamp:null}}}async function O1(t){const e=await K4(t);return!e.latestMigrationTimestamp||e.latestMigrationTimestamp.trim()===""?{needsMigration:!0,appVersion:fa,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database migration state unknown."}:G4>e.latestMigrationTimestamp?{needsMigration:!0,appVersion:fa,latestMigrationTimestamp:e.latestMigrationTimestamp,message:`Database is behind (${e.latestMigrationTimestamp}).`}:{needsMigration:!1,appVersion:fa,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database schema is up-to-date."}}function Y4({supabase:t,sessionEmail:e,sessionStatus:n,initStatus:r,configSnapshot:l,configSource:u,onRefresh:d,onLaunchSetup:h,onResetSetup:m}){const[p,y]=v.useState("profile"),[x,w]=v.useState(null),[j,k]=v.useState(!1);async function S(){if(!t)return;k(!0);const{data:{user:C}}=await t.auth.getUser();if(C){const{data:A}=await t.from("profiles").select("*").eq("id",C.id).single();A&&w(A)}k(!1)}v.useEffect(()=>{n==="authenticated"&&t&&S()},[n,t]);const _=[{id:"profile",label:"Profile",icon:Eu},{id:"security",label:"Security",icon:xa},{id:"workspace",label:"Workspace",icon:wA},{id:"supabase",label:"Supabase",icon:Tu}];async function T(){t&&(await t.auth.signOut(),d())}return o.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h1",{className:"text-4xl font-black tracking-tight",children:"Account Settings"}),o.jsx("p",{className:"text-muted-foreground text-lg",children:"Manage your profile and foundational preferences."})]}),o.jsxs("div",{className:"flex flex-col md:flex-row gap-12 items-start",children:[o.jsxs("aside",{className:"w-full md:w-72 flex flex-col gap-8 shrink-0",children:[o.jsx("nav",{className:"space-y-1",children:_.map(C=>{const A=C.icon,E=p===C.id;return o.jsxs("button",{onClick:()=>y(C.id),className:ve("w-full flex items-center gap-3 px-4 py-3 text-sm font-bold rounded-xl transition-all duration-300",E?"bg-foreground text-background shadow-lg shadow-foreground/10":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(A,{className:ve("w-5 h-5",E?"text-background":"text-muted-foreground/60")}),C.label]},C.id)})}),o.jsxs("div",{className:"pt-8 border-t space-y-6",children:[o.jsxs("button",{onClick:T,className:"group w-full flex items-center gap-3 px-4 py-2 text-sm font-bold rounded-xl transition-all duration-300 text-destructive hover:bg-destructive/10",children:[o.jsx(Hw,{className:"w-5 h-5 transition-transform group-hover:translate-x-1"}),"Logout"]}),o.jsxs("div",{className:"px-4",children:[o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/40 uppercase tracking-widest mb-1",children:"Version"}),o.jsxs("p",{className:"text-xs font-mono text-muted-foreground/60",children:["v",fa]})]})]})]}),o.jsxs("div",{className:"flex-1 w-full animate-in slide-in-from-right-4 duration-500",children:[p==="profile"&&o.jsx(W4,{sessionEmail:e,sessionStatus:n,supabase:t,initStatus:r,profile:x,onProfileUpdate:S,onRefresh:d,isLoading:j}),p==="security"&&o.jsx(X4,{supabase:t}),p==="workspace"&&o.jsx(J4,{supabase:t,sessionStatus:n}),p==="supabase"&&o.jsx(Q4,{configSnapshot:l,configSource:u,onLaunchSetup:h,onResetSetup:m})]})]})]})}function W4({sessionEmail:t,sessionStatus:e,supabase:n,initStatus:r,profile:l,onProfileUpdate:u,onRefresh:d,isLoading:h}){const[m,p]=v.useState(""),[y,x]=v.useState(""),[w,j]=v.useState(!0),[k,S]=v.useState(!1),[_,T]=v.useState(!1);v.useEffect(()=>{l&&(p(l.first_name||""),x(l.last_name||""))},[l]);const C=async()=>{if(!n||!l)return;S(!0);const{error:E}=await n.from("profiles").update({first_name:m,last_name:y}).eq("id",l.id);E||u(),S(!1)},A=async E=>{const M=E.target.files?.[0];if(!(!M||!n||!l)){T(!0);try{const P=M.name.split(".").pop(),U=`${l.id}/${Math.random()}.${P}`,{error:R}=await n.storage.from("avatars").upload(U,M);if(R)throw R;const{data:{publicUrl:B}}=n.storage.from("avatars").getPublicUrl(U);await n.from("profiles").update({avatar_url:B}).eq("id",l.id),u()}catch(P){console.error("Upload error:",P)}finally{T(!1)}}};return o.jsxs(rt,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(St,{className:"p-8 border-b bg-muted/20",children:[o.jsx(jt,{className:"text-2xl font-black",children:"Profile Information"}),o.jsx(Kt,{className:"text-base",children:"Update your personal foundation details."})]}),o.jsx(ht,{className:"p-8 space-y-10",children:h?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"})}):e==="authenticated"?o.jsxs("div",{className:"space-y-10",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-8",children:[o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-32 h-32 rounded-full bg-primary/10 border-4 border-background shadow-2xl overflow-hidden flex items-center justify-center",children:l?.avatar_url?o.jsx("img",{src:l.avatar_url,alt:"Avatar",className:"w-full h-full object-cover"}):t?o.jsx("span",{className:"text-4xl font-black text-primary",children:t.charAt(0).toUpperCase()}):o.jsx(Eu,{className:"w-12 h-12 text-primary/40"})}),o.jsxs("label",{className:"absolute bottom-1 right-1 h-10 w-10 rounded-full bg-background border shadow-lg flex items-center justify-center hover:scale-110 transition-transform cursor-pointer",children:[_?o.jsx(Qe,{className:"w-4 h-4 animate-spin text-muted-foreground"}):o.jsx(VE,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:A,disabled:_})]})]}),o.jsxs("div",{className:"flex-1 w-full grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"firstName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(Ne,{id:"firstName",placeholder:"Trung",value:m,onChange:E=>p(E.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"lastName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(Ne,{id:"lastName",placeholder:"Le",value:y,onChange:E=>x(E.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[o.jsx(Je,{htmlFor:"email",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Address"}),o.jsx(Ne,{id:"email",value:t||"",disabled:!0,className:"h-12 rounded-xl bg-muted/40 border-border/40 opacity-70 cursor-not-allowed"}),o.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-bold ml-1",children:"This is your login email and cannot be changed."})]})]})]}),o.jsxs("div",{className:"pt-8 border-t flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"text-base font-bold",children:"Sound & Haptic Feedback"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Play chimes and haptic pulses for system events."})]}),o.jsxs(oe,{variant:w?"default":"outline",className:ve("h-11 px-6 rounded-xl font-bold transition-all",w?"shadow-lg shadow-primary/20":""),onClick:()=>j(!w),children:[w?o.jsx(rm,{className:"w-4 h-4 mr-2"}):o.jsx(Xw,{className:"w-4 h-4 mr-2"}),w?"Enabled":"Disabled"]})]})]}):o.jsxs("div",{className:"py-8",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4 mb-6",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(xa,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold",children:"Authentication Gateway"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Access your foundational profile."})]})]}),n&&o.jsx(H4,{supabase:n,initStatus:r,sessionStatus:e,sessionEmail:t,onRefresh:d})]})}),e==="authenticated"&&!h&&o.jsx(ku,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(oe,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:C,disabled:k,children:[k?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(HC,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]})}function X4({supabase:t}){const[e,n]=v.useState(""),[r,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),p=async()=>{if(!t)return;if(e!==r){m({type:"error",msg:"Passwords do not match."});return}if(e.length<8){m({type:"error",msg:"Password must be at least 8 characters."});return}d(!0),m(null);const{error:y}=await t.auth.updateUser({password:e});y?m({type:"error",msg:y.message}):(m({type:"success",msg:"Password updated successfully."}),n(""),l("")),d(!1)};return o.jsxs(rt,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(St,{className:"p-8 border-b bg-muted/20",children:[o.jsx(jt,{className:"text-2xl font-black",children:"Security Protocol"}),o.jsx(Kt,{className:"text-base",children:"Manage your foundation credentials and access keys."})]}),o.jsxs(ht,{className:"p-8 space-y-8",children:[h&&o.jsxs(es,{variant:h.type==="error"?"destructive":"default",className:ve("animate-in fade-in slide-in-from-top-2 duration-300",h.type==="success"?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20":""),children:[h.type==="success"?o.jsx(Ks,{className:"h-4 w-4"}):o.jsx(Ho,{className:"h-4 w-4"}),o.jsx(ts,{className:"text-sm font-bold",children:h.msg})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"newPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"New Password"}),o.jsx(Ne,{id:"newPass",type:"password",placeholder:"••••••••",value:e,onChange:y=>n(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"confirmPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Confirm Password"}),o.jsx(Ne,{id:"confirmPass",type:"password",placeholder:"••••••••",value:r,onChange:y=>l(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]})]}),o.jsxs("div",{className:"bg-muted/30 p-6 rounded-2xl border border-border/40 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(Ho,{className:"w-5 h-5"})}),o.jsx("h5",{className:"font-bold",children:"Security Tip"})]}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Use a password at least 12 characters long with a mix of letters, numbers, and symbols to ensure your foundational data remains secure."})]})]})]}),o.jsx(ku,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(oe,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:p,disabled:u||!e||!r,children:[u?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(gi,{className:"w-4 h-4 mr-2"}),"Update Password"]})})]})}function J4({supabase:t,sessionStatus:e}){const[n,r]=v.useState([]),[l,u]=v.useState([]),[d,h]=v.useState(""),[m,p]=v.useState(!1),[y,x]=v.useState(!1),[w,j]=v.useState(!1),[k,S]=v.useState(null),[_,T]=v.useState(null),[C,A]=v.useState(""),[E,M]=v.useState("member"),[P,U]=v.useState(null),B=(n.find(H=>H.id===d)??null)?.role??null,se=B==="owner"||B==="admin",re=B==="owner";v.useEffect(()=>{!re&&E==="admin"&&M("member")},[re,E]);function ue(H){return H==="owner"?"Owner":H==="admin"?"Admin":"Member"}function xe(H){const ae=`${H.first_name??""} ${H.last_name??""}`.trim();return ae.length>0?ae:H.email??"Unknown User"}function ge(H){const ae=xe(H).trim();return ae.length>0?ae[0]?.toUpperCase()??"?":"?"}async function X(H,ae){x(!0);const ie=await be.getWorkspaceMembers(H,ae);ie.data?.success?(u(ie.data.members||[]),U(null)):(u([]),U({type:"error",msg:typeof ie.error=="string"?ie.error:ie.error?.message||"Failed to load workspace members."})),x(!1)}async function V(){if(!t)return;p(!0),U(null);const{data:{session:H}}=await t.auth.getSession(),ae=H?.access_token??null,ie=await be.getWorkspaces(ae);if(!ie.data?.success){r([]),u([]),h(""),p(!1),U({type:"error",msg:typeof ie.error=="string"?ie.error:ie.error?.message||"Failed to load workspaces."});return}const $=ie.data.workspaces||[];if(r($),$.length===0){be.setActiveWorkspaceId(null),h(""),u([]),p(!1);return}const fe=be.getActiveWorkspaceId(),le=fe?$.some(Ye=>Ye.id===fe):!1,Oe=ie.data.activeWorkspaceId,Ue=Oe?$.some(Ye=>Ye.id===Oe):!1,ft=(le?fe:Ue?Oe:$[0]?.id)??"";h(ft),be.setActiveWorkspaceId(ft||null),ft?await X(ft,ae):u([]),p(!1)}v.useEffect(()=>{e==="authenticated"&&t&&V()},[e,t]);const F=async H=>{if(!t)return;h(H),be.setActiveWorkspaceId(H),U(null);const{data:{session:ae}}=await t.auth.getSession();await X(H,ae?.access_token??null)},Z=async()=>{if(!t||!d||!se)return;const H=C.trim();if(!H){U({type:"error",msg:"Invite email is required."});return}j(!0);const{data:{session:ae}}=await t.auth.getSession(),ie=await be.inviteWorkspaceMember(d,{email:H,role:E},ae?.access_token??null);ie.data?.success?(A(""),U({type:"success",msg:ie.data.invitation_email_sent?`User created and invite email sent to ${H}.`:`Added ${H} to workspace.`}),await X(d,ae?.access_token??null)):U({type:"error",msg:typeof ie.error=="string"?ie.error:ie.error?.message||"Failed to invite member."}),j(!1)},ye=async(H,ae)=>{if(!t||!d)return;S(H.user_id),U(null);const{data:{session:ie}}=await t.auth.getSession(),$=await be.updateWorkspaceMemberRole(d,H.user_id,ae,ie?.access_token??null);$.data?.success?(U({type:"success",msg:`Updated ${xe(H)} role to ${ue(ae)}.`}),await X(d,ie?.access_token??null)):U({type:"error",msg:typeof $.error=="string"?$.error:$.error?.message||"Failed to update member role."}),S(null)},ne=async()=>{if(!t||!d||!_)return;const H=_,ae=xe(H);S(H.user_id),U(null);const{data:{session:ie}}=await t.auth.getSession(),$=await be.removeWorkspaceMember(d,H.user_id,ie?.access_token??null);$.data?.success?(U({type:"success",msg:`${ae} was removed from workspace.`}),T(null),await X(d,ie?.access_token??null)):U({type:"error",msg:typeof $.error=="string"?$.error:$.error?.message||"Failed to remove member."}),S(null)},D=_?k===_.user_id:!1,L=_?xe(_):"this member",J=()=>{D||T(null)};return e!=="authenticated"?o.jsx(rt,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:o.jsxs(St,{className:"p-8 border-b bg-muted/20",children:[o.jsx(jt,{className:"text-2xl font-black",children:"Workspace & Team"}),o.jsx(Kt,{className:"text-base",children:"Sign in to manage workspace members."})]})}):o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-700",children:[o.jsxs(rt,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(St,{className:"p-8 border-b bg-muted/20",children:[o.jsx(jt,{className:"text-2xl font-black",children:"Workspace & Team"}),o.jsx(Kt,{className:"text-base",children:"Switch your active workspace and manage members."})]}),o.jsxs(ht,{className:"p-8 space-y-6",children:[P&&o.jsxs(es,{variant:P.type==="error"?"destructive":"default",className:ve("animate-in fade-in slide-in-from-top-2 duration-300",P.type==="success"?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20":""),children:[P.type==="success"?o.jsx(Ks,{className:"h-4 w-4"}):o.jsx(Ho,{className:"h-4 w-4"}),o.jsx(ts,{className:"text-sm font-bold",children:P.msg})]}),m?o.jsx("div",{className:"py-16 flex items-center justify-center",children:o.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"})}):n.length===0?o.jsxs(es,{className:"bg-amber-500/5 border-amber-500/20 text-amber-600 dark:text-amber-400 p-6 rounded-2xl shadow-sm",children:[o.jsx(fs,{className:"w-5 h-5"}),o.jsx(Ru,{className:"font-bold mb-1",children:"No Active Workspace"}),o.jsx(ts,{className:"text-sm opacity-90",children:"No active workspace memberships were found for this account."})]}):o.jsxs("div",{className:"space-y-8",children:[o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1.2fr_1fr] gap-6",children:[o.jsxs(rt,{className:"border-border/40 bg-background/40",children:[o.jsxs(St,{className:"pb-4",children:[o.jsx(jt,{className:"text-base font-black",children:"Active Workspace"}),o.jsx(Kt,{children:"This workspace is used for dashboard, funnel, chat, and policy requests."})]}),o.jsxs(ht,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"workspace-select",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Workspace"}),o.jsx("select",{id:"workspace-select",value:d,onChange:H=>{F(H.target.value)},className:"h-12 w-full rounded-xl border border-border/40 bg-background/60 px-4 text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-primary",children:n.map(H=>o.jsx("option",{value:H.id,children:H.name},H.id))})]}),o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border/40 bg-muted/30 px-4 py-3",children:[o.jsxs("div",{className:"text-sm",children:[o.jsx("p",{className:"font-bold",children:"Your role"}),o.jsx("p",{className:"text-muted-foreground text-xs",children:"Permission level in this workspace"})]}),o.jsx(wt,{variant:B==="owner"?"default":B==="admin"?"secondary":"outline",className:"text-[10px] font-black uppercase tracking-widest",children:B?ue(B):"Unknown"})]})]})]}),o.jsxs(rt,{className:"border-border/40 bg-background/40",children:[o.jsxs(St,{className:"pb-4",children:[o.jsxs(jt,{className:"text-base font-black flex items-center gap-2",children:[o.jsx(am,{className:"w-4 h-4"}),"Invite Member"]}),o.jsx(Kt,{children:"Add an existing Folio user by email."})]}),o.jsx(ht,{className:"space-y-3",children:se?o.jsxs(o.Fragment,{children:[o.jsx(Ne,{placeholder:"member@company.com",value:C,onChange:H=>A(H.target.value),className:"h-11 rounded-xl bg-background/50 border-border/40"}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("select",{value:E,onChange:H=>M(H.target.value==="admin"?"admin":"member"),className:"h-11 flex-1 rounded-xl border border-border/40 bg-background/60 px-3 text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-primary",children:[o.jsx("option",{value:"member",children:"Member"}),re&&o.jsx("option",{value:"admin",children:"Admin"})]}),o.jsxs(oe,{className:"h-11 px-5 rounded-xl font-bold",disabled:w||C.trim().length===0,onClick:()=>{Z()},children:[w?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(am,{className:"w-4 h-4 mr-2"}),"Invite"]})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:"If this email is new, Folio will create the account and send an invite email."})]}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Only workspace admins can invite members."})})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("h4",{className:"text-sm font-black uppercase tracking-widest text-muted-foreground",children:["Members (",l.length,")"]}),o.jsxs(oe,{variant:"outline",className:"h-9 rounded-xl font-bold",onClick:()=>{V()},children:[o.jsx(Kw,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),y?o.jsx("div",{className:"py-12 flex items-center justify-center rounded-2xl border border-border/40 bg-muted/20",children:o.jsx(Qe,{className:"w-7 h-7 animate-spin text-primary"})}):o.jsx("div",{className:"space-y-3",children:l.map(H=>{const ae=se&&H.role!=="owner"&&(re||H.role==="member"),ie=se&&H.role!=="owner"&&(re||H.role==="member"),$=k===H.user_id;return o.jsxs("div",{className:"rounded-2xl border border-border/40 bg-background/50 p-4 flex flex-col md:flex-row md:items-center gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 text-primary font-black flex items-center justify-center shrink-0",children:ge(H)}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("p",{className:"font-bold truncate",children:[xe(H),H.is_current_user&&o.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:"(You)"})]}),o.jsx("p",{className:"text-sm text-muted-foreground truncate",children:H.email??"No email"})]})]}),o.jsxs("div",{className:"flex items-center gap-3 md:justify-end",children:[H.role==="owner"&&o.jsxs(wt,{className:"text-[10px] font-black uppercase tracking-widest flex items-center gap-1",children:[o.jsx(aC,{className:"w-3 h-3"}),"Owner"]}),H.role!=="owner"&&ae?o.jsxs("select",{value:H.role,disabled:$,onChange:fe=>{const le=fe.target.value==="admin"?"admin":"member";ye(H,le)},className:"h-10 rounded-xl border border-border/40 bg-background/60 px-3 text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-primary disabled:opacity-50",children:[o.jsx("option",{value:"member",children:"Member"}),re&&o.jsx("option",{value:"admin",children:"Admin"})]}):H.role!=="owner"?o.jsx(wt,{variant:H.role==="admin"?"secondary":"outline",className:"text-[10px] font-black uppercase tracking-widest",children:ue(H.role)}):null,ie&&o.jsx(oe,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10",disabled:$,onClick:()=>{T(H)},title:"Remove member",children:$?o.jsx(Qe,{className:"w-4 h-4 animate-spin"}):o.jsx(sr,{className:"w-4 h-4"})})]})]},H.user_id)})})]})]})]})]}),o.jsx(pa,{open:!!_,onOpenChange:H=>{H||J()},children:o.jsxs(ga,{className:"sm:max-w-md",children:[o.jsxs(ar,{children:[o.jsx(rr,{className:"text-lg font-black",children:"Remove Member"}),o.jsxs(bi,{className:"leading-relaxed",children:["Remove ",o.jsx("span",{className:"font-semibold text-foreground",children:L})," from this workspace? They will lose access to workspace policies, funnel data, dashboard metrics, and workspace-scoped retrieval."]})]}),o.jsxs(Xa,{className:"gap-2",children:[o.jsx(oe,{variant:"outline",onClick:J,disabled:D,children:"Cancel"}),o.jsxs(oe,{variant:"destructive",onClick:()=>{ne()},disabled:D,children:[D?o.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(sr,{className:"w-4 h-4 mr-2"}),"Remove"]})]})]})})]})}function Q4({configSnapshot:t,configSource:e,onLaunchSetup:n,onResetSetup:r}){return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(Tu,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-bold",children:"Supabase Configuration"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Primary storage and identity gateway."})]}),o.jsxs(wt,{variant:"secondary",className:"text-[10px] font-black uppercase tracking-widest px-3 py-1",children:["Source: ",e]})]}),o.jsxs(rt,{className:"border-border/40 shadow-sm bg-card/50 backdrop-blur-sm",children:[o.jsx(ht,{className:"p-8 space-y-8",children:t?o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"API Endpoint"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 backdrop-blur-sm shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold truncate text-foreground/80",children:t.url})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Project Identifier"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 font-mono shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold text-foreground/80",children:t.url.split("//")[1]?.split(".")[0]||"Unknown"})})]}),o.jsxs("div",{className:"md:col-span-2 space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Service Role Access (Masked)"}),o.jsxs("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 flex items-center justify-between shadow-inner",children:[o.jsxs("p",{className:"text-sm font-mono text-muted-foreground",children:[t.anonKey.slice(0,6),"...",t.anonKey.slice(-6)]}),o.jsx(wt,{variant:"outline",className:"text-[9px] font-bold",children:"Standard Key"})]})]})]}):o.jsxs(es,{className:"bg-amber-500/5 border-amber-500/20 text-amber-600 dark:text-amber-400 p-6 rounded-2xl shadow-sm",children:[o.jsx(fs,{className:"w-5 h-5"}),o.jsx(Ru,{className:"font-bold mb-1",children:"Infrastructure Standby"}),o.jsx(ts,{className:"text-sm opacity-90",children:"The foundation has not been initialized. You must run the setup wizard to continue."})]})}),o.jsxs(ku,{className:"bg-muted/20 p-8 flex gap-4 border-t",children:[o.jsxs(oe,{variant:t?"outline":"default",className:"flex-1 h-12 rounded-xl font-bold shadow-sm",onClick:n,children:[t?o.jsx(eA,{className:"w-4 h-4 mr-2"}):o.jsx(er,{className:"w-4 h-4 mr-2"}),t?"Run Setup Wizard":"Launch Initializer"]}),t&&o.jsx(oe,{variant:"ghost",size:"icon",className:"h-12 w-12 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",onClick:r,title:"Reset All Configuration",children:o.jsx(Kw,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"space-y-6 pt-4",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-destructive/10 flex items-center justify-center text-destructive",children:o.jsx(fs,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold text-destructive",children:"Advanced Maintenance"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Destructive actions and system-level overrides."})]})]}),o.jsx(rt,{className:"border-destructive/20 bg-destructive/5 overflow-hidden shadow-sm",children:o.jsxs(ht,{className:"p-8",children:[o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Fully resetting the foundation will purge all local storage cached parameters. This action is irreversible and will force a fresh bootstrap flow upon next launch."}),o.jsx(oe,{variant:"link",className:"px-0 text-destructive h-auto text-xs font-black uppercase tracking-widest mt-4 hover:no-underline hover:opacity-70 transition-opacity",onClick:r,children:"Wipe Local Foundation Buffer"})]})})]})]})}const Z4={theme:"system",setTheme:()=>null},M1=v.createContext(Z4);function e5({children:t,defaultTheme:e="system",storageKey:n="vite-ui-theme"}){const[r,l]=v.useState(()=>localStorage.getItem(n)||e);v.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),r==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(h);return}d.classList.add(r)},[r]);const u=v.useMemo(()=>({theme:r,setTheme:d=>{localStorage.setItem(n,d),l(d)}}),[r,n]);return o.jsx(M1.Provider,{value:u,children:t})}const t5=()=>{const t=v.useContext(M1);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function D1(){const{setTheme:t,theme:e}=t5();return o.jsxs(oe,{variant:"ghost",size:"icon",onClick:()=>t(e==="dark"?"light":"dark"),className:"text-muted-foreground hover:bg-muted/60 transition-all duration-300 h-9 w-9 rounded-full",title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:[e==="dark"?o.jsx(iA,{className:"h-[1.2rem] w-[1.2rem]"}):o.jsx(DC,{className:"h-[1.2rem] w-[1.2rem]"}),o.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function s5({open:t,onOpenChange:e,health:n,isBootstrapping:r,initStatus:l,sessionStatus:u,migrationStatus:d,onRunMigration:h}){return o.jsx(pa,{open:t,onOpenChange:e,children:o.jsxs(ga,{className:"sm:max-w-md",children:[o.jsxs(ar,{children:[o.jsxs(rr,{className:"flex items-center gap-2",children:[o.jsx(mi,{className:"w-5 h-5 text-primary"}),"Runtime Health Engine"]}),o.jsx(bi,{children:"Diagnostic overview of active foundation services."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[[{label:"API Provider",value:n,status:n==="ok"?"success":n==="error"?"error":"warning"},{label:"Bootstrap Cycle",value:r?"running":"stable",status:r?"warning":"success"},{label:"Init Integrity",value:l,status:l==="initialized"?"success":l==="error"?"error":"warning"},{label:"Auth Context",value:u,status:u==="authenticated"?"success":u==="error"?"error":"warning"}].map(m=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50 border",children:[o.jsx("span",{className:"text-sm font-medium",children:m.label}),o.jsx(wt,{variant:"outline",className:ve("text-[10px] uppercase font-bold",m.status==="success"&&"border-emerald-500/50 text-emerald-500 bg-emerald-500/5",m.status==="warning"&&"border-amber-500/50 text-amber-500 bg-amber-500/5",m.status==="error"&&"border-destructive/50 text-destructive bg-destructive/5"),children:m.value})]},m.label)),o.jsxs("div",{className:ve("p-4 rounded-xl border flex flex-col gap-3 transition-all",d?.needsMigration?"bg-amber-500/10 border-amber-500/20 text-amber-600 dark:text-amber-500":"bg-primary/5 border-primary/10 text-primary"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[d?.needsMigration?o.jsx(mi,{className:"w-4 h-4 shrink-0 animate-pulse"}):o.jsx(xa,{className:"w-4 h-4 shrink-0"}),o.jsx("p",{className:"text-xs font-semibold leading-relaxed",children:d?d.message:"Checking database schema migration parity..."})]}),d?.needsMigration&&h&&o.jsx(oe,{size:"sm",className:"w-full bg-amber-500 hover:bg-amber-600 text-white font-black text-[10px] uppercase tracking-widest h-8 rounded-lg",onClick:h,children:"Run System Migration"})]})]})]})})}class n5{buffer="";processChunk(e){const n=[];this.buffer+=e;const r=this.buffer.split(`
|
|
96
|
+
`);this.buffer=r.pop()||"";for(const l of r)if(l.startsWith("data: "))try{const u=JSON.parse(l.slice(6));n.push(u)}catch{}return n}flush(){if(!this.buffer.trim())return[];const e=[];if(this.buffer.startsWith("data: "))try{e.push(JSON.parse(this.buffer.slice(6)))}catch{}return this.buffer="",e}reset(){this.buffer=""}}async function P1(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,h=new n5,m=setTimeout(()=>{u.cancel("Timeout").catch(()=>{})},r);try{for(;;){const{value:p,done:y}=await u.read();if(y){h.flush().forEach(e);break}const x=d.decode(p,{stream:!0});h.processChunk(x).forEach(e)}}catch(p){const y=p instanceof Error?p:new Error(String(p));if(l)l(y);else throw y}finally{clearTimeout(m),h.reset()}}class rn extends Error{constructor(e,n,r){super(e),this.code=n,this.status=r,this.name="SetupApiError"}}async function a5(t){const e=await fetch("/api/setup/organizations",{headers:{Authorization:`Bearer ${t}`}}),n=await e.text();let r={};if(n.trim())try{r=JSON.parse(n)}catch{r={message:n.trim()}}if(!e.ok){const l=typeof r?.error=="string"&&r.error||typeof r?.message=="string"&&r.message||`${e.status} ${e.statusText} while fetching organizations`,u=e.status===500||e.status===502?" If local API is not running, start `npm run dev:api` and retry.":"";throw new rn(`${l}${u}`,"FETCH_ORGS_FAILED",e.status)}return r}async function r5(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 rn(r?.error||"Failed to auto-provision","PROVISION_FAILED",n.status)}await P1(n,e,{timeout:36e4,onError:r=>{throw new rn(`Provisioning stream error: ${r.message}`,"STREAM_ERROR")}})}async function i5(t){const e=await fetch(`/api/setup/projects/${encodeURIComponent(t.projectRef)}/credentials`,{headers:{Authorization:`Bearer ${t.accessToken}`}}),n=await e.json().catch(()=>({}));if(!e.ok)throw new rn(n?.error||"Failed to recover project credentials","RECOVERY_FAILED",e.status);return{projectId:String(n.projectId||t.projectRef),url:String(n.url||`https://${t.projectRef}.supabase.co`),anonKey:String(n.anonKey||""),dbPass:""}}async function o5(t,e){const n=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:t.projectRef,accessToken:t.accessToken,anonKey:t.anonKey})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new rn(r?.error||"Failed to run migration","MIGRATION_FAILED",n.status)}await P1(n,e,{timeout:6e5,onError:r=>{throw new rn(`Migration stream error: ${r.message}`,"STREAM_ERROR")}})}const um={step:"welcome",managed:{accessToken:"",organizations:[],selectedOrg:"",projectName:"Folio-Core",region:"us-east-1",isFetchingOrgs:!1},manual:{url:"",anonKey:""},projectId:"",logs:[],error:null,isMigrating:!1,migrationStatus:null};function l5(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:{...um.managed},error:null};case"RESET_MANUAL_FLOW":return{...t,manual:{...um.manual},error:null};default:return t}}const Xm=v.forwardRef(({className:t,...e},n)=>o.jsx("textarea",{className:ve("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));Xm.displayName="Textarea";function _f(t){const e=t.trim();return e?e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}.supabase.co`:""}function c5(t){const e=t.trim();if(!e)return{valid:!1,message:"URL is required"};if(e.startsWith("http://")||e.startsWith("https://"))try{return new URL(e).hostname.endsWith(".supabase.co")?{valid:!0,message:"Valid Supabase URL"}:{valid:!1,message:"URL must be a supabase.co domain"}}catch{return{valid:!1,message:"Invalid URL format"}}return/^[a-z0-9-]+$/.test(e)?{valid:!0,message:"Project ID detected"}:{valid:!1,message:"Enter a valid URL or project ID"}}function u5(t){const e=t.trim();return e?e.startsWith("sb_publishable_")?e.length<25?{valid:!1,message:"Incomplete publishable key"}:{valid:!0,message:"Valid publishable key"}:e.startsWith("eyJ")?e.length<50?{valid:!1,message:"Incomplete anon key"}:{valid:!0,message:"Valid anon key"}:{valid:!1,message:"Invalid API key format"}:{valid:!1,message:"API key is required"}}function L1(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 P0(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}}function d5({url:t,anonKey:e,error:n,onUrlChange:r,onAnonKeyChange:l,onSave:u,onBack:d}){const h=c5(t),m=u5(e);return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Manual Credentials"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect Folio to an existing Supabase project with URL and anon key."})]}),o.jsxs("div",{className:"grid gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"supabase-url",children:"Supabase URL or Project ID"}),o.jsx(Ne,{id:"supabase-url",value:t,onChange:p=>r(p.target.value),placeholder:"https://project.supabase.co or project-id",className:!h.valid&&t.length>0?"border-destructive focus-visible:ring-destructive":""}),t.length>0&&o.jsxs("p",{className:ve("text-xs flex items-center gap-1",h.valid?"text-emerald-500":"text-destructive"),children:[h.valid?o.jsx(Ks,{className:"w-3"}):o.jsx(fs,{className:"w-3"}),h.message]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"supabase-anon-key",children:"Anon Key"}),o.jsx(Xm,{id:"supabase-anon-key",value:e,onChange:p=>l(p.target.value),placeholder:"eyJ...",className:ve("min-h-[120px] font-mono text-xs",!m.valid&&e.length>0?"border-destructive focus-visible:ring-destructive":"")}),e.length>0&&o.jsxs("p",{className:ve("text-xs flex items-center gap-1",m.valid?"text-emerald-500":"text-destructive"),children:[m.valid?o.jsx(Ks,{className:"w-3"}):o.jsx(fs,{className:"w-3"}),m.message]})]})]}),n&&o.jsxs(es,{variant:"destructive",children:[o.jsx(fs,{className:"h-4 w-4"}),o.jsx(ts,{children:n})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(oe,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:d,children:[o.jsx(tl,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx(oe,{className:"ml-auto",onClick:u,disabled:!h.valid||!m.valid,children:"Validate and Continue"})]})]})}const nl=v.createContext(null),h5=({children:t,value:e,onValueChange:n,...r})=>{const[l,u]=v.useState(!1),d=v.useRef(null);return v.useEffect(()=>{const h=m=>{d.current&&!d.current.contains(m.target)&&u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),o.jsx(nl.Provider,{value:{value:e,onValueChange:n,open:l,setOpen:u},children:o.jsx("div",{ref:d,className:"relative inline-block w-full",...r,children:t})})},z1=v.forwardRef(({className:t,children:e,...n},r)=>{const l=v.useContext(nl);return o.jsxs("button",{ref:r,type:"button",onClick:()=>l?.setOpen(!l.open),className:ve("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...n,children:[e,o.jsx("svg",{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",className:"h-4 w-4 opacity-50",children:o.jsx("path",{d:"m6 9 6 6 6-6"})})]})});z1.displayName="SelectTrigger";const U1=v.forwardRef(({className:t,placeholder:e,...n},r)=>{const l=v.useContext(nl);return v.Children.toArray(n.children),o.jsx("span",{ref:r,className:ve("pointer-events-none",t),...n,children:l?.value||e})});U1.displayName="SelectValue";const B1=v.forwardRef(({className:t,children:e,position:n="popper",...r},l)=>v.useContext(nl)?.open?o.jsx("div",{ref:l,className:ve("absolute z-50 min-w-[8rem] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80 mt-1",n==="popper"&&"translate-y-1",t),...r,children:o.jsx("div",{className:"p-1 bg-white dark:bg-zinc-950",children:e})}):null);B1.displayName="SelectContent";const I1=v.forwardRef(({className:t,children:e,value:n,...r},l)=>{const u=v.useContext(nl);return o.jsxs("div",{ref:l,className:ve("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-accent hover:text-accent-foreground cursor-pointer",t),onClick:()=>{u?.onValueChange?.(n),u?.setOpen(!1)},...r,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u?.value===n&&o.jsx("svg",{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",className:"h-4 w-4",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}),o.jsx("span",{className:"truncate",children:e})]})});I1.displayName="SelectItem";const f5=[{value:"us-east-1",label:"US East (N. Virginia)"},{value:"us-west-1",label:"US West (N. California)"},{value:"eu-central-1",label:"Europe (Frankfurt)"},{value:"ap-southeast-1",label:"Asia Pacific (Singapore)"}];function m5({organizations:t,selectedOrg:e,projectName:n,region:r,onOrgSelect:l,onProjectNameChange:u,onRegionChange:d,onProvision:h,onBack:m}){return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Provisioning Parameters"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Choose an organization and project configuration for Folio deployment."})]}),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(Je,{htmlFor:"project-name",children:"Project Name"}),o.jsx(Ne,{id:"project-name",value:n,onChange:p=>u(p.target.value),placeholder:"my-folio-app"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"region",children:"Region"}),o.jsxs(h5,{value:r,onValueChange:d,children:[o.jsx(z1,{id:"region",children:o.jsx(U1,{placeholder:"Select region"})}),o.jsx(B1,{children:f5.map(p=>o.jsx(I1,{value:p.value,children:p.label},p.value))})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs(Je,{className:"flex items-center gap-2",children:[o.jsx(UE,{className:"w-4 h-4"}),"Select Organization"]}),o.jsx("div",{className:"grid gap-2 max-h-[160px] overflow-y-auto p-1 rounded-lg border bg-muted/20",children:t.map(p=>o.jsxs("button",{onClick:()=>l(p.id),className:ve("flex items-center justify-between p-3 rounded-md border text-sm transition-all",e===p.id?"bg-primary text-primary-foreground border-primary shadow-sm":"bg-background hover:border-primary/50"),children:[o.jsx("span",{children:p.name}),e===p.id&&o.jsx(gC,{className:"w-3 h-3 opacity-70"})]},p.id))})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(oe,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:m,children:[o.jsx(tl,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsxs(oe,{className:"ml-auto",onClick:h,disabled:!e||!n,children:[o.jsx($C,{className:"mr-2 h-4 w-4"}),"Auto-Provision"]})]})]})}function p5({accessToken:t,error:e,isFetching:n,onTokenChange:r,onFetchOrgs:l,onBack:u}){const d=L1(t);return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Supabase Access Token"}),o.jsxs("p",{className:"text-muted-foreground text-sm",children:["Enter a management token (",o.jsx("code",{className:"text-primary",children:"sbp_..."}),") so Folio can discover organizations and provision a project."]})]}),o.jsx("div",{className:"grid gap-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"access-token",children:"Personal Access Token"}),o.jsxs("div",{className:"relative",children:[o.jsx(gi,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(Ne,{id:"access-token",type:"password",value:t,onChange:h=>r(h.target.value),placeholder:"sbp_xxxxxxxxxxxxx",className:ve("pl-9",!d.valid&&t.length>0?"border-destructive focus-visible:ring-destructive":"")})]}),t.length>0&&o.jsxs("p",{className:ve("text-xs flex items-center gap-1",d.valid?"text-emerald-500":"text-destructive"),children:[d.valid?o.jsx(Ks,{className:"w-3"}):o.jsx(fs,{className:"w-3"}),d.message]})]})}),e&&o.jsxs(es,{variant:"destructive",children:[o.jsx(fs,{className:"h-4 w-4"}),o.jsx(ts,{children:e})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[o.jsxs(oe,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:u,disabled:n,children:[o.jsx(tl,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx(oe,{className:"ml-auto",onClick:l,disabled:!d.valid||n,children:n?o.jsxs(o.Fragment,{children:[o.jsx(Qe,{className:"mr-2 h-4 w-4 animate-spin"}),"Fetching..."]}):"Fetch Organizations"})]})]})}function V1({logs:t}){const e=v.useRef(null);return v.useEffect(()=>{e.current?.scrollIntoView({behavior:"smooth"})},[t]),o.jsxs("div",{className:"bg-zinc-950 rounded-xl border border-zinc-800 overflow-hidden shadow-2xl flex flex-col h-[300px]",role:"log","aria-live":"polite","aria-label":"Setup logs",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-zinc-800 bg-zinc-900/50",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/80"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/80"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500/80"}),o.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-widest text-zinc-500 font-bold",children:"Foundation Trace"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 font-mono text-[13px] leading-relaxed scrollbar-thin scrollbar-thumb-zinc-800",children:[t.length===0?o.jsx("div",{className:"text-zinc-600 italic",children:"Awaiting setup activity..."}):t.map((n,r)=>o.jsxs("div",{className:ve("mb-1 flex gap-3",n.type==="error"&&"text-red-400",n.type==="success"&&"text-emerald-400",n.type==="info"&&"text-blue-400",n.type==="stderr"&&"text-amber-400",n.type==="stdout"&&"text-zinc-300"),children:[o.jsx("span",{className:"text-zinc-600 shrink-0 select-none",children:new Date(n.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsx("span",{className:"break-all",children:n.message})]},`${n.timestamp}-${n.type}-${n.message}-${r}`)),o.jsx("div",{ref:e})]})]})}function g5({logs:t,error:e,isMigrating:n,migrationStatus:r,accessToken:l,onTokenChange:u,onRunMigration:d,onBypass:h}){const m=r?!r.needsMigration:!1;return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Database Migration"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:r?.message||`Run migration to align database with app v${fa}.`})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Je,{htmlFor:"migration-token",className:"flex items-center gap-2",children:[o.jsx(gi,{className:"w-4 h-4"}),"Supabase Access Token"]}),o.jsx(Ne,{id:"migration-token",type:"password",value:l,onChange:p=>u(p.target.value),placeholder:"sbp_xxxxxxxxxxxxx"})]}),o.jsx(V1,{logs:t}),e&&o.jsxs(es,{variant:"destructive",children:[o.jsx(fs,{className:"h-4 w-4"}),o.jsx(ts,{children:e})]}),o.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[m&&o.jsx(oe,{variant:"ghost",size:"sm",onClick:h,disabled:n,children:"Skip for now"}),o.jsx(oe,{className:"ml-auto",onClick:d,disabled:n||l.trim()==="",children:n?o.jsxs(o.Fragment,{children:[o.jsx(Qe,{className:"mr-2 h-4 w-4 animate-spin"}),"Migrating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Fw,{className:"mr-2 h-4 w-4"}),"Run Migration"]})})]})]})}function y5({logs:t,error:e,onRetry:n}){return o.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Provisioning"}),o.jsxs("p",{className:"text-muted-foreground text-sm flex items-center gap-2",children:[!e&&o.jsx(Qe,{className:"w-4 h-4 animate-spin text-primary"}),"Folio is creating a Supabase project and preparing runtime credentials."]})]}),o.jsx(V1,{logs:t}),e?o.jsx("div",{className:"flex items-center gap-3",children:o.jsxs(oe,{variant:"destructive",onClick:n,children:[o.jsx(fs,{className:"w-4 h-4 mr-2"}),"Retry Provisioning"]})}):null]})}function v5({onManaged:t,onManual:e,onBack:n}){return o.jsxs("div",{className:"flex flex-col h-full justify-center gap-10 animate-in fade-in slide-in-from-right-4 duration-500",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-4xl font-black tracking-tight",children:"Setup Mode"}),o.jsx("p",{className:"text-muted-foreground text-lg leading-relaxed max-w-md",children:"Select whether Folio should auto-provision a project or connect to an existing one."})]}),o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("button",{onClick:t,className:"group relative flex flex-col items-start p-8 text-left border border-border/40 rounded-3xl hover:border-primary hover:bg-primary/5 hover:shadow-xl hover:shadow-primary/5 transition-all duration-300",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center text-primary group-hover:scale-110 transition-transform duration-500",children:o.jsx(hu,{className:"w-6 h-6 fill-primary/20"})}),o.jsx("strong",{className:"text-xl font-bold",children:"Managed Setup"})]}),o.jsx("span",{className:"text-muted-foreground leading-relaxed",children:"Use an access token to auto-provision project + run migration automatically. Recommended for most users."}),o.jsx("div",{className:"absolute top-8 right-8 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:o.jsx(pi,{className:"w-6 h-6 text-primary"})})]}),o.jsxs("button",{onClick:e,className:"group relative flex flex-col items-start p-8 text-left border border-border/40 rounded-3xl hover:border-primary hover:bg-primary/5 hover:shadow-xl hover:shadow-primary/5 transition-all duration-300",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-muted flex items-center justify-center text-muted-foreground group-hover:bg-primary/10 group-hover:text-primary group-hover:scale-110 transition-all duration-500",children:o.jsx(Gm,{className:"w-6 h-6"})}),o.jsx("strong",{className:"text-xl font-bold",children:"Manual Connection"})]}),o.jsx("span",{className:"text-muted-foreground leading-relaxed",children:"Provide your own Supabase URL + anon key. Use this if you already have a configured project."}),o.jsx("div",{className:"absolute top-8 right-8 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:o.jsx(pi,{className:"w-6 h-6 text-primary"})})]})]}),o.jsx("div",{className:"pt-4",children:o.jsxs(oe,{variant:"ghost",size:"sm",className:"w-fit -ml-2 text-muted-foreground hover:text-foreground h-10 px-4 rounded-xl font-bold",onClick:n,children:[o.jsx(tl,{className:"w-4 h-4 mr-1"}),"Back to Welcome"]})})]})}function x5({onNext:t}){return o.jsxs("div",{className:"flex flex-col h-full justify-center gap-12 animate-in fade-in slide-in-from-bottom-4 duration-700",children:[o.jsxs("div",{className:"space-y-4 text-center sm:text-left",children:[o.jsxs("h2",{className:"text-5xl font-black tracking-tight leading-tight",children:["Welcome to ",o.jsx("span",{className:"text-primary",children:"Folio"})]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-lg leading-relaxed",children:"Let's configure your foundation runtime: local desktop app, remote Supabase database, and RealTimeX SDK backend connectivity."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs(rt,{className:"bg-muted/30 border-border/40 shadow-sm hover:shadow-md transition-all duration-300",children:[o.jsx(St,{className:"pb-3 px-6",children:o.jsxs(jt,{className:"flex items-center gap-2 text-base font-bold",children:[o.jsx(xa,{className:"w-5 h-5 text-primary"}),"Secure by Default"]})}),o.jsx(ht,{className:"px-6 pb-6",children:o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Credentials are stored locally and used to configure runtime contracts only."})})]}),o.jsxs(rt,{className:"bg-muted/30 border-border/40 shadow-sm hover:shadow-md transition-all duration-300",children:[o.jsx(St,{className:"pb-3 px-6",children:o.jsxs(jt,{className:"flex items-center gap-2 text-base font-bold",children:[o.jsx(_C,{className:"w-5 h-5 text-primary"}),"No Feature Lock-In"]})}),o.jsx(ht,{className:"px-6 pb-6",children:o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"This step only prepares infrastructure, not document automation features."})})]})]}),o.jsx("div",{className:"pt-4 flex justify-center sm:justify-start",children:o.jsx(oe,{size:"lg",className:"h-14 px-10 rounded-2xl text-base font-black shadow-xl shadow-primary/20 hover:scale-105 transition-all",onClick:t,children:"Start Setup"})})]})}function b5({onComplete:t,open:e=!0,canClose:n=!1}){const[r,l]=v.useReducer(l5,um),u=v.useRef("");v.useEffect(()=>()=>{u.current=""},[]);const d=v.useCallback((S,_)=>{l({type:"ADD_LOG",payload:{type:S,message:_}})},[]),h=v.useCallback(()=>{u.current="",t()},[t]),m=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_FETCHING_ORGS",payload:!0});const S=r.managed.accessToken.trim(),_=L1(S);if(!_.valid){l({type:"SET_ERROR",payload:_.message||"Invalid token"}),l({type:"SET_FETCHING_ORGS",payload:!1});return}try{u.current=S;const T=await a5(S);l({type:"SET_ORGANIZATIONS",payload:T}),l({type:"SET_STEP",payload:"managed-org"})}catch(T){const C=T instanceof rn?T.message:String(T);l({type:"SET_ERROR",payload:C})}finally{l({type:"SET_FETCHING_ORGS",payload:!1})}},[r.managed.accessToken]),p=v.useCallback(async S=>{const _=S?.projectRef||r.projectId||P0(r.manual.url),T=S?.accessToken||u.current||r.managed.accessToken.trim(),C=S?.url||r.manual.url,A=S?.anonKey||r.manual.anonKey;if(!_||!T){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"});let E=!1;try{if(await o5({projectRef:_,accessToken:T,anonKey:A},M=>{if(M.type==="stdout"){d("stdout",String(M.data));return}if(M.type==="stderr"){d("stderr",String(M.data));return}if(M.type==="info"){d("info",String(M.data));return}if(M.type==="error"){d("error",String(M.data));return}M.type==="done"&&(E=M.data==="success")}),!E)throw new Error("Migration did not complete successfully.");C&&A&&ff({url:_f(C),anonKey:A.trim()}),d("success","Migration completed. Setup is ready."),setTimeout(()=>h(),600)}catch(M){const P=M instanceof rn?M.message:String(M);l({type:"SET_ERROR",payload:P}),d("error",P)}finally{l({type:"SET_MIGRATING",payload:!1})}},[d,h,r.managed.accessToken,r.manual.anonKey,r.manual.url,r.projectId]),y=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"provisioning"}),l({type:"CLEAR_LOGS"}),d("info","Starting managed provisioning...");const S=u.current||r.managed.accessToken.trim(),_={result:null,projectId:"",receivedDone:!1,receivedError:!1},T=C=>{_.result=C,l({type:"SET_PROJECT_ID",payload:C.projectId}),ff({url:_f(C.url),anonKey:C.anonKey.trim()}),l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,appVersion:fa,latestMigrationTimestamp:null,message:"Fresh project created. Migration is required."}}),d("success","Project ready. Starting migration...")};try{if(await r5({accessToken:S,orgId:r.managed.selectedOrg,projectName:r.managed.projectName,region:r.managed.region},C=>{if(C.type==="project_id"){_.projectId=String(C.data),l({type:"SET_PROJECT_ID",payload:_.projectId});return}if(C.type==="info"){d("info",String(C.data));return}if(C.type==="error"){_.receivedError=!0,d("error",String(C.data)),l({type:"SET_ERROR",payload:String(C.data)});return}if(C.type==="success"){T(C.data);return}C.type==="done"&&(_.receivedDone=!0)}),!_.result&&_.projectId){d("info","Provisioning stream disconnected. Recovering credentials from existing project...");const C=await i5({accessToken:S,projectRef:_.projectId});T(C)}if(!_.result){const C=_.receivedError?"Provisioning failed before credentials were available. Retry or use manual setup.":_.receivedDone?"Provisioning ended without credentials. Retry or use manual setup.":"Provisioning stream ended unexpectedly. The project may still be provisioning; retry in a moment.";throw new rn(C,"PROVISION_INCOMPLETE")}await p({projectRef:_.result.projectId,accessToken:S,url:_.result.url,anonKey:_.result.anonKey})}catch(C){const A=C instanceof rn?C.message:String(C);l({type:"SET_ERROR",payload:A}),d("error",A)}},[d,p,r.managed.accessToken,r.managed.projectName,r.managed.region,r.managed.selectedOrg]),x=v.useCallback(async()=>{l({type:"SET_ERROR",payload:null}),l({type:"SET_STEP",payload:"validating"});const S=_f(r.manual.url),_=r.manual.anonKey.trim(),T=await TA(S,_);if(!T.valid){l({type:"SET_ERROR",payload:T.error||"Connection validation failed."}),l({type:"SET_STEP",payload:"credentials"});return}ff({url:S,anonKey:_}),l({type:"SET_MANUAL_URL",payload:S});const C=P0(S);C&&l({type:"SET_PROJECT_ID",payload:C});try{const A=Bm(S,_),E=await O1(A);l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:E.needsMigration,appVersion:E.appVersion,latestMigrationTimestamp:E.latestMigrationTimestamp,message:E.message}}),E.needsMigration?l({type:"SET_STEP",payload:"migration"}):h()}catch{l({type:"SET_MIGRATION_STATUS",payload:{needsMigration:!0,appVersion:fa,latestMigrationTimestamp:null,message:"Could not verify migration status. Run migration to continue."}}),l({type:"SET_STEP",payload:"migration"})}},[h,r.manual.anonKey,r.manual.url]);if(!e)return null;const w=[{key:"welcome",label:"Welcome"},{key:"config",label:"Configuration",subSteps:["type","managed-token","managed-org","credentials"]},{key:"validation",label:"Validation",subSteps:["provisioning","validating"]},{key:"migration",label:"Migration"}],k=r.step==="welcome"?"welcome":["type","managed-token","managed-org","credentials"].includes(r.step)?"config":["provisioning","validating"].includes(r.step)?"validation":"migration";return o.jsxs(pa,{open:e,onOpenChange:S=>{!S&&n&&t()},children:[o.jsx(R1,{className:"bg-zinc-950/80 backdrop-blur-sm"}),o.jsx(ga,{className:"sm:max-w-[1100px] w-full p-0 overflow-hidden border-none shadow-2xl",children:o.jsxs("div",{className:"flex w-full min-h-[700px]",children:[o.jsxs("aside",{className:"w-[300px] border-r bg-muted/30 p-8 flex flex-col gap-10",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Folio Setup"}),o.jsx("p",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wider",children:"Foundation Parity Mode"})]}),o.jsx("nav",{className:"flex-1",children:o.jsx("ul",{className:"space-y-4",children:w.map(S=>{const _=k===S.key,T=w.findIndex(C=>C.key===k)>w.findIndex(C=>C.key===S.key);return o.jsxs("li",{className:"flex items-center gap-3",children:[o.jsx("div",{className:ve("w-6 h-6 rounded-full flex items-center justify-center border transition-all duration-300",_?"border-primary bg-primary text-primary-foreground shadow-sm scale-110":T?"border-emerald-500 bg-emerald-50 text-emerald-500":"border-muted text-muted-foreground"),children:T?o.jsx(Ks,{className:"w-4 h-4"}):o.jsx("div",{className:"text-[10px] font-bold",children:w.indexOf(S)+1})}),o.jsx("span",{className:ve("text-sm font-medium transition-colors",_?"text-foreground":"text-muted-foreground"),children:S.label})]},S.key)})})}),o.jsxs("div",{className:"mt-auto pt-6 border-t flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground/50 uppercase tracking-widest",children:["Version ",fa]}),o.jsx(wt,{variant:"outline",className:"text-[10px] py-0 h-4",children:"Production"})]})]}),o.jsx("main",{className:"flex-1 p-12 bg-background relative flex flex-col",children:o.jsxs("div",{className:"max-w-[700px] w-full mx-auto flex-1",children:[r.step==="welcome"&&o.jsx(x5,{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(p5,{accessToken:r.managed.accessToken,error:r.error,isFetching:r.managed.isFetchingOrgs,onTokenChange:S=>l({type:"SET_ACCESS_TOKEN",payload:S}),onFetchOrgs:m,onBack:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="managed-org"&&o.jsx(m5,{organizations:r.managed.organizations,selectedOrg:r.managed.selectedOrg,projectName:r.managed.projectName,region:r.managed.region,onOrgSelect:S=>l({type:"SET_SELECTED_ORG",payload:S}),onProjectNameChange:S=>l({type:"SET_PROJECT_NAME",payload:S}),onRegionChange:S=>l({type:"SET_REGION",payload:S}),onProvision:y,onBack:()=>l({type:"SET_STEP",payload:"managed-token"})}),r.step==="provisioning"&&o.jsx(y5,{logs:r.logs,error:r.error,onRetry:()=>l({type:"SET_STEP",payload:"managed-token"})}),r.step==="credentials"&&o.jsx(d5,{url:r.manual.url,anonKey:r.manual.anonKey,error:r.error,onUrlChange:S=>l({type:"SET_MANUAL_URL",payload:S}),onAnonKeyChange:S=>l({type:"SET_MANUAL_ANON_KEY",payload:S}),onSave:x,onBack:()=>l({type:"SET_STEP",payload:"type"})}),r.step==="validating"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center space-y-4 animate-in fade-in zoom-in-95 duration-500",children:[o.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-primary border-t-transparent animate-spin"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h2",{className:"text-xl font-bold",children:"Validating Credentials"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Please wait while Folio verifies your Supabase configuration."})]})]}),r.step==="migration"&&o.jsx(g5,{logs:r.logs,error:r.error,isMigrating:r.isMigrating,migrationStatus:r.migrationStatus,accessToken:r.managed.accessToken,onTokenChange:S=>l({type:"SET_ACCESS_TOKEN",payload:S}),onRunMigration:()=>p(),onBypass:h})]})})]})})]})}const Jm=v.createContext({});function Qm(t){const e=v.useRef(null);return e.current===null&&(e.current=t()),e.current}const $1=typeof window<"u",q1=$1?v.useLayoutEffect:v.useEffect,Pu=v.createContext(null);function Zm(t,e){t.indexOf(e)===-1&&t.push(e)}function pu(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const ln=(t,e,n)=>n>e?e:n<t?t:n;let ep=()=>{};const An={},H1=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function G1(t){return typeof t=="object"&&t!==null}const F1=t=>/^0[^.\s]+$/u.test(t);function K1(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ls=t=>t,w5=(t,e)=>n=>e(t(n)),al=(...t)=>t.reduce(w5),Wo=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class tp{constructor(){this.subscriptions=[]}add(e){return Zm(this.subscriptions,e),()=>pu(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 Gs=t=>t*1e3,Ds=t=>t/1e3;function Y1(t,e){return e?t*(1e3/e):0}const W1=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,S5=1e-7,j5=12;function _5(t,e,n,r,l){let u,d,h=0;do d=e+(n-e)/2,u=W1(d,r,l)-t,u>0?n=d:e=d;while(Math.abs(u)>S5&&++h<j5);return d}function rl(t,e,n,r){if(t===e&&n===r)return Ls;const l=u=>_5(u,0,1,t,n);return u=>u===0||u===1?u:W1(l(u),e,r)}const X1=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,J1=t=>e=>1-t(1-e),Q1=rl(.33,1.53,.69,.99),sp=J1(Q1),Z1=X1(sp),eS=t=>(t*=2)<1?.5*sp(t):.5*(2-Math.pow(2,-10*(t-1))),np=t=>1-Math.sin(Math.acos(t)),tS=J1(np),sS=X1(np),N5=rl(.42,0,1,1),k5=rl(0,0,.58,1),nS=rl(.42,0,.58,1),T5=t=>Array.isArray(t)&&typeof t[0]!="number",aS=t=>Array.isArray(t)&&typeof t[0]=="number",E5={linear:Ls,easeIn:N5,easeInOut:nS,easeOut:k5,circIn:np,circInOut:sS,circOut:tS,backIn:sp,backInOut:Z1,backOut:Q1,anticipate:eS},C5=t=>typeof t=="string",L0=t=>{if(aS(t)){ep(t.length===4);const[e,n,r,l]=t;return rl(e,n,r,l)}else if(C5(t))return E5[t];return t},qc=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function A5(t,e){let n=new Set,r=new Set,l=!1,u=!1;const d=new WeakSet;let h={delta:0,timestamp:0,isProcessing:!1};function m(y){d.has(y)&&(p.schedule(y),t()),y(h)}const p={schedule:(y,x=!1,w=!1)=>{const k=w&&l?n:r;return x&&d.add(y),k.has(y)||k.add(y),y},cancel:y=>{r.delete(y),d.delete(y)},process:y=>{if(h=y,l){u=!0;return}l=!0,[n,r]=[r,n],n.forEach(m),n.clear(),l=!1,u&&(u=!1,p.process(y))}};return p}const R5=40;function rS(t,e){let n=!1,r=!0;const l={delta:0,timestamp:0,isProcessing:!1},u=()=>n=!0,d=qc.reduce((A,E)=>(A[E]=A5(u),A),{}),{setup:h,read:m,resolveKeyframes:p,preUpdate:y,update:x,preRender:w,render:j,postRender:k}=d,S=()=>{const A=An.useManualTiming?l.timestamp:performance.now();n=!1,An.useManualTiming||(l.delta=r?1e3/60:Math.max(Math.min(A-l.timestamp,R5),1)),l.timestamp=A,l.isProcessing=!0,h.process(l),m.process(l),p.process(l),y.process(l),x.process(l),w.process(l),j.process(l),k.process(l),l.isProcessing=!1,n&&e&&(r=!1,t(S))},_=()=>{n=!0,r=!0,l.isProcessing||t(S)};return{schedule:qc.reduce((A,E)=>{const M=d[E];return A[E]=(P,U=!1,R=!1)=>(n||_(),M.schedule(P,U,R)),A},{}),cancel:A=>{for(let E=0;E<qc.length;E++)d[qc[E]].cancel(A)},state:l,steps:d}}const{schedule:ct,cancel:ya,state:Ft,steps:Nf}=rS(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ls,!0);let Jc;function O5(){Jc=void 0}const Qt={now:()=>(Jc===void 0&&Qt.set(Ft.isProcessing||An.useManualTiming?Ft.timestamp:performance.now()),Jc),set:t=>{Jc=t,queueMicrotask(O5)}},iS=t=>e=>typeof e=="string"&&e.startsWith(t),oS=iS("--"),M5=iS("var(--"),ap=t=>M5(t)?D5.test(t.split("/*")[0].trim()):!1,D5=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function z0(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const wi={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Xo={...wi,transform:t=>ln(0,1,t)},Hc={...wi,default:1},Ao=t=>Math.round(t*1e5)/1e5,rp=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function P5(t){return t==null}const L5=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ip=(t,e)=>n=>!!(typeof n=="string"&&L5.test(n)&&n.startsWith(t)||e&&!P5(n)&&Object.prototype.hasOwnProperty.call(n,e)),lS=(t,e,n)=>r=>{if(typeof r!="string")return r;const[l,u,d,h]=r.match(rp);return{[t]:parseFloat(l),[e]:parseFloat(u),[n]:parseFloat(d),alpha:h!==void 0?parseFloat(h):1}},z5=t=>ln(0,255,t),kf={...wi,transform:t=>Math.round(z5(t))},Ja={test:ip("rgb","red"),parse:lS("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+kf.transform(t)+", "+kf.transform(e)+", "+kf.transform(n)+", "+Ao(Xo.transform(r))+")"};function U5(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 dm={test:ip("#"),parse:U5,transform:Ja.transform},il=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),la=il("deg"),on=il("%"),je=il("px"),B5=il("vh"),I5=il("vw"),U0={...on,parse:t=>on.parse(t)/100,transform:t=>on.transform(t*100)},ii={test:ip("hsl","hue"),parse:lS("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+on.transform(Ao(e))+", "+on.transform(Ao(n))+", "+Ao(Xo.transform(r))+")"},Rt={test:t=>Ja.test(t)||dm.test(t)||ii.test(t),parse:t=>Ja.test(t)?Ja.parse(t):ii.test(t)?ii.parse(t):dm.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ja.transform(t):ii.transform(t),getAnimatableNone:t=>{const e=Rt.parse(t);return e.alpha=0,Rt.transform(e)}},V5=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function $5(t){return isNaN(t)&&typeof t=="string"&&(t.match(rp)?.length||0)+(t.match(V5)?.length||0)>0}const cS="number",uS="color",q5="var",H5="var(",B0="${}",G5=/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 h=e.replace(G5,m=>(Rt.test(m)?(r.color.push(u),l.push(uS),n.push(Rt.parse(m))):m.startsWith(H5)?(r.var.push(u),l.push(q5),n.push(m)):(r.number.push(u),l.push(cS),n.push(parseFloat(m))),++u,B0)).split(B0);return{values:n,split:h,indexes:r,types:l}}function dS(t){return Jo(t).values}function hS(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 h=n[d];h===cS?u+=Ao(l[d]):h===uS?u+=Rt.transform(l[d]):u+=l[d]}return u}}const F5=t=>typeof t=="number"?0:Rt.test(t)?Rt.getAnimatableNone(t):t;function K5(t){const e=dS(t);return hS(t)(e.map(F5))}const Fs={test:$5,parse:dS,createTransformer:hS,getAnimatableNone:K5};function Tf(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 Y5({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 h=n<.5?n*(1+e):n+e-n*e,m=2*n-h;l=Tf(m,h,t+1/3),u=Tf(m,h,t),d=Tf(m,h,t-1/3)}return{red:Math.round(l*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:r}}function gu(t,e){return n=>n>0?e:t}const gt=(t,e,n)=>t+(e-t)*n,Ef=(t,e,n)=>{const r=t*t,l=n*(e*e-r)+r;return l<0?0:Math.sqrt(l)},W5=[dm,Ja,ii],X5=t=>W5.find(e=>e.test(t));function I0(t){const e=X5(t);if(!e)return!1;let n=e.parse(t);return e===ii&&(n=Y5(n)),n}const V0=(t,e)=>{const n=I0(t),r=I0(e);if(!n||!r)return gu(t,e);const l={...n};return u=>(l.red=Ef(n.red,r.red,u),l.green=Ef(n.green,r.green,u),l.blue=Ef(n.blue,r.blue,u),l.alpha=gt(n.alpha,r.alpha,u),Ja.transform(l))},hm=new Set(["none","hidden"]);function J5(t,e){return hm.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Q5(t,e){return n=>gt(t,e,n)}function op(t){return typeof t=="number"?Q5:typeof t=="string"?ap(t)?gu:Rt.test(t)?V0:tO:Array.isArray(t)?fS:typeof t=="object"?Rt.test(t)?V0:Z5:gu}function fS(t,e){const n=[...t],r=n.length,l=t.map((u,d)=>op(u)(u,e[d]));return u=>{for(let d=0;d<r;d++)n[d]=l[d](u);return n}}function Z5(t,e){const n={...t,...e},r={};for(const l in n)t[l]!==void 0&&e[l]!==void 0&&(r[l]=op(t[l])(t[l],e[l]));return l=>{for(const u in r)n[u]=r[u](l);return n}}function eO(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]],h=t.values[d]??0;n[l]=h,r[u]++}return n}const tO=(t,e)=>{const n=Fs.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?hm.has(t)&&!l.values.length||hm.has(e)&&!r.values.length?J5(t,e):al(fS(eO(r,l),l.values),n):gu(t,e)};function mS(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?gt(t,e,n):op(t)(t,e)}const sO=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>ct.update(e,n),stop:()=>ya(e),now:()=>Ft.isProcessing?Ft.timestamp:Qt.now()}},pS=(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)})`},yu=2e4;function lp(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<yu;)e+=n,r=t.next(e);return e>=yu?1/0:e}function nO(t,e=100,n){const r=n({...t,keyframes:[0,e]}),l=Math.min(lp(r),yu);return{type:"keyframes",ease:u=>r.next(l*u).value/e,duration:Ds(l)}}const aO=5;function gS(t,e,n){const r=Math.max(e-aO,0);return Y1(n-t(r),e-r)}const bt={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},Cf=.001;function rO({duration:t=bt.duration,bounce:e=bt.bounce,velocity:n=bt.velocity,mass:r=bt.mass}){let l,u,d=1-e;d=ln(bt.minDamping,bt.maxDamping,d),t=ln(bt.minDuration,bt.maxDuration,Ds(t)),d<1?(l=p=>{const y=p*d,x=y*t,w=y-n,j=fm(p,d),k=Math.exp(-x);return Cf-w/j*k},u=p=>{const x=p*d*t,w=x*n+n,j=Math.pow(d,2)*Math.pow(p,2)*t,k=Math.exp(-x),S=fm(Math.pow(p,2),d);return(-l(p)+Cf>0?-1:1)*((w-j)*k)/S}):(l=p=>{const y=Math.exp(-p*t),x=(p-n)*t+1;return-Cf+y*x},u=p=>{const y=Math.exp(-p*t),x=(n-p)*(t*t);return y*x});const h=5/t,m=oO(l,u,h);if(t=Gs(t),isNaN(m))return{stiffness:bt.stiffness,damping:bt.damping,duration:t};{const p=Math.pow(m,2)*r;return{stiffness:p,damping:d*2*Math.sqrt(r*p),duration:t}}}const iO=12;function oO(t,e,n){let r=n;for(let l=1;l<iO;l++)r=r-t(r)/e(r);return r}function fm(t,e){return t*Math.sqrt(1-e*e)}const lO=["duration","bounce"],cO=["stiffness","damping","mass"];function $0(t,e){return e.some(n=>t[n]!==void 0)}function uO(t){let e={velocity:bt.velocity,stiffness:bt.stiffness,damping:bt.damping,mass:bt.mass,isResolvedFromDuration:!1,...t};if(!$0(t,cO)&&$0(t,lO))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),l=r*r,u=2*ln(.05,1,1-(t.bounce||0))*Math.sqrt(l);e={...e,mass:bt.mass,stiffness:l,damping:u}}else{const n=rO({...t,velocity:0});e={...e,...n,mass:bt.mass},e.isResolvedFromDuration=!0}return e}function vu(t=bt.visualDuration,e=bt.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],h={done:!1,value:u},{stiffness:m,damping:p,mass:y,duration:x,velocity:w,isResolvedFromDuration:j}=uO({...n,velocity:-Ds(n.velocity||0)}),k=w||0,S=p/(2*Math.sqrt(m*y)),_=d-u,T=Ds(Math.sqrt(m/y)),C=Math.abs(_)<5;r||(r=C?bt.restSpeed.granular:bt.restSpeed.default),l||(l=C?bt.restDelta.granular:bt.restDelta.default);let A;if(S<1){const M=fm(T,S);A=P=>{const U=Math.exp(-S*T*P);return d-U*((k+S*T*_)/M*Math.sin(M*P)+_*Math.cos(M*P))}}else if(S===1)A=M=>d-Math.exp(-T*M)*(_+(k+T*_)*M);else{const M=T*Math.sqrt(S*S-1);A=P=>{const U=Math.exp(-S*T*P),R=Math.min(M*P,300);return d-U*((k+S*T*_)*Math.sinh(R)+M*_*Math.cosh(R))/M}}const E={calculatedDuration:j&&x||null,next:M=>{const P=A(M);if(j)h.done=M>=x;else{let U=M===0?k:0;S<1&&(U=M===0?Gs(k):gS(A,M,P));const R=Math.abs(U)<=r,B=Math.abs(d-P)<=l;h.done=R&&B}return h.value=h.done?d:P,h},toString:()=>{const M=Math.min(lp(E),yu),P=pS(U=>E.next(M*U).value,M,30);return M+"ms "+P},toTransition:()=>{}};return E}vu.applyToOptions=t=>{const e=nO(t,100,vu);return t.ease=e.ease,t.duration=Gs(e.duration),t.type="keyframes",t};function mm({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:l=10,bounceStiffness:u=500,modifyTarget:d,min:h,max:m,restDelta:p=.5,restSpeed:y}){const x=t[0],w={done:!1,value:x},j=R=>h!==void 0&&R<h||m!==void 0&&R>m,k=R=>h===void 0?m:m===void 0||Math.abs(h-R)<Math.abs(m-R)?h:m;let S=n*e;const _=x+S,T=d===void 0?_:d(_);T!==_&&(S=T-x);const C=R=>-S*Math.exp(-R/r),A=R=>T+C(R),E=R=>{const B=C(R),se=A(R);w.done=Math.abs(B)<=p,w.value=w.done?T:se};let M,P;const U=R=>{j(w.value)&&(M=R,P=vu({keyframes:[w.value,k(w.value)],velocity:gS(A,R,w.value),damping:l,stiffness:u,restDelta:p,restSpeed:y}))};return U(0),{calculatedDuration:null,next:R=>{let B=!1;return!P&&M===void 0&&(B=!0,E(R),U(R)),M!==void 0&&R>=M?P.next(R-M):(!B&&E(R),w)}}}function dO(t,e,n){const r=[],l=n||An.mix||mS,u=t.length-1;for(let d=0;d<u;d++){let h=l(t[d],t[d+1]);if(e){const m=Array.isArray(e)?e[d]||Ls:e;h=al(m,h)}r.push(h)}return r}function hO(t,e,{clamp:n=!0,ease:r,mixer:l}={}){const u=t.length;if(ep(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 h=dO(e,r,l),m=h.length,p=y=>{if(d&&y<t[0])return e[0];let x=0;if(m>1)for(;x<t.length-2&&!(y<t[x+1]);x++);const w=Wo(t[x],t[x+1],y);return h[x](w)};return n?y=>p(ln(t[0],t[u-1],y)):p}function fO(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const l=Wo(0,e,r);t.push(gt(n,1,l))}}function mO(t){const e=[0];return fO(e,t.length-1),e}function pO(t,e){return t.map(n=>n*e)}function gO(t,e){return t.map(()=>e||nS).splice(0,t.length-1)}function Ro({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const l=T5(r)?r.map(L0):L0(r),u={done:!1,value:e[0]},d=pO(n&&n.length===e.length?n:mO(e),t),h=hO(d,e,{ease:Array.isArray(l)?l:gO(e,l)});return{calculatedDuration:t,next:m=>(u.value=h(m),u.done=m>=t,u)}}const yO=t=>t!==null;function cp(t,{repeat:e,repeatType:n="loop"},r,l=1){const u=t.filter(yO),h=l<0||e&&n!=="loop"&&e%2===1?0:u.length-1;return!h||r===void 0?u[h]:r}const vO={decay:mm,inertia:mm,tween:Ro,keyframes:Ro,spring:vu};function yS(t){typeof t.type=="string"&&(t.type=vO[t.type])}class up{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 xO=t=>t/100;class dp extends up{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!==Qt.now()&&this.tick(Qt.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;yS(e);const{type:n=Ro,repeat:r=0,repeatDelay:l=0,repeatType:u,velocity:d=0}=e;let{keyframes:h}=e;const m=n||Ro;m!==Ro&&typeof h[0]!="number"&&(this.mixKeyframes=al(xO,mS(h[0],h[1])),h=[0,100]);const p=m({...e,keyframes:h});u==="mirror"&&(this.mirroredGenerator=m({...e,keyframes:[...h].reverse(),velocity:-d})),p.calculatedDuration===null&&(p.calculatedDuration=lp(p));const{calculatedDuration:y}=p;this.calculatedDuration=y,this.resolvedDuration=y+l,this.totalDuration=this.resolvedDuration*(r+1)-l,this.generator=p}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:h,calculatedDuration:m}=this;if(this.startTime===null)return r.next(0);const{delay:p=0,keyframes:y,repeat:x,repeatType:w,repeatDelay:j,type:k,onUpdate:S,finalKeyframe:_}=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-p*(this.playbackSpeed>=0?1:-1),C=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,E=r;if(x){const R=Math.min(this.currentTime,l)/h;let B=Math.floor(R),se=R%1;!se&&R>=1&&(se=1),se===1&&B--,B=Math.min(B,x+1),B%2&&(w==="reverse"?(se=1-se,j&&(se-=j/h)):w==="mirror"&&(E=d)),A=ln(0,1,se)*h}const M=C?{done:!1,value:y[0]}:E.next(A);u&&(M.value=u(M.value));let{done:P}=M;!C&&m!==null&&(P=this.playbackSpeed>=0?this.currentTime>=l:this.currentTime<=0);const U=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&P);return U&&k!==mm&&(M.value=cp(y,this.options,_,this.speed)),S&&S(M.value),U&&this.finish(),M}then(e,n){return this.finished.then(e,n)}get duration(){return Ds(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Ds(e)}get time(){return Ds(this.currentTime)}set time(e){e=Gs(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(Qt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=Ds(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=sO,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(Qt.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 bO(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Qa=t=>t*180/Math.PI,pm=t=>{const e=Qa(Math.atan2(t[1],t[0]));return gm(e)},wO={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:pm,rotateZ:pm,skewX:t=>Qa(Math.atan(t[1])),skewY:t=>Qa(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},gm=t=>(t=t%360,t<0&&(t+=360),t),q0=pm,H0=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),G0=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),SO={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:H0,scaleY:G0,scale:t=>(H0(t)+G0(t))/2,rotateX:t=>gm(Qa(Math.atan2(t[6],t[5]))),rotateY:t=>gm(Qa(Math.atan2(-t[2],t[0]))),rotateZ:q0,rotate:q0,skewX:t=>Qa(Math.atan(t[4])),skewY:t=>Qa(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ym(t){return t.includes("scale")?1:0}function vm(t,e){if(!t||t==="none")return ym(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,l;if(n)r=SO,l=n;else{const h=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=wO,l=h}if(!l)return ym(e);const u=r[e],d=l[1].split(",").map(_O);return typeof u=="function"?u(d):d[u]}const jO=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return vm(n,e)};function _O(t){return parseFloat(t.trim())}const Si=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ji=new Set(Si),F0=t=>t===wi||t===je,NO=new Set(["x","y","z"]),kO=Si.filter(t=>!NO.has(t));function TO(t){const e=[];return kO.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const da={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})=>vm(e,"x"),y:(t,{transform:e})=>vm(e,"y")};da.translateX=da.x;da.translateY=da.y;const tr=new Set;let xm=!1,bm=!1,wm=!1;function vS(){if(bm){const t=Array.from(tr).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const l=TO(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)})}bm=!1,xm=!1,tr.forEach(t=>t.complete(wm)),tr.clear()}function xS(){tr.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(bm=!0)})}function EO(){wm=!0,xS(),vS(),wm=!1}class hp{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?(tr.add(this),xm||(xm=!0,ct.read(xS),ct.resolveKeyframes(vS))):(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 h=r.readValue(n,d);h!=null&&(e[0]=h)}e[0]===void 0&&(e[0]=d),l&&u===void 0&&l.set(e[0])}bO(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),tr.delete(this)}cancel(){this.state==="scheduled"&&(tr.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const CO=t=>t.startsWith("--");function AO(t,e,n){CO(e)?t.style.setProperty(e,n):t.style[e]=n}const RO={};function bS(t,e){const n=K1(t);return()=>RO[e]??n()}const OO=bS(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),wS=bS(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),No=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,K0={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:No([0,.65,.55,1]),circOut:No([.55,0,1,.45]),backIn:No([.31,.01,.66,-.59]),backOut:No([.33,1.53,.69,.99])};function SS(t,e){if(t)return typeof t=="function"?wS()?pS(t,e):"ease-out":aS(t)?No(t):Array.isArray(t)?t.map(n=>SS(n,e)||K0.easeOut):K0[t]}function MO(t,e,n,{delay:r=0,duration:l=300,repeat:u=0,repeatType:d="loop",ease:h="easeOut",times:m}={},p=void 0){const y={[e]:n};m&&(y.offset=m);const x=SS(h,l);Array.isArray(x)&&(y.easing=x);const w={delay:r,duration:l,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"};return p&&(w.pseudoElement=p),t.animate(y,w)}function jS(t){return typeof t=="function"&&"applyToOptions"in t}function DO({type:t,...e}){return jS(t)&&wS()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class _S extends up{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:h,onComplete:m}=e;this.isPseudoElement=!!u,this.allowFlatten=d,this.options=e,ep(typeof e.type!="string");const p=DO(e);this.animation=MO(n,r,l,p,u),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!u){const y=cp(l,this.options,h,this.speed);this.updateMotionValue?this.updateMotionValue(y):AO(n,r,y),this.animation.cancel()}m?.(),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(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return Ds(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Ds(e)}get time(){return Ds(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Gs(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&&OO()?(this.animation.timeline=e,Ls):n(this)}}const NS={anticipate:eS,backInOut:Z1,circInOut:sS};function PO(t){return t in NS}function LO(t){typeof t.ease=="string"&&PO(t.ease)&&(t.ease=NS[t.ease])}const Af=10;class zO extends _S{constructor(e){LO(e),yS(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 h=new dp({...d,autoplay:!1}),m=Math.max(Af,Qt.now()-this.startTime),p=ln(0,Af,m-Af);n.setWithVelocity(h.sample(Math.max(0,m-p)).value,h.sample(m).value,p),h.stop()}}const Y0=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Fs.test(t)||t==="0")&&!t.startsWith("url("));function UO(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 BO(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=Y0(l,e),h=Y0(u,e);return!d||!h?!1:UO(t)||(n==="spring"||jS(n))&&r}function Sm(t){t.duration=0,t.type="keyframes"}const IO=new Set(["opacity","clipPath","filter","transform"]),VO=K1(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function $O(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:m,transformTemplate:p}=e.owner.getProps();return VO()&&n&&IO.has(n)&&(n!=="transform"||!p)&&!m&&!r&&l!=="mirror"&&u!==0&&d!=="inertia"}const qO=40;class HO extends up{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:l=0,repeatDelay:u=0,repeatType:d="loop",keyframes:h,name:m,motionValue:p,element:y,...x}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Qt.now();const w={autoplay:e,delay:n,type:r,repeat:l,repeatDelay:u,repeatType:d,name:m,motionValue:p,element:y,...x},j=y?.KeyframeResolver||hp;this.keyframeResolver=new j(h,(k,S,_)=>this.onKeyframesResolved(k,S,w,!_),m,p,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,l){this.keyframeResolver=void 0;const{name:u,type:d,velocity:h,delay:m,isHandoff:p,onUpdate:y}=r;this.resolvedAt=Qt.now(),BO(e,u,d,h)||((An.instantAnimations||!m)&&y?.(cp(e,r,n)),e[0]=e[e.length-1],Sm(r),r.repeat=0);const w={startTime:l?this.resolvedAt?this.resolvedAt-this.createdAt>qO?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},j=!p&&$O(w),k=w.motionValue?.owner?.current,S=j?new zO({...w,element:k}):new dp(w);S.finished.then(()=>{this.notifyFinished()}).catch(Ls),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}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(),EO()),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 kS(t,e,n,r=0,l=1){const u=Array.from(t).sort((p,y)=>p.sortNodePosition(y)).indexOf(e),d=t.size,h=(d-1)*r;return typeof n=="function"?n(u,d):l===1?u*r:h-u*r}const GO=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function FO(t){const e=GO.exec(t);if(!e)return[,];const[,n,r,l]=e;return[`--${n??r}`,l]}function TS(t,e,n=1){const[r,l]=FO(t);if(!r)return;const u=window.getComputedStyle(e).getPropertyValue(r);if(u){const d=u.trim();return H1(d)?parseFloat(d):d}return ap(l)?TS(l,e,n+1):l}const KO={type:"spring",stiffness:500,damping:25,restSpeed:10},YO=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),WO={type:"keyframes",duration:.8},XO={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},JO=(t,{keyframes:e})=>e.length>2?WO:ji.has(t)?t.startsWith("scale")?YO(e[1]):KO:XO,QO=t=>t!==null;function ZO(t,{repeat:e,repeatType:n="loop"},r){const l=t.filter(QO),u=e&&n!=="loop"&&e%2===1?0:l.length-1;return l[u]}function ES(t,e){if(t?.inherit&&e){const{inherit:n,...r}=t;return{...e,...r}}return t}function fp(t,e){const n=t?.[e]??t?.default??t;return n!==t?ES(n,t):n}function eM({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:l,repeat:u,repeatType:d,repeatDelay:h,from:m,elapsed:p,...y}){return!!Object.keys(y).length}const mp=(t,e,n,r={},l,u)=>d=>{const h=fp(r,t)||{},m=h.delay||r.delay||0;let{elapsed:p=0}=r;p=p-Gs(m);const y={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...h,delay:-p,onUpdate:w=>{e.set(w),h.onUpdate&&h.onUpdate(w)},onComplete:()=>{d(),h.onComplete&&h.onComplete()},name:t,motionValue:e,element:u?void 0:l};eM(h)||Object.assign(y,JO(t,y)),y.duration&&(y.duration=Gs(y.duration)),y.repeatDelay&&(y.repeatDelay=Gs(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let x=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(Sm(y),y.delay===0&&(x=!0)),(An.instantAnimations||An.skipAnimations||l?.shouldSkipAnimations)&&(x=!0,Sm(y),y.delay=0),y.allowFlatten=!h.type&&!h.ease,x&&!u&&e.get()!==void 0){const w=ZO(y.keyframes,h);if(w!==void 0){ct.update(()=>{y.onUpdate(w),y.onComplete()});return}}return h.isSync?new dp(y):new HO(y)};function W0(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function pp(t,e,n,r){if(typeof e=="function"){const[l,u]=W0(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]=W0(r);e=e(n!==void 0?n:t.custom,l,u)}return e}function fi(t,e,n){const r=t.getProps();return pp(r,e,n!==void 0?n:r.custom,t)}const CS=new Set(["width","height","top","left","right","bottom",...Si]),X0=30,tM=t=>!isNaN(parseFloat(t));class sM{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const l=Qt.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=Qt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=tM(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 tp);const r=this.events[e].add(n);return e==="change"?()=>{r(),ct.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=Qt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>X0)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,X0);return Y1(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 yi(t,e){return new sM(t,e)}const jm=t=>Array.isArray(t);function nM(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,yi(n))}function aM(t){return jm(t)?t[t.length-1]||0:t}function rM(t,e){const n=fi(t,e);let{transitionEnd:r={},transition:l={},...u}=n||{};u={...u,...r};for(const d in u){const h=aM(u[d]);nM(t,d,h)}}const Xt=t=>!!(t&&t.getVelocity);function iM(t){return!!(Xt(t)&&t.add)}function _m(t,e){const n=t.getValue("willChange");if(iM(n))return n.add(e);if(!n&&An.WillChange){const r=new An.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function gp(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const oM="framerAppearId",AS="data-"+gp(oM);function RS(t){return t.props[AS]}function lM({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function OS(t,e,{delay:n=0,transitionOverride:r,type:l}={}){let{transition:u,transitionEnd:d,...h}=e;const m=t.getDefaultTransition();u=u?ES(u,m):m;const p=u?.reduceMotion;r&&(u=r);const y=[],x=l&&t.animationState&&t.animationState.getState()[l];for(const w in h){const j=t.getValue(w,t.latestValues[w]??null),k=h[w];if(k===void 0||x&&lM(x,w))continue;const S={delay:n,...fp(u||{},w)},_=j.get();if(_!==void 0&&!j.isAnimating&&!Array.isArray(k)&&k===_&&!S.velocity)continue;let T=!1;if(window.MotionHandoffAnimation){const E=RS(t);if(E){const M=window.MotionHandoffAnimation(E,w,ct);M!==null&&(S.startTime=M,T=!0)}}_m(t,w);const C=p??t.shouldReduceMotion;j.start(mp(w,j,k,C&&CS.has(w)?{type:!1}:S,t,T));const A=j.animation;A&&y.push(A)}if(d){const w=()=>ct.update(()=>{d&&rM(t,d)});y.length?Promise.all(y).then(w):w()}return y}function Nm(t,e,n={}){const r=fi(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(OS(t,r,n)):()=>Promise.resolve(),d=t.variantChildren&&t.variantChildren.size?(m=0)=>{const{delayChildren:p=0,staggerChildren:y,staggerDirection:x}=l;return cM(t,e,m,p,y,x,n)}:()=>Promise.resolve(),{when:h}=l;if(h){const[m,p]=h==="beforeChildren"?[u,d]:[d,u];return m().then(()=>p())}else return Promise.all([u(),d(n.delay)])}function cM(t,e,n=0,r=0,l=0,u=1,d){const h=[];for(const m of t.variantChildren)m.notify("AnimationStart",e),h.push(Nm(m,e,{...d,delay:n+(typeof r=="function"?0:r)+kS(t.variantChildren,m,r,l,u)}).then(()=>m.notify("AnimationComplete",e)));return Promise.all(h)}function uM(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const l=e.map(u=>Nm(t,u,n));r=Promise.all(l)}else if(typeof e=="string")r=Nm(t,e,n);else{const l=typeof e=="function"?fi(t,e,n.custom):e;r=Promise.all(OS(t,l,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const dM={test:t=>t==="auto",parse:t=>t},MS=t=>e=>e.test(t),DS=[wi,je,on,la,I5,B5,dM],J0=t=>DS.find(MS(t));function hM(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||F1(t):!0}const fM=new Set(["brightness","contrast","saturate","opacity"]);function mM(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(rp)||[];if(!r)return t;const l=n.replace(r,"");let u=fM.has(e)?1:0;return r!==n&&(u*=100),e+"("+u+l+")"}const pM=/\b([a-z-]*)\(.*?\)/gu,km={...Fs,getAnimatableNone:t=>{const e=t.match(pM);return e?e.map(mM).join(" "):t}},Tm={...Fs,getAnimatableNone:t=>{const e=Fs.parse(t);return Fs.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},Q0={...wi,transform:Math.round},gM={rotate:la,rotateX:la,rotateY:la,rotateZ:la,scale:Hc,scaleX:Hc,scaleY:Hc,scaleZ:Hc,skew:la,skewX:la,skewY:la,distance:je,translateX:je,translateY:je,translateZ:je,x:je,y:je,z:je,perspective:je,transformPerspective:je,opacity:Xo,originX:U0,originY:U0,originZ:je},yp={borderWidth:je,borderTopWidth:je,borderRightWidth:je,borderBottomWidth:je,borderLeftWidth:je,borderRadius:je,borderTopLeftRadius:je,borderTopRightRadius:je,borderBottomRightRadius:je,borderBottomLeftRadius:je,width:je,maxWidth:je,height:je,maxHeight:je,top:je,right:je,bottom:je,left:je,inset:je,insetBlock:je,insetBlockStart:je,insetBlockEnd:je,insetInline:je,insetInlineStart:je,insetInlineEnd:je,padding:je,paddingTop:je,paddingRight:je,paddingBottom:je,paddingLeft:je,paddingBlock:je,paddingBlockStart:je,paddingBlockEnd:je,paddingInline:je,paddingInlineStart:je,paddingInlineEnd:je,margin:je,marginTop:je,marginRight:je,marginBottom:je,marginLeft:je,marginBlock:je,marginBlockStart:je,marginBlockEnd:je,marginInline:je,marginInlineStart:je,marginInlineEnd:je,fontSize:je,backgroundPositionX:je,backgroundPositionY:je,...gM,zIndex:Q0,fillOpacity:Xo,strokeOpacity:Xo,numOctaves:Q0},yM={...yp,color:Rt,backgroundColor:Rt,outlineColor:Rt,fill:Rt,stroke:Rt,borderColor:Rt,borderTopColor:Rt,borderRightColor:Rt,borderBottomColor:Rt,borderLeftColor:Rt,filter:km,WebkitFilter:km,mask:Tm,WebkitMask:Tm},PS=t=>yM[t],vM=new Set([km,Tm]);function LS(t,e){let n=PS(t);return vM.has(n)||(n=Fs),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const xM=new Set(["auto","none","0"]);function bM(t,e,n){let r=0,l;for(;r<t.length&&!l;){const u=t[r];typeof u=="string"&&!xM.has(u)&&Jo(u).values.length&&(l=t[r]),r++}if(l&&n)for(const u of e)t[u]=LS(n,l)}class wM extends hp{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 x=e[y];if(typeof x=="string"&&(x=x.trim(),ap(x))){const w=TS(x,n.current);w!==void 0&&(e[y]=w),y===e.length-1&&(this.finalKeyframe=x)}}if(this.resolveNoneKeyframes(),!CS.has(r)||e.length!==2)return;const[l,u]=e,d=J0(l),h=J0(u),m=z0(l),p=z0(u);if(m!==p&&da[r]){this.needsMeasurement=!0;return}if(d!==h)if(F0(d)&&F0(h))for(let y=0;y<e.length;y++){const x=e[y];typeof x=="string"&&(e[y]=parseFloat(x))}else da[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let l=0;l<e.length;l++)(e[l]===null||hM(e[l]))&&r.push(l);r.length&&bM(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=da[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]=da[n](e.measureViewportBox(),window.getComputedStyle(e.current)),d!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=d),this.removedTransforms?.length&&this.removedTransforms.forEach(([h,m])=>{e.getValue(h).set(m)}),this.resolveNoneKeyframes()}}const SM=new Set(["opacity","clipPath","filter","transform"]);function zS(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 US=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Em(t){return G1(t)&&"offsetHeight"in t}const{schedule:vp}=rS(queueMicrotask,!1),$s={x:!1,y:!1};function BS(){return $s.x||$s.y}function jM(t){return t==="x"||t==="y"?$s[t]?null:($s[t]=!0,()=>{$s[t]=!1}):$s.x||$s.y?null:($s.x=$s.y=!0,()=>{$s.x=$s.y=!1})}function IS(t,e){const n=zS(t),r=new AbortController,l={passive:!0,...e,signal:r.signal};return[n,l,()=>r.abort()]}function _M(t){return!(t.pointerType==="touch"||BS())}function NM(t,e,n={}){const[r,l,u]=IS(t,n);return r.forEach(d=>{let h=!1,m=!1,p;const y=()=>{d.removeEventListener("pointerleave",k)},x=_=>{p&&(p(_),p=void 0),y()},w=_=>{h=!1,window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),m&&(m=!1,x(_))},j=()=>{h=!0,window.addEventListener("pointerup",w,l),window.addEventListener("pointercancel",w,l)},k=_=>{if(_.pointerType!=="touch"){if(h){m=!0;return}x(_)}},S=_=>{if(!_M(_))return;m=!1;const T=e(d,_);typeof T=="function"&&(p=T,d.addEventListener("pointerleave",k,l))};d.addEventListener("pointerenter",S,l),d.addEventListener("pointerdown",j,l)}),u}const VS=(t,e)=>e?t===e?!0:VS(t,e.parentElement):!1,xp=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,kM=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function TM(t){return kM.has(t.tagName)||t.isContentEditable===!0}const EM=new Set(["INPUT","SELECT","TEXTAREA"]);function CM(t){return EM.has(t.tagName)||t.isContentEditable===!0}const Qc=new WeakSet;function Z0(t){return e=>{e.key==="Enter"&&t(e)}}function Rf(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const AM=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=Z0(()=>{if(Qc.has(n))return;Rf(n,"down");const l=Z0(()=>{Rf(n,"up")}),u=()=>Rf(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 eb(t){return xp(t)&&!BS()}const tb=new WeakSet;function RM(t,e,n={}){const[r,l,u]=IS(t,n),d=h=>{const m=h.currentTarget;if(!eb(h)||tb.has(h))return;Qc.add(m),n.stopPropagation&&tb.add(h);const p=e(m,h),y=(j,k)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",w),Qc.has(m)&&Qc.delete(m),eb(j)&&typeof p=="function"&&p(j,{success:k})},x=j=>{y(j,m===window||m===document||n.useGlobalTarget||VS(m,j.target))},w=j=>{y(j,!1)};window.addEventListener("pointerup",x,l),window.addEventListener("pointercancel",w,l)};return r.forEach(h=>{(n.useGlobalTarget?window:h).addEventListener("pointerdown",d,l),Em(h)&&(h.addEventListener("focus",p=>AM(p,l)),!TM(h)&&!h.hasAttribute("tabindex")&&(h.tabIndex=0))}),u}function bp(t){return G1(t)&&"ownerSVGElement"in t}const Zc=new WeakMap;let eu;const $S=(t,e,n)=>(r,l)=>l&&l[0]?l[0][t+"Size"]:bp(r)&&"getBBox"in r?r.getBBox()[e]:r[n],OM=$S("inline","width","offsetWidth"),MM=$S("block","height","offsetHeight");function DM({target:t,borderBoxSize:e}){Zc.get(t)?.forEach(n=>{n(t,{get width(){return OM(t,e)},get height(){return MM(t,e)}})})}function PM(t){t.forEach(DM)}function LM(){typeof ResizeObserver>"u"||(eu=new ResizeObserver(PM))}function zM(t,e){eu||LM();const n=zS(t);return n.forEach(r=>{let l=Zc.get(r);l||(l=new Set,Zc.set(r,l)),l.add(e),eu?.observe(r)}),()=>{n.forEach(r=>{const l=Zc.get(r);l?.delete(e),l?.size||eu?.unobserve(r)})}}const tu=new Set;let oi;function UM(){oi=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};tu.forEach(e=>e(t))},window.addEventListener("resize",oi)}function BM(t){return tu.add(t),oi||UM(),()=>{tu.delete(t),!tu.size&&typeof oi=="function"&&(window.removeEventListener("resize",oi),oi=void 0)}}function sb(t,e){return typeof t=="function"?BM(t):zM(t,e)}function IM(t){return bp(t)&&t.tagName==="svg"}const VM=[...DS,Rt,Fs],$M=t=>VM.find(MS(t)),nb=()=>({translate:0,scale:1,origin:0,originPoint:0}),li=()=>({x:nb(),y:nb()}),ab=()=>({min:0,max:0}),Pt=()=>({x:ab(),y:ab()}),qM=new WeakMap;function Lu(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qo(t){return typeof t=="string"||Array.isArray(t)}const wp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Sp=["initial",...wp];function zu(t){return Lu(t.animate)||Sp.some(e=>Qo(t[e]))}function qS(t){return!!(zu(t)||t.variants)}function HM(t,e,n){for(const r in e){const l=e[r],u=n[r];if(Xt(l))t.addValue(r,l);else if(Xt(u))t.addValue(r,yi(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,yi(d!==void 0?d:l,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const Cm={current:null},HS={current:!1},GM=typeof window<"u";function FM(){if(HS.current=!0,!!GM)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Cm.current=t.matches;t.addEventListener("change",e),e()}else Cm.current=!1}const rb=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let xu={};function GS(t){xu=t}function KM(){return xu}class YM{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:l,skipAnimations:u,blockInitialAnimation:d,visualState:h},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=hp,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,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 j=Qt.now();this.renderScheduledAt<j&&(this.renderScheduledAt=j,ct.render(this.render,!1,!0))};const{latestValues:p,renderState:y}=h;this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=y,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=l,this.skipAnimationsConfig=u,this.options=m,this.blockInitialAnimation=!!d,this.isControllingVariants=zu(n),this.isVariantNode=qS(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:x,...w}=this.scrapeMotionValuesFromProps(n,{},this);for(const j in w){const k=w[j];p[j]!==void 0&&Xt(k)&&k.set(p[j])}}mount(e){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=e,qM.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:(HS.current||FM(),this.shouldReduceMotion=Cm.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),ya(this.notifyUpdate),ya(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){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&SM.has(e)&&this.current instanceof HTMLElement){const{factory:d,keyframes:h,times:m,ease:p,duration:y}=n.accelerate,x=new _S({element:this.current,name:e,keyframes:h,times:m,ease:p,duration:Gs(y)}),w=d(x);this.valueSubscriptions.set(e,()=>{w(),x.cancel()});return}const r=ji.has(e);r&&this.onBindTransform&&this.onBindTransform();const l=n.on("change",d=>{this.latestValues[e]=d,this.props.onUpdate&&ct.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 xu){const n=xu[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):Pt()}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<rb.length;r++){const l=rb[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=HM(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=yi(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"&&(H1(r)||F1(r))?r=parseFloat(r):!$M(r)&&Fs.test(n)&&(r=LS(e,n)),this.setBaseTarget(e,Xt(r)?r.get():r)),Xt(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=pp(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&&!Xt(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 tp),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){vp.render(this.render)}}class FS extends YM{constructor(){super(...arguments),this.KeyframeResolver=wM}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;Xt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class ba{constructor(e){this.isMounted=!1,this.node=e}update(){}}function KS({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function WM({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function XM(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 Of(t){return t===void 0||t===1}function Am({scale:t,scaleX:e,scaleY:n}){return!Of(t)||!Of(e)||!Of(n)}function Fa(t){return Am(t)||YS(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function YS(t){return ib(t.x)||ib(t.y)}function ib(t){return t&&t!=="0%"}function bu(t,e,n){const r=t-n,l=e*r;return n+l}function ob(t,e,n,r,l){return l!==void 0&&(t=bu(t,l,r)),bu(t,n,r)+e}function Rm(t,e=0,n=1,r,l){t.min=ob(t.min,e,n,r,l),t.max=ob(t.max,e,n,r,l)}function WS(t,{x:e,y:n}){Rm(t.x,e.translate,e.scale,e.originPoint),Rm(t.y,n.translate,n.scale,n.originPoint)}const lb=.999999999999,cb=1.0000000000001;function JM(t,e,n,r=!1){const l=n.length;if(!l)return;e.x=e.y=1;let u,d;for(let h=0;h<l;h++){u=n[h],d=u.projectionDelta;const{visualElement:m}=u.options;m&&m.props.style&&m.props.style.display==="contents"||(r&&u.options.layoutScroll&&u.scroll&&u!==u.root&&ui(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(e.x*=d.x.scale,e.y*=d.y.scale,WS(t,d)),r&&Fa(u.latestValues)&&ui(t,u.latestValues))}e.x<cb&&e.x>lb&&(e.x=1),e.y<cb&&e.y>lb&&(e.y=1)}function ci(t,e){t.min=t.min+e,t.max=t.max+e}function ub(t,e,n,r,l=.5){const u=gt(t.min,t.max,l);Rm(t,e,n,u,r)}function ui(t,e){ub(t.x,e.x,e.scaleX,e.scale,e.originX),ub(t.y,e.y,e.scaleY,e.scale,e.originY)}function XS(t,e){return KS(XM(t.getBoundingClientRect(),e))}function QM(t,e,n){const r=XS(t,n),{scroll:l}=e;return l&&(ci(r.x,l.offset.x),ci(r.y,l.offset.y)),r}const ZM={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},e3=Si.length;function t3(t,e,n){let r="",l=!0;for(let u=0;u<e3;u++){const d=Si[u],h=t[d];if(h===void 0)continue;let m=!0;if(typeof h=="number")m=h===(d.startsWith("scale")?1:0);else{const p=parseFloat(h);m=d.startsWith("scale")?p===1:p===0}if(!m||n){const p=US(h,yp[d]);if(!m){l=!1;const y=ZM[d]||d;r+=`${y}(${p}) `}n&&(e[d]=p)}}return r=r.trim(),n?r=n(e,l?"":r):l&&(r="none"),r}function jp(t,e,n){const{style:r,vars:l,transformOrigin:u}=t;let d=!1,h=!1;for(const m in e){const p=e[m];if(ji.has(m)){d=!0;continue}else if(oS(m)){l[m]=p;continue}else{const y=US(p,yp[m]);m.startsWith("origin")?(h=!0,u[m]=y):r[m]=y}}if(e.transform||(d||n?r.transform=t3(e,t.transform,n):r.transform&&(r.transform="none")),h){const{originX:m="50%",originY:p="50%",originZ:y=0}=u;r.transformOrigin=`${m} ${p} ${y}`}}function JS(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 db(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const jo={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(je.test(t))t=parseFloat(t);else return t;const n=db(t,e.target.x),r=db(t,e.target.y);return`${n}% ${r}%`}},s3={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,l=Fs.parse(t);if(l.length>5)return r;const u=Fs.createTransformer(t),d=typeof l[0]!="number"?1:0,h=n.x.scale*e.x,m=n.y.scale*e.y;l[0+d]/=h,l[1+d]/=m;const p=gt(h,m,.5);return typeof l[2+d]=="number"&&(l[2+d]/=p),typeof l[3+d]=="number"&&(l[3+d]/=p),u(l)}},Om={borderRadius:{...jo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:jo,borderTopRightRadius:jo,borderBottomLeftRadius:jo,borderBottomRightRadius:jo,boxShadow:s3};function QS(t,{layout:e,layoutId:n}){return ji.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Om[t]||t==="opacity")}function _p(t,e,n){const r=t.style,l=e?.style,u={};if(!r)return u;for(const d in r)(Xt(r[d])||l&&Xt(l[d])||QS(d,t)||n?.getValue(d)?.liveStyle!==void 0)&&(u[d]=r[d]);return u}function n3(t){return window.getComputedStyle(t)}class a3 extends FS{constructor(){super(...arguments),this.type="html",this.renderInstance=JS}readValueFromInstance(e,n){if(ji.has(n))return this.projection?.isProjecting?ym(n):jO(e,n);{const r=n3(e),l=(oS(n)?r.getPropertyValue(n):r[n])||0;return typeof l=="string"?l.trim():l}}measureInstanceViewportBox(e,{transformPagePoint:n}){return XS(e,n)}build(e,n,r){jp(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return _p(e,n,r)}}const r3={offset:"stroke-dashoffset",array:"stroke-dasharray"},i3={offset:"strokeDashoffset",array:"strokeDasharray"};function o3(t,e,n=1,r=0,l=!0){t.pathLength=1;const u=l?r3:i3;t[u.offset]=`${-r}`,t[u.array]=`${e} ${n}`}const l3=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function ZS(t,{attrX:e,attrY:n,attrScale:r,pathLength:l,pathSpacing:u=1,pathOffset:d=0,...h},m,p,y){if(jp(t,h,p),m){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:x,style:w}=t;x.transform&&(w.transform=x.transform,delete x.transform),(w.transform||x.transformOrigin)&&(w.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),w.transform&&(w.transformBox=y?.transformBox??"fill-box",delete x.transformBox);for(const j of l3)x[j]!==void 0&&(w[j]=x[j],delete x[j]);e!==void 0&&(x.x=e),n!==void 0&&(x.y=n),r!==void 0&&(x.scale=r),l!==void 0&&o3(x,l,u,d,!1)}const ej=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"]),tj=t=>typeof t=="string"&&t.toLowerCase()==="svg";function c3(t,e,n,r){JS(t,e,void 0,r);for(const l in e.attrs)t.setAttribute(ej.has(l)?l:gp(l),e.attrs[l])}function sj(t,e,n){const r=_p(t,e,n);for(const l in t)if(Xt(t[l])||Xt(e[l])){const u=Si.indexOf(l)!==-1?"attr"+l.charAt(0).toUpperCase()+l.substring(1):l;r[u]=t[l]}return r}class u3 extends FS{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Pt}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ji.has(n)){const r=PS(n);return r&&r.default||0}return n=ej.has(n)?n:gp(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return sj(e,n,r)}build(e,n,r){ZS(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,l){c3(e,n,r,l)}mount(e){this.isSVGTag=tj(e.tagName),super.mount(e)}}const d3=Sp.length;function nj(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?nj(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<d3;n++){const r=Sp[n],l=t.props[r];(Qo(l)||l===!1)&&(e[r]=l)}return e}function aj(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 h3=[...wp].reverse(),f3=wp.length;function m3(t){return e=>Promise.all(e.map(({animation:n,options:r})=>uM(t,n,r)))}function p3(t){let e=m3(t),n=hb(),r=!0;const l=m=>(p,y)=>{const x=fi(t,y,m==="exit"?t.presenceContext?.custom:void 0);if(x){const{transition:w,transitionEnd:j,...k}=x;p={...p,...k,...j}}return p};function u(m){e=m(t)}function d(m){const{props:p}=t,y=nj(t.parent)||{},x=[],w=new Set;let j={},k=1/0;for(let _=0;_<f3;_++){const T=h3[_],C=n[T],A=p[T]!==void 0?p[T]:y[T],E=Qo(A),M=T===m?C.isActive:null;M===!1&&(k=_);let P=A===y[T]&&A!==p[T]&&E;if(P&&r&&t.manuallyAnimateOnMount&&(P=!1),C.protectedKeys={...j},!C.isActive&&M===null||!A&&!C.prevProp||Lu(A)||typeof A=="boolean")continue;if(T==="exit"&&C.isActive&&M!==!0){C.prevResolvedValues&&(j={...j,...C.prevResolvedValues});continue}const U=g3(C.prevProp,A);let R=U||T===m&&C.isActive&&!P&&E||_>k&&E,B=!1;const se=Array.isArray(A)?A:[A];let re=se.reduce(l(T),{});M===!1&&(re={});const{prevResolvedValues:ue={}}=C,xe={...ue,...re},ge=F=>{R=!0,w.has(F)&&(B=!0,w.delete(F)),C.needsAnimating[F]=!0;const Z=t.getValue(F);Z&&(Z.liveStyle=!1)};for(const F in xe){const Z=re[F],ye=ue[F];if(j.hasOwnProperty(F))continue;let ne=!1;jm(Z)&&jm(ye)?ne=!aj(Z,ye):ne=Z!==ye,ne?Z!=null?ge(F):w.add(F):Z!==void 0&&w.has(F)?ge(F):C.protectedKeys[F]=!0}C.prevProp=A,C.prevResolvedValues=re,C.isActive&&(j={...j,...re}),r&&t.blockInitialAnimation&&(R=!1);const X=P&&U;R&&(!X||B)&&x.push(...se.map(F=>{const Z={type:T};if(typeof F=="string"&&r&&!X&&t.manuallyAnimateOnMount&&t.parent){const{parent:ye}=t,ne=fi(ye,F);if(ye.enteringChildren&&ne){const{delayChildren:D}=ne.transition||{};Z.delay=kS(ye.enteringChildren,t,D)}}return{animation:F,options:Z}}))}if(w.size){const _={};if(typeof p.initial!="boolean"){const T=fi(t,Array.isArray(p.initial)?p.initial[0]:p.initial);T&&T.transition&&(_.transition=T.transition)}w.forEach(T=>{const C=t.getBaseTarget(T),A=t.getValue(T);A&&(A.liveStyle=!0),_[T]=C??null}),x.push({animation:_})}let S=!!x.length;return r&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(S=!1),r=!1,S?e(x):Promise.resolve()}function h(m,p){if(n[m].isActive===p)return Promise.resolve();t.variantChildren?.forEach(x=>x.animationState?.setActive(m,p)),n[m].isActive=p;const y=d(m);for(const x in n)n[x].protectedKeys={};return y}return{animateChanges:d,setActive:h,setAnimateFunction:u,getState:()=>n,reset:()=>{n=hb()}}}function g3(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!aj(e,t):!1}function $a(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function hb(){return{animate:$a(!0),whileInView:$a(),whileHover:$a(),whileTap:$a(),whileDrag:$a(),whileFocus:$a(),exit:$a()}}function fb(t,e){t.min=e.min,t.max=e.max}function Is(t,e){fb(t.x,e.x),fb(t.y,e.y)}function mb(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const rj=1e-4,y3=1-rj,v3=1+rj,ij=.01,x3=0-ij,b3=0+ij;function Zt(t){return t.max-t.min}function w3(t,e,n){return Math.abs(t-e)<=n}function pb(t,e,n,r=.5){t.origin=r,t.originPoint=gt(e.min,e.max,t.origin),t.scale=Zt(n)/Zt(e),t.translate=gt(n.min,n.max,t.origin)-t.originPoint,(t.scale>=y3&&t.scale<=v3||isNaN(t.scale))&&(t.scale=1),(t.translate>=x3&&t.translate<=b3||isNaN(t.translate))&&(t.translate=0)}function Oo(t,e,n,r){pb(t.x,e.x,n.x,r?r.originX:void 0),pb(t.y,e.y,n.y,r?r.originY:void 0)}function gb(t,e,n){t.min=n.min+e.min,t.max=t.min+Zt(e)}function S3(t,e,n){gb(t.x,e.x,n.x),gb(t.y,e.y,n.y)}function yb(t,e,n){t.min=e.min-n.min,t.max=t.min+Zt(e)}function wu(t,e,n){yb(t.x,e.x,n.x),yb(t.y,e.y,n.y)}function vb(t,e,n,r,l){return t-=e,t=bu(t,1/n,r),l!==void 0&&(t=bu(t,1/l,r)),t}function j3(t,e=0,n=1,r=.5,l,u=t,d=t){if(on.test(e)&&(e=parseFloat(e),e=gt(d.min,d.max,e/100)-d.min),typeof e!="number")return;let h=gt(u.min,u.max,r);t===u&&(h-=e),t.min=vb(t.min,e,n,h,l),t.max=vb(t.max,e,n,h,l)}function xb(t,e,[n,r,l],u,d){j3(t,e[n],e[r],e[l],e.scale,u,d)}const _3=["x","scaleX","originX"],N3=["y","scaleY","originY"];function bb(t,e,n,r){xb(t.x,e,_3,n?n.x:void 0,r?r.x:void 0),xb(t.y,e,N3,n?n.y:void 0,r?r.y:void 0)}function wb(t){return t.translate===0&&t.scale===1}function oj(t){return wb(t.x)&&wb(t.y)}function Sb(t,e){return t.min===e.min&&t.max===e.max}function k3(t,e){return Sb(t.x,e.x)&&Sb(t.y,e.y)}function jb(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function lj(t,e){return jb(t.x,e.x)&&jb(t.y,e.y)}function _b(t){return Zt(t.x)/Zt(t.y)}function Nb(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function tn(t){return[t("x"),t("y")]}function T3(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:p,rotate:y,rotateX:x,rotateY:w,skewX:j,skewY:k}=n;p&&(r=`perspective(${p}px) ${r}`),y&&(r+=`rotate(${y}deg) `),x&&(r+=`rotateX(${x}deg) `),w&&(r+=`rotateY(${w}deg) `),j&&(r+=`skewX(${j}deg) `),k&&(r+=`skewY(${k}deg) `)}const h=t.x.scale*e.x,m=t.y.scale*e.y;return(h!==1||m!==1)&&(r+=`scale(${h}, ${m})`),r||"none"}const cj=["TopLeft","TopRight","BottomLeft","BottomRight"],E3=cj.length,kb=t=>typeof t=="string"?parseFloat(t):t,Tb=t=>typeof t=="number"||je.test(t);function C3(t,e,n,r,l,u){l?(t.opacity=gt(0,n.opacity??1,A3(r)),t.opacityExit=gt(e.opacity??1,0,R3(r))):u&&(t.opacity=gt(e.opacity??1,n.opacity??1,r));for(let d=0;d<E3;d++){const h=`border${cj[d]}Radius`;let m=Eb(e,h),p=Eb(n,h);if(m===void 0&&p===void 0)continue;m||(m=0),p||(p=0),m===0||p===0||Tb(m)===Tb(p)?(t[h]=Math.max(gt(kb(m),kb(p),r),0),(on.test(p)||on.test(m))&&(t[h]+="%")):t[h]=p}(e.rotate||n.rotate)&&(t.rotate=gt(e.rotate||0,n.rotate||0,r))}function Eb(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const A3=uj(0,.5,tS),R3=uj(.5,.95,Ls);function uj(t,e,n){return r=>r<t?0:r>e?1:n(Wo(t,e,r))}function O3(t,e,n){const r=Xt(t)?t:yi(t);return r.start(mp("",r,e,n)),r.animation}function Zo(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const M3=(t,e)=>t.depth-e.depth;class D3{constructor(){this.children=[],this.isDirty=!1}add(e){Zm(this.children,e),this.isDirty=!0}remove(e){pu(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(M3),this.isDirty=!1,this.children.forEach(e)}}function P3(t,e){const n=Qt.now(),r=({timestamp:l})=>{const u=l-n;u>=e&&(ya(r),t(u-e))};return ct.setup(r,!0),()=>ya(r)}function su(t){return Xt(t)?t.get():t}class L3{constructor(){this.members=[]}add(e){Zm(this.members,e);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===e||r===this.lead||r===this.prevLead)continue;const l=r.instance;l&&l.isConnected===!1&&r.isPresent!==!1&&!r.snapshot&&pu(this.members,r)}e.scheduleRender()}remove(e){if(pu(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],d=u.instance;if(u.isPresent!==!1&&(!d||d.isConnected!==!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;if(!(l!==void 0&&u!==void 0&&l===u)){const m=r.instance;m&&m.isConnected===!1&&!r.snapshot||(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:h}=e.options;h===!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 nu={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Mf=["","X","Y","Z"],z3=1e3;let U3=0;function Df(t,e,n,r){const{latestValues:l}=e;l[t]&&(n[t]=l[t],e.setStaticValue(t,0),r&&(r[t]=0))}function dj(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=RS(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:l,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",ct,!(l||u))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&dj(r)}function hj({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:l}){return class{constructor(d={},h=e?.()){this.id=U3++,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(V3),this.nodes.forEach(G3),this.nodes.forEach(F3),this.nodes.forEach($3)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=h?h.root||h:this,this.path=h?[...h.path,h]:[],this.parent=h,this.depth=h?h.depth+1:0;for(let m=0;m<this.path.length;m++)this.path[m].shouldResetTransform=!0;this.root===this&&(this.nodes=new D3)}addEventListener(d,h){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new tp),this.eventHandlers.get(d).add(h)}notifyListeners(d,...h){const m=this.eventHandlers.get(d);m&&m.notify(...h)}hasListeners(d){return this.eventHandlers.has(d)}mount(d){if(this.instance)return;this.isSVG=bp(d)&&!IM(d),this.instance=d;const{layoutId:h,layout:m,visualElement:p}=this.options;if(p&&!p.current&&p.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(m||h)&&(this.isLayoutDirty=!0),t){let y,x=0;const w=()=>this.root.updateBlockedByResize=!1;ct.read(()=>{x=window.innerWidth}),t(d,()=>{const j=window.innerWidth;j!==x&&(x=j,this.root.updateBlockedByResize=!0,y&&y(),y=P3(w,250),nu.hasAnimatedSinceResize&&(nu.hasAnimatedSinceResize=!1,this.nodes.forEach(Rb)))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&p&&(h||m)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:x,hasRelativeLayoutChanged:w,layout:j})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const k=this.options.transition||p.getDefaultTransition()||J3,{onLayoutAnimationStart:S,onLayoutAnimationComplete:_}=p.getProps(),T=!this.targetLayout||!lj(this.targetLayout,j),C=!x&&w;if(this.options.layoutRoot||this.resumeFrom||C||x&&(T||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...fp(k,"layout"),onPlay:S,onComplete:_};(p.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(y,C)}else x||Rb(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=j})}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(),ya(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(K3),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&&dj(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y<this.path.length;y++){const x=this.path[y];x.shouldResetTransform=!0,x.updateScroll("snapshot"),x.options.layoutRoot&&x.willUpdate(!1)}const{layoutId:h,layout:m}=this.options;if(h===void 0&&!m)return;const p=this.getTransformTemplate();this.prevTransformTemplateValue=p?p(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Cb);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ab);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(H3),this.nodes.forEach(B3),this.nodes.forEach(I3)):this.nodes.forEach(Ab),this.clearAllSnapshots();const h=Qt.now();Ft.delta=ln(0,1e3/60,h-Ft.timestamp),Ft.timestamp=h,Ft.isProcessing=!0,Nf.update.process(Ft),Nf.preRender.process(Ft),Nf.render.process(Ft),Ft.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(q3),this.sharedNodes.forEach(Y3)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ct.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ct.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Zt(this.snapshot.measuredBox.x)&&!Zt(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 m=0;m<this.path.length;m++)this.path[m].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Pt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:h}=this.options;h&&h.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let h=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(h=!1),h&&this.instance){const m=r(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:m,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:m}}}resetTransform(){if(!l)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,h=this.projectionDelta&&!oj(this.projectionDelta),m=this.getTransformTemplate(),p=m?m(this.latestValues,""):void 0,y=p!==this.prevTransformTemplateValue;d&&this.instance&&(h||Fa(this.latestValues)||y)&&(l(this.instance,p),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const h=this.measurePageBox();let m=this.removeElementScroll(h);return d&&(m=this.removeTransform(m)),Q3(m),{animationId:this.root.animationId,measuredBox:h,layoutBox:m,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:d}=this.options;if(!d)return Pt();const h=d.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Z3))){const{scroll:p}=this.root;p&&(ci(h.x,p.offset.x),ci(h.y,p.offset.y))}return h}removeElementScroll(d){const h=Pt();if(Is(h,d),this.scroll?.wasRoot)return h;for(let m=0;m<this.path.length;m++){const p=this.path[m],{scroll:y,options:x}=p;p!==this.root&&y&&x.layoutScroll&&(y.wasRoot&&Is(h,d),ci(h.x,y.offset.x),ci(h.y,y.offset.y))}return h}applyTransform(d,h=!1){const m=Pt();Is(m,d);for(let p=0;p<this.path.length;p++){const y=this.path[p];!h&&y.options.layoutScroll&&y.scroll&&y!==y.root&&ui(m,{x:-y.scroll.offset.x,y:-y.scroll.offset.y}),Fa(y.latestValues)&&ui(m,y.latestValues)}return Fa(this.latestValues)&&ui(m,this.latestValues),m}removeTransform(d){const h=Pt();Is(h,d);for(let m=0;m<this.path.length;m++){const p=this.path[m];if(!p.instance||!Fa(p.latestValues))continue;Am(p.latestValues)&&p.updateSnapshot();const y=Pt(),x=p.measurePageBox();Is(y,x),bb(h,p.latestValues,p.snapshot?p.snapshot.layoutBox:void 0,y)}return Fa(this.latestValues)&&bb(h,this.latestValues),h}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!==Ft.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const m=!!this.resumingFrom||this!==h;if(!(d||m&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:y,layoutId:x}=this.options;if(!this.layout||!(y||x))return;this.resolvedRelativeTargetAt=Ft.timestamp;const w=this.getClosestProjectingParent();w&&this.linkedParentVersion!==w.layoutVersion&&!w.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(w&&w.layout?this.createRelativeTarget(w,this.layout.layoutBox,w.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Pt(),this.targetWithTransforms=Pt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),S3(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Is(this.target,this.layout.layoutBox),WS(this.target,this.targetDelta)):Is(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,w&&!!w.resumingFrom==!!this.resumingFrom&&!w.options.layoutScroll&&w.target&&this.animationProgress!==1?this.createRelativeTarget(w,this.target,w.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Am(this.parent.latestValues)||YS(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,h,m){this.relativeParent=d,this.linkedParentVersion=d.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Pt(),this.relativeTargetOrigin=Pt(),wu(this.relativeTargetOrigin,h,m),Is(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const d=this.getLead(),h=!!this.resumingFrom||this!==d;let m=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(m=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(m=!1),this.resolvedRelativeTargetAt===Ft.timestamp&&(m=!1),m)return;const{layout:p,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||!(p||y))return;Is(this.layoutCorrected,this.layout.layoutBox);const x=this.treeScale.x,w=this.treeScale.y;JM(this.layoutCorrected,this.treeScale,this.path,h),d.layout&&!d.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(d.target=d.layout.layoutBox,d.targetWithTransforms=Pt());const{target:j}=d;if(!j){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(mb(this.prevProjectionDelta.x,this.projectionDelta.x),mb(this.prevProjectionDelta.y,this.projectionDelta.y)),Oo(this.projectionDelta,this.layoutCorrected,j,this.latestValues),(this.treeScale.x!==x||this.treeScale.y!==w||!Nb(this.projectionDelta.x,this.prevProjectionDelta.x)||!Nb(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",j))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){if(this.options.visualElement?.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=li(),this.projectionDelta=li(),this.projectionDeltaWithTransform=li()}setAnimationOrigin(d,h=!1){const m=this.snapshot,p=m?m.latestValues:{},y={...this.latestValues},x=li();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!h;const w=Pt(),j=m?m.source:void 0,k=this.layout?this.layout.source:void 0,S=j!==k,_=this.getStack(),T=!_||_.members.length<=1,C=!!(S&&!T&&this.options.crossfade===!0&&!this.path.some(X3));this.animationProgress=0;let A;this.mixTargetDelta=E=>{const M=E/1e3;Ob(x.x,d.x,M),Ob(x.y,d.y,M),this.setTargetDelta(x),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wu(w,this.layout.layoutBox,this.relativeParent.layout.layoutBox),W3(this.relativeTarget,this.relativeTargetOrigin,w,M),A&&k3(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Pt()),Is(A,this.relativeTarget)),S&&(this.animationValues=y,C3(y,p,this.latestValues,M,C,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=M},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(ya(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ct.update(()=>{nu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=yi(0)),this.motionValue.jump(0,!1),this.currentAnimation=O3(this.motionValue,[0,1e3],{...d,velocity:0,isSync:!0,onUpdate:h=>{this.mixTargetDelta(h),d.onUpdate&&d.onUpdate(h)},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(z3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:h,target:m,layout:p,latestValues:y}=d;if(!(!h||!m||!p)){if(this!==d&&this.layout&&p&&fj(this.options.animationType,this.layout.layoutBox,p.layoutBox)){m=this.target||Pt();const x=Zt(this.layout.layoutBox.x);m.x.min=d.target.x.min,m.x.max=m.x.min+x;const w=Zt(this.layout.layoutBox.y);m.y.min=d.target.y.min,m.y.max=m.y.min+w}Is(h,m),ui(h,y),Oo(this.projectionDeltaWithTransform,this.layoutCorrected,h,y)}}registerSharedNode(d,h){this.sharedNodes.has(d)||this.sharedNodes.set(d,new L3),this.sharedNodes.get(d).add(h);const p=h.options.initialPromotionConfig;h.promote({transition:p?p.transition:void 0,preserveFollowOpacity:p&&p.shouldPreserveFollowOpacity?p.shouldPreserveFollowOpacity(h):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:h,preserveFollowOpacity:m}={}){const p=this.getStack();p&&p.promote(this,m),d&&(this.projectionDelta=void 0,this.needsReset=!0),h&&this.setOptions({transition:h})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let h=!1;const{latestValues:m}=d;if((m.z||m.rotate||m.rotateX||m.rotateY||m.rotateZ||m.skewX||m.skewY)&&(h=!0),!h)return;const p={};m.z&&Df("z",d,p,this.animationValues);for(let y=0;y<Mf.length;y++)Df(`rotate${Mf[y]}`,d,p,this.animationValues),Df(`skew${Mf[y]}`,d,p,this.animationValues);d.render();for(const y in p)d.setStaticValue(y,p[y]),this.animationValues&&(this.animationValues[y]=p[y]);d.scheduleRender()}applyProjectionStyles(d,h){if(!this.instance||this.isSVG)return;if(!this.isVisible){d.visibility="hidden";return}const m=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,d.visibility="",d.opacity="",d.pointerEvents=su(h?.pointerEvents)||"",d.transform=m?m(this.latestValues,""):"none";return}const p=this.getLead();if(!this.projectionDelta||!this.layout||!p.target){this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=su(h?.pointerEvents)||""),this.hasProjected&&!Fa(this.latestValues)&&(d.transform=m?m({},""):"none",this.hasProjected=!1);return}d.visibility="";const y=p.animationValues||p.latestValues;this.applyTransformsToTarget();let x=T3(this.projectionDeltaWithTransform,this.treeScale,y);m&&(x=m(y,x)),d.transform=x;const{x:w,y:j}=this.projectionDelta;d.transformOrigin=`${w.origin*100}% ${j.origin*100}% 0`,p.animationValues?d.opacity=p===this?y.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:d.opacity=p===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const k in Om){if(y[k]===void 0)continue;const{correct:S,applyTo:_,isCSSVariable:T}=Om[k],C=x==="none"?y[k]:S(y[k],p);if(_){const A=_.length;for(let E=0;E<A;E++)d[_[E]]=C}else T?this.options.visualElement.renderState.vars[k]=C:d[k]=C}this.options.layoutId&&(d.pointerEvents=p===this?su(h?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>d.currentAnimation?.stop()),this.root.nodes.forEach(Cb),this.root.sharedNodes.clear()}}}function B3(t){t.updateLayout()}function I3(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"?tn(y=>{const x=u?e.measuredBox[y]:e.layoutBox[y],w=Zt(x);x.min=n[y].min,x.max=x.min+w}):fj(l,e.layoutBox,n)&&tn(y=>{const x=u?e.measuredBox[y]:e.layoutBox[y],w=Zt(n[y]);x.max=x.min+w,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[y].max=t.relativeTarget[y].min+w)});const d=li();Oo(d,n,e.layoutBox);const h=li();u?Oo(h,t.applyTransform(r,!0),e.measuredBox):Oo(h,n,e.layoutBox);const m=!oj(d);let p=!1;if(!t.resumeFrom){const y=t.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:x,layout:w}=y;if(x&&w){const j=Pt();wu(j,e.layoutBox,x.layoutBox);const k=Pt();wu(k,n,w.layoutBox),lj(j,k)||(p=!0),y.options.layoutRoot&&(t.relativeTarget=k,t.relativeTargetOrigin=j,t.relativeParent=y)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:h,layoutDelta:d,hasLayoutChanged:m,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function V3(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 $3(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function q3(t){t.clearSnapshot()}function Cb(t){t.clearMeasurements()}function Ab(t){t.isLayoutDirty=!1}function H3(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Rb(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function G3(t){t.resolveTargetDelta()}function F3(t){t.calcProjection()}function K3(t){t.resetSkewAndRotation()}function Y3(t){t.removeLeadSnapshot()}function Ob(t,e,n){t.translate=gt(e.translate,0,n),t.scale=gt(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Mb(t,e,n,r){t.min=gt(e.min,n.min,r),t.max=gt(e.max,n.max,r)}function W3(t,e,n,r){Mb(t.x,e.x,n.x,r),Mb(t.y,e.y,n.y,r)}function X3(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const J3={duration:.45,ease:[.4,0,.1,1]},Db=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Pb=Db("applewebkit/")&&!Db("chrome/")?Math.round:Ls;function Lb(t){t.min=Pb(t.min),t.max=Pb(t.max)}function Q3(t){Lb(t.x),Lb(t.y)}function fj(t,e,n){return t==="position"||t==="preserve-aspect"&&!w3(_b(e),_b(n),.2)}function Z3(t){return t!==t.root&&t.scroll?.wasRoot}const eD=hj({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}),Pf={current:void 0},mj=hj({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Pf.current){const t=new eD({});t.mount(window),t.setOptions({layoutScroll:!0}),Pf.current=t}return Pf.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Np=v.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function zb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function tD(...t){return e=>{let n=!1;const r=t.map(l=>{const u=zb(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():zb(t[l],null)}}}}function sD(...t){return v.useCallback(tD(...t),t)}class nD extends v.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,l=Em(r)&&r.offsetWidth||0,u=Em(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 aD({children:t,isPresent:e,anchorX:n,anchorY:r,root:l,pop:u}){const d=v.useId(),h=v.useRef(null),m=v.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=v.useContext(Np),y=t.props?.ref??t?.ref,x=sD(h,y);return v.useInsertionEffect(()=>{const{width:w,height:j,top:k,left:S,right:_,bottom:T}=m.current;if(e||u===!1||!h.current||!w||!j)return;const C=n==="left"?`left: ${S}`:`right: ${_}`,A=r==="bottom"?`bottom: ${T}`:`top: ${k}`;h.current.dataset.motionPopId=d;const E=document.createElement("style");p&&(E.nonce=p);const M=l??document.head;return M.appendChild(E),E.sheet&&E.sheet.insertRule(`
|
|
97
|
+
[data-motion-pop-id="${d}"] {
|
|
98
|
+
position: absolute !important;
|
|
99
|
+
width: ${w}px !important;
|
|
100
|
+
height: ${j}px !important;
|
|
101
|
+
${C}px !important;
|
|
102
|
+
${A}px !important;
|
|
103
|
+
}
|
|
104
|
+
`),()=>{M.contains(E)&&M.removeChild(E)}},[e]),o.jsx(nD,{isPresent:e,childRef:h,sizeRef:m,pop:u,children:u===!1?t:v.cloneElement(t,{ref:x})})}const rD=({children:t,initial:e,isPresent:n,onExitComplete:r,custom:l,presenceAffectsLayout:u,mode:d,anchorX:h,anchorY:m,root:p})=>{const y=Qm(iD),x=v.useId();let w=!0,j=v.useMemo(()=>(w=!1,{id:x,initial:e,isPresent:n,custom:l,onExitComplete:k=>{y.set(k,!0);for(const S of y.values())if(!S)return;r&&r()},register:k=>(y.set(k,!1),()=>y.delete(k))}),[n,y,r]);return u&&w&&(j={...j}),v.useMemo(()=>{y.forEach((k,S)=>y.set(S,!1))},[n]),v.useEffect(()=>{!n&&!y.size&&r&&r()},[n]),t=o.jsx(aD,{pop:d==="popLayout",isPresent:n,anchorX:h,anchorY:m,root:p,children:t}),o.jsx(Pu.Provider,{value:j,children:t})};function iD(){return new Map}function pj(t=!0){const e=v.useContext(Pu);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:l}=e,u=v.useId();v.useEffect(()=>{if(t)return l(u)},[t]);const d=v.useCallback(()=>t&&r&&r(u),[u,r,t]);return!n&&r?[!1,d]:[!0]}const Gc=t=>t.key||"";function Ub(t){const e=[];return v.Children.forEach(t,n=>{v.isValidElement(n)&&e.push(n)}),e}const kp=({children:t,custom:e,initial:n=!0,onExitComplete:r,presenceAffectsLayout:l=!0,mode:u="sync",propagate:d=!1,anchorX:h="left",anchorY:m="top",root:p})=>{const[y,x]=pj(d),w=v.useMemo(()=>Ub(t),[t]),j=d&&!y?[]:w.map(Gc),k=v.useRef(!0),S=v.useRef(w),_=Qm(()=>new Map),T=v.useRef(new Set),[C,A]=v.useState(w),[E,M]=v.useState(w);q1(()=>{k.current=!1,S.current=w;for(let R=0;R<E.length;R++){const B=Gc(E[R]);j.includes(B)?(_.delete(B),T.current.delete(B)):_.get(B)!==!0&&_.set(B,!1)}},[E,j.length,j.join("-")]);const P=[];if(w!==C){let R=[...w];for(let B=0;B<E.length;B++){const se=E[B],re=Gc(se);j.includes(re)||(R.splice(B,0,se),P.push(se))}return u==="wait"&&P.length&&(R=P),M(Ub(R)),A(w),null}const{forceRender:U}=v.useContext(Jm);return o.jsx(o.Fragment,{children:E.map(R=>{const B=Gc(R),se=d&&!y?!1:w===E||j.includes(B),re=()=>{if(T.current.has(B))return;if(T.current.add(B),_.has(B))_.set(B,!0);else return;let ue=!0;_.forEach(xe=>{xe||(ue=!1)}),ue&&(U?.(),M(S.current),d&&x?.(),r&&r())};return o.jsx(rD,{isPresent:se,initial:!k.current||n?void 0:!1,custom:e,presenceAffectsLayout:l,mode:u,root:p,onExitComplete:se?void 0:re,anchorX:h,anchorY:m,children:R},B)})})},gj=v.createContext({strict:!1}),Bb={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 Ib=!1;function oD(){if(Ib)return;const t={};for(const e in Bb)t[e]={isEnabled:n=>Bb[e].some(r=>!!n[r])};GS(t),Ib=!0}function yj(){return oD(),KM()}function lD(t){const e=yj();for(const n in t)e[n]={...e[n],...t[n]};GS(e)}const cD=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","propagate","ignoreStrict","viewport"]);function Su(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||cD.has(t)}let vj=t=>!Su(t);function uD(t){typeof t=="function"&&(vj=e=>e.startsWith("on")?!Su(e):t(e))}try{uD(require("@emotion/is-prop-valid").default)}catch{}function dD(t,e,n){const r={};for(const l in t)l==="values"&&typeof t.values=="object"||(vj(l)||n===!0&&Su(l)||!e&&!Su(l)||t.draggable&&l.startsWith("onDrag"))&&(r[l]=t[l]);return r}const Uu=v.createContext({});function hD(t,e){if(zu(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 fD(t){const{initial:e,animate:n}=hD(t,v.useContext(Uu));return v.useMemo(()=>({initial:e,animate:n}),[Vb(e),Vb(n)])}function Vb(t){return Array.isArray(t)?t.join(" "):t}const Tp=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function xj(t,e,n){for(const r in e)!Xt(e[r])&&!QS(r,n)&&(t[r]=e[r])}function mD({transformTemplate:t},e){return v.useMemo(()=>{const n=Tp();return jp(n,e,t),Object.assign({},n.vars,n.style)},[e])}function pD(t,e){const n=t.style||{},r={};return xj(r,n,t),Object.assign(r,mD(t,e)),r}function gD(t,e){const n={},r=pD(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 bj=()=>({...Tp(),attrs:{}});function yD(t,e,n,r){const l=v.useMemo(()=>{const u=bj();return ZS(u,e,tj(r),t.transformTemplate,t.style),{...u.attrs,style:{...u.style}}},[e]);if(t.style){const u={};xj(u,t.style,t),l.style={...u,...l.style}}return l}const vD=["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 Ep(t){return typeof t!="string"||t.includes("-")?!1:!!(vD.indexOf(t)>-1||/[A-Z]/u.test(t))}function xD(t,e,n,{latestValues:r},l,u=!1,d){const m=(d??Ep(t)?yD:gD)(e,r,l,t),p=dD(e,typeof t=="string",u),y=t!==v.Fragment?{...p,...m,ref:n}:{},{children:x}=e,w=v.useMemo(()=>Xt(x)?x.get():x,[x]);return v.createElement(t,{...y,children:w})}function bD({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,l){return{latestValues:wD(n,r,l,t),renderState:e()}}function wD(t,e,n,r){const l={},u=r(t,{});for(const w in u)l[w]=su(u[w]);let{initial:d,animate:h}=t;const m=zu(t),p=qS(t);e&&p&&!m&&t.inherit!==!1&&(d===void 0&&(d=e.initial),h===void 0&&(h=e.animate));let y=n?n.initial===!1:!1;y=y||d===!1;const x=y?h:d;if(x&&typeof x!="boolean"&&!Lu(x)){const w=Array.isArray(x)?x:[x];for(let j=0;j<w.length;j++){const k=pp(t,w[j]);if(k){const{transitionEnd:S,transition:_,...T}=k;for(const C in T){let A=T[C];if(Array.isArray(A)){const E=y?A.length-1:0;A=A[E]}A!==null&&(l[C]=A)}for(const C in S)l[C]=S[C]}}}return l}const wj=t=>(e,n)=>{const r=v.useContext(Uu),l=v.useContext(Pu),u=()=>bD(t,e,r,l);return n?u():Qm(u)},SD=wj({scrapeMotionValuesFromProps:_p,createRenderState:Tp}),jD=wj({scrapeMotionValuesFromProps:sj,createRenderState:bj}),_D=Symbol.for("motionComponentSymbol");function ND(t,e,n){const r=v.useRef(n);v.useInsertionEffect(()=>{r.current=n});const l=v.useRef(null);return v.useCallback(u=>{u&&t.onMount?.(u),e&&(u?e.mount(u):e.unmount());const d=r.current;if(typeof d=="function")if(u){const h=d(u);typeof h=="function"&&(l.current=h)}else l.current?(l.current(),l.current=null):d(u);else d&&(d.current=u)},[e])}const Sj=v.createContext({});function ai(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function kD(t,e,n,r,l,u){const{visualElement:d}=v.useContext(Uu),h=v.useContext(gj),m=v.useContext(Pu),p=v.useContext(Np),y=p.reducedMotion,x=p.skipAnimations,w=v.useRef(null),j=v.useRef(!1);r=r||h.renderer,!w.current&&r&&(w.current=r(t,{visualState:e,parent:d,props:n,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:y,skipAnimations:x,isSVG:u}),j.current&&w.current&&(w.current.manuallyAnimateOnMount=!0));const k=w.current,S=v.useContext(Sj);k&&!k.projection&&l&&(k.type==="html"||k.type==="svg")&&TD(w.current,n,l,S);const _=v.useRef(!1);v.useInsertionEffect(()=>{k&&_.current&&k.update(n,m)});const T=n[AS],C=v.useRef(!!T&&!window.MotionHandoffIsComplete?.(T)&&window.MotionHasOptimisedAnimation?.(T));return q1(()=>{j.current=!0,k&&(_.current=!0,window.MotionIsMounted=!0,k.updateFeatures(),k.scheduleRenderMicrotask(),C.current&&k.animationState&&k.animationState.animateChanges())}),v.useEffect(()=>{k&&(!C.current&&k.animationState&&k.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(T)}),C.current=!1),k.enteringChildren=void 0)}),k}function TD(t,e,n,r){const{layoutId:l,layout:u,drag:d,dragConstraints:h,layoutScroll:m,layoutRoot:p,layoutCrossfade:y}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:jj(t.parent)),t.projection.setOptions({layoutId:l,layout:u,alwaysMeasureLayout:!!d||h&&ai(h),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:m,layoutRoot:p})}function jj(t){if(t)return t.options.allowProjection!==!1?t.projection:jj(t.parent)}function Lf(t,{forwardMotionProps:e=!1,type:n}={},r,l){r&&lD(r);const u=n?n==="svg":Ep(t),d=u?jD:SD;function h(p,y){let x;const w={...v.useContext(Np),...p,layoutId:ED(p)},{isStatic:j}=w,k=fD(p),S=d(p,j);if(!j&&$1){CD();const _=AD(w);x=_.MeasureLayout,k.visualElement=kD(t,S,w,l,_.ProjectionNode,u)}return o.jsxs(Uu.Provider,{value:k,children:[x&&k.visualElement?o.jsx(x,{visualElement:k.visualElement,...w}):null,xD(t,p,ND(S,k.visualElement,y),S,j,e,u)]})}h.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const m=v.forwardRef(h);return m[_D]=t,m}function ED({layoutId:t}){const e=v.useContext(Jm).id;return e&&t!==void 0?e+"-"+t:t}function CD(t,e){v.useContext(gj).strict}function AD(t){const e=yj(),{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 RD(t,e){if(typeof Proxy>"u")return Lf;const n=new Map,r=(u,d)=>Lf(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,Lf(d,void 0,t,e)),n.get(d))})}const OD=(t,e)=>e.isSVG??Ep(t)?new u3(e):new a3(e,{allowProjection:t!==v.Fragment});class MD extends ba{constructor(e){super(e),e.animationState||(e.animationState=p3(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Lu(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 DD=0;class PD extends ba{constructor(){super(...arguments),this.id=DD++}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 LD={animation:{Feature:MD},exit:{Feature:PD}};function ol(t){return{point:{x:t.pageX,y:t.pageY}}}const zD=t=>e=>xp(e)&&t(e,ol(e));function Mo(t,e,n,r){return Zo(t,e,zD(n),r)}const _j=({current:t})=>t?t.ownerDocument.defaultView:null,$b=(t,e)=>Math.abs(t-e);function UD(t,e){const n=$b(t.x,e.x),r=$b(t.y,e.y);return Math.sqrt(n**2+r**2)}const qb=new Set(["auto","scroll"]);class Nj{constructor(e,n,{transformPagePoint:r,contextWindow:l=window,dragSnapToOrigin:u=!1,distanceThreshold:d=3,element:h}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=j=>{this.handleScroll(j.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const j=Uf(this.lastMoveEventInfo,this.history),k=this.startEvent!==null,S=UD(j.offset,{x:0,y:0})>=this.distanceThreshold;if(!k&&!S)return;const{point:_}=j,{timestamp:T}=Ft;this.history.push({..._,timestamp:T});const{onStart:C,onMove:A}=this.handlers;k||(C&&C(this.lastMoveEvent,j),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,j)},this.handlePointerMove=(j,k)=>{this.lastMoveEvent=j,this.lastMoveEventInfo=zf(k,this.transformPagePoint),ct.update(this.updatePoint,!0)},this.handlePointerUp=(j,k)=>{this.end();const{onEnd:S,onSessionEnd:_,resumeAnimation:T}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Uf(j.type==="pointercancel"?this.lastMoveEventInfo:zf(k,this.transformPagePoint),this.history);this.startEvent&&S&&S(j,C),_&&_(j,C)},!xp(e))return;this.dragSnapToOrigin=u,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=d,this.contextWindow=l||window;const m=ol(e),p=zf(m,this.transformPagePoint),{point:y}=p,{timestamp:x}=Ft;this.history=[{...y,timestamp:x}];const{onSessionStart:w}=n;w&&w(e,Uf(p,this.history)),this.removeListeners=al(Mo(this.contextWindow,"pointermove",this.handlePointerMove),Mo(this.contextWindow,"pointerup",this.handlePointerUp),Mo(this.contextWindow,"pointercancel",this.handlePointerUp)),h&&this.startScrollTracking(h)}startScrollTracking(e){let n=e.parentElement;for(;n;){const r=getComputedStyle(n);(qb.has(r.overflowX)||qb.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}),window.addEventListener("scroll",this.onWindowScroll),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),ct.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ya(this.updatePoint)}}function zf(t,e){return e?{point:e(t.point)}:t}function Hb(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Uf({point:t},e){return{point:t,delta:Hb(t,kj(e)),offset:Hb(t,BD(e)),velocity:ID(e,.1)}}function BD(t){return t[0]}function kj(t){return t[t.length-1]}function ID(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const l=kj(t);for(;n>=0&&(r=t[n],!(l.timestamp-r.timestamp>Gs(e)));)n--;if(!r)return{x:0,y:0};r===t[0]&&t.length>2&&l.timestamp-r.timestamp>Gs(e)*2&&(r=t[1]);const u=Ds(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 VD(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?gt(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?gt(n,t,r.max):Math.min(t,n)),t}function Gb(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 $D(t,{top:e,left:n,bottom:r,right:l}){return{x:Gb(t.x,n,l),y:Gb(t.y,e,r)}}function Fb(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 qD(t,e){return{x:Fb(t.x,e.x),y:Fb(t.y,e.y)}}function HD(t,e){let n=.5;const r=Zt(t),l=Zt(e);return l>r?n=Wo(e.min,e.max-r,t.min):r>l&&(n=Wo(t.min,t.max-l,e.min)),ln(0,1,n)}function GD(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 Mm=.35;function FD(t=Mm){return t===!1?t=0:t===!0&&(t=Mm),{x:Kb(t,"left","right"),y:Kb(t,"top","bottom")}}function Kb(t,e,n){return{min:Yb(t,e),max:Yb(t,n)}}function Yb(t,e){return typeof t=="number"?t:t[e]||0}const KD=new WeakMap;class YD{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=Pt(),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=x=>{n&&this.snapToCursor(ol(x).point),this.stopAnimation()},d=(x,w)=>{const{drag:j,dragPropagation:k,onDragStart:S}=this.getProps();if(j&&!k&&(this.openDragLock&&this.openDragLock(),this.openDragLock=jM(j),!this.openDragLock))return;this.latestPointerEvent=x,this.latestPanInfo=w,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),tn(T=>{let C=this.getAxisMotionValue(T).get()||0;if(on.test(C)){const{projection:A}=this.visualElement;if(A&&A.layout){const E=A.layout.layoutBox[T];E&&(C=Zt(E)*(parseFloat(C)/100))}}this.originPoint[T]=C}),S&&ct.update(()=>S(x,w),!1,!0),_m(this.visualElement,"transform");const{animationState:_}=this.visualElement;_&&_.setActive("whileDrag",!0)},h=(x,w)=>{this.latestPointerEvent=x,this.latestPanInfo=w;const{dragPropagation:j,dragDirectionLock:k,onDirectionLock:S,onDrag:_}=this.getProps();if(!j&&!this.openDragLock)return;const{offset:T}=w;if(k&&this.currentDirection===null){this.currentDirection=XD(T),this.currentDirection!==null&&S&&S(this.currentDirection);return}this.updateAxis("x",w.point,T),this.updateAxis("y",w.point,T),this.visualElement.render(),_&&ct.update(()=>_(x,w),!1,!0)},m=(x,w)=>{this.latestPointerEvent=x,this.latestPanInfo=w,this.stop(x,w),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new Nj(e,{onSessionStart:u,onStart:d,onMove:h,onSessionEnd:m,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:r,contextWindow:_j(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:h}=this.getProps();h&&ct.postRender(()=>h(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||!Fc(e,l,this.currentDirection))return;const u=this.getAxisMotionValue(e);let d=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(d=VD(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&&ai(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=$D(r.layoutBox,e):this.constraints=!1,this.elastic=FD(n),l!==this.constraints&&!ai(e)&&r&&this.constraints&&!this.hasMutatedConstraints&&tn(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=GD(r.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!ai(e))return!1;const r=e.current,{projection:l}=this.visualElement;if(!l||!l.layout)return!1;const u=QM(r,l.root,this.visualElement.getTransformPagePoint());let d=qD(l.layout.layoutBox,u);if(n){const h=n(WM(d));this.hasMutatedConstraints=!!h,h&&(d=KS(h))}return d}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:l,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:h}=this.getProps(),m=this.constraints||{},p=tn(y=>{if(!Fc(y,n,this.currentDirection))return;let x=m&&m[y]||{};d&&(x={min:0,max:0});const w=l?200:1e6,j=l?40:1e7,k={type:"inertia",velocity:r?e[y]:0,bounceStiffness:w,bounceDamping:j,timeConstant:750,restDelta:1,restSpeed:10,...u,...x};return this.startAxisValueAnimation(y,k)});return Promise.all(p).then(h)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return _m(this.visualElement,e),r.start(mp(e,r,0,n,this.visualElement,!1))}stopAnimation(){tn(e=>this.getAxisMotionValue(e).stop())}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){tn(n=>{const{drag:r}=this.getProps();if(!Fc(n,r,this.currentDirection))return;const{projection:l}=this.visualElement,u=this.getAxisMotionValue(n);if(l&&l.layout){const{min:d,max:h}=l.layout.layoutBox[n],m=u.get()||0;u.set(e[n]-gt(d,h,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!ai(n)||!r||!this.constraints)return;this.stopAnimation();const l={x:0,y:0};tn(d=>{const h=this.getAxisMotionValue(d);if(h&&this.constraints!==!1){const m=h.get();l[d]=HD({min:m,max:m},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.constraints=!1,this.resolveConstraints(),tn(d=>{if(!Fc(d,e,null))return;const h=this.getAxisMotionValue(d),{min:m,max:p}=this.constraints[d];h.set(gt(m,p,l[d]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;KD.set(this.visualElement,this);const e=this.visualElement.current,n=Mo(e,"pointerdown",p=>{const{drag:y,dragListener:x=!0}=this.getProps(),w=p.target,j=w!==e&&CM(w);y&&x&&!j&&this.start(p)});let r;const l=()=>{const{dragConstraints:p}=this.getProps();ai(p)&&p.current&&(this.constraints=this.resolveRefConstraints(),r||(r=WD(e,p.current,()=>this.scalePositionWithinConstraints())))},{projection:u}=this.visualElement,d=u.addEventListener("measure",l);u&&!u.layout&&(u.root&&u.root.updateScroll(),u.updateLayout()),ct.read(l);const h=Zo(window,"resize",()=>this.scalePositionWithinConstraints()),m=u.addEventListener("didUpdate",(({delta:p,hasLayoutChanged:y})=>{this.isDragging&&y&&(tn(x=>{const w=this.getAxisMotionValue(x);w&&(this.originPoint[x]+=p[x].translate,w.set(w.get()+p[x].translate))}),this.visualElement.render())}));return()=>{h(),n(),d(),m&&m(),r&&r()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:l=!1,dragConstraints:u=!1,dragElastic:d=Mm,dragMomentum:h=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:l,dragConstraints:u,dragElastic:d,dragMomentum:h}}}function Wb(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function WD(t,e,n){const r=sb(t,Wb(n)),l=sb(e,Wb(n));return()=>{r(),l()}}function Fc(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function XD(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class JD extends ba{constructor(e){super(e),this.removeGroupControls=Ls,this.removeListeners=Ls,this.controls=new YD(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ls}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 Bf=t=>(e,n)=>{t&&ct.update(()=>t(e,n),!1,!0)};class QD extends ba{constructor(){super(...arguments),this.removePointerDownListener=Ls}onPointerDown(e){this.session=new Nj(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:_j(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:l}=this.node.getProps();return{onSessionStart:Bf(e),onStart:Bf(n),onMove:Bf(r),onEnd:(u,d)=>{delete this.session,l&&ct.postRender(()=>l(u,d))}}}mount(){this.removePointerDownListener=Mo(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 If=!1;class ZD extends v.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),If&&u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),nu.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}),If=!0,l||e.layoutDependency!==n||n===void 0||e.isPresent!==u?d.willUpdate():this.safeToRemove(),e.isPresent!==u&&(u?d.promote():d.relegate()||ct.postRender(()=>{const h=d.getStack();(!h||!h.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),vp.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:l}=e;If=!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 Tj(t){const[e,n]=pj(),r=v.useContext(Jm);return o.jsx(ZD,{...t,layoutGroup:r,switchLayoutGroup:v.useContext(Sj),isPresent:e,safeToRemove:n})}const e6={pan:{Feature:QD},drag:{Feature:JD,ProjectionNode:mj,MeasureLayout:Tj}};function Xb(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&&ct.postRender(()=>u(e,ol(e)))}class t6 extends ba{mount(){const{current:e}=this.node;e&&(this.unmount=NM(e,(n,r)=>(Xb(this.node,r,"Start"),l=>Xb(this.node,l,"End"))))}unmount(){}}class s6 extends ba{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=al(Zo(this.node.current,"focus",()=>this.onFocus()),Zo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Jb(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&&ct.postRender(()=>u(e,ol(e)))}class n6 extends ba{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=RM(e,(l,u)=>(Jb(this.node,u,"Start"),(d,{success:h})=>Jb(this.node,d,h?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:r?.tap===!1})}unmount(){}}const Dm=new WeakMap,Vf=new WeakMap,a6=t=>{const e=Dm.get(t.target);e&&e(t)},r6=t=>{t.forEach(a6)};function i6({root:t,...e}){const n=t||document;Vf.has(n)||Vf.set(n,{});const r=Vf.get(n),l=JSON.stringify(e);return r[l]||(r[l]=new IntersectionObserver(r6,{root:t,...e})),r[l]}function o6(t,e,n){const r=i6(e);return Dm.set(t,n),r.observe(t),()=>{Dm.delete(t),r.unobserve(t)}}const l6={some:0,all:1};class c6 extends ba{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:l6[l]},h=m=>{const{isIntersecting:p}=m;if(this.isInView===p||(this.isInView=p,u&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:y,onViewportLeave:x}=this.node.getProps(),w=p?y:x;w&&w(m)};return o6(this.node.current,d,h)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(u6(e,n))&&this.startObserver()}unmount(){}}function u6({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const d6={inView:{Feature:c6},tap:{Feature:n6},focus:{Feature:s6},hover:{Feature:t6}},h6={layout:{ProjectionNode:mj,MeasureLayout:Tj}},f6={...LD,...d6,...e6,...h6},Do=RD(f6,OD);function m6({supabase:t,initStatus:e,onSuccess:n,onResetConfigs:r}){const[l,u]=v.useState(""),[d,h]=v.useState(""),[m,p]=v.useState(""),[y,x]=v.useState(""),[w,j]=v.useState(""),[k,S]=v.useState(!1),[_,T]=v.useState(null),[C,A]=v.useState(!1),[E,M]=v.useState(e==="empty"),[P,U]=v.useState("password"),[R,B]=v.useState(!1);async function se(){S(!0),T(null);try{const{error:X}=await t.auth.signInWithPassword({email:l,password:d});if(X)throw X;n()}catch(X){T(X.message||"Authentication failed.")}finally{S(!1)}}async function re(){S(!0),T(null);try{const X=await be.setup({email:l,password:d,first_name:y,last_name:w});if(X.error)throw new Error(typeof X.error=="string"?X.error:X.error.message);const{error:V}=await t.auth.signInWithPassword({email:l,password:d});if(V)throw V;n()}catch(X){T(X.message||"Failed to initialize foundation.")}finally{S(!1)}}async function ue(){S(!0),T(null);try{const{error:X}=await t.auth.signInWithOtp({email:l,options:{shouldCreateUser:!1}});if(X)throw X;B(!0),p("")}catch(X){T(X.message||"Failed to send email code.")}finally{S(!1)}}async function xe(){S(!0),T(null);try{const{error:X}=await t.auth.verifyOtp({email:l,token:m,type:"email"});if(X)throw X;n()}catch(X){T(X.message||"Invalid code.")}finally{S(!1)}}async function ge(X){if(X.preventDefault(),E){await re();return}if(P==="password"){await se();return}if(!R){await ue();return}await xe()}return o.jsxs("div",{className:"min-h-screen bg-background flex items-center justify-center p-6 relative overflow-hidden",children:[o.jsxs("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none opacity-20",children:[o.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/20 blur-[120px] rounded-full animate-pulse"}),o.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-primary/10 blur-[120px] rounded-full animate-pulse delay-700"})]}),o.jsxs("div",{className:"absolute top-8 right-8 flex items-center gap-4 z-50",children:[o.jsx(D1,{}),o.jsxs("div",{className:"hidden sm:flex items-center gap-2 px-3 py-1.5 bg-muted/40 rounded-full border border-border/40 cursor-pointer hover:bg-muted/60 transition-colors group",children:[o.jsx(lu,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"text-[10px] font-extrabold tracking-widest text-muted-foreground",children:"EN"})]})]}),o.jsxs(Do.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},className:"w-full max-w-[450px] relative z-10",children:[o.jsxs("div",{className:"bg-card/40 backdrop-blur-2xl border border-border/40 p-10 rounded-[2.5rem] shadow-2xl shadow-black/10 space-y-8 overflow-hidden relative",children:[o.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-primary/40 to-transparent"}),o.jsxs("div",{className:"text-center space-y-4",children:[o.jsx("div",{className:"mx-auto w-16 h-16 bg-primary rounded-2xl flex items-center justify-center shadow-xl shadow-primary/20 hover:scale-105 transition-transform duration-500",children:o.jsx(lu,{className:"w-10 h-10"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-4xl font-black tracking-tighter uppercase italic text-foreground leading-none",children:E?"Initialization":"Access Gate"}),o.jsx("p",{className:"text-[10px] text-muted-foreground font-black tracking-[0.3em] uppercase mt-2 opacity-60",children:E?"Primary Administrator Enrollment":"Foundational Identity Required"})]})]}),o.jsxs("form",{onSubmit:ge,className:"space-y-6",children:[o.jsx(kp,{mode:"wait",children:E&&o.jsxs(Do.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-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(Ne,{placeholder:"Agent",value:y,onChange:X=>x(X.target.value),required:E,className:"h-12 bg-background/50 border-border/40 rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(Ne,{placeholder:"Zero",value:w,onChange:X=>j(X.target.value),required:E,className:"h-12 bg-background/50 border-border/40 rounded-xl"})]})]})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Coordinates"}),o.jsxs("div",{className:"relative group",children:[o.jsx(qo,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(Ne,{type:"email",placeholder:"admin@realtimex.ai",value:l,onChange:X=>{u(X.target.value),!E&&P==="otp"&&(B(!1),p(""))},required:!0,className:"pl-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium"})]})]}),(E||P==="password")&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Security Key"}),o.jsxs("div",{className:"relative group",children:[o.jsx(gi,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(Ne,{type:C?"text":"password",placeholder:"••••••••",value:d,onChange:X=>h(X.target.value),required:E||P==="password",className:"pl-12 pr-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium"}),o.jsx("button",{type:"button",onClick:()=>A(!C),className:"absolute right-4 top-1/2 -translate-y-1/2 text-muted-foreground/40 hover:text-primary transition-colors focus:outline-none",children:C?o.jsx(lC,{className:"w-5 h-5"}):o.jsx(uC,{className:"w-5 h-5"})})]})]}),!E&&P==="otp"&&R&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{className:"text-[10px] font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Code (OTP)"}),o.jsxs("div",{className:"relative group",children:[o.jsx(gi,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4.5 h-4.5 text-muted-foreground/40 group-focus-within:text-primary transition-colors"}),o.jsx(Ne,{type:"text",inputMode:"numeric",placeholder:"6-digit code",value:m,onChange:X=>p(X.target.value.replace(/\D/g,"").slice(0,6)),required:!0,className:"pl-12 h-14 bg-background/50 border-border/40 rounded-2xl focus:ring-primary/20 font-medium tracking-[0.3em]"})]})]}),_&&o.jsx(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},children:o.jsxs(es,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20 py-3 rounded-2xl",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(fs,{className:"w-4 h-4 shrink-0"}),o.jsx(ts,{className:"text-xs font-bold leading-relaxed",children:_})]}),(_.includes("fetch")||_.includes("connection"))&&r&&o.jsx(oe,{variant:"link",size:"sm",onClick:r,className:"text-[10px] font-black uppercase tracking-tighter text-destructive h-auto p-0 mt-2 ml-6 hover:no-underline hover:opacity-70",children:"Reset Configuration Foundation"})]})}),o.jsx(oe,{size:"lg",className:"w-full h-14 rounded-2xl text-base font-black shadow-xl shadow-primary/20 hover:scale-[1.02] active:scale-[0.98] transition-all duration-300",disabled:k||!l||E&&!d||!E&&P==="password"&&!d||!E&&P==="otp"&&R&&m.length<6,children:k?o.jsx(Qe,{className:"w-5 h-5 animate-spin"}):o.jsxs(o.Fragment,{children:[E?o.jsx(xa,{className:"w-5 h-5 mr-3"}):o.jsx(qw,{className:"w-5 h-5 mr-3"}),E?"Engage Administrator":P==="password"?"Log In to Dashboard":R?"Verify Code & Login":"Send Email Code"]})}),!E&&o.jsxs("button",{type:"button",onClick:()=>{T(null),B(!1),p(""),U(P==="password"?"otp":"password")},className:"w-full text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground hover:text-primary transition-colors flex items-center justify-center gap-2 group",children:[P==="password"?"Use Login with Email Code (OTP)":"Use Password Login",o.jsx(p0,{className:"w-3 h-3 group-hover:translate-x-1 transition-transform"})]}),!E&&P==="otp"&&R&&o.jsx("button",{type:"button",onClick:()=>{ue()},className:"w-full text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground hover:text-primary transition-colors",disabled:k,children:"Resend Email Code"})]}),o.jsx("div",{className:"pt-6 border-t border-border/10",children:o.jsxs("button",{type:"button",onClick:()=>{T(null),B(!1),p(""),U("password"),M(!E)},className:"w-full text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground hover:text-primary transition-colors flex items-center justify-center gap-2 group",children:[E?"Already have an account? Access Gate":"First time? Enroll Primary Admin",o.jsx(p0,{className:"w-3 h-3 group-hover:translate-x-1 transition-transform"})]})})]}),o.jsx("div",{className:"mt-10 text-center",children:o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/30 uppercase tracking-[0.5em]",children:"Powered by Foundations Protocol 2026"})})]})]})}const p6={"app.name":"Folio","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.saveChanges":"Save Changes","common.previous":"Previous","common.next":"Next","nav.dashboard":"Dashboard","nav.configuration":"Configuration","nav.accountSettings":"Account Settings","nav.signOut":"Sign Out","config.title":"Foundation Configuration","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.disconnect":"Disconnect","config.gmail.connect":"Connect Gmail","config.gmail.connectDesc":"Connect your Google account","config.outlook.connect":"Connect Outlook","config.outlook.connectDesc":"Connect your Microsoft account","config.model.title":"AI Model Configuration","config.model.desc":"Configure your AI model and processing settings","config.llm.title":"LLM","config.model.provider":"LLM Provider","config.model.name":"Model Name","config.model.selectModel":"Select a model","config.model.syncInterval":"Sync Interval (minutes)","config.model.intelligentRename":"Intelligent Rename","config.model.checkConnection":"Check Connection","config.model.saveConfig":"Save Configuration","config.providers.gmail":"Gmail","config.providers.outlook":"Outlook","config.providers.imap":"IMAP / SMTP","config.embed.title":"Embedding (RAG)","config.embed.desc":"Configure embeddings for knowledge base search.","config.byok.title":"Provider Credentials (BYOK)","config.byok.desc":"Configure your own API keys and OAuth credentials.","config.byok.googleTitle":"Google Cloud","config.byok.microsoftTitle":"Microsoft Azure","config.byok.clientId":"Client ID","config.byok.clientSecret":"Client Secret","config.imap.title":"Connect via IMAP","config.imap.connect":"Connect IMAP Account","config.imap.desc":"Connect any email provider using IMAP/SMTP.","config.voice.title":"Voice & Speech","config.voice.desc":"Configure text-to-speech for AI interaction.","config.voice.autoTitle":"Auto-Speak Responses","config.voice.provider":"TTS Provider","config.voice.voice":"Voice","config.voice.speed":"Speed","config.voice.quality":"Quality","config.toast.settingsSaved":"Settings saved successfully","config.toast.connectionFailed":"Failed to connect to provider","config.toast.accountDisconnected":"Account disconnected","config.gmail.authSteps":"Follow the prompts in the popup to authorize access.","config.gmail.credentialsDesc":"Enter your Google OAuth credentials.","config.outlook.credentialsDesc":"Enter your Microsoft Azure credentials.","config.outlook.instructions":"Use the device code below to authenticate.","setup.back":"Back","setup.engage":"Connect"},g6=p6,Ej=v.createContext(void 0);function y6({children:t}){const[e]=v.useState("en"),[n]=v.useState(!1),r=v.useCallback(d=>{},[]),l=v.useCallback(d=>g6[d]||d,[]),u=v.useMemo(()=>({language:e,setLanguage:r,t:l,isLoading:n}),[e,l,n]);return o.jsx(Ej.Provider,{value:u,children:t})}function _i(){const t=v.useContext(Ej);if(t===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return t}function qa(t,e){return t?typeof t=="string"?t:t.message||e:e}const Cj={user:null,isAuthenticated:!1,profile:null,accounts:[],rules:[],settings:null,stats:null,isLoading:!0,isInitialized:!1,error:null};function v6(t,e){switch(e.type){case"SET_USER":{const n=!!e.payload;return{...t,user:e.payload,isAuthenticated:n,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_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"CLEAR_DATA":return{...Cj,isLoading:!1,isInitialized:!0};default:return t}}const Aj=v.createContext(null);function x6({children:t}){const[e,n]=v.useReducer(v6,Cj),r=v.useMemo(()=>hs(),[]);v.useEffect(()=>{if(!r){n({type:"SET_INITIALIZED",payload:!0});return}async function d(){if(!r)return;const{data:{session:h}}=await r.auth.getSession();n({type:"SET_USER",payload:h?.user||null}),n({type:"SET_INITIALIZED",payload:!0});const{data:{subscription:m}}=r.auth.onAuthStateChange((p,y)=>{n({type:"SET_USER",payload:y?.user||null}),y||n({type:"CLEAR_DATA"})});return()=>m.unsubscribe()}d()},[r]);const l=v.useMemo(()=>({fetchAccounts:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await be.getAccounts(d?.access_token);h.data&&n({type:"SET_ACCOUNTS",payload:h.data.accounts})},fetchRules:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await be.getRules(d?.access_token);h.data&&n({type:"SET_RULES",payload:h.data.rules})},fetchSettings:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await be.getSettings(d?.access_token);h.data&&h.data.settings&&n({type:"SET_SETTINGS",payload:h.data.settings})},fetchProfile:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await be.getProfile(d?.access_token);h.data&&n({type:"SET_PROFILE",payload:h.data})},fetchStats:async()=>{if(!r)return;const{data:{session:d}}=await r.auth.getSession(),h=await be.getStats(d?.access_token);h.data&&n({type:"SET_STATS",payload:h.data.stats})},disconnectAccount:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await be.disconnectAccount(d,h?.access_token);return m.data?.success?(n({type:"REMOVE_ACCOUNT",payload:d}),!0):(n({type:"SET_ERROR",payload:qa(m.error,"Failed to disconnect")}),!1)},updateSettings:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await be.updateSettings(d,h?.access_token);return m.data&&m.data.settings?(n({type:"SET_SETTINGS",payload:m.data.settings}),!0):(n({type:"SET_ERROR",payload:qa(m.error,"Failed to update settings")}),!1)},updateProfile:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await be.updateProfile(d,h?.access_token);return m.data?(n({type:"UPDATE_PROFILE",payload:m.data}),!0):(n({type:"SET_ERROR",payload:qa(m.error,"Failed to update profile")}),!1)},createRule:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await be.createRule(d,h?.access_token);return m.data?(n({type:"ADD_RULE",payload:m.data.rule}),!0):(n({type:"SET_ERROR",payload:qa(m.error,"Failed to create rule")}),!1)},updateRule:async(d,h)=>{if(!r)return!1;const{data:{session:m}}=await r.auth.getSession(),p=await be.updateRule(d,h,m?.access_token);return p.data?(n({type:"UPDATE_RULE",payload:p.data.rule}),!0):(n({type:"SET_ERROR",payload:qa(p.error,"Failed to update rule")}),!1)},deleteRule:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await be.deleteRule(d,h?.access_token);return m.data?.success?(n({type:"REMOVE_RULE",payload:d}),!0):(n({type:"SET_ERROR",payload:qa(m.error,"Failed to delete rule")}),!1)},toggleRule:async d=>{if(!r)return!1;const{data:{session:h}}=await r.auth.getSession(),m=await be.toggleRule(d,h?.access_token);return m.data?(n({type:"UPDATE_RULE",payload:m.data.rule}),!0):(n({type:"SET_ERROR",payload:qa(m.error,"Failed to toggle rule")}),!1)}}),[e.accounts,e.rules]),u=v.useMemo(()=>({state:e,dispatch:n,actions:l,supabase:r}),[e,l,r]);return o.jsx(Aj.Provider,{value:u,children:t})}function ll(){const t=v.useContext(Aj);if(!t)throw new Error("useApp must be used within AppProvider");return t}function b6(t){return null}function ds({className:t,size:e="md",text:n}){const r={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-10 h-10"};return o.jsxs("div",{className:ve("flex flex-col items-center justify-center gap-3",t),children:[o.jsx(Qe,{className:ve("animate-spin text-primary",r[e])}),n&&o.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:n})]})}function w6({open:t,onOpenChange:e}){const{t:n}=_i(),{actions:r}=ll(),[l,u]=v.useState(!1),[d,h]=v.useState(""),[m,p]=v.useState(""),[y,x]=v.useState(""),[w,j]=v.useState(993),[k,S]=v.useState(""),[_,T]=v.useState(465),[C,A]=v.useState(!0),[E,M]=v.useState(!0),P=R=>{const B=R.target.value;if(h(B),B.includes("@")){const se=B.split("@")[1].toLowerCase();se.includes("gmail.com")?(x("imap.gmail.com"),S("smtp.gmail.com"),j(993),A(!0),T(465),M(!0)):se.includes("outlook.com")||se.includes("hotmail.com")?(x("outlook.office365.com"),S("smtp.office365.com"),j(993),A(!0),T(587),M(!1)):se.includes("yahoo.com")?(x("imap.mail.yahoo.com"),S("smtp.mail.yahoo.com"),j(993),A(!0),T(465),M(!0)):se.includes("icloud.com")?(x("imap.mail.me.com"),S("smtp.mail.me.com"),j(993),A(!0),T(587),M(!1)):se.includes("fastmail.com")&&(x("imap.fastmail.com"),S("smtp.fastmail.com"),j(993),A(!0),T(465),M(!0))}},U=async()=>{if(!d||!m||!y||!k){he.error(n("config.imap.missingFields"));return}u(!0);try{(await be.connectImap({email:d,password:m,imapHost:y,imapPort:Number(w),smtpHost:k,smtpPort:Number(_),imapSecure:C,smtpSecure:E})).data?.success?(he.success(n("config.imap.connected")),e(!1),r.fetchAccounts(),h(""),p(""),x(""),S(""),j(993),T(465),A(!0),M(!0)):he.error(n("config.imap.connectFailed"))}catch(R){console.error("IMAP Connect Error:",R),he.error(n("config.imap.connectFailed"))}finally{u(!1)}};return o.jsx(pa,{open:t,onOpenChange:e,children:o.jsxs(ga,{className:"sm:max-w-2xl",children:[o.jsxs(ar,{children:[o.jsxs(rr,{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-400 font-bold text-sm",children:o.jsx(qo,{className:"w-4 h-4"})}),n("config.imap.connect")]}),o.jsx(bi,{children:n("config.imap.desc")})]}),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 flex gap-3",children:[o.jsx(fs,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[o.jsx("p",{className:"font-medium",children:n("config.imap.appPasswordTitle")}),o.jsx("p",{children:n("config.imap.appPasswordDesc")})]})]}),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:n("config.imap.emailLabel")}),o.jsx(Ne,{placeholder:"you@example.com",value:d,onChange:P,type:"email"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:n("config.imap.passwordLabel")}),o.jsx(Ne,{placeholder:"xxxx-xxxx-xxxx-xxxx",value:m,onChange:R=>p(R.target.value),type:"password"})]}),o.jsxs("div",{className:"pt-2",children:[o.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[o.jsx(JC,{className:"w-4 h-4"}),n("config.imap.serverSettings")]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 border rounded-lg bg-secondary/10",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"IMAP Host"}),o.jsx(Ne,{className:"h-8 text-xs font-mono",placeholder:"imap.example.com",value:y,onChange:R=>x(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Port"}),o.jsx(Ne,{className:"h-8 text-xs font-mono",placeholder:"993",type:"number",value:w,onChange:R=>{const B=parseInt(R.target.value)||993;j(B),A(B===993)}}),o.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:C,onChange:R=>A(R.target.checked),className:"accent-primary"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Implicit TLS"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"SMTP Host"}),o.jsx(Ne,{className:"h-8 text-xs font-mono",placeholder:"smtp.example.com",value:k,onChange:R=>S(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Port"}),o.jsx(Ne,{className:"h-8 text-xs font-mono",placeholder:"465",type:"number",value:_,onChange:R=>{const B=parseInt(R.target.value)||465;T(B),M(B===465)}}),o.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:E,onChange:R=>M(R.target.checked),className:"accent-primary"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Implicit TLS"})]})]})]})]})]})]}),o.jsxs(Xa,{children:[o.jsx(oe,{variant:"outline",onClick:()=>e(!1),children:n("common.cancel")}),o.jsxs(oe,{onClick:U,disabled:l||!d||!m||!y||!k,children:[l?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),n("config.imap.connectBtn")]})]})]})})}function S6({localSettings:t,setLocalSettings:e,handleSaveSettings:n,savingSettings:r}){const{state:l,actions:u,supabase:d}=ll(),{t:h}=_i(),[m,p]=v.useState(!1),[y,x]=v.useState("credentials"),[w,j]=v.useState(""),[k,S]=v.useState(""),[_,T]=v.useState(""),[C,A]=v.useState(""),[E,M]=v.useState(!1),[P,U]=v.useState(!1),[R,B]=v.useState(!1),[se,re]=v.useState("credentials"),[ue,xe]=v.useState(""),[ge,X]=v.useState(""),[V,F]=v.useState(!1),[Z,ye]=v.useState(null),[ne,D]=v.useState(!1),[L,J]=v.useState(!1),[H,ae]=v.useState(!1),ie=v.useRef(null),$=()=>{x("credentials"),j(""),S(""),T(""),A(""),p(!0)},fe=pe=>{j(pe);try{const De=JSON.parse(pe),it=De.installed||De.web||De;it.client_id&&S(it.client_id),it.client_secret&&T(it.client_secret)}catch{}},le=async()=>{if(!k||!_){he.error(h("config.toast.missingGmailCreds"));return}M(!0);try{if(await u.updateSettings({google_client_id:k,google_client_secret:_})){const De=d?(await d.auth.getSession()).data.session?.access_token:void 0,it=await be.getGmailAuthUrl(k,_,De);it.data?.authUrl?(window.open(it.data.authUrl,"_blank"),x("code"),he.success(h("config.toast.authorizeAndPaste"))):he.error(h("config.toast.oauthUrlFailed"))}else he.error(h("config.toast.saveCredsFailed"))}catch{he.error(h("config.toast.saveCredsFailed"))}finally{M(!1)}},Oe=async()=>{if(!C.trim()){he.error(h("config.toast.missingAuthCode"));return}U(!0);try{const pe=d?(await d.auth.getSession()).data.session?.access_token:void 0;(await be.connectGmail(C.trim(),k,_,pe)).data?.success?(he.success(h("config.toast.gmailConnected")),p(!1),u.fetchAccounts()):he.error(h("config.toast.gmailConnectFailed"))}catch{he.error(h("config.toast.gmailConnectFailed"))}finally{U(!1)}},Ue=()=>{re("credentials"),xe(""),X(""),B(!0)},ft=async()=>{if(!ue){he.error(h("config.toast.missingOutlookClientId"));return}F(!0);try{if(await u.updateSettings({microsoft_client_id:ue,microsoft_tenant_id:ge||"common"})){const De=d?(await d.auth.getSession()).data.session?.access_token:void 0,it=await be.startMicrosoftDeviceFlow(ue,ge||"common",De);it.data?.deviceCode?(ye(it.data.deviceCode),re("device-code"),D(!0),Ye(it.data.deviceCode.deviceCode,ue,ge||"common")):he.error(h("config.toast.deviceFlowFailed"))}else he.error(h("config.toast.saveCredsFailed"))}catch{he.error(h("config.toast.saveCredsFailed"))}finally{F(!1)}},Ye=async(pe,De,it)=>{const Ut=setInterval(async()=>{try{const Ws=d?(await d.auth.getSession()).data.session?.access_token:void 0;(await be.pollMicrosoftDeviceCode(pe,De,it,Ws)).data?.success&&(clearInterval(Ut),ye(null),D(!1),B(!1),he.success(h("config.toast.outlookConnected")),u.fetchAccounts())}catch{}},5e3);setTimeout(()=>clearInterval(Ut),900*1e3)},de=async pe=>{if(!confirm(h("config.toast.disconnectConfirm")))return;await u.disconnectAccount(pe)&&he.success(h("config.toast.accountDisconnected"))},Fe=pe=>pe==="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"}):pe==="imap"?o.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-400",children:o.jsx(qo,{className:"w-5 h-5"})}):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-6 animate-in fade-in duration-500",children:[o.jsx(pa,{open:m,onOpenChange:p,children:o.jsxs(ga,{className:"sm:max-w-lg",children:[o.jsxs(ar,{children:[o.jsxs(rr,{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"}),h("config.gmail.connect")]}),o.jsx(bi,{children:h(y==="credentials"?"config.gmail.credentialsDesc":"config.gmail.authCodeDesc")})]}),y==="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.jsx("label",{className:"text-sm font-medium",children:h("config.gmail.pasteJson")}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/10 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:w,onChange:pe=>fe(pe.target.value)})]}),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:h("config.byok.clientId")}),o.jsx(Ne,{placeholder:h("config.gmail.clientIdPlaceholder"),value:k,onChange:pe=>S(pe.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.byok.clientSecret")}),o.jsx(Ne,{type:"password",placeholder:h("config.gmail.clientSecretPlaceholder"),value:_,onChange:pe=>T(pe.target.value)})]})]})]}),o.jsxs(Xa,{children:[o.jsx(oe,{variant:"outline",onClick:()=>p(!1),children:h("common.cancel")}),o.jsxs(oe,{onClick:le,disabled:E||!k||!_,children:[E?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),h("common.save")," & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.gmail.authCode")}),o.jsx(Ne,{placeholder:h("config.gmail.authCodePlaceholder"),value:C,onChange:pe=>A(pe.target.value),className:"font-mono"})]})}),o.jsxs(Xa,{children:[o.jsx(oe,{variant:"outline",onClick:()=>x("credentials"),children:h("setup.back")}),o.jsxs(oe,{onClick:Oe,disabled:P||!C.trim(),children:[P?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),"Connect"]})]})]})]})}),o.jsx(pa,{open:R,onOpenChange:B,children:o.jsxs(ga,{className:"sm:max-w-lg",children:[o.jsx(ar,{children:o.jsxs(rr,{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"}),h("config.outlook.connect")]})}),se==="credentials"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children: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:h("config.outlook.clientId")}),o.jsx(Ne,{placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",value:ue,onChange:pe=>xe(pe.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:h("config.outlook.tenantIdOptional")}),o.jsx(Ne,{placeholder:h("config.outlook.tenantPlaceholder"),value:ge,onChange:pe=>X(pe.target.value)})]})]})}),o.jsxs(Xa,{children:[o.jsx(oe,{variant:"outline",onClick:()=>B(!1),children:h("common.cancel")}),o.jsxs(oe,{onClick:ft,disabled:V||!ue,children:[V?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),"Save & Connect"]})]})]}):o.jsxs(o.Fragment,{children:[Z&&o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("p",{className:"text-sm mb-4",children:Z.message}),o.jsx("div",{className:"bg-secondary/10 p-4 rounded-lg flex items-center justify-center",children:o.jsx("code",{className:"text-2xl font-mono font-bold tracking-wider",children:Z.userCode})}),o.jsx(oe,{className:"w-full",onClick:()=>window.open(Z.verificationUri,"_blank"),children:"Open Login Page"}),o.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[o.jsx(ds,{size:"sm"})," Waiting for authentication..."]})]}),o.jsx(Xa,{children:o.jsx(oe,{variant:"outline",onClick:()=>B(!1),children:h("common.cancel")})})]})]})}),o.jsx(w6,{open:L,onOpenChange:J}),o.jsx("div",{ref:ie,children:o.jsxs(rt,{children:[o.jsxs(St,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ae(!H),children:[o.jsxs(jt,{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xa,{className:"w-5 h-5 text-orange-500"}),h("config.byok.title")]}),H?o.jsx($o,{className:"w-5 h-5"}):o.jsx(pi,{className:"w-5 h-5"})]}),o.jsx(Kt,{children:h("config.byok.desc")})]}),H&&o.jsxs(ht,{className:"space-y-6 animate-in slide-in-from-top-2",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"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Ne,{type:"password",placeholder:"Client ID",value:t.google_client_id||"",onChange:pe=>e(De=>({...De,google_client_id:pe.target.value}))}),o.jsx(Ne,{type:"password",placeholder:"Client Secret",value:t.google_client_secret||"",onChange:pe=>e(De=>({...De,google_client_secret:pe.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"]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsx(Ne,{type:"password",placeholder:"Client ID",value:t.microsoft_client_id||"",onChange:pe=>e(De=>({...De,microsoft_client_id:pe.target.value}))}),o.jsx(Ne,{type:"password",placeholder:"Client Secret",value:t.microsoft_client_secret||"",onChange:pe=>e(De=>({...De,microsoft_client_secret:pe.target.value}))}),o.jsx(Ne,{placeholder:"Tenant ID",value:t.microsoft_tenant_id||"",onChange:pe=>e(De=>({...De,microsoft_tenant_id:pe.target.value}))})]})]}),o.jsx("div",{className:"flex justify-end mt-4",children:o.jsxs(oe,{onClick:n,disabled:r,variant:"secondary",children:[r?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),"Save API Credentials"]})})]})]})}),o.jsxs(rt,{children:[o.jsxs(St,{children:[o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(Tu,{className:"w-5 h-5 text-primary"})," ",h("config.accounts.title")]}),o.jsx(Kt,{children:h("config.accounts.desc")})]}),o.jsx(ht,{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.jsx("h3",{className:"text-sm font-semibold",children:h("config.accounts.addNew")}),o.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[o.jsxs(oe,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:$,children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center mr-3 text-red-600 font-bold",children:"G"}),o.jsx("div",{className:"text-left font-medium",children:"Connect Gmail"})]}),o.jsxs(oe,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:Ue,children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center mr-3 text-blue-600 font-bold",children:"O"}),o.jsx("div",{className:"text-left font-medium",children:"Connect Outlook"})]}),o.jsxs(oe,{variant:"outline",className:"h-auto py-4 border-dashed justify-start",onClick:()=>J(!0),children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center mr-3 text-slate-600",children:o.jsx(qo,{})}),o.jsx("div",{className:"text-left font-medium",children:"Connect IMAP"})]})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-semibold",children:h("config.accounts.yourAccounts")}),l.accounts.length===0?o.jsx("div",{className:"py-8 text-center text-muted-foreground border-2 border-dashed rounded-lg",children:"No accounts connected"}):o.jsx("div",{className:"space-y-3",children:l.accounts.map(pe=>o.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-card",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[Fe(pe.provider),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-sm",children:pe.email_address}),o.jsx("div",{className:"text-[10px] text-muted-foreground uppercase",children:pe.provider})]})]}),o.jsx(oe,{variant:"ghost",size:"sm",onClick:()=>de(pe.id),className:"text-destructive",children:o.jsx(sr,{className:"w-4 h-4"})})]},pe.id))})]})]})})]})]})}const Rj=v.createContext(void 0);function j6({children:t}){const[e,n]=v.useState(!1),[r,l]=v.useState(!1),[u,d]=v.useState(null),h=v.useRef(null),m=v.useRef(null),p=v.useRef(null),y=v.useRef(null),x=v.useRef(0),w=v.useCallback(()=>{if(y.current&&(y.current.cancel().catch(()=>{}),y.current=null),p.current){try{p.current.stop(),p.current.disconnect()}catch{}p.current=null}h.current&&(h.current.pause(),h.current.currentTime=0,h.current=null),n(!1),l(!1),d(null),x.current++},[]),j=v.useCallback((T,C)=>new Promise((A,E)=>{T.decodeAudioData(C,M=>{const P=T.createBufferSource();P.buffer=M,P.connect(T.destination),P.onended=()=>A(),P.start(0),p.current=P},M=>E(M))}),[]),k=v.useCallback(async(T,C,A={})=>{w();const E=x.current;l(!0),d(C||null);try{const M=await fetch("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:T,...A})});if(!M.ok)throw new Error("TTS generation failed");const P=await M.blob(),U=URL.createObjectURL(P),R=new Audio(U);h.current=R,R.onplay=()=>n(!0),R.onended=()=>{x.current===E&&(n(!1),l(!1),d(null),URL.revokeObjectURL(U))},R.onerror=()=>{x.current===E&&(n(!1),l(!1),d(null),URL.revokeObjectURL(U))},await R.play()}catch(M){console.error("[TTSContext] Speak failed:",M),x.current===E&&(l(!1),d(null))}},[w]),S=v.useCallback(async(T,C,A={})=>{w();const E=x.current;l(!0),d(C||null);try{const M=await fetch("/api/tts/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:T,...A})});if(!M.ok)throw new Error("TTS streaming failed");const P=M.body?.getReader();if(!P)throw new Error("No response body");y.current=P;const U=new TextDecoder;let R="";const B=[];m.current||(m.current=new(window.AudioContext||window.webkitAudioContext));const se=m.current;for(;x.current===E;){const{done:re,value:ue}=await P.read();if(re)break;R+=U.decode(ue,{stream:!0});const xe=R.split(`
|
|
105
|
+
`);R=xe.pop()||"";for(const ge of xe){const X=ge.trim();if(!X||!X.startsWith("data:"))continue;const V=X.slice(5).trim();if(V)try{const F=JSON.parse(V);if(F.audio){const Z=atob(F.audio),ye=new Uint8Array(Z.length);for(let ne=0;ne<Z.length;ne++)ye[ne]=Z.charCodeAt(ne);B.push(ye.buffer),B.length===1&&(n(!0),await j(se,ye.buffer))}}catch{}}}if(x.current===E)for(let re=1;re<B.length&&x.current===E;re++)await j(se,B[re]);x.current===E&&(n(!1),l(!1),d(null))}catch(M){console.error("[TTSContext] Stream failed:",M),x.current===E&&(n(!1),l(!1),d(null))}},[w,j]),_=v.useMemo(()=>({isPlaying:e,isSpeaking:r,speakingId:u,currentAudio:h.current,speak:k,speakStream:S,stop:w}),[e,r,u,k,S,w]);return o.jsx(Rj.Provider,{value:_,children:t})}function _6(){const t=v.useContext(Rj);if(t===void 0)throw new Error("useTTSContext must be used within a TTSProvider");return t}function N6(){const{speak:t,speakStream:e,stop:n,isPlaying:r,isSpeaking:l,speakingId:u}=_6(),d=v.useCallback(async(m,p,y={})=>t(m,p,y),[t]),h=v.useCallback(async(m,p,y={})=>e(m,p,y),[e]);return{speak:d,speakStream:h,stop:n,isPlaying:r,isSpeaking:l,speakingId:u}}function k6(){const{t}=_i(),{state:e,actions:n}=ll(),{speak:r}=N6(),[l,u]=v.useState(e.settings?.tts_provider||"piper_local"),[d,h]=v.useState(e.settings?.tts_voice||null),[m,p]=v.useState(e.settings?.tts_speed||1),[y,x]=v.useState(e.settings?.tts_quality||10),[w,j]=v.useState(e.settings?.tts_auto_play??!0),[k,S]=v.useState([]),[_,T]=v.useState(!1),[C,A]=v.useState(!1),[E,M]=v.useState(!1);v.useEffect(()=>{e.settings&&(u(e.settings.tts_provider||"piper_local"),h(e.settings.tts_voice||null),p(e.settings.tts_speed||1),x(e.settings.tts_quality||10),j(e.settings.tts_auto_play??!0))},[e.settings]),v.useEffect(()=>{(async()=>{T(!0);try{const ue=await fetch("/api/tts/providers");if(ue.ok){const xe=await ue.json();if(xe.success&&xe.providers&&(S(xe.providers),!l&&xe.providers.length>0)){const ge=xe.providers[0];u(ge.id),ge.config?.voices?.length>0&&h(ge.config.voices[0])}}else he.error(t("config.voice.toast.providersFailed"))}catch(ue){console.error("Error fetching TTS providers:",ue),he.error(t("config.voice.toast.serviceFailed"))}finally{T(!1)}})()},[t,l]);const U=k.find(re=>re.id===l)?.config?.voices||[],R=re=>{u(re);const ue=k.find(xe=>xe.id===re);ue&&ue.config?.voices&&ue.config.voices.length>0?h(ue.config.voices[0]):h(null)},B=async()=>{A(!0);try{const re=t("config.voice.testText");await r(re,void 0,{provider:l,voice:d||void 0,speed:m,quality:y})}catch(re){console.error("TTS test failed:",re),he.error(t("config.voice.toast.testFailed"))}finally{A(!1)}},se=async()=>{M(!0),await n.updateSettings({tts_provider:l,tts_voice:d,tts_speed:m,tts_quality:y,tts_auto_play:w})?he.success(t("config.voice.toast.saved")):he.error(t("config.voice.toast.saveFailed")),M(!1)};return o.jsxs(rt,{children:[o.jsxs(St,{children:[o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(rm,{className:"w-5 h-5 text-purple-500"}),t("config.voice.title")]}),o.jsx(Kt,{children:t("config.voice.desc")})]}),o.jsxs(ht,{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between pb-4 border-b text-sm",children:[o.jsxs("div",{className:"space-y-0.5",children:[o.jsx("label",{className:"font-medium",children:t("config.voice.autoTitle")}),o.jsx("p",{className:"text-xs text-muted-foreground",children:t("config.voice.autoHelp")})]}),o.jsxs(oe,{variant:w?"default":"outline",size:"sm",onClick:()=>j(!w),className:"gap-2",children:[w?o.jsx(rm,{className:"w-4 h-4"}):o.jsx(Xw,{className:"w-4 h-4"}),t(w?"common.enabled":"common.disabled")]})]}),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:t("config.voice.provider")}),_?o.jsxs("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20",children:[o.jsx(ds,{size:"sm",className:"mr-2"}),o.jsx("span",{className:"text-xs text-muted-foreground italic",children:t("config.voice.loadingProviders")})]}):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:l,onChange:re=>R(re.target.value),disabled:_,children:[k.length===0&&o.jsx("option",{value:"piper_local",children:t("config.voice.piperLocal")}),k.map(re=>o.jsx("option",{value:re.id,children:re.name},re.id))]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.voice")}),U.length>0?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:d||"",onChange:re=>h(re.target.value),disabled:_,children:[!d&&o.jsx("option",{value:"",children:t("config.voice.selectVoice")}),U.map(re=>o.jsx("option",{value:re,children:re},re))]}):o.jsx("div",{className:"h-10 border rounded-md flex items-center px-3 bg-muted/20 text-xs text-muted-foreground",children:t("config.voice.noVoices")})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.speed")}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.toFixed(1),"x"]})]}),o.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.1",value:m,onChange:re=>p(parseFloat(re.target.value)),className:"w-full h-2 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm font-medium",children:t("config.voice.quality")}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[y,"/20"]})]}),o.jsx("input",{type:"range",min:"1",max:"20",step:"1",value:y,onChange:re=>x(parseInt(re.target.value,10)),className:"w-full h-2 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[o.jsxs(oe,{variant:"outline",onClick:B,disabled:C,children:[C?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(uA,{className:"w-4 h-4 mr-2"}),t("config.voice.test")]}),o.jsxs(oe,{onClick:se,disabled:E,children:[E?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(ma,{className:"w-4 h-4 mr-2"}),t("config.voice.save")]})]})]})]})}function T6(t,e){const n=[],r=(t.ingestion_llm_provider||t.llm_provider||e||"").trim(),l=(t.ingestion_llm_model||t.llm_model||"").trim(),u=r&&l?`${r}:${l}`:"",d=r&&l?`${r}:${l}:pdf`:"",h=t.vision_model_capabilities;if(h&&typeof h=="object"&&!Array.isArray(h))for(const[m,p]of Object.entries(h)){if(!p||typeof p!="object"||Array.isArray(p))continue;const y=p,x=y.state;if(x!=="supported"&&x!=="unsupported"&&x!=="pending_unsupported")continue;const w=m.split(":"),j=w[0]||"unknown",k=w.length>=3&&w[w.length-1]==="pdf",S=k?"pdf":"image",_=k?w.slice(1,-1):w.slice(1),T=_.length>0?_.join(":"):m,C=x==="pending_unsupported"?"unknown":x;n.push({key:m,provider:j,model:T,modality:S,state:C,learnedAt:y.learned_at,expiresAt:y.expires_at,reason:y.reason,isCurrent:m===u||m===d})}return u&&!n.some(m=>m.key===u)&&n.unshift({key:u,provider:r,model:l,modality:"image",state:"unknown",isCurrent:!0}),d&&!n.some(m=>m.key===d)&&n.unshift({key:d,provider:r,model:l,modality:"pdf",state:"unknown",isCurrent:!0}),n.sort((m,p)=>m.isCurrent&&!p.isCurrent?-1:!m.isCurrent&&p.isCurrent?1:`${m.provider}:${m.model}`.localeCompare(`${p.provider}:${p.model}`)),n}function E6(t){return t==="supported"?"default":t==="unsupported"?"destructive":"secondary"}function Qb(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function C6({localSettings:t,setLocalSettings:e,handleSaveSettings:n,savingSettings:r,handleTestConnection:l,testingLlm:u,providersWithSaved:d,modelsWithSaved:h,ingestionProvidersWithSaved:m,ingestionModelsWithSaved:p,embedProvidersWithSaved:y,embedModelsWithSaved:x,handleProviderChange:w,handleIngestionProviderChange:j,handleEmbedProviderChange:k,DEFAULT_PROVIDER:S}){const{t:_}=_i(),T=T6(t,S),C=(E,M)=>{e(P=>{const U=P?.vision_model_capabilities&&typeof P.vision_model_capabilities=="object"&&!Array.isArray(P.vision_model_capabilities)?{...P.vision_model_capabilities}:{};if(M==="unknown")delete U[E];else{const R=new Date().toISOString(),B=M==="supported"?180:30,se=new Date(Date.now()+B*24*60*60*1e3).toISOString();U[E]={...U[E]||{},state:M,learned_at:R,expires_at:se,reason:"manual_override"}}return{...P,vision_model_capabilities:U}})},A=()=>{e(E=>({...E,vision_model_capabilities:{}}))};return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs(rt,{children:[o.jsx(St,{children:o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(ma,{className:"w-5 h-5 text-indigo-500"}),"AI Model Configuration"]})}),o.jsxs(ht,{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"chat-llm-provider-select",children:"Chat LLM Provider"}),o.jsxs("select",{id:"chat-llm-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.llm_provider||S,onChange:E=>w(E.target.value),children:[o.jsx("option",{value:S,children:"RealTimeX AI"}),d.filter(E=>E.provider!==S).map(E=>o.jsx("option",{value:E.provider,children:E.name||E.provider},E.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"chat-llm-model-select",children:"Chat LLM Model"}),o.jsx("select",{id:"chat-llm-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.llm_model||"",onChange:E=>e(M=>({...M,llm_model:E.target.value})),children:h.map(E=>o.jsx("option",{value:E.id,children:E.name||E.id},E.id))})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"ingestion-llm-provider-select",children:"Ingestion LLM Provider"}),o.jsxs("select",{id:"ingestion-llm-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.ingestion_llm_provider||t.llm_provider||S,onChange:E=>j(E.target.value),children:[o.jsx("option",{value:S,children:"RealTimeX AI"}),m.filter(E=>E.provider!==S).map(E=>o.jsx("option",{value:E.provider,children:E.name||E.provider},E.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"ingestion-llm-model-select",children:"Ingestion LLM Model"}),o.jsx("select",{id:"ingestion-llm-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.ingestion_llm_model||t.llm_model||"",onChange:E=>e(M=>({...M,ingestion_llm_model:E.target.value})),children:p.map(E=>o.jsx("option",{value:E.id,children:E.name||E.id},E.id))})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"embedding-provider-select",children:"Embedding Provider"}),o.jsxs("select",{id:"embedding-provider-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.embedding_provider||S,onChange:E=>k(E.target.value),children:[o.jsx("option",{value:S,children:"RealTimeX Embed"}),y.filter(E=>E.provider!==S).map(E=>o.jsx("option",{value:E.provider,children:E.name||E.provider},E.provider))]}),o.jsx("label",{className:"text-sm font-medium",htmlFor:"embedding-model-select",children:"Embedding Model"}),o.jsx("select",{id:"embedding-model-select",className:"w-full h-10 border rounded-md px-3 bg-background",value:t.embedding_model||"",onChange:E=>e(M=>({...M,embedding_model:E.target.value})),children:x.map(E=>o.jsx("option",{value:E.id,children:E.name||E.id},E.id))})]})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(oe,{variant:"outline",onClick:l,disabled:u,children:"Test Connection"}),o.jsxs(oe,{onClick:n,disabled:r,children:[r?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),"Save AI Config"]})]})]})]}),o.jsx(k6,{}),o.jsxs(rt,{children:[o.jsxs(St,{children:[o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(tm,{className:"w-5 h-5 text-primary"}),"Vision Capability Overrides"]}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Review and edit learned multimodal support per model. Set to ",o.jsx("span",{className:"font-medium",children:"Unknown"})," to let Folio probe again."]})]}),o.jsxs(ht,{className:"space-y-4",children:[T.length===0?o.jsx("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground",children:"No model capability entries yet."}):o.jsx("div",{className:"space-y-3",children:T.map(E=>o.jsx("div",{className:"rounded-md border p-3",children:o.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("p",{className:"font-medium break-all",children:[E.provider," / ",E.model]}),o.jsx(wt,{variant:"outline",children:E.modality}),E.isCurrent?o.jsx(wt,{variant:"outline",children:"Current"}):null,o.jsx(wt,{variant:E6(E.state),children:E.state})]}),o.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[E.reason?`reason: ${E.reason}`:"reason: not set",E.expiresAt?` • expires: ${new Date(E.expiresAt).toLocaleString()}`:""]})]}),o.jsxs("div",{className:"w-full md:w-[180px]",children:[o.jsx("label",{className:"sr-only",htmlFor:`vision-state-${Qb(E.key)}`,children:"Vision capability state"}),o.jsxs("select",{id:`vision-state-${Qb(E.key)}`,className:"w-full h-10 border rounded-md px-3 bg-background",value:E.state,onChange:M=>C(E.key,M.target.value),children:[o.jsx("option",{value:"unknown",children:"Unknown (auto-probe)"}),o.jsx("option",{value:"supported",children:"Supported"}),o.jsx("option",{value:"unsupported",children:"Unsupported"})]})]})]})},E.key))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(oe,{variant:"outline",onClick:A,children:"Reset Learned Map"}),o.jsxs(oe,{onClick:n,disabled:r,children:[r?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),"Save Capability Overrides"]})]})]})]}),o.jsxs(rt,{children:[o.jsx(St,{children:o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(sl,{className:"w-5 h-5 text-primary"})," System Settings"]})}),o.jsxs(ht,{className:"space-y-6",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",htmlFor:"sync-interval-input",children:"Sync Interval (minutes)"}),o.jsx(Ne,{id:"sync-interval-input",type:"number",value:t.sync_interval_minutes||5,onChange:E=>e(M=>({...M,sync_interval_minutes:parseInt(E.target.value)}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",htmlFor:"storage-path-input",children:"Storage Path"}),o.jsx(Ne,{id:"storage-path-input",placeholder:"/path/to/storage",value:t.storage_path||"",onChange:E=>e(M=>({...M,storage_path:E.target.value}))})]})]}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(oe,{onClick:n,disabled:r,children:[r?o.jsx(ds,{size:"sm",className:"mr-2"}):o.jsx(an,{className:"w-4 h-4 mr-2"}),"Save System Settings"]})})]})]})]})}function A6(){const{t}=_i(),{supabase:e}=ll(),[n,r]=v.useState([]),[l,u]=v.useState(!0),[d,h]=v.useState(!1),[m,p]=v.useState("credentials"),[y,x]=v.useState(""),[w,j]=v.useState(""),[k,S]=v.useState(""),[_,T]=v.useState(""),[C,A]=v.useState(!1);v.useEffect(()=>{E()},[]);const E=async()=>{try{const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,B=await be.getAccounts(R);B.data&&B.data.accounts&&r(B.data.accounts)}catch(R){console.error(R)}finally{u(!1)}},M=R=>{T(R);try{const B=JSON.parse(R),se=B.web||B.installed;se?.client_id&&se?.client_secret&&(x(se.client_id),j(se.client_secret))}catch{}},P=async()=>{if(!y||!w){he.error(t("config.gmail.error.missingCreds")||"Please provide Client ID and Secret");return}try{A(!0);const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,B=await be.getGoogleDriveAuthUrl(y.trim(),R);B.data?.authUrl?(window.open(B.data.authUrl,"_blank","width=600,height=700"),p("auth_code")):he.error(t("config.gmail.error.authUrl")||"Failed to generate auth URL")}catch{he.error(t("config.gmail.error.authUrl")||"Failed to generate auth URL")}finally{A(!1)}},U=async()=>{if(!k){he.error(t("config.gmail.error.missingCode")||"Please provide Auth Code");return}try{A(!0);const R=e?(await e.auth.getSession()).data.session?.access_token:void 0,B=await be.connectGoogleDrive(k.trim(),y.trim(),w.trim(),R);B.data?.success?(he.success("Successfully connected to Google Drive"),h(!1),S(""),E()):he.error(B.error?.message||"Failed to connect")}catch{he.error("An error occurred while connecting")}finally{A(!1)}};return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsx(pa,{open:d,onOpenChange:h,children:o.jsxs(ga,{className:"sm:max-w-lg",children:[o.jsxs(ar,{children:[o.jsxs(rr,{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:"G"}),"Connect Google Drive"]}),o.jsx(bi,{children:m==="credentials"?"Provide your Google Cloud project credentials.":"Paste the authorization code."})]}),m==="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.jsx("label",{className:"text-sm font-medium",children:"Paste credentials JSON"}),o.jsx("textarea",{className:"w-full h-24 p-3 text-xs font-mono border rounded-lg bg-secondary/10 resize-none focus:outline-none focus:ring-2 focus:ring-primary",placeholder:'{"installed":{"client_id":"...","client_secret":"..."}}',value:_,onChange:R=>M(R.target.value)})]}),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(Ne,{placeholder:"Enter Client ID",value:y,onChange:R=>x(R.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Client Secret"}),o.jsx(Ne,{type:"password",placeholder:"Enter Client Secret",value:w,onChange:R=>j(R.target.value)})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[o.jsx(oe,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),o.jsxs(oe,{onClick:P,disabled:C||!y||!w,children:[C?"Generating...":"Next"," ",o.jsx(pi,{className:"w-4 h-4 ml-1"})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Authorization Code"}),o.jsx(Ne,{placeholder:"Paste the code from Google here",value:k,onChange:R=>S(R.target.value),autoFocus:!0}),o.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"A new window was opened for you to authorize the app. Once you approve, paste the code here."})]})}),o.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[o.jsx(oe,{variant:"ghost",onClick:()=>p("credentials"),children:"Back"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(oe,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),o.jsx(oe,{onClick:U,disabled:C||!k,children:C?"Connecting...":"Connect Drive"})]})]})]})]})}),o.jsxs(rt,{children:[o.jsxs(St,{children:[o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(g0,{className:"w-5 h-5 text-sky-500"}),"Cloud Storage"]}),o.jsx(Kt,{children:"Connect cloud drives like Google Drive or Dropbox to allow Folio to read and write documents directly to your cloud."})]}),o.jsx(ht,{children:o.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[o.jsxs(rt,{className:"flex flex-col border-dashed hover:border-solid hover:border-blue-300 transition-colors",children:[o.jsxs(St,{className:"pb-3 text-center",children:[o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center text-blue-600 dark:text-blue-400 mb-2",children:o.jsx(vC,{className:"w-6 h-6"})}),o.jsx(jt,{className:"text-base",children:"Google Drive"}),o.jsx(Kt,{className:"text-xs",children:"Sync files to and from Google Drive"})]}),o.jsx(ht,{className:"flex-1 flex flex-col justify-end pt-0",children:n.some(R=>R.provider==="google_drive"&&R.is_connected)?o.jsxs(oe,{className:"w-full gap-2 text-xs",variant:"secondary",disabled:!0,children:[o.jsx(Ks,{className:"w-4 h-4 text-green-500"}),"Connected"]}):o.jsx(oe,{className:"w-full gap-2 text-xs",variant:"outline",onClick:()=>{p("credentials"),h(!0)},children:"Connect Google Drive"})})]}),o.jsxs(rt,{className:"flex flex-col border-dashed opacity-50 cursor-not-allowed",children:[o.jsxs(St,{className:"pb-3 text-center",children:[o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl bg-blue-100 flex items-center justify-center text-blue-600 mb-2",children:o.jsx(g0,{className:"w-6 h-6"})}),o.jsx(jt,{className:"text-base",children:"Dropbox"}),o.jsx(Kt,{className:"text-xs",children:"Coming soon"})]}),o.jsx(ht,{className:"flex-1 flex flex-col justify-end pt-0",children:o.jsx(oe,{className:"w-full gap-2 text-xs",variant:"outline",disabled:!0,children:"Coming Soon"})})]})]})})]})]})}function R6(t,e){return t?typeof t=="string"?t:typeof t=="object"&&"message"in t?t.message:e:e}const O6=["string","number","date","currency","string[]"];function M6(){const[t,e]=v.useState(null),[n,r]=v.useState(!0),[l,u]=v.useState(!1),[d,h]=v.useState(""),[m,p]=v.useState([]),[y,x]=v.useState(null),[w,j]=v.useState([]),[k,S]=v.useState(!1),[_,T]=v.useState(!1),[C,A]=v.useState(""),[E,M]=v.useState(!1),[P,U]=v.useState(null),[R,B]=v.useState([]),[se,re]=v.useState(""),[ue,xe]=v.useState("");v.useEffect(()=>{(async()=>{r(!0);try{const fe=hs(),{data:le}=await(fe?.auth.getSession()??Promise.resolve({data:{session:null}})),Oe=le.session?.access_token??null;e(Oe);const Ue=await be.getBaselineConfig(Oe);Ue.data&&(Ue.data.config?(h(Ue.data.config.context??""),p(Ue.data.config.fields),x(Ue.data.config.version)):p(Ue.data.defaults))}catch{he.error("Failed to load baseline config")}finally{r(!1)}})()},[]);const ge=v.useCallback(async()=>{try{const fe=(await be.getSDKChatProviders())?.data?.providers??[];B(fe),fe.length>0&&!se&&(re(fe[0].provider),xe(fe[0].models?.[0]?.id??""))}catch{}},[se]);v.useEffect(()=>{_&&R.length===0&&ge()},[_,R.length,ge]);const X=async()=>{const $=await be.getBaselineConfigHistory(t);$.data&&j($.data.history),S(!0)},V=$=>p(fe=>fe.map(le=>le.key===$?{...le,enabled:!le.enabled}:le)),F=($,fe)=>p(le=>le.map(Oe=>Oe.key===$?{...Oe,description:fe}:Oe)),Z=()=>p($=>[...$,{key:"",type:"string",description:"",enabled:!0,is_default:!1}]),ye=($,fe)=>p(le=>le.map((Oe,Ue)=>Ue===$?{...Oe,...fe}:Oe)),ne=$=>p(fe=>fe.filter((le,Oe)=>Oe!==$)),D=async()=>{if(m.filter(le=>le.enabled).length===0){he.error("At least one field must be enabled");return}if(m.filter(le=>!le.is_default&&le.enabled&&(!le.key.trim()||!le.description.trim())).length>0){he.error("Custom fields require both a key and a description");return}u(!0);try{const le=await be.saveBaselineConfig({context:d||null,fields:m,activate:!0},t);le.data?.success?(x(le.data.config.version),he.success(`Baseline config saved as v${le.data.config.version}`),k&&X()):he.error("Failed to save config")}finally{u(!1)}},L=async($,fe)=>{(await be.activateBaselineConfig($,t)).data?.success&&(x(fe),he.success(`v${fe} is now active`),X())},J=async()=>{if(C.trim()){M(!0),U(null);try{const $=await be.suggestBaselineConfig({description:C,provider:se||void 0,model:ue||void 0},t);$.data?.suggestion?(U($.data.suggestion),he.success("Suggestion ready — review and apply below.")):he.error(R6($.error,"Suggestion failed."))}catch{he.error("LLM suggestion failed.")}finally{M(!1)}}},H=()=>{P&&(h(P.context),p($=>{const fe=new Set($.map(Oe=>Oe.key)),le=P.fields.filter(Oe=>Oe.key&&!fe.has(Oe.key));return[...$,...le]}),U(null),A(""),T(!1),he.success("Suggestion applied — review fields then Save & Activate."))};if(n)return o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(ds,{size:"md"})});const ae=m.filter($=>$.is_default),ie=m.filter($=>!$.is_default);return o.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[o.jsxs(rt,{className:"border-violet-500/20 bg-violet-500/5",children:[o.jsxs(St,{className:"cursor-pointer select-none",onClick:()=>{T($=>!$),U(null)},children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs(jt,{className:"flex items-center gap-2 text-base",children:[o.jsx(Cn,{className:"w-4 h-4 text-violet-500"}),"Magic Composer"]}),_?o.jsx(cu,{className:"w-4 h-4 text-muted-foreground"}):o.jsx($o,{className:"w-4 h-4 text-muted-foreground"})]}),!_&&o.jsx(Kt,{children:"Describe your workflow — AI will suggest a context string and custom fields."})]}),_&&o.jsxs(ht,{className:"space-y-4 pt-0",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe your workflow — AI will suggest a context string and custom fields tailored to your documents."}),R.length>0&&o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx($m,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("select",{value:`${se}::${ue}`,onChange:$=>{const[fe,le]=$.target.value.split("::");re(fe),xe(le)},className:"text-xs rounded-lg border border-border/40 bg-background px-2 py-1 flex-1 max-w-xs",children:R.flatMap($=>($.models??[]).map(fe=>o.jsxs("option",{value:`${$.provider}::${fe.id}`,children:[$.provider," / ",fe.id]},`${$.provider}::${fe.id}`)))}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"for suggestion"})]}),o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx("textarea",{className:`flex-1 min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm resize-y
|
|
106
|
+
focus:outline-none focus:ring-2 focus:ring-ring placeholder:text-muted-foreground`,placeholder:'e.g. "I process SaaS vendor invoices, software licences, and employment contracts for a startup. Vendors include Stripe, AWS, and GitHub. Documents are in English and French."',value:C,onChange:$=>A($.target.value),onKeyDown:$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)&&J()}}),o.jsx(oe,{onClick:J,disabled:E||!C.trim(),className:`h-10 w-10 p-0 rounded-xl flex items-center justify-center bg-violet-500 hover:bg-violet-600
|
|
107
|
+
text-white shadow-lg shadow-violet-500/20 hover:scale-105 active:scale-95 transition-all`,title:"Suggest baseline config with AI (⌘↵)",children:E?o.jsx(Qe,{className:"w-4 h-4 animate-spin"}):o.jsx(Cn,{className:"w-4 h-4"})})]}),P&&o.jsxs("div",{className:`rounded-xl border border-violet-500/20 bg-violet-500/5 p-4 space-y-3
|
|
108
|
+
animate-in slide-in-from-bottom-2 duration-300`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-xs font-semibold text-violet-600 dark:text-violet-400",children:"AI Suggestion"}),o.jsx("button",{type:"button",onClick:()=>U(null),className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(Ps,{className:"w-3.5 h-3.5"})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Extraction Context"}),o.jsx("p",{className:"text-xs bg-muted/60 rounded-lg px-3 py-2 leading-relaxed",children:P.context})]}),P.fields.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:["Custom Fields to Add (",P.fields.length,")"]}),o.jsx("div",{className:"space-y-1.5",children:P.fields.map(($,fe)=>o.jsxs("div",{className:"flex items-start gap-2 bg-muted/60 rounded-lg px-3 py-2",children:[o.jsx("code",{className:"text-xs font-mono mt-0.5 shrink-0",children:$.key}),o.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0",children:$.type}),o.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:$.description})]},fe))})]}),P.fields.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No additional custom fields suggested for this workflow."}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(oe,{size:"sm",onClick:H,className:`flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest
|
|
109
|
+
bg-violet-500 hover:bg-violet-600 text-white`,children:"Apply Suggestion"}),o.jsx(oe,{size:"sm",variant:"outline",onClick:()=>U(null),className:"h-8 px-3 rounded-xl",children:"Discard"})]})]})]})]}),o.jsxs(rt,{children:[o.jsxs(St,{children:[o.jsxs(jt,{className:"flex items-center gap-2",children:[o.jsx(Uw,{className:"w-5 h-5 text-violet-500"}),"Extraction Context"]}),o.jsx(Kt,{children:"Describe the kinds of documents you typically process. This context is injected directly into the extraction prompt, helping the model specialise for your workflow."})]}),o.jsx(ht,{children:o.jsx("textarea",{className:`w-full min-h-[96px] rounded-md border bg-background px-3 py-2 text-sm resize-y
|
|
110
|
+
focus:outline-none focus:ring-2 focus:ring-ring placeholder:text-muted-foreground`,placeholder:'e.g. "I primarily process SaaS vendor invoices and software contracts. Documents are in English and French. Frequent vendors include Stripe, AWS, and GitHub."',value:d,onChange:$=>h($.target.value)})})]}),o.jsxs(rt,{children:[o.jsxs(St,{children:[o.jsx(jt,{className:"text-base",children:"Default Fields"}),o.jsx(Kt,{children:"Built-in fields extracted from every document. Toggle to enable or disable. Edit the description to give the model a better hint for your documents."})]}),o.jsx(ht,{className:"space-y-3",children:ae.map($=>o.jsxs("div",{className:"flex items-start gap-3 group",children:[o.jsx("button",{type:"button",onClick:()=>V($.key),className:`mt-0.5 flex-shrink-0 w-5 h-5 rounded border-2 flex items-center justify-center transition-colors
|
|
111
|
+
${$.enabled?"bg-violet-500 border-violet-500":"border-muted-foreground/40 bg-background"}`,children:$.enabled&&o.jsx(an,{className:"w-3 h-3 text-white"})}),o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"text-xs font-mono bg-muted px-1.5 py-0.5 rounded",children:$.key}),o.jsx(wt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:$.type})]}),o.jsx(Ne,{className:"h-7 text-xs",value:$.description,disabled:!$.enabled,onChange:fe=>F($.key,fe.target.value)})]})]},$.key))})]}),o.jsxs(rt,{children:[o.jsx(St,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx(jt,{className:"text-base",children:"Custom Fields"}),o.jsx(Kt,{className:"mt-1",children:"Add fields specific to your workflow — project codes, contract types, department names, or any entity your documents carry."})]}),o.jsxs(oe,{variant:"outline",size:"sm",onClick:Z,className:"gap-1.5",children:[o.jsx(er,{className:"w-3.5 h-3.5"}),"Add Field"]})]})}),ie.length>0&&o.jsx(ht,{className:"space-y-4",children:m.map(($,fe)=>$.is_default?null:o.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_32px] gap-2 items-start",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Key"}),o.jsx(Ne,{className:"h-8 text-xs font-mono",placeholder:"e.g. project_code",value:$.key,onChange:le=>ye(fe,{key:le.target.value.toLowerCase().replace(/\s+/g,"_")})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Type"}),o.jsx("select",{className:"w-full h-8 text-xs border rounded-md px-2 bg-background",value:$.type,onChange:le=>ye(fe,{type:le.target.value}),children:O6.map(le=>o.jsx("option",{value:le,children:le},le))})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-muted-foreground",children:"Description / hint for the model"}),o.jsx(Ne,{className:"h-8 text-xs",placeholder:"What this field contains",value:$.description,onChange:le=>ye(fe,{description:le.target.value})})]}),o.jsx("button",{type:"button",onClick:()=>ne(fe),className:"mt-6 p-1 rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",children:o.jsx(sr,{className:"w-3.5 h-3.5"})})]},fe))})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("button",{type:"button",onClick:k?()=>S(!1):X,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(bC,{className:"w-3.5 h-3.5"}),"Version history",y!==null&&o.jsxs(wt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-1",children:["v",y," active"]}),k?o.jsx(cu,{className:"w-3 h-3"}):o.jsx($o,{className:"w-3 h-3"})]}),o.jsxs(oe,{onClick:D,disabled:l,className:"gap-2",children:[l?o.jsx(ds,{size:"sm"}):o.jsx(an,{className:"w-4 h-4"}),"Save & Activate"]})]}),k&&o.jsx(rt,{children:o.jsx(ht,{className:"pt-4 space-y-2",children:w.length===0?o.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No saved versions yet"}):w.map($=>o.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg border bg-muted/30",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"text-sm font-mono font-medium",children:["v",$.version]}),$.is_active&&o.jsx(wt,{className:"text-[10px] px-1.5 py-0 bg-violet-500 text-white",children:"active"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:new Date($.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",$.fields.filter(fe=>fe.enabled).length," fields",$.context?" · context set":""]})]}),!$.is_active&&o.jsx(oe,{variant:"outline",size:"sm",className:"h-6 text-xs px-2",onClick:()=>L($.id,$.version),children:"Activate"})]},$.id))})})]})}const Cp=v.createContext(null),Oj=v.forwardRef(({className:t,defaultValue:e,value:n,onValueChange:r,...l},u)=>{const[d,h]=v.useState(e||""),m=n!==void 0?n:d,p=v.useCallback(y=>{r&&r(y),n===void 0&&h(y)},[r,n]);return o.jsx(Cp.Provider,{value:{value:m,onValueChange:p},children:o.jsx("div",{ref:u,className:t,...l})})});Oj.displayName="Tabs";const Mj=v.forwardRef(({className:t,...e},n)=>o.jsx("div",{ref:n,className:ve("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));Mj.displayName="TabsList";const ko=v.forwardRef(({className:t,value:e,onClick:n,...r},l)=>{const u=v.useContext(Cp);if(!u)throw new Error("TabsTrigger must be used within Tabs");const d=u.value===e;return o.jsx("button",{ref:l,type:"button",role:"tab","aria-selected":d,"data-state":d?"active":"inactive",className:ve("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),onClick:h=>{u.onValueChange(e),n?.(h)},...r})});ko.displayName="TabsTrigger";const To=v.forwardRef(({className:t,value:e,...n},r)=>{const l=v.useContext(Cp);if(!l)throw new Error("TabsContent must be used within Tabs");return l.value!==e?null:o.jsx("div",{ref:r,role:"tabpanel","data-state":"active",className:ve("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n})});To.displayName="TabsContent";const Ha="realtimexai";function D6(){const{state:t,actions:e}=ll(),{t:n}=_i(),[r,l]=v.useState(!1),[u,d]=v.useState(!1),[h,m]=v.useState({});b6({system_instruction:n("config.agent.systemInstruction"),data:{accounts_count:t.accounts.length,connected_providers:t.accounts.map(X=>X.provider),rules_count:t.rules.length,active_rules:t.rules.filter(X=>X.is_enabled).map(X=>X.name),current_settings:{llm_provider:h.llm_provider,llm_model:h.llm_model,ingestion_llm_provider:h.ingestion_llm_provider,ingestion_llm_model:h.ingestion_llm_model}}});const[p,y]=v.useState([]),[x,w]=v.useState([]);v.useEffect(()=>{(async()=>{try{const F=await be.getChatProviders();F.data&&y(F.data.providers||[])}catch(F){console.error(F)}})(),(async()=>{try{const F=await be.getEmbedProviders();F.data&&w(F.data.providers||[])}catch(F){console.error(F)}})()},[n]);const k=p.find(X=>X.provider===(h.llm_provider||Ha))?.models||[],S=h.ingestion_llm_provider||h.llm_provider||Ha,T=p.find(X=>X.provider===S)?.models||[],A=x.find(X=>X.provider===(h.embedding_provider||Ha))?.models||[],E=v.useMemo(()=>!h.llm_model||k.some(V=>V.id===h.llm_model)?k:[{id:h.llm_model,name:`${h.llm_model} (saved)`},...k],[k,h.llm_model]),M=v.useMemo(()=>!h.llm_provider||h.llm_provider===Ha||p.some(V=>V.provider===h.llm_provider)?p:[{provider:h.llm_provider,name:`${h.llm_provider} (saved)`,models:[]},...p],[p,h.llm_provider]),P=v.useMemo(()=>{const X=h.ingestion_llm_model||h.llm_model;return!X||T.some(F=>F.id===X)?T:[{id:X,name:`${X} (saved)`},...T]},[T,h.ingestion_llm_model,h.llm_model]),U=v.useMemo(()=>!h.ingestion_llm_provider||h.ingestion_llm_provider===Ha||p.some(V=>V.provider===h.ingestion_llm_provider)?p:[{provider:h.ingestion_llm_provider,name:`${h.ingestion_llm_provider} (saved)`,models:[]},...p],[p,h.ingestion_llm_provider]),R=v.useMemo(()=>!h.embedding_model||A.some(V=>V.id===h.embedding_model)?A:[{id:h.embedding_model,name:`${h.embedding_model} (saved)`},...A],[A,h.embedding_model]),B=v.useMemo(()=>!h.embedding_provider||h.embedding_provider===Ha||x.some(V=>V.provider===h.embedding_provider)?x:[{provider:h.embedding_provider,name:`${h.embedding_provider} (saved)`,models:[]},...x],[x,h.embedding_provider]),se=X=>{const V=p.find(F=>F.provider===X);m(F=>({...F,llm_provider:X,llm_model:V?.models?.[0]?.id||""}))},re=X=>{const V=x.find(F=>F.provider===X);m(F=>({...F,embedding_provider:X,embedding_model:V?.models?.[0]?.id||""}))},ue=X=>{const V=p.find(F=>F.provider===X);m(F=>({...F,ingestion_llm_provider:X,ingestion_llm_model:V?.models?.[0]?.id||""}))},xe=async()=>{d(!0);try{const X=await be.testLlm({llm_provider:h.llm_provider||void 0,llm_model:h.llm_model||void 0});X.data?.success?he.success(X.data.message):he.error(n("config.toast.connectionFailed"))}catch{he.error(n("config.toast.connectionFailed"))}finally{d(!1)}};v.useEffect(()=>{e.fetchAccounts(),e.fetchRules(),e.fetchSettings()},[]),v.useEffect(()=>{t.settings&&m(t.settings)},[t.settings]);const ge=async()=>{l(!0);const X=await e.updateSettings(h);l(!1),X&&he.success(n("config.toast.settingsSaved"))};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-6 animate-in fade-in duration-500 flex flex-col h-full",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Configuration"}),o.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your connected integrations and AI providers."})]})}),o.jsxs(Oj,{defaultValue:"mail",className:"w-full",children:[o.jsxs(Mj,{className:"grid w-full grid-cols-4 max-w-lg h-12",children:[o.jsx(ko,{value:"mail",className:"h-10",children:"Mail"}),o.jsx(ko,{value:"storage",className:"h-10",children:"Storage"}),o.jsx(ko,{value:"intelligence",className:"h-10",children:"Intelligence"}),o.jsx(ko,{value:"baseline",className:"h-10",children:"Baseline"})]}),o.jsxs("div",{className:"mt-8",children:[o.jsx(To,{value:"mail",className:"m-0 border-none p-0 outline-none",children:o.jsx(S6,{localSettings:h,setLocalSettings:m,handleSaveSettings:ge,savingSettings:r})}),o.jsx(To,{value:"storage",className:"m-0 border-none p-0 outline-none",children:o.jsx(A6,{})}),o.jsx(To,{value:"intelligence",className:"m-0 border-none p-0 outline-none",children:o.jsx(C6,{localSettings:h,setLocalSettings:m,handleSaveSettings:ge,savingSettings:r,handleTestConnection:xe,testingLlm:u,providersWithSaved:M,modelsWithSaved:E,embedProvidersWithSaved:B,embedModelsWithSaved:R,ingestionProvidersWithSaved:U,ingestionModelsWithSaved:P,handleProviderChange:se,handleEmbedProviderChange:re,handleIngestionProviderChange:ue,DEFAULT_PROVIDER:Ha})}),o.jsx(To,{value:"baseline",className:"m-0 border-none p-0 outline-none",children:o.jsx(M6,{})})]})]})]})}function P6({status:t,onSnooze:e,onOpenModal:n}){const[r,l]=v.useState(!1),[u,d]=v.useState(!1),h=p=>{const y=new Date(Date.now()+p*60*60*1e3);e?.(y),he.success(`Reminder snoozed until ${y.toLocaleTimeString()}`)},m=["Enhanced TTS voice support (Piper, Supertonic)","Real-time audio streaming infrastructure","Improved AI model provider resolution"];return r?o.jsx("div",{className:"fixed top-24 left-1/2 -translate-x-1/2 z-[60] animate-in slide-in-from-top-5",children:o.jsxs("button",{onClick:()=>l(!1),className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-amber-950 rounded-full shadow-2xl shadow-amber-500/20 hover:scale-105 active:scale-95 transition-all text-[11px] font-black uppercase tracking-widest border border-amber-400/50 backdrop-blur-md",children:[o.jsx(Cn,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"System Update Available"})]})}):o.jsx("div",{className:"fixed top-0 left-0 right-0 z-[60] animate-in slide-in-from-top-10 duration-700",children:o.jsxs("div",{className:"bg-amber-500 text-amber-950 px-6 py-4 shadow-2xl border-b border-amber-400/50 backdrop-blur-xl relative overflow-hidden",children:[o.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2 blur-3xl pointer-events-none"}),o.jsx("div",{className:"max-w-5xl mx-auto relative",children:o.jsxs("div",{className:"flex items-start gap-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-950/10 flex items-center justify-center shrink-0",children:o.jsx(Ww,{className:"h-6 w-6"})}),o.jsxs("div",{className:"flex-1 space-y-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-black tracking-tight flex items-center gap-2",children:["Foundational Update Required",o.jsxs("span",{className:"text-[10px] px-2 py-0.5 bg-amber-950/10 rounded-full border border-amber-950/20 uppercase tracking-widest font-black",children:["v",t.appVersion]})]}),o.jsx("p",{className:"text-sm font-medium opacity-80 mt-1 max-w-2xl leading-relaxed",children:"New architecture components detected. Migration is necessary to enable real-time audio streaming and enhanced AI provider resolution."})]}),o.jsx(oe,{size:"icon",variant:"ghost",className:"h-8 w-8 text-amber-950 hover:bg-amber-950/10 rounded-full shrink-0",onClick:()=>l(!0),children:o.jsx(Gw,{className:"h-4 w-4"})})]}),u&&o.jsxs("div",{className:"bg-amber-950/5 rounded-2xl p-4 border border-amber-950/10 animate-in fade-in slide-in-from-top-2",children:[o.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-60 mb-3",children:"Protocol Improvements:"}),o.jsx("ul",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-2",children:m.map((p,y)=>o.jsxs("li",{className:"text-xs flex items-center gap-2 font-bold",children:[o.jsx("div",{className:"w-1 h-1 rounded-full bg-amber-950/40"}),p]},y))})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[o.jsx(oe,{size:"sm",className:"h-9 px-6 bg-amber-950 text-amber-50 hover:bg-black rounded-full font-black text-[10px] uppercase tracking-[0.2em] shadow-xl shadow-amber-950/20 active:scale-95 transition-all",onClick:n,children:"Apply Update Now"}),o.jsx("div",{className:"h-4 w-px bg-amber-950/20 hidden sm:block mx-1"}),o.jsxs(oe,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full",onClick:()=>h(1),children:[o.jsx(sl,{className:"h-3.5 w-3.5 mr-2 opacity-60"}),"Snooze 1h"]}),o.jsxs(oe,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full",onClick:()=>h(24),children:[o.jsx(Bw,{className:"h-3.5 w-3.5 mr-2 opacity-60"}),"Tomorrow"]}),o.jsxs(oe,{size:"sm",variant:"ghost",className:"h-9 text-amber-950 font-black text-[10px] uppercase tracking-widest hover:bg-amber-950/10 rounded-full ml-auto",onClick:()=>d(!u),children:[u?o.jsx(cu,{className:"h-4 w-4"}):o.jsx($o,{className:"h-4 w-4"}),o.jsx("span",{className:"ml-2",children:u?"Hide Details":"Inspect Protocol"})]})]})]})]})})]})})}function L6({open:t,onOpenChange:e,status:n,onSnooze:r}){const l=Fo(),u=S=>{const _=new Date(Date.now()+S*60*60*1e3);r?.(_),he.success(`Reminder snoozed until ${_.toLocaleTimeString()}`),e(!1)},[d,h]=v.useState(!1),[m,p]=v.useState([]),[y,x]=v.useState(""),w=v.useRef(null),j=v.useMemo(()=>{const S=l?.url;if(!S)return"";try{return new URL(S).hostname.split(".")[0]||""}catch{return""}},[l?.url]);v.useEffect(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth"})},[m]);const k=async()=>{if(!j){he.error("Foundation Error: Missing Project ID");return}if(!y){he.error("Security Error: Provide a Supabase Access Token.");return}h(!0),p(["[System] Initializing migration protocol...","[Auth] Verifying project credentials..."]);try{const S=await fetch("/api/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRef:j,accessToken:y})});if(!S.ok)throw new Error(`Migration engine failed: ${S.status}`);const _=S.body?.getReader();if(!_)throw new Error("Failed to initialize log stream.");const T=new TextDecoder;let C="",A=!1;for(;;){const{done:E,value:M}=await _.read();if(E)break;C+=T.decode(M,{stream:!0});const P=C.split(`
|
|
112
|
+
`);C=P.pop()||"";for(const U of P){const R=U.trim();if(!(!R||!R.startsWith("data: ")))try{const B=JSON.parse(R.substring(6));B.type==="done"?B.data==="success"&&(A=!0):B.data&&p(se=>[...se,B.data])}catch{}}}if(A)p(E=>[...E,"","═".repeat(50),"✅ FOUNDATION UPDATED","","✓ Database schema synchronized","✓ API contracts verified","","System will reload to apply changes...","═".repeat(50)]),setTimeout(()=>{window.location.reload()},2e3);else throw new Error("Migration completed with errors.")}catch(S){console.error(S),p(_=>[..._,"",`❌ FATAL ERROR: ${S instanceof Error?S.message:String(S)}`]),he.error("Migration interrupted. Consult system logs.")}finally{h(!1)}};return o.jsx(pa,{open:t,onOpenChange:S=>!d&&e(S),children:o.jsx(ga,{className:"max-h-[90vh] sm:max-w-4xl overflow-y-auto border-none bg-background/95 backdrop-blur-2xl shadow-2xl p-0 gap-0 selection:bg-primary/20",children:o.jsxs("div",{className:"bg-gradient-to-br from-primary/5 via-transparent to-transparent",children:[o.jsx(ar,{className:"p-8 pb-4",children:o.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[o.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:o.jsx(hu,{className:"h-6 w-6 text-primary"})}),o.jsxs("div",{children:[o.jsx(rr,{className:"text-2xl font-black tracking-tight",children:"Database Setup Required"}),o.jsxs(bi,{className:"text-xs font-bold uppercase tracking-[0.2em] opacity-60",children:["Foundational Registry Sync • ",n.appVersion]})]})]})}),o.jsxs("div",{className:"px-8 pb-8 space-y-6",children:[o.jsxs(es,{className:"bg-muted/40 border-none rounded-2xl p-4",children:[o.jsx(Hm,{className:"h-4 w-4 text-primary"}),o.jsxs(ts,{className:"text-xs font-medium leading-relaxed",children:["Your application requires a database schema update to enable new features like ",o.jsx("strong",{children:"Enhanced TTS Engine"})," and ",o.jsx("strong",{children:"Real-time Intelligence Streaming"}),". Existing data remains untouched."]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm p-6 space-y-4",children:[o.jsx("h3",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground",children:"Security Credentials"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"project-id",className:"text-[10px] uppercase tracking-widest font-black opacity-60",children:"Project Identity"}),o.jsx(Ne,{id:"project-id",value:j,disabled:!0,readOnly:!0,className:"h-10 bg-muted/50 border-none font-mono text-xs rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx(Je,{htmlFor:"access-token",className:"text-[10px] uppercase tracking-widest font-black opacity-60",children:"Personal Access Token"}),o.jsxs("a",{href:"https://supabase.com/dashboard/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-black tracking-widest text-primary hover:underline flex items-center gap-1",children:["GENERATE ",o.jsx(Vw,{className:"h-2.5 w-2.5"})]})]}),o.jsx(Ne,{id:"access-token",type:"password",placeholder:"sbp_...",value:y,onChange:S=>x(S.target.value),disabled:d,className:"h-10 bg-background border-border/40 focus:ring-primary/20 rounded-xl font-mono text-xs"})]}),o.jsx(oe,{onClick:k,disabled:d||!y,className:"w-full h-11 rounded-xl bg-primary text-primary-foreground font-black text-[10px] uppercase tracking-[0.2em] shadow-lg shadow-primary/20 hover:scale-[1.02] active:scale-[0.98] transition-all",children:d?o.jsxs(o.Fragment,{children:[o.jsx(Qe,{className:"mr-2 h-4 w-4 animate-spin"}),"Deploying..."]}):o.jsxs(o.Fragment,{children:[o.jsx(xa,{className:"mr-2 h-4 w-4"}),"Initialize Protocol"]})})]})]})}),o.jsxs("div",{className:"flex flex-col rounded-2xl border bg-zinc-950/95 text-zinc-400 font-mono text-[11px] p-5 shadow-inner min-h-[300px] overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4 shrink-0",children:[o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500/20"})]}),o.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest opacity-40 ml-2",children:"Foundation Terminal"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[m.length===0?o.jsxs("div",{className:"text-zinc-700 italic flex flex-col items-center justify-center h-full opacity-50",children:[o.jsx(Go,{className:"h-8 w-8 mb-2"}),o.jsx("span",{children:"Awaiting synchronization..."})]}):m.map((S,_)=>o.jsxs("div",{className:ve("mb-1.5 leading-relaxed break-words",S.includes("✅")||S.includes("success")?"text-emerald-400":S.includes("❌")||S.includes("Error")?"text-red-400 font-bold":S.includes("🚀")||S.includes("[System]")?"text-primary":""),children:[o.jsx("span",{className:"opacity-30 mr-2",children:_+1}),S]},_)),o.jsx("div",{ref:w})]})]})]})]}),o.jsx(Xa,{className:"p-8 pt-0 flex-col sm:flex-row gap-3",children:o.jsxs("div",{className:"flex gap-3 w-full",children:[o.jsxs(oe,{type:"button",variant:"secondary",onClick:()=>u(1),disabled:d,className:"flex-1 h-11 rounded-xl font-black text-[10px] uppercase tracking-widest",children:[o.jsx(sl,{className:"h-4 w-4 mr-2 opacity-60"}),"Snooze 1h"]}),o.jsxs(oe,{type:"button",variant:"secondary",onClick:()=>u(24),disabled:d,className:"flex-1 h-11 rounded-xl font-black text-[10px] uppercase tracking-widest",children:[o.jsx(Bw,{className:"h-4 w-4 mr-2 opacity-60"}),"Tomorrow"]})]})})]})})})}const z6=[{id:"bay-area-utilities",name:"Bay Area Utilities",description:"PG&E, Recology, EBMUD, and SCE bill handling",policies:4,tags:["utilities","california"]},{id:"freelancer-tax",name:"Freelancer Tax Pack",description:"1099-NEC, W-9, invoices, and estimated taxes",policies:6,tags:["finance","tax"]},{id:"medical-records",name:"Medical Records",description:"EOB, lab results, prescription receipts",policies:5,tags:["health","insurance"]},{id:"legal-docs",name:"Legal Documents",description:"Contracts, notices, deeds, and court documents",policies:3,tags:["legal","priority"]}];function U6({initialCompose:t,onInitialConsumed:e}){const[n,r]=v.useState([]),[l,u]=v.useState(!0),[d,h]=v.useState(""),[m,p]=v.useState(!1),[y,x]=v.useState(null),[w,j]=v.useState(!1),[k,S]=v.useState(!1),[_,T]=v.useState(null),[C,A]=v.useState("policies"),[E,M]=v.useState([]),[P,U]=v.useState(""),[R,B]=v.useState(""),[se,re]=v.useState(null),[ue,xe]=v.useState(null),[ge,X]=v.useState(null),[V,F]=v.useState(!1),[Z,ye]=v.useState({name:"",description:"",keywords:"",matchStrategy:"ANY",actions:[{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}],tags:"",priority:100}),[ne,D]=v.useState(!1),L=v.useCallback(async()=>{u(!0);const I=await be.getPolicies?.(se);I?.data?.policies&&r(I.data.policies),u(!1)},[se]),J=v.useCallback(async()=>{try{const ce=(await be.getSDKChatProviders?.())?.data?.providers??[];M(ce),ce.length>0&&!P&&(U(ce[0].provider),B(ce[0].models?.[0]?.id??""))}catch{}},[P]);v.useEffect(()=>{const I=hs();I&&I.auth.getSession().then(({data:ce})=>{re(ce.session?.access_token??null)})},[]),v.useEffect(()=>{L(),J()},[L,J]),v.useEffect(()=>{t&&(h(t),e?.())},[t,e]);const H=async()=>{if(d.trim()){p(!0),x(null);try{const I=await be.synthesizePolicy?.({description:d,provider:P||void 0,model:R||void 0},se);if(I?.data?.policy){x(I.data.policy),j(!1);const ce=I.data.warning;ce?he.warning(ce):he.success("Policy synthesized! Review and save below.")}else he.error(I?.data?.error??"Synthesis failed.")}catch{he.error("LLM synthesis failed.")}finally{p(!1)}}},ae=async I=>{S(!0);try{await be.savePolicy?.(I,se),he.success(`Policy "${I.metadata.name}" saved.`),x(null),h(""),await L()}catch{he.error("Failed to save policy.")}finally{S(!1)}},ie=async I=>{window.confirm(`Delete policy "${I}"?`)&&(await be.deletePolicy?.(I,se),he.success("Policy deleted."),await L())},$=async I=>{r(ce=>ce.map(Pe=>Pe.metadata.id===I.metadata.id?{...Pe,metadata:{...Pe.metadata,enabled:!Pe.metadata.enabled}}:Pe));try{await be.patchPolicy?.(I.metadata.id,{enabled:!I.metadata.enabled},se)}catch{he.error("Failed to toggle policy."),await L()}},fe=I=>{xe(I.metadata.id),X({name:I.metadata.name,description:I.metadata.description,tags:(I.metadata.tags??[]).join(", "),priority:I.metadata.priority})},le=()=>{xe(null),X(null)},Oe=async I=>{if(ge)try{await be.patchPolicy?.(I,{name:ge.name,description:ge.description,tags:ge.tags.split(",").map(ce=>ce.trim()).filter(Boolean),priority:ge.priority},se),he.success("Policy updated."),xe(null),X(null),await L()}catch{he.error("Failed to save edits.")}},Ue=I=>{h(I.metadata.description),A("policies"),he.success("Description pre-filled — edit and click ✨ to re-synthesize.")},ft=async()=>{await be.reloadPolicies?.(se),await L(),he.success("Policies reloaded.")},Ye=(I,ce,Pe)=>{ye(qe=>{const pt=qe.actions.map((ss,Ie)=>Ie===I?{...ss,[ce]:Pe}:ss);return{...qe,actions:pt}})},de=()=>{ye(I=>({...I,actions:[...I.actions,{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}]}))},Fe=I=>{ye(ce=>({...ce,actions:ce.actions.filter((Pe,qe)=>qe!==I)}))},pe=I=>I.type==="append_to_google_sheet"&&!I.spreadsheet_id?.trim(),De=Z.actions.some(pe),it=async()=>{if(!Z.name.trim())return;const I=Z.actions.findIndex(pe);if(I!==-1){he.error(`Action #${I+1}: "Append to Google Sheet" requires Spreadsheet ID or Google Sheet URL.`);return}D(!0);try{const ce=Z.name.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),Pe=Z.keywords.split(",").map(Ie=>Ie.trim()).filter(Boolean),qe=Z.tags.split(",").map(Ie=>Ie.trim()).filter(Boolean),pt=Z.actions.filter(Ie=>Ie.type==="copy_to_gdrive"||Ie.type==="auto_rename"||Ie.type==="append_to_google_sheet"||Ie.destination.trim()).map(Ie=>{const ns={type:Ie.type};if(Ie.type==="copy")ns.destination=Ie.destination,Ie.filename&&(ns.filename=Ie.filename);else if(Ie.type==="rename")ns.destination=Ie.destination;else if(Ie.type!=="auto_rename"){if(Ie.type==="copy_to_gdrive")Ie.destination.trim()&&(ns.destination=Ie.destination.trim()),Ie.filename&&(ns.filename=Ie.filename);else if(Ie.type==="log_csv")ns.path=Ie.destination;else if(Ie.type==="append_to_google_sheet"){const cl=Ie.spreadsheet_id?.trim();cl&&(ns.spreadsheet_id=cl);const Mn=Ie.range?.trim();Mn&&(ns.range=Mn);const Yt=(Ie.columns??[]).map(Xs=>Xs.trim()).filter(Boolean);Yt.length>0&&(ns.columns=Yt)}}return ns}),ss={metadata:{id:ce,name:Z.name.trim(),description:Z.description.trim(),priority:Z.priority,tags:qe,enabled:!0},spec:{match:{strategy:Z.matchStrategy,conditions:Pe.length>0?[{type:"keyword",value:Pe}]:[{type:"keyword",value:[]}]},extract:[],actions:pt}};await be.savePolicy?.(ss,se),he.success(`Policy "${ss.metadata.name}" created.`),F(!1),ye({name:"",description:"",keywords:"",matchStrategy:"ANY",actions:[{type:"copy",destination:"",filename:"",columns:[],spreadsheet_id:"",range:""}],tags:"",priority:100}),await L()}catch{he.error("Failed to create policy.")}finally{D(!1)}},Ut=I=>{if(I.type==="append_to_google_sheet"){const ce=I.spreadsheet_id?.trim()||I.spreadsheet_url?.trim()||"",Pe=I.range?.trim()||"";return ce&&Pe?`${ce} (${Pe})`:ce||Pe}return I.type==="log_csv"?I.path?.trim()||"":I.destination?.trim()||I.pattern?.trim()||""},Ws=(I,ce)=>{x(Pe=>{if(!Pe)return Pe;const qe=(Pe.spec.actions??[]).map((pt,ss)=>ss===I?{...pt,...ce}:pt);return{...Pe,spec:{...Pe.spec,actions:qe}}})},ki=(I=>{if(!I)return[];const ce=[];I.metadata.name?.trim()||ce.push("Policy name is missing."),I.metadata.id?.trim()||ce.push("Policy id is missing.");const Pe=I.spec.actions??[];return Pe.length===0&&ce.push("At least one action is required."),Pe.forEach((qe,pt)=>{qe.type==="append_to_google_sheet"&&(qe.spreadsheet_id?.trim()||qe.spreadsheet_url?.trim()||ce.push(`Action #${pt+1} append_to_google_sheet is missing spreadsheet_id / URL.`)),qe.type==="copy"&&!qe.destination?.trim()&&ce.push(`Action #${pt+1} copy is missing destination.`),qe.type==="rename"&&!(qe.pattern?.trim()||qe.destination?.trim())&&ce.push(`Action #${pt+1} rename is missing pattern.`)}),ce})(y),Bu=!!y&&ki.length===0&&!k;return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-10 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-end justify-between",children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-3xl font-black tracking-tight flex items-center gap-3",children:[o.jsx(Yw,{className:"w-8 h-8 text-primary"}),"Policy Engine"]}),o.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Define automation rules that govern how Folio handles your documents."})]}),o.jsxs(oe,{variant:"outline",size:"sm",onClick:ft,className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-4 h-4"}),"Reload"]})]}),o.jsx("div",{className:"flex gap-1 p-1 rounded-2xl bg-muted/50 border w-fit",children:["policies","packs"].map(I=>o.jsx("button",{onClick:()=>A(I),className:ve("px-5 py-2 rounded-xl text-xs font-black uppercase tracking-widest transition-all",C===I?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:I==="policies"?"Active Policies":"Policy Packs"},I))}),C==="policies"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-2xl border bg-card/60 backdrop-blur-sm p-6 shadow-sm space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx(Cn,{className:"w-4 h-4 text-primary"}),o.jsx("h2",{className:"text-sm font-black uppercase tracking-widest",children:"Magic Composer"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe a rule in plain English. Click ✨ to generate the policy automatically."}),E.length>0&&o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx($m,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("select",{value:`${P}::${R}`,onChange:I=>{const[ce,Pe]=I.target.value.split("::");U(ce),B(Pe)},className:"text-xs rounded-lg border border-border/40 bg-background px-2 py-1 text-foreground flex-1 max-w-xs",children:E.flatMap(I=>(I.models??[]).map(ce=>o.jsxs("option",{value:`${I.provider}::${ce.id}`,children:[I.provider," / ",ce.id]},`${I.provider}::${ce.id}`)))}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"for synthesis"})]}),o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx(Xm,{placeholder:"e.g. If I get a bill from Tesla, move it to /Car/ folder and log the amount to my CSV…",value:d,onChange:I=>h(I.target.value),className:"flex-1 min-h-[80px] resize-none rounded-xl border-border/40 bg-background text-sm",onKeyDown:I=>{I.key==="Enter"&&(I.metaKey||I.ctrlKey)&&H()}}),o.jsx(oe,{onClick:H,disabled:m||!d.trim(),className:ve("h-10 w-10 p-0 rounded-xl flex items-center justify-center transition-all","bg-primary text-primary-foreground shadow-lg shadow-primary/20","hover:scale-105 active:scale-95"),title:"Synthesize policy with AI",children:m?o.jsx(Qe,{className:"w-4 h-4 animate-spin"}):o.jsx(Cn,{className:"w-4 h-4"})})]}),y&&o.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/5 p-4 space-y-3 animate-in slide-in-from-bottom-2 duration-300",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"font-black text-sm",children:y.metadata.name}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:y.metadata.description})]}),o.jsxs(wt,{variant:"outline",className:"text-[10px] uppercase font-bold",children:["Priority ",y.metadata.priority]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 text-xs text-muted-foreground",children:[o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Match"}),o.jsxs("div",{className:"space-y-1",children:[y.spec.match.conditions.length===0&&o.jsx("div",{children:"—"}),y.spec.match.conditions.map((I,ce)=>o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:I.type})," ",Array.isArray(I.value)?I.value.join(", "):I.value]},`${I.type}-${ce}`))]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Extract"}),o.jsxs("div",{className:"space-y-1",children:[(y.spec.extract?.length??0)===0&&o.jsx("div",{children:"—"}),y.spec.extract?.map(I=>o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:I.key})," ","(",I.type,")",I.required?" *":""]},I.key))]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/60 p-2",children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] mb-1 text-foreground",children:"Actions"}),o.jsxs("div",{className:"space-y-2",children:[(y.spec.actions?.length??0)===0&&o.jsx("div",{children:"—"}),y.spec.actions?.map((I,ce)=>o.jsxs("div",{className:"rounded-md border border-border/50 bg-background/80 p-2 space-y-1.5",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:I.type})," ",Ut(I)]}),I.type==="copy_to_gdrive"&&o.jsx(Ne,{value:I.destination??"",onChange:Pe=>Ws(ce,{destination:Pe.target.value}),placeholder:"Google Drive folder ID",className:"h-7 text-[11px] rounded-lg font-mono"}),I.type==="append_to_google_sheet"&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(Ne,{value:I.spreadsheet_id??I.spreadsheet_url??"",onChange:Pe=>Ws(ce,{spreadsheet_id:Pe.target.value,spreadsheet_url:void 0}),placeholder:"Spreadsheet ID or URL",className:"h-7 text-[11px] rounded-lg font-mono"}),o.jsx(Ne,{value:I.range??"",onChange:Pe=>Ws(ce,{range:Pe.target.value}),placeholder:"Optional range (e.g. Sheet1!A:Z)",className:"h-7 text-[11px] rounded-lg font-mono"})]})]},`${I.type}-${ce}`))]})]})]}),ki.length>0?o.jsx(es,{className:"rounded-xl border-red-200 bg-red-50",children:o.jsxs(ts,{className:"text-xs text-red-700",children:[o.jsx("div",{className:"font-semibold mb-1",children:"Fix before saving:"}),o.jsx("div",{className:"space-y-0.5",children:ki.map((I,ce)=>o.jsx("div",{children:I},`synth-issue-${ce}`))})]})}):o.jsx("div",{className:"text-[11px] text-emerald-700 font-semibold",children:"Policy looks valid for save."}),o.jsx("div",{className:"flex gap-2",children:o.jsx(oe,{type:"button",size:"sm",variant:"outline",onClick:()=>j(I=>!I),className:"h-7 px-2 rounded-lg text-[10px] uppercase tracking-widest",children:w?"Hide JSON":"Show JSON"})}),w&&o.jsx("pre",{className:"rounded-lg border border-border/40 bg-background p-3 text-[11px] overflow-auto max-h-72 whitespace-pre-wrap font-mono",children:JSON.stringify(y,null,2)}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(oe,{size:"sm",onClick:()=>ae(y),disabled:!Bu,className:"flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest",children:k?o.jsx(Qe,{className:"w-3 h-3 animate-spin"}):"Save Policy"}),o.jsx(oe,{size:"sm",variant:"outline",onClick:()=>{x(null),j(!1)},className:"h-8 px-3 rounded-xl",children:"Discard"})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("h2",{className:"text-xs font-black uppercase tracking-widest text-muted-foreground",children:["Active Policies (",n.length,")"]}),o.jsx(oe,{size:"sm",variant:V?"secondary":"outline",onClick:()=>F(I=>!I),className:"h-7 px-3 rounded-xl gap-1.5 text-[10px] font-black uppercase tracking-widest",children:V?o.jsxs(o.Fragment,{children:[o.jsx(Ps,{className:"w-3 h-3"}),"Cancel"]}):o.jsxs(o.Fragment,{children:[o.jsx(hu,{className:"w-3 h-3"}),"Quick Create"]})})]}),V&&o.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-primary/5 p-5 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(hu,{className:"w-3.5 h-3.5 text-primary"}),o.jsx("span",{className:"text-xs font-black uppercase tracking-widest text-primary",children:"Quick Create Policy"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"col-span-2 space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Name *"}),o.jsx(Ne,{placeholder:"e.g. Tesla Invoice Handler",value:Z.name,onChange:I=>ye({...Z,name:I.target.value}),className:"h-8 text-sm rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"col-span-2 space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Description"}),o.jsx(Ne,{placeholder:"What does this policy do?",value:Z.description,onChange:I=>ye({...Z,description:I.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Match Keywords"}),o.jsx(Ne,{placeholder:"tesla, invoice, PG&E (comma-sep)",value:Z.keywords,onChange:I=>ye({...Z,keywords:I.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Match Strategy"}),o.jsxs("select",{value:Z.matchStrategy,onChange:I=>ye({...Z,matchStrategy:I.target.value}),className:"h-8 w-full text-xs rounded-xl border border-border/40 bg-background px-3 text-foreground",children:[o.jsx("option",{value:"ANY",children:"ANY keyword matches"}),o.jsx("option",{value:"ALL",children:"ALL keywords match"})]})]}),o.jsxs("div",{className:"col-span-2 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Actions"}),o.jsxs("button",{type:"button",onClick:de,className:"flex items-center gap-1 text-[10px] font-bold text-primary hover:text-primary/80 transition-colors",children:[o.jsx(er,{className:"w-3 h-3"}),"Add Action"]})]}),o.jsx("div",{className:"space-y-2",children:Z.actions.map((I,ce)=>{const Pe=!I.filename||I.filename===""?"original":I.filename==="auto"?"auto":"custom";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2 items-start",children:[o.jsxs("select",{value:I.type,onChange:qe=>Ye(ce,"type",qe.target.value),className:"h-8 text-xs rounded-xl border border-border/40 bg-background px-2 text-foreground w-full",children:[o.jsx("option",{value:"copy",children:"Copy to folder"}),o.jsx("option",{value:"rename",children:"Rename file (Pattern)"}),o.jsx("option",{value:"log_csv",children:"Log to CSV"}),o.jsx("option",{value:"copy_to_gdrive",children:"Copy to Google Drive"}),o.jsx("option",{value:"append_to_google_sheet",children:"Append to Google Sheet"})]}),o.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[I.type!=="append_to_google_sheet"&&o.jsx(Ne,{placeholder:I.type==="copy"?"/Car/":I.type==="copy_to_gdrive"?"Folder ID (empty = My Drive root)":I.type==="rename"?"Tesla-{date}":"/logs/invoices.csv",value:I.destination,onChange:qe=>Ye(ce,"destination",qe.target.value),className:"h-8 text-xs rounded-xl border-border/40 bg-background font-mono flex-1 min-w-0"}),Z.actions.length>1&&o.jsx("button",{type:"button",onClick:()=>Fe(ce),className:"text-muted-foreground hover:text-destructive transition-colors shrink-0 p-1",children:o.jsx(Ps,{className:"w-3.5 h-3.5"})})]})]}),(I.type==="copy"||I.type==="copy_to_gdrive")&&o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2 items-center",children:[o.jsx("div",{"aria-hidden":"true"}),o.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[o.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:"Filename:"}),o.jsxs("select",{value:Pe,onChange:qe=>{const pt=qe.target.value;pt==="original"?Ye(ce,"filename",""):pt==="auto"?Ye(ce,"filename","auto"):Ye(ce,"filename","{date}_{issuer}_{document_type}")},className:"h-7 text-xs rounded-lg border border-border/40 bg-background px-2 text-foreground shrink-0",children:[o.jsx("option",{value:"original",children:"Keep original"}),o.jsx("option",{value:"auto",children:"Smart rename (AI)"}),o.jsx("option",{value:"custom",children:"Custom pattern"})]}),Pe==="custom"&&o.jsx(Ne,{value:I.filename,onChange:qe=>Ye(ce,"filename",qe.target.value),placeholder:"{date}_{issuer}_{document_type}",className:"h-7 text-xs rounded-lg border-border/40 bg-background font-mono flex-1 min-w-0"})]})]}),I.type==="append_to_google_sheet"&&o.jsxs("div",{className:"grid grid-cols-[9rem_minmax(0,1fr)] gap-2",children:[o.jsx("div",{"aria-hidden":"true"}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ne,{placeholder:"Spreadsheet ID or Google Sheet URL",value:I.spreadsheet_id||"",onChange:qe=>Ye(ce,"spreadsheet_id",qe.target.value),className:"h-7 text-xs rounded-lg flex-1"}),o.jsx(Ne,{placeholder:"Optional tab/range (e.g. Sheet1!A:F)",value:I.range||"",onChange:qe=>Ye(ce,"range",qe.target.value),className:"h-7 text-xs rounded-lg w-32"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5 p-2 rounded-lg border border-border/40 bg-muted/20",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Je,{className:"text-[10px] uppercase font-bold text-muted-foreground",children:"Columns Mapping (A, B, C...)"}),o.jsxs(oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-[10px] px-2 py-0",onClick:()=>{const qe=[...I.columns||[],""];Ye(ce,"columns",qe)},children:[o.jsx(er,{className:"w-3 h-3 mr-1"})," Add Col"]})]}),(I.columns||[]).map((qe,pt)=>o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground w-4 flex-shrink-0 text-center",children:String.fromCharCode(65+pt)}),o.jsx(Ne,{placeholder:"e.g. {Date} or Static Text",value:qe,onChange:ss=>{const Ie=[...I.columns||[]];Ie[pt]=ss.target.value,Ye(ce,"columns",Ie)},className:"h-7 text-xs rounded-lg font-mono flex-1"}),o.jsx("button",{type:"button",onClick:()=>{const ss=(I.columns||[]).filter((Ie,ns)=>ns!==pt);Ye(ce,"columns",ss)},className:"text-muted-foreground hover:text-destructive p-1",children:o.jsx(Ps,{className:"w-3 h-3"})})]},pt)),(!I.columns||I.columns.length===0)&&o.jsx("div",{className:"text-[10px] text-muted-foreground italic text-center py-1",children:"No explicit mapping provided. Folio will auto-map by reading header row from the sheet template."})]})]})]})]},ce)})})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Tags"}),o.jsx(Ne,{placeholder:"finance, cars (comma-sep)",value:Z.tags,onChange:I=>ye({...Z,tags:I.target.value}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(Je,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Priority"}),o.jsx(Ne,{type:"number",min:1,max:999,value:Z.priority,onChange:I=>ye({...Z,priority:Number(I.target.value)}),className:"h-8 text-xs rounded-xl border-border/40 bg-background"})]})]}),De&&o.jsx("p",{className:"text-[10px] text-destructive",children:'"Append to Google Sheet" actions require a Spreadsheet ID or Google Sheet URL.'}),o.jsxs("div",{className:"flex gap-2 pt-1",children:[o.jsx(oe,{size:"sm",onClick:it,disabled:ne||!Z.name.trim()||De,className:"flex-1 h-8 rounded-xl font-black text-[10px] uppercase tracking-widest gap-1.5",children:ne?o.jsx(Qe,{className:"w-3 h-3 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(er,{className:"w-3 h-3"}),"Create Policy"]})}),o.jsx(oe,{size:"sm",variant:"outline",onClick:()=>F(!1),className:"h-8 px-3 rounded-xl",children:"Cancel"})]})]}),l?o.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[o.jsx(Qe,{className:"w-6 h-6 animate-spin mr-3"}),"Loading policies..."]}):n.length===0?o.jsxs(es,{className:"rounded-2xl border-dashed",children:[o.jsx(Hm,{className:"h-4 w-4"}),o.jsx(ts,{className:"text-sm",children:"No policies yet. Use the Magic Composer above to create your first one."})]}):o.jsx("div",{className:"space-y-2",children:n.map(I=>o.jsxs("div",{className:ve("rounded-2xl border bg-card/50 shadow-sm overflow-hidden transition-all",I.metadata.enabled===!1&&"opacity-60"),children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",children:[o.jsx("button",{title:I.metadata.enabled===!1?"Enable policy":"Disable policy",onClick:()=>$(I),className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:I.metadata.enabled===!1?o.jsx(hA,{className:"w-5 h-5 text-muted-foreground"}):o.jsx(mA,{className:"w-5 h-5 text-primary"})}),o.jsx("div",{className:"flex-1 min-w-0",children:ue===I.metadata.id&&ge?o.jsxs("div",{className:"space-y-2",onClick:ce=>ce.stopPropagation(),children:[o.jsx(Ne,{value:ge.name,onChange:ce=>X({...ge,name:ce.target.value}),placeholder:"Policy name",className:"h-7 text-sm font-semibold"}),o.jsx(Ne,{value:ge.description,onChange:ce=>X({...ge,description:ce.target.value}),placeholder:"Description",className:"h-7 text-xs"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ne,{value:ge.tags,onChange:ce=>X({...ge,tags:ce.target.value}),placeholder:"Tags (comma-separated)",className:"h-7 text-xs flex-1"}),o.jsx(Ne,{type:"number",value:ge.priority,onChange:ce=>X({...ge,priority:Number(ce.target.value)}),placeholder:"Priority",className:"h-7 text-xs w-20",min:1,max:999})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"font-bold text-sm truncate",children:I.metadata.name}),o.jsxs(wt,{variant:"outline",className:"text-[9px] shrink-0",children:["P",I.metadata.priority]}),(I.metadata.learning_examples??0)>0&&o.jsxs(wt,{variant:"secondary",className:"text-[9px] shrink-0",children:["Learned ",I.metadata.learning_examples]}),I.metadata.tags?.map(ce=>o.jsxs(wt,{variant:"secondary",className:"text-[9px] gap-1 shrink-0",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),ce]},ce))]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:I.metadata.description})]})}),o.jsx("div",{className:"flex items-center gap-1 shrink-0",children:ue===I.metadata.id?o.jsxs(o.Fragment,{children:[o.jsx(oe,{size:"sm",variant:"default",className:"h-7 px-2 text-xs",onClick:()=>Oe(I.metadata.id),children:"Save"}),o.jsx(oe,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:le,children:"Cancel"})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{title:"Edit metadata",onClick:()=>fe(I),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:[o.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),o.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),o.jsx("button",{title:"Re-compose with AI",onClick:()=>Ue(I),className:"text-muted-foreground hover:text-primary transition-colors p-1",children:o.jsx(Cn,{className:"w-4 h-4"})}),o.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-1",onClick:()=>T(_===I.metadata.id?null:I.metadata.id),children:_===I.metadata.id?o.jsx(cu,{className:"w-4 h-4"}):o.jsx($o,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>ie(I.metadata.id),className:"text-muted-foreground hover:text-destructive transition-colors p-1",children:o.jsx(sr,{className:"w-4 h-4"})})]})})]}),_===I.metadata.id&&o.jsxs("div",{className:"border-t px-5 py-4 bg-muted/20 space-y-3 animate-in slide-in-from-top-2 duration-200",children:[o.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:["Match (",I.spec.match.strategy,")"]}),I.spec.match.conditions.map((ce,Pe)=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:ce.type})," ",Array.isArray(ce.value)?ce.value.join(", "):ce.value]},Pe))]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:"Extract"}),I.spec.extract?.map(ce=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:ce.key})," ","(",ce.type,")",ce.required?" *":""]},ce.key))??o.jsx("span",{className:"text-muted-foreground/60",children:"—"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"font-bold uppercase tracking-widest text-[9px] text-muted-foreground mb-1",children:"Actions"}),I.spec.actions?.map((ce,Pe)=>o.jsxs("div",{className:"text-muted-foreground",children:[o.jsx("span",{className:"font-mono bg-muted px-1 rounded text-[10px]",children:ce.type})," ",Ut(ce)]},Pe))??o.jsx("span",{className:"text-muted-foreground/60",children:"—"})]})]}),(I.metadata.learning_examples??0)>0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Learned examples: ",I.metadata.learning_examples,I.metadata.learning_last_at?` · last on ${new Date(I.metadata.learning_last_at).toLocaleDateString()}`:""]})]})]},I.metadata.id))})]})]}),C==="packs"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Import curated policy bundles to instantly configure Folio for common use cases."}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:z6.map(I=>o.jsxs("div",{className:"rounded-2xl border bg-card/60 p-5 space-y-3 hover:border-primary/30 hover:shadow-md transition-all group",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"font-black text-sm",children:I.name}),o.jsxs(wt,{variant:"outline",className:"text-[9px] shrink-0",children:[I.policies," policies"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:I.description})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:I.tags.map(ce=>o.jsxs(wt,{variant:"secondary",className:"text-[9px] gap-1",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),ce]},ce))}),o.jsxs(oe,{size:"sm",variant:"outline",className:"w-full h-8 rounded-xl font-black text-[10px] uppercase tracking-widest group-hover:border-primary/40 transition-all",onClick:()=>he.info(`"${I.name}" import coming soon!`),children:[o.jsx(LC,{className:"w-3 h-3 mr-2"}),"Import Pack"]})]},I.id))})]})]})}function Za(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function Zb(t){const e=[];for(const n of t){const r=Za(n);if(!r)continue;const l=Za(r.metadata)??{},u=Za(r.spec)??{},d=Array.isArray(u.actions)?u.actions:[],h=typeof l.id=="string"?l.id.trim():"";if(!h)continue;const m=d.map(p=>{const y=Za(p);return typeof y?.type=="string"?y.type.trim():""}).filter(p=>p==="append_to_google_sheet"||p==="webhook"||p==="copy_to_gdrive"||p==="copy"||p==="log_csv"||p==="notify");e.push({id:h,name:typeof l.name=="string"?l.name:h,priority:typeof l.priority=="number"?l.priority:100,riskyActions:m,learningExamples:typeof l.learning_examples=="number"?l.learning_examples:0,learningLastAt:typeof l.learning_last_at=="string"?l.learning_last_at:null})}return e.sort((n,r)=>r.priority-n.priority),e}function B6(t){if(!Array.isArray(t)||t.length===0)return null;const n=[...t].reverse().find(h=>{const m=String(h?.step??"").toLowerCase();return m.includes("learned fallback")||m.includes("learned policy candidate selected")});if(!n)return null;const r=String(n.step??"").toLowerCase(),l=Za(n.details);if(!l)return null;const u=typeof l.reason=="string"?l.reason:r.includes("candidate selected")?"accepted":void 0,d=Za(l.bestCandidate)??(typeof l.policyId=="string"||typeof l.score=="number"||typeof l.support=="number"?{policyId:l.policyId,score:l.score,support:l.support}:void 0);return{reason:u,evaluatedPolicies:typeof l.evaluatedPolicies=="number"?l.evaluatedPolicies:void 0,evaluatedSamples:typeof l.evaluatedSamples=="number"?l.evaluatedSamples:void 0,bestCandidate:d,topCandidates:Array.isArray(l.topCandidates)?l.topCandidates.map(h=>Za(h)).filter(h=>!!h):void 0}}function I6(t){if(!t)return"No learned candidate details available yet.";switch(t){case"accepted":return"Learned fallback selected a policy candidate.";case"no_policy_ids":return"No candidate policies available for learned fallback.";case"no_document_features":return"Document had insufficient signals for learned fallback scoring.";case"no_feedback_samples":return"No learned examples yet. Match at least one document with learning enabled.";case"no_valid_samples":return"Learned examples exist but were too sparse to score.";case"score_below_threshold":return"A candidate was found but confidence stayed below threshold.";case"read_error":return"Learned fallback could not read feedback history.";default:return t.replace(/_/g," ")}}function V6({status:t}){return{pending:o.jsx(sl,{className:"w-4 h-4 text-muted-foreground"}),processing:o.jsx(Qe,{className:"w-4 h-4 text-blue-500 animate-spin"}),matched:o.jsx(Ks,{className:"w-4 h-4 text-emerald-500"}),no_match:o.jsx(sm,{className:"w-4 h-4 text-amber-500"}),duplicate:o.jsx(sm,{className:"w-4 h-4 text-emerald-500"}),error:o.jsx(Iw,{className:"w-4 h-4 text-destructive"})}[t]??null}function ia({children:t}){return o.jsx("div",{className:"text-[9px] font-bold uppercase tracking-widest text-muted-foreground mb-1.5",children:t})}function $6(t){const e=[];t.status==="no_match"?e.push(`I have a document named "${t.filename}" that wasn't matched by any policy.`):e.push(`I have a document named "${t.filename}" that matched a policy, but I want to create a better, more specific policy for it.`),t.mime_type&&e.push(`It is a ${t.mime_type} file.`);const n=t.extracted?Object.entries(t.extracted).filter(([r,l])=>r!=="_enrichment"&&l!=null):[];if(n.length>0){const r=n.map(([l,u])=>`${l}: ${String(u)}`).join(", ");e.push(`Partial data already extracted: ${r}.`)}return e.push("Create a policy to handle this exact type of document — infer the document type, define strict match conditions, extract key fields, and route it to an appropriate folder."),e.join(" ")}function ew(t){if(t==null)return"null";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}const q6=["issuer","vendor","sender","document_type","date","due_date","amount","total","currency"];function H6({extracted:t}){const e=q6.filter(n=>t[n]!=null&&String(t[n]).trim()!=="").map(n=>({key:n,value:String(t[n])}));return e.length===0?null:o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map(({key:n,value:r})=>o.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full bg-muted border",children:[o.jsx("span",{className:"text-muted-foreground font-mono",children:n}),o.jsx("span",{className:"font-medium",children:r})]},n))})}function G6({tags:t,onChange:e}){const[n,r]=v.useState(""),l=v.useRef(null),u=m=>e(t.filter(p=>p!==m)),d=()=>{const m=n.toLowerCase().trim().replace(/\s+/g,"-");if(!m||t.includes(m)){r("");return}e([...t,m]),r("")},h=m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d()):m.key==="Backspace"&&!n&&t.length>0&&e(t.slice(0,-1))};return o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 rounded-xl border px-3 py-2 bg-background min-h-[36px] cursor-text",role:"button",tabIndex:0,onClick:()=>l.current?.focus(),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l.current?.focus())},children:[t.map(m=>o.jsxs("span",{className:ve("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full border",Ap(m)),children:[m,o.jsx("button",{onClick:p=>{p.stopPropagation(),u(m)},className:"ml-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":`Remove ${m}`,children:o.jsx(Ps,{className:"w-2.5 h-2.5"})})]},m)),o.jsx("input",{ref:l,value:n,onChange:m=>r(m.target.value),onKeyDown:h,onBlur:d,placeholder:t.length?"":"Add tags…",className:"flex-1 min-w-[80px] bg-transparent text-xs outline-none placeholder:text-muted-foreground/50"}),n&&o.jsx("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(er,{className:"w-3 h-3"})})]})}function F6({ingestion:t,onClose:e,onRerun:n,onTagsChange:r,onComposePolicy:l,onManualMatch:u}){const d=t.extracted&&Object.keys(t.extracted).length>0?t.extracted:null,h=d&&typeof d._enrichment=="object"&&d._enrichment!==null?d._enrichment:null,m=t.actions_taken?.length?t.actions_taken:null,[p,y]=v.useState(t.summary??null),[x,w]=v.useState(!1),[j,k]=v.useState([]),[S,_]=v.useState(!1),[T,C]=v.useState(""),[A,E]=v.useState(!0),[M,P]=v.useState(!0),[U,R]=v.useState(!1),[B,se]=v.useState(!1),[re,ue]=v.useState(null),[xe,ge]=v.useState(!1),[X,V]=v.useState(!1),[F,Z]=v.useState(null),[ye,ne]=v.useState([]),[D,L]=v.useState(null),[J,H]=v.useState(!1),ae=t.status!=="pending"&&t.status!=="processing",ie=!!u&&!t.policy_name&&t.status!=="pending"&&t.status!=="processing",$=B6(t.trace);v.useEffect(()=>{if(!ae||p)return;let de=!1;return(async()=>{w(!0);try{const pe=(await hs()?.auth.getSession())?.data?.session?.access_token??null,De=await be.summarizeIngestion(t.id,pe);if(de)return;De.data?.summary&&y(De.data.summary)}catch{}finally{de||w(!1)}})(),()=>{de=!0}},[t.id]),v.useEffect(()=>{if(!ie)return;let de=!1;return(async()=>{_(!0),ue(null);try{const pe=(await hs()?.auth.getSession())?.data?.session?.access_token??null,De=await be.getPolicies(pe);if(de)return;if(De?.error){const Ut=typeof De.error=="string"?De.error:De.error.message;throw new Error(Ut||"Failed to load policies.")}const it=Zb(De?.data?.policies??[]);k(it),C(Ut=>Ut||it[0]?.id||"")}catch{de||(k([]),ue("Failed to load policies."))}finally{de||_(!1)}})(),()=>{de=!0}},[ie,t.id]);const fe=v.useCallback(async()=>{if(!u||!T||B)return;const Fe=j.find(pe=>pe.id===T)?.riskyActions??[];if(M&&Fe.length>0&&!U){ue(`Re-run may trigger side-effect actions: ${Fe.join(", ")}. Enable side-effect confirmation to continue.`);return}se(!0),ue(null);try{await u({policyId:T,learn:A,rerun:M,allowSideEffects:M?U:!1}),Z(null),ne([]),L(null)}catch(pe){const De=pe instanceof Error?pe.message:String(pe);ue(De||"Failed to assign policy.")}finally{se(!1)}},[U,B,A,u,j,M,T]),le=v.useCallback(async()=>{if(!(!T||xe||X)){ge(!0),L(null),Z(null),ne([]);try{const Fe=(await hs()?.auth.getSession())?.data?.session?.access_token??null,pe=await be.suggestPolicyRefinement(t.id,{policyId:T},Fe);if(pe?.error){const Ut=typeof pe.error=="string"?pe.error:pe.error.message;throw new Error(Ut||"Unable to suggest refinement.")}const De=pe?.data?.suggestion?.policy;if(!De)throw new Error("No policy refinement draft was returned.");const it=Array.isArray(pe?.data?.suggestion?.rationale)?pe.data.suggestion.rationale.map(Ut=>String(Ut).trim()).filter(Boolean):[];Z(De),ne(it),H(!1)}catch(de){const Fe=de instanceof Error?de.message:String(de);L(Fe||"Unable to suggest refinement.")}finally{ge(!1)}}},[t.id,X,xe,T]),Oe=v.useCallback(async()=>{if(!(!F||X)){V(!0),L(null);try{const Fe=(await hs()?.auth.getSession())?.data?.session?.access_token??null,pe=await be.savePolicy(F,Fe);if(pe?.error){const it=typeof pe.error=="string"?pe.error:pe.error.message;throw new Error(it||"Failed to apply refinement.")}he.success(`Applied refinement to policy "${F.metadata.name}".`),Z(null),ne([]),L(null),H(!1);const De=await be.getPolicies(Fe);if(!De?.error){const it=Zb(De?.data?.policies??[]);k(it)}}catch(de){const Fe=de instanceof Error?de.message:String(de);L(Fe||"Failed to apply refinement.")}finally{V(!1)}}},[X,F]),Ue=j.find(de=>de.id===T),ft=Ue?.riskyActions??[],Ye=v.useCallback(de=>{de.target===de.currentTarget&&e()},[e]);return o.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm flex items-center justify-center p-4",role:"button",tabIndex:0,onClick:Ye,onKeyDown:de=>{de.key==="Escape"&&(de.preventDefault(),e()),(de.key==="Enter"||de.key===" ")&&de.target===de.currentTarget&&(de.preventDefault(),e())},children:o.jsxs("div",{className:"bg-background border rounded-2xl shadow-2xl w-full max-w-3xl flex flex-col overflow-hidden animate-in zoom-in-95 duration-200",children:[o.jsxs("div",{className:"flex items-start gap-3 px-6 pt-5 pb-4 border-b",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-muted flex items-center justify-center shrink-0 mt-0.5",children:o.jsx(qm,{className:"w-4 h-4 text-muted-foreground"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"font-bold text-sm truncate",title:t.filename,children:t.filename}),o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.source," · ",new Date(t.created_at).toLocaleString(),t.file_size&&` · ${(t.file_size/1024).toFixed(1)}KB`]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(V6,{status:t.status}),o.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(Ps,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto max-h-[65vh]",children:[ae&&o.jsxs("div",{children:[o.jsx(ia,{children:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Cn,{className:"w-2.5 h-2.5"}),"Summary"]})}),d&&o.jsx("div",{className:"mb-2",children:o.jsx(H6,{extracted:d})}),x?o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-full"}),o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-5/6"}),o.jsx("div",{className:"h-3 rounded bg-muted animate-pulse w-4/6"})]}):p?o.jsx("p",{className:"text-xs text-foreground/80 leading-relaxed",children:p}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No summary available."})]}),!ae&&o.jsx("div",{className:"rounded-xl bg-muted/40 border px-4 py-3 text-xs text-muted-foreground text-center",children:"Summary will be available after processing completes."}),o.jsxs("div",{children:[o.jsx(ia,{children:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(du,{className:"w-2.5 h-2.5"}),"Tags"]})}),o.jsx(G6,{tags:t.tags??[],onChange:r}),o.jsx("p",{className:"text-[10px] text-muted-foreground mt-1.5",children:"Enter to add · Backspace to remove · spaces become hyphens"})]}),o.jsxs("div",{children:[o.jsx(ia,{children:"Policy Matched"}),t.policy_name?o.jsx(wt,{variant:"secondary",children:t.policy_name}):o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"No policy matched"}),ie&&o.jsxs("div",{className:"rounded-xl border bg-muted/20 p-3 space-y-2",children:[o.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Assign To Existing Policy"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("select",{className:"flex-1 h-8 rounded-lg border bg-background px-2 text-xs outline-none focus:ring-2 focus:ring-primary/30",value:T,onChange:de=>{C(de.target.value),R(!1),ue(null),Z(null),ne([]),L(null)},disabled:S||B||j.length===0,children:j.length===0?o.jsx("option",{value:"",children:S?"Loading policies…":"No active policies"}):j.map(de=>o.jsx("option",{value:de.id,children:de.learningExamples>0?`${de.name} (${de.learningExamples} learned)`:de.name},de.id))}),o.jsx(oe,{variant:"outline",size:"sm",className:"h-8 rounded-lg",disabled:B||S||!T,onClick:fe,children:B?o.jsx(Qe,{className:"w-3.5 h-3.5 animate-spin"}):"Match To Policy"}),o.jsx(oe,{variant:"outline",size:"sm",className:"h-8 rounded-lg",disabled:xe||X||S||!T,onClick:le,children:xe?o.jsx(Qe,{className:"w-3.5 h-3.5 animate-spin"}):"Suggest Refinement"})]}),Ue&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Learned examples for this policy: ",Ue.learningExamples,Ue.learningLastAt?` · last on ${new Date(Ue.learningLastAt).toLocaleDateString()}`:""]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[o.jsx("input",{type:"checkbox",className:"rounded border-muted-foreground/40",checked:A,onChange:de=>E(de.target.checked),disabled:B}),"Learn from this match"]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[o.jsx("input",{type:"checkbox",className:"rounded border-muted-foreground/40",checked:M,onChange:de=>{P(de.target.checked),R(!1),ue(null)},disabled:B}),"Re-run ingestion now (recommended)"]}),M&&ft.length>0&&o.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-2 text-[11px] text-amber-700 space-y-1",children:[o.jsxs("p",{children:["This policy has side-effect actions: ",ft.join(", ")]}),o.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px]",children:[o.jsx("input",{type:"checkbox",className:"rounded border-amber-500/40",checked:U,onChange:de=>R(de.target.checked),disabled:B}),"I understand this may create external writes on re-run"]})]}),(F||D)&&o.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-2.5 space-y-2",children:[o.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-primary",children:"Policy Refinement Preview"}),D&&o.jsx("p",{className:"text-[11px] text-destructive",children:D}),F&&o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-[11px] text-foreground/90",children:[F.metadata.name," · ",F.spec.match.conditions.length," match conditions · ",(F.spec.extract??[]).length," extract fields"]}),ye.length>0&&o.jsx("div",{className:"space-y-1",children:ye.map((de,Fe)=>o.jsx("p",{className:"text-[10px] text-muted-foreground",children:de},`refine-rationale-${Fe}`))}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:()=>H(de=>!de),children:J?"Hide JSON":"Show JSON"}),o.jsx(oe,{size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:Oe,disabled:X,children:X?o.jsx(Qe,{className:"w-3.5 h-3.5 animate-spin"}):"Apply To Policy"}),o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 rounded-lg text-[10px]",onClick:()=>{Z(null),ne([]),L(null),H(!1)},children:"Discard"})]}),J&&o.jsx("pre",{className:"rounded-md border border-border/40 bg-background p-2 text-[10px] overflow-auto max-h-48 whitespace-pre-wrap font-mono",children:JSON.stringify(F,null,2)})]})]}),re&&o.jsx("p",{className:"text-[11px] text-destructive",children:re})]})]})]}),$&&o.jsxs("div",{children:[o.jsx(ia,{children:"Learning Diagnostics"}),o.jsxs("div",{className:"rounded-xl border bg-muted/20 px-4 py-3 space-y-1.5",children:[o.jsx("p",{className:"text-xs text-foreground/90",children:I6($.reason)}),($.evaluatedPolicies!==void 0||$.evaluatedSamples!==void 0)&&o.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Evaluated policies: ",$.evaluatedPolicies??0," · samples: ",$.evaluatedSamples??0]}),$.bestCandidate&&o.jsxs("p",{className:"text-[11px] text-muted-foreground font-mono",children:["Best: ",String($.bestCandidate.policyId??"-")," · score ",String($.bestCandidate.score??"-")," · support ",String($.bestCandidate.support??"-"),$.bestCandidate.requiredScore!==void 0?` · needed ${String($.bestCandidate.requiredScore)}`:""]})]})]}),d&&o.jsxs("div",{children:[o.jsx(ia,{children:"Extracted Data"}),o.jsx("div",{className:"rounded-xl border overflow-hidden",children:Object.entries(d).filter(([de])=>de!=="_enrichment").map(([de,Fe])=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 text-xs border-b last:border-0",children:[o.jsx("span",{className:"font-mono text-muted-foreground",children:de}),o.jsx("span",{className:"font-medium text-right max-w-[55%] truncate",children:ew(Fe)})]},de))})]}),h&&Object.keys(h).length>0&&o.jsxs("div",{children:[o.jsx(ia,{children:"Enrichment Data"}),o.jsx("div",{className:"rounded-xl border overflow-hidden",children:Object.entries(h).map(([de,Fe])=>o.jsxs("div",{className:"px-4 py-2 text-xs border-b last:border-0",children:[o.jsx("div",{className:"font-mono text-muted-foreground mb-1",children:de}),o.jsx("pre",{className:"font-medium whitespace-pre-wrap break-all",children:ew(Fe)})]},de))})]}),m&&o.jsxs("div",{children:[o.jsx(ia,{children:"Actions Taken"}),o.jsx("ul",{className:"space-y-1",children:m.map((de,Fe)=>o.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[o.jsx(Ks,{className:"w-3 h-3 text-emerald-500 shrink-0"}),o.jsx("span",{className:"text-muted-foreground",children:String(de)})]},Fe))})]}),t.error_message&&o.jsxs("div",{children:[o.jsx(ia,{children:"Error"}),o.jsx("div",{className:"rounded-xl bg-destructive/5 border border-destructive/20 px-4 py-3",children:o.jsx("p",{className:"text-xs text-destructive font-mono break-all",children:t.error_message})})]}),!d&&!m&&!t.error_message&&ae&&!x&&!p&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No extracted data or actions recorded."})]}),o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t bg-muted/20",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(oe,{variant:"outline",size:"sm",onClick:n,className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-3.5 h-3.5"}),"Re-run"]}),l&&o.jsxs(oe,{variant:"outline",size:"sm",onClick:()=>l($6(t)),className:"gap-2 rounded-xl border-primary/30 text-primary hover:bg-primary/5 hover:text-primary",children:[o.jsx(Cn,{className:"w-3.5 h-3.5"}),"Create Policy"]})]}),o.jsx(oe,{variant:"ghost",size:"sm",onClick:e,className:"rounded-xl",children:"Close"})]})]})})}function K6({children:t}){return o.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3",children:t})}function Y6({ingestion:t,onClose:e}){return o.jsx("div",{className:"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-200",children:o.jsxs("div",{className:"bg-card w-full max-w-3xl rounded-2xl shadow-xl border overflow-hidden flex flex-col max-h-[90vh]",children:[o.jsxs("div",{className:"px-6 py-4 border-b flex items-center justify-between bg-muted/20",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:o.jsx(Go,{className:"w-4 h-4 text-emerald-500"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold",children:"AI Processing Trace"}),o.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[400px]",title:t.filename,children:t.filename})]})]}),o.jsx("button",{onClick:e,className:"p-2 -mr-2 text-muted-foreground hover:text-foreground hover:bg-muted rounded-xl transition-colors",children:o.jsx(Ps,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"p-6 overflow-y-auto space-y-6",children:t.trace&&t.trace.length>0?o.jsxs("div",{children:[o.jsx(K6,{children:"Execution Log"}),o.jsx("div",{className:"rounded-xl bg-zinc-950 text-emerald-400 p-4 font-mono text-[11px] space-y-3 overflow-x-auto border border-zinc-800 shadow-inner max-h-[60vh] overflow-y-auto",children:[...t.trace].reverse().map((n,r)=>o.jsxs("div",{className:`flex gap-3 leading-relaxed ${n.step.startsWith("---")?"text-zinc-500 my-4 text-center justify-center":""}`,children:[!n.step.startsWith("---")&&o.jsx("span",{className:"opacity-40 shrink-0",children:new Date(n.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsxs("div",{className:n.step.startsWith("---")?"font-bold uppercase tracking-widest":"",children:[o.jsx("span",{className:"font-semibold text-zinc-100",children:n.step}),n.details&&Object.keys(n.details).length>0&&o.jsxs("pre",{className:"mt-1 flex text-emerald-500/80 whitespace-pre-wrap text-[10px]",children:[o.jsx("span",{className:"select-none opacity-30 mr-2",children:"↳"}),JSON.stringify(n.details,null,2)]})]})]},r))})]}):o.jsx("p",{className:"text-sm text-muted-foreground text-center py-12 border-2 border-dashed rounded-xl",children:"No trace logs available for this ingestion."})})]})})}const tw=["bg-blue-500/10 text-blue-600 border-blue-500/20","bg-emerald-500/10 text-emerald-600 border-emerald-500/20","bg-amber-500/10 text-amber-700 border-amber-500/20","bg-violet-500/10 text-violet-600 border-violet-500/20","bg-rose-500/10 text-rose-600 border-rose-500/20","bg-cyan-500/10 text-cyan-600 border-cyan-500/20","bg-orange-500/10 text-orange-600 border-orange-500/20"];function Ap(t){let e=0;for(const n of t)e=e*31+n.charCodeAt(0)>>>0;return tw[e%tw.length]}function W6({status:t}){const e={pending:{label:"Pending",icon:o.jsx(sl,{className:"w-3 h-3"}),cls:"bg-muted text-muted-foreground"},processing:{label:"Processing",icon:o.jsx(Qe,{className:"w-3 h-3 animate-spin"}),cls:"bg-blue-500/10 text-blue-500"},matched:{label:"Matched",icon:o.jsx(Ks,{className:"w-3 h-3"}),cls:"bg-emerald-500/10 text-emerald-500"},no_match:{label:"No Match",icon:o.jsx(sm,{className:"w-3 h-3"}),cls:"bg-amber-500/10 text-amber-600"},error:{label:"Error",icon:o.jsx(Iw,{className:"w-3 h-3"}),cls:"bg-destructive/10 text-destructive"},duplicate:{label:"Duplicate",icon:o.jsx(tC,{className:"w-3 h-3"}),cls:"bg-violet-500/10 text-violet-500"}},n=e[t]??e.pending;return o.jsxs("span",{className:ve("inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full",n.cls),children:[n.icon,n.label]})}function X6({source:t}){const e={upload:"📄",dropzone:"📂",email:"📧",url:"🔗"};return o.jsxs("span",{className:"text-xs text-muted-foreground",children:[e[t]??"📄"," ",t]})}function J6(t){return t?t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`:""}function Q6({tags:t,activeFilters:e,onToggle:n}){if(!t.length)return null;const r=t.slice(0,3),l=t.length-r.length;return o.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[r.map(u=>o.jsx("button",{onClick:d=>n(u,d),className:ve("inline-flex items-center text-[9px] px-1.5 py-0 rounded-full border transition-all",Ap(u),e.has(u)&&"ring-1 ring-current font-semibold"),children:u},u)),l>0&&o.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["+",l]})]})}function Z6({allTags:t,activeFilters:e,onToggle:n,onClear:r}){return t.length?o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[o.jsx(du,{className:"w-3 h-3"}),o.jsx("span",{children:"Filter by tag:"})]}),o.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.map(l=>o.jsx("button",{onClick:()=>n(l),className:ve("inline-flex items-center text-[10px] px-2 py-0.5 rounded-full border transition-all",Ap(l),e.has(l)?"ring-1 ring-current font-semibold shadow-sm":"opacity-70 hover:opacity-100"),children:l},l))}),e.size>0&&o.jsxs("button",{onClick:r,className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(Ps,{className:"w-3 h-3"}),"Clear"]})]}):null}const $f=20;function eP({page:t,total:e,pageSize:n,onPage:r}){const l=Math.max(1,Math.ceil(e/n));if(l<=1&&e<=n)return null;const u=e===0?0:(t-1)*n+1,d=Math.min(t*n,e);return o.jsxs("div",{className:"flex items-center justify-between px-1 pt-2",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:e===0?"No results":`${u}–${d} of ${e}`}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-2 rounded-lg",onClick:()=>r(t-1),disabled:t<=1,children:o.jsx(tl,{className:"w-3.5 h-3.5"})}),o.jsxs("span",{className:"text-xs text-muted-foreground px-2",children:["Page ",t," of ",l]}),o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-2 rounded-lg",onClick:()=>r(t+1),disabled:t>=l,children:o.jsx(pi,{className:"w-3.5 h-3.5"})})]})]})}function tP({onComposePolicyForDoc:t}){const[e,n]=v.useState([]),[r,l]=v.useState(0),[u,d]=v.useState(1),[h,m]=v.useState(!0),[p,y]=v.useState(!1),[x,w]=v.useState(!1),[j,k]=v.useState(null),[S,_]=v.useState(null),[T,C]=v.useState(null),[A,E]=v.useState(new Set),[M,P]=v.useState([]),[U,R]=v.useState(""),[B,se]=v.useState(""),re=v.useRef(null),ue=v.useRef(null),xe=L=>{R(L),re.current&&clearTimeout(re.current),re.current=setTimeout(()=>{se(L),d(1)},300)},ge=v.useCallback(async(L=u)=>{if(j===null)return;m(!0);const J=await be.getIngestions({page:L,pageSize:$f,q:B||void 0},j),H=J?.data?.ingestions??[];n(H),l(J?.data?.total??0),m(!1),P(ae=>[...new Set([...ae,...H.flatMap($=>$.tags??[])])].sort())},[j,B,u]);v.useEffect(()=>{const L=hs();L&&L.auth.getSession().then(({data:J})=>{k(J.session?.access_token??null)})},[]),v.useEffect(()=>{j!==null&&ge(u)},[j,B,u]);const X=v.useMemo(()=>A.size?e.filter(L=>[...A].every(J=>L.tags?.includes(J))):e,[e,A]),V=L=>{E(J=>{const H=new Set(J);return H.has(L)?H.delete(L):H.add(L),H}),d(1)},F=async L=>{const J=Array.from(L);if(J.length){w(!0);try{for(const H of J){he.info(`Ingesting ${H.name}…`);const ae=await be.uploadDocument?.(H,j);if(ae?.success)if(ae.ingestion?.status==="duplicate"){const ie=ae.ingestion.extracted?.original_filename??"a previous upload";he.warning(`${H.name} is a duplicate of "${ie}" — skipped.`)}else he.success(`${H.name} → ${ae.ingestion?.status}`);else he.error(`Failed to ingest ${H.name}`)}d(1),await ge(1)}finally{w(!1)}}},Z=L=>{L.preventDefault(),y(!1),F(L.dataTransfer.files)},ye=async(L,J)=>{J.stopPropagation(),await be.rerunIngestion?.(L,j),he.success("Re-running…"),await ge(u)},ne=async(L,J)=>{if(J.stopPropagation(),!window.confirm("Delete this ingestion record?"))return;await be.deleteIngestion?.(L,j),he.success("Deleted.");const H=r-1,ae=Math.max(1,Math.ceil(H/$f)),ie=Math.min(u,ae);d(ie),await ge(ie)},D=async(L,J)=>{n(H=>H.map(ae=>ae.id===L?{...ae,tags:J}:ae)),S?.id===L&&_(H=>H&&{...H,tags:J}),await be.updateIngestionTags(L,J,j),P(H=>[...new Set([...H,...J])].sort())};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-6 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-9 h-9 rounded-xl bg-primary/10 flex items-center justify-center",children:o.jsx($w,{className:"w-5 h-5 text-primary"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold",children:"Funnel"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Document ingestion pipeline"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(oe,{variant:"outline",size:"sm",onClick:()=>ge(u),className:"gap-2 rounded-xl",children:[o.jsx(ma,{className:"w-3.5 h-3.5"}),"Refresh"]}),o.jsxs(oe,{size:"sm",onClick:()=>ue.current?.click(),disabled:x,className:"gap-2 rounded-xl",children:[x?o.jsx(Qe,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(nm,{className:"w-3.5 h-3.5"}),"Upload"]}),o.jsx("input",{ref:ue,type:"file",multiple:!0,hidden:!0,onChange:L=>L.target.files&&F(L.target.files)})]})]}),o.jsxs("div",{onDragOver:L=>{L.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:Z,onClick:()=>ue.current?.click(),className:ve("rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-2 py-8",p?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx(nm,{className:ve("w-8 h-8 transition-colors",p?"text-primary":"text-muted-foreground/50")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:p?"Drop to ingest":"Drag & drop files here, or click to browse"}),o.jsx("p",{className:"text-xs text-muted-foreground/60",children:".txt, .md, .pdf, .docx — up to 20MB"})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx(KC,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none"}),o.jsx("input",{type:"text",value:U,onChange:L=>xe(L.target.value),placeholder:"Search filename, policy, summary…",className:"w-full pl-9 pr-9 py-2 text-sm rounded-xl border bg-background placeholder:text-muted-foreground/50 outline-none focus:ring-2 focus:ring-primary/30 transition"}),U&&o.jsx("button",{onClick:()=>{R(""),se(""),d(1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(Ps,{className:"w-3.5 h-3.5"})})]}),M.length>0&&o.jsx(Z6,{allTags:M,activeFilters:A,onToggle:V,onClear:()=>E(new Set)})]}),o.jsx("div",{className:"rounded-2xl border overflow-hidden",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{className:"bg-muted/40 border-b",children:o.jsxs("tr",{children:[o.jsx("th",{className:"text-left px-5 py-3 text-xs font-semibold text-muted-foreground",children:"File"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Status"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Policy"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Source"}),o.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-muted-foreground",children:"Date"}),o.jsx("th",{className:"px-4 py-3"})]})}),o.jsx("tbody",{className:"divide-y",children:h?o.jsx("tr",{children:o.jsxs("td",{colSpan:6,className:"text-center py-12 text-muted-foreground",children:[o.jsx(Qe,{className:"w-5 h-5 animate-spin mx-auto mb-2"}),"Loading…"]})}):X.length===0?o.jsx("tr",{children:o.jsxs("td",{colSpan:6,className:"text-center py-16 text-muted-foreground",children:[o.jsx(qm,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:B||A.size>0?"No documents match your search.":"No ingestions yet — upload a document above."}),(B||A.size>0)&&o.jsx("button",{className:"mt-2 text-xs text-primary hover:underline",onClick:()=>{R(""),se(""),E(new Set),d(1)},children:"Clear filters"})]})}):X.map(L=>o.jsxs("tr",{onClick:()=>_(L),className:ve("cursor-pointer transition-colors",L.status==="processing"?"animate-pulse bg-blue-500/5 hover:bg-blue-500/10":"hover:bg-muted/30"),children:[o.jsxs("td",{className:"px-5 py-3.5",children:[o.jsx("div",{className:"font-medium text-sm truncate max-w-[220px]",title:L.filename,children:L.filename}),L.status==="duplicate"?o.jsxs("div",{className:"text-xs text-violet-500/80 truncate max-w-[220px]",children:["↳ ",L.extracted?.original_filename??"previously processed"]}):L.file_size&&o.jsx("div",{className:"text-xs text-muted-foreground",children:J6(L.file_size)}),o.jsx(Q6,{tags:L.tags??[],activeFilters:A,onToggle:(J,H)=>{H.stopPropagation(),V(J)}})]}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx(W6,{status:L.status})}),o.jsx("td",{className:"px-4 py-3.5",children:L.policy_name?o.jsx(wt,{variant:"secondary",className:"text-[10px]",children:L.policy_name}):o.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"—"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx(X6,{source:L.source})}),o.jsx("td",{className:"px-4 py-3.5 text-xs text-muted-foreground whitespace-nowrap",children:new Date(L.created_at).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[o.jsx("button",{title:"View Processing Trace",onClick:J=>{J.stopPropagation(),C(L)},className:"text-muted-foreground hover:text-emerald-500 p-1 transition-colors",children:o.jsx(Go,{className:"w-3.5 h-3.5"})}),o.jsx("button",{title:"Re-run",onClick:J=>ye(L.id,J),className:"text-muted-foreground hover:text-foreground p-1 transition-colors",children:o.jsx(ma,{className:"w-3.5 h-3.5"})}),o.jsx("button",{title:"Delete",onClick:J=>ne(L.id,J),className:"text-muted-foreground hover:text-destructive p-1 transition-colors",children:o.jsx(sr,{className:"w-3.5 h-3.5"})}),o.jsx(pi,{className:"w-3.5 h-3.5 text-muted-foreground/40"})]})})]},L.id))})]})}),o.jsx(eP,{page:u,total:r,pageSize:$f,onPage:L=>d(L)}),S&&o.jsx(F6,{ingestion:S,onClose:()=>_(null),onTagsChange:L=>D(S.id,L),onRerun:async()=>{await be.rerunIngestion?.(S.id,j),await ge(u),_(null),he.success("Re-running ingestion…")},onComposePolicy:t?L=>{_(null),t(L)}:void 0,onManualMatch:async({policyId:L,learn:J,rerun:H,allowSideEffects:ae})=>{const ie=await be.matchIngestionToPolicy(S.id,{policyId:L,learn:J,rerun:H,allowSideEffects:ae},j);if(ie?.error){const fe=typeof ie.error=="string"?ie.error:ie.error.message;throw new Error(fe||"Failed to match ingestion to policy.")}const $=ie?.data?.ingestion;if(!$)throw new Error("Match succeeded but updated ingestion payload is missing.");$&&(n(fe=>fe.map(le=>le.id===$.id?$:le)),_($)),await ge(u),H?he.success(J?"Policy matched, learned, and re-run started.":"Policy matched and re-run started."):he.success(J?"Policy match saved and learned.":"Policy match saved.")}}),T&&o.jsx(Y6,{ingestion:T,onClose:()=>C(null)})]})}function sP({activeSessionId:t,onSelectSession:e,refreshTrigger:n}){const[r,l]=v.useState([]),[u,d]=v.useState(!0),h=v.useCallback(async()=>{const y=hs();if(!y)return null;const{data:x}=await y.auth.getSession();return x.session?.access_token??null},[]),m=v.useCallback(async()=>{try{const y=await h(),x=await be.getChatSessions(y);x.data?.success&&l(x.data.sessions)}catch(y){console.error("Failed to fetch sessions",y)}finally{d(!1)}},[h]);v.useEffect(()=>{m()},[m,n]);const p=async(y,x)=>{y.stopPropagation();try{const w=await hs();if(!w)return;const{error:j}=await w.from("chat_sessions").delete().eq("id",x);j||(l(k=>k.filter(S=>S.id!==x)),t===x&&e(null))}catch(w){console.error(w)}};return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx("div",{className:"p-3 border-b border-border bg-surface/15",children:o.jsxs("button",{onClick:()=>e(null),className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-primary/10 hover:bg-primary/20 text-primary rounded-xl transition-all font-semibold text-sm border border-primary/20 cursor-pointer",children:[o.jsx(er,{size:16}),"New Chat"]})}),o.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1 scrollbar-on-hover",children:u?o.jsx("div",{className:"p-4 text-center text-xs text-muted-foreground",children:"Loading..."}):r.length===0?o.jsxs("div",{className:"p-8 text-center text-muted-foreground",children:[o.jsx(uu,{size:24,className:"mx-auto opacity-20 mb-2"}),o.jsx("p",{className:"text-xs font-medium",children:"No chat history"}),o.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-muted-foreground/80",children:"Conversations are private to your account in this workspace."})]}):r.map(y=>o.jsxs("div",{onClick:()=>e(y.id),className:`group flex items-center justify-between px-3 py-3 rounded-lg cursor-pointer transition-all text-sm ${t===y.id?"bg-primary/15 text-foreground ring-1 ring-primary/30 font-medium":"text-muted-foreground hover:bg-surface/50 hover:text-foreground"}`,children:[o.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[o.jsx(uu,{size:14,className:t===y.id?"text-primary":"opacity-50"}),o.jsx("span",{className:"truncate",children:y.title})]}),o.jsx("button",{onClick:x=>p(x,y.id),className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-destructive/10 hover:text-destructive rounded transition-all",children:o.jsx(sr,{size:12})})]},y.id))})]})}function nP({message:t}){const e=t.role==="user",n=r=>r.split(`
|
|
113
|
+
`).map((l,u)=>o.jsxs("span",{children:[l,o.jsx("br",{})]},u));return o.jsx("div",{className:`flex w-full ${e?"justify-end":"justify-start"}`,children:o.jsxs("div",{className:`flex gap-3 max-w-[85%] ${e?"flex-row-reverse":"flex-row"}`,children:[o.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 shadow-sm ${e?"bg-primary text-primary-foreground":"bg-surface border border-border shadow-inner text-foreground"}`,children:e?o.jsx(Eu,{size:14,strokeWidth:2.5}):o.jsx(tm,{size:14,className:"text-primary",strokeWidth:2.5})}),o.jsxs("div",{className:`flex flex-col ${e?"items-end":"items-start"}`,children:[o.jsx("div",{className:`px-4 py-3 rounded-2xl text-[13px] leading-relaxed shadow-sm ${e?"bg-primary text-primary-foreground rounded-tr-sm":"bg-surface border border-border/60 text-foreground rounded-tl-sm"}`,children:o.jsx("div",{className:"font-sans break-words whitespace-pre-wrap",children:n(t.content)})}),o.jsxs("div",{className:"flex items-center gap-2 mt-1.5 px-1",children:[o.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-medium tracking-wide",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),!e&&t.context_sources&&t.context_sources.length>0&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-secondary/20 text-secondary border border-secondary/20 flex items-center gap-1 font-medium",children:[o.jsx(tm,{size:10}),t.context_sources.length," sources"]})]})]})]})})}function Kc(t){return typeof t=="string"?t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?t.message:"Request failed"}function aP({sessionId:t,onContextUpdate:e,onSessionCreated:n}){const[r,l]=v.useState([]),[u,d]=v.useState(""),[h,m]=v.useState(!1),[p,y]=v.useState(!1),[x,w]=v.useState(!1),j=v.useRef(null),k=v.useRef(null),S=v.useRef(!0),_=v.useRef(null),T=v.useRef(null),C=v.useRef(null),A=v.useCallback(async()=>{const B=hs();if(!B)return null;const{data:se}=await B.auth.getSession();return se.session?.access_token??null},[]),E=v.useCallback(async B=>{try{const se=await A();if(!se)throw new Error("Authentication required");const re=await be.getChatMessages(B,se);if(re.error)throw new Error(Kc(re.error));if(re.data?.success&&T.current===B){l(re.data.messages);const ue=re.data.messages.filter(xe=>xe.role==="assistant"&&Array.isArray(xe.context_sources)).flatMap(xe=>xe.context_sources??[]);e(ue)}}catch(se){console.error("Failed to fetch messages",se),he.error("Failed to load chat history")}finally{T.current===B&&w(!1)}},[A,e]);v.useEffect(()=>{if(t){if(C.current===t){C.current=null,w(!1);return}l([]),w(!0),T.current=t,E(t)}else l([]),w(!1),e([]),T.current=null},[t,E,e]),v.useEffect(()=>{S.current&&j.current&&j.current.scrollIntoView({behavior:"smooth"})},[r,p]);const M=()=>{const B=k.current;if(!B)return;const se=B.scrollHeight-B.scrollTop-B.clientHeight;S.current=se<64},P=async B=>{if(B?.preventDefault(),!u.trim()||h)return;const se=u.trim();d(""),_.current&&(_.current.style.height="auto"),m(!0),y(!0);try{const re=await A();if(!re)throw new Error("Authentication required");const ue={id:"temp-"+Date.now(),role:"user",content:se,created_at:new Date().toISOString()};l(V=>[...V,ue]);let xe=t;if(!xe){const V=await be.createChatSession(re);if(V.error)throw new Error(Kc(V.error));if(V.data?.success)xe=V.data.session.id,C.current=xe,n(xe);else throw new Error("Failed to create session")}const ge=await be.sendChatMessage({sessionId:xe,content:se},re);if(ge.error)throw new Error(Kc(ge.error));const X=ge.data?.message;ge.data?.success&&X&&(l(V=>[...V,X]),X.context_sources&&X.context_sources.length>0&&e(X.context_sources))}catch(re){console.error("Message failed",re),he.error(Kc(re)||"Failed to send message"),l(ue=>[...ue,{id:"err-"+Date.now(),role:"assistant",content:"I encountered an error trying to process that request.",created_at:new Date().toISOString()}])}finally{m(!1),y(!1)}},U=B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),P())},R=["Find me the latest invoice from AWS.","What is the late penalty on the ACME contract?","Show me receipts from last week.","Summarize my recent cloud hosting expenses."];return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:k,onScroll:M,className:"flex-1 overflow-y-auto p-5 space-y-6 scrollbar-on-hover",children:[x?o.jsxs("div",{className:"flex-1 h-full flex items-center justify-center text-muted-foreground gap-2",children:[o.jsx(ma,{size:18,className:"animate-spin"}),o.jsx("span",{className:"text-sm",children:"Loading history..."})]}):r.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center text-muted-foreground/80",children:[o.jsx("div",{className:"w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center mb-6 text-primary",children:o.jsx(Cn,{size:32})}),o.jsx("h3",{className:"text-2xl font-bold mb-3 text-foreground tracking-tight",children:"Chat with your Documents"}),o.jsx("p",{className:"text-sm max-w-sm mx-auto mb-10 leading-relaxed",children:"Folio has seamlessly read and memorized your files using Semantic Search. Ask any question to retrieve precise answers and exact page citations."}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-w-lg w-full",children:R.map((B,se)=>o.jsx("button",{onClick:()=>d(B),className:"text-left p-3.5 text-xs font-medium bg-surface/30 hover:bg-surface border border-border/50 hover:border-border rounded-xl transition-all cursor-pointer shadow-sm hover:shadow",children:B},se))})]}):o.jsxs(o.Fragment,{children:[r.map(B=>o.jsx(nP,{message:B},B.id)),o.jsx(kp,{children:p&&o.jsx(Do.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"flex justify-start w-full",children:o.jsx("div",{className:"bg-surface border border-border/50 rounded-2xl rounded-tl-none px-4 py-3.5 flex items-center gap-3 shadow-sm",children:o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0s"}}),o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.15s"}}),o.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.3s"}})]})})})})]}),o.jsx("div",{ref:j})]}),o.jsx("div",{className:"p-4 bg-surface/40 backdrop-blur-xl border-t border-border/50",children:o.jsx("form",{onSubmit:P,className:"relative max-w-4xl mx-auto",children:o.jsxs("div",{className:"relative flex items-end gap-2 bg-surface/80 border border-border/60 hover:border-border rounded-2xl px-3 py-2 shadow-sm transition-all focus-within:ring-2 focus-within:ring-primary/20 focus-within:border-primary/50",children:[o.jsx("textarea",{ref:_,value:u,onChange:B=>{d(B.target.value),B.target.style.height="auto",B.target.style.height=Math.min(B.target.scrollHeight,200)+"px"},onKeyDown:U,placeholder:"Message Folio AI...",rows:1,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-none py-2.5 pl-1 text-sm text-foreground resize-none min-h-[44px] max-h-[200px] placeholder:text-muted-foreground/50",disabled:h}),o.jsx("button",{type:"submit",disabled:!u.trim()||h,className:"p-2.5 mb-1 bg-primary text-primary-foreground rounded-xl shadow-md hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all shrink-0 cursor-pointer",children:h?o.jsx(ma,{size:18,className:"animate-spin"}):o.jsx(WC,{size:18})})]})})})]})}function rP({sources:t,onClose:e}){return!t||t.length===0?null:o.jsx(kp,{children:o.jsxs(Do.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"flex flex-col h-full",children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between bg-surface/15",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground/80",children:[o.jsx(DE,{size:16,className:"text-secondary"}),o.jsx("span",{children:"Retrieved Context"})]}),o.jsx("button",{onClick:e,className:"p-1 hover:bg-surface rounded-md text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:o.jsx(Ps,{size:14})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3 scrollbar-on-hover",children:t.map((n,r)=>{const l=Math.round(n.similarity*100);return o.jsxs("div",{className:"p-3 bg-surface/20 hover:bg-surface/50 border border-border rounded-xl transition-all group",children:[o.jsxs("div",{className:"flex justify-between items-start mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold",children:[o.jsx("span",{className:"flex items-center justify-center w-4 h-4 bg-primary/10 text-primary rounded",children:r+1}),o.jsxs("span",{className:`px-1.5 py-0.5 rounded border ${l>=80?"bg-amber-500/10 text-amber-600 border-amber-500/20":"bg-blue-500/10 text-blue-500 border-blue-500/20"}`,children:[l,"% Match"]})]}),o.jsx("button",{onClick:()=>{console.log("Open Ingestion ID:",n.ingestion_id)},className:"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-muted-foreground hover:text-primary transition-opacity focus-visible:ring-2 focus-visible:ring-primary/40 rounded cursor-pointer",title:"View Source Document",children:o.jsx(Vw,{size:12})})]}),o.jsxs("div",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-4 font-mono bg-black/5 p-2 rounded-lg border border-border/40",children:['"',n.content,'"']})]},r)})}),o.jsxs("div",{className:"p-3 border-t border-border bg-surface/20 text-[10px] text-center text-muted-foreground/50 font-medium",children:[t.length," document chunk",t.length!==1?"s":""," retrieved"]})]})})}function iP(){const[t,e]=v.useState(null),[n,r]=v.useState([]),[l,u]=v.useState(!1),[d,h]=v.useState(0),m=v.useCallback(y=>{e(y),h(x=>x+1)},[]),p=v.useCallback(y=>{r(y),y.length>0&&u(!0)},[]);return o.jsxs("div",{className:"flex w-full h-[calc(100vh-15rem)] min-h-[540px] gap-4 overflow-hidden animate-in fade-in duration-500",children:[o.jsx("div",{className:"w-64 shrink-0 flex flex-col h-full bg-surface/25 backdrop-blur-xl border border-border rounded-xl overflow-hidden shadow-sm",children:o.jsx(sP,{activeSessionId:t,onSelectSession:e,refreshTrigger:d})}),o.jsx("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-surface/60 rounded-xl overflow-hidden border border-border relative shadow-sm",children:o.jsx(aP,{sessionId:t,onContextUpdate:p,onSessionCreated:m})}),l&&o.jsx("div",{className:"w-80 shrink-0 flex flex-col h-full bg-surface/25 backdrop-blur-xl border border-border rounded-xl overflow-hidden shadow-sm",children:o.jsx(rP,{sources:n,onClose:()=>u(!1)})})]})}const Dj=v.createContext(void 0);function oP({children:t}){const[e,n]=v.useState(!1),r=v.useCallback(()=>n(!0),[]),l=v.useCallback(()=>n(!1),[]),u=v.useMemo(()=>({isExpanded:e,setIsExpanded:n,openTerminal:r,closeTerminal:l}),[e,r,l]);return o.jsx(Dj.Provider,{value:u,children:t})}function lP(){const t=v.useContext(Dj);if(t===void 0)throw new Error("useTerminal must be used within a TerminalProvider");return t}const cP=/(https?:\/\/[^\s<>"'`]+)/g;function qf(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Pj(t){if(typeof t!="string"||t.trim().length===0)return null;try{const e=new URL(t.trim());return e.protocol!=="http:"&&e.protocol!=="https:"?null:e.toString()}catch{return null}}function uP(t){if(!qf(t)||!qf(t.remediation))return null;const e=t.remediation,n=typeof e.title=="string"?e.title.trim():"",r=typeof e.summary=="string"?e.summary.trim():"",l=typeof e.code=="string"?e.code.trim():"",u=Array.isArray(e.steps)?e.steps.filter(h=>typeof h=="string").map(h=>h.trim()).filter(Boolean):[],d=Array.isArray(e.links)?e.links.filter(qf).map(h=>{const m=Pj(h.url);return m?{label:typeof h.label=="string"&&h.label.trim().length>0?h.label.trim():"Open help link",url:m}:null}).filter(h=>h!==null):[];return!n&&!r&&!l&&u.length===0&&d.length===0?null:{...n?{title:n}:{},...r?{summary:r}:{},...l?{code:l}:{},steps:u,links:d}}function Yc(t){const e=[];let n=0;for(const r of t.matchAll(cP)){const l=r[0]??"",u=r.index??0,d=u+l.length;u>n&&e.push(o.jsx("span",{children:t.slice(n,u)},`txt-${n}-${u}`));const h=Pj(l);h?e.push(o.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 decoration-current/50 hover:decoration-current",onClick:m=>m.stopPropagation(),children:h},`url-${u}-${h}`)):e.push(o.jsx("span",{children:l},`txt-${u}-${d}`)),n=d}return n<t.length&&e.push(o.jsx("span",{children:t.slice(n)},`txt-${n}-${t.length}`)),e.length>0?o.jsx(o.Fragment,{children:e}):t}function dP(){const t=hs(),{isExpanded:e,openTerminal:n,closeTerminal:r}=lP(),[l,u]=v.useState([]),[d,h]=v.useState(new Set),[m,p]=v.useState(!1),y=v.useRef(null);v.useEffect(()=>{let _=!0;const T=async()=>{if(!t)return;const{data:{user:E}}=await t.auth.getUser();if(!E)return;const{data:M,error:P}=await t.from("processing_events").select("*").eq("user_id",E.id).order("created_at",{ascending:!1}).limit(50);if(M&&_){u(M);const U=new Set;M.forEach(R=>{R.event_type==="error"&&R.details?.error&&U.add(R.id)}),h(U)}},C=async()=>{if(!t)return null;const{data:{user:E}}=await t.auth.getUser();return E?t.channel("processing_events_realtime").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events",filter:`user_id=eq.${E.id}`},M=>{const P=M.new;_&&(P.event_type==="error"&&P.details?.error&&h(U=>new Set(U).add(P.id)),P.details?.is_completion||(P.event_type==="error"||P.agent_state==="action"||P.agent_state==="extraction"||P.details?.is_high_intent===!0)&&n(),u(U=>{const R=[P,...U];return P.details?.is_completion&&setTimeout(()=>{_&&r()},3e3),R.length>100?R.slice(0,100):R}),p(!0),setTimeout(()=>p(!1),500))}).subscribe():null};T();const A=C();return()=>{_=!1,A.then(E=>{E&&t&&t.removeChannel(E)})}},[t,n,r]);const x=(_,T)=>{T.stopPropagation(),h(C=>{const A=new Set(C);return A.has(_)?A.delete(_):A.add(_),A})},w=_=>{switch(_.event_type){case"error":return"border-l-rose-500/50 bg-rose-500/5 text-rose-200";case"action":return"border-l-indigo-500/50 bg-indigo-500/5 text-indigo-200";case"analysis":return"border-l-amber-500/50 bg-amber-500/5 text-amber-200";default:return"border-l-emerald-500/30 text-emerald-100 hover:bg-white/5"}},j=_=>{if(!_)return o.jsx(mi,{className:"w-3.5 h-3.5"});const T=_.toLowerCase();return T.includes("triage")?o.jsx(hC,{className:"w-3.5 h-3.5"}):T.includes("extraction")?o.jsx(Uw,{className:"w-3.5 h-3.5"}):T.includes("matching")?o.jsx(Gm,{className:"w-3.5 h-3.5"}):T.includes("action")?o.jsx(Fw,{className:"w-3.5 h-3.5"}):T.includes("completed")?o.jsx(Ks,{className:"w-3.5 h-3.5"}):T.includes("error")?o.jsx(Ho,{className:"w-3.5 h-3.5"}):o.jsx($m,{className:"w-3.5 h-3.5"})},k=_=>_||"System",S=_=>{const T=_.details?.action||_.details?.error;if(typeof T=="string"&&T.trim().length>0)return T;const C=JSON.stringify(_.details);return typeof C=="string"&&C.trim().length>0?C:"Event received."};return e?o.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-[450px] bg-[#0A0D14] border border-white/10 rounded-xl shadow-2xl flex flex-col overflow-hidden transition-all duration-300 ease-out h-[600px] max-h-[85vh]",children:[o.jsxs("div",{className:"px-4 py-3 border-b border-white/10 bg-white/5 flex items-center justify-between shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Go,{className:"w-4 h-4 text-emerald-400"}),o.jsx("h3",{className:"font-semibold text-sm text-zinc-100 uppercase tracking-widest",children:"Live Trace"}),o.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-emerald-500/10 border border-emerald-500/20 ml-2",children:[o.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${m?"bg-emerald-400 animate-pulse":"bg-emerald-500/50"}`}),o.jsx("span",{className:"text-[9px] font-medium text-emerald-400/80 uppercase tracking-widest",children:m?"Streaming":"Connected"})]})]}),o.jsx("button",{onClick:_=>{_.stopPropagation(),r()},className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white transition-colors",children:o.jsx(Gw,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-2 font-mono text-xs flex flex-col gap-1.5 custom-scrollbar bg-[#05070A]",children:[l.length===0?o.jsxs("div",{className:"flex items-center justify-center h-full text-zinc-500 flex-col gap-2",children:[o.jsx(mi,{className:"w-6 h-6 opacity-20"}),o.jsx("span",{className:"text-sm",children:"Waiting for ingestion events..."})]}):l.map(_=>{const T=d.has(_.id),C=uP(_.details);return o.jsx("div",{className:`border-l-2 pl-3 py-2 pr-2 rounded-r-md transition-colors ${w(_)}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"shrink-0 pt-0.5 opacity-60",children:j(_.agent_state)}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:new Date(_.created_at).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsx("span",{className:"text-[10px] font-bold tracking-wider uppercase opacity-80 shrink-0",children:k(_.agent_state)}),_.ingestion_id&&o.jsx("span",{className:"text-[10px] text-zinc-500 truncate ml-auto uppercase",title:_.ingestion_id,children:_.ingestion_id.substring(0,8)})]}),o.jsx("div",{className:"leading-relaxed break-words whitespace-pre-wrap",children:Yc(S(_))}),_.event_type==="error"&&C&&o.jsxs("div",{className:"mt-2 rounded border border-amber-400/30 bg-amber-500/10 px-2.5 py-2 text-[10px] text-amber-100 space-y-1.5",children:[o.jsx("p",{className:"font-semibold uppercase tracking-wider text-[9px] text-amber-200",children:"Suggested Fix"}),C.title&&o.jsx("p",{className:"font-semibold text-amber-100",children:Yc(C.title)}),C.summary&&o.jsx("p",{className:"text-amber-100/90",children:Yc(C.summary)}),C.code&&o.jsxs("p",{className:"text-amber-200/90",children:["Code: ",C.code]}),C.steps.length>0&&o.jsx("ol",{className:"list-decimal pl-4 space-y-1 text-amber-100/90",children:C.steps.map(A=>o.jsx("li",{children:Yc(A)},`${_.id}-fix-step-${A}-${A.length}`))}),C.links.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:C.links.map(A=>o.jsx("a",{href:A.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center rounded border border-amber-300/40 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-amber-100 hover:bg-amber-300/10",onClick:E=>E.stopPropagation(),children:A.label},`${_.id}-fix-link-${A.url}`))})]}),_.event_type!=="info"&&_.details&&Object.keys(_.details).length>(_.details.action?1:0)&&o.jsx("div",{className:"mt-2 text-[10px]",children:_.event_type==="error"?o.jsxs("div",{className:"bg-rose-950/30 rounded border border-rose-500/20 overflow-hidden",children:[o.jsxs("button",{className:"w-full text-left px-2 py-1 flex justify-between items-center hover:bg-rose-500/10 text-rose-300 font-semibold uppercase tracking-wider text-[9px]",onClick:A=>x(_.id,A),children:[o.jsx("span",{children:"Error Details"}),o.jsx("span",{className:"opacity-50",children:T?"Hide":"Show"})]}),T&&o.jsx("pre",{className:"p-2 border-t border-rose-500/20 overflow-x-auto text-rose-200/80 custom-scrollbar",children:JSON.stringify(_.details,null,2)})]}):o.jsx("div",{className:"bg-black/20 rounded border border-white/5 p-2 overflow-x-auto text-white/50 custom-scrollbar",children:o.jsx("pre",{children:JSON.stringify(Object.fromEntries(Object.entries(_.details).filter(([A])=>A!=="action")),null,2)})})})]})]})},_.id)}),o.jsx("div",{ref:y,className:"h-4 shrink-0"})]}),o.jsxs("div",{className:"shrink-0 p-3 bg-white/5 border-t border-white/10 flex items-center gap-2 text-zinc-500 text-xs",children:[o.jsx("span",{className:"text-emerald-500/50 font-bold",children:"➜"}),o.jsx("span",{className:"animate-pulse",children:"_"})]})]}):o.jsxs("button",{type:"button",className:"fixed bottom-4 right-4 z-50 bg-[#0A0D14] border border-white/10 rounded-full py-2 px-4 shadow-xl flex items-center gap-3 cursor-pointer transition-all hover:bg-[#11141D] hover:border-white/20",onClick:n,children:[o.jsxs("div",{className:"relative",children:[o.jsx(Go,{className:`w-4 h-4 ${m?"text-emerald-400":"text-zinc-400"}`}),m&&o.jsx("div",{className:"absolute inset-0 bg-emerald-400/20 blur-sm rounded-full animate-pulse"})]}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-xs font-medium text-zinc-200",children:"Live Trace"}),o.jsx("span",{className:"text-[10px] text-zinc-500 leading-none mt-0.5",children:l.length>0?k(l[0].agent_state):"Idle"})]}),o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/50 shadow-[0_0_8px_rgba(16,185,129,0.5)] ml-1"})]})}function hP(){const t=v.useMemo(()=>Fo(),[]),[e,n]=v.useState("dashboard"),[r,l]=v.useState(null),[u,d]=v.useState(!t),[h,m]=v.useState(!1),[p,y]=v.useState("not_checked"),[x,w]=v.useState("Folio ready. Run setup to configure runtime contracts."),[j,k]=v.useState(t),S=EA(),[_,T]=v.useState(!1),[C,A]=v.useState(0),[E,M]=v.useState("unknown"),[P,U]=v.useState("unknown"),[R,B]=v.useState(null),[se,re]=v.useState(null),[ue,xe]=v.useState(!1),[ge,X]=v.useState(()=>{const $=localStorage.getItem("folio_migration_snoozed_until");return $?new Date($):null}),[V,F]=v.useState(null),Z=v.useMemo(()=>j?Bm(j.url,j.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}}):null,[j]);v.useEffect(()=>{if(!Z){U("unknown"),B(null);return}const{data:$}=Z.auth.onAuthStateChange((fe,le)=>{U(le?.user?"authenticated":"anonymous"),B(le?.user?.email??null),A(Oe=>Oe+1)});return()=>{$.subscription.unsubscribe()}},[Z]),v.useEffect(()=>{let $=!1;async function fe(Oe,Ue){const ft=Promise.resolve(Oe);let Ye=null;const de=new Promise((Fe,pe)=>{Ye=setTimeout(()=>{pe(new Error(`Operation timed out after ${Ue}ms`))},Ue)});try{return await Promise.race([ft,de])}finally{Ye&&clearTimeout(Ye)}}async function le(){if(!Z){M("unknown"),U("unknown"),B(null),re(null),F(null);return}T(!0),F(null);try{const{data:Oe,error:Ue}=await fe(Z.from("init_state").select("is_initialized").single(),12e3);if(Ue)if(Ue.code==="42P01")M("missing_view");else throw M("error"),new Error(Ue.message||"Failed to query init_state");else{const Fe=Number(Oe.is_initialized??0)>0;M(Fe?"initialized":"empty")}const{data:ft,error:Ye}=await fe(Z.auth.getSession(),12e3);if(Ye)U("error"),B(null);else{const Fe=ft.session?.user??null;U(Fe?"authenticated":"anonymous"),B(Fe?.email??null)}const de=await fe(O1(Z),12e3);re(de)}catch(Oe){const Ue=Oe instanceof Error?Oe.message:String(Oe);$||(F(Ue),w(`Bootstrap check failed: ${Ue}`))}finally{$||T(!1)}}return le(),()=>{$=!0}},[Z,C]);function ye(){const $=Fo();k($),d(!1),w("Setup complete. Foundation runtime is configured."),y("not_checked"),A(fe=>fe+1)}function ne(){kA(),k(null),M("unknown"),U("unknown"),B(null),re(null),F(null),d(!0),w("Stored setup was cleared. Run setup wizard again."),y("not_checked"),A($=>$+1)}function D(){A($=>$+1)}const L=$=>{X($),localStorage.setItem("folio_migration_snoozed_until",$.toISOString())},J=v.useMemo(()=>!(!se?.needsMigration||ge&&ge>new Date),[se,ge]),H=[{id:"dashboard",label:"Dashboard",icon:y0},{id:"chat",label:"Chat",icon:uu},{id:"funnel",label:"Funnel",icon:$w},{id:"policies",label:"Policies",icon:Yw},{id:"config",label:"Configuration",icon:Gm}];return u||!j?o.jsx("div",{className:"min-h-screen bg-background",children:o.jsx(b5,{open:u||!j,canClose:!!j,onComplete:ye})}):E==="empty"||E==="missing_view"||P!=="authenticated"?_&&E==="unknown"?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(Qe,{className:"w-10 h-10 animate-spin text-primary opacity-50"}),o.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.3em] text-muted-foreground animate-pulse",children:"Initializing Engine..."})]})}):o.jsx(m6,{supabase:Z,initStatus:E,onSuccess:D,onResetConfigs:ne},`login-${E}`):o.jsx(oP,{children:o.jsxs("div",{className:"min-h-screen bg-background text-foreground selection:bg-primary/10 flex flex-col font-sans animate-in fade-in duration-1000",children:[J&&se&&o.jsx(P6,{status:se,onSnooze:L,onOpenModal:()=>xe(!0)}),se&&o.jsx(L6,{open:ue,onOpenChange:xe,status:se,onSnooze:L}),o.jsx("header",{className:ve("border-b bg-background/80 backdrop-blur-xl sticky top-0 z-50 transition-all duration-500",J&&"mt-24 sm:mt-20"),children:o.jsxs("div",{className:"container max-w-[1400px] mx-auto px-8 h-20 flex items-center",children:[o.jsxs("div",{className:"flex items-center gap-3 w-[280px]",children:[o.jsx("div",{className:"w-9 h-9 flex items-center justify-center",children:o.jsx(lu,{className:"w-8 h-8"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h1",{className:"text-xl font-bold tracking-tight text-foreground/90",children:"Folio"}),o.jsx("div",{className:"flex items-center",children:o.jsxs("span",{className:"relative flex h-2 w-2",children:[o.jsx("span",{className:ve("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",p==="ok"?"bg-emerald-400":"bg-primary/40")}),o.jsx("span",{className:ve("relative inline-flex rounded-full h-2 w-2",p==="ok"?"bg-emerald-500":"bg-primary/60")})]})})]})]}),o.jsx("nav",{className:"flex-1 hidden md:flex items-center justify-center gap-2",children:H.map($=>o.jsxs("button",{onClick:()=>n($.id),className:ve("flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-semibold transition-all duration-300",e===$.id?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground/80 hover:bg-muted/60 hover:text-foreground"),children:[o.jsx($.icon,{className:ve("w-4.5 h-4.5",e===$.id?"text-primary":"text-muted-foreground/60")}),$.label]},$.id))}),o.jsxs("div",{className:"flex items-center justify-end gap-5 w-[280px]",children:[o.jsxs("div",{className:"hidden lg:flex items-center gap-2 px-3 py-1.5 bg-muted/40 rounded-full border border-border/40 cursor-pointer hover:bg-muted/60 transition-colors",children:[o.jsx("img",{src:"https://flagcdn.com/w40/us.png",className:"w-4 h-3 rounded-sm opacity-80",alt:"EN"}),o.jsx("span",{className:"text-[10px] font-extrabold tracking-widest text-muted-foreground",children:"EN"})]}),o.jsxs(oe,{variant:"ghost",size:"icon",className:ve("rounded-full h-9 w-9 transition-all relative group",se?.needsMigration?"text-red-500 hover:bg-red-500/10":"text-muted-foreground hover:bg-muted/60"),onClick:()=>m(!0),children:[o.jsx(mi,{className:ve("w-5 h-5",se?.needsMigration&&"animate-pulse")}),se?.needsMigration&&o.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-red-500 ring-4 ring-red-500/20 animate-ping"})]}),o.jsx(D1,{}),o.jsx("div",{className:"w-10 h-10 rounded-full overflow-hidden border-2 border-background shadow-lg cursor-pointer ring-1 ring-border/20",onClick:()=>n("account"),children:o.jsx("div",{className:"w-full h-full bg-primary flex items-center justify-center text-primary-foreground font-black text-xs",children:R?.charAt(0).toUpperCase()||"A"})})]})]})}),o.jsxs("main",{className:"flex-1 w-full px-6 py-12 mx-auto max-w-[1600px]",children:[V&&o.jsxs(es,{variant:"destructive",className:"mb-10 animate-in fade-in slide-in-from-top-4 duration-500",children:[o.jsx(fs,{className:"h-5 w-5"}),o.jsx(Ru,{className:"font-bold",children:"Protocol Connection Failure"}),o.jsx(ts,{className:"text-[13px] opacity-90",children:V})]}),e==="dashboard"&&o.jsx(PA,{configSnapshot:j,configSource:S,setActivePage:n}),e==="chat"&&o.jsx(iP,{}),e==="funnel"&&o.jsx(tP,{onComposePolicyForDoc:$=>{l($),n("policies")}}),e==="policies"&&o.jsx(U6,{initialCompose:r,onInitialConsumed:()=>l(null)}),e==="config"&&o.jsx(D6,{}),e==="account"&&o.jsx(Y4,{supabase:Z,sessionEmail:R,sessionStatus:P,initStatus:E,configSnapshot:j,configSource:S,onRefresh:D,onLaunchSetup:()=>d(!0),onResetSetup:ne})]}),o.jsx(dP,{}),o.jsx("div",{className:"fixed bottom-6 left-6 z-[60]",children:o.jsx(oe,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full shadow-xl bg-background border border-border/40 text-muted-foreground hover:text-primary hover:scale-110 transition-all",children:o.jsx(y0,{className:"w-6 h-6"})})}),o.jsx("footer",{className:"border-t bg-card/20 py-10 mt-auto",children:o.jsxs("div",{className:"container max-w-7xl mx-auto px-8 flex items-center justify-between text-[11px] text-muted-foreground font-bold uppercase tracking-[0.2em] opacity-40",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{children:"Core Foundation Protocol"}),o.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground"}),o.jsx("span",{children:"2026"})]}),o.jsxs("div",{className:"flex items-center gap-8",children:[o.jsx("a",{href:"#",className:"hover:text-foreground transition-colors",children:"Whitepaper"}),o.jsx("a",{href:"#",className:"hover:text-foreground transition-colors",children:"Foundation Registry"})]})]})}),o.jsx(s5,{open:h,onOpenChange:m,health:p,isBootstrapping:_,initStatus:E||"unknown",sessionStatus:P||"unknown",migrationStatus:se,onRunMigration:()=>{m(!1),xe(!0)}})]})})}o2.createRoot(document.getElementById("root")).render(o.jsx(nw.StrictMode,{children:o.jsx(e5,{defaultTheme:"dark",storageKey:"folio-theme",children:o.jsx(y6,{children:o.jsx(x6,{children:o.jsxs(j6,{children:[o.jsx(hP,{}),o.jsx(DA,{})]})})})})}));
|