@suveren/gateway 0.3.5 → 0.3.7

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.
@@ -0,0 +1,105 @@
1
+ var Hf=Object.defineProperty;var Vf=(e,t,n)=>t in e?Hf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fo=(e,t,n)=>Vf(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const s of a)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const s={};return a.integrity&&(s.integrity=a.integrity),a.referrerPolicy&&(s.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?s.credentials="include":a.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(a){if(a.ep)return;a.ep=!0;const s=n(a);fetch(a.href,s)}})();var Xc={exports:{}},xo={},qc={exports:{}},Z={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var na=Symbol.for("react.element"),Kf=Symbol.for("react.portal"),Gf=Symbol.for("react.fragment"),Yf=Symbol.for("react.strict_mode"),Qf=Symbol.for("react.profiler"),Jf=Symbol.for("react.provider"),Xf=Symbol.for("react.context"),qf=Symbol.for("react.forward_ref"),Zf=Symbol.for("react.suspense"),em=Symbol.for("react.memo"),tm=Symbol.for("react.lazy"),jl=Symbol.iterator;function nm(e){return e===null||typeof e!="object"?null:(e=jl&&e[jl]||e["@@iterator"],typeof e=="function"?e:null)}var Zc={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},eu=Object.assign,tu={};function ir(e,t,n){this.props=e,this.context=t,this.refs=tu,this.updater=n||Zc}ir.prototype.isReactComponent={};ir.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ir.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function nu(){}nu.prototype=ir.prototype;function xi(e,t,n){this.props=e,this.context=t,this.refs=tu,this.updater=n||Zc}var wi=xi.prototype=new nu;wi.constructor=xi;eu(wi,ir.prototype);wi.isPureReactComponent=!0;var kl=Array.isArray,ru=Object.prototype.hasOwnProperty,Si={current:null},au={key:!0,ref:!0,__self:!0,__source:!0};function ou(e,t,n){var r,a={},s=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(s=""+t.key),t)ru.call(t,r)&&!au.hasOwnProperty(r)&&(a[r]=t[r]);var l=arguments.length-2;if(l===1)a.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];a.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)a[r]===void 0&&(a[r]=l[r]);return{$$typeof:na,type:e,key:s,ref:i,props:a,_owner:Si.current}}function rm(e,t){return{$$typeof:na,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function ji(e){return typeof e=="object"&&e!==null&&e.$$typeof===na}function am(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Cl=/\/+/g;function Oo(e,t){return typeof e=="object"&&e!==null&&e.key!=null?am(""+e.key):t.toString(36)}function Pa(e,t,n,r,a){var s=typeof e;(s==="undefined"||s==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(s){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case na:case Kf:i=!0}}if(i)return i=e,a=a(i),e=r===""?"."+Oo(i,0):r,kl(a)?(n="",e!=null&&(n=e.replace(Cl,"$&/")+"/"),Pa(a,t,n,"",function(u){return u})):a!=null&&(ji(a)&&(a=rm(a,n+(!a.key||i&&i.key===a.key?"":(""+a.key).replace(Cl,"$&/")+"/")+e)),t.push(a)),1;if(i=0,r=r===""?".":r+":",kl(e))for(var l=0;l<e.length;l++){s=e[l];var c=r+Oo(s,l);i+=Pa(s,t,n,c,a)}else if(c=nm(e),typeof c=="function")for(e=c.call(e),l=0;!(s=e.next()).done;)s=s.value,c=r+Oo(s,l++),i+=Pa(s,t,n,c,a);else if(s==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function ua(e,t,n){if(e==null)return e;var r=[],a=0;return Pa(e,r,"","",function(s){return t.call(n,s,a++)}),r}function om(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Be={current:null},Ta={transition:null},sm={ReactCurrentDispatcher:Be,ReactCurrentBatchConfig:Ta,ReactCurrentOwner:Si};function su(){throw Error("act(...) is not supported in production builds of React.")}Z.Children={map:ua,forEach:function(e,t,n){ua(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ua(e,function(){t++}),t},toArray:function(e){return ua(e,function(t){return t})||[]},only:function(e){if(!ji(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Z.Component=ir;Z.Fragment=Gf;Z.Profiler=Qf;Z.PureComponent=xi;Z.StrictMode=Yf;Z.Suspense=Zf;Z.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sm;Z.act=su;Z.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=eu({},e.props),a=e.key,s=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,i=Si.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)ru.call(t,c)&&!au.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:na,type:e.type,key:a,ref:s,props:r,_owner:i}};Z.createContext=function(e){return e={$$typeof:Xf,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Jf,_context:e},e.Consumer=e};Z.createElement=ou;Z.createFactory=function(e){var t=ou.bind(null,e);return t.type=e,t};Z.createRef=function(){return{current:null}};Z.forwardRef=function(e){return{$$typeof:qf,render:e}};Z.isValidElement=ji;Z.lazy=function(e){return{$$typeof:tm,_payload:{_status:-1,_result:e},_init:om}};Z.memo=function(e,t){return{$$typeof:em,type:e,compare:t===void 0?null:t}};Z.startTransition=function(e){var t=Ta.transition;Ta.transition={};try{e()}finally{Ta.transition=t}};Z.unstable_act=su;Z.useCallback=function(e,t){return Be.current.useCallback(e,t)};Z.useContext=function(e){return Be.current.useContext(e)};Z.useDebugValue=function(){};Z.useDeferredValue=function(e){return Be.current.useDeferredValue(e)};Z.useEffect=function(e,t){return Be.current.useEffect(e,t)};Z.useId=function(){return Be.current.useId()};Z.useImperativeHandle=function(e,t,n){return Be.current.useImperativeHandle(e,t,n)};Z.useInsertionEffect=function(e,t){return Be.current.useInsertionEffect(e,t)};Z.useLayoutEffect=function(e,t){return Be.current.useLayoutEffect(e,t)};Z.useMemo=function(e,t){return Be.current.useMemo(e,t)};Z.useReducer=function(e,t,n){return Be.current.useReducer(e,t,n)};Z.useRef=function(e){return Be.current.useRef(e)};Z.useState=function(e){return Be.current.useState(e)};Z.useSyncExternalStore=function(e,t,n){return Be.current.useSyncExternalStore(e,t,n)};Z.useTransition=function(){return Be.current.useTransition()};Z.version="18.3.1";qc.exports=Z;var d=qc.exports;/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var im=d,lm=Symbol.for("react.element"),cm=Symbol.for("react.fragment"),um=Object.prototype.hasOwnProperty,dm=im.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,fm={key:!0,ref:!0,__self:!0,__source:!0};function iu(e,t,n){var r,a={},s=null,i=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)um.call(t,r)&&!fm.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)a[r]===void 0&&(a[r]=t[r]);return{$$typeof:lm,type:e,key:s,ref:i,props:a,_owner:dm.current}}xo.Fragment=cm;xo.jsx=iu;xo.jsxs=iu;Xc.exports=xo;var o=Xc.exports,lu={exports:{}},rt={},cu={exports:{}},uu={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(e){function t(z,R){var $=z.length;z.push(R);e:for(;0<$;){var L=$-1>>>1,V=z[L];if(0<a(V,R))z[L]=R,z[$]=V,$=L;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var R=z[0],$=z.pop();if($!==R){z[0]=$;e:for(var L=0,V=z.length,ee=V>>>1;L<ee;){var J=2*(L+1)-1,je=z[J],b=J+1,U=z[b];if(0>a(je,$))b<V&&0>a(U,je)?(z[L]=U,z[b]=$,L=b):(z[L]=je,z[J]=$,L=J);else if(b<V&&0>a(U,$))z[L]=U,z[b]=$,L=b;else break e}}return R}function a(z,R){var $=z.sortIndex-R.sortIndex;return $!==0?$:z.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],p=1,f=null,v=3,y=!1,x=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function g(z){for(var R=n(u);R!==null;){if(R.callback===null)r(u);else if(R.startTime<=z)r(u),R.sortIndex=R.expirationTime,t(c,R);else break;R=n(u)}}function S(z){if(w=!1,g(z),!x)if(n(c)!==null)x=!0,X(E);else{var R=n(u);R!==null&&oe(S,R.startTime-z)}}function E(z,R){x=!1,w&&(w=!1,h(N),N=-1),y=!0;var $=v;try{for(g(R),f=n(c);f!==null&&(!(f.expirationTime>R)||z&&!H());){var L=f.callback;if(typeof L=="function"){f.callback=null,v=f.priorityLevel;var V=L(f.expirationTime<=R);R=e.unstable_now(),typeof V=="function"?f.callback=V:f===n(c)&&r(c),g(R)}else r(c);f=n(c)}if(f!==null)var ee=!0;else{var J=n(u);J!==null&&oe(S,J.startTime-R),ee=!1}return ee}finally{f=null,v=$,y=!1}}var I=!1,k=null,N=-1,C=5,P=-1;function H(){return!(e.unstable_now()-P<C)}function W(){if(k!==null){var z=e.unstable_now();P=z;var R=!0;try{R=k(!0,z)}finally{R?B():(I=!1,k=null)}}else I=!1}var B;if(typeof m=="function")B=function(){m(W)};else if(typeof MessageChannel<"u"){var _=new MessageChannel,D=_.port2;_.port1.onmessage=W,B=function(){D.postMessage(null)}}else B=function(){j(W,0)};function X(z){k=z,I||(I=!0,B())}function oe(z,R){N=j(function(){z(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){x||y||(x=!0,X(E))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(z){switch(v){case 1:case 2:case 3:var R=3;break;default:R=v}var $=v;v=R;try{return z()}finally{v=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,R){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var $=v;v=z;try{return R()}finally{v=$}},e.unstable_scheduleCallback=function(z,R,$){var L=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?L+$:L):$=L,z){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=$+V,z={id:p++,callback:R,priorityLevel:z,startTime:$,expirationTime:V,sortIndex:-1},$>L?(z.sortIndex=$,t(u,z),n(c)===null&&z===n(u)&&(w?(h(N),N=-1):w=!0,oe(S,$-L))):(z.sortIndex=V,t(c,z),x||y||(x=!0,X(E))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var R=v;return function(){var $=v;v=R;try{return z.apply(this,arguments)}finally{v=$}}}})(uu);cu.exports=uu;var mm=cu.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var pm=d,nt=mm;function F(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var du=new Set,Fr={};function Tn(e,t){er(e,t),er(e+"Capture",t)}function er(e,t){for(Fr[e]=t,e=0;e<t.length;e++)du.add(t[e])}var Ot=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ys=Object.prototype.hasOwnProperty,hm=/^[: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]*$/,bl={},Nl={};function gm(e){return ys.call(Nl,e)?!0:ys.call(bl,e)?!1:hm.test(e)?Nl[e]=!0:(bl[e]=!0,!1)}function vm(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ym(e,t,n,r){if(t===null||typeof t>"u"||vm(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function De(e,t,n,r,a,s,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=i}var Re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Re[e]=new De(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Re[t]=new De(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Re[e]=new De(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Re[e]=new De(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Re[e]=new De(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Re[e]=new De(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Re[e]=new De(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Re[e]=new De(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Re[e]=new De(e,5,!1,e.toLowerCase(),null,!1,!1)});var ki=/[\-:]([a-z])/g;function Ci(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(ki,Ci);Re[t]=new De(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(ki,Ci);Re[t]=new De(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(ki,Ci);Re[t]=new De(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Re[e]=new De(e,1,!1,e.toLowerCase(),null,!1,!1)});Re.xlinkHref=new De("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Re[e]=new De(e,1,!1,e.toLowerCase(),null,!0,!0)});function bi(e,t,n,r){var a=Re.hasOwnProperty(t)?Re[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(ym(t,n,a,r)&&(n=null),r||a===null?gm(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=n===null?a.type===3?!1:"":n:(t=a.attributeName,r=a.attributeNamespace,n===null?e.removeAttribute(t):(a=a.type,n=a===3||a===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Ht=pm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,da=Symbol.for("react.element"),Ln=Symbol.for("react.portal"),Mn=Symbol.for("react.fragment"),Ni=Symbol.for("react.strict_mode"),xs=Symbol.for("react.profiler"),fu=Symbol.for("react.provider"),mu=Symbol.for("react.context"),Ei=Symbol.for("react.forward_ref"),ws=Symbol.for("react.suspense"),Ss=Symbol.for("react.suspense_list"),zi=Symbol.for("react.memo"),Yt=Symbol.for("react.lazy"),pu=Symbol.for("react.offscreen"),El=Symbol.iterator;function pr(e){return e===null||typeof e!="object"?null:(e=El&&e[El]||e["@@iterator"],typeof e=="function"?e:null)}var he=Object.assign,Bo;function kr(e){if(Bo===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Bo=t&&t[1]||""}return`
34
+ `+Bo+e}var Do=!1;function Uo(e,t){if(!e||Do)return"";Do=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var a=u.stack.split(`
35
+ `),s=r.stack.split(`
36
+ `),i=a.length-1,l=s.length-1;1<=i&&0<=l&&a[i]!==s[l];)l--;for(;1<=i&&0<=l;i--,l--)if(a[i]!==s[l]){if(i!==1||l!==1)do if(i--,l--,0>l||a[i]!==s[l]){var c=`
37
+ `+a[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=l);break}}}finally{Do=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?kr(e):""}function xm(e){switch(e.tag){case 5:return kr(e.type);case 16:return kr("Lazy");case 13:return kr("Suspense");case 19:return kr("SuspenseList");case 0:case 2:case 15:return e=Uo(e.type,!1),e;case 11:return e=Uo(e.type.render,!1),e;case 1:return e=Uo(e.type,!0),e;default:return""}}function js(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Mn:return"Fragment";case Ln:return"Portal";case xs:return"Profiler";case Ni:return"StrictMode";case ws:return"Suspense";case Ss:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case mu:return(e.displayName||"Context")+".Consumer";case fu:return(e._context.displayName||"Context")+".Provider";case Ei:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case zi:return t=e.displayName||null,t!==null?t:js(e.type)||"Memo";case Yt:t=e._payload,e=e._init;try{return js(e(t))}catch{}}return null}function wm(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return js(t);case 8:return t===Ni?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function un(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Sm(e){var t=hu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(i){r=""+i,s.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function fa(e){e._valueTracker||(e._valueTracker=Sm(e))}function gu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=hu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Va(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ks(e,t){var n=t.checked;return he({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function zl(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=un(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function vu(e,t){t=t.checked,t!=null&&bi(e,"checked",t,!1)}function Cs(e,t){vu(e,t);var n=un(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?bs(e,t.type,n):t.hasOwnProperty("defaultValue")&&bs(e,t.type,un(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Il(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function bs(e,t,n){(t!=="number"||Va(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Cr=Array.isArray;function Yn(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+un(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Ns(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return he({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Pl(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(F(92));if(Cr(n)){if(1<n.length)throw Error(F(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:un(n)}}function yu(e,t){var n=un(t.value),r=un(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Tl(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function xu(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Es(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?xu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var ma,wu=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(ma=ma||document.createElement("div"),ma.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ma.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Or(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var zr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},jm=["Webkit","ms","Moz","O"];Object.keys(zr).forEach(function(e){jm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),zr[t]=zr[e]})});function Su(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||zr.hasOwnProperty(e)&&zr[e]?(""+t).trim():t+"px"}function ju(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=Su(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var km=he({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zs(e,t){if(t){if(km[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function Is(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 Ps=null;function Ii(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ts=null,Qn=null,Jn=null;function Rl(e){if(e=oa(e)){if(typeof Ts!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Co(t),Ts(e.stateNode,e.type,t))}}function ku(e){Qn?Jn?Jn.push(e):Jn=[e]:Qn=e}function Cu(){if(Qn){var e=Qn,t=Jn;if(Jn=Qn=null,Rl(e),t)for(e=0;e<t.length;e++)Rl(t[e])}}function bu(e,t){return e(t)}function Nu(){}var Wo=!1;function Eu(e,t,n){if(Wo)return e(t,n);Wo=!0;try{return bu(e,t,n)}finally{Wo=!1,(Qn!==null||Jn!==null)&&(Nu(),Cu())}}function Br(e,t){var n=e.stateNode;if(n===null)return null;var r=Co(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(F(231,t,typeof n));return n}var Rs=!1;if(Ot)try{var hr={};Object.defineProperty(hr,"passive",{get:function(){Rs=!0}}),window.addEventListener("test",hr,hr),window.removeEventListener("test",hr,hr)}catch{Rs=!1}function Cm(e,t,n,r,a,s,i,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Ir=!1,Ka=null,Ga=!1,_s=null,bm={onError:function(e){Ir=!0,Ka=e}};function Nm(e,t,n,r,a,s,i,l,c){Ir=!1,Ka=null,Cm.apply(bm,arguments)}function Em(e,t,n,r,a,s,i,l,c){if(Nm.apply(this,arguments),Ir){if(Ir){var u=Ka;Ir=!1,Ka=null}else throw Error(F(198));Ga||(Ga=!0,_s=u)}}function Rn(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function zu(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function _l(e){if(Rn(e)!==e)throw Error(F(188))}function zm(e){var t=e.alternate;if(!t){if(t=Rn(e),t===null)throw Error(F(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return _l(a),e;if(s===r)return _l(a),t;s=s.sibling}throw Error(F(188))}if(n.return!==r.return)n=a,r=s;else{for(var i=!1,l=a.child;l;){if(l===n){i=!0,n=a,r=s;break}if(l===r){i=!0,r=a,n=s;break}l=l.sibling}if(!i){for(l=s.child;l;){if(l===n){i=!0,n=s,r=a;break}if(l===r){i=!0,r=s,n=a;break}l=l.sibling}if(!i)throw Error(F(189))}}if(n.alternate!==r)throw Error(F(190))}if(n.tag!==3)throw Error(F(188));return n.stateNode.current===n?e:t}function Iu(e){return e=zm(e),e!==null?Pu(e):null}function Pu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Pu(e);if(t!==null)return t;e=e.sibling}return null}var Tu=nt.unstable_scheduleCallback,Al=nt.unstable_cancelCallback,Im=nt.unstable_shouldYield,Pm=nt.unstable_requestPaint,ve=nt.unstable_now,Tm=nt.unstable_getCurrentPriorityLevel,Pi=nt.unstable_ImmediatePriority,Ru=nt.unstable_UserBlockingPriority,Ya=nt.unstable_NormalPriority,Rm=nt.unstable_LowPriority,_u=nt.unstable_IdlePriority,wo=null,zt=null;function _m(e){if(zt&&typeof zt.onCommitFiberRoot=="function")try{zt.onCommitFiberRoot(wo,e,void 0,(e.current.flags&128)===128)}catch{}}var wt=Math.clz32?Math.clz32:Lm,Am=Math.log,$m=Math.LN2;function Lm(e){return e>>>=0,e===0?32:31-(Am(e)/$m|0)|0}var pa=64,ha=4194304;function br(e){switch(e&-e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Qa(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~a;l!==0?r=br(l):(s&=i,s!==0&&(r=br(s)))}else i=n&~a,i!==0?r=br(i):s!==0&&(r=br(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,s=t&-t,a>=s||a===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-wt(t),a=1<<n,r|=e[n],t&=~a;return r}function Mm(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Fm(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-wt(s),l=1<<i,c=a[i];c===-1?(!(l&n)||l&r)&&(a[i]=Mm(l,t)):c<=t&&(e.expiredLanes|=l),s&=~l}}function As(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Au(){var e=pa;return pa<<=1,!(pa&4194240)&&(pa=64),e}function Ho(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ra(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-wt(t),e[t]=n}function Om(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-wt(n),s=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~s}}function Ti(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-wt(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var ae=0;function $u(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Lu,Ri,Mu,Fu,Ou,$s=!1,ga=[],tn=null,nn=null,rn=null,Dr=new Map,Ur=new Map,Xt=[],Bm="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 submit".split(" ");function $l(e,t){switch(e){case"focusin":case"focusout":tn=null;break;case"dragenter":case"dragleave":nn=null;break;case"mouseover":case"mouseout":rn=null;break;case"pointerover":case"pointerout":Dr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ur.delete(t.pointerId)}}function gr(e,t,n,r,a,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[a]},t!==null&&(t=oa(t),t!==null&&Ri(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Dm(e,t,n,r,a){switch(t){case"focusin":return tn=gr(tn,e,t,n,r,a),!0;case"dragenter":return nn=gr(nn,e,t,n,r,a),!0;case"mouseover":return rn=gr(rn,e,t,n,r,a),!0;case"pointerover":var s=a.pointerId;return Dr.set(s,gr(Dr.get(s)||null,e,t,n,r,a)),!0;case"gotpointercapture":return s=a.pointerId,Ur.set(s,gr(Ur.get(s)||null,e,t,n,r,a)),!0}return!1}function Bu(e){var t=wn(e.target);if(t!==null){var n=Rn(t);if(n!==null){if(t=n.tag,t===13){if(t=zu(n),t!==null){e.blockedOn=t,Ou(e.priority,function(){Mu(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ra(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ls(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ps=r,n.target.dispatchEvent(r),Ps=null}else return t=oa(n),t!==null&&Ri(t),e.blockedOn=n,!1;t.shift()}return!0}function Ll(e,t,n){Ra(e)&&n.delete(t)}function Um(){$s=!1,tn!==null&&Ra(tn)&&(tn=null),nn!==null&&Ra(nn)&&(nn=null),rn!==null&&Ra(rn)&&(rn=null),Dr.forEach(Ll),Ur.forEach(Ll)}function vr(e,t){e.blockedOn===t&&(e.blockedOn=null,$s||($s=!0,nt.unstable_scheduleCallback(nt.unstable_NormalPriority,Um)))}function Wr(e){function t(a){return vr(a,e)}if(0<ga.length){vr(ga[0],e);for(var n=1;n<ga.length;n++){var r=ga[n];r.blockedOn===e&&(r.blockedOn=null)}}for(tn!==null&&vr(tn,e),nn!==null&&vr(nn,e),rn!==null&&vr(rn,e),Dr.forEach(t),Ur.forEach(t),n=0;n<Xt.length;n++)r=Xt[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Xt.length&&(n=Xt[0],n.blockedOn===null);)Bu(n),n.blockedOn===null&&Xt.shift()}var Xn=Ht.ReactCurrentBatchConfig,Ja=!0;function Wm(e,t,n,r){var a=ae,s=Xn.transition;Xn.transition=null;try{ae=1,_i(e,t,n,r)}finally{ae=a,Xn.transition=s}}function Hm(e,t,n,r){var a=ae,s=Xn.transition;Xn.transition=null;try{ae=4,_i(e,t,n,r)}finally{ae=a,Xn.transition=s}}function _i(e,t,n,r){if(Ja){var a=Ls(e,t,n,r);if(a===null)es(e,t,r,Xa,n),$l(e,r);else if(Dm(a,e,t,n,r))r.stopPropagation();else if($l(e,r),t&4&&-1<Bm.indexOf(e)){for(;a!==null;){var s=oa(a);if(s!==null&&Lu(s),s=Ls(e,t,n,r),s===null&&es(e,t,r,Xa,n),s===a)break;a=s}a!==null&&r.stopPropagation()}else es(e,t,r,null,n)}}var Xa=null;function Ls(e,t,n,r){if(Xa=null,e=Ii(r),e=wn(e),e!==null)if(t=Rn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=zu(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Xa=e,null}function Du(e){switch(e){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Tm()){case Pi:return 1;case Ru:return 4;case Ya:case Rm:return 16;case _u:return 536870912;default:return 16}default:return 16}}var Zt=null,Ai=null,_a=null;function Uu(){if(_a)return _a;var e,t=Ai,n=t.length,r,a="value"in Zt?Zt.value:Zt.textContent,s=a.length;for(e=0;e<n&&t[e]===a[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===a[s-r];r++);return _a=a.slice(e,1<r?1-r:void 0)}function Aa(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function va(){return!0}function Ml(){return!1}function at(e){function t(n,r,a,s,i){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=s,this.target=i,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?va:Ml,this.isPropagationStopped=Ml,this}return he(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=va)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=va)},persist:function(){},isPersistent:va}),t}var lr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$i=at(lr),aa=he({},lr,{view:0,detail:0}),Vm=at(aa),Vo,Ko,yr,So=he({},aa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Li,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==yr&&(yr&&e.type==="mousemove"?(Vo=e.screenX-yr.screenX,Ko=e.screenY-yr.screenY):Ko=Vo=0,yr=e),Vo)},movementY:function(e){return"movementY"in e?e.movementY:Ko}}),Fl=at(So),Km=he({},So,{dataTransfer:0}),Gm=at(Km),Ym=he({},aa,{relatedTarget:0}),Go=at(Ym),Qm=he({},lr,{animationName:0,elapsedTime:0,pseudoElement:0}),Jm=at(Qm),Xm=he({},lr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),qm=at(Xm),Zm=he({},lr,{data:0}),Ol=at(Zm),ep={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tp={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"},np={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rp(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=np[e])?!!t[e]:!1}function Li(){return rp}var ap=he({},aa,{key:function(e){if(e.key){var t=ep[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Aa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?tp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Li,charCode:function(e){return e.type==="keypress"?Aa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Aa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),op=at(ap),sp=he({},So,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bl=at(sp),ip=he({},aa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Li}),lp=at(ip),cp=he({},lr,{propertyName:0,elapsedTime:0,pseudoElement:0}),up=at(cp),dp=he({},So,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),fp=at(dp),mp=[9,13,27,32],Mi=Ot&&"CompositionEvent"in window,Pr=null;Ot&&"documentMode"in document&&(Pr=document.documentMode);var pp=Ot&&"TextEvent"in window&&!Pr,Wu=Ot&&(!Mi||Pr&&8<Pr&&11>=Pr),Dl=" ",Ul=!1;function Hu(e,t){switch(e){case"keyup":return mp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Fn=!1;function hp(e,t){switch(e){case"compositionend":return Vu(t);case"keypress":return t.which!==32?null:(Ul=!0,Dl);case"textInput":return e=t.data,e===Dl&&Ul?null:e;default:return null}}function gp(e,t){if(Fn)return e==="compositionend"||!Mi&&Hu(e,t)?(e=Uu(),_a=Ai=Zt=null,Fn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Wu&&t.locale!=="ko"?null:t.data;default:return null}}var vp={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 Wl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!vp[e.type]:t==="textarea"}function Ku(e,t,n,r){ku(r),t=qa(t,"onChange"),0<t.length&&(n=new $i("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Tr=null,Hr=null;function yp(e){rd(e,0)}function jo(e){var t=Dn(e);if(gu(t))return e}function xp(e,t){if(e==="change")return t}var Gu=!1;if(Ot){var Yo;if(Ot){var Qo="oninput"in document;if(!Qo){var Hl=document.createElement("div");Hl.setAttribute("oninput","return;"),Qo=typeof Hl.oninput=="function"}Yo=Qo}else Yo=!1;Gu=Yo&&(!document.documentMode||9<document.documentMode)}function Vl(){Tr&&(Tr.detachEvent("onpropertychange",Yu),Hr=Tr=null)}function Yu(e){if(e.propertyName==="value"&&jo(Hr)){var t=[];Ku(t,Hr,e,Ii(e)),Eu(yp,t)}}function wp(e,t,n){e==="focusin"?(Vl(),Tr=t,Hr=n,Tr.attachEvent("onpropertychange",Yu)):e==="focusout"&&Vl()}function Sp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return jo(Hr)}function jp(e,t){if(e==="click")return jo(t)}function kp(e,t){if(e==="input"||e==="change")return jo(t)}function Cp(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jt=typeof Object.is=="function"?Object.is:Cp;function Vr(e,t){if(jt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!ys.call(t,a)||!jt(e[a],t[a]))return!1}return!0}function Kl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Gl(e,t){var n=Kl(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Kl(n)}}function Qu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Qu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ju(){for(var e=window,t=Va();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Va(e.document)}return t}function Fi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function bp(e){var t=Ju(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Qu(n.ownerDocument.documentElement,n)){if(r!==null&&Fi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,s=Math.min(r.start,a);r=r.end===void 0?s:Math.min(r.end,a),!e.extend&&s>r&&(a=r,r=s,s=a),a=Gl(n,s);var i=Gl(n,r);a&&i&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Np=Ot&&"documentMode"in document&&11>=document.documentMode,On=null,Ms=null,Rr=null,Fs=!1;function Yl(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fs||On==null||On!==Va(r)||(r=On,"selectionStart"in r&&Fi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Rr&&Vr(Rr,r)||(Rr=r,r=qa(Ms,"onSelect"),0<r.length&&(t=new $i("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=On)))}function ya(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Bn={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionend:ya("Transition","TransitionEnd")},Jo={},Xu={};Ot&&(Xu=document.createElement("div").style,"AnimationEvent"in window||(delete Bn.animationend.animation,delete Bn.animationiteration.animation,delete Bn.animationstart.animation),"TransitionEvent"in window||delete Bn.transitionend.transition);function ko(e){if(Jo[e])return Jo[e];if(!Bn[e])return e;var t=Bn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Xu)return Jo[e]=t[n];return e}var qu=ko("animationend"),Zu=ko("animationiteration"),ed=ko("animationstart"),td=ko("transitionend"),nd=new Map,Ql="abort auxClick 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(" ");function fn(e,t){nd.set(e,t),Tn(t,[e])}for(var Xo=0;Xo<Ql.length;Xo++){var qo=Ql[Xo],Ep=qo.toLowerCase(),zp=qo[0].toUpperCase()+qo.slice(1);fn(Ep,"on"+zp)}fn(qu,"onAnimationEnd");fn(Zu,"onAnimationIteration");fn(ed,"onAnimationStart");fn("dblclick","onDoubleClick");fn("focusin","onFocus");fn("focusout","onBlur");fn(td,"onTransitionEnd");er("onMouseEnter",["mouseout","mouseover"]);er("onMouseLeave",["mouseout","mouseover"]);er("onPointerEnter",["pointerout","pointerover"]);er("onPointerLeave",["pointerout","pointerover"]);Tn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Tn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Tn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Tn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Tn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Tn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Nr="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(" "),Ip=new Set("cancel close invalid load scroll toggle".split(" ").concat(Nr));function Jl(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Em(r,t,void 0,e),e.currentTarget=null}function rd(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var i=r.length-1;0<=i;i--){var l=r[i],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==s&&a.isPropagationStopped())break e;Jl(a,l,u),s=c}else for(i=0;i<r.length;i++){if(l=r[i],c=l.instance,u=l.currentTarget,l=l.listener,c!==s&&a.isPropagationStopped())break e;Jl(a,l,u),s=c}}}if(Ga)throw e=_s,Ga=!1,_s=null,e}function le(e,t){var n=t[Ws];n===void 0&&(n=t[Ws]=new Set);var r=e+"__bubble";n.has(r)||(ad(t,e,2,!1),n.add(r))}function Zo(e,t,n){var r=0;t&&(r|=4),ad(n,e,r,t)}var xa="_reactListening"+Math.random().toString(36).slice(2);function Kr(e){if(!e[xa]){e[xa]=!0,du.forEach(function(n){n!=="selectionchange"&&(Ip.has(n)||Zo(n,!1,e),Zo(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[xa]||(t[xa]=!0,Zo("selectionchange",!1,t))}}function ad(e,t,n,r){switch(Du(t)){case 1:var a=Wm;break;case 4:a=Hm;break;default:a=_i}n=a.bind(null,t,n,e),a=void 0,!Rs||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function es(e,t,n,r,a){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var l=r.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;i=i.return}for(;l!==null;){if(i=wn(l),i===null)return;if(c=i.tag,c===5||c===6){r=s=i;continue e}l=l.parentNode}}r=r.return}Eu(function(){var u=s,p=Ii(n),f=[];e:{var v=nd.get(e);if(v!==void 0){var y=$i,x=e;switch(e){case"keypress":if(Aa(n)===0)break e;case"keydown":case"keyup":y=op;break;case"focusin":x="focus",y=Go;break;case"focusout":x="blur",y=Go;break;case"beforeblur":case"afterblur":y=Go;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":y=Fl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":y=Gm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":y=lp;break;case qu:case Zu:case ed:y=Jm;break;case td:y=up;break;case"scroll":y=Vm;break;case"wheel":y=fp;break;case"copy":case"cut":case"paste":y=qm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":y=Bl}var w=(t&4)!==0,j=!w&&e==="scroll",h=w?v!==null?v+"Capture":null:v;w=[];for(var m=u,g;m!==null;){g=m;var S=g.stateNode;if(g.tag===5&&S!==null&&(g=S,h!==null&&(S=Br(m,h),S!=null&&w.push(Gr(m,S,g)))),j)break;m=m.return}0<w.length&&(v=new y(v,x,null,n,p),f.push({event:v,listeners:w}))}}if(!(t&7)){e:{if(v=e==="mouseover"||e==="pointerover",y=e==="mouseout"||e==="pointerout",v&&n!==Ps&&(x=n.relatedTarget||n.fromElement)&&(wn(x)||x[Bt]))break e;if((y||v)&&(v=p.window===p?p:(v=p.ownerDocument)?v.defaultView||v.parentWindow:window,y?(x=n.relatedTarget||n.toElement,y=u,x=x?wn(x):null,x!==null&&(j=Rn(x),x!==j||x.tag!==5&&x.tag!==6)&&(x=null)):(y=null,x=u),y!==x)){if(w=Fl,S="onMouseLeave",h="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(w=Bl,S="onPointerLeave",h="onPointerEnter",m="pointer"),j=y==null?v:Dn(y),g=x==null?v:Dn(x),v=new w(S,m+"leave",y,n,p),v.target=j,v.relatedTarget=g,S=null,wn(p)===u&&(w=new w(h,m+"enter",x,n,p),w.target=g,w.relatedTarget=j,S=w),j=S,y&&x)t:{for(w=y,h=x,m=0,g=w;g;g=$n(g))m++;for(g=0,S=h;S;S=$n(S))g++;for(;0<m-g;)w=$n(w),m--;for(;0<g-m;)h=$n(h),g--;for(;m--;){if(w===h||h!==null&&w===h.alternate)break t;w=$n(w),h=$n(h)}w=null}else w=null;y!==null&&Xl(f,v,y,w,!1),x!==null&&j!==null&&Xl(f,j,x,w,!0)}}e:{if(v=u?Dn(u):window,y=v.nodeName&&v.nodeName.toLowerCase(),y==="select"||y==="input"&&v.type==="file")var E=xp;else if(Wl(v))if(Gu)E=kp;else{E=Sp;var I=wp}else(y=v.nodeName)&&y.toLowerCase()==="input"&&(v.type==="checkbox"||v.type==="radio")&&(E=jp);if(E&&(E=E(e,u))){Ku(f,E,n,p);break e}I&&I(e,v,u),e==="focusout"&&(I=v._wrapperState)&&I.controlled&&v.type==="number"&&bs(v,"number",v.value)}switch(I=u?Dn(u):window,e){case"focusin":(Wl(I)||I.contentEditable==="true")&&(On=I,Ms=u,Rr=null);break;case"focusout":Rr=Ms=On=null;break;case"mousedown":Fs=!0;break;case"contextmenu":case"mouseup":case"dragend":Fs=!1,Yl(f,n,p);break;case"selectionchange":if(Np)break;case"keydown":case"keyup":Yl(f,n,p)}var k;if(Mi)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else Fn?Hu(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(Wu&&n.locale!=="ko"&&(Fn||N!=="onCompositionStart"?N==="onCompositionEnd"&&Fn&&(k=Uu()):(Zt=p,Ai="value"in Zt?Zt.value:Zt.textContent,Fn=!0)),I=qa(u,N),0<I.length&&(N=new Ol(N,e,null,n,p),f.push({event:N,listeners:I}),k?N.data=k:(k=Vu(n),k!==null&&(N.data=k)))),(k=pp?hp(e,n):gp(e,n))&&(u=qa(u,"onBeforeInput"),0<u.length&&(p=new Ol("onBeforeInput","beforeinput",null,n,p),f.push({event:p,listeners:u}),p.data=k))}rd(f,t)})}function Gr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qa(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,s=a.stateNode;a.tag===5&&s!==null&&(a=s,s=Br(e,n),s!=null&&r.unshift(Gr(e,s,a)),s=Br(e,t),s!=null&&r.push(Gr(e,s,a))),e=e.return}return r}function $n(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Xl(e,t,n,r,a){for(var s=t._reactName,i=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,a?(c=Br(n,s),c!=null&&i.unshift(Gr(n,c,l))):a||(c=Br(n,s),c!=null&&i.push(Gr(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Pp=/\r\n?/g,Tp=/\u0000|\uFFFD/g;function ql(e){return(typeof e=="string"?e:""+e).replace(Pp,`
38
+ `).replace(Tp,"")}function wa(e,t,n){if(t=ql(t),ql(e)!==t&&n)throw Error(F(425))}function Za(){}var Os=null,Bs=null;function Ds(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Us=typeof setTimeout=="function"?setTimeout:void 0,Rp=typeof clearTimeout=="function"?clearTimeout:void 0,Zl=typeof Promise=="function"?Promise:void 0,_p=typeof queueMicrotask=="function"?queueMicrotask:typeof Zl<"u"?function(e){return Zl.resolve(null).then(e).catch(Ap)}:Us;function Ap(e){setTimeout(function(){throw e})}function ts(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),Wr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);Wr(t)}function an(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function ec(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var cr=Math.random().toString(36).slice(2),Et="__reactFiber$"+cr,Yr="__reactProps$"+cr,Bt="__reactContainer$"+cr,Ws="__reactEvents$"+cr,$p="__reactListeners$"+cr,Lp="__reactHandles$"+cr;function wn(e){var t=e[Et];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Bt]||n[Et]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=ec(e);e!==null;){if(n=e[Et])return n;e=ec(e)}return t}e=n,n=e.parentNode}return null}function oa(e){return e=e[Et]||e[Bt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Dn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Co(e){return e[Yr]||null}var Hs=[],Un=-1;function mn(e){return{current:e}}function ce(e){0>Un||(e.current=Hs[Un],Hs[Un]=null,Un--)}function ie(e,t){Un++,Hs[Un]=e.current,e.current=t}var dn={},Le=mn(dn),Ve=mn(!1),Nn=dn;function tr(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},s;for(s in n)a[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Ke(e){return e=e.childContextTypes,e!=null}function eo(){ce(Ve),ce(Le)}function tc(e,t,n){if(Le.current!==dn)throw Error(F(168));ie(Le,t),ie(Ve,n)}function od(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(F(108,wm(e)||"Unknown",a));return he({},n,r)}function to(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,Nn=Le.current,ie(Le,e),ie(Ve,Ve.current),!0}function nc(e,t,n){var r=e.stateNode;if(!r)throw Error(F(169));n?(e=od(e,t,Nn),r.__reactInternalMemoizedMergedChildContext=e,ce(Ve),ce(Le),ie(Le,e)):ce(Ve),ie(Ve,n)}var At=null,bo=!1,ns=!1;function sd(e){At===null?At=[e]:At.push(e)}function Mp(e){bo=!0,sd(e)}function pn(){if(!ns&&At!==null){ns=!0;var e=0,t=ae;try{var n=At;for(ae=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}At=null,bo=!1}catch(a){throw At!==null&&(At=At.slice(e+1)),Tu(Pi,pn),a}finally{ae=t,ns=!1}}return null}var Wn=[],Hn=0,no=null,ro=0,st=[],it=0,En=null,$t=1,Lt="";function vn(e,t){Wn[Hn++]=ro,Wn[Hn++]=no,no=e,ro=t}function id(e,t,n){st[it++]=$t,st[it++]=Lt,st[it++]=En,En=e;var r=$t;e=Lt;var a=32-wt(r)-1;r&=~(1<<a),n+=1;var s=32-wt(t)+a;if(30<s){var i=a-a%5;s=(r&(1<<i)-1).toString(32),r>>=i,a-=i,$t=1<<32-wt(t)+a|n<<a|r,Lt=s+e}else $t=1<<s|n<<a|r,Lt=e}function Oi(e){e.return!==null&&(vn(e,1),id(e,1,0))}function Bi(e){for(;e===no;)no=Wn[--Hn],Wn[Hn]=null,ro=Wn[--Hn],Wn[Hn]=null;for(;e===En;)En=st[--it],st[it]=null,Lt=st[--it],st[it]=null,$t=st[--it],st[it]=null}var tt=null,et=null,ue=!1,xt=null;function ld(e,t){var n=lt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function rc(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,tt=e,et=an(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,tt=e,et=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=En!==null?{id:$t,overflow:Lt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=lt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,tt=e,et=null,!0):!1;default:return!1}}function Vs(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Ks(e){if(ue){var t=et;if(t){var n=t;if(!rc(e,t)){if(Vs(e))throw Error(F(418));t=an(n.nextSibling);var r=tt;t&&rc(e,t)?ld(r,n):(e.flags=e.flags&-4097|2,ue=!1,tt=e)}}else{if(Vs(e))throw Error(F(418));e.flags=e.flags&-4097|2,ue=!1,tt=e}}}function ac(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;tt=e}function Sa(e){if(e!==tt)return!1;if(!ue)return ac(e),ue=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ds(e.type,e.memoizedProps)),t&&(t=et)){if(Vs(e))throw cd(),Error(F(418));for(;t;)ld(e,t),t=an(t.nextSibling)}if(ac(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(F(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){et=an(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}et=null}}else et=tt?an(e.stateNode.nextSibling):null;return!0}function cd(){for(var e=et;e;)e=an(e.nextSibling)}function nr(){et=tt=null,ue=!1}function Di(e){xt===null?xt=[e]:xt.push(e)}var Fp=Ht.ReactCurrentBatchConfig;function xr(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(F(309));var r=n.stateNode}if(!r)throw Error(F(147,e));var a=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(i){var l=a.refs;i===null?delete l[s]:l[s]=i},t._stringRef=s,t)}if(typeof e!="string")throw Error(F(284));if(!n._owner)throw Error(F(290,e))}return e}function ja(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function oc(e){var t=e._init;return t(e._payload)}function ud(e){function t(h,m){if(e){var g=h.deletions;g===null?(h.deletions=[m],h.flags|=16):g.push(m)}}function n(h,m){if(!e)return null;for(;m!==null;)t(h,m),m=m.sibling;return null}function r(h,m){for(h=new Map;m!==null;)m.key!==null?h.set(m.key,m):h.set(m.index,m),m=m.sibling;return h}function a(h,m){return h=cn(h,m),h.index=0,h.sibling=null,h}function s(h,m,g){return h.index=g,e?(g=h.alternate,g!==null?(g=g.index,g<m?(h.flags|=2,m):g):(h.flags|=2,m)):(h.flags|=1048576,m)}function i(h){return e&&h.alternate===null&&(h.flags|=2),h}function l(h,m,g,S){return m===null||m.tag!==6?(m=cs(g,h.mode,S),m.return=h,m):(m=a(m,g),m.return=h,m)}function c(h,m,g,S){var E=g.type;return E===Mn?p(h,m,g.props.children,S,g.key):m!==null&&(m.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Yt&&oc(E)===m.type)?(S=a(m,g.props),S.ref=xr(h,m,g),S.return=h,S):(S=Da(g.type,g.key,g.props,null,h.mode,S),S.ref=xr(h,m,g),S.return=h,S)}function u(h,m,g,S){return m===null||m.tag!==4||m.stateNode.containerInfo!==g.containerInfo||m.stateNode.implementation!==g.implementation?(m=us(g,h.mode,S),m.return=h,m):(m=a(m,g.children||[]),m.return=h,m)}function p(h,m,g,S,E){return m===null||m.tag!==7?(m=bn(g,h.mode,S,E),m.return=h,m):(m=a(m,g),m.return=h,m)}function f(h,m,g){if(typeof m=="string"&&m!==""||typeof m=="number")return m=cs(""+m,h.mode,g),m.return=h,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case da:return g=Da(m.type,m.key,m.props,null,h.mode,g),g.ref=xr(h,null,m),g.return=h,g;case Ln:return m=us(m,h.mode,g),m.return=h,m;case Yt:var S=m._init;return f(h,S(m._payload),g)}if(Cr(m)||pr(m))return m=bn(m,h.mode,g,null),m.return=h,m;ja(h,m)}return null}function v(h,m,g,S){var E=m!==null?m.key:null;if(typeof g=="string"&&g!==""||typeof g=="number")return E!==null?null:l(h,m,""+g,S);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case da:return g.key===E?c(h,m,g,S):null;case Ln:return g.key===E?u(h,m,g,S):null;case Yt:return E=g._init,v(h,m,E(g._payload),S)}if(Cr(g)||pr(g))return E!==null?null:p(h,m,g,S,null);ja(h,g)}return null}function y(h,m,g,S,E){if(typeof S=="string"&&S!==""||typeof S=="number")return h=h.get(g)||null,l(m,h,""+S,E);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case da:return h=h.get(S.key===null?g:S.key)||null,c(m,h,S,E);case Ln:return h=h.get(S.key===null?g:S.key)||null,u(m,h,S,E);case Yt:var I=S._init;return y(h,m,g,I(S._payload),E)}if(Cr(S)||pr(S))return h=h.get(g)||null,p(m,h,S,E,null);ja(m,S)}return null}function x(h,m,g,S){for(var E=null,I=null,k=m,N=m=0,C=null;k!==null&&N<g.length;N++){k.index>N?(C=k,k=null):C=k.sibling;var P=v(h,k,g[N],S);if(P===null){k===null&&(k=C);break}e&&k&&P.alternate===null&&t(h,k),m=s(P,m,N),I===null?E=P:I.sibling=P,I=P,k=C}if(N===g.length)return n(h,k),ue&&vn(h,N),E;if(k===null){for(;N<g.length;N++)k=f(h,g[N],S),k!==null&&(m=s(k,m,N),I===null?E=k:I.sibling=k,I=k);return ue&&vn(h,N),E}for(k=r(h,k);N<g.length;N++)C=y(k,h,N,g[N],S),C!==null&&(e&&C.alternate!==null&&k.delete(C.key===null?N:C.key),m=s(C,m,N),I===null?E=C:I.sibling=C,I=C);return e&&k.forEach(function(H){return t(h,H)}),ue&&vn(h,N),E}function w(h,m,g,S){var E=pr(g);if(typeof E!="function")throw Error(F(150));if(g=E.call(g),g==null)throw Error(F(151));for(var I=E=null,k=m,N=m=0,C=null,P=g.next();k!==null&&!P.done;N++,P=g.next()){k.index>N?(C=k,k=null):C=k.sibling;var H=v(h,k,P.value,S);if(H===null){k===null&&(k=C);break}e&&k&&H.alternate===null&&t(h,k),m=s(H,m,N),I===null?E=H:I.sibling=H,I=H,k=C}if(P.done)return n(h,k),ue&&vn(h,N),E;if(k===null){for(;!P.done;N++,P=g.next())P=f(h,P.value,S),P!==null&&(m=s(P,m,N),I===null?E=P:I.sibling=P,I=P);return ue&&vn(h,N),E}for(k=r(h,k);!P.done;N++,P=g.next())P=y(k,h,N,P.value,S),P!==null&&(e&&P.alternate!==null&&k.delete(P.key===null?N:P.key),m=s(P,m,N),I===null?E=P:I.sibling=P,I=P);return e&&k.forEach(function(W){return t(h,W)}),ue&&vn(h,N),E}function j(h,m,g,S){if(typeof g=="object"&&g!==null&&g.type===Mn&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case da:e:{for(var E=g.key,I=m;I!==null;){if(I.key===E){if(E=g.type,E===Mn){if(I.tag===7){n(h,I.sibling),m=a(I,g.props.children),m.return=h,h=m;break e}}else if(I.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Yt&&oc(E)===I.type){n(h,I.sibling),m=a(I,g.props),m.ref=xr(h,I,g),m.return=h,h=m;break e}n(h,I);break}else t(h,I);I=I.sibling}g.type===Mn?(m=bn(g.props.children,h.mode,S,g.key),m.return=h,h=m):(S=Da(g.type,g.key,g.props,null,h.mode,S),S.ref=xr(h,m,g),S.return=h,h=S)}return i(h);case Ln:e:{for(I=g.key;m!==null;){if(m.key===I)if(m.tag===4&&m.stateNode.containerInfo===g.containerInfo&&m.stateNode.implementation===g.implementation){n(h,m.sibling),m=a(m,g.children||[]),m.return=h,h=m;break e}else{n(h,m);break}else t(h,m);m=m.sibling}m=us(g,h.mode,S),m.return=h,h=m}return i(h);case Yt:return I=g._init,j(h,m,I(g._payload),S)}if(Cr(g))return x(h,m,g,S);if(pr(g))return w(h,m,g,S);ja(h,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,m!==null&&m.tag===6?(n(h,m.sibling),m=a(m,g),m.return=h,h=m):(n(h,m),m=cs(g,h.mode,S),m.return=h,h=m),i(h)):n(h,m)}return j}var rr=ud(!0),dd=ud(!1),ao=mn(null),oo=null,Vn=null,Ui=null;function Wi(){Ui=Vn=oo=null}function Hi(e){var t=ao.current;ce(ao),e._currentValue=t}function Gs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function qn(e,t){oo=e,Ui=Vn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ut(e){var t=e._currentValue;if(Ui!==e)if(e={context:e,memoizedValue:t,next:null},Vn===null){if(oo===null)throw Error(F(308));Vn=e,oo.dependencies={lanes:0,firstContext:e}}else Vn=Vn.next=e;return t}var Sn=null;function Vi(e){Sn===null?Sn=[e]:Sn.push(e)}function fd(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,Vi(t)):(n.next=a.next,a.next=n),t.interleaved=n,Dt(e,r)}function Dt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qt=!1;function Ki(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function md(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ft(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function on(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,te&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Dt(e,n)}return a=r.interleaved,a===null?(t.next=t,Vi(r)):(t.next=a.next,a.next=t),r.interleaved=t,Dt(e,n)}function $a(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ti(e,n)}}function sc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?a=s=i:s=s.next=i,n=n.next}while(n!==null);s===null?a=s=t:s=s.next=t}else a=s=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function so(e,t,n,r){var a=e.updateQueue;Qt=!1;var s=a.firstBaseUpdate,i=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,u=c.next;c.next=null,i===null?s=u:i.next=u,i=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==i&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(s!==null){var f=a.baseState;i=0,p=u=c=null,l=s;do{var v=l.lane,y=l.eventTime;if((r&v)===v){p!==null&&(p=p.next={eventTime:y,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,w=l;switch(v=t,y=n,w.tag){case 1:if(x=w.payload,typeof x=="function"){f=x.call(y,f,v);break e}f=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=w.payload,v=typeof x=="function"?x.call(y,f,v):x,v==null)break e;f=he({},f,v);break e;case 2:Qt=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,v=a.effects,v===null?a.effects=[l]:v.push(l))}else y={eventTime:y,lane:v,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=y,c=f):p=p.next=y,i|=v;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;v=l,l=v.next,v.next=null,a.lastBaseUpdate=v,a.shared.pending=null}}while(!0);if(p===null&&(c=f),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=p,t=a.shared.interleaved,t!==null){a=t;do i|=a.lane,a=a.next;while(a!==t)}else s===null&&(a.shared.lanes=0);In|=i,e.lanes=i,e.memoizedState=f}}function ic(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(F(191,a));a.call(r)}}}var sa={},It=mn(sa),Qr=mn(sa),Jr=mn(sa);function jn(e){if(e===sa)throw Error(F(174));return e}function Gi(e,t){switch(ie(Jr,t),ie(Qr,e),ie(It,sa),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Es(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Es(t,e)}ce(It),ie(It,t)}function ar(){ce(It),ce(Qr),ce(Jr)}function pd(e){jn(Jr.current);var t=jn(It.current),n=Es(t,e.type);t!==n&&(ie(Qr,e),ie(It,n))}function Yi(e){Qr.current===e&&(ce(It),ce(Qr))}var me=mn(0);function io(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var rs=[];function Qi(){for(var e=0;e<rs.length;e++)rs[e]._workInProgressVersionPrimary=null;rs.length=0}var La=Ht.ReactCurrentDispatcher,as=Ht.ReactCurrentBatchConfig,zn=0,pe=null,we=null,be=null,lo=!1,_r=!1,Xr=0,Op=0;function _e(){throw Error(F(321))}function Ji(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!jt(e[n],t[n]))return!1;return!0}function Xi(e,t,n,r,a,s){if(zn=s,pe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,La.current=e===null||e.memoizedState===null?Wp:Hp,e=n(r,a),_r){s=0;do{if(_r=!1,Xr=0,25<=s)throw Error(F(301));s+=1,be=we=null,t.updateQueue=null,La.current=Vp,e=n(r,a)}while(_r)}if(La.current=co,t=we!==null&&we.next!==null,zn=0,be=we=pe=null,lo=!1,t)throw Error(F(300));return e}function qi(){var e=Xr!==0;return Xr=0,e}function bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return be===null?pe.memoizedState=be=e:be=be.next=e,be}function dt(){if(we===null){var e=pe.alternate;e=e!==null?e.memoizedState:null}else e=we.next;var t=be===null?pe.memoizedState:be.next;if(t!==null)be=t,we=e;else{if(e===null)throw Error(F(310));we=e,e={memoizedState:we.memoizedState,baseState:we.baseState,baseQueue:we.baseQueue,queue:we.queue,next:null},be===null?pe.memoizedState=be=e:be=be.next=e}return be}function qr(e,t){return typeof t=="function"?t(e):t}function os(e){var t=dt(),n=t.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=e;var r=we,a=r.baseQueue,s=n.pending;if(s!==null){if(a!==null){var i=a.next;a.next=s.next,s.next=i}r.baseQueue=a=s,n.pending=null}if(a!==null){s=a.next,r=r.baseState;var l=i=null,c=null,u=s;do{var p=u.lane;if((zn&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,i=r):c=c.next=f,pe.lanes|=p,In|=p}u=u.next}while(u!==null&&u!==s);c===null?i=r:c.next=l,jt(r,t.memoizedState)||(He=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do s=a.lane,pe.lanes|=s,In|=s,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function ss(e){var t=dt(),n=t.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(a!==null){n.pending=null;var i=a=a.next;do s=e(s,i.action),i=i.next;while(i!==a);jt(s,t.memoizedState)||(He=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function hd(){}function gd(e,t){var n=pe,r=dt(),a=t(),s=!jt(r.memoizedState,a);if(s&&(r.memoizedState=a,He=!0),r=r.queue,Zi(xd.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||be!==null&&be.memoizedState.tag&1){if(n.flags|=2048,Zr(9,yd.bind(null,n,r,a,t),void 0,null),Ne===null)throw Error(F(349));zn&30||vd(n,t,a)}return a}function vd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=pe.updateQueue,t===null?(t={lastEffect:null,stores:null},pe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function yd(e,t,n,r){t.value=n,t.getSnapshot=r,wd(t)&&Sd(e)}function xd(e,t,n){return n(function(){wd(t)&&Sd(e)})}function wd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!jt(e,n)}catch{return!0}}function Sd(e){var t=Dt(e,1);t!==null&&St(t,e,1,-1)}function lc(e){var t=bt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:qr,lastRenderedState:e},t.queue=e,e=e.dispatch=Up.bind(null,pe,e),[t.memoizedState,e]}function Zr(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=pe.updateQueue,t===null?(t={lastEffect:null,stores:null},pe.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function jd(){return dt().memoizedState}function Ma(e,t,n,r){var a=bt();pe.flags|=e,a.memoizedState=Zr(1|t,n,void 0,r===void 0?null:r)}function No(e,t,n,r){var a=dt();r=r===void 0?null:r;var s=void 0;if(we!==null){var i=we.memoizedState;if(s=i.destroy,r!==null&&Ji(r,i.deps)){a.memoizedState=Zr(t,n,s,r);return}}pe.flags|=e,a.memoizedState=Zr(1|t,n,s,r)}function cc(e,t){return Ma(8390656,8,e,t)}function Zi(e,t){return No(2048,8,e,t)}function kd(e,t){return No(4,2,e,t)}function Cd(e,t){return No(4,4,e,t)}function bd(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Nd(e,t,n){return n=n!=null?n.concat([e]):null,No(4,4,bd.bind(null,t,e),n)}function el(){}function Ed(e,t){var n=dt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Ji(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function zd(e,t){var n=dt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Ji(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Id(e,t,n){return zn&21?(jt(n,t)||(n=Au(),pe.lanes|=n,In|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,He=!0),e.memoizedState=n)}function Bp(e,t){var n=ae;ae=n!==0&&4>n?n:4,e(!0);var r=as.transition;as.transition={};try{e(!1),t()}finally{ae=n,as.transition=r}}function Pd(){return dt().memoizedState}function Dp(e,t,n){var r=ln(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Td(e))Rd(t,n);else if(n=fd(e,t,n,r),n!==null){var a=Oe();St(n,e,r,a),_d(n,t,r)}}function Up(e,t,n){var r=ln(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Td(e))Rd(t,a);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var i=t.lastRenderedState,l=s(i,n);if(a.hasEagerState=!0,a.eagerState=l,jt(l,i)){var c=t.interleaved;c===null?(a.next=a,Vi(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=fd(e,t,a,r),n!==null&&(a=Oe(),St(n,e,r,a),_d(n,t,r))}}function Td(e){var t=e.alternate;return e===pe||t!==null&&t===pe}function Rd(e,t){_r=lo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function _d(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ti(e,n)}}var co={readContext:ut,useCallback:_e,useContext:_e,useEffect:_e,useImperativeHandle:_e,useInsertionEffect:_e,useLayoutEffect:_e,useMemo:_e,useReducer:_e,useRef:_e,useState:_e,useDebugValue:_e,useDeferredValue:_e,useTransition:_e,useMutableSource:_e,useSyncExternalStore:_e,useId:_e,unstable_isNewReconciler:!1},Wp={readContext:ut,useCallback:function(e,t){return bt().memoizedState=[e,t===void 0?null:t],e},useContext:ut,useEffect:cc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ma(4194308,4,bd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ma(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ma(4,2,e,t)},useMemo:function(e,t){var n=bt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Dp.bind(null,pe,e),[r.memoizedState,e]},useRef:function(e){var t=bt();return e={current:e},t.memoizedState=e},useState:lc,useDebugValue:el,useDeferredValue:function(e){return bt().memoizedState=e},useTransition:function(){var e=lc(!1),t=e[0];return e=Bp.bind(null,e[1]),bt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=pe,a=bt();if(ue){if(n===void 0)throw Error(F(407));n=n()}else{if(n=t(),Ne===null)throw Error(F(349));zn&30||vd(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,cc(xd.bind(null,r,s,e),[e]),r.flags|=2048,Zr(9,yd.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=bt(),t=Ne.identifierPrefix;if(ue){var n=Lt,r=$t;n=(r&~(1<<32-wt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Xr++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Op++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Hp={readContext:ut,useCallback:Ed,useContext:ut,useEffect:Zi,useImperativeHandle:Nd,useInsertionEffect:kd,useLayoutEffect:Cd,useMemo:zd,useReducer:os,useRef:jd,useState:function(){return os(qr)},useDebugValue:el,useDeferredValue:function(e){var t=dt();return Id(t,we.memoizedState,e)},useTransition:function(){var e=os(qr)[0],t=dt().memoizedState;return[e,t]},useMutableSource:hd,useSyncExternalStore:gd,useId:Pd,unstable_isNewReconciler:!1},Vp={readContext:ut,useCallback:Ed,useContext:ut,useEffect:Zi,useImperativeHandle:Nd,useInsertionEffect:kd,useLayoutEffect:Cd,useMemo:zd,useReducer:ss,useRef:jd,useState:function(){return ss(qr)},useDebugValue:el,useDeferredValue:function(e){var t=dt();return we===null?t.memoizedState=e:Id(t,we.memoizedState,e)},useTransition:function(){var e=ss(qr)[0],t=dt().memoizedState;return[e,t]},useMutableSource:hd,useSyncExternalStore:gd,useId:Pd,unstable_isNewReconciler:!1};function vt(e,t){if(e&&e.defaultProps){t=he({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Ys(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:he({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Eo={isMounted:function(e){return(e=e._reactInternals)?Rn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Oe(),a=ln(e),s=Ft(r,a);s.payload=t,n!=null&&(s.callback=n),t=on(e,s,a),t!==null&&(St(t,e,a,r),$a(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Oe(),a=ln(e),s=Ft(r,a);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=on(e,s,a),t!==null&&(St(t,e,a,r),$a(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Oe(),r=ln(e),a=Ft(n,r);a.tag=2,t!=null&&(a.callback=t),t=on(e,a,r),t!==null&&(St(t,e,r,n),$a(t,e,r))}};function uc(e,t,n,r,a,s,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,i):t.prototype&&t.prototype.isPureReactComponent?!Vr(n,r)||!Vr(a,s):!0}function Ad(e,t,n){var r=!1,a=dn,s=t.contextType;return typeof s=="object"&&s!==null?s=ut(s):(a=Ke(t)?Nn:Le.current,r=t.contextTypes,s=(r=r!=null)?tr(e,a):dn),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Eo,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=s),t}function dc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Eo.enqueueReplaceState(t,t.state,null)}function Qs(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Ki(e);var s=t.contextType;typeof s=="object"&&s!==null?a.context=ut(s):(s=Ke(t)?Nn:Le.current,a.context=tr(e,s)),a.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(Ys(e,t,s,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&Eo.enqueueReplaceState(a,a.state,null),so(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function or(e,t){try{var n="",r=t;do n+=xm(r),r=r.return;while(r);var a=n}catch(s){a=`
39
+ Error generating stack: `+s.message+`
40
+ `+s.stack}return{value:e,source:t,stack:a,digest:null}}function is(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Js(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Kp=typeof WeakMap=="function"?WeakMap:Map;function $d(e,t,n){n=Ft(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){fo||(fo=!0,si=r),Js(e,t)},n}function Ld(e,t,n){n=Ft(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){Js(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Js(e,t),typeof r!="function"&&(sn===null?sn=new Set([this]):sn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function fc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Kp;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=sh.bind(null,e,t,n),t.then(e,e))}function mc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function pc(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ft(-1,1),t.tag=2,on(n,t,1))),n.lanes|=1),e)}var Gp=Ht.ReactCurrentOwner,He=!1;function Fe(e,t,n,r){t.child=e===null?dd(t,null,n,r):rr(t,e.child,n,r)}function hc(e,t,n,r,a){n=n.render;var s=t.ref;return qn(t,a),r=Xi(e,t,n,r,s,a),n=qi(),e!==null&&!He?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Ut(e,t,a)):(ue&&n&&Oi(t),t.flags|=1,Fe(e,t,r,a),t.child)}function gc(e,t,n,r,a){if(e===null){var s=n.type;return typeof s=="function"&&!ll(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,Md(e,t,s,r,a)):(e=Da(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&a)){var i=s.memoizedProps;if(n=n.compare,n=n!==null?n:Vr,n(i,r)&&e.ref===t.ref)return Ut(e,t,a)}return t.flags|=1,e=cn(s,r),e.ref=t.ref,e.return=t,t.child=e}function Md(e,t,n,r,a){if(e!==null){var s=e.memoizedProps;if(Vr(s,r)&&e.ref===t.ref)if(He=!1,t.pendingProps=r=s,(e.lanes&a)!==0)e.flags&131072&&(He=!0);else return t.lanes=e.lanes,Ut(e,t,a)}return Xs(e,t,n,r,a)}function Fd(e,t,n){var r=t.pendingProps,a=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ie(Gn,qe),qe|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ie(Gn,qe),qe|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ie(Gn,qe),qe|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,ie(Gn,qe),qe|=r;return Fe(e,t,a,n),t.child}function Od(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Xs(e,t,n,r,a){var s=Ke(n)?Nn:Le.current;return s=tr(t,s),qn(t,a),n=Xi(e,t,n,r,s,a),r=qi(),e!==null&&!He?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Ut(e,t,a)):(ue&&r&&Oi(t),t.flags|=1,Fe(e,t,n,a),t.child)}function vc(e,t,n,r,a){if(Ke(n)){var s=!0;to(t)}else s=!1;if(qn(t,a),t.stateNode===null)Fa(e,t),Ad(t,n,r),Qs(t,n,r,a),r=!0;else if(e===null){var i=t.stateNode,l=t.memoizedProps;i.props=l;var c=i.context,u=n.contextType;typeof u=="object"&&u!==null?u=ut(u):(u=Ke(n)?Nn:Le.current,u=tr(t,u));var p=n.getDerivedStateFromProps,f=typeof p=="function"||typeof i.getSnapshotBeforeUpdate=="function";f||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==u)&&dc(t,i,r,u),Qt=!1;var v=t.memoizedState;i.state=v,so(t,r,i,a),c=t.memoizedState,l!==r||v!==c||Ve.current||Qt?(typeof p=="function"&&(Ys(t,n,p,r),c=t.memoizedState),(l=Qt||uc(t,n,l,r,v,c,u))?(f||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=u,r=l):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,md(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:vt(t.type,l),i.props=u,f=t.pendingProps,v=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=ut(c):(c=Ke(n)?Nn:Le.current,c=tr(t,c));var y=n.getDerivedStateFromProps;(p=typeof y=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==f||v!==c)&&dc(t,i,r,c),Qt=!1,v=t.memoizedState,i.state=v,so(t,r,i,a);var x=t.memoizedState;l!==f||v!==x||Ve.current||Qt?(typeof y=="function"&&(Ys(t,n,y,r),x=t.memoizedState),(u=Qt||uc(t,n,u,r,v,x,c)||!1)?(p||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,x,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,x,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&v===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&v===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),i.props=r,i.state=x,i.context=c,r=u):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&v===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&v===e.memoizedState||(t.flags|=1024),r=!1)}return qs(e,t,n,r,s,a)}function qs(e,t,n,r,a,s){Od(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return a&&nc(t,n,!1),Ut(e,t,s);r=t.stateNode,Gp.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=rr(t,e.child,null,s),t.child=rr(t,null,l,s)):Fe(e,t,l,s),t.memoizedState=r.state,a&&nc(t,n,!0),t.child}function Bd(e){var t=e.stateNode;t.pendingContext?tc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&tc(e,t.context,!1),Gi(e,t.containerInfo)}function yc(e,t,n,r,a){return nr(),Di(a),t.flags|=256,Fe(e,t,n,r),t.child}var Zs={dehydrated:null,treeContext:null,retryLane:0};function ei(e){return{baseLanes:e,cachePool:null,transitions:null}}function Dd(e,t,n){var r=t.pendingProps,a=me.current,s=!1,i=(t.flags&128)!==0,l;if((l=i)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ie(me,a&1),e===null)return Ks(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,s?(r=t.mode,s=t.child,i={mode:"hidden",children:i},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=i):s=Po(i,r,0,null),e=bn(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=ei(n),t.memoizedState=Zs,e):tl(t,i));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return Yp(e,t,i,r,l,a,n);if(s){s=r.fallback,i=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=cn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?s=cn(l,s):(s=bn(s,i,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,i=e.child.memoizedState,i=i===null?ei(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~n,t.memoizedState=Zs,r}return s=e.child,e=s.sibling,r=cn(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function tl(e,t){return t=Po({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function ka(e,t,n,r){return r!==null&&Di(r),rr(t,e.child,null,n),e=tl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Yp(e,t,n,r,a,s,i){if(n)return t.flags&256?(t.flags&=-257,r=is(Error(F(422))),ka(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,a=t.mode,r=Po({mode:"visible",children:r.children},a,0,null),s=bn(s,a,i,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&rr(t,e.child,null,i),t.child.memoizedState=ei(i),t.memoizedState=Zs,s);if(!(t.mode&1))return ka(e,t,i,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(F(419)),r=is(s,r,void 0),ka(e,t,i,r)}if(l=(i&e.childLanes)!==0,He||l){if(r=Ne,r!==null){switch(i&-i){case 4:a=2;break;case 16:a=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|i)?0:a,a!==0&&a!==s.retryLane&&(s.retryLane=a,Dt(e,a),St(r,e,a,-1))}return il(),r=is(Error(F(421))),ka(e,t,i,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=ih.bind(null,e),a._reactRetry=t,null):(e=s.treeContext,et=an(a.nextSibling),tt=t,ue=!0,xt=null,e!==null&&(st[it++]=$t,st[it++]=Lt,st[it++]=En,$t=e.id,Lt=e.overflow,En=t),t=tl(t,r.children),t.flags|=4096,t)}function xc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Gs(e.return,t,n)}function ls(e,t,n,r,a){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=a)}function Ud(e,t,n){var r=t.pendingProps,a=r.revealOrder,s=r.tail;if(Fe(e,t,r.children,n),r=me.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&xc(e,n,t);else if(e.tag===19)xc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ie(me,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&io(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),ls(t,!1,a,n,s);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&io(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}ls(t,!0,n,null,s);break;case"together":ls(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Fa(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ut(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),In|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(F(153));if(t.child!==null){for(e=t.child,n=cn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=cn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Qp(e,t,n){switch(t.tag){case 3:Bd(t),nr();break;case 5:pd(t);break;case 1:Ke(t.type)&&to(t);break;case 4:Gi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;ie(ao,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ie(me,me.current&1),t.flags|=128,null):n&t.child.childLanes?Dd(e,t,n):(ie(me,me.current&1),e=Ut(e,t,n),e!==null?e.sibling:null);ie(me,me.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Ud(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ie(me,me.current),r)break;return null;case 22:case 23:return t.lanes=0,Fd(e,t,n)}return Ut(e,t,n)}var Wd,ti,Hd,Vd;Wd=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};ti=function(){};Hd=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,jn(It.current);var s=null;switch(n){case"input":a=ks(e,a),r=ks(e,r),s=[];break;case"select":a=he({},a,{value:void 0}),r=he({},r,{value:void 0}),s=[];break;case"textarea":a=Ns(e,a),r=Ns(e,r),s=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Za)}zs(n,r);var i;n=null;for(u in a)if(!r.hasOwnProperty(u)&&a.hasOwnProperty(u)&&a[u]!=null)if(u==="style"){var l=a[u];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Fr.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var c=r[u];if(l=a!=null?a[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(s=s||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Fr.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&le("scroll",e),s||l===c||(s=[])):(s=s||[]).push(u,c))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}};Vd=function(e,t,n,r){n!==r&&(t.flags|=4)};function wr(e,t){if(!ue)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ae(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Jp(e,t,n){var r=t.pendingProps;switch(Bi(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ae(t),null;case 1:return Ke(t.type)&&eo(),Ae(t),null;case 3:return r=t.stateNode,ar(),ce(Ve),ce(Le),Qi(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Sa(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,xt!==null&&(ci(xt),xt=null))),ti(e,t),Ae(t),null;case 5:Yi(t);var a=jn(Jr.current);if(n=t.type,e!==null&&t.stateNode!=null)Hd(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(F(166));return Ae(t),null}if(e=jn(It.current),Sa(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Et]=t,r[Yr]=s,e=(t.mode&1)!==0,n){case"dialog":le("cancel",r),le("close",r);break;case"iframe":case"object":case"embed":le("load",r);break;case"video":case"audio":for(a=0;a<Nr.length;a++)le(Nr[a],r);break;case"source":le("error",r);break;case"img":case"image":case"link":le("error",r),le("load",r);break;case"details":le("toggle",r);break;case"input":zl(r,s),le("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},le("invalid",r);break;case"textarea":Pl(r,s),le("invalid",r)}zs(n,s),a=null;for(var i in s)if(s.hasOwnProperty(i)){var l=s[i];i==="children"?typeof l=="string"?r.textContent!==l&&(s.suppressHydrationWarning!==!0&&wa(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&wa(r.textContent,l,e),a=["children",""+l]):Fr.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&le("scroll",r)}switch(n){case"input":fa(r),Il(r,s,!0);break;case"textarea":fa(r),Tl(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=Za)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=xu(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Et]=t,e[Yr]=r,Wd(e,t,!1,!1),t.stateNode=e;e:{switch(i=Is(n,r),n){case"dialog":le("cancel",e),le("close",e),a=r;break;case"iframe":case"object":case"embed":le("load",e),a=r;break;case"video":case"audio":for(a=0;a<Nr.length;a++)le(Nr[a],e);a=r;break;case"source":le("error",e),a=r;break;case"img":case"image":case"link":le("error",e),le("load",e),a=r;break;case"details":le("toggle",e),a=r;break;case"input":zl(e,r),a=ks(e,r),le("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=he({},r,{value:void 0}),le("invalid",e);break;case"textarea":Pl(e,r),a=Ns(e,r),le("invalid",e);break;default:a=r}zs(n,a),l=a;for(s in l)if(l.hasOwnProperty(s)){var c=l[s];s==="style"?ju(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&wu(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Or(e,c):typeof c=="number"&&Or(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Fr.hasOwnProperty(s)?c!=null&&s==="onScroll"&&le("scroll",e):c!=null&&bi(e,s,c,i))}switch(n){case"input":fa(e),Il(e,r,!1);break;case"textarea":fa(e),Tl(e);break;case"option":r.value!=null&&e.setAttribute("value",""+un(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Yn(e,!!r.multiple,s,!1):r.defaultValue!=null&&Yn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Za)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ae(t),null;case 6:if(e&&t.stateNode!=null)Vd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(F(166));if(n=jn(Jr.current),jn(It.current),Sa(t)){if(r=t.stateNode,n=t.memoizedProps,r[Et]=t,(s=r.nodeValue!==n)&&(e=tt,e!==null))switch(e.tag){case 3:wa(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&wa(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Et]=t,t.stateNode=r}return Ae(t),null;case 13:if(ce(me),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ue&&et!==null&&t.mode&1&&!(t.flags&128))cd(),nr(),t.flags|=98560,s=!1;else if(s=Sa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(F(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(F(317));s[Et]=t}else nr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ae(t),s=!1}else xt!==null&&(ci(xt),xt=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||me.current&1?Se===0&&(Se=3):il())),t.updateQueue!==null&&(t.flags|=4),Ae(t),null);case 4:return ar(),ti(e,t),e===null&&Kr(t.stateNode.containerInfo),Ae(t),null;case 10:return Hi(t.type._context),Ae(t),null;case 17:return Ke(t.type)&&eo(),Ae(t),null;case 19:if(ce(me),s=t.memoizedState,s===null)return Ae(t),null;if(r=(t.flags&128)!==0,i=s.rendering,i===null)if(r)wr(s,!1);else{if(Se!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=io(e),i!==null){for(t.flags|=128,wr(s,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,i=s.alternate,i===null?(s.childLanes=0,s.lanes=e,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,e=i.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ie(me,me.current&1|2),t.child}e=e.sibling}s.tail!==null&&ve()>sr&&(t.flags|=128,r=!0,wr(s,!1),t.lanes=4194304)}else{if(!r)if(e=io(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),wr(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!ue)return Ae(t),null}else 2*ve()-s.renderingStartTime>sr&&n!==1073741824&&(t.flags|=128,r=!0,wr(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(n=s.last,n!==null?n.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=ve(),t.sibling=null,n=me.current,ie(me,r?n&1|2:n&1),t):(Ae(t),null);case 22:case 23:return sl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?qe&1073741824&&(Ae(t),t.subtreeFlags&6&&(t.flags|=8192)):Ae(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function Xp(e,t){switch(Bi(t),t.tag){case 1:return Ke(t.type)&&eo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ar(),ce(Ve),ce(Le),Qi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Yi(t),null;case 13:if(ce(me),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));nr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ce(me),null;case 4:return ar(),null;case 10:return Hi(t.type._context),null;case 22:case 23:return sl(),null;case 24:return null;default:return null}}var Ca=!1,$e=!1,qp=typeof WeakSet=="function"?WeakSet:Set,G=null;function Kn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ge(e,t,r)}else n.current=null}function ni(e,t,n){try{n()}catch(r){ge(e,t,r)}}var wc=!1;function Zp(e,t){if(Os=Ja,e=Ju(),Fi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var i=0,l=-1,c=-1,u=0,p=0,f=e,v=null;t:for(;;){for(var y;f!==n||a!==0&&f.nodeType!==3||(l=i+a),f!==s||r!==0&&f.nodeType!==3||(c=i+r),f.nodeType===3&&(i+=f.nodeValue.length),(y=f.firstChild)!==null;)v=f,f=y;for(;;){if(f===e)break t;if(v===n&&++u===a&&(l=i),v===s&&++p===r&&(c=i),(y=f.nextSibling)!==null)break;f=v,v=f.parentNode}f=y}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Bs={focusedElem:e,selectionRange:n},Ja=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var w=x.memoizedProps,j=x.memoizedState,h=t.stateNode,m=h.getSnapshotBeforeUpdate(t.elementType===t.type?w:vt(t.type,w),j);h.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(S){ge(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return x=wc,wc=!1,x}function Ar(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var s=a.destroy;a.destroy=void 0,s!==void 0&&ni(t,n,s)}a=a.next}while(a!==r)}}function zo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ri(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Kd(e){var t=e.alternate;t!==null&&(e.alternate=null,Kd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Et],delete t[Yr],delete t[Ws],delete t[$p],delete t[Lp])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gd(e){return e.tag===5||e.tag===3||e.tag===4}function Sc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ai(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Za));else if(r!==4&&(e=e.child,e!==null))for(ai(e,t,n),e=e.sibling;e!==null;)ai(e,t,n),e=e.sibling}function oi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(oi(e,t,n),e=e.sibling;e!==null;)oi(e,t,n),e=e.sibling}var Pe=null,yt=!1;function Gt(e,t,n){for(n=n.child;n!==null;)Yd(e,t,n),n=n.sibling}function Yd(e,t,n){if(zt&&typeof zt.onCommitFiberUnmount=="function")try{zt.onCommitFiberUnmount(wo,n)}catch{}switch(n.tag){case 5:$e||Kn(n,t);case 6:var r=Pe,a=yt;Pe=null,Gt(e,t,n),Pe=r,yt=a,Pe!==null&&(yt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(yt?(e=Pe,n=n.stateNode,e.nodeType===8?ts(e.parentNode,n):e.nodeType===1&&ts(e,n),Wr(e)):ts(Pe,n.stateNode));break;case 4:r=Pe,a=yt,Pe=n.stateNode.containerInfo,yt=!0,Gt(e,t,n),Pe=r,yt=a;break;case 0:case 11:case 14:case 15:if(!$e&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var s=a,i=s.destroy;s=s.tag,i!==void 0&&(s&2||s&4)&&ni(n,t,i),a=a.next}while(a!==r)}Gt(e,t,n);break;case 1:if(!$e&&(Kn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ge(n,t,l)}Gt(e,t,n);break;case 21:Gt(e,t,n);break;case 22:n.mode&1?($e=(r=$e)||n.memoizedState!==null,Gt(e,t,n),$e=r):Gt(e,t,n);break;default:Gt(e,t,n)}}function jc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new qp),t.forEach(function(r){var a=lh.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function gt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var s=e,i=t,l=i;e:for(;l!==null;){switch(l.tag){case 5:Pe=l.stateNode,yt=!1;break e;case 3:Pe=l.stateNode.containerInfo,yt=!0;break e;case 4:Pe=l.stateNode.containerInfo,yt=!0;break e}l=l.return}if(Pe===null)throw Error(F(160));Yd(s,i,a),Pe=null,yt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(u){ge(a,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Qd(t,e),t=t.sibling}function Qd(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gt(t,e),Ct(e),r&4){try{Ar(3,e,e.return),zo(3,e)}catch(w){ge(e,e.return,w)}try{Ar(5,e,e.return)}catch(w){ge(e,e.return,w)}}break;case 1:gt(t,e),Ct(e),r&512&&n!==null&&Kn(n,n.return);break;case 5:if(gt(t,e),Ct(e),r&512&&n!==null&&Kn(n,n.return),e.flags&32){var a=e.stateNode;try{Or(a,"")}catch(w){ge(e,e.return,w)}}if(r&4&&(a=e.stateNode,a!=null)){var s=e.memoizedProps,i=n!==null?n.memoizedProps:s,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&vu(a,s),Is(l,i);var u=Is(l,s);for(i=0;i<c.length;i+=2){var p=c[i],f=c[i+1];p==="style"?ju(a,f):p==="dangerouslySetInnerHTML"?wu(a,f):p==="children"?Or(a,f):bi(a,p,f,u)}switch(l){case"input":Cs(a,s);break;case"textarea":yu(a,s);break;case"select":var v=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!s.multiple;var y=s.value;y!=null?Yn(a,!!s.multiple,y,!1):v!==!!s.multiple&&(s.defaultValue!=null?Yn(a,!!s.multiple,s.defaultValue,!0):Yn(a,!!s.multiple,s.multiple?[]:"",!1))}a[Yr]=s}catch(w){ge(e,e.return,w)}}break;case 6:if(gt(t,e),Ct(e),r&4){if(e.stateNode===null)throw Error(F(162));a=e.stateNode,s=e.memoizedProps;try{a.nodeValue=s}catch(w){ge(e,e.return,w)}}break;case 3:if(gt(t,e),Ct(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Wr(t.containerInfo)}catch(w){ge(e,e.return,w)}break;case 4:gt(t,e),Ct(e);break;case 13:gt(t,e),Ct(e),a=e.child,a.flags&8192&&(s=a.memoizedState!==null,a.stateNode.isHidden=s,!s||a.alternate!==null&&a.alternate.memoizedState!==null||(al=ve())),r&4&&jc(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?($e=(u=$e)||p,gt(t,e),$e=u):gt(t,e),Ct(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(G=e,p=e.child;p!==null;){for(f=G=p;G!==null;){switch(v=G,y=v.child,v.tag){case 0:case 11:case 14:case 15:Ar(4,v,v.return);break;case 1:Kn(v,v.return);var x=v.stateNode;if(typeof x.componentWillUnmount=="function"){r=v,n=v.return;try{t=r,x.props=t.memoizedProps,x.state=t.memoizedState,x.componentWillUnmount()}catch(w){ge(r,n,w)}}break;case 5:Kn(v,v.return);break;case 22:if(v.memoizedState!==null){Cc(f);continue}}y!==null?(y.return=v,G=y):Cc(f)}p=p.sibling}e:for(p=null,f=e;;){if(f.tag===5){if(p===null){p=f;try{a=f.stateNode,u?(s=a.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=f.stateNode,c=f.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Su("display",i))}catch(w){ge(e,e.return,w)}}}else if(f.tag===6){if(p===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(w){ge(e,e.return,w)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;p===f&&(p=null),f=f.return}p===f&&(p=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:gt(t,e),Ct(e),r&4&&jc(e);break;case 21:break;default:gt(t,e),Ct(e)}}function Ct(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Gd(n)){var r=n;break e}n=n.return}throw Error(F(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(Or(a,""),r.flags&=-33);var s=Sc(e);oi(e,s,a);break;case 3:case 4:var i=r.stateNode.containerInfo,l=Sc(e);ai(e,l,i);break;default:throw Error(F(161))}}catch(c){ge(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function eh(e,t,n){G=e,Jd(e)}function Jd(e,t,n){for(var r=(e.mode&1)!==0;G!==null;){var a=G,s=a.child;if(a.tag===22&&r){var i=a.memoizedState!==null||Ca;if(!i){var l=a.alternate,c=l!==null&&l.memoizedState!==null||$e;l=Ca;var u=$e;if(Ca=i,($e=c)&&!u)for(G=a;G!==null;)i=G,c=i.child,i.tag===22&&i.memoizedState!==null?bc(a):c!==null?(c.return=i,G=c):bc(a);for(;s!==null;)G=s,Jd(s),s=s.sibling;G=a,Ca=l,$e=u}kc(e)}else a.subtreeFlags&8772&&s!==null?(s.return=a,G=s):kc(e)}}function kc(e){for(;G!==null;){var t=G;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:$e||zo(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!$e)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:vt(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&ic(t,s,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ic(t,i,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var f=p.dehydrated;f!==null&&Wr(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}$e||t.flags&512&&ri(t)}catch(v){ge(t,t.return,v)}}if(t===e){G=null;break}if(n=t.sibling,n!==null){n.return=t.return,G=n;break}G=t.return}}function Cc(e){for(;G!==null;){var t=G;if(t===e){G=null;break}var n=t.sibling;if(n!==null){n.return=t.return,G=n;break}G=t.return}}function bc(e){for(;G!==null;){var t=G;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{zo(4,t)}catch(c){ge(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){ge(t,a,c)}}var s=t.return;try{ri(t)}catch(c){ge(t,s,c)}break;case 5:var i=t.return;try{ri(t)}catch(c){ge(t,i,c)}}}catch(c){ge(t,t.return,c)}if(t===e){G=null;break}var l=t.sibling;if(l!==null){l.return=t.return,G=l;break}G=t.return}}var th=Math.ceil,uo=Ht.ReactCurrentDispatcher,nl=Ht.ReactCurrentOwner,ct=Ht.ReactCurrentBatchConfig,te=0,Ne=null,ye=null,Te=0,qe=0,Gn=mn(0),Se=0,ea=null,In=0,Io=0,rl=0,$r=null,We=null,al=0,sr=1/0,_t=null,fo=!1,si=null,sn=null,ba=!1,en=null,mo=0,Lr=0,ii=null,Oa=-1,Ba=0;function Oe(){return te&6?ve():Oa!==-1?Oa:Oa=ve()}function ln(e){return e.mode&1?te&2&&Te!==0?Te&-Te:Fp.transition!==null?(Ba===0&&(Ba=Au()),Ba):(e=ae,e!==0||(e=window.event,e=e===void 0?16:Du(e.type)),e):1}function St(e,t,n,r){if(50<Lr)throw Lr=0,ii=null,Error(F(185));ra(e,n,r),(!(te&2)||e!==Ne)&&(e===Ne&&(!(te&2)&&(Io|=n),Se===4&&qt(e,Te)),Ge(e,r),n===1&&te===0&&!(t.mode&1)&&(sr=ve()+500,bo&&pn()))}function Ge(e,t){var n=e.callbackNode;Fm(e,t);var r=Qa(e,e===Ne?Te:0);if(r===0)n!==null&&Al(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Al(n),t===1)e.tag===0?Mp(Nc.bind(null,e)):sd(Nc.bind(null,e)),_p(function(){!(te&6)&&pn()}),n=null;else{switch($u(r)){case 1:n=Pi;break;case 4:n=Ru;break;case 16:n=Ya;break;case 536870912:n=_u;break;default:n=Ya}n=af(n,Xd.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Xd(e,t){if(Oa=-1,Ba=0,te&6)throw Error(F(327));var n=e.callbackNode;if(Zn()&&e.callbackNode!==n)return null;var r=Qa(e,e===Ne?Te:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=po(e,r);else{t=r;var a=te;te|=2;var s=Zd();(Ne!==e||Te!==t)&&(_t=null,sr=ve()+500,Cn(e,t));do try{ah();break}catch(l){qd(e,l)}while(!0);Wi(),uo.current=s,te=a,ye!==null?t=0:(Ne=null,Te=0,t=Se)}if(t!==0){if(t===2&&(a=As(e),a!==0&&(r=a,t=li(e,a))),t===1)throw n=ea,Cn(e,0),qt(e,r),Ge(e,ve()),n;if(t===6)qt(e,r);else{if(a=e.current.alternate,!(r&30)&&!nh(a)&&(t=po(e,r),t===2&&(s=As(e),s!==0&&(r=s,t=li(e,s))),t===1))throw n=ea,Cn(e,0),qt(e,r),Ge(e,ve()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(F(345));case 2:yn(e,We,_t);break;case 3:if(qt(e,r),(r&130023424)===r&&(t=al+500-ve(),10<t)){if(Qa(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){Oe(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Us(yn.bind(null,e,We,_t),t);break}yn(e,We,_t);break;case 4:if(qt(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var i=31-wt(r);s=1<<i,i=t[i],i>a&&(a=i),r&=~s}if(r=a,r=ve()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*th(r/1960))-r,10<r){e.timeoutHandle=Us(yn.bind(null,e,We,_t),r);break}yn(e,We,_t);break;case 5:yn(e,We,_t);break;default:throw Error(F(329))}}}return Ge(e,ve()),e.callbackNode===n?Xd.bind(null,e):null}function li(e,t){var n=$r;return e.current.memoizedState.isDehydrated&&(Cn(e,t).flags|=256),e=po(e,t),e!==2&&(t=We,We=n,t!==null&&ci(t)),e}function ci(e){We===null?We=e:We.push.apply(We,e)}function nh(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],s=a.getSnapshot;a=a.value;try{if(!jt(s(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function qt(e,t){for(t&=~rl,t&=~Io,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-wt(t),r=1<<n;e[n]=-1,t&=~r}}function Nc(e){if(te&6)throw Error(F(327));Zn();var t=Qa(e,0);if(!(t&1))return Ge(e,ve()),null;var n=po(e,t);if(e.tag!==0&&n===2){var r=As(e);r!==0&&(t=r,n=li(e,r))}if(n===1)throw n=ea,Cn(e,0),qt(e,t),Ge(e,ve()),n;if(n===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,yn(e,We,_t),Ge(e,ve()),null}function ol(e,t){var n=te;te|=1;try{return e(t)}finally{te=n,te===0&&(sr=ve()+500,bo&&pn())}}function Pn(e){en!==null&&en.tag===0&&!(te&6)&&Zn();var t=te;te|=1;var n=ct.transition,r=ae;try{if(ct.transition=null,ae=1,e)return e()}finally{ae=r,ct.transition=n,te=t,!(te&6)&&pn()}}function sl(){qe=Gn.current,ce(Gn)}function Cn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Rp(n)),ye!==null)for(n=ye.return;n!==null;){var r=n;switch(Bi(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&eo();break;case 3:ar(),ce(Ve),ce(Le),Qi();break;case 5:Yi(r);break;case 4:ar();break;case 13:ce(me);break;case 19:ce(me);break;case 10:Hi(r.type._context);break;case 22:case 23:sl()}n=n.return}if(Ne=e,ye=e=cn(e.current,null),Te=qe=t,Se=0,ea=null,rl=Io=In=0,We=$r=null,Sn!==null){for(t=0;t<Sn.length;t++)if(n=Sn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,s=n.pending;if(s!==null){var i=s.next;s.next=a,r.next=i}n.pending=r}Sn=null}return e}function qd(e,t){do{var n=ye;try{if(Wi(),La.current=co,lo){for(var r=pe.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}lo=!1}if(zn=0,be=we=pe=null,_r=!1,Xr=0,nl.current=null,n===null||n.return===null){Se=1,ea=t,ye=null;break}e:{var s=e,i=n.return,l=n,c=t;if(t=Te,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,f=p.tag;if(!(p.mode&1)&&(f===0||f===11||f===15)){var v=p.alternate;v?(p.updateQueue=v.updateQueue,p.memoizedState=v.memoizedState,p.lanes=v.lanes):(p.updateQueue=null,p.memoizedState=null)}var y=mc(i);if(y!==null){y.flags&=-257,pc(y,i,l,s,t),y.mode&1&&fc(s,u,t),t=y,c=u;var x=t.updateQueue;if(x===null){var w=new Set;w.add(c),t.updateQueue=w}else x.add(c);break e}else{if(!(t&1)){fc(s,u,t),il();break e}c=Error(F(426))}}else if(ue&&l.mode&1){var j=mc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),pc(j,i,l,s,t),Di(or(c,l));break e}}s=c=or(c,l),Se!==4&&(Se=2),$r===null?$r=[s]:$r.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var h=$d(s,c,t);sc(s,h);break e;case 1:l=c;var m=s.type,g=s.stateNode;if(!(s.flags&128)&&(typeof m.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(sn===null||!sn.has(g)))){s.flags|=65536,t&=-t,s.lanes|=t;var S=Ld(s,l,t);sc(s,S);break e}}s=s.return}while(s!==null)}tf(n)}catch(E){t=E,ye===n&&n!==null&&(ye=n=n.return);continue}break}while(!0)}function Zd(){var e=uo.current;return uo.current=co,e===null?co:e}function il(){(Se===0||Se===3||Se===2)&&(Se=4),Ne===null||!(In&268435455)&&!(Io&268435455)||qt(Ne,Te)}function po(e,t){var n=te;te|=2;var r=Zd();(Ne!==e||Te!==t)&&(_t=null,Cn(e,t));do try{rh();break}catch(a){qd(e,a)}while(!0);if(Wi(),te=n,uo.current=r,ye!==null)throw Error(F(261));return Ne=null,Te=0,Se}function rh(){for(;ye!==null;)ef(ye)}function ah(){for(;ye!==null&&!Im();)ef(ye)}function ef(e){var t=rf(e.alternate,e,qe);e.memoizedProps=e.pendingProps,t===null?tf(e):ye=t,nl.current=null}function tf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Xp(n,t),n!==null){n.flags&=32767,ye=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Se=6,ye=null;return}}else if(n=Jp(n,t,qe),n!==null){ye=n;return}if(t=t.sibling,t!==null){ye=t;return}ye=t=e}while(t!==null);Se===0&&(Se=5)}function yn(e,t,n){var r=ae,a=ct.transition;try{ct.transition=null,ae=1,oh(e,t,n,r)}finally{ct.transition=a,ae=r}return null}function oh(e,t,n,r){do Zn();while(en!==null);if(te&6)throw Error(F(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(F(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(Om(e,s),e===Ne&&(ye=Ne=null,Te=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ba||(ba=!0,af(Ya,function(){return Zn(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=ct.transition,ct.transition=null;var i=ae;ae=1;var l=te;te|=4,nl.current=null,Zp(e,n),Qd(n,e),bp(Bs),Ja=!!Os,Bs=Os=null,e.current=n,eh(n),Pm(),te=l,ae=i,ct.transition=s}else e.current=n;if(ba&&(ba=!1,en=e,mo=a),s=e.pendingLanes,s===0&&(sn=null),_m(n.stateNode),Ge(e,ve()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(fo)throw fo=!1,e=si,si=null,e;return mo&1&&e.tag!==0&&Zn(),s=e.pendingLanes,s&1?e===ii?Lr++:(Lr=0,ii=e):Lr=0,pn(),null}function Zn(){if(en!==null){var e=$u(mo),t=ct.transition,n=ae;try{if(ct.transition=null,ae=16>e?16:e,en===null)var r=!1;else{if(e=en,en=null,mo=0,te&6)throw Error(F(331));var a=te;for(te|=4,G=e.current;G!==null;){var s=G,i=s.child;if(G.flags&16){var l=s.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(G=u;G!==null;){var p=G;switch(p.tag){case 0:case 11:case 15:Ar(8,p,s)}var f=p.child;if(f!==null)f.return=p,G=f;else for(;G!==null;){p=G;var v=p.sibling,y=p.return;if(Kd(p),p===u){G=null;break}if(v!==null){v.return=y,G=v;break}G=y}}}var x=s.alternate;if(x!==null){var w=x.child;if(w!==null){x.child=null;do{var j=w.sibling;w.sibling=null,w=j}while(w!==null)}}G=s}}if(s.subtreeFlags&2064&&i!==null)i.return=s,G=i;else e:for(;G!==null;){if(s=G,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Ar(9,s,s.return)}var h=s.sibling;if(h!==null){h.return=s.return,G=h;break e}G=s.return}}var m=e.current;for(G=m;G!==null;){i=G;var g=i.child;if(i.subtreeFlags&2064&&g!==null)g.return=i,G=g;else e:for(i=m;G!==null;){if(l=G,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:zo(9,l)}}catch(E){ge(l,l.return,E)}if(l===i){G=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,G=S;break e}G=l.return}}if(te=a,pn(),zt&&typeof zt.onPostCommitFiberRoot=="function")try{zt.onPostCommitFiberRoot(wo,e)}catch{}r=!0}return r}finally{ae=n,ct.transition=t}}return!1}function Ec(e,t,n){t=or(n,t),t=$d(e,t,1),e=on(e,t,1),t=Oe(),e!==null&&(ra(e,1,t),Ge(e,t))}function ge(e,t,n){if(e.tag===3)Ec(e,e,n);else for(;t!==null;){if(t.tag===3){Ec(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(sn===null||!sn.has(r))){e=or(n,e),e=Ld(t,e,1),t=on(t,e,1),e=Oe(),t!==null&&(ra(t,1,e),Ge(t,e));break}}t=t.return}}function sh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Oe(),e.pingedLanes|=e.suspendedLanes&n,Ne===e&&(Te&n)===n&&(Se===4||Se===3&&(Te&130023424)===Te&&500>ve()-al?Cn(e,0):rl|=n),Ge(e,t)}function nf(e,t){t===0&&(e.mode&1?(t=ha,ha<<=1,!(ha&130023424)&&(ha=4194304)):t=1);var n=Oe();e=Dt(e,t),e!==null&&(ra(e,t,n),Ge(e,n))}function ih(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),nf(e,n)}function lh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(F(314))}r!==null&&r.delete(t),nf(e,n)}var rf;rf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ve.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,Qp(e,t,n);He=!!(e.flags&131072)}else He=!1,ue&&t.flags&1048576&&id(t,ro,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Fa(e,t),e=t.pendingProps;var a=tr(t,Le.current);qn(t,n),a=Xi(null,t,r,e,a,n);var s=qi();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ke(r)?(s=!0,to(t)):s=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ki(t),a.updater=Eo,t.stateNode=a,a._reactInternals=t,Qs(t,r,e,n),t=qs(null,t,r,!0,s,n)):(t.tag=0,ue&&s&&Oi(t),Fe(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Fa(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=uh(r),e=vt(r,e),a){case 0:t=Xs(null,t,r,e,n);break e;case 1:t=vc(null,t,r,e,n);break e;case 11:t=hc(null,t,r,e,n);break e;case 14:t=gc(null,t,r,vt(r.type,e),n);break e}throw Error(F(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:vt(r,a),Xs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:vt(r,a),vc(e,t,r,a,n);case 3:e:{if(Bd(t),e===null)throw Error(F(387));r=t.pendingProps,s=t.memoizedState,a=s.element,md(e,t),so(t,r,null,n);var i=t.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){a=or(Error(F(423)),t),t=yc(e,t,r,n,a);break e}else if(r!==a){a=or(Error(F(424)),t),t=yc(e,t,r,n,a);break e}else for(et=an(t.stateNode.containerInfo.firstChild),tt=t,ue=!0,xt=null,n=dd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(nr(),r===a){t=Ut(e,t,n);break e}Fe(e,t,r,n)}t=t.child}return t;case 5:return pd(t),e===null&&Ks(t),r=t.type,a=t.pendingProps,s=e!==null?e.memoizedProps:null,i=a.children,Ds(r,a)?i=null:s!==null&&Ds(r,s)&&(t.flags|=32),Od(e,t),Fe(e,t,i,n),t.child;case 6:return e===null&&Ks(t),null;case 13:return Dd(e,t,n);case 4:return Gi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=rr(t,null,r,n):Fe(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:vt(r,a),hc(e,t,r,a,n);case 7:return Fe(e,t,t.pendingProps,n),t.child;case 8:return Fe(e,t,t.pendingProps.children,n),t.child;case 12:return Fe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,s=t.memoizedProps,i=a.value,ie(ao,r._currentValue),r._currentValue=i,s!==null)if(jt(s.value,i)){if(s.children===a.children&&!Ve.current){t=Ut(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){i=s.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=Ft(-1,n&-n),c.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Gs(s.return,n,t),l.lanes|=n;break}c=c.next}}else if(s.tag===10)i=s.type===t.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(F(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Gs(i,n,t),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===t){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}Fe(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,qn(t,n),a=ut(a),r=r(a),t.flags|=1,Fe(e,t,r,n),t.child;case 14:return r=t.type,a=vt(r,t.pendingProps),a=vt(r.type,a),gc(e,t,r,a,n);case 15:return Md(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:vt(r,a),Fa(e,t),t.tag=1,Ke(r)?(e=!0,to(t)):e=!1,qn(t,n),Ad(t,r,a),Qs(t,r,a,n),qs(null,t,r,!0,e,n);case 19:return Ud(e,t,n);case 22:return Fd(e,t,n)}throw Error(F(156,t.tag))};function af(e,t){return Tu(e,t)}function ch(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new ch(e,t,n,r)}function ll(e){return e=e.prototype,!(!e||!e.isReactComponent)}function uh(e){if(typeof e=="function")return ll(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ei)return 11;if(e===zi)return 14}return 2}function cn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Da(e,t,n,r,a,s){var i=2;if(r=e,typeof e=="function")ll(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Mn:return bn(n.children,a,s,t);case Ni:i=8,a|=8;break;case xs:return e=lt(12,n,t,a|2),e.elementType=xs,e.lanes=s,e;case ws:return e=lt(13,n,t,a),e.elementType=ws,e.lanes=s,e;case Ss:return e=lt(19,n,t,a),e.elementType=Ss,e.lanes=s,e;case pu:return Po(n,a,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case fu:i=10;break e;case mu:i=9;break e;case Ei:i=11;break e;case zi:i=14;break e;case Yt:i=16,r=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=lt(i,n,t,a),t.elementType=e,t.type=r,t.lanes=s,t}function bn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function Po(e,t,n,r){return e=lt(22,e,r,t),e.elementType=pu,e.lanes=n,e.stateNode={isHidden:!1},e}function cs(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function us(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function dh(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ho(0),this.expirationTimes=Ho(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ho(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function cl(e,t,n,r,a,s,i,l,c){return e=new dh(e,t,n,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=lt(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ki(s),e}function fh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ln,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function of(e){if(!e)return dn;e=e._reactInternals;e:{if(Rn(e)!==e||e.tag!==1)throw Error(F(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ke(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(F(171))}if(e.tag===1){var n=e.type;if(Ke(n))return od(e,n,t)}return t}function sf(e,t,n,r,a,s,i,l,c){return e=cl(n,r,!0,e,a,s,i,l,c),e.context=of(null),n=e.current,r=Oe(),a=ln(n),s=Ft(r,a),s.callback=t??null,on(n,s,a),e.current.lanes=a,ra(e,a,r),Ge(e,r),e}function To(e,t,n,r){var a=t.current,s=Oe(),i=ln(a);return n=of(n),t.context===null?t.context=n:t.pendingContext=n,t=Ft(s,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=on(a,t,i),e!==null&&(St(e,a,i,s),$a(e,a,i)),i}function ho(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function zc(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ul(e,t){zc(e,t),(e=e.alternate)&&zc(e,t)}function mh(){return null}var lf=typeof reportError=="function"?reportError:function(e){console.error(e)};function dl(e){this._internalRoot=e}Ro.prototype.render=dl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));To(e,t,null,null)};Ro.prototype.unmount=dl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Pn(function(){To(null,e,null,null)}),t[Bt]=null}};function Ro(e){this._internalRoot=e}Ro.prototype.unstable_scheduleHydration=function(e){if(e){var t=Fu();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Xt.length&&t!==0&&t<Xt[n].priority;n++);Xt.splice(n,0,e),n===0&&Bu(e)}};function fl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function _o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Ic(){}function ph(e,t,n,r,a){if(a){if(typeof r=="function"){var s=r;r=function(){var u=ho(i);s.call(u)}}var i=sf(t,r,e,0,null,!1,!1,"",Ic);return e._reactRootContainer=i,e[Bt]=i.current,Kr(e.nodeType===8?e.parentNode:e),Pn(),i}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var u=ho(c);l.call(u)}}var c=cl(e,0,!1,null,null,!1,!1,"",Ic);return e._reactRootContainer=c,e[Bt]=c.current,Kr(e.nodeType===8?e.parentNode:e),Pn(function(){To(t,c,n,r)}),c}function Ao(e,t,n,r,a){var s=n._reactRootContainer;if(s){var i=s;if(typeof a=="function"){var l=a;a=function(){var c=ho(i);l.call(c)}}To(t,i,e,a)}else i=ph(n,t,e,a,r);return ho(i)}Lu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=br(t.pendingLanes);n!==0&&(Ti(t,n|1),Ge(t,ve()),!(te&6)&&(sr=ve()+500,pn()))}break;case 13:Pn(function(){var r=Dt(e,1);if(r!==null){var a=Oe();St(r,e,1,a)}}),ul(e,1)}};Ri=function(e){if(e.tag===13){var t=Dt(e,134217728);if(t!==null){var n=Oe();St(t,e,134217728,n)}ul(e,134217728)}};Mu=function(e){if(e.tag===13){var t=ln(e),n=Dt(e,t);if(n!==null){var r=Oe();St(n,e,t,r)}ul(e,t)}};Fu=function(){return ae};Ou=function(e,t){var n=ae;try{return ae=e,t()}finally{ae=n}};Ts=function(e,t,n){switch(t){case"input":if(Cs(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=Co(r);if(!a)throw Error(F(90));gu(r),Cs(r,a)}}}break;case"textarea":yu(e,n);break;case"select":t=n.value,t!=null&&Yn(e,!!n.multiple,t,!1)}};bu=ol;Nu=Pn;var hh={usingClientEntryPoint:!1,Events:[oa,Dn,Co,ku,Cu,ol]},Sr={findFiberByHostInstance:wn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},gh={bundleType:Sr.bundleType,version:Sr.version,rendererPackageName:Sr.rendererPackageName,rendererConfig:Sr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ht.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Iu(e),e===null?null:e.stateNode},findFiberByHostInstance:Sr.findFiberByHostInstance||mh,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Na=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Na.isDisabled&&Na.supportsFiber)try{wo=Na.inject(gh),zt=Na}catch{}}rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=hh;rt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!fl(t))throw Error(F(200));return fh(e,t,null,n)};rt.createRoot=function(e,t){if(!fl(e))throw Error(F(299));var n=!1,r="",a=lf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=cl(e,1,!1,null,null,n,!1,r,a),e[Bt]=t.current,Kr(e.nodeType===8?e.parentNode:e),new dl(t)};rt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(F(188)):(e=Object.keys(e).join(","),Error(F(268,e)));return e=Iu(t),e=e===null?null:e.stateNode,e};rt.flushSync=function(e){return Pn(e)};rt.hydrate=function(e,t,n){if(!_o(t))throw Error(F(200));return Ao(null,e,t,!0,n)};rt.hydrateRoot=function(e,t,n){if(!fl(e))throw Error(F(405));var r=n!=null&&n.hydratedSources||null,a=!1,s="",i=lf;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=sf(t,null,e,1,n??null,a,!1,s,i),e[Bt]=t.current,Kr(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new Ro(t)};rt.render=function(e,t,n){if(!_o(t))throw Error(F(200));return Ao(null,e,t,!1,n)};rt.unmountComponentAtNode=function(e){if(!_o(e))throw Error(F(40));return e._reactRootContainer?(Pn(function(){Ao(null,null,e,!1,function(){e._reactRootContainer=null,e[Bt]=null})}),!0):!1};rt.unstable_batchedUpdates=ol;rt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!_o(n))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return Ao(e,t,n,!1,r)};rt.version="18.3.1-next-f1338f8080-20240426";function cf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(cf)}catch(e){console.error(e)}}cf(),lu.exports=rt;var uf=lu.exports,df,Pc=uf;df=Pc.createRoot,Pc.hydrateRoot;/**
41
+ * react-router v7.13.1
42
+ *
43
+ * Copyright (c) Remix Software Inc.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE.md file in the root directory of this source tree.
47
+ *
48
+ * @license MIT
49
+ */var Tc="popstate";function Rc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function vh(e={}){function t(r,a){var u;let s=(u=a.state)==null?void 0:u.masked,{pathname:i,search:l,hash:c}=s||r.location;return ui("",{pathname:i,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",s?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:ta(a)}return xh(t,n,null,e)}function de(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ft(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function yh(){return Math.random().toString(36).substring(2,10)}function _c(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ui(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?ur(t):t,state:n,key:t&&t.key||r||yh(),unstable_mask:a}}function ta({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ur(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function xh(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,i=a.history,l="POP",c=null,u=p();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function p(){return(i.state||{idx:null}).idx}function f(){l="POP";let j=p(),h=j==null?null:j-u;u=j,c&&c({action:l,location:w.location,delta:h})}function v(j,h){l="PUSH";let m=Rc(j)?j:ui(w.location,j,h);u=p()+1;let g=_c(m,u),S=w.createHref(m.unstable_mask||m);try{i.pushState(g,"",S)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;a.location.assign(S)}s&&c&&c({action:l,location:w.location,delta:1})}function y(j,h){l="REPLACE";let m=Rc(j)?j:ui(w.location,j,h);u=p();let g=_c(m,u),S=w.createHref(m.unstable_mask||m);i.replaceState(g,"",S),s&&c&&c({action:l,location:w.location,delta:0})}function x(j){return wh(j)}let w={get action(){return l},get location(){return e(a,i)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Tc,f),c=j,()=>{a.removeEventListener(Tc,f),c=null}},createHref(j){return t(a,j)},createURL:x,encodeLocation(j){let h=x(j);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:v,replace:y,go(j){return i.go(j)}};return w}function wh(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),de(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ta(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function ff(e,t,n="/"){return Sh(e,t,n,!1)}function Sh(e,t,n,r){let a=typeof t=="string"?ur(t):t,s=Wt(a.pathname||"/",n);if(s==null)return null;let i=mf(e);jh(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=_h(s);l=Th(i[c],u,r)}return l}function mf(e,t=[],n=[],r="",a=!1){let s=(i,l,c=a,u)=>{let p={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&c)return;de(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let f=Pt([r,p.relativePath]),v=n.concat(p);i.children&&i.children.length>0&&(de(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),mf(i.children,t,v,f,c)),!(i.path==null&&!i.index)&&t.push({path:f,score:Ih(f,i.index),routesMeta:v})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))s(i,l);else for(let u of pf(i.path))s(i,l,!0,u)}),t}function pf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let i=pf(r.join("/")),l=[];return l.push(...i.map(c=>c===""?s:[s,c].join("/"))),a&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function jh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ph(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var kh=/^:[\w-]+$/,Ch=3,bh=2,Nh=1,Eh=10,zh=-2,Ac=e=>e==="*";function Ih(e,t){let n=e.split("/"),r=n.length;return n.some(Ac)&&(r+=zh),t&&(r+=bh),n.filter(a=>!Ac(a)).reduce((a,s)=>a+(kh.test(s)?Ch:s===""?Nh:Eh),r)}function Ph(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Th(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,p=s==="/"?t:t.slice(s.length)||"/",f=go({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},p),v=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=go({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},p)),!f)return null;Object.assign(a,f.params),i.push({params:a,pathname:Pt([s,f.pathname]),pathnameBase:Mh(Pt([s,f.pathnameBase])),route:v}),f.pathnameBase!=="/"&&(s=Pt([s,f.pathnameBase]))}return i}function go(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Rh(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let s=a[0],i=s.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((u,{paramName:p,isOptional:f},v)=>{if(p==="*"){let x=l[v]||"";i=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const y=l[v];return f&&!y?u[p]=void 0:u[p]=(y||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:i,pattern:e}}function Rh(e,t=!1,n=!0){ft(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,u,p)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let f=p.charAt(u+i.length);return f&&f!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function _h(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ft(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Wt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var Ah=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function $h(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?ur(e):e,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=$c(n.substring(1),"/"):s=$c(n,t)):s=t,{pathname:s,search:Fh(r),hash:Oh(a)}}function $c(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function ds(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Lh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ml(e){let t=Lh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function $o(e,t,n,r=!1){let a;typeof e=="string"?a=ur(e):(a={...e},de(!a.pathname||!a.pathname.includes("?"),ds("?","pathname","search",a)),de(!a.pathname||!a.pathname.includes("#"),ds("#","pathname","hash",a)),de(!a.search||!a.search.includes("#"),ds("#","search","hash",a)));let s=e===""||a.pathname==="",i=s?"/":a.pathname,l;if(i==null)l=n;else{let f=t.length-1;if(!r&&i.startsWith("..")){let v=i.split("/");for(;v[0]==="..";)v.shift(),f-=1;a.pathname=v.join("/")}l=f>=0?t[f]:"/"}let c=$h(a,l),u=i&&i!=="/"&&i.endsWith("/"),p=(s||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}var Pt=e=>e.join("/").replace(/\/\/+/g,"/"),Mh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Fh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Oh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Bh=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Dh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Uh(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var hf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function gf(e,t){let n=e;if(typeof n!="string"||!Ah.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(hf)try{let s=new URL(window.location.href),i=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Wt(i.pathname,t);i.origin===s.origin&&l!=null?n=l+i.search+i.hash:a=!0}catch{ft(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var vf=["POST","PUT","PATCH","DELETE"];new Set(vf);var Wh=["GET",...vf];new Set(Wh);var dr=d.createContext(null);dr.displayName="DataRouter";var Lo=d.createContext(null);Lo.displayName="DataRouterState";var Hh=d.createContext(!1),yf=d.createContext({isTransitioning:!1});yf.displayName="ViewTransition";var Vh=d.createContext(new Map);Vh.displayName="Fetchers";var Kh=d.createContext(null);Kh.displayName="Await";var ot=d.createContext(null);ot.displayName="Navigation";var ia=d.createContext(null);ia.displayName="Location";var kt=d.createContext({outlet:null,matches:[],isDataRoute:!1});kt.displayName="Route";var pl=d.createContext(null);pl.displayName="RouteError";var xf="REACT_ROUTER_ERROR",Gh="REDIRECT",Yh="ROUTE_ERROR_RESPONSE";function Qh(e){if(e.startsWith(`${xf}:${Gh}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Jh(e){if(e.startsWith(`${xf}:${Yh}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Bh(t.status,t.statusText,t.data)}catch{}}function Xh(e,{relative:t}={}){de(fr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(ot),{hash:a,pathname:s,search:i}=la(e,{relative:t}),l=s;return n!=="/"&&(l=s==="/"?n:Pt([n,s])),r.createHref({pathname:l,search:i,hash:a})}function fr(){return d.useContext(ia)!=null}function mt(){return de(fr(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(ia).location}var wf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Sf(e){d.useContext(ot).static||d.useLayoutEffect(e)}function Vt(){let{isDataRoute:e}=d.useContext(kt);return e?fg():qh()}function qh(){de(fr(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(dr),{basename:t,navigator:n}=d.useContext(ot),{matches:r}=d.useContext(kt),{pathname:a}=mt(),s=JSON.stringify(ml(r)),i=d.useRef(!1);return Sf(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(ft(i.current,wf),!i.current)return;if(typeof c=="number"){n.go(c);return}let p=$o(c,JSON.parse(s),a,u.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Pt([t,p.pathname])),(u.replace?n.replace:n.push)(p,u.state,u)},[t,n,s,a,e])}var Zh=d.createContext(null);function eg(e){let t=d.useContext(kt).outlet;return d.useMemo(()=>t&&d.createElement(Zh.Provider,{value:e},t),[t,e])}function la(e,{relative:t}={}){let{matches:n}=d.useContext(kt),{pathname:r}=mt(),a=JSON.stringify(ml(n));return d.useMemo(()=>$o(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function tg(e,t){return jf(e,t)}function jf(e,t,n){var j;de(fr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=d.useContext(ot),{matches:a}=d.useContext(kt),s=a[a.length-1],i=s?s.params:{},l=s?s.pathname:"/",c=s?s.pathnameBase:"/",u=s&&s.route;{let h=u&&u.path||"";Cf(l,!u||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${h}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
+
51
+ Please change the parent <Route path="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let p=mt(),f;if(t){let h=typeof t=="string"?ur(t):t;de(c==="/"||((j=h.pathname)==null?void 0:j.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${h.pathname}" was given in the \`location\` prop.`),f=h}else f=p;let v=f.pathname||"/",y=v;if(c!=="/"){let h=c.replace(/^\//,"").split("/");y="/"+v.replace(/^\//,"").split("/").slice(h.length).join("/")}let x=ff(e,{pathname:y});ft(u||x!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),ft(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=sg(x&&x.map(h=>Object.assign({},h,{params:Object.assign({},i,h.params),pathname:Pt([c,r.encodeLocation?r.encodeLocation(h.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:Pt([c,r.encodeLocation?r.encodeLocation(h.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),a,n);return t&&w?d.createElement(ia.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...f},navigationType:"POP"}},w):w}function ng(){let e=dg(),t=Dh(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:s},"ErrorBoundary")," or"," ",d.createElement("code",{style:s},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:a},n):null,i)}var rg=d.createElement(ng,null),kf=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Jh(e.digest);n&&(e=n)}let t=e!==void 0?d.createElement(kt.Provider,{value:this.props.routeContext},d.createElement(pl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?d.createElement(ag,{error:e},t):t}};kf.contextType=Hh;var fs=new WeakMap;function ag({children:e,error:t}){let{basename:n}=d.useContext(ot);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Qh(t.digest);if(r){let a=fs.get(t);if(a)throw a;let s=gf(r.location,n);if(hf&&!fs.get(t))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw fs.set(t,i),i}return d.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return e}function og({routeContext:e,match:t,children:n}){let r=d.useContext(dr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(kt.Provider,{value:e},n)}function sg(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,s=r==null?void 0:r.errors;if(s!=null){let p=a.findIndex(f=>f.route.id&&(s==null?void 0:s[f.route.id])!==void 0);de(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,p+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let p=0;p<a.length;p++){let f=a[p];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=p),f.route.id){let{loaderData:v,errors:y}=r,x=f.route.loader&&!v.hasOwnProperty(f.route.id)&&(!y||y[f.route.id]===void 0);if(f.route.lazy||x){n.isStatic&&(i=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,u=r&&c?(p,f)=>{var v,y;c(p,{location:r.location,params:((y=(v=r.matches)==null?void 0:v[0])==null?void 0:y.params)??{},unstable_pattern:Uh(r.matches),errorInfo:f})}:void 0;return a.reduceRight((p,f,v)=>{let y,x=!1,w=null,j=null;r&&(y=s&&f.route.id?s[f.route.id]:void 0,w=f.route.errorElement||rg,i&&(l<0&&v===0?(Cf("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,j=null):l===v&&(x=!0,j=f.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,v+1)),m=()=>{let g;return y?g=w:x?g=j:f.route.Component?g=d.createElement(f.route.Component,null):f.route.element?g=f.route.element:g=p,d.createElement(og,{match:f,routeContext:{outlet:p,matches:h,isDataRoute:r!=null},children:g})};return r&&(f.route.ErrorBoundary||f.route.errorElement||v===0)?d.createElement(kf,{location:r.location,revalidation:r.revalidation,component:w,error:y,children:m(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):m()},null)}function hl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ig(e){let t=d.useContext(dr);return de(t,hl(e)),t}function lg(e){let t=d.useContext(Lo);return de(t,hl(e)),t}function cg(e){let t=d.useContext(kt);return de(t,hl(e)),t}function gl(e){let t=cg(e),n=t.matches[t.matches.length-1];return de(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ug(){return gl("useRouteId")}function dg(){var r;let e=d.useContext(pl),t=lg("useRouteError"),n=gl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function fg(){let{router:e}=ig("useNavigate"),t=gl("useNavigate"),n=d.useRef(!1);return Sf(()=>{n.current=!0}),d.useCallback(async(a,s={})=>{ft(n.current,wf),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...s}))},[e,t])}var Lc={};function Cf(e,t,n){!t&&!Lc[e]&&(Lc[e]=!0,ft(!1,n))}d.memo(mg);function mg({routes:e,future:t,state:n,isStatic:r,onError:a}){return jf(e,void 0,{state:n,isStatic:r,onError:a})}function Jt({to:e,replace:t,state:n,relative:r}){de(fr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=d.useContext(ot);ft(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=d.useContext(kt),{pathname:i}=mt(),l=Vt(),c=$o(e,ml(s),i,r==="path"),u=JSON.stringify(c);return d.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:r})},[l,u,r,t,n]),null}function pg(e){return eg(e.context)}function Ce(e){de(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function hg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:s=!1,unstable_useTransitions:i}){de(!fr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=d.useMemo(()=>({basename:l,navigator:a,static:s,unstable_useTransitions:i,future:{}}),[l,a,s,i]);typeof n=="string"&&(n=ur(n));let{pathname:u="/",search:p="",hash:f="",state:v=null,key:y="default",unstable_mask:x}=n,w=d.useMemo(()=>{let j=Wt(u,l);return j==null?null:{location:{pathname:j,search:p,hash:f,state:v,key:y,unstable_mask:x},navigationType:r}},[l,u,p,f,v,y,r,x]);return ft(w!=null,`<Router basename="${l}"> is not able to match the URL "${u}${p}${f}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:d.createElement(ot.Provider,{value:c},d.createElement(ia.Provider,{children:t,value:w}))}function gg({children:e,location:t}){return tg(di(e),t)}function di(e,t=[]){let n=[];return d.Children.forEach(e,(r,a)=>{if(!d.isValidElement(r))return;let s=[...t,a];if(r.type===d.Fragment){n.push.apply(n,di(r.props.children,s));return}de(r.type===Ce,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),de(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=di(r.props.children,s)),n.push(i)}),n}var Ua="get",Wa="application/x-www-form-urlencoded";function Mo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function vg(e){return Mo(e)&&e.tagName.toLowerCase()==="button"}function yg(e){return Mo(e)&&e.tagName.toLowerCase()==="form"}function xg(e){return Mo(e)&&e.tagName.toLowerCase()==="input"}function wg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Sg(e,t){return e.button===0&&(!t||t==="_self")&&!wg(e)}function fi(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function jg(e,t){let n=fi(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(s=>{n.append(a,s)})}),n}var Ea=null;function kg(){if(Ea===null)try{new FormData(document.createElement("form"),0),Ea=!1}catch{Ea=!0}return Ea}var Cg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ms(e){return e!=null&&!Cg.has(e)?(ft(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Wa}"`),null):e}function bg(e,t){let n,r,a,s,i;if(yg(e)){let l=e.getAttribute("action");r=l?Wt(l,t):null,n=e.getAttribute("method")||Ua,a=ms(e.getAttribute("enctype"))||Wa,s=new FormData(e)}else if(vg(e)||xg(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?Wt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Ua,a=ms(e.getAttribute("formenctype"))||ms(l.getAttribute("enctype"))||Wa,s=new FormData(l,e),!kg()){let{name:u,type:p,value:f}=e;if(p==="image"){let v=u?`${u}.`:"";s.append(`${v}x`,"0"),s.append(`${v}y`,"0")}else u&&s.append(u,f)}}else{if(Mo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Ua,r=null,a=Wa,i=e}return s&&a==="text/plain"&&(i=s,s=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:s,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function vl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ng(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Wt(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${r}`,a}async function Eg(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function zg(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Ig(e,t,n){let r=await Promise.all(e.map(async a=>{let s=t.routes[a.route.id];if(s){let i=await Eg(s,n);return i.links?i.links():[]}return[]}));return _g(r.flat(1).filter(zg).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Mc(e,t,n,r,a,s){let i=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var p;return n[u].pathname!==c.pathname||((p=n[u].route.path)==null?void 0:p.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return s==="assets"?t.filter((c,u)=>i(c,u)||l(c,u)):s==="data"?t.filter((c,u)=>{var f;let p=r.routes[c.route.id];if(!p||!p.hasLoader)return!1;if(i(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let v=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((f=n[0])==null?void 0:f.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function Pg(e,t,{includeHydrateFallback:n}={}){return Tg(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let s=[a.module];return a.clientActionModule&&(s=s.concat(a.clientActionModule)),a.clientLoaderModule&&(s=s.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(s=s.concat(a.hydrateFallbackModule)),a.imports&&(s=s.concat(a.imports)),s}).flat(1))}function Tg(e){return[...new Set(e)]}function Rg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function _g(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let s=JSON.stringify(Rg(a));return n.has(s)||(n.add(s),r.push({key:s,link:a})),r},[])}function bf(){let e=d.useContext(dr);return vl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Ag(){let e=d.useContext(Lo);return vl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var yl=d.createContext(void 0);yl.displayName="FrameworkContext";function Nf(){let e=d.useContext(yl);return vl(e,"You must render this element inside a <HydratedRouter> element"),e}function $g(e,t){let n=d.useContext(yl),[r,a]=d.useState(!1),[s,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:p,onTouchStart:f}=t,v=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let w=h=>{h.forEach(m=>{i(m.isIntersecting)})},j=new IntersectionObserver(w,{threshold:.5});return v.current&&j.observe(v.current),()=>{j.disconnect()}}},[e]),d.useEffect(()=>{if(r){let w=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(w)}}},[r]);let y=()=>{a(!0)},x=()=>{a(!1),i(!1)};return n?e!=="intent"?[s,v,{}]:[s,v,{onFocus:jr(l,y),onBlur:jr(c,x),onMouseEnter:jr(u,y),onMouseLeave:jr(p,x),onTouchStart:jr(f,y)}]:[!1,v,{}]}function jr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Lg({page:e,...t}){let{router:n}=bf(),r=d.useMemo(()=>ff(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(Fg,{page:e,matches:r,...t}):null}function Mg(e){let{manifest:t,routeModules:n}=Nf(),[r,a]=d.useState([]);return d.useEffect(()=>{let s=!1;return Ig(e,t,n).then(i=>{s||a(i)}),()=>{s=!0}},[e,t,n]),r}function Fg({page:e,matches:t,...n}){let r=mt(),{future:a,manifest:s,routeModules:i}=Nf(),{basename:l}=bf(),{loaderData:c,matches:u}=Ag(),p=d.useMemo(()=>Mc(e,t,u,s,r,"data"),[e,t,u,s,r]),f=d.useMemo(()=>Mc(e,t,u,s,r,"assets"),[e,t,u,s,r]),v=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let w=new Set,j=!1;if(t.forEach(m=>{var S;let g=s.routes[m.route.id];!g||!g.hasLoader||(!p.some(E=>E.route.id===m.route.id)&&m.route.id in c&&((S=i[m.route.id])!=null&&S.shouldRevalidate)||g.hasClientLoader?j=!0:w.add(m.route.id))}),w.size===0)return[];let h=Ng(e,l,a.unstable_trailingSlashAwareDataRequests,"data");return j&&w.size>0&&h.searchParams.set("_routes",t.filter(m=>w.has(m.route.id)).map(m=>m.route.id).join(",")),[h.pathname+h.search]},[l,a.unstable_trailingSlashAwareDataRequests,c,r,s,p,t,e,i]),y=d.useMemo(()=>Pg(f,s),[f,s]),x=Mg(f);return d.createElement(d.Fragment,null,v.map(w=>d.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...n})),y.map(w=>d.createElement("link",{key:w,rel:"modulepreload",href:w,...n})),x.map(({key:w,link:j})=>d.createElement("link",{key:w,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function Og(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Bg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Bg&&(window.__reactRouterVersion="7.13.1")}catch{}function Dg({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=d.useRef();a.current==null&&(a.current=vh({window:r,v5Compat:!0}));let s=a.current,[i,l]=d.useState({action:s.action,location:s.location}),c=d.useCallback(u=>{n===!1?l(u):d.startTransition(()=>l(u))},[n]);return d.useLayoutEffect(()=>s.listen(c),[s,c]),d.createElement(hg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:s,unstable_useTransitions:n})}var Ef=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ze=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:s,replace:i,unstable_mask:l,state:c,target:u,to:p,preventScrollReset:f,viewTransition:v,unstable_defaultShouldRevalidate:y,...x},w){let{basename:j,navigator:h,unstable_useTransitions:m}=d.useContext(ot),g=typeof p=="string"&&Ef.test(p),S=gf(p,j);p=S.to;let E=Xh(p,{relative:a}),I=mt(),k=null;if(l){let D=$o(l,[],I.unstable_mask?I.unstable_mask.pathname:"/",!0);j!=="/"&&(D.pathname=D.pathname==="/"?j:Pt([j,D.pathname])),k=h.createHref(D)}let[N,C,P]=$g(r,x),H=Hg(p,{replace:i,unstable_mask:l,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:v,unstable_defaultShouldRevalidate:y,unstable_useTransitions:m});function W(D){t&&t(D),D.defaultPrevented||H(D)}let B=!(S.isExternal||s),_=d.createElement("a",{...x,...P,href:(B?k:void 0)||S.absoluteURL||E,onClick:B?W:t,ref:Og(w,C),target:u,"data-discover":!g&&n==="render"?"true":void 0});return N&&!g?d.createElement(d.Fragment,null,_,d.createElement(Lg,{page:E})):_});Ze.displayName="Link";var xl=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:s,to:i,viewTransition:l,children:c,...u},p){let f=la(i,{relative:u.relative}),v=mt(),y=d.useContext(Lo),{navigator:x,basename:w}=d.useContext(ot),j=y!=null&&Qg(f)&&l===!0,h=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,m=v.pathname,g=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;n||(m=m.toLowerCase(),g=g?g.toLowerCase():null,h=h.toLowerCase()),g&&w&&(g=Wt(g,w)||g);const S=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let E=m===h||!a&&m.startsWith(h)&&m.charAt(S)==="/",I=g!=null&&(g===h||!a&&g.startsWith(h)&&g.charAt(h.length)==="/"),k={isActive:E,isPending:I,isTransitioning:j},N=E?t:void 0,C;typeof r=="function"?C=r(k):C=[r,E?"active":null,I?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let P=typeof s=="function"?s(k):s;return d.createElement(Ze,{...u,"aria-current":N,className:C,ref:p,style:P,to:i,viewTransition:l},typeof c=="function"?c(k):c)});xl.displayName="NavLink";var Ug=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:s,method:i=Ua,action:l,onSubmit:c,relative:u,preventScrollReset:p,viewTransition:f,unstable_defaultShouldRevalidate:v,...y},x)=>{let{unstable_useTransitions:w}=d.useContext(ot),j=Gg(),h=Yg(l,{relative:u}),m=i.toLowerCase()==="get"?"get":"post",g=typeof l=="string"&&Ef.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let I=E.nativeEvent.submitter,k=(I==null?void 0:I.getAttribute("formmethod"))||i,N=()=>j(I||E.currentTarget,{fetcherKey:t,method:k,navigate:n,replace:a,state:s,relative:u,preventScrollReset:p,viewTransition:f,unstable_defaultShouldRevalidate:v});w&&n!==!1?d.startTransition(()=>N()):N()};return d.createElement("form",{ref:x,method:m,action:h,onSubmit:r?c:S,...y,"data-discover":!g&&e==="render"?"true":void 0})});Ug.displayName="Form";function Wg(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zf(e){let t=d.useContext(dr);return de(t,Wg(e)),t}function Hg(e,{target:t,replace:n,unstable_mask:r,state:a,preventScrollReset:s,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let p=Vt(),f=mt(),v=la(e,{relative:i});return d.useCallback(y=>{if(Sg(y,t)){y.preventDefault();let x=n!==void 0?n:ta(f)===ta(v),w=()=>p(e,{replace:x,unstable_mask:r,state:a,preventScrollReset:s,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});u?d.startTransition(()=>w()):w()}},[f,p,v,n,r,a,t,e,s,i,l,c,u])}function If(e){ft(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=d.useRef(fi(e)),n=d.useRef(!1),r=mt(),a=d.useMemo(()=>jg(r.search,n.current?null:t.current),[r.search]),s=Vt(),i=d.useCallback((l,c)=>{const u=fi(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,s("?"+u,c)},[s,a]);return[a,i]}var Vg=0,Kg=()=>`__${String(++Vg)}__`;function Gg(){let{router:e}=zf("useSubmit"),{basename:t}=d.useContext(ot),n=ug(),r=e.fetch,a=e.navigate;return d.useCallback(async(s,i={})=>{let{action:l,method:c,encType:u,formData:p,body:f}=bg(s,t);if(i.navigate===!1){let v=i.fetcherKey||Kg();await r(v,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||c,formEncType:i.encType||u,flushSync:i.flushSync})}else await a(i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||c,formEncType:i.encType||u,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,a,t,n])}function Yg(e,{relative:t}={}){let{basename:n}=d.useContext(ot),r=d.useContext(kt);de(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),s={...la(e||".",{relative:t})},i=mt();if(e==null){s.search=i.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(p=>p==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let p=l.toString();s.search=p?`?${p}`:""}}return(!e||e===".")&&a.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Pt([n,s.pathname])),ta(s)}function Qg(e,{relative:t}={}){let n=d.useContext(yf);de(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=zf("useViewTransitionState"),a=la(e,{relative:t});if(!n.isTransitioning)return!1;let s=Wt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Wt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return go(a.pathname,i)!=null||go(a.pathname,s)!=null}class Pf extends Error{constructor(n){super("different_account");Fo(this,"summary");this.name="DifferentAccountError",this.summary=n}}class Jg{constructor(){Fo(this,"apiKey",null)}setApiKey(t){this.apiKey=t}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(t,n){return globalThis.fetch(t,{...n,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n==null?void 0:n.headers}})}async login(t,n={}){const r=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":t,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:n.confirmWipe===!0})});if(r.status===409){const s=await r.json().catch(()=>({}));if(s!=null&&s.wouldWipe)throw new Pf(s.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const s=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(s.error||`Login failed: ${r.status}`)}return(await r.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const t=await this.fetch("/api/groups");if(!t.ok)throw new Error(`Failed to fetch groups: ${t.status}`);const n=await t.json();return n.groups??n}async listProfiles(){const t=await this.fetch("/api/profiles");if(!t.ok)throw new Error(`Failed to fetch profiles: ${t.status}`);return(await t.json()).profiles}async getProfile(t){const n=await this.fetch(`/api/profiles/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch profile: ${n.status}`);return n.json()}async attest(t){const n=await this.fetch("/api/as/attest",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Attest failed: ${n.status}`)}return n.json()}async getPending(t){const n=await this.fetch(`/api/attestations/pending?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch pending: ${n.status}`);const r=await n.json();return r.pending??r}async getMyAttestations(t){const n=t?`?status=${encodeURIComponent(t)}`:"",r=await this.fetch(`/api/attestations/mine${n}`);if(!r.ok)throw new Error(`Failed to fetch attestations: ${r.status}`);return((await r.json()).attestations??[]).map(s=>{var i,l;return{authorization_id:s.authorization_id,profile_id:s.profileId,path:s.path,title:s.title??null,sp_status:s.status??null,frame:s.bounds??s.frame??{},required_domains:s.requiredDomains??[],attested_domains:s.attestedDomains??[],missing_domains:(s.requiredDomains??[]).filter(c=>!(s.attestedDomains??[]).includes(c)),deferred_commitment_domains:s.deferredCommitmentDomains??[],approvers_frozen:s.approversFrozen??[],above_cap:s.aboveCap??!1,created_at:s.createdAt?new Date(s.createdAt*1e3).toISOString():"",earliest_expiry:(i=s.attestations)!=null&&i.length?new Date(Math.min(...s.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=s.attestations)!=null&&l.length?Math.max(0,Math.min(...s.attestations.map(c=>c.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getMyReceipts(t){const n=new URLSearchParams;t!=null&&t.date&&n.set("date",t.date),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).receipts??[]}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(a.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const s=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`Create group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const s=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`Join group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:a.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async getCredential(t){const n=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to check credential: ${n.status}`);return n.json()}async setCredential(t,n){const r=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to save credential: ${r.status}`)}async testCredential(t){const n=await this.fetch(`/vault/test/${encodeURIComponent(t)}`,{method:"POST"});if(!n.ok)throw new Error(`Test failed: ${n.status}`);return n.json()}async aiAssist(t){const n=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error,disclaimer:"AI surfaces reality. You supply intent."}}async aiIntentReview(t){const n=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error}}async aiTest(t){const n=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`AI test failed: ${n.status}`);return n.json()}async getMcpHealth(){const t=await this.fetch("/mcp/health");if(!t.ok)throw new Error(`MCP server unreachable: ${t.status}`);return t.json()}async getMcpIntegrations(){const t=await this.fetch("/mcp/integrations");if(!t.ok)throw new Error(`Failed to fetch integrations: ${t.status}`);return t.json()}async getOAuthHealth(t){try{const n=await this.fetch(`/auth/oauth/${encodeURIComponent(t)}/health`);return n.ok?await n.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const t=await this.fetch("/mcp/integrations/manifests");if(!t.ok)throw new Error(`Failed to fetch manifests: ${t.status}`);return t.json()}async discoverScopeField(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/discover/${encodeURIComponent(n)}`);if(!r.ok){const a=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(a.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async getTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`);if(r.status===404||!r.ok)return null;const a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const s=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(s.error||`setTeamProfileConfig failed: ${a.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(a.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?(await r.json()).approvers??[]:[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(a.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getProposals(t){const n=await this.fetch(`/api/proposals?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals??[]}async resolveProposal(t,n,r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!a.ok){const s=await a.json().catch(()=>({error:"Failed"}));throw new Error(s.error||`Failed: ${a.status}`)}return a.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(a.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(a=>{var l,c;const s=a.owner??{userId:""};return{authorization_id:a.authorization_id??a.authorizationId,profile_id:a.profileId??a.profile_id,path:a.path??"",title:a.title??null,sp_status:a.status??a.sp_status??null,frame:a.bounds??a.frame??{},required_domains:a.requiredDomains??a.required_domains??[],attested_domains:a.attestedDomains??a.attested_domains??[],missing_domains:(a.requiredDomains??a.required_domains??[]).filter(u=>!(a.attestedDomains??a.attested_domains??[]).includes(u)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(l=a.attestations)!=null&&l.length?new Date(Math.min(...a.attestations.map(u=>u.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.attestations)!=null&&c.length?Math.max(0,Math.min(...a.attestations.map(u=>u.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:s}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const s=await a.json();return{receipts:s.receipts??[],nextBefore:s.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const a=r.toString(),s=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!s.ok)throw new Error(`Failed to fetch team receipts: ${s.status}`);const i=await s.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=t.domain||"owner",s=await this.getProposals(a);let i=[];if(r==="all"){const l=[],c=new Date;for(let p=0;p<n;p++){const f=new Date(c);f.setUTCDate(c.getUTCDate()-p),l.push(f.toISOString().slice(0,10))}i=(await Promise.all(l.map(p=>this.getMyReceipts({date:p,profile:t.profile})))).flat()}return{proposals:s,receipts:i}}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Save failed"}));throw new Error(a.error||`Save failed: ${r.status}`)}}}const M=new Jg,Tf=d.createContext(null);function Xg({children:e}){const[t,n]=d.useState(null),[r,a]=d.useState("personal"),[s,i]=d.useState(null),[l,c]=d.useState(""),[u,p]=d.useState(null),[f,v]=d.useState(null),[y,x]=d.useState(!1),[w,j]=d.useState(""),h=d.useRef(!1),m=d.useRef(null),g=d.useCallback(async()=>{if(h.current)try{const N=await M.getMyTeam();if(N){const{group:C,membership:P}=N;p(C),v(P),a("team"),i(C);const H=m.current??P.domains[0]??"owner";c(H)}else p(null),v(null),a("personal")}catch{}},[]);d.useEffect(()=>{const N=()=>{document.visibilityState==="visible"&&g()};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[g]);const S=d.useCallback(async(N,C={})=>{x(!0),j("");try{M.setApiKey(N),h.current=!0;const P=await M.login(N,C);n(P),m.current=P.id;const H=await M.getGroups(),W=H.find(B=>B.isPersonal)??H[0]??null;i(W),c("owner"),await g()}catch(P){throw M.clearApiKey(),h.current=!1,j(P instanceof Error?P.message:"Login failed"),P}finally{x(!1)}},[g]),E=d.useCallback(async()=>{await M.logout(),M.clearApiKey(),h.current=!1,m.current=null,n(null),i(null),c(""),p(null),v(null),a("personal"),j("")},[]),I=d.useCallback(()=>j(""),[]),k=d.useCallback((N,C)=>{i(N),c(C)},[]);return o.jsx(Tf.Provider,{value:{user:t,mode:r,group:s,domain:l,groupId:(s==null?void 0:s.id)??null,activeTeam:u,activeMembership:f,isLoading:y,error:w,login:S,logout:E,clearError:I,activeGroup:s,activeDomain:l,groups:s?[s]:[],setActiveContext:k,refreshGroups:g},children:e})}function ze(){const e=d.useContext(Tf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Rf=d.createContext(null);function qg({children:e}){const{user:t}=ze(),n=d.useRef(null),[r,a]=d.useState(!1),s=d.useRef(new Map),i=d.useCallback((l,c)=>{const u=s.current;return u.has(l)||u.set(l,new Set),u.get(l).add(c),()=>{var p;(p=u.get(l))==null||p.delete(c)}},[]);return d.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,a(!1));return}if(n.current)return;const l=M.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>a(!0),c.onerror=()=>a(!1);const u=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected"];for(const p of u)c.addEventListener(p,f=>{let v;try{v=JSON.parse(f.data)}catch{v=null}const y=s.current.get(p);if(y)for(const x of y)try{x(v)}catch(w){console.error(`[EventSource] handler for "${p}" threw:`,w)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),o.jsx(Rf.Provider,{value:{connected:r,addListener:i},children:e})}function fe(e,t){const n=d.useContext(Rf);if(!n)return;const{addListener:r}=n;d.useEffect(()=>r(e,t),[e,t,r])}const Mr="suveren-theme",Fc="hap-theme";function za(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Fc);t!==null&&localStorage.getItem(Mr)===null&&localStorage.setItem(Mr,t),t!==null&&localStorage.removeItem(Fc)})();function _f(){const[e,t]=d.useState(()=>{const s=localStorage.getItem(Mr);return s==="light"||s==="dark"?s:"system"}),[n,r]=d.useState(()=>za(e));d.useEffect(()=>{const s=document.documentElement,i=za(e);s.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Mr):localStorage.setItem(Mr,e),r(za(e))},[e]),d.useEffect(()=>{if(e!=="system")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(za("system"));return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e]);const a=d.useCallback(()=>{t(s=>s==="system"?"light":s==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const Zg=5*60*1e3,ev=2e3;function Af(){const[e,t]=d.useState(!1),[n,r]=d.useState("docker"),[a,s]=d.useState(""),[i,l]=d.useState(null),[c,u]=d.useState(!1),[p,f]=d.useState(!1),[v,y]=d.useState(!1),x=d.useRef(null);return d.useEffect(()=>{let w=!1;const j=(g=!1)=>{fetch(g?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{w||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(s(S.version),x.current===null?x.current=S.version:S.version!==x.current&&S.version!=="dev"&&u(!0)))}).catch(()=>{})};j(!0);const h=setInterval(()=>j(!1),v?ev:Zg),m=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",m),window.addEventListener("focus",m),()=>{w=!0,clearInterval(h),document.removeEventListener("visibilitychange",m),window.removeEventListener("focus",m)}},[v]),{updateAvailable:e&&!p,installMethod:n,version:a,latestVersion:i,serverRestarted:c,startFastPolling:()=>y(!0),dismiss:()=>f(!0)}}function tv(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Oc={system:"◑",light:"☀",dark:"☾"};function nv(){const{mode:e,group:t,domain:n}=ze();return e==="personal"?o.jsx("span",{children:"personal"}):t?o.jsxs("span",{children:[t.name," / ",n]}):o.jsx("span",{children:n})}function wl({onMenuToggle:e}){const{user:t,logout:n}=ze(),{theme:r,toggle:a}=_f(),{version:s}=Af(),i=tv(s);return o.jsx("nav",{className:"top-nav",children:o.jsxs("div",{className:"top-nav-inner",children:[o.jsxs("div",{className:"logo-group",children:[o.jsx("span",{className:"logo",children:"Suveren"}),o.jsx("span",{className:"version-badge",children:"Local Gateway"})]}),o.jsx("div",{className:"nav-spacer"}),o.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"user-chip",children:[o.jsx("strong",{children:t.name}),o.jsx("span",{className:"dot"}),o.jsx(nv,{})]}),o.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Oc[r]}),o.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):o.jsxs(o.Fragment,{children:[i&&o.jsxs("span",{title:"Running gateway version",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:["v",i]}),o.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Oc[r]})]})}),t&&e&&o.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Nt(e,t){var n;if((n=t==null?void 0:t.revokedSet)!=null&&n.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function $f(e,t){const n={active:[],pending:[],expired:[],revoked:[]};for(const r of e)n[Nt(r,t)].push(r);return n}function Mt(e,t,n){const r=d.useRef(e);r.current=e,d.useEffect(()=>{let a=null;const s=()=>typeof document>"u"?!0:document.visibilityState==="visible",i=()=>{s()&&r.current()},l=()=>{a===null&&(a=setInterval(i,t))},c=()=>{a!==null&&(clearInterval(a),a=null)},u=()=>{s()?(r.current(),l()):c()};return s()&&(r.current(),l()),document.addEventListener("visibilitychange",u),()=>{c(),document.removeEventListener("visibilitychange",u)}},[t,n])}const Lf=d.createContext(null),rv=3e4;function av({children:e}){const[t,n]=d.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0}),r=d.useRef(null),a=d.useCallback(async()=>{let c=!1;const[u,p]=await Promise.all([M.getIntegrationManifests().catch(()=>(c=!0,{manifests:[]})),M.getMcpHealth().catch(()=>null)]);n(f=>({manifests:u.manifests,integrations:(p==null?void 0:p.integrations)??f.integrations,activeSessions:(p==null?void 0:p.activeSessions)??f.activeSessions,mcpServerUp:!!p,manifestsError:c,fetchCount:f.fetchCount+1}))},[]);fe("integration-changed",a),Mt(a,3e5);const s=d.useMemo(()=>{const c=new Map(t.integrations.map(v=>[v.id,v])),u=Date.now(),p=t.fetchCount>0&&t.manifests.some(v=>{const y=c.get(v.id);return y&&!y.running});p&&r.current===null?r.current=u:p||(r.current=null);const f=r.current!==null&&u-r.current<rv;return t.manifests.map(v=>{const y=c.get(v.id);let x;return t.fetchCount===0?x="loading":y!=null&&y.running?x="running":y!=null&&y.error?x="error":y&&f?x="starting":x="not-running",{id:v.id,manifest:v,integration:y,state:x}})},[t]),i=d.useMemo(()=>s.filter(c=>c.state==="not-running"||c.state==="error").length,[s]),l={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:s,attentionCount:i,activeSessions:t.activeSessions,refresh:a};return o.jsx(Lf.Provider,{value:l,children:e})}function Sl(){const e=d.useContext(Lf);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const ov=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Authorizations",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function sv(){const{activeDomain:e}=ze(),[t,n]=d.useState({}),r=d.useCallback(async()=>{try{const[a,s,i,l,c]=await Promise.all([M.getCredential("ai-config").catch(()=>null),M.getMyAttestations().catch(()=>null),M.getProposals(e||"owner").catch(()=>null),M.getProposalsForApprover().catch(()=>null),M.getAgentContext().catch(()=>"")]),u={};if(a&&!a.configured&&(u.assistant=1),s){const y=$f(s).expired.length;y>0&&(u.authorizations=y)}const p=(i==null?void 0:i.length)??0,f=(l==null?void 0:l.length)??0,v=p+f;v>0&&(u.proposals=v),(!c||!c.trim())&&(u.brief=1),n(u)}catch{}},[e]);return fe("attestation-changed",r),fe("proposal-added",r),fe("proposal-resolved",r),fe("proposal-approved",r),fe("proposal-rejected",r),fe("team-membership-changed",r),Mt(r,3e5,e),t}const iv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},lv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function cv(){const{mode:e,group:t,domain:n,activeTeam:r}=ze(),a=sv(),{attentionCount:s}=Sl(),i={...a};s>0&&(i.integrations=s);const l=ov.filter(v=>!v.teamOnly||e==="team"),c=d.useRef(null),[u,p]=d.useState(null),f=mt();return d.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?p(`You are now acting in team context — ${r.name}`):e==="personal"&&p("You have left the team — back to personal context"),c.current=e)},[e,r]),d.useEffect(()=>{p(null)},[f.pathname]),o.jsxs("div",{className:"sidebar",children:[o.jsx("ul",{className:"sidebar-nav",children:l.map(v=>{const y=v.statusKey?i[v.statusKey]:0;return o.jsx("li",{children:o.jsxs(xl,{to:v.to,end:v.to==="/",className:({isActive:x})=>`sidebar-item${x?" active":""}`,children:[o.jsx("span",{className:"icon",children:v.icon}),v.label,y?o.jsx("span",{style:iv,children:y}):null]})},v.to)})}),o.jsxs("div",{className:"sidebar-context",children:[o.jsx("div",{className:"ctx-label",children:"Active context"}),o.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),u&&o.jsx("div",{style:lv,role:"status","aria-live":"polite",children:u})]})}const ps="suveren:updatedTo";function uv(e){return e==="npm"?"suveren-gateway stop; npm install -g @suveren/gateway@latest && suveren-gateway start --detach":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}function dv(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const n of e)if(!n.closest(".update-overlay"))return!0;const t=document.activeElement;if(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)){const n=t.value;if(n&&n.trim())return!0}return!1}function fv(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:s,dismiss:i}=Af(),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[f,v]=d.useState(()=>{try{const g=sessionStorage.getItem(ps);if(g)return sessionStorage.removeItem(ps),g}catch{}return null}),y=uv(t),x=d.useRef(null),w=g=>{try{sessionStorage.setItem(ps,g||r||"✓")}catch{}window.location.reload()};d.useEffect(()=>{if(!f)return;const g=setTimeout(()=>v(null),6e3);return()=>clearTimeout(g)},[f]),d.useEffect(()=>{if(!l||!a)return;const g=()=>dv()?!1:(w(n),!0);if(g())return;const S=setInterval(g,1500);return()=>clearInterval(S)},[l,a,n]),d.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const j=e&&!l&&!f||!!f&&!l;d.useEffect(()=>{if(!j){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const g=()=>{var I;const E=((I=x.current)==null?void 0:I.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${E}px`)};g();const S=new ResizeObserver(g);return x.current&&S.observe(x.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const h=()=>{c(!0),s()},m=async()=>{try{await navigator.clipboard.writeText(y),p(!0),setTimeout(()=>p(!1),1800)}catch{}};return o.jsxs(o.Fragment,{children:[f&&!l&&o.jsx("div",{ref:x,className:"update-banner is-live",role:"status","aria-live":"polite",children:o.jsxs("div",{className:"update-banner-row",children:[o.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",f&&f!=="✓"?` — ${f} is live`:" — now live","."]}),o.jsx("button",{className:"update-banner-x",onClick:()=>v(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!f&&o.jsx("div",{ref:x,className:"update-banner",role:"status","aria-live":"polite",children:o.jsxs("div",{className:"update-banner-row",children:[o.jsx("span",{className:"update-banner-text",children:"Update available."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[o.jsx("button",{className:"btn btn-sm btn-secondary",onClick:h,children:"Update"}),o.jsx("button",{className:"update-banner-x",onClick:i,"aria-label":"Dismiss",children:"×"})]})]})}),l&&o.jsx("div",{className:"update-overlay",children:o.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[o.jsx("div",{className:"update-spinner"}),o.jsxs("h2",{children:["Finishing the update","…"]}),o.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",o.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),o.jsxs("div",{className:"update-cmd-row",children:[o.jsx("code",{className:"update-cmd",children:y}),o.jsx("button",{className:"btn btn-sm btn-primary",onClick:m,children:u?"Copied":"Copy"})]}),o.jsxs("div",{className:"update-status",children:[o.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),o.jsxs("div",{className:"update-overlay-actions",children:[o.jsx("button",{className:"btn btn-primary",onClick:()=>w(n),children:"Reload now"}),o.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const mv={system:"◑",light:"☀",dark:"☾"},pv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function hv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:s}=ze(),{theme:i,toggle:l}=_f(),c=mt();return d.useEffect(()=>{t()},[c.pathname]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),o.jsxs("div",{className:"mobile-menu-panel",children:[n&&o.jsxs("div",{className:"mobile-menu-header",children:[o.jsx("strong",{children:n.name}),o.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${a}`:a||"personal"})]}),o.jsx("nav",{className:"mobile-menu-nav",children:pv.map(u=>o.jsxs(xl,{to:u.to,end:u.to==="/",className:({isActive:p})=>`mobile-menu-item${p?" active":""}`,onClick:t,children:[o.jsx("span",{className:"icon",children:u.icon}),u.label]},u.to))}),o.jsxs("div",{className:"mobile-menu-footer",children:[o.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[o.jsx("span",{className:"icon",children:mv[i]}),"Theme: ",i]}),o.jsx("button",{className:"mobile-menu-action",onClick:()=>{s(),t()},children:"Logout"})]})]})]}):null}function gv(){const[e,t]=d.useState(!1);return o.jsxs(av,{children:[o.jsx(wl,{onMenuToggle:()=>t(!e)}),o.jsx(fv,{}),o.jsx(cv,{}),o.jsx(hv,{open:e,onClose:()=>t(!1)}),o.jsx("div",{className:"main-content",children:o.jsx("div",{className:"page-inner",children:o.jsx(pg,{})})})]})}function vv(){const[e,t]=d.useState(""),{login:n,isLoading:r,error:a,clearError:s}=ze(),[i,l]=d.useState(null),c=async()=>{if(e.trim()){s();try{await n(e)}catch(f){if(f instanceof Pf){l(f.summary);return}}}},u=async()=>{l(null),s();try{await n(e,{confirmWipe:!0})}catch{}},p=()=>{l(null)};return o.jsxs(o.Fragment,{children:[o.jsx(wl,{}),o.jsxs("div",{className:"login-split",children:[o.jsx("div",{className:"login-split-left",children:o.jsxs("div",{style:{maxWidth:"28rem"},children:[o.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),o.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your receipts."})]})}),o.jsx("div",{className:"login-split-right",children:o.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),o.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage authorizations."})]}),a&&o.jsx("div",{className:"error-message",children:a}),o.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[o.jsx("label",{className:"form-label",children:"API Key"}),o.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:f=>t(f.target.value),onKeyDown:f=>f.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),o.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),o.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),o.jsx("div",{className:"login-divider",children:"New here?"}),o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",o.jsx("br",{}),"then come back to sign in."]}),o.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),o.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[o.jsxs(o.Fragment,{children:["Create an account at ",o.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start authorizing agents"].map((f,v)=>o.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:v<2?"0.5rem":0},children:[o.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[v+1,"."]}),f]},v))})]})]})})]}),i&&o.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:p,children:o.jsxs("div",{className:"card",onClick:f=>f.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[o.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),o.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",o.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),o.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[o.jsxs("li",{children:[i.credentialCount," stored service credential",i.credentialCount===1?"":"s",i.credentialIds.length>0&&o.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",i.credentialIds.slice(0,5).join(", "),i.credentialIds.length>5?`, +${i.credentialIds.length-5} more`:"",")"]})]}),o.jsxs("li",{children:[i.serviceCount," configured integration",i.serviceCount===1?"":"s"]}),o.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),o.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Authorizations and receipts on the Service Provider are NOT affected — only this gateway's local state is wiped."}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:p,disabled:r,children:"Cancel"}),o.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:u,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function yv(){const{setActiveContext:e}=ze(),t=Vt(),[n,r]=d.useState(""),[a,s]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(!1),p=async()=>{if(n.trim()){u(!0),l("");try{const v=await M.joinGroup(n.trim());e(v,v.myDomains[0]||""),t("/")}catch(v){l(v instanceof Error?v.message:"Failed to join group")}finally{u(!1)}}},f=async()=>{if(a.trim()){u(!0),l("");try{const v=await M.createGroup(a.trim());e(v,v.myDomains[0]||""),t("/")}catch(v){l(v instanceof Error?v.message:"Failed to create group")}finally{u(!1)}}};return o.jsxs(o.Fragment,{children:[o.jsx(wl,{}),o.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:o.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),o.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"Join an existing team or create a new one to share authority across domains."})]}),i&&o.jsx("div",{className:"error-message",children:i}),o.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[o.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),o.jsxs("div",{className:"invite-input-row",children:[o.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:v=>r(v.target.value),onKeyDown:v=>v.key==="Enter"&&p(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),o.jsx("button",{className:"btn btn-primary",onClick:p,disabled:c,children:"Join"})]})]}),o.jsxs("div",{className:"card",children:[o.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:a,onChange:v=>s(v.target.value),onKeyDown:v=>v.key==="Enter"&&f(),style:{flex:1},disabled:c}),o.jsx("button",{className:"btn btn-secondary",onClick:f,disabled:c,children:"Create"})]})]})]})})]})}const mi="suveren-setup-ai-skipped",pi="suveren-setup-agent-done",hi="suveren-setup-dismissed",xv={"hap-setup-ai-skipped":mi,"hap-setup-agent-done":pi,"hap-setup-dismissed":hi};function wv(){for(const[e,t]of Object.entries(xv)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}wv();const hs={"claude-code":{label:"Claude Code",snippet:e=>JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
52
+
53
+ ${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
54
+ SSE transport: GET ${e}/sse
55
+ Health check: GET ${e}/health`}};function Sv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[s,i]=d.useState(()=>localStorage.getItem(mi)==="true"),[l,c]=d.useState(()=>localStorage.getItem(pi)==="true"),[u,p]=d.useState(()=>localStorage.getItem(hi)==="true"),[f,v]=d.useState(null),[y,x]=d.useState("claude-code"),[w,j]=d.useState(!1),h=[{label:"AI Assistant",detail:"A trusted AI helps you think through authorizations — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":s?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Authorize your agent",to:"/agent/new",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],m=h.filter(C=>C.status==="done"||C.status==="skipped").length,g=m===h.length,S=d.useCallback(()=>{localStorage.setItem(mi,"true"),i(!0)},[]),E=d.useCallback(()=>{localStorage.setItem(pi,"true"),c(!0),v(null)},[]),I=d.useCallback(()=>{localStorage.setItem(hi,"true"),p(!0)},[]),k=d.useCallback(async C=>{try{await navigator.clipboard.writeText(C),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(u||g)return null;const N=h.findIndex(C=>C.status==="pending");return o.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[o.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),o.jsx("button",{onClick:I,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:h.map((C,P)=>{const H=P===N,W=C.status==="done"||C.status==="skipped"?"●":"○",B=C.status==="done"?"var(--success)":C.status==="skipped"?"var(--text-tertiary)":H?"var(--accent)":"var(--text-tertiary)";return o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:H?"0.75rem":"0.25rem 0",borderRadius:H?"0.5rem":void 0,background:H?"var(--accent-subtle)":void 0},children:[o.jsx("span",{style:{color:B,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:W}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[C.to&&C.status==="pending"?o.jsx(Ze,{to:C.to,style:{fontSize:"0.9rem",fontWeight:H?600:500,color:H?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:C.label}):C.status==="pending"&&P===3?o.jsx("button",{onClick:()=>v(f===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:H?600:500,color:H?"var(--accent)":"var(--text-primary)"},children:C.label}):o.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:C.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:C.label}),C.optional&&C.status==="pending"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),C.status==="skipped"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),C.detail&&C.status==="pending"&&H&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:C.detail})]}),C.optional&&C.status==="pending"&&o.jsx("button",{onClick:S,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),C.to&&C.status==="pending"&&o.jsx(Ze,{to:C.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),P===3&&f===3&&o.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[o.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),o.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:a}),o.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(hs).map(([_,D])=>o.jsx("button",{onClick:()=>x(_),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:y===_?600:400,background:y===_?"var(--accent-subtle)":"transparent",color:y===_?"var(--accent)":"var(--text-secondary)",border:`1px solid ${y===_?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:D.label},_))}),o.jsx("pre",{style:{fontFamily:"monospace",fontSize:"0.78rem",lineHeight:1.6,padding:"0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",overflow:"auto",whiteSpace:"pre-wrap",margin:0,marginBottom:"0.75rem"},children:hs[y].snippet(a)}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(hs[y].snippet(a)),children:w?"Copied":"Copy"}),o.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Done"})]})]})]},P)})}),o.jsxs("div",{style:{marginTop:"1.25rem"},children:[o.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${m/h.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),o.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[m," of ",h.length," complete"]})]})]})}function kn({variant:e="base",style:t,className:n,...r}){const a=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return o.jsx("span",{className:`${a}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function gs(){return o.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[o.jsx(kn,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[o.jsx(kn,{variant:"line",style:{width:"35%"}}),o.jsx(kn,{variant:"line-sm",style:{width:"65%"}})]})]})}const jv=30*60;function vs(e){return e.replace(/@.*$/,"").split("/").pop()??e}function kv(){var _;const{domain:e}=ze(),[t,n]=d.useState([]),[r,a]=d.useState([]),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(!1),[f,v]=d.useState(!1),[y,x]=d.useState(!1),{entries:w,activeSessions:j,loading:h}=Sl(),m=!h,g=d.useCallback(()=>{M.getMyAttestations().then(D=>{n(D),p(!0)}).catch(()=>p(!0)),M.getProposals(e||"owner").then(D=>{a(D),v(!0)}).catch(()=>v(!0)),M.getProposalsForApprover().then(D=>i(D)).catch(()=>i([])),M.getCredential("ai-config").then(D=>{c(D.configured),x(!0)}).catch(()=>x(!0))},[e]);fe("attestation-changed",g),fe("proposal-added",g),fe("proposal-resolved",g),fe("proposal-approved",g),fe("proposal-rejected",g),Mt(g,3e5,e);const S=u&&f&&y&&m,E=$f(t),I=E.active,k=E.expired,N=I.filter(D=>D.remaining_seconds!==null&&D.remaining_seconds<=jv),C=r.filter(D=>D.status==="pending"),P=w.filter(D=>D.state==="running"),H=w.filter(D=>D.state==="starting"),W=w.filter(D=>D.state==="not-running"||D.state==="error"),B=[];for(const D of s)B.push({label:"Approval needed",detail:`${D.tool} — above-cap action under ${vs(D.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const D of C)B.push({label:"Approval pending",detail:`${D.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const D of N){const X=Math.ceil((D.remaining_seconds??0)/60);B.push({label:"Expiring soon",detail:`${D.title??vs(D.profile_id)} — ${X} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const D of k)B.push({label:"Expired",detail:D.title??vs(D.profile_id),to:"/authorizations",color:"var(--danger)"});for(const D of W)B.push({label:D.state==="error"?"Integration error":"Integration stopped",detail:D.state==="error"&&((_=D.integration)!=null&&_.error)?`${D.manifest.name}: ${D.integration.error}`:`${D.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const D of H)B.push({label:"Integration starting",detail:`${D.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});return l||B.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"page-header",children:o.jsx("h1",{className:"page-title",children:"Dashboard"})}),S&&o.jsx(Sv,{aiConfigured:l,hasRunningIntegration:P.length>0,hasActiveAuth:I.length>0,hasAgentConnected:j>0,mcpEndpoint:`http://localhost:${window.location.port==="3400"?"3430":"7430"}`}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[o.jsx(Ze,{to:"/authorizations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:I.length>0?"var(--success)":"var(--text-tertiary)"},children:I.length}):o.jsx(kn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),o.jsx(Ze,{to:"/proposals",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[f?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:C.length>0?"var(--warning)":"var(--text-tertiary)"},children:C.length}):o.jsx(kn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),o.jsx(Ze,{to:"/authorizations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:k.length>0?"var(--danger)":"var(--text-tertiary)"},children:k.length}):o.jsx(kn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),o.jsx(Ze,{to:"/integrations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[m?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:P.length>0?"var(--success)":"var(--text-tertiary)"},children:P.length}):o.jsx(kn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),B.length>0?o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:B.map((D,X)=>o.jsx(Ze,{to:D.to,style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"0.75rem 1rem",display:"flex",alignItems:"center",gap:"0.75rem"},children:[o.jsx("span",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",background:D.color,flexShrink:0}}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:D.label}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.detail})]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},X))}):S?o.jsx("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:o.jsx("div",{style:{fontSize:"0.9rem",color:"var(--text-secondary)"},children:"All clear. Nothing needs your attention."})}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[o.jsx(gs,{}),o.jsx(gs,{}),o.jsx(gs,{})]})]})}const Cv=["Scope & Limits","Intent","Authorize"];function Mf({currentStep:e,onStepClick:t}){const n=Vt();return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",marginBottom:"2.5rem"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",flex:1,overflow:"hidden"},children:Cv.map((r,a)=>{const s=a+2,i=s<e,l=s===e;return o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[a>0&&o.jsx("div",{style:{width:"1.5rem",height:"2px",background:i?"var(--accent)":"var(--border)",flexShrink:1}}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[o.jsx("div",{className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:i&&t?()=>t(s):void 0,style:i&&t?{cursor:"pointer"}:void 0,children:i?"✓":a+1}),o.jsx("span",{className:"step-label-text",style:{fontSize:"0.6rem",marginTop:"0.3rem",color:l?"var(--accent)":i?"var(--text-secondary)":"var(--text-tertiary)",fontWeight:l?600:400,textAlign:"center"},children:r})]})]},s)})}),o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>n("/agent/new"),style:{flexShrink:0,fontSize:"0.8rem",marginTop:"0.15rem"},children:"Cancel"})]})}const Bc=40;function Ee(e,t){if(t)return t.slice(0,Bc);const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),s=a>=0?r.slice(0,a):r;return(s.charAt(0).toUpperCase()+s.slice(1)).slice(0,Bc)}function bv({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:a}){return o.jsxs("div",{className:"context-strip",children:[n&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"context-strip-label",children:"Team:"}),o.jsxs("span",{children:[o.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&o.jsxs("span",{children:[o.jsx("strong",{children:"Profile:"})," ",Ee(e)]}),t&&o.jsxs("span",{children:[o.jsx("strong",{children:"Bounds:"})," ",t]}),a&&o.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:a,children:"Switch"})]})}function Nv({integrationId:e,field:t,value:n,onChange:r,disabled:a}){const[s,i]=d.useState(null),[l,c]=d.useState(null),[u,p]=d.useState(!0);d.useEffect(()=>{let y=!1;return M.discoverScopeField(e,t).then(x=>{y||(i(x.options),p(!1))}).catch(x=>{y||(c(x instanceof Error?x.message:String(x)),p(!1))}),()=>{y=!0}},[e,t]);const f=new Set(n.split(",").map(y=>y.trim()).filter(Boolean)),v=y=>{const x=new Set(f);x.has(y)?x.delete(y):x.add(y),r(Array.from(x).join(","))};return u?o.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):l||!s?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",l??"no response","). Enter values manually, separated by commas."]}),o.jsx("input",{className:"form-input",type:"text",value:n,onChange:y=>r(y.target.value),disabled:a})]}):s.length===0?o.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:s.map(y=>{const x=y.extras??{},w=typeof x.access=="string"?x.access:void 0,j=w==="reader",h=x.primary===!0;return o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:j?"var(--text-tertiary)":"var(--text-primary)",cursor:a||j?"not-allowed":"pointer"},title:j?"Read-only — you can authorize list/read but not writes":void 0,children:[o.jsx("input",{type:"checkbox",checked:f.has(String(y.value)),onChange:()=>v(String(y.value)),disabled:a||j}),o.jsx("span",{children:y.label||y.value}),h&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),w&&o.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",w]})]},y.value)})})}function Ev(e){return e.replace(/@.*$/,"").split("/").pop()??e}function zv(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Iv(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Pv(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Dc(e,t){const n=e.trim();return n?t==="email"?n.includes("@")&&n.indexOf(".",n.indexOf("@"))>-1:t==="domain"?n.includes(".")&&!n.includes("@"):!0:!1}function Tv(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function Rv(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function _v(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Av(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),a=n%60;return a===0?`${r} hour${r!==1?"s":""}`:`${r}h ${a}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function $v({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:s}){const i=Rv(s),l=_v(s),c=Tv(s),u=Av(t,s),p=t===""?null:Number(t),f=()=>{const y=t===""?0:Number(t),x=y%i,w=x===0?y+i:y+(i-x);n(String(w))},v=()=>{const y=t===""?0:Number(t);if(y<=0)return;const x=y%i,w=x===0?y-i:y-x;n(String(Math.max(0,w)))};return o.jsxs("div",{className:"bounded-input",children:[o.jsxs("div",{className:"bounded-input-field",children:[o.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:v,disabled:r||t===""||Number(t)<=0,"aria-label":"Decrease",children:"−"}),o.jsx("input",{id:e,className:"stepper-input",type:"number",min:0,step:i,value:t,placeholder:a??"0",onChange:y=>n(y.target.value),onFocus:y=>y.target.select(),disabled:r}),o.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:f,disabled:r,"aria-label":"Increase",children:"+"}),c&&o.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:c})]}),l.length>0&&!r&&o.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(y=>o.jsx("button",{type:"button",className:`preset-chip${p===y.value?" preset-chip-selected":""}`,onClick:()=>n(String(y.value)),children:y.label},y.value))}),u&&o.jsxs("div",{className:"bounded-input-echo",children:["≈ ",u]})]})}function Uc({htmlFor:e,label:t,description:n}){const[r,a]=d.useState(!1);return o.jsxs("div",{className:"field-label-with-tip",children:[o.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>a(s=>!s),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onBlur:()=>a(!1),children:"i"}),r&&o.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function Lv({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:s}){const[i,l]=d.useState(""),[c,u]=d.useState(!1),p=d.useRef(null),f=t?t.split(",").map(h=>h.trim()).filter(Boolean):[],v=h=>{const m=h.trim();if(!m)return;if(!Dc(m,a)){u(!0);return}u(!1);const g=f.includes(m)?f:[...f,m];n(g.join(",")),l("")},y=h=>{const m=f.filter((g,S)=>S!==h);n(m.join(","))},x=h=>{h.key==="Enter"||h.key===","||h.key==="Tab"?i.trim()&&(h.preventDefault(),v(i)):h.key==="Backspace"&&!i&&f.length>0&&y(f.length-1)},w=h=>{const m=h.clipboardData.getData("text");if(m.includes(",")){h.preventDefault();const S=m.split(",").map(I=>I.trim()).filter(Boolean).filter(I=>Dc(I,a)),E=[...new Set([...f,...S])];n(E.join(",")),l(""),u(!1)}},j=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return o.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var h;return(h=p.current)==null?void 0:h.focus()},children:[f.map((h,m)=>o.jsxs("span",{className:"tag-pill",children:[h,!r&&o.jsx("button",{type:"button",className:"tag-remove",onClick:g=>{g.stopPropagation(),y(m)},"aria-label":`Remove ${h}`,children:"×"})]},h)),!r&&o.jsx("input",{ref:p,id:e,className:"tag-input-field",type:"text",value:i,onChange:h=>{l(h.target.value),u(!1)},onKeyDown:x,onPaste:w,onBlur:()=>{i.trim()&&v(i)},placeholder:f.length===0?s??j:""})]})}function Mv({id:e,options:t,value:n,onChange:r,disabled:a}){const s=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],i=l=>{const c=s.includes(l)?s.filter(u=>u!==l):[...s,l];r(c.join(","))};return o.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>o.jsxs("label",{className:`checkbox-pill${s.includes(l)?" checkbox-pill-selected":""}`,children:[o.jsx("input",{type:"checkbox",checked:s.includes(l),onChange:()=>i(l),disabled:a}),o.jsx("span",{children:l})]},l))})}function Wc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:s,twoColumn:i,discoveryIntegrationId:l}){const c=zv(e,t),u=`${a}-field-${e}`,p=o.jsx(o.Fragment,{children:Pv(t)?o.jsx(Mv,{id:u,options:t.enum,value:n,onChange:f=>r(e,f),disabled:s}):(()=>{const f=t.boundType;return(f==null?void 0:f.kind)==="enum"&&Array.isArray(f.values)})()?o.jsxs("select",{id:u,className:"form-select",value:n,onChange:f=>r(e,f.target.value),disabled:s,children:[o.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(f=>o.jsx("option",{value:f,children:f},f))]}):"enum"in t&&t.enum?o.jsxs("select",{id:u,className:"form-select",value:n,onChange:f=>r(e,f.target.value),disabled:s,children:[o.jsx("option",{value:"",children:"Select..."}),t.enum.map(f=>o.jsx("option",{value:f,children:f},f))]}):t.type==="number"?o.jsx($v,{id:u,value:n,onChange:f=>r(e,f),disabled:s,unit:t.unit}):Iv(t)?o.jsx(Lv,{id:u,value:n,onChange:f=>r(e,f),disabled:s,format:t.format}):l?o.jsx(Nv,{integrationId:l,field:e,value:n,onChange:f=>r(e,f),disabled:s}):o.jsx("input",{id:u,className:"form-input",type:"text",value:n,onChange:f=>r(e,f.target.value),disabled:s})});return i?o.jsxs("div",{className:"bounds-field-row",children:[o.jsx("div",{className:"bounds-field-label",children:o.jsx(Uc,{htmlFor:u,label:c,description:t.description})}),o.jsx("div",{className:"bounds-field-input",children:p})]},`${a}-${e}`):o.jsxs("div",{className:"form-group",children:[o.jsx(Uc,{htmlFor:u,label:c,description:t.description}),p]},`${a}-${e}`)}function Fv(e,t){if(!t)return"no-config";const n=t.caps,r=Array.isArray(t.approvers)&&t.approvers.length>0;if(!(n&&Object.keys(n).length>0))return r?"approvers-dormant":"no-config";let s=!1;for(const[i,l]of Object.entries(n)){const c=e[i];if(c===""||c===void 0)continue;const u=Number(c);if(!isNaN(u)&&u>l){s=!0;break}}return s?r?"above-approvers":"hard-ceiling":"within-cap"}function Ov(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const s=e[r];if(s===""||s===void 0)continue;const i=Number(s);!isNaN(i)&&i>a&&n.add(r)}return n}function Bv({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:s,initialFrame:i,profileConfig:l,approverNames:c,adminName:u}){const p=e.boundsSchema??e.frameSchema,f=e.contextSchema,v=p?Object.entries(p.fields).filter(([z])=>!(z==="profile"||z==="path")):[],y=f&&f.keyOrder.length>0?Object.entries(f.fields):[],x=a??i??{},w=s??{},j={};for(const[z]of v)j[z]=x[z]!==void 0?String(x[z]):"";const h={};for(const[z]of y)h[z]=w[z]!==void 0?String(w[z]):"";const[m,g]=d.useState(j),[S,E]=d.useState(h),[I,k]=d.useState(null);d.useEffect(()=>{const z=Ev(e.id);M.getIntegrationManifests().then(({manifests:R})=>{const $=R.find(L=>L.profile===z&&L.contextDiscovery&&Object.keys(L.contextDiscovery).length>0);k($??null)}).catch(()=>k(null))},[e.id]);const N=Fv(m,l),C=Ov(m,l==null?void 0:l.caps),P=(z,R)=>{g($=>({...$,[z]:R}))},H=(z,R)=>{E($=>({...$,[z]:R}))},W=()=>{const z={profile:e.id};for(const[$,L]of v)L.type==="number"?z[$]=m[$]===""?0:Number(m[$]):z[$]=m[$];const R={};for(const[$,L]of y)L.type==="number"?R[$]=S[$]===""?0:Number(S[$]):R[$]=S[$];return[z,R]},B=()=>{const[z,R]=W();t(z,R)},_=()=>{const z=(l==null?void 0:l.caps)??{},R={...m};for(const V of C)z[V]!==void 0&&(R[V]=String(z[V]));g(R);const $={profile:e.id};for(const[V,ee]of v)if(ee.type==="number"){const J=R[V]??"";$[V]=J===""?0:Number(J)}else $[V]=R[V]??"";const L={};for(const[V,ee]of y)ee.type==="number"?L[V]=S[V]===""?0:Number(S[V]):L[V]=S[V];t($,L)},D=z=>{const R=l==null?void 0:l.caps;if(!R||R[z]===void 0)return null;const $=R[z],L=C.has(z);return N==="hard-ceiling"&&L?o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",$," — exceeds team ceiling"]}):N==="above-approvers"&&L?o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",$," — above cap"]}):o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",$," ok"]})},X=()=>{var z;if(N==="no-config")return null;if(N==="approvers-dormant"){const R=c&&c.length>0?c.join(", "):"the configured approvers";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",R]}),o.jsxs("div",{children:["No caps are set on this profile, so ",R," won't gate any action under this authority. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(N==="within-cap")return o.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:o.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(N==="above-approvers"){const R=c&&c.length>0?c.join(", "):"the required approvers";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),o.jsxs("div",{children:[o.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",R,". Within-cap actions run per the mode you choose."]})]})}if(N==="hard-ceiling"){const R=Array.from(C)[0],$=R?(z=l==null?void 0:l.caps)==null?void 0:z[R]:void 0,L=u??"the team admin";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),o.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",$??"the configured limit",". Lower your bound or ask ",L," to add an approver path above the cap."]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:_,children:"Save below cap"}),n&&o.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},oe=N==="hard-ceiling";return o.jsxs("div",{children:[y.length>0&&o.jsxs("div",{className:"context-section",children:[o.jsxs("div",{className:"bounds-section-header",children:[o.jsx("span",{className:"bounds-section-icon",children:"🛡"}),o.jsxs("div",{children:[o.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),o.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the SP"})]})]}),y.map(([z,R])=>{var L;const $=!!((L=I==null?void 0:I.contextDiscovery)!=null&&L[z]);return o.jsx(Wc,{fieldKey:z,fieldDef:R,value:S[z],onChange:H,prefix:"context",readOnly:r,discoveryIntegrationId:$?I.id:void 0},`context-${z}`)})]}),v.length>0&&o.jsxs("div",{className:"bounds-section",children:[o.jsxs("div",{className:"bounds-section-header",children:[o.jsx("span",{className:"bounds-section-icon",children:"🔒"}),o.jsxs("div",{children:[o.jsx("div",{className:"bounds-section-title",children:"Limits"}),o.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Service Provider"})]})]}),o.jsx("div",{className:"bounds-fields-grid",children:v.map(([z,R])=>{var $;return o.jsxs("div",{style:{display:"contents"},children:[o.jsx(Wc,{fieldKey:z,fieldDef:R,value:m[z],onChange:P,prefix:"bounds",readOnly:r,twoColumn:!0}),N!=="no-config"&&(($=l==null?void 0:l.caps)==null?void 0:$[z])!==void 0&&o.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:D(z)})]},`bounds-${z}`)})}),X()]}),o.jsx("button",{className:"btn btn-primary",onClick:B,disabled:oe,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Dv(e){var n;const t=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((n=t==null?void 0:t[1])==null?void 0:n.trim())??null}function Uv(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Wv="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function vo({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:s}){const[i,l]=d.useState([{role:"assistant",content:r??Wv}]),[c,u]=d.useState(""),[p,f]=d.useState(!1),[v,y]=d.useState(null),x=d.useRef(null);d.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[i,p]);const w=async()=>{const h=c.trim();if(!h||p)return;const m=[...i,{role:"user",content:h}];l(m),u(""),y(null),f(!0);try{const g=await M.aiChat({target:e,currentText:t,messages:m.filter((S,E)=>!(E===0&&S.role==="assistant"))});g.success&&g.reply?l(S=>[...S,{role:"assistant",content:g.reply}]):y(g.error??"AI returned no reply")}catch(g){y(g instanceof Error?g.message:"Chat failed")}finally{f(!1)}},j=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),w())};return o.jsxs("div",{className:"intent-chat",children:[o.jsx("h3",{className:"card-title",children:s??"AI Assistant"}),o.jsxs("div",{ref:x,className:"chat-messages",children:[i.map((h,m)=>{const g=h.role==="assistant"?Dv(h.content):null,S=g?Uv(h.content):h.content;return o.jsx("div",{className:`chat-msg ${h.role}`,children:o.jsxs("div",{className:"chat-msg-body",children:[S&&o.jsx("div",{className:"chat-msg-prose",children:S}),g!==null&&o.jsxs(o.Fragment,{children:[o.jsx("pre",{className:"chat-fenced-block",children:g}),o.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(g),children:"Apply this draft"})]})]})},m)}),p&&o.jsx("div",{className:"chat-msg assistant",children:o.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),v&&o.jsx("div",{className:"error-message",children:v}),o.jsxs("div",{className:"chat-composer",children:[o.jsxs("div",{className:"chat-composer-pill",children:[o.jsx("textarea",{className:"chat-input",value:c,onChange:h=>u(h.target.value),onKeyDown:j,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:p}),o.jsx("button",{type:"button",className:"chat-send-btn",onClick:w,disabled:p||!c.trim(),"aria-label":"Send",children:"↑"})]}),o.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Ff({open:e,onClose:t,children:n,ariaLabel:r}){const a=d.useRef(null),s=d.useRef(null);return d.useEffect(()=>{var l;if(!e)return;s.current=document.activeElement,document.body.style.overflow="hidden";const i=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",i),(l=a.current)==null||l.focus(),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="",s.current instanceof HTMLElement&&s.current.focus()}},[e,t]),uf.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),o.jsxs("aside",{ref:a,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[o.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),o.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function Hv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vv(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const u of[c.scope,...c.scope.split(",").map(p=>p.trim())]){const p=u.toLowerCase();u&&!a.has(p)&&(a.add(p),r.push(u))}r.sort((c,u)=>u.length-c.length);const s=c=>{const u=c.toLowerCase();return t.filter(p=>{var f,v;return((f=p.scope)==null?void 0:f.toLowerCase())===u||((v=p.scope)==null?void 0:v.split(",").map(y=>y.trim().toLowerCase()).includes(u))})},i=["\\[\\d+\\]",...r.map(Hv)],l=new RegExp(`(${i.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const u=/^\[(\d+)\]$/.exec(c);if(u){const p=t[Number(u[1])-1];if(p){const f=p.scope&&p.scope!=="all (unscoped)"?p.scope:"all recipients",v=n?`${n}: ${f}`:f;return{text:c,label:v,matched:[p]}}}else if(r.some(p=>p.toLowerCase()===c.toLowerCase())){const p=s(c);if(p.length>0)return{text:c,label:c,matched:p}}return{text:c,label:c,matched:null}})}const Hc=`Why — What's the situation? Why does this need to happen?
56
+
57
+ Goal — What should the agent try to achieve?
58
+
59
+ Watch out — What should the agent avoid or be careful about?`;function Kv(e,t,n,r){return Vv(e,t,r).map((a,s)=>{if(!a.matched)return o.jsx("span",{children:a.text},s);const i=a.matched;return o.jsx("button",{type:"button",onClick:()=>n(i),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:a.label},s)})}function Gv(){var A;const e=Vt(),[t]=If(),n=Number(t.get("step"))||2,[r,a]=d.useState(null),[s,i]=d.useState(null),[l,c]=d.useState(n),[u,p]=d.useState(null),[f,v]=d.useState(null),[y,x]=d.useState(Hc),[w,j]=d.useState(!1),[h,m]=d.useState(!0),[g,S]=d.useState(null),[E,I]=d.useState([]),[k,N]=d.useState(void 0),[C,P]=d.useState(!1),[H,W]=d.useState(null),[B,_]=d.useState(null),[D,X]=d.useState(null),[oe,z]=d.useState([]),[R,$]=d.useState(null);d.useEffect(()=>{var Ie;const T=sessionStorage.getItem("agentAuth");if(!T){e("/agent/new");return}const Y=JSON.parse(T);a(Y);const xe=sessionStorage.getItem("agentGate");if(xe){const ke=JSON.parse(xe);ke.bounds&&p(ke.bounds),ke.context&&v(ke.context),(Ie=ke.gateContent)!=null&&Ie.intent&&x(ke.gateContent.intent)}M.getProfile(Y.profileId).then(ke=>i(ke)).catch(()=>e("/agent/new")).finally(()=>m(!1)),Y.groupId&&Promise.all([M.getTeamProfileConfig(Y.groupId,Y.profileId).catch(()=>null),M.getGroupById(Y.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([ke,hn,_n])=>{if(S(ke),ke){const Tt=new Map;for(const re of _n){const pt=re.name&&re.email?`${re.name} (${re.email})`:re.name||re.email||re.id;Tt.set(re.id,pt)}const Ue=(hn==null?void 0:hn.members)??[];for(const re of Ue){const pt=re.userId??re.id;pt&&(re.name&&re.email?Tt.set(pt,`${re.name} (${re.email})`):re.name&&Tt.set(pt,re.name))}const mr=(ke.approvers??[]).map(re=>Tt.get(re)??re);I(mr);const Kt=Ue.find(re=>re.role==="admin");if(Kt){const re=Kt.userId??Kt.id;re&&N(Tt.get(re)??Kt.name)}}})},[e]);const L=u?Object.entries(u).filter(([T])=>T!=="profile"&&T!=="path").map(([T,Y])=>`${T} = ${Y}`).join(", "):"",V=(T,Y)=>{p(T),v(Y),c(3)},ee=y.trim()!==Hc.trim()&&y.trim()!=="",J=T=>{ee&&!confirm("Replace your current intent with the AI draft?")||x(T)},je=()=>{const T=s==null?void 0:s.ttl,Y={intent:y};sessionStorage.setItem("agentGate",JSON.stringify({bounds:u,context:f,gateContent:Y,ttlConfig:T})),e("/agent/review")},b=async()=>{if(r){P(!0),W(null),_(null),X(null),z([]),$(null);try{const T=await M.aiIntentReview({profileId:r.profileId,newIntent:y,context:f??void 0});z(T.grants??[]),T.success?T.review?W(T.review):_(T.note??"No other authorizations on this profile to compare against."):X(T.error??"Check failed.")}catch(T){X(T instanceof Error?T.message:"Check failed.")}finally{P(!1)}}},U=T=>{x(T),(H||B||D)&&(W(null),_(null),X(null),z([]),$(null))};return h||!r||!s?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):o.jsxs(o.Fragment,{children:[o.jsx(Mf,{currentStep:l,onStepClick:T=>{T>=2&&c(T)}}),o.jsx(bv,{profileId:r.profileId,bounds:L||void 0,groupName:r.groupName,domain:r.domain}),l===2&&o.jsx("div",{className:"card",children:o.jsx(Bv,{profile:s,onConfirm:V,onCancel:()=>e("/agent/new"),initialBounds:u||void 0,initialContext:f||void 0,profileConfig:g,approverNames:E,adminName:k})}),l===3&&o.jsxs("div",{className:"intent-layout",children:[o.jsx("div",{className:"card intent-pane chat",children:o.jsx(vo,{target:{kind:"intent",profileId:r.profileId,bounds:L||void 0},currentText:y,onApply:J})}),o.jsxs("div",{className:"card intent-pane document",children:[o.jsx("h3",{className:"card-title",children:"What should your agent know?"}),o.jsx("textarea",{className:"intent-textarea",value:y,onChange:T=>U(T.target.value)}),o.jsxs("div",{className:"char-counter",children:[y.length," / 2000"]}),o.jsxs("div",{style:{marginTop:"0.5rem"},children:[o.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:b,disabled:C||!ee,children:C?"Checking…":"Check against my other grants"}),D&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),o.jsx("div",{className:"hint-body",children:D})]}),B&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsx("div",{className:"hint-body",children:B})]}),H&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsxs("div",{className:"hint-body",children:[o.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),o.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Kv(H,oe,$,Ee(r.profileId))}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),o.jsxs("div",{className:"intent-footer",children:[o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),o.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:je,disabled:!ee,children:"Continue to Review"})]}),(((A=g==null?void 0:g.approvers)==null?void 0:A.length)??0)>0&&o.jsxs("div",{className:"hint-box",role:"note",children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsxs("div",{className:"hint-body",children:[o.jsxs("div",{className:"hint-head",children:["Visible to ",E.length>0?E.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",E.length>0?E.join(", "):"this profile's required approvers",". Only they can decrypt it — your Service Provider cannot. Each approver stores a copy as their accountability record."]})]})]}),o.jsx("button",{type:"button",className:"floating-help",onClick:()=>j(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),o.jsx(Ff,{open:w,onClose:()=>j(!1),ariaLabel:"Intent assistant",children:o.jsx(vo,{target:{kind:"intent",profileId:r.profileId,bounds:L||void 0},currentText:y,onApply:T=>{J(T),j(!1)}})}),R&&o.jsx("div",{className:"modal-backdrop",onClick:T=>T.target===T.currentTarget&&$(null),children:o.jsxs("div",{className:"modal",children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h3",{className:"modal-title",children:R.length>1?`Existing authorizations (${R.length})`:"Existing authorization"}),o.jsx("button",{className:"modal-close",onClick:()=>$(null),children:"×"})]}),o.jsx("div",{className:"modal-body",children:R.map((T,Y)=>{var xe;return o.jsxs("div",{style:{marginBottom:Y<R.length-1?"1rem":0,paddingBottom:Y<R.length-1?"1rem":0,borderBottom:Y<R.length-1?"1px solid var(--border)":"none"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),o.jsx("div",{style:{marginBottom:"0.75rem"},children:T.scope}),o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),o.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((xe=T.intent)==null?void 0:xe.trim())||"(no intent recorded)"}),Object.entries(T.bounds).filter(([Ie])=>Ie!=="profile"&&Ie!=="path").length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(T.bounds).filter(([Ie])=>Ie!=="profile"&&Ie!=="path").map(([Ie,ke])=>`${Ie}: ${ke}`).join(" · ")})]})]},Y)})})]})})]})]})}function Yv(e){return e.normalize("NFC").replace(/\r\n?/g,`
60
+ `).split(`
61
+ `).map(a=>a.replace(/[ \t]+$/,"")).join(`
62
+ `).replace(/\n+$/,"")}async function gi(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function Ha(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const a=n.keyOrder.map(i=>`${i}=${String(e[i])}`).join(`
63
+ `);return`sha256:${await gi(a)}`}async function Of(e,t){if(!t.contextSchema||t.contextSchema.keyOrder.length===0)return`sha256:${await gi("")}`;const r=t.contextSchema.keyOrder.map(s=>`${s}=${String(e[s])}`).join(`
64
+ `);return`sha256:${await gi(r)}`}async function yo(e){const t=new TextEncoder().encode(Yv(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}`}function Bf(e,t){if(!e.authorization_id)throw new Error("Attest result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??t.boundsHash,contextHash:t.contextHash,context:t.context,gateContent:t.gateContent,...t.path?{path:t.path}:{}}}function Vc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Qv(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Jv(e,t,n){for(const r of e){const a=Vc(t[r]),s=Vc(n[r]);if(!(a.size===0||s.size===0)&&!Qv(a,s))return!1}return!0}function Xv(){var pt,ca,K;const e=Vt(),{user:t,mode:n,domain:r}=ze(),[a,s]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState("immediate"),[v,y]=d.useState(1800),[x,w]=d.useState(86400),[j,h]=d.useState(""),[m,g]=d.useState("hours"),[S,E]=d.useState(""),[I,k]=d.useState(!1),[N,C]=d.useState(!1),[P,H]=d.useState(""),[W,B]=d.useState(null),[_,D]=d.useState([]),[X,oe]=d.useState(!1),[z,R]=d.useState([]),[$,L]=d.useState(0);d.useEffect(()=>{const O=sessionStorage.getItem("agentAuth"),Q=sessionStorage.getItem("agentGate");if(!O||!Q){e("/agent/new");return}const q=JSON.parse(O),ne=JSON.parse(Q),Me={bounds:ne.bounds??{},context:ne.context??{},gateContent:ne.gateContent};s(q),l(Me),ne.ttlConfig&&(y(ne.ttlConfig.default??1800),w(ne.ttlConfig.max??86400)),M.getProfile(q.profileId).then(Ye=>{var ht;if(u(Ye),!S){const Rt=Ye.name??((ht=q.profileId.split("/").pop())==null?void 0:ht.replace(/@.*$/,""))??"",Qe=[];if(Me.context&&Ye.contextSchema)for(const gn of Ye.contextSchema.keyOrder){const se=Me.context[gn];if(se!==void 0&&se!==""){const Xe=String(se).split(",").map(An=>An.trim()).filter(Boolean);Qe.push(Xe.join(", "))}}const Je=Qe.length>0?`${Rt}: ${Qe.join(" · ")}`:Rt;E(Je)}}).catch(()=>{}),q.groupId?Promise.all([M.getTeamProfileConfig(q.groupId,q.profileId).catch(()=>null),M.getGroupById(q.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([Ye,ht,Rt])=>{if(B(Ye),Ye){const Qe=new Map;for(const se of Rt){const Xe=se.name&&se.email?`${se.name} (${se.email})`:se.name||se.email||se.id;Qe.set(se.id,Xe)}const Je=(ht==null?void 0:ht.members)??[];for(const se of Je){const Xe=se.userId??se.id;Xe&&(se.name&&se.email?Qe.set(Xe,`${se.name} (${se.email})`):se.name&&Qe.set(Xe,se.name))}const gn=(Ye.approvers??[]).map(se=>Qe.get(se)??se);D(gn)}}).finally(()=>{oe(!0)}):oe(!0)},[e]),d.useEffect(()=>{if(!(a!=null&&a.profileId))return;const O=a.profileId,Q=sessionStorage.getItem("agentEditReplaces");M.getEnrichedAuthorizations().then(q=>{const ne=q.filter(Me=>Me.profileId===O&&Me.authorizationId!==Q).map(Me=>({authorizationId:Me.authorizationId,bounds:Me.bounds,context:Me.context??{},intent:Me.intent}));R(ne)}).catch(()=>R([]))},[a==null?void 0:a.profileId]),d.useEffect(()=>{if(!i||!c||z.length===0){L(0);return}let O=!1;return(async()=>{const Q=await Ha(i.bounds,c),q=await Promise.all(z.map(ne=>Ha(ne.bounds,c).catch(()=>null)));O||L(q.filter(ne=>ne===Q).length)})().catch(()=>{O||L(0)}),()=>{O=!0}},[i,c,z]);const V=async()=>{if(!(!a||!i||!c||!t)){if(!a.groupId){H("No active group; cannot create authorization.");return}C(!0),H("");try{const O=r||a.domain||"owner",Q=await Ha(i.bounds,c),q=await Of(i.context,c),[ne,Me]=await Promise.all([yo(i.gateContent.intent),yo(JSON.stringify({profile:a.profileId,domain:O,group:a.groupId}))]);let Ye,ht,Rt,Qe;if(a.isTeam){const Xe=await M.getApproversPubkeys(a.groupId,a.profileId);if(Xe.length>0){const An=await M.encryptIntent(i.gateContent.intent,Xe);Ye=An.intentCiphertext,ht=An.encryptedKeys,Rt=An.approversFrozen,Qe=An.intentDisclosureHash}}const Je=`authz_${crypto.randomUUID()}`,gn=sessionStorage.getItem("agentEditReplaces")||void 0,se=await M.attest({authorization_id:Je,replaces:gn,profile_id:a.profileId,bounds:i.bounds,bounds_hash:Q,context_hash:q,domain:O,did:t.did,gate_content_hashes:{intent:ne},execution_context_hash:Me,group_id:a.groupId,ttl:v,commitment_mode:p==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:Ye,encrypted_keys:ht,approvers_frozen:Rt,intent_disclosure_hash:Qe,disclose_identity:I});try{await M.pushGateContent(Bf(se,{boundsHash:Q,contextHash:q,context:i.context,gateContent:i.gateContent}))}catch(Xe){try{await M.revokeAttestation(Je,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${Xe instanceof Error?Xe.message:"Unknown error"})`)}if(gn)try{await M.revokeAttestation(gn,`Replaced by ${Je} (edit)`),M.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(Je)}`)}catch(O){H(O instanceof Error?O.message:"Attestation failed")}finally{C(!1)}}};if(!a||!i)return o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ee=Object.entries(i.bounds).filter(([O])=>O!=="profile"&&O!=="path"),J=Object.entries(i.context),b=((W==null?void 0:W.caps)!=null?Object.keys(W.caps):[]).length!==0,U=_.length>0?_.join(", "):((W==null?void 0:W.approvers)??[]).join(", "),A=b?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${U}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",T=b?`Over-cap actions will be reviewed by you and ${U}. Within-cap actions run per the mode you chose above.`:`Approvers ${U} can read your intent but won't gate any action — no caps configured on this profile.`,Y=!!((pt=W==null?void 0:W.approvers)!=null&&pt.length),xe=v>x,Ie={flex:1,padding:"0.75rem",border:p==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:p==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},ke={flex:1,padding:"0.75rem",border:p==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:p==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},hn=((ca=c==null?void 0:c.contextSchema)==null?void 0:ca.keyOrder)??[],_n=z.filter(O=>Jv(hn,i.context,O.context)),Tt=_n.length>0,Ue=Ee(a.profileId),mr=O=>{const Q=Object.values(O).map(q=>String(q).trim()).filter(Boolean);return Q.length>0?Q.join(", "):"all (unscoped)"},Kt=_n.map(O=>mr(O.context)).join("; "),re=`This grant's scope overlaps an existing grant on ${Ue} (scoped to: ${Kt}). When two grants cover the same actions, the agent may act under either — the more permissive limits effectively apply. Confirm this is intended before authorizing.`;return o.jsxs(o.Fragment,{children:[o.jsx(Mf,{currentStep:4,onStepClick:O=>{O<=3&&e(`/agent/gate?step=${O}`)}}),o.jsxs("div",{className:"card",children:[o.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your authorization details before signing."}),P&&o.jsx("div",{className:"error-message",children:P}),o.jsxs("dl",{className:"review-grid",children:[o.jsx("dt",{children:"Profile"}),o.jsxs("dd",{children:[Ee(a.profileId),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:a.profileId})]}),a.groupName&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Team"}),o.jsx("dd",{children:a.groupName})]}),a.groupId&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Approvers"}),o.jsx("dd",{children:X?(((K=W==null?void 0:W.approvers)==null?void 0:K.length)??0)===0?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"None — solo authorization"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"No approvers configured for this profile in this team. Your intent stays on your gateway."})]}):o.jsxs(o.Fragment,{children:[U,o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:A})]}):o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]}),o.jsx("dt",{children:"TTL"}),o.jsx("dd",{children:"30 minutes"})]}),!!ee.length&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Bounds"}),o.jsx("dl",{className:"review-grid",children:ee.map(([O,Q])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:O}),o.jsx("dd",{children:String(Q)})]},O))})]}),!!J.length&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Context"}),o.jsx("dl",{className:"review-grid",children:J.map(([O,Q])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:O}),o.jsx("dd",{children:String(Q)})]},O))})]}),o.jsx("div",{className:"gate-content-block",children:o.jsxs("div",{className:"gate-content-item",children:[o.jsx("div",{className:"gate-content-label",children:"Intent"}),o.jsx("div",{className:"gate-content-text",children:i.gateContent.intent})]})}),o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.5rem"},children:"Commitment"}),o.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1.25rem"},children:[o.jsxs("button",{onClick:()=>f("immediate"),style:Ie,children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]}),o.jsxs("button",{onClick:()=>f("per-action"),style:ke,children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]})]}),$>0?o.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),o.jsxs("div",{children:[$===1?`An active grant on ${Ue} already has exactly these limits.`:`${$} active grants on ${Ue} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",o.jsx("strong",{children:"Extend"})," on the Authorizations page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,Tt?o.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),o.jsx("div",{children:re})]})]}):null,o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"Duration"}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"1.25rem",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(O=>O.seconds<=x).map(O=>o.jsx("button",{onClick:()=>{y(O.seconds),h("")},style:{padding:"0.5rem 0.85rem",border:v===O.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:v===O.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:O.label},O.seconds)),o.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[o.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:j,onChange:O=>{h(O.target.value);const Q=parseInt(O.target.value,10);if(Q>0){const q=m==="days"?Q*86400:Q*3600;y(Math.min(q,x))}}}),o.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:m,onChange:O=>{g(O.target.value);const Q=parseInt(j,10);if(Q>0){const q=O.target.value==="days"?Q*86400:Q*3600;y(Math.min(q,x))}},children:[o.jsx("option",{value:"hours",children:"hours"}),o.jsx("option",{value:"days",children:"days"})]})]}),xe&&o.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",x>=86400?`${Math.floor(x/86400)} days`:`${Math.floor(x/3600)} hours`]})]}),o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"Title"}),o.jsxs("div",{style:{marginBottom:"1.25rem"},children:[o.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Ee(a.profileId)}: daily operations`,value:S,onChange:O=>E(O.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this authorization on your dashboard."})]}),o.jsx("div",{style:{marginBottom:"1.25rem"},children:o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:I,onChange:O=>k(O.target.checked),style:{marginTop:"0.15rem"}}),o.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this authority",o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:'Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.'})]})]})}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/agent/gate"),children:"Back"}),o.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:V,disabled:N||!S.trim(),children:N?"Signing...":p==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),o.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Y?"block":"none"},children:T})]})]})}const qv={card:"💳",mail:"✉️"};function Zv({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var je;const[s,i]=d.useState({}),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[f,v]=d.useState({}),[y,x]=d.useState(!1),[w,j]=d.useState(null),[h,m]=d.useState(!1),[g,S]=d.useState(!1),[E,I]=d.useState(!1),[k,N]=d.useState(!1),[C,P]=d.useState({});d.useEffect(()=>{let b=!1;return M.getCredential(e.id).then(U=>{var A;if(!(b||!U.configured)){if(c(!0),p(!0),U.fields){const T={};for(const Y of e.credentials.fields)U.fields[Y.key]!=null&&(T[Y.key]=U.fields[Y.key]);v(T)}if(e.oauth){const T=((A=U.fieldNames)==null?void 0:A.includes(e.oauth.tokenStorage))??!1;x(T),T&&M.getOAuthHealth(e.id).then(Y=>{b||j(Y)})}}}).catch(()=>{}),()=>{b=!0}},[e.id,e.oauth]);const H=!!e.oauth||e.credentials.fields.some(b=>!b.optional),W=e.oauth?y:l,B=!H||W,_=n==="starting"?"starting":B?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!y?"needs-oauth":"unconfigured",D=async()=>{if(e.credentials.fields.some(U=>{var A;return(A=s[U.key])==null?void 0:A.trim()})){m(!0);try{await M.setCredential(e.id,s),c(!0),i({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await z())}catch{a(`Failed to save ${e.name} credentials`)}finally{m(!1)}}},X=async()=>{if(e.credentials.fields.some(U=>{var A;return(A=s[U.key])==null?void 0:A.trim()})){m(!0);try{await M.setCredential(e.id,s),i({}),c(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(N(!1),a(`${e.name} credentials updated — restarting...`),await z())}catch{a(`Failed to update ${e.name} credentials`)}finally{m(!1)}}},oe=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const b=setInterval(async()=>{var U;try{const A=await M.getCredential(e.id);A.configured&&e.oauth&&((U=A.fieldNames)!=null&&U.includes(e.oauth.tokenStorage))&&(x(!0),N(!1),j(null),clearInterval(b),a(`${e.name} connected — starting integration...`),M.getOAuthHealth(e.id).then(j).catch(()=>{}),await z())}catch{}},2e3);setTimeout(()=>clearInterval(b),12e4)},z=async()=>{I(!0);try{const b=await M.activateIntegration(e.id);b.warning?a(b.warning):a(`${e.name} integration started with ${b.tools.length} tools`),r()}catch(b){a(`Failed to start ${e.name}: ${b instanceof Error?b.message:"Unknown error"}`)}finally{I(!1)}},R=async()=>{try{await M.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},$=qv[e.icon]??"🔧",L=_==="running"?{c:"int-chip-ok",t:"Running"}:_==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},V=e.oauth&&y&&(w==null?void 0:w.status)==="failed",ee=H?V?{c:"int-chip-bad",t:"Auth failed"}:W?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},J=b=>b.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return o.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[o.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:$}),o.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),o.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[_!=="unconfigured"&&_!=="needs-oauth"&&o.jsxs("span",{className:`int-chip ${L.c}`,children:[o.jsx("span",{className:"int-dot"}),L.t]}),o.jsxs("span",{className:`int-chip ${ee.c}`,children:[o.jsx("span",{className:"int-dot"}),ee.t]})]})]}),e.oauth&&y&&o.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:w!=null&&w.account?o.jsxs(o.Fragment,{children:["Connected as ",o.jsx("b",{children:w.account})]}):o.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),V&&!k&&o.jsxs("div",{style:{marginTop:"0.7rem"},children:[o.jsxs("div",{className:"status-banner status-banner-error",style:{marginBottom:"0.6rem"},children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsxs("span",{className:"status-banner-text",children:["Authentication failed",w!=null&&w.error?` — ${w.error}`:"",". Reconnect to restore access."]})]}),o.jsxs("button",{className:"btn btn-primary btn-sm",onClick:oe,children:["Reconnect ",e.name]})]}),o.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[o.jsx("summary",{children:"Details"}),o.jsxs("div",{className:"int-meta",children:[o.jsx("span",{className:"int-k",children:"What"}),o.jsx("span",{children:e.description}),e.profile&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Profile"}),o.jsx("span",{children:e.profile})]}),e.oauth&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Scopes"}),o.jsx("span",{children:((je=e.oauth.scopes)==null?void 0:je.join(", "))||"—"})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Tools"}),o.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(_!=="running"||V)&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsxs("button",{onClick:()=>S(!g),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[o.jsx("span",{style:{transition:"transform 0.2s",transform:g?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),g&&o.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((b,U)=>o.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[o.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:U+1}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:b.title}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[J(b.description),b.link&&o.jsxs(o.Fragment,{children:[" ",o.jsxs("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},U))})]}),_==="starting"&&o.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[o.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),k&&o.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),u&&o.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Your current values are filled in below (secret hidden — click ","“","show","”","). Edit them, then",e.oauth?" Save and Connect to re-link the account.":" Save to apply."]}),e.credentials.fields.map(b=>o.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[o.jsx("label",{className:"form-label",children:b.label}),b.type==="password"?o.jsxs("div",{className:"cred-field",children:[o.jsx("input",{className:"form-input",type:C[b.key]?"text":"password",placeholder:b.placeholder,value:s[b.key]||"",onChange:U=>i(A=>({...A,[b.key]:U.target.value}))}),o.jsx("button",{className:"cred-toggle",onClick:()=>P(U=>({...U,[b.key]:!U[b.key]})),children:C[b.key]?"hide":"show"})]}):o.jsx("input",{className:"form-input",type:"text",placeholder:b.placeholder,value:s[b.key]||"",onChange:U=>i(A=>({...A,[b.key]:U.target.value}))})]},b.key)),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[o.jsx("button",{className:"btn btn-primary btn-sm",onClick:X,disabled:h,children:h?"Saving…":"Save"}),e.oauth&&o.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:oe,children:["Connect ",e.name]}),o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{N(!1),i({})},children:"Cancel"})]})]}),!k&&_==="running"&&t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[o.jsx(Ze,{to:"/agent/new",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Authorize agent"}),(e.credentials.fields.length>0||e.oauth)&&o.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{i({...f}),N(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Change credentials"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:R,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),o.jsx("div",{style:{display:"none"},children:o.jsx(Ze,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),_==="unconfigured"&&(()=>{const b=e.credentials.fields.every(T=>T.optional),U=e.credentials.fields.some(T=>!T.optional),A=e.credentials.fields.some(T=>{var Y;return(Y=s[T.key])==null?void 0:Y.trim()});return o.jsxs(o.Fragment,{children:[u&&o.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[o.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",o.jsx("button",{onClick:()=>{c(!0),e.oauth&&x(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!u&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!u&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(T=>o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:T.label}),T.type==="password"?o.jsxs("div",{className:"cred-field",children:[o.jsx("input",{className:"form-input",type:C[T.key]?"text":"password",placeholder:T.placeholder,value:s[T.key]||"",onChange:Y=>i(xe=>({...xe,[T.key]:Y.target.value}))}),o.jsx("button",{className:"cred-toggle",onClick:()=>P(Y=>({...Y,[T.key]:!Y[T.key]})),children:C[T.key]?"hide":"show"})]}):o.jsx("input",{className:"form-input",type:"text",placeholder:T.placeholder,value:s[T.key]||"",onChange:Y=>i(xe=>({...xe,[T.key]:Y.target.value}))})]},T.key)),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[A&&o.jsx("button",{className:"btn btn-primary",onClick:D,disabled:h||U&&!e.credentials.fields.filter(T=>!T.optional).every(T=>{var Y;return(Y=s[T.key])==null?void 0:Y.trim()}),children:h?"Saving...":"Save & Encrypt"}),b&&!A&&o.jsx("button",{className:"btn btn-primary",onClick:z,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),_==="needs-oauth"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[o.jsxs("button",{className:"btn btn-primary",onClick:oe,children:["Connect ",e.name," Account"]}),o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),_==="ready"&&!t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[o.jsx("button",{className:"btn btn-primary",onClick:z,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&o.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),x(!1)},children:"Change Credentials"})]})]}),_==="ready"&&t&&!t.running&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[o.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:z,disabled:E,children:E?"Starting...":"Start"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:R,children:"Disable"})]})]})]})}function ey(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=Sl(),[s,i]=d.useState(""),l=d.useCallback(c=>{i(c),setTimeout(()=>i(""),5e3)},[]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Integrations"}),o.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),s&&o.jsx("div",{className:"alert alert-success",children:s}),e?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?o.jsxs("div",{className:"status-banner status-banner-error",children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):o.jsxs(o.Fragment,{children:[r.map(c=>o.jsx(Zv,{manifest:c.manifest,integration:c.integration,state:c.state,onStatusChange:a,onSuccess:l},c.id)),r.length===0&&(n?o.jsxs("div",{className:"status-banner status-banner-error",children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",o.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):o.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."}))]})]})}function ty(){var H,W,B;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=ze(),[a,s]=d.useState(null),[i,l]=d.useState(!1),[c,u]=d.useState(""),[p,f]=d.useState(""),[v,y]=d.useState(!1),[x,w]=d.useState(""),[j,h]=d.useState("");d.useEffect(()=>{fetch("/health").then(_=>_.json()).then(_=>{typeof _.spUrl=="string"&&h(_.spUrl)}).catch(()=>{})},[]),d.useEffect(()=>{if(!e){s(null);return}M.getGroupById(e.id).then(_=>{const D=_.group??_,X=_.members??[],oe=_.isAdmin??!1,z=X.map(R=>{const $=R.userId||R.id||"",L=R.role||(oe&&$===D.createdBy?"admin":"member");return{id:$,name:R.name||$.slice(0,8)||"Member",email:R.email||"",domains:R.domains||[],role:L,isAdmin:L==="admin"||oe&&$===D.createdBy}});s({id:D.id,name:D.name,members:z})}).catch(()=>s(null))},[e==null?void 0:e.id]);const m=(a==null?void 0:a.members.filter(_=>_.isAdmin))??[],g=(e==null?void 0:e.isAdmin)===!0&&m.length<=1&&m.some(_=>_.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",E=x.trim()===S&&!i,I=()=>{w(""),y(!0)},k=()=>{y(!1),w("")},N=async()=>{if(!(!e||!E)){l(!0),u("");try{await M.leaveTeam(e.id),await n(),f("You have left the team."),s(null),k()}catch(_){u(_ instanceof Error?_.message:"Failed to leave team")}finally{l(!1)}}},C=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,P=j?`${j}/dashboard/groups`:void 0;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"page-header",children:o.jsxs("div",{children:[o.jsx("h1",{className:"page-title",children:"Team"}),o.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Service Provider dashboard."})]})}),c&&o.jsx("div",{className:"error-message",children:c}),p&&o.jsx("div",{className:"alert alert-success",children:p}),e?o.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[o.jsxs("div",{className:"card-header",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"card-title",children:e.name}),o.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((H=a==null?void 0:a.members)==null?void 0:H.length)??0," ",(((W=a==null?void 0:a.members)==null?void 0:W.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),o.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(B=a==null?void 0:a.members)==null?void 0:B.map(_=>o.jsxs("div",{className:"member-row",children:[o.jsx("div",{className:"member-avatar",children:_.name.split(" ").map(D=>D[0]).join("").slice(0,2).toUpperCase()}),o.jsxs("div",{className:"member-info",children:[o.jsx("div",{className:"member-name",children:_.name}),o.jsx("div",{className:"member-email",children:_.email})]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:_.role})]},_.id)),o.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[C&&o.jsx("a",{className:"btn btn-secondary btn-sm",href:C,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),o.jsx("span",{title:g?"You are the only admin. Transfer admin to another member in your Service Provider dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:I,disabled:i||g,children:"Leave team"})})]})]}):o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[o.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every authorization you create here is in your personal context. You can join an existing team or create a new one in your Service Provider dashboard."}),P&&o.jsx("a",{className:"btn btn-primary btn-sm",href:P,target:"_blank",rel:"noopener noreferrer",children:"Open Service Provider dashboard →"})]}),v&&e&&o.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:k,children:o.jsxs("div",{className:"card",onClick:_=>_.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[o.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",S,"?"]}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),o.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[o.jsx("li",{children:"Revoke all authorizations you created in this team's context"}),o.jsx("li",{children:"Reject any pending action proposals you authored"}),o.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),o.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",o.jsx("strong",{children:"personal"})," authorizations are not affected."]}),o.jsxs("div",{className:"form-group",children:[o.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",o.jsx("code",{children:S})," to confirm:"]}),o.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:x,onChange:_=>w(_.target.value),placeholder:S,disabled:i,autoFocus:!0})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:k,disabled:i,children:"Cancel"}),o.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:N,disabled:!E,children:i?"Leaving...":"Leave team"})]})]})})]})}function ny({onDismiss:e}){const t=Vt(),{group:n,groupId:r,domain:a}=ze(),[s,i]=d.useState([]),[l,c]=d.useState([]),[u,p]=d.useState([]),[f,v]=d.useState(!0),[y,x]=d.useState({}),[w,j]=d.useState(null);d.useEffect(()=>{Promise.all([M.listProfiles().catch(()=>[]),M.getIntegrationManifests().then(k=>k.manifests??[]).catch(()=>[]),M.getMcpHealth().then(k=>k.integrations??[]).catch(()=>[])]).then(async([k,N,C])=>{if(i(k),c(N),p(C),r){const P=await Promise.all(k.map(W=>M.getTeamProfileConfig(r,W.id).catch(()=>null))),H={};k.forEach((W,B)=>{const _=P[B];_&&(H[W.id]=_)}),x(H)}}).finally(()=>v(!1))},[r]);const h=new Map,m=new Map;for(const k of l)k.profile&&h.set(k.profile,k);for(const k of u){const N=l.find(C=>C.id===k.id);N!=null&&N.profile&&m.set(N.profile,k)}const g=s.filter(k=>{const N=k.id.replace(/@.*$/,"").split("/").pop()??k.id;return h.has(N)}),S=k=>k in y,E=(k,N)=>{if(!r){console.error("No active group when creating authorization");return}const C=S(k);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:k,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:a,isTeam:C})),N?sessionStorage.setItem("agentGate",JSON.stringify({bounds:N.bounds,context:N.context,gateContent:{intent:N.intent},ttlConfig:{max:N.ttl},templateMode:N.mode,templateTtl:N.ttl})):sessionStorage.removeItem("agentGate"),j(null),e==null||e(),t("/agent/gate")},I=k=>{if(!r)return;const N=k.replace(/@.*$/,"").split("/").pop()??k,C=h.get(N);C!=null&&C.templates&&C.templates.length>0?j({profileId:k,manifest:C}):E(k)};if(w){const k=w.manifest.templates??[];return o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginBottom:"1rem"},onClick:()=>j(null),children:"← Back to profiles"}),o.jsxs("h3",{style:{margin:"0 0 0.25rem 0",fontSize:"1rem"},children:["Set up ",w.manifest.name," authorization"]}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.5rem",marginBottom:"0.75rem",fontWeight:600},children:"Quick start"}),o.jsx("div",{style:{display:"grid",gap:"0.75rem",gridTemplateColumns:`repeat(${Math.min(k.length,3)}, 1fr)`},children:k.map(N=>o.jsxs("button",{className:"template-card",onClick:()=>E(w.profileId,N),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[o.jsx("span",{className:`template-mode template-mode-${N.mode==="automatic"?"auto":"review"}`,children:N.mode==="automatic"?"Auto":"Review"}),o.jsx("span",{className:"template-risk","data-risk":N.risk,children:N.risk})]}),o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:N.name}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:N.description}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:N.tags.map(C=>o.jsx("span",{className:"template-tag",children:C},C))})]},N.name))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",margin:"1.5rem 0"},children:[o.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}}),o.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"or"}),o.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}})]}),o.jsx("button",{className:"btn btn-primary",style:{width:"100%",textAlign:"center",padding:"0.75rem"},onClick:()=>E(w.profileId),children:"Custom — define your own limits and scope"})]})}return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:`
65
+ .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
66
+ .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
67
+ @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
68
+ @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
69
+ `}),f?o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):g.length===0?o.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[o.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),o.jsx(Ze,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):o.jsx("div",{className:"profile-grid",children:g.map(k=>{const N=S(k.id),C=k.id.replace(/@.*$/,"").split("/").pop()??k.id,P=h.get(C),H=m.get(C),W=(H==null?void 0:H.running)===!0;return o.jsxs("div",{className:"card",style:W?void 0:{opacity:.7},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[o.jsx("h3",{className:"card-title",style:{margin:0},children:Ee(k.id,k.name)}),N?o.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"})]}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:k.description}),W?o.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>I(k.id),children:"Authorize"}):o.jsxs(Ze,{to:`/integrations?setup=${(P==null?void 0:P.id)??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",(P==null?void 0:P.name)??"integration"]})]},k.id)})})]})}const ry={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function ay({status:e,label:t}){return o.jsx("span",{className:`status-badge status-${e}`,children:t||ry[e]})}function oy({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return o.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const xn=86400,Er=3600,Ia=60,sy=30*xn;function iy(e){if(e<=0)return"Expired";if(e>90*xn){const t=Math.floor(e/sy);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*xn){const t=Math.floor(e/xn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*xn){const t=Math.floor(e/xn),n=Math.floor(e%xn/Er);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Er){const t=Math.floor(e/Er),n=Math.floor(e%Er/Ia);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Ia){const t=Math.floor(e/Ia),n=Math.floor(e%Ia);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function ly({expiresAt:e}){const[t,n]=d.useState(()=>e-Date.now()/1e3),r=t<2*Er;d.useEffect(()=>{const s=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(s)},[e,r]);const a=t<300;return o.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:iy(t)})}function Df({icon:e,title:t,text:n,children:r}){return o.jsxs("div",{className:"empty-state",children:[e&&o.jsx("div",{className:"empty-state-icon",children:e}),o.jsx("div",{className:"empty-state-title",children:t}),n&&o.jsx("div",{className:"empty-state-text",children:n}),r]})}function cy(e){const t=Math.floor(e/86400);if(t>=1)return`${t} day${t===1?"":"s"}`;const n=Math.floor(e/3600);if(n>=1)return`${n} hour${n===1?"":"s"}`;const r=Math.ceil(e/60);return`${r} minute${r===1?"":"s"}`}const uy=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function dy({item:e,onClose:t,onSuccess:n}){var h;const{user:r,activeDomain:a,groupId:s}=ze(),i=e.remaining_seconds??0,l=uy.filter(m=>m.seconds>i),c=((h=l[0])==null?void 0:h.seconds)??2592e3,[u,p]=d.useState(c),[f,v]=d.useState(!1),[y,x]=d.useState(""),w=Object.entries(e.frame).filter(([m])=>m!=="profile"&&m!=="path"),j=async()=>{var m;if(r){v(!0),x("");try{const g=e.authorization_id,S=await M.getGateContent(g);if(!S)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const E=await M.getProfile(e.profile_id),I=e.frame,k=S.context??{},N=e.attested_domains[0]||a||"owner",C=await Ha(I,E),P=await Of(k,E),[H,W]=await Promise.all([yo(S.gateContent.intent),yo(JSON.stringify({profile:e.profile_id,path:e.path,domain:N}))]);if(!s)throw new Error("No active group; cannot extend authorization.");const B=(((m=e.deferred_commitment_domains)==null?void 0:m.length)??0)>0?"review":"automatic",_=await M.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:I,bounds_hash:C,context_hash:P,domain:N,did:r.did,gate_content_hashes:{intent:H},execution_context_hash:W,group_id:s,commitment_mode:B,ttl:u});await M.pushGateContent(Bf(_,{boundsHash:C,contextHash:P,context:k,path:e.path,gateContent:S.gateContent})),n()}catch(g){x(g instanceof Error?g.message:"Extension failed")}finally{v(!1)}}};return o.jsx("div",{className:"modal-backdrop",onClick:m=>m.target===m.currentTarget&&t(),children:o.jsxs("div",{className:"modal",children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h3",{className:"modal-title",children:"Extend Authorization"}),o.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),o.jsxs("div",{className:"modal-body",children:[o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Ee(e.profile_id)," / ",e.path]}),w.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:w.map(([m,g])=>`${m}=${g}`).join(" · ")})]}),o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),i>0&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",cy(i),". Only longer durations are shown."]}),o.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:l.length===0?o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This authorization is already on the longest available duration. Nothing to extend."}):l.map(m=>o.jsx("button",{className:`btn ${u===m.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(m.seconds),style:{minWidth:"3.5rem"},children:m.label},m.seconds))})]}),o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, context, and gate content will be re-attested with a new TTL (measured from now)."}),y&&o.jsx("div",{className:"error-message",children:y})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:f,children:"Cancel"}),o.jsx("button",{className:"btn btn-primary",onClick:j,disabled:f,children:f?"Extending...":"Extend"})]})]})})}function fy(e,t,n){return[...e].sort((r,a)=>{if(n){if(r.authorization_id===n&&a.authorization_id!==n)return-1;if(a.authorization_id===n&&r.authorization_id!==n)return 1}const s=Nt(r,{revokedSet:t}),i=Nt(a,{revokedSet:t}),l={active:0,pending:1,expired:2,revoked:3};return l[s]!==l[i]?l[s]-l[i]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function my({item:e,revokedSet:t,expandedHash:n,gateCache:r,gateLoading:a,copiedHash:s,revokingHash:i,copyingHash:l,profileConfigCache:c,mode:u,ownerLabel:p,isAdmin:f,onExpand:v,onCopyHash:y,onCopy:x,onRevoke:w,onExtend:j,highlightHash:h}){var $;const m=Nt(e,{revokedSet:t}),g=n===e.authorization_id,S=r[e.authorization_id],E=m==="active"||m==="pending"||m==="expired",I=Object.entries(e.frame).filter(([L])=>L!=="profile"&&L!=="path"),k=c.get(e.profile_id)??null,N=((($=k==null?void 0:k.approvers)==null?void 0:$.length)??0)>0,C=new Map;if(k!=null&&k.caps&&u==="team")for(const[L,V]of I){const ee=k.caps[L];ee!==void 0&&Number(V)>ee&&C.set(L,{authorized:Number(V),cap:ee})}const P=C.size>0,H=e.approvers_frozen??[],W=(k==null?void 0:k.approvers)??[],B=u==="team"&&H.length>0&&W.length>0&&(H.length!==W.length||H.some(L=>!W.includes(L))||W.some(L=>!H.includes(L))),_=Array.from(C.entries()).map(([L,V])=>`${L}: ${V.authorized} (cap ${V.cap})`).join(", "),D=Array.from(C.entries()).map(([L,V])=>`${L}: ${V.authorized} → ${V.cap}`).join(", "),X=P?N?C.size===1?`Above team cap: ${_} — actions require approval`:`Above team cap (${C.size}): ${_} — actions require approval`:C.size===1?`Reduced by hard cap: ${D}`:`Reduced by hard cap (${C.size}): ${D}`:"",oe=P?N?"Above-cap actions under this authority require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this authorization to reissue within the cap.":void 0,z=Ee(e.profile_id),R=h!=null&&e.authorization_id===h;return o.jsxs("div",{className:`card${R?" card-highlight":""}`,style:{marginBottom:0},children:[p&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",o.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:p})]}),o.jsxs("div",{className:"auth-card-header",children:[o.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:z}),e.title&&o.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),o.jsx(ay,{status:m}),m==="active"&&e.earliest_expiry&&o.jsx(ly,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),m==="expired"&&o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:new Date(e.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(L=>o.jsx(oy,{domain:L,attested:e.attested_domains.includes(L)},L)),e.deferred_commitment_domains.length>0&&o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),P&&o.jsx("span",{title:oe,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:N?"var(--accent-subtle)":"var(--danger-subtle)",color:N?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:X}),B&&o.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>x(e),disabled:l===e.authorization_id,title:"The approver list for this profile has changed since this authority was created. Copy to reissue with the current approvers.",children:l===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),I.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:I.map(([L,V],ee)=>{const J=C.get(L);return o.jsxs("span",{children:[ee>0&&" · ",J?N?o.jsxs("span",{title:`Team cap on ${L} is ${J.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${J.authorized}.`,children:[o.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[L,"=",String(V)]}),o.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",J.cap]})]}):o.jsxs("span",{title:`Team cap on ${L} is ${J.cap} with no approvers configured (hard cap). Authorized for ${J.authorized}; effective ${J.cap}.`,children:[o.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[L,"=",String(V)]}),o.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",J.cap]})]}):o.jsxs("span",{children:[L,"=",String(V)]})]},L)})}),o.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>v(e),children:g?"▲ Hide Details":"▼ Details"})}),g&&o.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[I.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),o.jsx("dl",{className:"review-grid",children:I.map(([L,V])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:L}),o.jsx("dd",{children:String(V)})]},L))})]}),(S==null?void 0:S.context)&&Object.keys(S.context).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Context"}),o.jsx("dl",{className:"review-grid",children:Object.entries(S.context).map(([L,V])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:L}),o.jsx("dd",{children:String(V)})]},L))})]}),o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),a===e.authorization_id?o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):S?o.jsx("div",{className:"gate-content-block",children:o.jsx("div",{className:"gate-content-item",children:o.jsx("div",{className:"gate-content-text",children:S.gateContent.intent})})}):o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),o.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>y(e.authorization_id),children:s===e.authorization_id?"copied":"copy"})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!p&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e),disabled:l===e.authorization_id,title:"Start a new authorization pre-filled with these bounds, context, and intent",children:l===e.authorization_id?"Copying…":"⧉ Copy"}),!p&&(m==="active"||m==="pending")&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e,{asEdit:!0}),disabled:l===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new authorization revokes this one",children:"✎ Edit"}),!p&&E&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>j(e),children:"↻ Extend"}),p&&f&&m!=="revoked"?o.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>w(e.authorization_id,p,z),disabled:i===e.authorization_id,children:i===e.authorization_id?"Revoking…":"Revoke"}):!p&&(m==="active"||m==="pending")?o.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>w(e.authorization_id),disabled:i===e.authorization_id,children:i===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function py(){const[e,t]=d.useState([]),[n,r]=d.useState(!0),[a,s]=d.useState([]),[i,l]=d.useState(!1),[c,u]=d.useState("mine"),[p,f]=d.useState("active"),[v,y]=d.useState(null),[x,w]=d.useState(null),[j,h]=If(),[m,g]=d.useState(()=>j.get("new")==="1"),[S,E]=d.useState(()=>j.get("highlight")),[I,k]=d.useState(null),[N,C]=d.useState({}),[P,H]=d.useState(null),[W,B]=d.useState(null),[_,D]=d.useState(null),[X,oe]=d.useState(new Set),[z,R]=d.useState(null),[$,L]=d.useState(null),V=Vt(),{group:ee,groupId:J,domain:je,mode:b,activeTeam:U}=ze(),A=(U==null?void 0:U.isAdmin)===!0,[T,Y]=d.useState(()=>new Map),xe=d.useCallback(()=>{r(!0),M.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),Ie=d.useCallback(()=>{J&&(l(!0),M.listTeamAuthorizations(J).then(s).catch(()=>{}).finally(()=>l(!1)))},[J]);fe("attestation-changed",()=>{xe(),A&&J&&Ie()}),d.useEffect(()=>{if(!S)return;j.get("highlight")&&(j.delete("highlight"),h(j,{replace:!0}));const K=window.setTimeout(()=>E(null),3e3);return()=>window.clearTimeout(K)},[]),Mt(xe,3e5),d.useEffect(()=>{c==="team"&&A&&J&&a.length===0&&!i&&Ie()},[c,A,J,a.length,i,Ie]),d.useEffect(()=>{if(b!=="team"||!J)return;const K=c==="mine"?e:a;if(K.length===0)return;const O=[...new Set(K.map(Q=>Q.profile_id))].filter(Q=>!T.has(Q));if(O.length!==0){Y(Q=>{const q=new Map(Q);for(const ne of O)q.set(ne,null);return q});for(const Q of O)M.getTeamProfileConfig(J,Q).then(q=>{Y(ne=>new Map(ne).set(Q,q))}).catch(()=>{})}},[e,a,c,J,b,T]);const ke=async K=>{if(I===K.authorization_id){k(null);return}k(K.authorization_id);const O=K.authorization_id;if(!(O in N)){H(K.authorization_id);try{const Q=await M.getGateContent(O);C(q=>({...q,[O]:Q}))}catch{C(Q=>({...Q,[O]:null}))}finally{H(null)}}},hn=K=>{navigator.clipboard.writeText(K).then(()=>{D(K),setTimeout(()=>D(null),2e3)})},_n=async(K,O)=>{var Q;if(!J){alert("No active group; cannot copy authorization.");return}L(K.authorization_id);try{const q=K.authorization_id;let ne=N[q]??null;q in N||(ne=await M.getGateContent(q),C(Je=>({...Je,[q]:ne})));const Me=Object.fromEntries(Object.entries(K.frame).filter(([Je])=>Je!=="profile"&&Je!=="path")),Ye=(ne==null?void 0:ne.context)??{},ht=((Q=ne==null?void 0:ne.gateContent)==null?void 0:Q.intent)??"",Rt=K.deferred_commitment_domains.length>0?"review":"automatic",Qe=K.attested_domains[0]||je||"owner";sessionStorage.setItem("agentAuth",JSON.stringify({profileId:K.profile_id,groupId:J,groupName:(ee==null?void 0:ee.name)??null,domain:Qe})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Me,context:Ye,gateContent:{intent:ht},templateMode:Rt})),O!=null&&O.asEdit?sessionStorage.setItem("agentEditReplaces",K.authorization_id):sessionStorage.removeItem("agentEditReplaces"),V("/agent/gate")}catch(q){alert(q instanceof Error?q.message:"Failed to copy authorization")}finally{L(null)}},Tt=async(K,O,Q)=>{const q=O&&Q?`Revoke ${O}'s ${Q} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(q)){R(K);try{await M.revokeAttestation(K),oe(ne=>new Set(ne).add(K)),M.resyncGates().catch(()=>{}),O&&J&&Ie()}catch(ne){alert(ne instanceof Error?ne.message:"Failed to revoke authorization")}finally{R(null)}}},Ue=c==="mine"?e:a,mr=c==="mine"?n:i,Kt={active:Ue.filter(K=>Nt(K,{revokedSet:X})==="active").length,pending:Ue.filter(K=>Nt(K,{revokedSet:X})==="pending").length,expired:Ue.filter(K=>Nt(K,{revokedSet:X})==="expired").length,revoked:Ue.filter(K=>Nt(K,{revokedSet:X})==="revoked").length},re=(()=>{const K=new Map;for(const O of Ue){if(Nt(O,{revokedSet:X})!==p)continue;const Q=K.get(O.profile_id)??{count:0,review:!1};Q.count+=1,O.deferred_commitment_domains.length>0&&(Q.review=!0),K.set(O.profile_id,Q)}return Array.from(K.entries()).map(([O,Q])=>({profileId:O,...Q})).sort((O,Q)=>Ee(O.profileId).localeCompare(Ee(Q.profileId)))})(),pt=fy(Ue.filter(K=>{if(Nt(K,{revokedSet:X})!==p||v!==null&&K.profile_id!==v)return!1;if(x!==null){const O=K.deferred_commitment_domains.length>0;if(x==="review"&&!O||x==="auto"&&O)return!1}return!0}),X,S),ca={revokedSet:X,expandedHash:I,gateCache:N,gateLoading:P,copiedHash:_,revokingHash:z,copyingHash:$,profileConfigCache:T,mode:b,activeDomain:je,group:ee,groupId:J,onExpand:ke,onCopyHash:hn,onCopy:_n,onRevoke:Tt,onExtend:B,highlightHash:S};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[o.jsxs("div",{children:[o.jsx("h1",{className:"page-title",children:"Authorizations"}),o.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),o.jsx("button",{className:"btn btn-primary",onClick:()=>g(!0),children:"+ New authorization"})]}),m&&o.jsx("div",{className:"modal-backdrop",onClick:()=>{g(!1),j.get("new")&&(j.delete("new"),h(j,{replace:!0}))},children:o.jsxs("div",{className:"modal",onClick:K=>K.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h2",{className:"modal-title",children:"New authorization"}),o.jsx("button",{className:"modal-close",onClick:()=>{g(!1),j.get("new")&&(j.delete("new"),h(j,{replace:!0}))},children:"×"})]}),o.jsxs("div",{className:"modal-body",children:[o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),o.jsx(ny,{onDismiss:()=>g(!1)})]})]})}),A&&o.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[o.jsx("button",{className:`nav-tab${c==="mine"?" active":""}`,onClick:()=>{u("mine"),f("active"),y(null),w(null),k(null)},children:"Mine"}),o.jsx("button",{className:`nav-tab${c==="team"?" active":""}`,onClick:()=>{u("team"),f("active"),y(null),w(null),k(null)},children:"Team"})]}),o.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(K=>o.jsxs("button",{className:`nav-tab${p===K?" active":""}`,onClick:()=>{f(K),y(null),w(null)},children:[K.charAt(0).toUpperCase()+K.slice(1)," (",Kt[K],")"]},K))}),re.length>0&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[re.map(K=>{const O=v===K.profileId;return o.jsx("button",{className:`btn btn-sm ${O?"btn-primary":"btn-secondary"}`,onClick:()=>y(O?null:K.profileId),children:Ee(K.profileId)},K.profileId)}),o.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(K=>{const O=x===K;return o.jsx("button",{className:`btn btn-sm ${O?"btn-primary":"btn-secondary"}`,onClick:()=>w(O?null:K),children:K==="auto"?"Auto":"Review"},K)})]}),mr&&Ue.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):pt.length===0?o.jsx(Df,{icon:"☰",title:"No authorizations",text:`No ${p} authorizations found.`}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:pt.map(K=>{const O=c==="team"?K:null,Q=O!=null&&O.owner?O.owner.name??O.owner.email??O.owner.userId:void 0;return o.jsx(my,{item:K,ownerLabel:Q,isAdmin:A,...ca},K.authorization_id)})}),W&&o.jsx(dy,{item:W,onClose:()=>B(null),onSuccess:()=>{B(null),xe()}})]})}function Uf({profileId:e}){return o.jsx("span",{className:"profile-badge",children:Ee(e)})}function hy(e){return new Date(e*1e3).toLocaleString()}function gy(e,t){if(t==="all")return!0;const n=t==="1d"?1:t==="7d"?7:30,r=Math.floor(Date.now()/1e3)-n*86400;return e.timestamp>=r}function vy(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Ee(e.profileId).toLowerCase().includes(n)||e.path.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||e.attestationHash.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||JSON.stringify(e.executionContext).toLowerCase().includes(n)}function Kc(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,a)=>a.timestamp-r.timestamp)}function yy(){const{activeTeam:e,groupId:t}=ze(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=d.useState("mine"),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState({}),[f,v]=d.useState(new Set),[y,x]=d.useState(""),[w,j]=d.useState(new Set),[h,m]=d.useState(new Set),[g,S]=d.useState("all"),[E,I]=d.useState(!1),[k,N]=d.useState(null),[C,P]=d.useState(!1),[H,W]=d.useState(!1),B=d.useRef(""),_=d.useCallback(b=>r==="team"&&n&&t?M.listTeamReceiptsPage(t,{before:b,limit:200}):M.getMyReceiptsPage({before:b,limit:200}),[r,n,t]),D=d.useCallback(()=>{const b=r==="team"?`team:${t}`:"mine",U=B.current!==b;B.current=b,c(!0),W(!1),_().then(A=>{i(T=>U?A.receipts:Kc(T,A.receipts)),N(T=>U?A.nextBefore:T??A.nextBefore)}).catch(()=>{U&&i([]),W(!0)}).finally(()=>c(!1))},[_,r,t]),X=d.useCallback(()=>{!k||C||(P(!0),W(!1),_(k).then(b=>{i(U=>Kc(U,b.receipts)),N(b.nextBefore)}).catch(()=>W(!0)).finally(()=>P(!1)))},[k,C,_]);Mt(D,12e4),d.useEffect(()=>{r!=="team"||Object.keys(u).length>0||M.listUsers().then(b=>{const U={};for(const A of b)U[A.id]={name:A.name,email:A.email};p(U)}).catch(()=>{})},[r,u]);const oe=d.useMemo(()=>{const b=new Set;for(const U of s)b.add(Ee(U.profileId));return[...b].sort()},[s]),z=d.useMemo(()=>{const b=new Set;for(const U of s)b.add(U.action);return[...b].sort()},[s]),R=d.useMemo(()=>{if(r!=="team")return[];const b=new Set;for(const U of s)U.userId&&b.add(U.userId);return[...b].map(U=>{var A;return{id:U,label:(A=u[U])!=null&&A.name?`${u[U].name} (${u[U].email})`:U}}).sort((U,A)=>U.label.localeCompare(A.label))},[r,s,u]),$=d.useMemo(()=>s.filter(b=>!(!vy(b,y)||w.size>0&&!w.has(Ee(b.profileId))||h.size>0&&!h.has(b.action)||f.size>0&&b.userId&&!f.has(b.userId)||!gy(b,g))),[s,y,w,h,f,g]),L=w.size>0||h.size>0||f.size>0||g!=="all";function V(b){j(U=>{const A=new Set(U);return A.has(b)?A.delete(b):A.add(b),A})}function ee(b){m(U=>{const A=new Set(U);return A.has(b)?A.delete(b):A.add(b),A})}function J(b){v(U=>{const A=new Set(U);return A.has(b)?A.delete(b):A.add(b),A})}function je(){j(new Set),m(new Set),v(new Set),S("all"),x("")}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Receipts"}),o.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),n&&o.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(b=>o.jsx("button",{onClick:()=>a(b),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===b?"2px solid var(--accent)":"2px solid transparent",color:r===b?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===b?600:500},children:b==="mine"?"Mine":"Team"},b))}),o.jsxs("div",{className:"search-filter-bar",children:[o.jsxs("div",{className:"search-input-wrap",children:[o.jsx("span",{className:"search-icon",children:"⌕"}),o.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:y,onChange:b=>x(b.target.value)}),y&&o.jsx("button",{className:"search-clear",onClick:()=>x(""),children:"×"})]}),o.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>I(!E),children:["Filters",L?` (${w.size+h.size+(g!=="all"?1:0)})`:""]})]}),E&&o.jsxs("div",{className:"filter-panel",children:[oe.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Profile"}),o.jsx("div",{className:"filter-chips",children:oe.map(b=>o.jsx("button",{className:`filter-chip${w.has(b)?" selected":""}`,onClick:()=>V(b),children:b},b))})]}),z.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Action"}),o.jsx("div",{className:"filter-chips",children:z.map(b=>o.jsx("button",{className:`filter-chip${h.has(b)?" selected":""}`,onClick:()=>ee(b),children:b},b))})]}),r==="team"&&R.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Owner"}),o.jsx("div",{className:"filter-chips",children:R.map(b=>o.jsx("button",{className:`filter-chip${f.has(b.id)?" selected":""}`,onClick:()=>J(b.id),children:b.label},b.id))})]}),o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Time range"}),o.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([b,U])=>o.jsx("button",{className:`filter-chip${g===b?" selected":""}`,onClick:()=>S(b),children:U},b))})]})]}),L&&o.jsxs("div",{className:"active-filters",children:[[...w].map(b=>o.jsxs("span",{className:"active-chip",onClick:()=>V(b),children:[b," ",o.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...h].map(b=>o.jsxs("span",{className:"active-chip",onClick:()=>ee(b),children:[b," ",o.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...f].map(b=>{const U=u[b],A=U?U.name:b;return o.jsxs("span",{className:"active-chip",onClick:()=>J(b),children:[A," ",o.jsx("span",{className:"chip-remove",children:"×"})]},b)}),g!=="all"&&o.jsxs("span",{className:"active-chip",onClick:()=>S("all"),children:[g==="1d"?"Today":g==="7d"?"7 days":"30 days"," ",o.jsx("span",{className:"chip-remove",children:"×"})]}),o.jsx("button",{className:"clear-filters",onClick:je,children:"Clear all"})]}),H&&o.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:o.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load receipts — your session may have expired. Try signing out and back in."})}),l&&s.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$.length===0?o.jsx(Df,{icon:"⌕",title:s.length===0?"No receipts in the last 30 days":"No matching receipts",text:s.length===0?"Execution receipts appear here after an agent uses an authorized tool. Older receipts can be loaded below.":"Try adjusting your search or filters."}):o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:$.length===s.length?`${s.length} receipt${s.length!==1?"s":""}`:`${$.length} of ${s.length} receipts`}),o.jsx("div",{className:"timeline",children:$.map(b=>{var U;return o.jsx("div",{className:"timeline-event",children:o.jsxs("div",{className:"card",style:{marginBottom:0},children:[o.jsxs("div",{className:"auth-card-header",children:[o.jsx(Uf,{profileId:b.profileId}),o.jsx("span",{className:"auth-card-path",children:b.path}),o.jsx("span",{className:"receipt-action",children:b.action}),o.jsx("span",{className:"auth-card-time",children:hy(b.timestamp)})]}),r==="team"&&b.userId&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner:"," ",o.jsx("span",{style:{color:"var(--text-secondary)"},children:(U=u[b.userId])!=null&&U.name?`${u[b.userId].name} (${u[b.userId].email})`:b.userId})]}),Object.keys(b.executionContext).length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:Object.entries(b.executionContext).map(([A,T])=>`${A}=${T}`).join(" · ")}),o.jsxs("div",{style:{display:"flex",gap:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:[o.jsxs("span",{children:["Daily: ",b.cumulativeState.daily.count," calls, $",b.cumulativeState.daily.amount]}),o.jsxs("span",{children:["Monthly: ",b.cumulativeState.monthly.count," calls, $",b.cumulativeState.monthly.amount]})]}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all",marginTop:"0.375rem"},children:b.attestationHash})]})},b.id)})})]}),k&&o.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:X,disabled:C,children:C?"Loading…":"Load older"})})]})}const Gc={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}};function xy(){const[e,t]=d.useState(""),[n,r]=d.useState("openrouter"),[a,s]=d.useState("openai-compatible"),[i,l]=d.useState("https://openrouter.ai/api/v1"),[c,u]=d.useState("google/gemma-4-31b-it"),[p,f]=d.useState(""),[v,y]=d.useState(!1),[x,w]=d.useState(!1),[j,h]=d.useState(!1),[m,g]=d.useState(null),S=d.useCallback(C=>{t(C),setTimeout(()=>t(""),3e3)},[]),E=d.useCallback(async()=>{try{const C=await M.getCredential("ai-config");if(y(C.configured),C.configured&&C.fields){C.fields.provider&&s(C.fields.provider),C.fields.endpoint&&l(C.fields.endpoint),C.fields.model&&u(C.fields.model);const P=C.fields.endpoint??"";P.includes("openai.com")?r("openai"):P.includes("groq.com")?r("groq"):P.includes("together.xyz")?r("together"):P.includes("openrouter.ai")?r("openrouter"):r("ollama")}}catch{}},[]);d.useEffect(()=>{E()},[E]);const I=C=>{r(C);const P=Gc[C];P&&(s(P.provider),l(P.endpoint),u(P.models[0]))},k=async()=>{w(!0);try{await M.setCredential("ai-config",{provider:a,endpoint:i,model:c,...p?{apiKey:p}:{}}),y(!0),S("AI configuration saved!")}catch{S("Failed to save AI config")}finally{w(!1)}},N=async()=>{h(!0),g(null);try{const C=await M.aiTest(p?{provider:a,endpoint:i,model:c,apiKey:p}:{});g(C.ok?`OK: ${C.message}`:`Failed: ${C.message}`)}catch(C){g(`Error: ${C instanceof Error?C.message:"Unknown"}`)}finally{h(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"AI Assistant"}),o.jsx("p",{className:"page-subtitle",children:"Advisory AI to help you think through intent when authorizing agents."})]}),e&&o.jsx("div",{className:"alert alert-success",children:e}),o.jsxs("div",{className:"card",children:[o.jsx("h3",{className:"card-title",children:"Configuration"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through authorizations. Keys are encrypted in your vault."}),v&&o.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[o.jsx("span",{className:"status-banner-icon",children:"✓"}),o.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:"Provider Preset"}),o.jsxs("select",{className:"form-input",value:n,onChange:C=>I(C.target.value),children:[o.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),o.jsx("option",{value:"ollama",children:"Ollama (local)"}),o.jsx("option",{value:"openai",children:"OpenAI"}),o.jsx("option",{value:"groq",children:"Groq"}),o.jsx("option",{value:"together",children:"Together"})]})]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:"Model"}),(()=>{var H;const C=((H=Gc[n])==null?void 0:H.models)??[],P=C.includes(c);return o.jsxs(o.Fragment,{children:[o.jsxs("select",{className:"form-input",value:P?c:"__custom__",onChange:W=>{W.target.value==="__custom__"?u(""):u(W.target.value)},style:{marginBottom:P?void 0:"0.375rem"},children:[C.map(W=>o.jsx("option",{value:W,children:W},W)),o.jsx("option",{value:"__custom__",children:"Custom model..."})]}),!P&&o.jsx("input",{className:"form-input",value:c,onChange:W=>u(W.target.value),placeholder:"Enter model name"})]})})()]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"1rem"},children:[o.jsx("label",{className:"form-label",children:"API Key (if required)"}),o.jsx("input",{className:"form-input",type:"password",value:p,onChange:C=>f(C.target.value),placeholder:v?"••••••••••••••••":"sk-... (not needed for Ollama)"})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[o.jsx("button",{className:"btn btn-primary",onClick:k,disabled:x,children:x?"Saving...":"Save & Encrypt"}),v&&o.jsx("button",{className:"btn btn-ghost",onClick:N,disabled:j,children:j?"Testing...":"Test Connection"})]}),m&&o.jsx("div",{className:`alert ${m.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:m})]}),o.jsx(wy,{}),o.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[o.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,marginBottom:"1rem"},children:"Security"}),o.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),o.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[o.jsx("li",{children:"Every tool call verified against your authorization bounds"}),o.jsx("li",{children:"Credentials never exposed to agents through MCP"}),o.jsx("li",{children:"Every action produces a signed receipt"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),o.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[o.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),o.jsx("li",{children:"For best security, run agents in sandboxed environments"}),o.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]})]})}function wy(){const[e,t]=d.useState(null),[n,r]=d.useState({intent:"",context:""}),[a,s]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(!1),v=d.useCallback(async()=>{if(!p)try{const w=await M.getAIPrompts();t(w),r({intent:w.intent.current,context:w.context.current}),f(!0)}catch(w){l(w instanceof Error?w.message:"Failed to load prompts")}},[p]),y=async w=>{if(e){s(w),l(null);try{const j=n[w],h=j.trim()===e[w].default.trim()?"":j;await M.setAIPrompt(w,h);const m=await M.getAIPrompts();t(m),r({intent:m.intent.current,context:m.context.current}),u(w),setTimeout(()=>u(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{s(null)}}},x=async w=>{if(confirm(`Revert ${w} prompt to the built-in default?`)){s(w),l(null);try{await M.setAIPrompt(w,"");const j=await M.getAIPrompts();t(j),r({intent:j.intent.current,context:j.context.current})}catch(j){l(j instanceof Error?j.message:"Revert failed")}finally{s(null)}}};return o.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:w=>{w.currentTarget.open&&v()},children:[o.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-authorization) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),i&&o.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:i}),!p&&!i&&o.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&o.jsxs(o.Fragment,{children:[o.jsx(Yc,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:w=>r(j=>({...j,intent:w})),onSave:()=>y("intent"),onRevert:()=>x("intent"),saving:a==="intent",justSaved:c==="intent"}),o.jsx(Yc,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:n.context,onChange:w=>r(j=>({...j,context:w})),onSave:()=>y("context"),onRevert:()=>x("context"),saving:a==="context",justSaved:c==="context"})]})]})}function Yc({kind:e,label:t,description:n,state:r,draft:a,onChange:s,onSave:i,onRevert:l,saving:c,justSaved:u}){const p=a!==r.current;return o.jsxs("section",{style:{marginBottom:"1.5rem"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),o.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),o.jsx("textarea",{className:"form-textarea",value:a,onChange:f=>s(f.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${t} system prompt`}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[o.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:i,disabled:c||!p,children:c?"Saving…":"Save"}),r.overridden&&o.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:l,disabled:c,title:"Discard the override and use the built-in default",children:"Revert to default"}),u&&o.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),p&&!c&&!u&&o.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),o.jsxs("details",{style:{marginTop:"0.5rem"},children:[o.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),o.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:r.default})]}),o.jsx("span",{style:{display:"none"},children:e})]})}function Sy(e){return e.proposalId?"review":"automatic"}function Qc(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,s=[];for(const i of e)r==="pending"&&i.status!=="pending"||n.profile&&i.profileId!==n.profile||s.push({kind:"proposal",id:i.id,sortTimestamp:i.createdAt,commitmentMode:"review",profileId:i.profileId,proposal:i});if(r==="all")for(const i of t){const l=Sy(i);!a&&l==="automatic"||n.profile&&i.profileId!==n.profile||s.push({kind:"receipt",id:i.id,sortTimestamp:i.timestamp,commitmentMode:l,profileId:i.profileId,receipt:i})}return s.sort((i,l)=>l.sortTimestamp-i.sortTimestamp),typeof n.limit=="number"&&n.limit>0?s.slice(0,n.limit):s}function Wf(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),a=Math.floor(n%86400/3600),s=Math.floor(n%3600/60);let i;return r>0?i=`expires in ${r}d ${a}h`:a>0?i=`expires in ${a}h ${s}m`:i=`expires in ${Math.max(1,s)}m`,{label:i,urgent:n<2*3600,expired:!1}}const jy={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},ky={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function Cy(e){const t=Date.now()-e*1e3,n=t/36e5;return n<48?n<1?`${Math.max(1,Math.round(t/6e4))}m ago`:`${Math.round(n)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function by(e){return e.split("__").pop()??e}function Ny(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Ey=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),zy=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Iy(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:zy.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function vi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>vi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Jc({item:e,onApprove:t,onReject:n,resolving:r}){const a=e.kind==="proposal",s=a?e.proposal.status:"executed",i=a?e.proposal.tool:e.receipt.action,l=by(i),c=Ny(i),u=a?e.proposal.toolArgs:null,p=a?e.proposal.executionContext:e.receipt.executionContext,f=a?null:e.receipt.cumulativeState,v=u?Object.entries(u).filter(([x])=>!Ey.has(x)):[],y=Object.entries(p??{});return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[o.jsx(Uf,{profileId:e.profileId}),o.jsx("code",{style:{fontSize:"0.85rem"},children:l}),e.commitmentMode==="automatic"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[a&&s==="pending"&&(()=>{const x=Wf(e.proposal.expiresAt,Date.now());return o.jsx("span",{style:{fontSize:"0.72rem",color:x.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:x.urgent?600:400,whiteSpace:"nowrap"},children:x.label})})(),o.jsx("span",{className:`status-badge ${ky[s]}`,children:jy[s]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Cy(e.sortTimestamp)})]})]}),c&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[o.jsx("span",{children:"⚠"}),o.jsx("span",{children:"Irreversible action"})]}),a&&typeof(u==null?void 0:u._imagePreview)=="string"&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),o.jsx("img",{src:u._imagePreview,alt:typeof(u==null?void 0:u.altText)=="string"?u.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),a&&v.length>0&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Arguments"}),o.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:v.map(([x,w])=>o.jsxs(d.Fragment,{children:[o.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:x}),o.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:Iy(x,w)?o.jsx("img",{src:w,alt:typeof(u==null?void 0:u.altText)=="string"?u.altText:x,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"},onError:j=>{const h=j.currentTarget,m=h.parentElement;if(!m)return;h.style.display="none";const g=document.createElement("span");g.textContent=w,g.style.color="var(--text-tertiary)",m.appendChild(g)}}):vi(w)})]},x))})]}),y.length>0&&o.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:y.map(([x,w])=>`${x}=${vi(w)}`).join(" · ")}),f&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",f.daily.count," action",f.daily.count===1?"":"s",f.daily.amount>0?`, ${f.daily.amount}`:""," · ","this month: ",f.monthly.count,f.monthly.amount>0?`, ${f.monthly.amount}`:""]}),a&&s==="pending"&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),o.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[a?"Proposal":"Receipt",": ",e.id]})]})}const Py=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function yi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>yi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ty(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Ry({proposal:e,currentUserId:t,onAction:n,onMessage:r}){const[a,s]=d.useState(!1),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(!1),[v,y]=d.useState(null),[x,w]=d.useState(!1),j=e.tool.split("__").pop()??e.tool,h=Object.entries(e.toolArgs).filter(([B])=>!Py.has(B)),m=Object.entries(e.executionContext),g=e.pendingApprovers??[],S=e.approvedBy??{},E=Object.keys(S).length,I=g.filter(B=>!(B in S)).length,k=t in S,N=async()=>{if(c===null){f(!0),y(null);try{const B=await M.getAttestationIntent(e.authorizationId);if(!B){y("Intent not available or you are not an authorized approver.");return}const _=await M.decryptIntent({intentCiphertext:B.intentCiphertext,encryptedKey:B.encryptedKey,approverId:t});u(_)}catch(B){y(B instanceof Error?B.message:"Failed to decrypt intent")}finally{f(!1)}}},C=async()=>{x?w(!1):(w(!0),await N())},P=async()=>{s(!0),r("");try{await M.approveProposal(e.id);try{if(c===null){const B=await M.getAttestationIntent(e.authorizationId);if(B){const _=await M.decryptIntent({intentCiphertext:B.intentCiphertext,encryptedKey:B.encryptedKey,approverId:t});u(_),await M.storeApprovedIntent(e.authorizationId,_)}}else await M.storeApprovedIntent(e.authorizationId,c)}catch{}r(`Approved. ${I-1>0?`${I-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(B){r(B instanceof Error?B.message:"Approval failed")}finally{s(!1)}},H=async()=>{const B=prompt("Rejection reason (optional):");if(B!==null){l(!0),r("");try{await M.rejectProposal(e.id,B||void 0),r("Action rejected."),n()}catch(_){r(_ instanceof Error?_.message:"Rejection failed")}finally{l(!1)}}},W=a||i;return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Ee(e.profileId)}),o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const B=Wf(e.expiresAt,Date.now());return o.jsx("span",{style:{fontSize:"0.72rem",color:B.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:B.urgent?600:400,whiteSpace:"nowrap"},children:B.label})})(),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ty(e.createdAt)})]})]}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[E," of ",g.length," approver",g.length===1?"":"s"," signed off",g.map(B=>{const _=B in S;return o.jsxs("span",{style:{marginLeft:"0.5rem",color:_?"var(--success, green)":"var(--text-tertiary)"},children:[_?"✓":"○"," ",B===t?"You":B]},B)})]}),o.jsxs("div",{style:{marginBottom:"0.5rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),o.jsx("code",{style:{fontSize:"0.85rem"},children:j})]}),h.length>0&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Arguments"}),o.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:h.map(([B,_])=>o.jsxs(d.Fragment,{children:[o.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:B}),o.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:yi(_)})]},B))})]}),m.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:m.map(([B,_])=>`${B}=${yi(_)}`).join(" · ")}),o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:C,disabled:p,children:[x?"▲ Hide intent":"▼ Show intent",p&&" (decrypting...)"]}),x&&o.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:v?o.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:v}):c!==null?o.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:c}):o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this authority."})})]}),!k&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:P,disabled:W,children:a?"Approving...":"Approve"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:H,disabled:W,children:i?"Rejecting...":"Reject"})]}),k&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),o.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})}function _y(){const{domain:e,user:t}=ze(),n=(t==null?void 0:t.id)??"",[r,a]=d.useState("awaiting-me"),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(""),f=d.useCallback(async()=>{try{const A=await M.getProposalsForApprover();i(A)}catch{}finally{c(!1)}},[]);fe("proposal-added",f),fe("proposal-approved",f),fe("proposal-rejected",f),fe("proposal-resolved",f),Mt(f,3e4);const[v,y]=d.useState([]),x=d.useCallback(async()=>{try{const A=await M.getProposals(e||"owner");y(A)}catch{}},[e]);fe("proposal-added",x),fe("proposal-approved",x),fe("proposal-rejected",x),fe("proposal-resolved",x),Mt(x,3e4,e);const w=d.useMemo(()=>v.filter(A=>{var T;return A.status==="pending"&&(((T=A.pendingApprovers)==null?void 0:T.length)??0)===0}),[v]),j=d.useMemo(()=>Qc(w,[],{status:"pending"}),[w]),[h,m]=d.useState([]),g=d.useCallback(async()=>{if(n)try{const T=(await M.getProposals(e||"owner")).filter(Y=>Y.status==="pending"&&Y.pendingApprovers&&Y.pendingApprovers.includes(n)&&Y.approvedBy&&n in Y.approvedBy);m(T)}catch{}},[n,e]);fe("proposal-approved",g),fe("proposal-rejected",g),Mt(g,3e4,`${n}:${e}`),d.useEffect(()=>{f(),x(),g()},[]);const[S,E]=d.useState([]),[I,k]=d.useState([]),[N,C]=d.useState(!0),[P,H]=d.useState(null),[W,B]=d.useState(""),[_,D]=d.useState("pending"),[X,oe]=d.useState(null),[z,R]=d.useState(!1),$=d.useCallback(async()=>{try{const{proposals:A,receipts:T}=await M.getThread({domain:e,status:_,sinceDays:7});E(A),k(T)}catch{}finally{C(!1)}},[e,_]);Mt($,3e4,`${e}:${_}`);const L=async(A,T)=>{H(A),B("");try{const Y=e||"owner",xe=await M.resolveProposal(A,T,Y);B(T==="commit"?`Action approved. Status: ${xe.status}`:"Action rejected."),await Promise.all([$(),x()])}catch(Y){B(Y instanceof Error?Y.message:"Failed")}finally{H(null)}},V=d.useMemo(()=>{const A=new Set;for(const T of S)A.add(T.profileId);for(const T of I)A.add(T.profileId);return Array.from(A).sort()},[S,I]),ee=d.useMemo(()=>Qc(S,I,{status:_,profile:X??void 0,includeAutonomous:z}),[S,I,_,X,z]),J=d.useCallback(()=>{f(),g()},[f,g]),je=d.useMemo(()=>{const A=new Set,T=[];for(const Y of h)A.has(Y.id)||(A.add(Y.id),T.push(Y));return T.sort((Y,xe)=>xe.createdAt-Y.createdAt)},[h]),b=s.length+j.length,U=je.length;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Pending Approvals"}),o.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),o.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[o.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>a("awaiting-me"),children:["Awaiting me ",b>0&&o.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:b})]}),o.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",U>0&&o.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:U})]}),o.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),$()},children:"All"})]}),r==="awaiting-me"&&o.jsx(o.Fragment,{children:l&&b===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):b===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(u||W)&&o.jsx("div",{className:"alert alert-success",children:u||W}),j.map(A=>o.jsx(Jc,{item:A,onApprove:T=>L(T,"commit"),onReject:T=>L(T,"reject"),resolving:P===A.id},A.id)),s.map(A=>o.jsx(Ry,{proposal:A,currentUserId:n,onAction:J,onMessage:p},A.id))]})}),r==="awaiting-others"&&o.jsx(o.Fragment,{children:je.length===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:je.map(A=>o.jsx($y,{proposal:A,currentUserId:n,onCancel:async()=>{try{await M.rejectProposal(A.id,"cancelled by creator"),g(),x()}catch(T){alert(T instanceof Error?T.message:"Cancel failed")}}},A.id))})}),r==="all"&&o.jsxs(o.Fragment,{children:[W&&o.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:W}),o.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[o.jsx("button",{className:`filter-chip ${_==="pending"?"selected":""}`,onClick:()=>D("pending"),children:"Pending"}),o.jsx("button",{className:`filter-chip ${_==="all"?"selected":""}`,onClick:()=>D("all"),children:"All"}),V.length>0&&o.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),V.map(A=>o.jsx("button",{className:`filter-chip ${X===A?"selected":""}`,onClick:()=>oe(X===A?null:A),children:Ee(A)},A)),_==="all"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),o.jsxs("button",{className:`filter-chip ${z?"selected":""}`,onClick:()=>R(!z),title:"Include actions executed without human review (automatic commitment mode)",children:[z?"✓ ":"","Autonomous actions"]})]})]}),N&&ee.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ee.length===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:_==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:_==="pending"?"Your agents are operating within their authorizations. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:ee.map(A=>o.jsx(Jc,{item:A,onApprove:T=>L(T,"commit"),onReject:T=>L(T,"reject"),resolving:P===A.id},A.id))})]})]})}function Ay(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function $y({proposal:e,currentUserId:t,onCancel:n}){var u;const[r,a]=d.useState(!1),s=Object.keys(e.approvedBy??{}),i=(e.pendingApprovers??[]).filter(p=>!(p in(e.approvedBy??{}))),l=(((u=e.pendingApprovers)==null?void 0:u.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}};return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Ee(e.profileId)}),l&&o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),o.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ay(e.createdAt)})]}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:o.jsx("code",{children:e.tool.split("__").pop()??e.tool})}),l&&o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[s.map(p=>o.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:p===t?"You approved":`${p} approved`},p)),i.map(p=>o.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",p===t?"you":p]},p))]}),o.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const Ly=`# Agent Brief
70
+
71
+ You act on my behalf through Suveren — the gateway that gates every
72
+ privileged tool call you make. Suveren implements the bounded-authority
73
+ model from the open Human Agency Protocol (HAP): each authorization
74
+ describes an area of authority, a set of numeric limits, and a scope.
75
+ Operate inside those bounds or the Gatekeeper will reject your action.
76
+
77
+ ## Before you act in a domain
78
+
79
+ 1. Call \`list-authorizations(domain: "<domain>")\` to load the full
80
+ intent, scope, and usage for that area. The session brief shows only
81
+ a one-line summary per authority — the Intent paragraph lives behind
82
+ that call, and often contains soft rules you MUST honor (e.g. "never
83
+ publish on weekends", "only reply in English").
84
+ 2. If the action would exceed a bound or fall outside the scope, stop
85
+ and explain what would be blocked instead of trying.
86
+ 3. If you're not sure whether an action is covered, ask me first.
87
+
88
+ ## How to handle reviews
89
+
90
+ Authorizations in review mode require my approval before the action
91
+ executes. When you propose an action:
92
+ - Include everything I need to judge it (title, recipients, amounts,
93
+ dates, attendees) in the tool arguments.
94
+ - Don't batch unrelated proposals — one proposal per decision.
95
+
96
+ ## Standing orders
97
+
98
+ (Add your own here. Examples:)
99
+
100
+ - Every morning, summarize today's calendar and flag conflicts.
101
+ - On Fridays, give me a weekly review: what's done, what slipped, what's
102
+ next.
103
+ - Never email anyone outside the company without asking first.
104
+ - When drafting posts, prefer plain language over marketing copy.
105
+ `;function My(){const[e,t]=d.useState(""),[n,r]=d.useState(""),[a,s]=d.useState(!0),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(!1),v=e!==n,y=new Blob([e]).size,x=16*1024;d.useEffect(()=>{if(!v)return;const m=S=>{S.preventDefault(),S.returnValue=""},g=S=>{var k,N;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const E=(N=(k=S.target)==null?void 0:k.closest)==null?void 0:N.call(k,"a");if(!E||!E.href)return;let I;try{I=new URL(E.href)}catch{return}I.origin===window.location.origin&&I.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",m),document.addEventListener("click",g,!0),()=>{window.removeEventListener("beforeunload",m),document.removeEventListener("click",g,!0)}},[v]),d.useEffect(()=>{let m=!1;return M.getAgentContext().then(g=>{m||(t(g),r(g))}).catch(g=>{m||u({kind:"error",text:g instanceof Error?g.message:"Failed to load context"})}).finally(()=>{m||s(!1)}),()=>{m=!0}},[]);const w=async()=>{l(!0),u(null);try{await M.saveAgentContext(e),r(e),u({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(m){u({kind:"error",text:m instanceof Error?m.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),u(null)},h=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(Ly)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Agent Brief"}),o.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!a&&o.jsx("button",{className:"btn btn-primary btn-sm",onClick:h,disabled:i,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&o.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),o.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[o.jsx("div",{className:"card intent-pane chat",children:o.jsx(vo,{target:{kind:"context"},currentText:e,onApply:m=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(m)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),o.jsxs("div",{className:"card intent-pane document",children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[o.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),o.jsxs("span",{style:{fontSize:"0.75rem",color:y>x?"var(--danger)":"var(--text-muted)"},children:[y.toLocaleString()," / ",x.toLocaleString()," bytes"]})]}),o.jsx("textarea",{className:"form-textarea",value:e,onChange:m=>t(m.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),o.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i||!v,children:"Revert"}),o.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:w,disabled:i||!v||y>x||a,children:i?"Saving…":"Save"})]})]}),o.jsx("button",{type:"button",className:"floating-help",onClick:()=>f(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),o.jsx(Ff,{open:p,onClose:()=>f(!1),ariaLabel:"Brief assistant",children:o.jsx(vo,{target:{kind:"context"},currentText:e,onApply:m=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(m),f(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Fy({children:e}){const{user:t,mode:n,domain:r}=ze();return t?n==="team"&&!r?o.jsx(Jt,{to:"/onboarding",replace:!0}):o.jsx(o.Fragment,{children:e}):o.jsx(Jt,{to:"/login",replace:!0})}function Oy(){const{user:e}=ze();return o.jsxs(gg,{children:[o.jsx(Ce,{path:"/login",element:e?o.jsx(Jt,{to:"/",replace:!0}):o.jsx(vv,{})}),o.jsx(Ce,{path:"/onboarding",element:e?o.jsx(yv,{}):o.jsx(Jt,{to:"/login",replace:!0})}),o.jsxs(Ce,{element:o.jsx(Fy,{children:o.jsx(gv,{})}),children:[o.jsx(Ce,{path:"/",element:o.jsx(kv,{})}),o.jsx(Ce,{path:"/agent/new",element:o.jsx(Jt,{to:"/authorizations?new=1",replace:!0})}),o.jsx(Ce,{path:"/agent/gate",element:o.jsx(Gv,{})}),o.jsx(Ce,{path:"/agent/review",element:o.jsx(Xv,{})}),o.jsx(Ce,{path:"/integrations",element:o.jsx(ey,{})}),o.jsx(Ce,{path:"/groups",element:o.jsx(ty,{})}),o.jsx(Ce,{path:"/authorizations",element:o.jsx(py,{})}),o.jsx(Ce,{path:"/audit",element:o.jsx(yy,{})}),o.jsx(Ce,{path:"/proposals",element:o.jsx(_y,{})}),o.jsx(Ce,{path:"/agent-brief",element:o.jsx(My,{})}),o.jsx(Ce,{path:"/settings",element:o.jsx(xy,{})}),o.jsx(Ce,{path:"/settings/services",element:o.jsx(Jt,{to:"/settings",replace:!0})}),o.jsx(Ce,{path:"/deploy",element:o.jsx(Jt,{to:"/integrations",replace:!0})})]}),o.jsx(Ce,{path:"*",element:o.jsx(Jt,{to:"/",replace:!0})})]})}function By(){return o.jsx(Dg,{children:o.jsx(Xg,{children:o.jsx(qg,{children:o.jsx(Oy,{})})})})}df(document.getElementById("root")).render(o.jsx(d.StrictMode,{children:o.jsx(By,{})}));